From 911fb6aa9b94c5c368ecf31baab58cd61c0800f1 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 7 Feb 2010 17:19:34 +1300 Subject: [PATCH] sequenceEditor is mod-aware now. --- OpenRa.FileFormats/FileSystem.cs | 18 ++++++++++++++++ OpenRa.Game/Game.cs | 14 +++---------- SequenceEditor/Program.cs | 35 ++++++++++++++++---------------- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/OpenRa.FileFormats/FileSystem.cs b/OpenRa.FileFormats/FileSystem.cs index 5d015acddc..2c25187fed 100644 --- a/OpenRa.FileFormats/FileSystem.cs +++ b/OpenRa.FileFormats/FileSystem.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using IjwFramework.Collections; +using System; namespace OpenRa.FileFormats { @@ -64,6 +65,23 @@ namespace OpenRa.FileFormats } } + public static void MountTemporaryEx(string name) + { + name = name.ToLowerInvariant(); + var optional = name.StartsWith("~"); + if (optional) name = name.Substring(1); + + var a = name.EndsWith(".mix") + ? (Action)(() => FileSystem.MountTemporary(new Package(name))) + : () => FileSystem.MountTemporary(new Folder(name)); + + if (optional) + try { a(); } + catch { } + else + a(); + } + public static void UnmountTemporaryPackages() { mountedFolders.RemoveAll(f => temporaryMounts.Contains(f)); diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 003936aded..e2c3904388 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -40,16 +40,9 @@ namespace OpenRa FileSystem.UnmountTemporaryPackages(); Timer.Time("reset: {0}"); - foreach (var dir in manifest.Folders) - FileSystem.MountTemporary(new Folder(dir)); - - foreach (var pkg in manifest.Packages) - if (pkg.StartsWith( "~")) // this package is optional. - try { FileSystem.MountTemporary(new Package(pkg.Substring(1))); } - catch { } - else - FileSystem.MountTemporary(new Package(pkg)); - + foreach (var dir in manifest.Folders) FileSystem.MountTemporaryEx(dir); + foreach (var pkg in manifest.Packages) FileSystem.MountTemporaryEx(pkg); + Timer.Time("mount temporary packages: {0}"); } @@ -87,7 +80,6 @@ namespace OpenRa viewport = new Viewport(clientSize, Game.world.Map.Offset, Game.world.Map.Offset + Game.world.Map.Size, renderer); Timer.Time( "ChromeProv, SeqProv, viewport: {0}" ); - skipMakeAnims = true; foreach (var treeReference in Game.world.Map.Trees) world.CreateActor(treeReference.Image, new int2(treeReference.Location), null); diff --git a/SequenceEditor/Program.cs b/SequenceEditor/Program.cs index 1059ccc730..1e99d0afec 100644 --- a/SequenceEditor/Program.cs +++ b/SequenceEditor/Program.cs @@ -69,24 +69,28 @@ namespace SequenceEditor { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - FileSystem.MountDefaultPackages(); - try - { - FileSystem.MountAftermathPackages(); - } - catch( FileNotFoundException ){} - XmlFilename = args.FirstOrDefault( x => x.EndsWith(".xml") ) ?? "sequences.xml"; + if (args.Length != 3) + { + MessageBox.Show( "usage: SequenceEditor mod[,mod]* sequences-file.xml palette.pal"); + return; + } + + var mods = args[0].Split(','); + var manifest = new Manifest(mods); + + foreach (var folder in manifest.Folders) FileSystem.MountTemporaryEx(folder); + foreach (var pkg in manifest.Packages) FileSystem.MountTemporaryEx(pkg); + + XmlFilename = args[1]; Doc = new XmlDocument(); Doc.Load(XmlFilename); - var tempPal = new Palette(FileSystem.Open("temperat.pal")); - Pal = tempPal; //new Palette(tempPal, new ShroudPaletteRemap()); + var tempPal = new Palette(FileSystem.Open(args[2])); + Pal = tempPal; - UnitName = args.FirstOrDefault( x => !x.EndsWith(".xml") ); - if (UnitName == null) - UnitName = GetTextForm.GetString("Unit to edit?", "e1"); - if (UnitName == null) + UnitName = GetTextForm.GetString("Unit to edit?", "e1"); + if (string.IsNullOrEmpty(UnitName)) return; LoadAndResolve(UnitName); @@ -95,10 +99,7 @@ namespace SequenceEditor foreach (XmlElement e in Doc.SelectNodes(xpath)) { if (e.HasAttribute("src")) - { - var src = e.GetAttribute("src"); - LoadAndResolve(src); - } + LoadAndResolve(e.GetAttribute("src")); Sequences[e.GetAttribute("name")] = new Sequence(e); }