Extract default TileSet/Sequence dictionaries to ModData.
This commit is contained in:
@@ -24,8 +24,8 @@ namespace OpenRA
|
|||||||
public readonly IReadOnlyDictionary<string, SoundInfo> Voices;
|
public readonly IReadOnlyDictionary<string, SoundInfo> Voices;
|
||||||
public readonly IReadOnlyDictionary<string, SoundInfo> Notifications;
|
public readonly IReadOnlyDictionary<string, SoundInfo> Notifications;
|
||||||
public readonly IReadOnlyDictionary<string, MusicInfo> Music;
|
public readonly IReadOnlyDictionary<string, MusicInfo> Music;
|
||||||
public readonly IReadOnlyDictionary<string, TileSet> TileSets;
|
public readonly TileSet TileSet;
|
||||||
public readonly IReadOnlyDictionary<string, SequenceProvider> Sequences;
|
public readonly SequenceProvider Sequences;
|
||||||
|
|
||||||
public Ruleset(
|
public Ruleset(
|
||||||
IDictionary<string, ActorInfo> actors,
|
IDictionary<string, ActorInfo> actors,
|
||||||
@@ -33,16 +33,16 @@ namespace OpenRA
|
|||||||
IDictionary<string, SoundInfo> voices,
|
IDictionary<string, SoundInfo> voices,
|
||||||
IDictionary<string, SoundInfo> notifications,
|
IDictionary<string, SoundInfo> notifications,
|
||||||
IDictionary<string, MusicInfo> music,
|
IDictionary<string, MusicInfo> music,
|
||||||
IDictionary<string, TileSet> tileSets,
|
TileSet tileSet,
|
||||||
IDictionary<string, SequenceProvider> sequences)
|
SequenceProvider sequences)
|
||||||
{
|
{
|
||||||
Actors = new ReadOnlyDictionary<string, ActorInfo>(actors);
|
Actors = new ReadOnlyDictionary<string, ActorInfo>(actors);
|
||||||
Weapons = new ReadOnlyDictionary<string, WeaponInfo>(weapons);
|
Weapons = new ReadOnlyDictionary<string, WeaponInfo>(weapons);
|
||||||
Voices = new ReadOnlyDictionary<string, SoundInfo>(voices);
|
Voices = new ReadOnlyDictionary<string, SoundInfo>(voices);
|
||||||
Notifications = new ReadOnlyDictionary<string, SoundInfo>(notifications);
|
Notifications = new ReadOnlyDictionary<string, SoundInfo>(notifications);
|
||||||
Music = new ReadOnlyDictionary<string, MusicInfo>(music);
|
Music = new ReadOnlyDictionary<string, MusicInfo>(music);
|
||||||
TileSets = new ReadOnlyDictionary<string, TileSet>(tileSets);
|
TileSet = tileSet;
|
||||||
Sequences = new ReadOnlyDictionary<string, SequenceProvider>(sequences);
|
Sequences = sequences;
|
||||||
|
|
||||||
foreach (var a in Actors.Values)
|
foreach (var a in Actors.Values)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ namespace OpenRA
|
|||||||
readonly Dictionary<string, SoundInfo> voiceCache = new Dictionary<string, SoundInfo>();
|
readonly Dictionary<string, SoundInfo> voiceCache = new Dictionary<string, SoundInfo>();
|
||||||
readonly Dictionary<string, SoundInfo> notificationCache = new Dictionary<string, SoundInfo>();
|
readonly Dictionary<string, SoundInfo> notificationCache = new Dictionary<string, SoundInfo>();
|
||||||
readonly Dictionary<string, MusicInfo> musicCache = new Dictionary<string, MusicInfo>();
|
readonly Dictionary<string, MusicInfo> musicCache = new Dictionary<string, MusicInfo>();
|
||||||
readonly Dictionary<string, TileSet> tileSetCache = new Dictionary<string, TileSet>();
|
|
||||||
|
|
||||||
public event EventHandler LoadingProgress;
|
public event EventHandler LoadingProgress;
|
||||||
void RaiseProgress()
|
void RaiseProgress()
|
||||||
@@ -43,6 +42,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Ruleset Load(IReadOnlyFileSystem fileSystem,
|
public Ruleset Load(IReadOnlyFileSystem fileSystem,
|
||||||
|
TileSet tileSet,
|
||||||
MiniYaml additionalRules,
|
MiniYaml additionalRules,
|
||||||
MiniYaml additionalWeapons,
|
MiniYaml additionalWeapons,
|
||||||
MiniYaml additionalVoices,
|
MiniYaml additionalVoices,
|
||||||
@@ -57,7 +57,6 @@ namespace OpenRA
|
|||||||
Dictionary<string, SoundInfo> voices;
|
Dictionary<string, SoundInfo> voices;
|
||||||
Dictionary<string, SoundInfo> notifications;
|
Dictionary<string, SoundInfo> notifications;
|
||||||
Dictionary<string, MusicInfo> music;
|
Dictionary<string, MusicInfo> music;
|
||||||
Dictionary<string, TileSet> tileSets;
|
|
||||||
|
|
||||||
using (new PerfTimer("Actors"))
|
using (new PerfTimer("Actors"))
|
||||||
actors = LoadYamlRules(fileSystem, actorCache, m.Rules, additionalRules,
|
actors = LoadYamlRules(fileSystem, actorCache, m.Rules, additionalRules,
|
||||||
@@ -79,12 +78,8 @@ namespace OpenRA
|
|||||||
music = LoadYamlRules(fileSystem, musicCache, m.Music, additionalMusic,
|
music = LoadYamlRules(fileSystem, musicCache, m.Music, additionalMusic,
|
||||||
k => new MusicInfo(k.Key, k.Value));
|
k => new MusicInfo(k.Key, k.Value));
|
||||||
|
|
||||||
using (new PerfTimer("TileSets"))
|
var sequences = tileSet != null ? new SequenceProvider(fileSystem, modData, tileSet, additionalSequences) : null;
|
||||||
tileSets = LoadTileSets(fileSystem, tileSetCache, m.TileSets);
|
return new Ruleset(actors, weapons, voices, notifications, music, tileSet, sequences);
|
||||||
|
|
||||||
// TODO: only initialize, and then cache, the provider for the given map
|
|
||||||
var sequences = tileSets.ToDictionary(t => t.Key, t => new SequenceProvider(fileSystem, modData, t.Value, additionalSequences));
|
|
||||||
return new Ruleset(actors, weapons, voices, notifications, music, tileSets, sequences);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -93,9 +88,9 @@ namespace OpenRA
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Ruleset Load(IReadOnlyFileSystem fileSystem, Map map = null)
|
public Ruleset Load(IReadOnlyFileSystem fileSystem, Map map = null)
|
||||||
{
|
{
|
||||||
return map != null ? Load(fileSystem, map.RuleDefinitions, map.WeaponDefinitions,
|
return map != null ? Load(fileSystem, modData.DefaultTileSets[map.Tileset], map.RuleDefinitions,
|
||||||
map.VoiceDefinitions, map.NotificationDefinitions, map.MusicDefinitions,
|
map.WeaponDefinitions,map.VoiceDefinitions, map.NotificationDefinitions, map.MusicDefinitions,
|
||||||
map.SequenceDefinitions) : Load(fileSystem, null, null, null, null, null, null);
|
map.SequenceDefinitions) : Load(fileSystem, null, null, null, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, T> LoadYamlRules<T>(IReadOnlyFileSystem fileSystem,
|
Dictionary<string, T> LoadYamlRules<T>(IReadOnlyFileSystem fileSystem,
|
||||||
|
|||||||
@@ -169,10 +169,9 @@ namespace OpenRA
|
|||||||
[FieldLoader.Ignore] CellLayer<PPos[]> cellProjection;
|
[FieldLoader.Ignore] CellLayer<PPos[]> cellProjection;
|
||||||
[FieldLoader.Ignore] CellLayer<List<MPos>> inverseCellProjection;
|
[FieldLoader.Ignore] CellLayer<List<MPos>> inverseCellProjection;
|
||||||
|
|
||||||
[FieldLoader.Ignore] Lazy<TileSet> cachedTileSet;
|
|
||||||
[FieldLoader.Ignore] Lazy<Ruleset> rules;
|
[FieldLoader.Ignore] Lazy<Ruleset> rules;
|
||||||
public Ruleset Rules { get { return rules != null ? rules.Value : null; } }
|
public Ruleset Rules { get { return rules != null ? rules.Value : null; } }
|
||||||
public SequenceProvider SequenceProvider { get { return Rules.Sequences[Tileset]; } }
|
public SequenceProvider SequenceProvider { get { return Rules.Sequences; } }
|
||||||
|
|
||||||
[FieldLoader.Ignore] public ProjectedCellRegion ProjectedCellBounds;
|
[FieldLoader.Ignore] public ProjectedCellRegion ProjectedCellBounds;
|
||||||
[FieldLoader.Ignore] public CellRegion AllCells;
|
[FieldLoader.Ignore] public CellRegion AllCells;
|
||||||
@@ -307,8 +306,6 @@ namespace OpenRA
|
|||||||
return modData.DefaultRules;
|
return modData.DefaultRules;
|
||||||
});
|
});
|
||||||
|
|
||||||
cachedTileSet = Exts.Lazy(() => Rules.TileSets[Tileset]);
|
|
||||||
|
|
||||||
var tl = new MPos(0, 0).ToCPos(this);
|
var tl = new MPos(0, 0).ToCPos(this);
|
||||||
var br = new MPos(MapSize.X - 1, MapSize.Y - 1).ToCPos(this);
|
var br = new MPos(MapSize.X - 1, MapSize.Y - 1).ToCPos(this);
|
||||||
AllCells = new CellRegion(Grid.Type, tl, br);
|
AllCells = new CellRegion(Grid.Type, tl, br);
|
||||||
@@ -388,7 +385,7 @@ namespace OpenRA
|
|||||||
// Odd-height ramps get bumped up a level to the next even height layer
|
// Odd-height ramps get bumped up a level to the next even height layer
|
||||||
if ((height & 1) == 1)
|
if ((height & 1) == 1)
|
||||||
{
|
{
|
||||||
var ti = cachedTileSet.Value.GetTileInfo(MapTiles.Value[uv]);
|
var ti = Rules.TileSet.GetTileInfo(MapTiles.Value[uv]);
|
||||||
if (ti != null && ti.RampType != 0)
|
if (ti != null && ti.RampType != 0)
|
||||||
height += 1;
|
height += 1;
|
||||||
}
|
}
|
||||||
@@ -624,7 +621,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public byte[] SavePreview()
|
public byte[] SavePreview()
|
||||||
{
|
{
|
||||||
var tileset = Rules.TileSets[Tileset];
|
var tileset = Rules.TileSet;
|
||||||
var resources = Rules.Actors["world"].TraitInfos<ResourceTypeInfo>()
|
var resources = Rules.Actors["world"].TraitInfos<ResourceTypeInfo>()
|
||||||
.ToDictionary(r => r.ResourceType, r => r.TerrainType);
|
.ToDictionary(r => r.ResourceType, r => r.TerrainType);
|
||||||
|
|
||||||
@@ -875,7 +872,7 @@ namespace OpenRA
|
|||||||
public void FixOpenAreas()
|
public void FixOpenAreas()
|
||||||
{
|
{
|
||||||
var r = new Random();
|
var r = new Random();
|
||||||
var tileset = Rules.TileSets[Tileset];
|
var tileset = Rules.TileSet;
|
||||||
|
|
||||||
for (var j = Bounds.Top; j < Bounds.Bottom; j++)
|
for (var j = Bounds.Top; j < Bounds.Bottom; j++)
|
||||||
{
|
{
|
||||||
@@ -923,7 +920,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var custom = CustomTerrain[uv];
|
var custom = CustomTerrain[uv];
|
||||||
terrainIndex = cachedTerrainIndexes[uv] =
|
terrainIndex = cachedTerrainIndexes[uv] =
|
||||||
custom != byte.MaxValue ? custom : cachedTileSet.Value.GetTerrainIndex(MapTiles.Value[uv]);
|
custom != byte.MaxValue ? custom : Rules.TileSet.GetTerrainIndex(MapTiles.Value[uv]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (byte)terrainIndex;
|
return (byte)terrainIndex;
|
||||||
@@ -931,7 +928,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public TerrainTypeInfo GetTerrainInfo(CPos cell)
|
public TerrainTypeInfo GetTerrainInfo(CPos cell)
|
||||||
{
|
{
|
||||||
return cachedTileSet.Value[GetTerrainIndex(cell)];
|
return Rules.TileSet[GetTerrainIndex(cell)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPos Clamp(CPos cell)
|
public CPos Clamp(CPos cell)
|
||||||
|
|||||||
@@ -35,10 +35,16 @@ namespace OpenRA
|
|||||||
public VoxelLoader VoxelLoader { get; private set; }
|
public VoxelLoader VoxelLoader { get; private set; }
|
||||||
public CursorProvider CursorProvider { get; private set; }
|
public CursorProvider CursorProvider { get; private set; }
|
||||||
public FS ModFiles = new FS();
|
public FS ModFiles = new FS();
|
||||||
|
public IReadOnlyFileSystem DefaultFileSystem { get { return ModFiles; } }
|
||||||
|
|
||||||
readonly Lazy<Ruleset> defaultRules;
|
readonly Lazy<Ruleset> defaultRules;
|
||||||
public Ruleset DefaultRules { get { return defaultRules.Value; } }
|
public Ruleset DefaultRules { get { return defaultRules.Value; } }
|
||||||
public IReadOnlyFileSystem DefaultFileSystem { get { return ModFiles; } }
|
|
||||||
|
readonly Lazy<IReadOnlyDictionary<string, TileSet>> defaultTileSets;
|
||||||
|
public IReadOnlyDictionary<string, TileSet> DefaultTileSets { get { return defaultTileSets.Value; } }
|
||||||
|
|
||||||
|
readonly Lazy<IReadOnlyDictionary<string, SequenceProvider>> defaultSequences;
|
||||||
|
public IReadOnlyDictionary<string, SequenceProvider> DefaultSequences { get { return defaultSequences.Value; } }
|
||||||
|
|
||||||
public ModData(string mod, bool useLoadScreen = false)
|
public ModData(string mod, bool useLoadScreen = false)
|
||||||
{
|
{
|
||||||
@@ -74,6 +80,24 @@ namespace OpenRA
|
|||||||
SpriteSequenceLoader.OnMissingSpriteError = s => Log.Write("debug", s);
|
SpriteSequenceLoader.OnMissingSpriteError = s => Log.Write("debug", s);
|
||||||
|
|
||||||
defaultRules = Exts.Lazy(() => RulesetCache.Load(DefaultFileSystem));
|
defaultRules = Exts.Lazy(() => RulesetCache.Load(DefaultFileSystem));
|
||||||
|
defaultTileSets = Exts.Lazy(() =>
|
||||||
|
{
|
||||||
|
var items = new Dictionary<string, TileSet>();
|
||||||
|
|
||||||
|
foreach (var file in Manifest.TileSets)
|
||||||
|
{
|
||||||
|
var t = new TileSet(DefaultFileSystem, file);
|
||||||
|
items.Add(t.Id, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IReadOnlyDictionary<string, TileSet>)(new ReadOnlyDictionary<string, TileSet>(items));
|
||||||
|
});
|
||||||
|
|
||||||
|
defaultSequences = Exts.Lazy(() =>
|
||||||
|
{
|
||||||
|
var items = DefaultTileSets.ToDictionary(t => t.Key, t => new SequenceProvider(DefaultFileSystem, this, t.Value, null));
|
||||||
|
return (IReadOnlyDictionary<string, SequenceProvider>)(new ReadOnlyDictionary<string, SequenceProvider>(items));
|
||||||
|
});
|
||||||
|
|
||||||
initialThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
|
initialThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ namespace OpenRA
|
|||||||
Map = map;
|
Map = map;
|
||||||
Timestep = orderManager.LobbyInfo.GlobalSettings.Timestep;
|
Timestep = orderManager.LobbyInfo.GlobalSettings.Timestep;
|
||||||
|
|
||||||
TileSet = map.Rules.TileSets[Map.Tileset];
|
TileSet = map.Rules.TileSet;
|
||||||
SharedRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);
|
SharedRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);
|
||||||
|
|
||||||
var worldActorType = type == WorldType.Editor ? "EditorWorld" : "World";
|
var worldActorType = type == WorldType.Editor ? "EditorWorld" : "World";
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
preview.IsVisible = () => editorWidget.CurrentBrush == this;
|
preview.IsVisible = () => editorWidget.CurrentBrush == this;
|
||||||
|
|
||||||
var variant = resource.Variants.FirstOrDefault();
|
var variant = resource.Variants.FirstOrDefault();
|
||||||
var sequenceProvider = wr.World.Map.Rules.Sequences[world.TileSet.Id];
|
var sequenceProvider = wr.World.Map.Rules.Sequences;
|
||||||
var sequence = sequenceProvider.GetSequence("resources", variant);
|
var sequence = sequenceProvider.GetSequence("resources", variant);
|
||||||
var sprite = sequence.GetSprite(resource.MaxDensity - 1);
|
var sprite = sequence.GetSprite(resource.MaxDensity - 1);
|
||||||
preview.GetSprite = () => sprite;
|
preview.GetSprite = () => sprite;
|
||||||
|
|||||||
@@ -100,8 +100,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
var mapTiles = map.MapTiles.Value;
|
var mapTiles = map.MapTiles.Value;
|
||||||
var mapHeight = map.MapHeight.Value;
|
var mapHeight = map.MapHeight.Value;
|
||||||
|
|
||||||
var rules = map.Rules;
|
var tileset = map.Rules.TileSet;
|
||||||
var tileset = rules.TileSets[map.Tileset];
|
|
||||||
var template = tileset.Templates[Template];
|
var template = tileset.Templates[Template];
|
||||||
var baseHeight = mapHeight.Contains(cell) ? mapHeight[cell] : (byte)0;
|
var baseHeight = mapHeight.Contains(cell) ? mapHeight[cell] : (byte)0;
|
||||||
|
|
||||||
@@ -139,8 +138,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
var queue = new Queue<CPos>();
|
var queue = new Queue<CPos>();
|
||||||
var touched = new CellLayer<bool>(map);
|
var touched = new CellLayer<bool>(map);
|
||||||
|
|
||||||
var rules = map.Rules;
|
var tileset = map.Rules.TileSet;
|
||||||
var tileset = rules.TileSets[map.Tileset];
|
|
||||||
var template = tileset.Templates[Template];
|
var template = tileset.Templates[Template];
|
||||||
|
|
||||||
Action<CPos> maybeEnqueue = newCell =>
|
Action<CPos> maybeEnqueue = newCell =>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
var rules = map.Rules;
|
var rules = map.Rules;
|
||||||
var factions = rules.Actors["world"].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray();
|
var factions = rules.Actors["world"].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray();
|
||||||
var sequenceProviders = new[] { rules.Sequences[map.Tileset] };
|
var sequenceProviders = new[] { rules.Sequences };
|
||||||
|
|
||||||
foreach (var actorInfo in rules.Actors)
|
foreach (var actorInfo in rules.Actors)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
|
|
||||||
// Pick a random color for the bot
|
// Pick a random color for the bot
|
||||||
var validator = server.ModData.Manifest.Get<ColorValidator>();
|
var validator = server.ModData.Manifest.Get<ColorValidator>();
|
||||||
var tileset = server.Map.Rules.TileSets[server.Map.Tileset];
|
var tileset = server.Map.Rules.TileSet;
|
||||||
var terrainColors = tileset.TerrainInfo.Where(ti => ti.RestrictPlayerColor).Select(ti => ti.Color);
|
var terrainColors = tileset.TerrainInfo.Where(ti => ti.RestrictPlayerColor).Select(ti => ti.Color);
|
||||||
var playerColors = server.LobbyInfo.Clients.Select(c => c.Color.RGB)
|
var playerColors = server.LobbyInfo.Clients.Select(c => c.Color.RGB)
|
||||||
.Concat(server.MapPlayers.Players.Values.Select(p => p.Color.RGB));
|
.Concat(server.MapPlayers.Players.Values.Select(p => p.Color.RGB));
|
||||||
@@ -1064,7 +1064,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
server.SendOrderTo(connectionToEcho, "Message", message);
|
server.SendOrderTo(connectionToEcho, "Message", message);
|
||||||
};
|
};
|
||||||
|
|
||||||
var tileset = server.Map.Rules.TileSets[server.Map.Tileset];
|
var tileset = server.Map.Rules.TileSet;
|
||||||
var terrainColors = tileset.TerrainInfo.Where(ti => ti.RestrictPlayerColor).Select(ti => ti.Color).ToList();
|
var terrainColors = tileset.TerrainInfo.Where(ti => ti.RestrictPlayerColor).Select(ti => ti.Color).ToList();
|
||||||
var playerColors = server.LobbyInfo.Clients.Where(c => c.Index != playerIndex).Select(c => c.Color.RGB)
|
var playerColors = server.LobbyInfo.Clients.Where(c => c.Index != playerIndex).Select(c => c.Color.RGB)
|
||||||
.Concat(server.MapPlayers.Players.Values.Select(p => p.Color.RGB)).ToList();
|
.Concat(server.MapPlayers.Players.Values.Select(p => p.Color.RGB)).ToList();
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
ValidateMapFormat(format);
|
ValidateMapFormat(format);
|
||||||
|
|
||||||
var tileset = GetTileset(mapSection);
|
var tileset = GetTileset(mapSection);
|
||||||
Map = new Map(modData, modData.DefaultRules.TileSets[tileset], MapSize, MapSize)
|
Map = new Map(modData, modData.DefaultTileSets[tileset], MapSize, MapSize)
|
||||||
{
|
{
|
||||||
Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(filename)),
|
Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(filename)),
|
||||||
Author = "Westwood Studios",
|
Author = "Westwood Studios",
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
public class LayerSelectorLogic : ChromeLogic
|
public class LayerSelectorLogic : ChromeLogic
|
||||||
{
|
{
|
||||||
readonly EditorViewportControllerWidget editor;
|
readonly EditorViewportControllerWidget editor;
|
||||||
readonly World world;
|
|
||||||
readonly WorldRenderer worldRenderer;
|
readonly WorldRenderer worldRenderer;
|
||||||
|
|
||||||
readonly ScrollPanelWidget layerTemplateList;
|
readonly ScrollPanelWidget layerTemplateList;
|
||||||
@@ -29,8 +28,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
public LayerSelectorLogic(Widget widget, WorldRenderer worldRenderer)
|
public LayerSelectorLogic(Widget widget, WorldRenderer worldRenderer)
|
||||||
{
|
{
|
||||||
this.worldRenderer = worldRenderer;
|
this.worldRenderer = worldRenderer;
|
||||||
world = worldRenderer.World;
|
|
||||||
|
|
||||||
editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
|
editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
|
||||||
|
|
||||||
layerTemplateList = widget.Get<ScrollPanelWidget>("LAYERTEMPLATE_LIST");
|
layerTemplateList = widget.Get<ScrollPanelWidget>("LAYERTEMPLATE_LIST");
|
||||||
@@ -60,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
layerPreview.GetPalette = () => resource.Palette;
|
layerPreview.GetPalette = () => resource.Palette;
|
||||||
|
|
||||||
var variant = resource.Variants.FirstOrDefault();
|
var variant = resource.Variants.FirstOrDefault();
|
||||||
var sequenceProvider = rules.Sequences[world.TileSet.Id];
|
var sequenceProvider = rules.Sequences;
|
||||||
var sequence = sequenceProvider.GetSequence("resources", variant);
|
var sequence = sequenceProvider.GetSequence("resources", variant);
|
||||||
var frame = sequence.Frames != null ? sequence.Frames.Last() : resource.MaxDensity - 1;
|
var frame = sequence.Frames != null ? sequence.Frames.Last() : resource.MaxDensity - 1;
|
||||||
layerPreview.GetSprite = () => sequence.GetSprite(frame);
|
layerPreview.GetSprite = () => sequence.GetSprite(frame);
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
Widget panel;
|
Widget panel;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public NewMapLogic(Action onExit, Action<string> onSelect, Widget widget, World world)
|
public NewMapLogic(Action onExit, Action<string> onSelect, Widget widget, World world, ModData modData)
|
||||||
{
|
{
|
||||||
panel = widget;
|
panel = widget;
|
||||||
|
|
||||||
panel.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
|
panel.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
|
||||||
|
|
||||||
var tilesetDropDown = panel.Get<DropDownButtonWidget>("TILESET");
|
var tilesetDropDown = panel.Get<DropDownButtonWidget>("TILESET");
|
||||||
var tilesets = world.Map.Rules.TileSets.Select(t => t.Key).ToList();
|
var tilesets = modData.DefaultTileSets.Select(t => t.Key).ToList();
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
height = Math.Max(2, height);
|
height = Math.Max(2, height);
|
||||||
|
|
||||||
var maxTerrainHeight = world.Map.Grid.MaximumTerrainHeight;
|
var maxTerrainHeight = world.Map.Grid.MaximumTerrainHeight;
|
||||||
var tileset = world.Map.Rules.TileSets[tilesetDropDown.Text];
|
var tileset = modData.DefaultTileSets[tilesetDropDown.Text];
|
||||||
var map = new Map(Game.ModData, tileset, width + 2, height + maxTerrainHeight + 2);
|
var map = new Map(Game.ModData, tileset, width + 2, height + maxTerrainHeight + 2);
|
||||||
|
|
||||||
var tl = new PPos(1, 1);
|
var tl = new PPos(1, 1);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
public TileSelectorLogic(Widget widget, WorldRenderer worldRenderer)
|
public TileSelectorLogic(Widget widget, WorldRenderer worldRenderer)
|
||||||
{
|
{
|
||||||
var rules = worldRenderer.World.Map.Rules;
|
var rules = worldRenderer.World.Map.Rules;
|
||||||
var tileset = rules.TileSets[worldRenderer.World.Map.Tileset];
|
var tileset = rules.TileSet;
|
||||||
|
|
||||||
editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
|
editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
|
||||||
panel = widget.Get<ScrollPanelWidget>("TILETEMPLATE_LIST");
|
panel = widget.Get<ScrollPanelWidget>("TILETEMPLATE_LIST");
|
||||||
|
|||||||
@@ -48,14 +48,14 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public TerrainTemplatePreviewWidget(WorldRenderer worldRenderer, World world)
|
public TerrainTemplatePreviewWidget(WorldRenderer worldRenderer, World world)
|
||||||
{
|
{
|
||||||
this.worldRenderer = worldRenderer;
|
this.worldRenderer = worldRenderer;
|
||||||
tileset = world.Map.Rules.TileSets[world.Map.Tileset];
|
tileset = world.Map.Rules.TileSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TerrainTemplatePreviewWidget(TerrainTemplatePreviewWidget other)
|
protected TerrainTemplatePreviewWidget(TerrainTemplatePreviewWidget other)
|
||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
worldRenderer = other.worldRenderer;
|
worldRenderer = other.worldRenderer;
|
||||||
tileset = other.worldRenderer.World.Map.Rules.TileSets[other.worldRenderer.World.Map.Tileset];
|
tileset = other.worldRenderer.World.Map.Rules.TileSet;
|
||||||
Template = other.Template;
|
Template = other.Template;
|
||||||
GetScale = other.GetScale;
|
GetScale = other.GetScale;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands
|
|||||||
{
|
{
|
||||||
mapSize = new Size(stream.ReadUInt16(), stream.ReadUInt16());
|
mapSize = new Size(stream.ReadUInt16(), stream.ReadUInt16());
|
||||||
|
|
||||||
tileSet = rules.TileSets["ARRAKIS"];
|
tileSet = Game.ModData.DefaultTileSets["ARRAKIS"];
|
||||||
|
|
||||||
map = new Map(Game.ModData, tileSet, mapSize.Width + 2 * MapCordonWidth, mapSize.Height + 2 * MapCordonWidth)
|
map = new Map(Game.ModData, tileSet, mapSize.Width + 2 * MapCordonWidth, mapSize.Height + 2 * MapCordonWidth)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
|
|
||||||
fullSize = new int2(iniSize[2], iniSize[3]);
|
fullSize = new int2(iniSize[2], iniSize[3]);
|
||||||
|
|
||||||
var map = new Map(Game.ModData, modData.DefaultRules.TileSets[tileset], size.Width, size.Height);
|
var map = new Map(Game.ModData, modData.DefaultTileSets[tileset], size.Width, size.Height);
|
||||||
map.Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(filename));
|
map.Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(filename));
|
||||||
map.Author = "Westwood Studios";
|
map.Author = "Westwood Studios";
|
||||||
map.Bounds = new Rectangle(iniBounds[0], iniBounds[1], iniBounds[2], 2 * iniBounds[3] + 2 * iniBounds[1]);
|
map.Bounds = new Rectangle(iniBounds[0], iniBounds[1], iniBounds[2], 2 * iniBounds[3] + 2 * iniBounds[1]);
|
||||||
@@ -243,7 +243,7 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
|
|
||||||
void ReadTiles(Map map, IniFile file)
|
void ReadTiles(Map map, IniFile file)
|
||||||
{
|
{
|
||||||
var tileset = Game.ModData.DefaultRules.TileSets[map.Tileset];
|
var tileset = Game.ModData.DefaultTileSets[map.Tileset];
|
||||||
var mapSection = file.GetSection("IsoMapPack5");
|
var mapSection = file.GetSection("IsoMapPack5");
|
||||||
|
|
||||||
var data = Convert.FromBase64String(mapSection.Aggregate(string.Empty, (a, b) => a + b.Value));
|
var data = Convert.FromBase64String(mapSection.Aggregate(string.Empty, (a, b) => a + b.Value));
|
||||||
|
|||||||
Reference in New Issue
Block a user