Require map generators to specify valid tilesets.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
c41a1302b6
commit
e5ffed2a4f
@@ -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 */ }
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -988,6 +988,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public interface IEditorMapGeneratorInfo : IMapGeneratorInfo
|
||||
{
|
||||
string[] Tilesets { get; }
|
||||
IMapGeneratorSettings GetSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user