diff --git a/SequenceEditor/Form1.cs b/SequenceEditor/Form1.cs index a1dd5bbcbb..ba9131ba66 100644 --- a/SequenceEditor/Form1.cs +++ b/SequenceEditor/Form1.cs @@ -22,7 +22,7 @@ namespace SequenceEditor { var shp = GetTextForm.GetString( "Add SHP...", "" ); if (shp == null) return; - Program.Shps.Add(shp, Program.LoadAndResolve(shp)); + Program.LoadAndResolve(shp); } void toolStripButton2_Click(object sender, EventArgs e) diff --git a/SequenceEditor/Program.cs b/SequenceEditor/Program.cs index 8bd1692655..ebc7482f19 100644 --- a/SequenceEditor/Program.cs +++ b/SequenceEditor/Program.cs @@ -17,12 +17,14 @@ namespace SequenceEditor public static Palette Pal; public static Dictionary Sequences = new Dictionary(); - public static Bitmap[] LoadAndResolve( string shp ) + public static void LoadAndResolve( string shp ) { try { + if (Shps.ContainsKey(shp)) return; + var reader = new ShpReader(FileSystem.OpenWithExts(shp, ".shp", ".tem", ".sno", ".int")); - return reader.Select(ih => + Shps[shp] = reader.Select(ih => { var bmp = new Bitmap(reader.Width, reader.Height); for (var j = 0; j < bmp.Height; j++) @@ -31,10 +33,7 @@ namespace SequenceEditor return bmp; }).ToArray(); } - catch - { - return new Bitmap[] { }; - } + catch { } } public static void Save() @@ -87,14 +86,15 @@ namespace SequenceEditor if (UnitName == null) return; + LoadAndResolve(UnitName); + var xpath = string.Format("//unit[@name=\"{0}\"]/sequence", UnitName); foreach (XmlElement e in Doc.SelectNodes(xpath)) { if (e.HasAttribute("src")) { var src = e.GetAttribute("src"); - if (!Shps.ContainsKey(src)) - Shps[src] = LoadAndResolve(src); + LoadAndResolve(src); } Sequences[e.GetAttribute("name")] = new Sequence(e); }