From e652a15b01b626b6bd954e6ea6b14794dbe52041 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 29 Dec 2010 21:41:04 +1300 Subject: [PATCH] Remove some duplication --- OpenRA.Editor/Form1.cs | 16 +++------------- OpenRA.Editor/MapSelect.cs | 8 ++++++-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index edf0430807..84296785f2 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -254,11 +254,8 @@ namespace OpenRA.Editor void SaveAsClicked(object sender, EventArgs e) { - using (var nms = new MapSelect()) + using (var nms = new MapSelect(currentMod)) { - nms.MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", currentMod, "maps" } - .Aggregate(Path.Combine); - nms.txtNew.ReadOnly = false; nms.btnOk.Text = "Save"; nms.txtNew.Text = "unnamed"; @@ -281,21 +278,14 @@ namespace OpenRA.Editor void OpenClicked(object sender, EventArgs e) { - using (var nms = new MapSelect()) + using (var nms = new MapSelect(currentMod)) { - nms.MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", currentMod, "maps" } - .Aggregate(Path.Combine); - nms.txtNew.ReadOnly = true; nms.txtPathOut.ReadOnly = true; nms.btnOk.Text = "Open"; if (DialogResult.OK == nms.ShowDialog()) - { - var path = nms.txtNew.Tag as string; - System.Console.WriteLine("OpenClicked: {0}", path); - LoadMap(path); - } + LoadMap(nms.txtNew.Tag as string); } } diff --git a/OpenRA.Editor/MapSelect.cs b/OpenRA.Editor/MapSelect.cs index bc77d2dadb..be8cf7574b 100644 --- a/OpenRA.Editor/MapSelect.cs +++ b/OpenRA.Editor/MapSelect.cs @@ -3,6 +3,7 @@ using System.IO; using System.Windows.Forms; using OpenRA.FileFormats; using OpenRA.Graphics; +using System.Linq; namespace OpenRA.Editor { @@ -10,9 +11,12 @@ namespace OpenRA.Editor { public string MapFolderPath; - public MapSelect() + public MapSelect(string currentMod) { - InitializeComponent(); + MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", currentMod, "maps" } + .Aggregate(Path.Combine); + + InitializeComponent(); MapIconsList.Images.Add(pictureBox1.Image); }