Wire up most of saving again.
This commit is contained in:
@@ -61,8 +61,6 @@ namespace OpenRA.Editor
|
||||
|
||||
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<CountryInfo>().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 */
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user