diff --git a/OpenRA.Editor/Form1.Designer.cs b/OpenRA.Editor/Form1.Designer.cs index ebf25e08f5..07f47175c4 100755 --- a/OpenRA.Editor/Form1.Designer.cs +++ b/OpenRA.Editor/Form1.Designer.cs @@ -85,8 +85,6 @@ namespace OpenRA.Editor this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.redAlertMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.miniMapExport = new System.Windows.Forms.ToolStripMenuItem(); this.miniMapToPng = new System.Windows.Forms.ToolStripMenuItem(); this.fullMapRenderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -582,7 +580,6 @@ namespace OpenRA.Editor this.saveToolStripMenuItem, this.saveAsToolStripMenuItem, this.toolStripSeparator2, - this.toolStripMenuItem1, this.miniMapExport, this.toolStripSeparator3, this.exitToolStripMenuItem}); @@ -639,25 +636,6 @@ namespace OpenRA.Editor this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Size = new System.Drawing.Size(120, 6); // - // toolStripMenuItem1 - // - this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.redAlertMapToolStripMenuItem}); - this.toolStripMenuItem1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripMenuItem1.Image"))); - this.toolStripMenuItem1.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(123, 22); - this.toolStripMenuItem1.Text = "&Import"; - // - // cCRedAlertMapToolStripMenuItem - // - this.redAlertMapToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("cCRedAlertMapToolStripMenuItem.Image"))); - this.redAlertMapToolStripMenuItem.Name = "cCRedAlertMapToolStripMenuItem"; - this.redAlertMapToolStripMenuItem.Size = new System.Drawing.Size(188, 22); - this.redAlertMapToolStripMenuItem.Text = "&Legacy Map Format..."; - this.redAlertMapToolStripMenuItem.ToolTipText = "Import an original C&C / Red Alert and convert it to the .oramap format."; - this.redAlertMapToolStripMenuItem.Click += new System.EventHandler(this.ImportLegacyMapClicked); - // // mnuExport // this.miniMapExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -1097,8 +1075,6 @@ namespace OpenRA.Editor private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem redAlertMapToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem miniMapExport; private System.Windows.Forms.ToolStripMenuItem miniMapToPng; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index b3ffb39b5e..92bc01f224 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -437,37 +437,6 @@ namespace OpenRA.Editor Close(); } - void ImportLegacyMapClicked(object sender, EventArgs e) - { - using (var ofd = new OpenFileDialog { RestoreDirectory = true, - Filter = "Legacy maps (*.ini;*.mpr)|*.ini;*.mpr" }) - if (DialogResult.OK == ofd.ShowDialog()) - { - /* massive hack: we should be able to call NewMap() with the imported Map object, - * but something's not right internally in it, unless loaded via the real maploader */ - - var savePath = Path.Combine(Path.GetTempPath(), "OpenRA.Import"); - Directory.CreateDirectory(savePath); - - var errors = new List(); - - var map = LegacyMapImporter.Import(ofd.FileName, a => errors.Add(a)); - - if (errors.Count > 0) - using (var eld = new ErrorListDialog(errors)) - eld.ShowDialog(); - - map.MakeDefaultPlayers(); - - map.Save(savePath); - LoadMap(savePath); - loadedMapName = null; /* editor needs to think this hasnt been saved */ - - Directory.Delete(savePath, true); - MakeDirty(); - } - } - void OnFormClosing(object sender, FormClosingEventArgs e) { if (!dirty) return; diff --git a/OpenRA.Editor/OpenRA.Editor.csproj b/OpenRA.Editor/OpenRA.Editor.csproj index be2dd5e5fa..2b4313d66a 100644 --- a/OpenRA.Editor/OpenRA.Editor.csproj +++ b/OpenRA.Editor/OpenRA.Editor.csproj @@ -96,7 +96,6 @@ Form1.cs - Form diff --git a/OpenRA.Utility/Command.cs b/OpenRA.Utility/Command.cs index ff230b4430..4f846c5a1d 100644 --- a/OpenRA.Utility/Command.cs +++ b/OpenRA.Utility/Command.cs @@ -331,5 +331,20 @@ namespace OpenRA.Utility Game.modData = new ModData(mod); new Map(map, mod); } + + [Desc("MOD", "FILENAME", "Convert a legacy INI/MPR map to the OpenRA format.")] + public static void ImportLegacyMap(string[] args) + { + var mod = args[1]; + var filename = args[2]; + Game.modData = new ModData(mod); + Rules.LoadRules(Game.modData.Manifest, new Map()); + var map = LegacyMapImporter.Import(filename, e => Console.WriteLine(e)); + map.RequiresMod = mod; + map.MakeDefaultPlayers(); + var dest = map.Title + ".oramap"; + map.Save(dest); + Console.WriteLine(dest + " saved."); + } } } diff --git a/OpenRA.Editor/LegacyMapImporter.cs b/OpenRA.Utility/LegacyMapImporter.cs similarity index 99% rename from OpenRA.Editor/LegacyMapImporter.cs rename to OpenRA.Utility/LegacyMapImporter.cs index f1dab220e1..640c676c48 100644 --- a/OpenRA.Editor/LegacyMapImporter.cs +++ b/OpenRA.Utility/LegacyMapImporter.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -18,7 +18,7 @@ using System.Text; using OpenRA.FileFormats; using OpenRA.Traits; -namespace OpenRA.Editor +namespace OpenRA.Utility { public class LegacyMapImporter { diff --git a/OpenRA.Utility/OpenRA.Utility.csproj b/OpenRA.Utility/OpenRA.Utility.csproj index 085267930e..3fa93c808b 100644 --- a/OpenRA.Utility/OpenRA.Utility.csproj +++ b/OpenRA.Utility/OpenRA.Utility.csproj @@ -77,6 +77,7 @@ + diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index 06914d0119..a6ef3850b4 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -32,6 +32,7 @@ namespace OpenRA.Utility { "--map-upgrade-v5", Command.UpgradeV5Map }, { "--upgrade-map", UpgradeRules.UpgradeMap }, { "--upgrade-mod", UpgradeRules.UpgradeMod }, + { "--map-import", Command.ImportLegacyMap } }; static void Main(string[] args)