Require map generators to specify valid tilesets.

This commit is contained in:
Paul Chote
2025-04-26 13:29:03 +01:00
committed by Gustas Kažukauskas
parent c41a1302b6
commit e5ffed2a4f
6 changed files with 18 additions and 2 deletions

View File

@@ -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 */ }

View File

@@ -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)
{

View File

@@ -988,6 +988,7 @@ namespace OpenRA.Mods.Common.Traits
public interface IEditorMapGeneratorInfo : IMapGeneratorInfo
{
string[] Tilesets { get; }
IMapGeneratorSettings GetSettings();
}
}

View File

@@ -29,6 +29,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var tools = world.Map.Rules.Actors[SystemActors.EditorWorld].TraitInfos<IEditorToolInfo>();
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));

View File

@@ -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

View File

@@ -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