diff --git a/OpenRA.Mods.Common/Traits/World/ClearMapGenerator.cs b/OpenRA.Mods.Common/Traits/World/ClearMapGenerator.cs index 4b8cf4bc95..63a40590ed 100644 --- a/OpenRA.Mods.Common/Traits/World/ClearMapGenerator.cs +++ b/OpenRA.Mods.Common/Traits/World/ClearMapGenerator.cs @@ -32,6 +32,10 @@ namespace OpenRA.Mods.Common.Traits [Desc("Internal id for this map generator.")] public readonly string Type = null; + [FieldLoader.Require] + [Desc("Tilesets that are compatible with this map generator.")] + public readonly string[] Tilesets = null; + [FluentReference] [Desc("The title to use for generated maps.")] public readonly string MapTitle = "label-random-map"; @@ -115,6 +119,7 @@ namespace OpenRA.Mods.Common.Traits string IEditorToolInfo.Label => Name; string IEditorToolInfo.PanelWidget => PanelWidget; + string[] IEditorMapGeneratorInfo.Tilesets => Tilesets; } public class ClearMapGenerator { /* we're only interested in the Info */ } diff --git a/OpenRA.Mods.Common/Traits/World/ExperimentalMapGenerator.cs b/OpenRA.Mods.Common/Traits/World/ExperimentalMapGenerator.cs index f6b461ed0a..3519795107 100644 --- a/OpenRA.Mods.Common/Traits/World/ExperimentalMapGenerator.cs +++ b/OpenRA.Mods.Common/Traits/World/ExperimentalMapGenerator.cs @@ -32,6 +32,10 @@ namespace OpenRA.Mods.Common.Traits [FluentReference] public readonly string Name = null; + [FieldLoader.Require] + [Desc("Tilesets that are compatible with this map generator.")] + public readonly string[] Tilesets = null; + [FluentReference] [Desc("The title to use for generated maps.")] public readonly string MapTitle = "label-random-map"; @@ -50,6 +54,7 @@ namespace OpenRA.Mods.Common.Traits string IMapGeneratorInfo.Type => Type; string IMapGeneratorInfo.Name => Name; string IMapGeneratorInfo.MapTitle => MapTitle; + string[] IEditorMapGeneratorInfo.Tilesets => Tilesets; static MiniYaml SettingsLoader(MiniYaml my) { diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index da25b3203a..d5c35f99b9 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -988,6 +988,7 @@ namespace OpenRA.Mods.Common.Traits public interface IEditorMapGeneratorInfo : IMapGeneratorInfo { + string[] Tilesets { get; } IMapGeneratorSettings GetSettings(); } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapToolsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapToolsLogic.cs index c5eabb4189..763ccf78c3 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapToolsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapToolsLogic.cs @@ -29,6 +29,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var tools = world.Map.Rules.Actors[SystemActors.EditorWorld].TraitInfos(); foreach (var tool in tools) { + if (tool is IEditorMapGeneratorInfo gi && !gi.Tilesets.Contains(world.Map.Tileset)) + continue; + var panel = Game.LoadWidget(world, tool.PanelWidget, widget, new WidgetArgs() { { "tool", tool } }); toolPanels.Add(panel); toolLabels.Add(panel, FluentProvider.GetMessage(tool.Label)); diff --git a/mods/cnc/rules/map-generators.yaml b/mods/cnc/rules/map-generators.yaml index bbabe7126c..733e7b7d6f 100644 --- a/mods/cnc/rules/map-generators.yaml +++ b/mods/cnc/rules/map-generators.yaml @@ -2,6 +2,7 @@ ExperimentalMapGenerator@experimental: Type: experimental Name: map-generator-experimental + Tilesets: DESERT, SNOW, TEMPERAT, WINTER Settings: MultiChoiceOption@hidden_defaults: Choice@hidden_defaults: @@ -439,16 +440,15 @@ ClearMapGenerator@clear: Type: clear Name: map-generator-clear + Tilesets: DESERT, SNOW, TEMPERAT, WINTER Settings: MultiChoiceOption@Tile: Label: label-clear-map-generator-option-tile Choice@CommonClear: Label: label-clear-map-generator-choice-tile-clear - Tileset: DESERT,SNOW,TEMPERAT,WINTER Settings: Tile: 255 Choice@CommonWater: Label: label-clear-map-generator-choice-tile-water - Tileset: DESERT,SNOW,TEMPERAT,WINTER Settings: Tile: 1 diff --git a/mods/ra/rules/map-generators.yaml b/mods/ra/rules/map-generators.yaml index a22b684175..5912e2a51a 100644 --- a/mods/ra/rules/map-generators.yaml +++ b/mods/ra/rules/map-generators.yaml @@ -2,6 +2,7 @@ ExperimentalMapGenerator@experimental: Type: experimental Name: map-generator-experimental + Tilesets: DESERT, SNOW, TEMPERAT Settings: MultiChoiceOption@hidden_defaults: Choice@hidden_defaults: @@ -463,6 +464,7 @@ ClearMapGenerator@clear: Type: clear Name: map-generator-clear + Tilesets: DESERT, SNOW, TEMPERAT, INTERIOR Settings: MultiChoiceOption@Tile: Label: label-clear-map-generator-option-tile