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)
{
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);
}
}

View File

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