Remove Ruleset.TileSet.
This commit is contained in:
@@ -28,7 +28,6 @@ namespace OpenRA
|
||||
public readonly IReadOnlyDictionary<string, SoundInfo> Notifications;
|
||||
public readonly IReadOnlyDictionary<string, MusicInfo> Music;
|
||||
public readonly ITerrainInfo TerrainInfo;
|
||||
public readonly TileSet TileSet;
|
||||
public readonly SequenceProvider Sequences;
|
||||
public readonly IReadOnlyDictionary<string, MiniYamlNode> ModelSequences;
|
||||
|
||||
@@ -38,7 +37,7 @@ namespace OpenRA
|
||||
IReadOnlyDictionary<string, SoundInfo> voices,
|
||||
IReadOnlyDictionary<string, SoundInfo> notifications,
|
||||
IReadOnlyDictionary<string, MusicInfo> music,
|
||||
TileSet tileSet,
|
||||
ITerrainInfo terrainInfo,
|
||||
SequenceProvider sequences,
|
||||
IReadOnlyDictionary<string, MiniYamlNode> modelSequences)
|
||||
{
|
||||
@@ -47,8 +46,7 @@ namespace OpenRA
|
||||
Voices = voices;
|
||||
Notifications = notifications;
|
||||
Music = music;
|
||||
TerrainInfo = tileSet;
|
||||
TileSet = tileSet;
|
||||
TerrainInfo = terrainInfo;
|
||||
Sequences = sequences;
|
||||
ModelSequences = modelSequences;
|
||||
|
||||
@@ -173,10 +171,10 @@ namespace OpenRA
|
||||
public static Ruleset LoadDefaultsForTileSet(ModData modData, string tileSet)
|
||||
{
|
||||
var dr = modData.DefaultRules;
|
||||
var ts = modData.DefaultTileSets[tileSet];
|
||||
var terrainInfo = modData.DefaultTerrainInfo[tileSet];
|
||||
var sequences = modData.DefaultSequences[tileSet];
|
||||
|
||||
return new Ruleset(dr.Actors, dr.Weapons, dr.Voices, dr.Notifications, dr.Music, ts, sequences, dr.ModelSequences);
|
||||
return new Ruleset(dr.Actors, dr.Weapons, dr.Voices, dr.Notifications, dr.Music, terrainInfo, sequences, dr.ModelSequences);
|
||||
}
|
||||
|
||||
public static Ruleset Load(ModData modData, IReadOnlyFileSystem fileSystem, string tileSet,
|
||||
@@ -205,8 +203,8 @@ namespace OpenRA
|
||||
var music = MergeOrDefault("Music", fileSystem, m.Music, mapMusic, dr.Music,
|
||||
k => new MusicInfo(k.Key, k.Value));
|
||||
|
||||
// TODO: Add support for merging custom tileset modifications
|
||||
var ts = modData.DefaultTileSets[tileSet];
|
||||
// TODO: Add support for merging custom terrain modifications
|
||||
var terrainInfo = modData.DefaultTerrainInfo[tileSet];
|
||||
|
||||
// TODO: Top-level dictionary should be moved into the Ruleset instead of in its own object
|
||||
var sequences = mapSequences == null ? modData.DefaultSequences[tileSet] :
|
||||
@@ -217,7 +215,7 @@ namespace OpenRA
|
||||
modelSequences = MergeOrDefault("ModelSequences", fileSystem, m.ModelSequences, mapModelSequences, dr.ModelSequences,
|
||||
k => k);
|
||||
|
||||
ruleset = new Ruleset(actors, weapons, voices, notifications, music, ts, sequences, modelSequences);
|
||||
ruleset = new Ruleset(actors, weapons, voices, notifications, music, terrainInfo, sequences, modelSequences);
|
||||
};
|
||||
|
||||
if (modData.IsOnMainThread)
|
||||
|
||||
@@ -42,8 +42,8 @@ namespace OpenRA
|
||||
readonly Lazy<Ruleset> defaultRules;
|
||||
public Ruleset DefaultRules { get { return defaultRules.Value; } }
|
||||
|
||||
readonly Lazy<IReadOnlyDictionary<string, TileSet>> defaultTileSets;
|
||||
public IReadOnlyDictionary<string, TileSet> DefaultTileSets { get { return defaultTileSets.Value; } }
|
||||
readonly Lazy<IReadOnlyDictionary<string, ITerrainInfo>> defaultTerrainInfo;
|
||||
public IReadOnlyDictionary<string, ITerrainInfo> DefaultTerrainInfo { get { return defaultTerrainInfo.Value; } }
|
||||
|
||||
readonly Lazy<IReadOnlyDictionary<string, SequenceProvider>> defaultSequences;
|
||||
public IReadOnlyDictionary<string, SequenceProvider> DefaultSequences { get { return defaultSequences.Value; } }
|
||||
@@ -95,9 +95,9 @@ namespace OpenRA
|
||||
Hotkeys = new HotkeyManager(ModFiles, Game.Settings.Keys, Manifest);
|
||||
|
||||
defaultRules = Exts.Lazy(() => Ruleset.LoadDefaults(this));
|
||||
defaultTileSets = Exts.Lazy(() =>
|
||||
defaultTerrainInfo = Exts.Lazy(() =>
|
||||
{
|
||||
var items = new Dictionary<string, TileSet>();
|
||||
var items = new Dictionary<string, ITerrainInfo>();
|
||||
|
||||
foreach (var file in Manifest.TileSets)
|
||||
{
|
||||
@@ -105,12 +105,12 @@ namespace OpenRA
|
||||
items.Add(t.Id, t);
|
||||
}
|
||||
|
||||
return (IReadOnlyDictionary<string, TileSet>)(new ReadOnlyDictionary<string, TileSet>(items));
|
||||
return (IReadOnlyDictionary<string, ITerrainInfo>)(new ReadOnlyDictionary<string, ITerrainInfo>(items));
|
||||
});
|
||||
|
||||
defaultSequences = Exts.Lazy(() =>
|
||||
{
|
||||
var items = DefaultTileSets.ToDictionary(t => t.Key, t => new SequenceProvider(DefaultFileSystem, this, t.Key, null));
|
||||
var items = DefaultTerrainInfo.ToDictionary(t => t.Key, t => new SequenceProvider(DefaultFileSystem, this, t.Key, null));
|
||||
return (IReadOnlyDictionary<string, SequenceProvider>)(new ReadOnlyDictionary<string, SequenceProvider>(items));
|
||||
});
|
||||
|
||||
|
||||
@@ -265,7 +265,10 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
var iniBounds = mapSection.GetValue("LocalSize", "0, 0, 0, 0").Split(',').Select(int.Parse).ToArray();
|
||||
var size = new Size(iniSize[2], 2 * iniSize[3]);
|
||||
|
||||
var map = new Map(Game.ModData, utility.ModData.DefaultTileSets[tileset], size.Width, size.Height)
|
||||
if (!utility.ModData.DefaultTerrainInfo.TryGetValue(tileset, out var terrainInfo))
|
||||
throw new InvalidDataException("Unknown tileset {0}".F(tileset));
|
||||
|
||||
var map = new Map(Game.ModData, terrainInfo, size.Width, size.Height)
|
||||
{
|
||||
Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(filename)),
|
||||
Author = "Westwood Studios",
|
||||
@@ -328,7 +331,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
|
||||
static void ReadTiles(Map map, IniFile file, int2 fullSize)
|
||||
{
|
||||
var tileset = Game.ModData.DefaultTileSets[map.Tileset];
|
||||
var terrainInfo = (ITemplatedTerrainInfo)Game.ModData.DefaultTerrainInfo[map.Tileset];
|
||||
var mapSection = file.GetSection("IsoMapPack5");
|
||||
|
||||
var data = Convert.FromBase64String(string.Concat(mapSection.Select(kvp => kvp.Value)));
|
||||
@@ -355,7 +358,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
|
||||
if (map.Tiles.Contains(cell))
|
||||
{
|
||||
if (!tileset.Templates.ContainsKey(tilenum))
|
||||
if (!terrainInfo.Templates.ContainsKey(tilenum))
|
||||
tilenum = subtile = 0;
|
||||
|
||||
map.Tiles[cell] = new TerrainTile(tilenum, subtile);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Tileset: " + kv.Key);
|
||||
var terrainInfo = modData.DefaultTileSets[kv.Key];
|
||||
var terrainInfo = modData.DefaultTerrainInfo[kv.Key];
|
||||
|
||||
if (terrainInfo is ITemplatedTerrainInfo templatedTerrainInfo)
|
||||
foreach (var r in modData.DefaultRules.Actors["world"].TraitInfos<ITiledTerrainRendererInfo>())
|
||||
|
||||
@@ -65,10 +65,10 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
// The original game isn't case sensitive, but we are.
|
||||
var tileset = GetTileset(mapSection).ToUpperInvariant();
|
||||
if (!ModData.DefaultTileSets.ContainsKey(tileset))
|
||||
if (!ModData.DefaultTerrainInfo.TryGetValue(tileset, out var terrainInfo))
|
||||
throw new InvalidDataException("Unknown tileset {0}".F(tileset));
|
||||
|
||||
Map = new Map(ModData, ModData.DefaultTileSets[tileset], MapSize, MapSize)
|
||||
Map = new Map(ModData, terrainInfo, MapSize, MapSize)
|
||||
{
|
||||
Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(filename)),
|
||||
Author = "Westwood Studios",
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
panel.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
|
||||
|
||||
var tilesetDropDown = panel.Get<DropDownButtonWidget>("TILESET");
|
||||
var tilesets = modData.DefaultTileSets.Select(t => t.Key).ToList();
|
||||
var tilesets = modData.DefaultTerrainInfo.Keys;
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(template,
|
||||
@@ -36,6 +36,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option;
|
||||
return item;
|
||||
};
|
||||
|
||||
tilesetDropDown.Text = tilesets.First();
|
||||
tilesetDropDown.OnClick = () =>
|
||||
tilesetDropDown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, tilesets, setupItem);
|
||||
@@ -54,7 +55,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
height = Math.Max(2, height);
|
||||
|
||||
var maxTerrainHeight = world.Map.Grid.MaximumTerrainHeight;
|
||||
var tileset = modData.DefaultTileSets[tilesetDropDown.Text];
|
||||
var tileset = modData.DefaultTerrainInfo[tilesetDropDown.Text];
|
||||
var map = new Map(Game.ModData, tileset, width + 2, height + maxTerrainHeight + 2);
|
||||
|
||||
var tl = new PPos(1, 1 + maxTerrainHeight);
|
||||
|
||||
@@ -306,7 +306,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands
|
||||
void Initialize(string mapFile)
|
||||
{
|
||||
mapSize = new Size(stream.ReadUInt16(), stream.ReadUInt16());
|
||||
terrainInfo = Game.ModData.DefaultTileSets["ARRAKIS"];
|
||||
terrainInfo = (ITemplatedTerrainInfo)Game.ModData.DefaultTerrainInfo["ARRAKIS"];
|
||||
|
||||
map = new Map(Game.ModData, terrainInfo, mapSize.Width + 2 * MapCordonWidth, mapSize.Height + 2 * MapCordonWidth)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user