From b7975031bc05c6b7926c926df612d06201f5ed91 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 29 Dec 2010 22:13:51 +1300 Subject: [PATCH] Wire up most of saving again. --- OpenRA.Editor/Form1.cs | 12 +++--------- OpenRA.Editor/MapSelect.cs | 4 ++-- OpenRA.FileFormats/Map/MapStub.cs | 2 +- OpenRA.Game/Map.cs | 14 ++++++++++++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 84296785f2..020ee6a021 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -60,8 +60,6 @@ namespace OpenRA.Editor loadedMapName = mapname; Game.modData = new ModData(currentMod); - - System.Console.WriteLine("Loading map: {0}",mapname); // load the map var map = new Map(mapname); @@ -246,7 +244,7 @@ namespace OpenRA.Editor else { surface1.Map.PlayerCount = surface1.Map.Waypoints.Count; - surface1.Map.Save(); + surface1.Map.Save(loadedMapName); dirty = false; } @@ -268,9 +266,6 @@ namespace OpenRA.Editor // TODO: Allow the user to choose map format (directory vs oramap) loadedMapName = Path.Combine(nms.MapFolderPath, nms.txtNew.Text + ".oramap"); - - // TODO: Change surface1.Map.Container if necessary - SaveClicked(sender, e); } } @@ -299,7 +294,7 @@ namespace OpenRA.Editor if (DialogResult.OK == nmd.ShowDialog()) { - var map = Map.NewWithTileset(nmd.theater.SelectedItem as string); + var map = Map.FromTileset(nmd.theater.SelectedItem as string); map.Resize((int)nmd.width.Value, (int)nmd.height.Value); map.ResizeCordon((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value, @@ -357,8 +352,7 @@ namespace OpenRA.Editor map.Players.Add("Neutral", new PlayerReference("Neutral", Rules.Info["world"].Traits.WithInterface().First().Race, true, true)); - // TODO: Set map.Container using savePath - map.Save(); + map.Save(savePath); LoadMap(savePath); loadedMapName = null; /* editor needs to think this hasnt been saved */ diff --git a/OpenRA.Editor/MapSelect.cs b/OpenRA.Editor/MapSelect.cs index be8cf7574b..f043db68c3 100644 --- a/OpenRA.Editor/MapSelect.cs +++ b/OpenRA.Editor/MapSelect.cs @@ -45,8 +45,8 @@ namespace OpenRA.Editor { txtNew.Text = MapList.SelectedItems[0].Text; txtNew.Tag = MapList.SelectedItems[0].Tag; - System.Console.WriteLine(MapList.SelectedItems[0]); - var map = new Map(txtNew.Tag as string); + + var map = new Map(txtNew.Tag as string); txtTitle.Text = map.Title; txtAuthor.Text = map.Author; txtTheater.Text = map.Tileset; diff --git a/OpenRA.FileFormats/Map/MapStub.cs b/OpenRA.FileFormats/Map/MapStub.cs index 5622cd37db..716b716ca7 100644 --- a/OpenRA.FileFormats/Map/MapStub.cs +++ b/OpenRA.FileFormats/Map/MapStub.cs @@ -19,7 +19,7 @@ namespace OpenRA.FileFormats public class MapStub { protected IFolder Container; - public string Path; + public string Path {get; protected set;} // Yaml map data public string Uid { get; protected set; } diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index 547810e5c3..f19be4927f 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -53,7 +53,7 @@ namespace OpenRA // Do nothing; not a valid map (editor hack) } - public static Map NewWithTileset(string tileset) + public static Map FromTileset(string tileset) { Map map = new Map(); map.MapSize = new int2(1, 1); @@ -194,8 +194,18 @@ namespace OpenRA LoadBinaryData(); } - public void Save() + public void Save(string toPath) { + // Saving the map to a new location + if (toPath != Path) + { + // TODO: Copy all other files (resources, rules) in the map package + Path = toPath; + + // TODO: This doesn't work - need a FileSystem.CreatePackage() + Container = FileSystem.OpenPackage(Path, int.MaxValue); + } + // Todo: save to a zip file in the support dir by default MapFormat = 3;