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.")]
|
[Desc("Internal id for this map generator.")]
|
||||||
public readonly string Type = null;
|
public readonly string Type = null;
|
||||||
|
|
||||||
|
[FieldLoader.Require]
|
||||||
|
[Desc("Tilesets that are compatible with this map generator.")]
|
||||||
|
public readonly string[] Tilesets = null;
|
||||||
|
|
||||||
[FluentReference]
|
[FluentReference]
|
||||||
[Desc("The title to use for generated maps.")]
|
[Desc("The title to use for generated maps.")]
|
||||||
public readonly string MapTitle = "label-random-map";
|
public readonly string MapTitle = "label-random-map";
|
||||||
@@ -115,6 +119,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
string IEditorToolInfo.Label => Name;
|
string IEditorToolInfo.Label => Name;
|
||||||
string IEditorToolInfo.PanelWidget => PanelWidget;
|
string IEditorToolInfo.PanelWidget => PanelWidget;
|
||||||
|
string[] IEditorMapGeneratorInfo.Tilesets => Tilesets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ClearMapGenerator { /* we're only interested in the Info */ }
|
public class ClearMapGenerator { /* we're only interested in the Info */ }
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[FluentReference]
|
[FluentReference]
|
||||||
public readonly string Name = null;
|
public readonly string Name = null;
|
||||||
|
|
||||||
|
[FieldLoader.Require]
|
||||||
|
[Desc("Tilesets that are compatible with this map generator.")]
|
||||||
|
public readonly string[] Tilesets = null;
|
||||||
|
|
||||||
[FluentReference]
|
[FluentReference]
|
||||||
[Desc("The title to use for generated maps.")]
|
[Desc("The title to use for generated maps.")]
|
||||||
public readonly string MapTitle = "label-random-map";
|
public readonly string MapTitle = "label-random-map";
|
||||||
@@ -50,6 +54,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
string IMapGeneratorInfo.Type => Type;
|
string IMapGeneratorInfo.Type => Type;
|
||||||
string IMapGeneratorInfo.Name => Name;
|
string IMapGeneratorInfo.Name => Name;
|
||||||
string IMapGeneratorInfo.MapTitle => MapTitle;
|
string IMapGeneratorInfo.MapTitle => MapTitle;
|
||||||
|
string[] IEditorMapGeneratorInfo.Tilesets => Tilesets;
|
||||||
|
|
||||||
static MiniYaml SettingsLoader(MiniYaml my)
|
static MiniYaml SettingsLoader(MiniYaml my)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -988,6 +988,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public interface IEditorMapGeneratorInfo : IMapGeneratorInfo
|
public interface IEditorMapGeneratorInfo : IMapGeneratorInfo
|
||||||
{
|
{
|
||||||
|
string[] Tilesets { get; }
|
||||||
IMapGeneratorSettings GetSettings();
|
IMapGeneratorSettings GetSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var tools = world.Map.Rules.Actors[SystemActors.EditorWorld].TraitInfos<IEditorToolInfo>();
|
var tools = world.Map.Rules.Actors[SystemActors.EditorWorld].TraitInfos<IEditorToolInfo>();
|
||||||
foreach (var tool in tools)
|
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 } });
|
var panel = Game.LoadWidget(world, tool.PanelWidget, widget, new WidgetArgs() { { "tool", tool } });
|
||||||
toolPanels.Add(panel);
|
toolPanels.Add(panel);
|
||||||
toolLabels.Add(panel, FluentProvider.GetMessage(tool.Label));
|
toolLabels.Add(panel, FluentProvider.GetMessage(tool.Label));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
ExperimentalMapGenerator@experimental:
|
ExperimentalMapGenerator@experimental:
|
||||||
Type: experimental
|
Type: experimental
|
||||||
Name: map-generator-experimental
|
Name: map-generator-experimental
|
||||||
|
Tilesets: DESERT, SNOW, TEMPERAT, WINTER
|
||||||
Settings:
|
Settings:
|
||||||
MultiChoiceOption@hidden_defaults:
|
MultiChoiceOption@hidden_defaults:
|
||||||
Choice@hidden_defaults:
|
Choice@hidden_defaults:
|
||||||
@@ -439,16 +440,15 @@
|
|||||||
ClearMapGenerator@clear:
|
ClearMapGenerator@clear:
|
||||||
Type: clear
|
Type: clear
|
||||||
Name: map-generator-clear
|
Name: map-generator-clear
|
||||||
|
Tilesets: DESERT, SNOW, TEMPERAT, WINTER
|
||||||
Settings:
|
Settings:
|
||||||
MultiChoiceOption@Tile:
|
MultiChoiceOption@Tile:
|
||||||
Label: label-clear-map-generator-option-tile
|
Label: label-clear-map-generator-option-tile
|
||||||
Choice@CommonClear:
|
Choice@CommonClear:
|
||||||
Label: label-clear-map-generator-choice-tile-clear
|
Label: label-clear-map-generator-choice-tile-clear
|
||||||
Tileset: DESERT,SNOW,TEMPERAT,WINTER
|
|
||||||
Settings:
|
Settings:
|
||||||
Tile: 255
|
Tile: 255
|
||||||
Choice@CommonWater:
|
Choice@CommonWater:
|
||||||
Label: label-clear-map-generator-choice-tile-water
|
Label: label-clear-map-generator-choice-tile-water
|
||||||
Tileset: DESERT,SNOW,TEMPERAT,WINTER
|
|
||||||
Settings:
|
Settings:
|
||||||
Tile: 1
|
Tile: 1
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
ExperimentalMapGenerator@experimental:
|
ExperimentalMapGenerator@experimental:
|
||||||
Type: experimental
|
Type: experimental
|
||||||
Name: map-generator-experimental
|
Name: map-generator-experimental
|
||||||
|
Tilesets: DESERT, SNOW, TEMPERAT
|
||||||
Settings:
|
Settings:
|
||||||
MultiChoiceOption@hidden_defaults:
|
MultiChoiceOption@hidden_defaults:
|
||||||
Choice@hidden_defaults:
|
Choice@hidden_defaults:
|
||||||
@@ -463,6 +464,7 @@
|
|||||||
ClearMapGenerator@clear:
|
ClearMapGenerator@clear:
|
||||||
Type: clear
|
Type: clear
|
||||||
Name: map-generator-clear
|
Name: map-generator-clear
|
||||||
|
Tilesets: DESERT, SNOW, TEMPERAT, INTERIOR
|
||||||
Settings:
|
Settings:
|
||||||
MultiChoiceOption@Tile:
|
MultiChoiceOption@Tile:
|
||||||
Label: label-clear-map-generator-option-tile
|
Label: label-clear-map-generator-option-tile
|
||||||
|
|||||||
Reference in New Issue
Block a user