Remove some duplication

This commit is contained in:
Paul Chote
2010-12-29 21:41:04 +13:00
parent fc6438e311
commit e652a15b01
2 changed files with 9 additions and 15 deletions

View File

@@ -254,11 +254,8 @@ namespace OpenRA.Editor
void SaveAsClicked(object sender, EventArgs e) 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.txtNew.ReadOnly = false;
nms.btnOk.Text = "Save"; nms.btnOk.Text = "Save";
nms.txtNew.Text = "unnamed"; nms.txtNew.Text = "unnamed";
@@ -281,21 +278,14 @@ namespace OpenRA.Editor
void OpenClicked(object sender, EventArgs e) 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.txtNew.ReadOnly = true;
nms.txtPathOut.ReadOnly = true; nms.txtPathOut.ReadOnly = true;
nms.btnOk.Text = "Open"; nms.btnOk.Text = "Open";
if (DialogResult.OK == nms.ShowDialog()) if (DialogResult.OK == nms.ShowDialog())
{ LoadMap(nms.txtNew.Tag as string);
var path = nms.txtNew.Tag as string;
System.Console.WriteLine("OpenClicked: {0}", path);
LoadMap(path);
}
} }
} }

View File

@@ -3,6 +3,7 @@ using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;
using System.Linq;
namespace OpenRA.Editor namespace OpenRA.Editor
{ {
@@ -10,8 +11,11 @@ namespace OpenRA.Editor
{ {
public string MapFolderPath; public string MapFolderPath;
public MapSelect() public MapSelect(string currentMod)
{ {
MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", currentMod, "maps" }
.Aggregate(Path.Combine);
InitializeComponent(); InitializeComponent();
MapIconsList.Images.Add(pictureBox1.Image); MapIconsList.Images.Add(pictureBox1.Image);
} }