sequenceEditor is mod-aware now.

This commit is contained in:
Chris Forbes
2010-02-07 17:19:34 +13:00
parent b1fca54e7e
commit 911fb6aa9b
3 changed files with 39 additions and 28 deletions

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using IjwFramework.Collections; using IjwFramework.Collections;
using System;
namespace OpenRa.FileFormats 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() public static void UnmountTemporaryPackages()
{ {
mountedFolders.RemoveAll(f => temporaryMounts.Contains(f)); mountedFolders.RemoveAll(f => temporaryMounts.Contains(f));

View File

@@ -40,16 +40,9 @@ namespace OpenRa
FileSystem.UnmountTemporaryPackages(); FileSystem.UnmountTemporaryPackages();
Timer.Time("reset: {0}"); Timer.Time("reset: {0}");
foreach (var dir in manifest.Folders) foreach (var dir in manifest.Folders) FileSystem.MountTemporaryEx(dir);
FileSystem.MountTemporary(new Folder(dir)); foreach (var pkg in manifest.Packages) FileSystem.MountTemporaryEx(pkg);
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));
Timer.Time("mount temporary packages: {0}"); 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); viewport = new Viewport(clientSize, Game.world.Map.Offset, Game.world.Map.Offset + Game.world.Map.Size, renderer);
Timer.Time( "ChromeProv, SeqProv, viewport: {0}" ); Timer.Time( "ChromeProv, SeqProv, viewport: {0}" );
skipMakeAnims = true; skipMakeAnims = true;
foreach (var treeReference in Game.world.Map.Trees) foreach (var treeReference in Game.world.Map.Trees)
world.CreateActor(treeReference.Image, new int2(treeReference.Location), null); world.CreateActor(treeReference.Image, new int2(treeReference.Location), null);

View File

@@ -69,24 +69,28 @@ namespace SequenceEditor
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); 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 = new XmlDocument();
Doc.Load(XmlFilename); Doc.Load(XmlFilename);
var tempPal = new Palette(FileSystem.Open("temperat.pal")); var tempPal = new Palette(FileSystem.Open(args[2]));
Pal = tempPal; //new Palette(tempPal, new ShroudPaletteRemap()); Pal = tempPal;
UnitName = args.FirstOrDefault( x => !x.EndsWith(".xml") ); UnitName = GetTextForm.GetString("Unit to edit?", "e1");
if (UnitName == null) if (string.IsNullOrEmpty(UnitName))
UnitName = GetTextForm.GetString("Unit to edit?", "e1");
if (UnitName == null)
return; return;
LoadAndResolve(UnitName); LoadAndResolve(UnitName);
@@ -95,10 +99,7 @@ namespace SequenceEditor
foreach (XmlElement e in Doc.SelectNodes(xpath)) foreach (XmlElement e in Doc.SelectNodes(xpath))
{ {
if (e.HasAttribute("src")) if (e.HasAttribute("src"))
{ LoadAndResolve(e.GetAttribute("src"));
var src = e.GetAttribute("src");
LoadAndResolve(src);
}
Sequences[e.GetAttribute("name")] = new Sequence(e); Sequences[e.GetAttribute("name")] = new Sequence(e);
} }