diff --git a/Resources/EnginePrototypes/entityCategory.yml b/Resources/EnginePrototypes/entityCategory.yml index 28e629b9e9a..1e4fe750bf5 100644 --- a/Resources/EnginePrototypes/entityCategory.yml +++ b/Resources/EnginePrototypes/entityCategory.yml @@ -18,3 +18,9 @@ description: entity-category-desc-hide hideSpawnMenu: true inheritable: false + +# Entity prototypes added by the fork. With CVar you can hide all entities without this category +- type: entityCategory + id: ForkFiltered + name: entity-category-name-fork + description: entity-category-desc-fork \ No newline at end of file diff --git a/Resources/Locale/en-US/entity-category.ftl b/Resources/Locale/en-US/entity-category.ftl index dfdba8fbab3..5ce5aaebeb4 100644 --- a/Resources/Locale/en-US/entity-category.ftl +++ b/Resources/Locale/en-US/entity-category.ftl @@ -7,3 +7,6 @@ entity-category-desc-spawner = Entity prototypes that spawn other entities. entity-category-name-hide = Hidden entity-category-desc-hide = Entity prototypes that should be hidden from entity spawn menus + +entity-category-name-fork = Fork Filtered +entity-category-desc-fork = Entity prototypes added by the fork. With CVar you can hide all entities without this category \ No newline at end of file diff --git a/Robust.Client/UserInterface/Controllers/Implementations/EntitySpawningUIController.cs b/Robust.Client/UserInterface/Controllers/Implementations/EntitySpawningUIController.cs index 70eab2f376e..5b89262c397 100644 --- a/Robust.Client/UserInterface/Controllers/Implementations/EntitySpawningUIController.cs +++ b/Robust.Client/UserInterface/Controllers/Implementations/EntitySpawningUIController.cs @@ -7,6 +7,8 @@ using Robust.Client.ResourceManagement; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; +using Robust.Shared; +using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.IoC; using Robust.Shared.Prototypes; @@ -19,6 +21,7 @@ namespace Robust.Client.UserInterface.Controllers.Implementations; public sealed class EntitySpawningUIController : UIController { + [Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IPlacementManager _placement = default!; [Dependency] private readonly IPrototypeManager _prototypes = default!; @@ -192,6 +195,9 @@ private void BuildEntityList(string? searchStr = null) _window.SelectedButton = null; searchStr = searchStr?.ToLowerInvariant(); + var categoryFilter = _cfg.GetCVar(CVars.EntitiesCategoryFilter); + _prototypes.TryIndex(categoryFilter, out var filter); + foreach (var prototype in _prototypes.EnumeratePrototypes()) { if (prototype.Abstract) @@ -204,6 +210,11 @@ private void BuildEntityList(string? searchStr = null) continue; } + if (filter is not null && !prototype.Categories.Contains(filter)) + { + continue; + } + if (searchStr != null && !DoesEntityMatchSearch(prototype, searchStr)) { continue; diff --git a/Robust.Shared/CVars.cs b/Robust.Shared/CVars.cs index 8228eb19228..c57b3ea6909 100644 --- a/Robust.Shared/CVars.cs +++ b/Robust.Shared/CVars.cs @@ -683,6 +683,13 @@ protected CVars() public static readonly CVarDef BuildManifestHash = CVarDef.Create("build.manifest_hash", ""); + /// + /// Allows you to disable the display of all entities in the spawn menu that are not labeled with the ShowSpawnMenu category. + /// This is useful for forks that just want to disable the standard upstream content + /// + public static readonly CVarDef EntitiesCategoryFilter = + CVarDef.Create("build.entities_category_filter", ""); + /* * WATCHDOG */