Add UI setting to control whether cargo filter drop down is shown

pull/28/head
Jonathan G Rennison 7 years ago
parent f3c95dd9a7
commit 097cf9b0b1

@ -33,7 +33,6 @@
#include "table/sprites.h"
#include "safeguards.h"
//#include "engine_gui.h"
static const int LEVEL_WIDTH = 10; ///< Indenting width of a sub-group in pixels
@ -81,7 +80,9 @@ static const NWidgetPart _nested_group_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GL_SORT_BY_ORDER), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_SORT_BY_DROPDOWN), SetMinimalSize(167, 12), SetDataTip(0x0, STR_TOOLTIP_SORT_CRITERIA),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_FILTER_BY_CARGO), SetMinimalSize(167, 12), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_FILTER_CRITERIA),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_FILTER_BY_CARGO_SEL),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_FILTER_BY_CARGO), SetMinimalSize(167, 12), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_FILTER_CRITERIA),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(12, 12), SetResize(1, 0), EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
@ -356,6 +357,8 @@ public:
{
this->CreateNestedTree();
this->CheckCargoFilterEnableState(WID_GL_FILTER_BY_CARGO_SEL, false);
this->vscroll = this->GetScrollbar(WID_GL_LIST_VEHICLE_SCROLLBAR);
this->group_sb = this->GetScrollbar(WID_GL_LIST_GROUP_SCROLLBAR);
@ -488,6 +491,9 @@ public:
this->vli.index = ALL_GROUP;
HideDropDownMenu(this);
}
this->CheckCargoFilterEnableState(WID_GL_FILTER_BY_CARGO_SEL, true);
this->SetDirty();
}

@ -1318,6 +1318,8 @@ STR_CONFIG_SETTING_SHOW_ADV_TRACE_RESTRICT_FEATURES :Show advanced r
STR_CONFIG_SETTING_SHOW_ADV_TRACE_RESTRICT_FEATURES_HELPTEXT :Show advanced routing restriction features. When disabled, some advanced features are not shown in the UI, but are still available to all players.
STR_CONFIG_SETTING_SHOW_PROGSIG_FEATURES :Show programmable signal feature: {STRING2}
STR_CONFIG_SETTING_SHOW_PROGSIG_FEATURES_HELPTEXT :Show programmable signal feature. When disabled, the buttons to build and configure programmable signals are not shown in the UI, but are still available to all players.
STR_CONFIG_SETTING_SHOW_VEH_LIST_CARGO_FILTER :Show cargo type filter in vehicle lists: {STRING2}
STR_CONFIG_SETTING_SHOW_VEH_LIST_CARGO_FILTER_HELPTEXT :Show cargo type filter in vehicle lists. When enabled vehicle list windows include an additional filter dropdown.
STR_CONFIG_SETTING_LANDSCAPE :Landscape: {STRING2}
STR_CONFIG_SETTING_LANDSCAPE_HELPTEXT :Landscapes define basic gameplay scenarios with different cargos and town growth requirements. NewGRF and Game Scripts allow finer control though

@ -1069,6 +1069,17 @@ static bool ProgrammableSignalsShownChanged(int32)
return true;
}
static bool VehListCargoFilterShownChanged(int32)
{
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS, 0);
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
return true;
}
static bool TownFoundingChanged(int32 p1)
{
if (_game_mode != GM_EDITOR && _settings_game.economy.found_town == TF_FORBIDDEN) {

@ -1608,6 +1608,7 @@ static SettingsContainer &GetSettingsTree()
interface->Add(new SettingEntry("gui.show_train_weight_ratios_in_details"));
interface->Add(new SettingEntry("gui.show_vehicle_group_in_details"));
interface->Add(new SettingEntry("gui.show_vehicle_list_company_colour"));
interface->Add(new SettingEntry("gui.show_veh_list_cargo_filter"));
}
SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));

@ -174,6 +174,7 @@ struct GUISettings {
bool show_restricted_signal_default; ///< Show restricted electric signals using the default sprite
bool show_adv_tracerestrict_features; ///< Show advanced trace restrict features in UI
bool show_progsig_ui; ///< Show programmable signals feature in UI
bool show_veh_list_cargo_filter; ///< Show cargo list filter in UI
uint8 osk_activation; ///< Mouse gesture to trigger the OSK.
bool show_vehicle_route_steps; ///< when a window related to a specific vehicle is focused, show route steps
bool show_vehicle_list_company_colour; ///< show the company colour of vehicles which have an owner different to the owner of the vehicle list

@ -25,6 +25,7 @@ static bool TrainSlopeSteepnessChanged(int32 p1);
static bool RoadVehSlopeSteepnessChanged(int32 p1);
static bool DragSignalsDensityChanged(int32);
static bool ProgrammableSignalsShownChanged(int32);
static bool VehListCargoFilterShownChanged(int32);
static bool TownFoundingChanged(int32 p1);
static bool DifficultyNoiseChange(int32 i);
static bool MaxNoAIsChange(int32 i);
@ -4122,6 +4123,14 @@ strhelp = STR_CONFIG_SETTING_SHOW_PROGSIG_FEATURES_HELPTEXT
proc = ProgrammableSignalsShownChanged
cat = SC_ADVANCED
[SDTC_BOOL]
var = gui.show_veh_list_cargo_filter
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = true
str = STR_CONFIG_SETTING_SHOW_VEH_LIST_CARGO_FILTER
strhelp = STR_CONFIG_SETTING_SHOW_VEH_LIST_CARGO_FILTER_HELPTEXT
proc = VehListCargoFilterShownChanged
[SDTC_BOOL]
var = gui.enable_single_veh_shared_order_gui
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC

@ -2597,6 +2597,7 @@ enum TraceRestrictSlotWindowWidgets {
WID_TRSL_SORT_BY_ORDER,
WID_TRSL_SORT_BY_DROPDOWN,
WID_TRSL_FILTER_BY_CARGO,
WID_TRSL_FILTER_BY_CARGO_SEL,
WID_TRSL_LIST_VEHICLE,
WID_TRSL_LIST_VEHICLE_SCROLLBAR,
};
@ -2637,7 +2638,9 @@ static const NWidgetPart _nested_slot_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TRSL_SORT_BY_ORDER), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_TRSL_SORT_BY_DROPDOWN), SetMinimalSize(167, 12), SetDataTip(0x0, STR_TOOLTIP_SORT_CRITERIA),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_TRSL_FILTER_BY_CARGO), SetMinimalSize(167, 12), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_FILTER_CRITERIA),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_TRSL_FILTER_BY_CARGO_SEL),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_TRSL_FILTER_BY_CARGO), SetMinimalSize(167, 12), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_FILTER_CRITERIA),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(12, 12), SetResize(1, 0), EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
@ -2780,6 +2783,8 @@ public:
{
this->CreateNestedTree();
this->CheckCargoFilterEnableState(WID_TRSL_FILTER_BY_CARGO_SEL, false);
this->vscroll = this->GetScrollbar(WID_TRSL_LIST_VEHICLE_SCROLLBAR);
this->slot_sb = this->GetScrollbar(WID_TRSL_LIST_SLOTS_SCROLLBAR);
this->sorting = &_sorting.train;
@ -2878,6 +2883,9 @@ public:
if (this->vli.index != ALL_TRAINS_TRACE_RESTRICT_SLOT_ID && !TraceRestrictSlot::IsValidID(this->vli.index)) {
this->vli.index = ALL_TRAINS_TRACE_RESTRICT_SLOT_ID;
}
if (gui_scope) this->CheckCargoFilterEnableState(WID_TRSL_FILTER_BY_CARGO_SEL, true);
this->SetDirty();
}

@ -237,6 +237,16 @@ void BaseVehicleListWindow::OnInit()
this->SetCargoFilterArray();
}
void BaseVehicleListWindow::CheckCargoFilterEnableState(int plane_widget, bool re_init, bool possible)
{
NWidgetStacked *sel = this->GetWidget<NWidgetStacked>(plane_widget);
const int plane = (possible && _settings_client.gui.show_veh_list_cargo_filter) ? 0 : SZSP_NONE;
if (plane != sel->shown_plane) {
sel->SetDisplayedPlane(plane);
if (re_init) this->ReInit();
}
}
/**
* Compute the size for the Action dropdown.
* @param show_autoreplace If true include the autoreplace item.
@ -1695,7 +1705,7 @@ public:
this->CreateNestedTree();
this->GetWidget<NWidgetStacked>(WID_VL_FILTER_BY_CARGO_SEL)->SetDisplayedPlane((this->vli.type == VL_SHARED_ORDERS || this->vli.type == VL_SINGLE_VEH) ? SZSP_NONE : 0);
this->CheckCargoFilterEnableState(WID_VL_FILTER_BY_CARGO_SEL, false, this->vli.type != VL_SHARED_ORDERS && this->vli.type != VL_SINGLE_VEH);
this->vscroll = this->GetScrollbar(WID_VL_SCROLLBAR);
@ -2032,10 +2042,13 @@ public:
this->vehicles.ForceRebuild();
if (this->vli.type == VL_SHARED_ORDERS && !_settings_client.gui.enable_single_veh_shared_order_gui && this->vehicles.Length() == 1) {
delete this;
return;
}
} else {
this->vehicles.ForceResort();
}
this->CheckCargoFilterEnableState(WID_VL_FILTER_BY_CARGO_SEL, true, this->vli.type != VL_SHARED_ORDERS && this->vli.type != VL_SINGLE_VEH);
}
};

@ -68,6 +68,7 @@ struct BaseVehicleListWindow : public Window {
void SetCargoFilterArray();
void FilterVehicleList();
void OnInit() override;
void CheckCargoFilterEnableState(int plane_widget, bool re_init, bool possible = true);
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group, bool show_template_replace, StringID change_order_str = 0);
DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group, bool show_template_replace,
StringID change_order_str = 0, bool show_create_group = false);

@ -17,7 +17,8 @@ enum GroupListWidgets {
WID_GL_CAPTION, ///< Caption of the window.
WID_GL_SORT_BY_ORDER, ///< Sort order.
WID_GL_SORT_BY_DROPDOWN, ///< Sort by dropdown list.
WID_GL_FILTER_BY_CARGO, ///< Filter vehicled by cargo type.
WID_GL_FILTER_BY_CARGO, ///< Filter vehicle by cargo type.
WID_GL_FILTER_BY_CARGO_SEL, ///< Filter vehicle by cargo type panel selector.
WID_GL_LIST_VEHICLE, ///< List of the vehicles.
WID_GL_LIST_VEHICLE_SCROLLBAR, ///< Scrollbar for the list.
WID_GL_AVAILABLE_VEHICLES, ///< Available vehicles.

Loading…
Cancel
Save