From a845947e0f1cb2a851ebadb0b0d79258af38e5ec Mon Sep 17 00:00:00 2001 From: Pavlos Touboulidis Date: Tue, 13 May 2014 16:43:29 +0300 Subject: [PATCH] Minor style & nit fixes --- OpenRA.Game/GameRules/RulesetCache.cs | 10 +++++----- OpenRA.Game/Graphics/SequenceProvider.cs | 4 +++- OpenRA.Game/Traits/World/ResourceType.cs | 6 +++--- OpenRA.Game/Widgets/ButtonWidget.cs | 2 -- OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs | 1 - OpenRA.Mods.Cnc/Widgets/ProductionTypeButtonWidget.cs | 2 -- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/OpenRA.Game/GameRules/RulesetCache.cs b/OpenRA.Game/GameRules/RulesetCache.cs index 21b9609aef..c119e1c6c4 100755 --- a/OpenRA.Game/GameRules/RulesetCache.cs +++ b/OpenRA.Game/GameRules/RulesetCache.cs @@ -31,11 +31,13 @@ namespace OpenRA readonly Dictionary tileSetCache = new Dictionary(); readonly Dictionary sequenceCaches = new Dictionary(); - public Action OnProgress = () => { if (Game.modData != null && Game.modData.LoadScreen != null) Game.modData.LoadScreen.Display(); }; + public Action OnProgress; public RulesetCache(ModData modData) { this.modData = modData; + + OnProgress = () => { if (modData.LoadScreen != null) modData.LoadScreen.Display(); }; } public Ruleset LoadDefaultRules() @@ -77,7 +79,7 @@ namespace OpenRA using (new PerfTimer("TileSets")) tileSets = LoadTileSets(tileSetCache, sequenceCaches, m.TileSets); - var sequences = sequenceCaches.ToDictionary((kvp) => kvp.Key, (kvp) => new SequenceProvider(kvp.Value, map)); + var sequences = sequenceCaches.ToDictionary(kvp => kvp.Key, kvp => new SequenceProvider(kvp.Value, map)); OnProgress(); return new Ruleset(actors, weapons, voices, notifications, music, movies, tileSets, sequences); @@ -88,7 +90,7 @@ namespace OpenRA string[] files, List nodes, Func, T> f) { - string inputKey = string.Concat(string.Join("|", files), "|", nodes.WriteToString()); + var inputKey = string.Concat(string.Join("|", files), "|", nodes.WriteToString()); var mergedNodes = files .Select(s => MiniYaml.FromFile(s)) @@ -120,9 +122,7 @@ namespace OpenRA { TileSet t; if (itemCache.TryGetValue(file, out t)) - { items.Add(t.Id, t); - } else { t = new TileSet(modData, file); diff --git a/OpenRA.Game/Graphics/SequenceProvider.cs b/OpenRA.Game/Graphics/SequenceProvider.cs index afc9417dc6..f250216dbf 100644 --- a/OpenRA.Game/Graphics/SequenceProvider.cs +++ b/OpenRA.Game/Graphics/SequenceProvider.cs @@ -68,10 +68,12 @@ namespace OpenRA.Graphics readonly Dictionary>> sequenceCache = new Dictionary>>(); - public Action OnProgress = () => { if (Game.modData != null && Game.modData.LoadScreen != null) Game.modData.LoadScreen.Display(); }; + public Action OnProgress; public SequenceCache(ModData modData, TileSet tileSet) { + OnProgress = () => { if (modData.LoadScreen != null) modData.LoadScreen.Display(); }; + this.modData = modData; spriteLoader = Exts.Lazy(() => new SpriteLoader(tileSet.Extensions, new SheetBuilder(SheetType.Indexed))); diff --git a/OpenRA.Game/Traits/World/ResourceType.cs b/OpenRA.Game/Traits/World/ResourceType.cs index 4cd507bd85..f3e8b98b20 100644 --- a/OpenRA.Game/Traits/World/ResourceType.cs +++ b/OpenRA.Game/Traits/World/ResourceType.cs @@ -32,7 +32,7 @@ namespace OpenRA.Traits public PipType PipColor = PipType.Yellow; - public object Create(ActorInitializer init) { return new ResourceType(this, init); } + public object Create(ActorInitializer init) { return new ResourceType(this, init.world); } } public class ResourceType : IWorldLoaded @@ -41,13 +41,13 @@ namespace OpenRA.Traits public PaletteReference Palette { get; private set; } public readonly Dictionary Variants; - public ResourceType(ResourceTypeInfo info, ActorInitializer init) + public ResourceType(ResourceTypeInfo info, World world) { this.Info = info; Variants = new Dictionary(); foreach (var v in info.Variants) { - var seq = init.world.Map.SequenceProvider.GetSequence("resources", v); + var seq = world.Map.SequenceProvider.GetSequence("resources", v); var sprites = Exts.MakeArray(seq.Length, x => seq.GetSprite(x)); Variants.Add(v, sprites); } diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs index 0f63ece79f..1d20e82ce2 100644 --- a/OpenRA.Game/Widgets/ButtonWidget.cs +++ b/OpenRA.Game/Widgets/ButtonWidget.cs @@ -11,8 +11,6 @@ using System; using System.Drawing; using OpenRA.FileFormats; -using OpenRA.Graphics; -using OpenRA.Network; namespace OpenRA.Widgets { diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs index df9916c713..40f11efcac 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs @@ -12,7 +12,6 @@ using System; using System.Linq; using OpenRA.Graphics; using OpenRA.Mods.RA; -using OpenRA.Mods.RA.Widgets.Logic; using OpenRA.Traits; using OpenRA.Widgets; diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionTypeButtonWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionTypeButtonWidget.cs index 7debdef2ab..9599ce75b3 100644 --- a/OpenRA.Mods.Cnc/Widgets/ProductionTypeButtonWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ProductionTypeButtonWidget.cs @@ -9,8 +9,6 @@ #endregion using OpenRA.Widgets; -using OpenRA.Graphics; -using OpenRA.Network; namespace OpenRA.Mods.Cnc.Widgets {