Wire up most of saving again.

This commit is contained in:
Paul Chote
2010-12-29 22:13:51 +13:00
parent e652a15b01
commit b7975031bc
4 changed files with 18 additions and 14 deletions

View File

@@ -61,8 +61,6 @@ namespace OpenRA.Editor
Game.modData = new ModData(currentMod); Game.modData = new ModData(currentMod);
System.Console.WriteLine("Loading map: {0}",mapname);
// load the map // load the map
var map = new Map(mapname); var map = new Map(mapname);
@@ -246,7 +244,7 @@ namespace OpenRA.Editor
else else
{ {
surface1.Map.PlayerCount = surface1.Map.Waypoints.Count; surface1.Map.PlayerCount = surface1.Map.Waypoints.Count;
surface1.Map.Save(); surface1.Map.Save(loadedMapName);
dirty = false; dirty = false;
} }
@@ -268,9 +266,6 @@ namespace OpenRA.Editor
// TODO: Allow the user to choose map format (directory vs oramap) // TODO: Allow the user to choose map format (directory vs oramap)
loadedMapName = Path.Combine(nms.MapFolderPath, nms.txtNew.Text + ".oramap"); loadedMapName = Path.Combine(nms.MapFolderPath, nms.txtNew.Text + ".oramap");
// TODO: Change surface1.Map.Container if necessary
SaveClicked(sender, e); SaveClicked(sender, e);
} }
} }
@@ -299,7 +294,7 @@ namespace OpenRA.Editor
if (DialogResult.OK == nmd.ShowDialog()) 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.Resize((int)nmd.width.Value, (int)nmd.height.Value);
map.ResizeCordon((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.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", map.Players.Add("Neutral", new PlayerReference("Neutral",
Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true)); Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
// TODO: Set map.Container using savePath map.Save(savePath);
map.Save();
LoadMap(savePath); LoadMap(savePath);
loadedMapName = null; /* editor needs to think this hasnt been saved */ loadedMapName = null; /* editor needs to think this hasnt been saved */

View File

@@ -45,8 +45,8 @@ namespace OpenRA.Editor
{ {
txtNew.Text = MapList.SelectedItems[0].Text; txtNew.Text = MapList.SelectedItems[0].Text;
txtNew.Tag = MapList.SelectedItems[0].Tag; 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; txtTitle.Text = map.Title;
txtAuthor.Text = map.Author; txtAuthor.Text = map.Author;
txtTheater.Text = map.Tileset; txtTheater.Text = map.Tileset;

View File

@@ -19,7 +19,7 @@ namespace OpenRA.FileFormats
public class MapStub public class MapStub
{ {
protected IFolder Container; protected IFolder Container;
public string Path; public string Path {get; protected set;}
// Yaml map data // Yaml map data
public string Uid { get; protected set; } public string Uid { get; protected set; }

View File

@@ -53,7 +53,7 @@ namespace OpenRA
// Do nothing; not a valid map (editor hack) // 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 map = new Map();
map.MapSize = new int2(1, 1); map.MapSize = new int2(1, 1);
@@ -194,8 +194,18 @@ namespace OpenRA
LoadBinaryData(); 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 // Todo: save to a zip file in the support dir by default
MapFormat = 3; MapFormat = 3;