diff --git a/src/group.h b/src/group.h index 91ee77e601..053aeb1594 100644 --- a/src/group.h +++ b/src/group.h @@ -93,6 +93,11 @@ static inline bool IsAllGroupID(GroupID id_g) return id_g == ALL_GROUP; } +static inline bool IsTopLevelGroupID(GroupID index) +{ + return index == DEFAULT_GROUP || index == ALL_GROUP; +} + #define FOR_ALL_GROUPS_FROM(var, start) FOR_ALL_ITEMS_FROM(Group, group_index, var, start) #define FOR_ALL_GROUPS(var) FOR_ALL_GROUPS_FROM(var, 0) diff --git a/src/group_gui.cpp b/src/group_gui.cpp index b12c4ce92c..ec7fd4c73f 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -548,7 +548,7 @@ public: /* Disable all lists management button when the list is empty */ this->SetWidgetDisabledState(WID_GL_MANAGE_VEHICLES_DROPDOWN, !this->ShouldShowActionDropdownList() || _local_company != this->vli.company); - this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_company != this->vli.company, + this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_company != this->vli.company || (IsTopLevelGroupID(this->vli.index) && _settings_client.gui.disable_top_veh_list_mass_actions), WID_GL_STOP_ALL, WID_GL_START_ALL, WIDGET_LIST_END); @@ -817,7 +817,8 @@ public: break; case WID_GL_MANAGE_VEHICLES_DROPDOWN: { - DropDownList *list = this->BuildActionDropdownList(true, Group::IsValidID(this->vli.index), this->vli.vtype == VEH_TRAIN); + DropDownList *list = this->BuildActionDropdownList(true, Group::IsValidID(this->vli.index), this->vli.vtype == VEH_TRAIN, + 0, false, IsTopLevelGroupID(this->vli.index)); ShowDropDownList(this, list, -1, WID_GL_MANAGE_VEHICLES_DROPDOWN); break; } diff --git a/src/lang/english.txt b/src/lang/english.txt index b620592b9c..a4ad2d453f 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1322,6 +1322,8 @@ STR_CONFIG_SETTING_SHOW_VEH_LIST_CARGO_FILTER :Show cargo type 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_SHOW_ADV_LOADING_MODE_FEATURES :Show advanced loading mode features: {STRING2} STR_CONFIG_SETTING_SHOW_ADV_LOADING_MODE_FEATURES_HELPTEXT :Show advanced loading mode features (through load/unload). When disabled, some advanced loading mode features are not shown in the UI, but are still available to all players. +STR_CONFIG_SETTING_DISABLE_TOP_VEH_LIST_MASS_ACTIONS :Disable mass action buttons for top-level vehicle lists +STR_CONFIG_SETTING_DISABLE_TOP_VEH_LIST_MASS_ACTIONS_HELPTEXT :This disables depot/service and start/stop buttons for all vehicle and all ungrouped vehicle lists. This is intended to help avoid the negative impact of accidentally pressing one of these buttons. 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 diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 5778d2513a..479bcf84fc 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1610,6 +1610,7 @@ static SettingsContainer &GetSettingsTree() interface->Add(new SettingEntry("gui.show_vehicle_list_company_colour")); interface->Add(new SettingEntry("gui.show_veh_list_cargo_filter")); interface->Add(new SettingEntry("gui.show_adv_load_mode_features")); + interface->Add(new SettingEntry("gui.disable_top_veh_list_mass_actions")); } SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS)); diff --git a/src/settings_type.h b/src/settings_type.h index 356b6ccd3d..dbc2ea1c26 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -180,6 +180,7 @@ struct GUISettings { bool show_vehicle_list_company_colour; ///< show the company colour of vehicles which have an owner different to the owner of the vehicle list bool enable_single_veh_shared_order_gui; ///< enable showing a single vehicle in the shared order GUI window bool show_adv_load_mode_features; ///< enable advanced loading mode features in UI + bool disable_top_veh_list_mass_actions; ///< disable mass actions buttons for non-group vehicle lists uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity. uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed. diff --git a/src/table/settings.ini b/src/table/settings.ini index e3ebab3358..5cddf86391 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -4148,6 +4148,15 @@ str = STR_CONFIG_SETTING_SHOW_ADV_LOADING_MODE_FEATURES strhelp = STR_CONFIG_SETTING_SHOW_ADV_LOADING_MODE_FEATURES_HELPTEXT cat = SC_EXPERT +[SDTC_BOOL] +var = gui.disable_top_veh_list_mass_actions +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = false +str = STR_CONFIG_SETTING_DISABLE_TOP_VEH_LIST_MASS_ACTIONS +strhelp = STR_CONFIG_SETTING_DISABLE_TOP_VEH_LIST_MASS_ACTIONS_HELPTEXT +proc = RedrawScreen +cat = SC_EXPERT + ; For the dedicated build we'll enable dates in logs by default. [SDTC_BOOL] ifdef = DEDICATED diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 417dd3724f..d904ce8850 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -311,18 +311,19 @@ bool BaseVehicleListWindow::ShouldShowActionDropdownList() const * @return Itemlist for dropdown */ DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autoreplace, bool show_group, bool show_template_replace, - StringID change_order_str, bool show_create_group) + StringID change_order_str, bool show_create_group, bool consider_top_level) { DropDownList *list = new DropDownList(); bool disable = this->vehicles.Length() == 0; + bool mass_action_disable = disable || (_settings_client.gui.disable_top_veh_list_mass_actions && consider_top_level); if (show_autoreplace) *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, disable); if (show_autoreplace && show_template_replace) { *list->Append() = new DropDownListStringItem(STR_TMPL_TEMPLATE_REPLACEMENT, ADI_TEMPLATE_REPLACE, disable); } - *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, disable); - *list->Append() = new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, disable); - *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_CANCEL_DEPOT_SERVICE, ADI_CANCEL_DEPOT, disable); + *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, mass_action_disable); + *list->Append() = new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, mass_action_disable); + *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_CANCEL_DEPOT_SERVICE, ADI_CANCEL_DEPOT, mass_action_disable); if (show_group) { *list->Append() = new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE, ADI_ADD_SHARED, disable); @@ -1870,7 +1871,7 @@ public: if (this->owner == _local_company) { this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VL_STANDARD); this->SetWidgetDisabledState(WID_VL_MANAGE_VEHICLES_DROPDOWN, !this->ShouldShowActionDropdownList()); - this->SetWidgetsDisabledState(this->vehicles.Length() == 0, + this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || (this->vli.type == VL_STANDARD && _settings_client.gui.disable_top_veh_list_mass_actions), WID_VL_STOP_ALL, WID_VL_START_ALL, WIDGET_LIST_END); @@ -1915,8 +1916,9 @@ public: break; case WID_VL_MANAGE_VEHICLES_DROPDOWN: { - DropDownList *list = this->BuildActionDropdownList(VehicleListIdentifier::UnPack(this->window_number).type == VL_STANDARD, false, - this->vli.vtype == VEH_TRAIN, this->GetChangeOrderStringID(), true); + VehicleListIdentifier vli = VehicleListIdentifier::UnPack(this->window_number); + DropDownList *list = this->BuildActionDropdownList(vli.type == VL_STANDARD, false, + this->vli.vtype == VEH_TRAIN, this->GetChangeOrderStringID(), true, vli.type == VL_STANDARD); ShowDropDownList(this, list, -1, WID_VL_MANAGE_VEHICLES_DROPDOWN); break; } diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h index 92de1dd72c..469913e2e1 100644 --- a/src/vehicle_gui_base.h +++ b/src/vehicle_gui_base.h @@ -73,7 +73,7 @@ struct BaseVehicleListWindow : public Window { 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); + StringID change_order_str = 0, bool show_create_group = false, bool consider_top_level = false); bool ShouldShowActionDropdownList() const; };