diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj
index 84d52d8fda..22d2431803 100644
--- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj
+++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj
@@ -107,6 +107,7 @@
+
diff --git a/BizHawk.MultiClient/tools/Watch/WatchList.cs b/BizHawk.Client.Common/tools/WatchList.cs
similarity index 81%
rename from BizHawk.MultiClient/tools/Watch/WatchList.cs
rename to BizHawk.Client.Common/tools/WatchList.cs
index b8fd0c0dac..8665e9dd9c 100644
--- a/BizHawk.MultiClient/tools/Watch/WatchList.cs
+++ b/BizHawk.Client.Common/tools/WatchList.cs
@@ -4,16 +4,11 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
-using System.Windows.Forms;
-using BizHawk.Client.Common;
-
-namespace BizHawk.MultiClient
+namespace BizHawk.Client.Common
{
public class WatchList : IEnumerable
{
-
-
public const string ADDRESS = "AddressColumn";
public const string VALUE = "ValueColumn";
public const string PREV = "PrevColumn";
@@ -297,26 +292,6 @@ namespace BizHawk.MultiClient
public string CurrentFileName { get { return _currentFilename; } set { _currentFilename = value; } }
public bool Changes { get; set; }
- public bool Save()
- {
- bool result;
- if (!String.IsNullOrWhiteSpace(CurrentFileName))
- {
- result = SaveFile();
- }
- else
- {
- result = SaveAs();
- }
-
- if (result)
- {
- Changes = false;
- }
-
- return result;
- }
-
public bool Load(string path, bool append)
{
bool result = LoadFile(path, append);
@@ -346,7 +321,7 @@ namespace BizHawk.MultiClient
}
}
- private bool SaveFile()
+ public bool Save()
{
if (String.IsNullOrWhiteSpace(CurrentFileName))
{
@@ -380,13 +355,12 @@ namespace BizHawk.MultiClient
return true;
}
- public bool SaveAs()
+ public bool SaveAs(FileInfo file)
{
- var file = GetSaveFileFromUser(CurrentFileName);
if (file != null)
{
CurrentFileName = file.FullName;
- return SaveFile();
+ return Save();
}
else
{
@@ -546,53 +520,6 @@ namespace BizHawk.MultiClient
return 0;
}
- public static FileInfo GetFileFromUser(string currentFile)
- {
- var ofd = new OpenFileDialog();
- if (currentFile.Length > 0)
- ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
- ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath, null);
- ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
- ofd.RestoreDirectory = true;
-
- GlobalWinF.Sound.StopSound();
- var result = ofd.ShowDialog();
- GlobalWinF.Sound.StartSound();
- if (result != DialogResult.OK)
- return null;
- var file = new FileInfo(ofd.FileName);
- return file;
- }
-
- public static FileInfo GetSaveFileFromUser(string currentFile)
- {
- var sfd = new SaveFileDialog();
- if (currentFile.Length > 0)
- {
- sfd.FileName = Path.GetFileNameWithoutExtension(currentFile);
- sfd.InitialDirectory = Path.GetDirectoryName(currentFile);
- }
- else if (!(Global.Emulator is NullEmulator))
- {
- sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
- sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath, null);
- }
- else
- {
- sfd.FileName = "NULL";
- sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath, null);
- }
- sfd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
- sfd.RestoreDirectory = true;
- GlobalWinF.Sound.StopSound();
- var result = sfd.ShowDialog();
- GlobalWinF.Sound.StartSound();
- if (result != DialogResult.OK)
- return null;
- var file = new FileInfo(sfd.FileName);
- return file;
- }
-
#endregion
}
}
diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj
index aa7275b8e6..7767909ba5 100644
--- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj
+++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj
@@ -741,7 +741,6 @@
WatchEditor.cs
-
Component
diff --git a/BizHawk.MultiClient/tools/ToolHelpers.cs b/BizHawk.MultiClient/tools/ToolHelpers.cs
index 705c39cbdc..903c8ab1c7 100644
--- a/BizHawk.MultiClient/tools/ToolHelpers.cs
+++ b/BizHawk.MultiClient/tools/ToolHelpers.cs
@@ -11,6 +11,55 @@ namespace BizHawk.MultiClient
{
class ToolHelpers
{
+ public static FileInfo GetWatchFileFromUser(string currentFile)
+ {
+ var ofd = new OpenFileDialog();
+ if (!String.IsNullOrWhiteSpace(currentFile))
+ {
+ ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
+ }
+ ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath, null);
+ ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
+ ofd.RestoreDirectory = true;
+
+ GlobalWinF.Sound.StopSound();
+ var result = ofd.ShowDialog();
+ GlobalWinF.Sound.StartSound();
+ if (result != DialogResult.OK)
+ return null;
+ var file = new FileInfo(ofd.FileName);
+ return file;
+ }
+
+ public static FileInfo GetWatchSaveFileFromUser(string currentFile)
+ {
+ var sfd = new SaveFileDialog();
+ if (!String.IsNullOrWhiteSpace(currentFile))
+ {
+ sfd.FileName = Path.GetFileNameWithoutExtension(currentFile);
+ sfd.InitialDirectory = Path.GetDirectoryName(currentFile);
+ }
+ else if (!(Global.Emulator is NullEmulator))
+ {
+ sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
+ sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath, null);
+ }
+ else
+ {
+ sfd.FileName = "NULL";
+ sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath, null);
+ }
+ sfd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
+ sfd.RestoreDirectory = true;
+ GlobalWinF.Sound.StopSound();
+ var result = sfd.ShowDialog();
+ GlobalWinF.Sound.StartSound();
+ if (result != DialogResult.OK)
+ return null;
+ var file = new FileInfo(sfd.FileName);
+ return file;
+ }
+
public static FileInfo GetCheatFileFromUser(string currentFile)
{
var ofd = new OpenFileDialog();
diff --git a/BizHawk.MultiClient/tools/Watch/RamSearch.cs b/BizHawk.MultiClient/tools/Watch/RamSearch.cs
index 626dd6f03b..adda680004 100644
--- a/BizHawk.MultiClient/tools/Watch/RamSearch.cs
+++ b/BizHawk.MultiClient/tools/Watch/RamSearch.cs
@@ -911,7 +911,7 @@ namespace BizHawk.MultiClient
private void OpenMenuItem_Click(object sender, EventArgs e)
{
LoadWatchFile(
- WatchList.GetFileFromUser(String.Empty),
+ ToolHelpers.GetWatchFileFromUser(String.Empty),
sender == AppendFileMenuItem,
sender == TruncateFromFileMenuItem
);
@@ -928,10 +928,22 @@ namespace BizHawk.MultiClient
watches.Add(Searches[i]);
}
- if (watches.Save())
+ if (!String.IsNullOrWhiteSpace(watches.CurrentFileName))
{
- CurrentFileName = watches.CurrentFileName;
- MessageLabel.Text = Path.GetFileName(CurrentFileName) + " saved";
+ if (watches.Save())
+ {
+ CurrentFileName = watches.CurrentFileName;
+ MessageLabel.Text = Path.GetFileName(CurrentFileName) + " saved";
+ }
+ }
+ else
+ {
+ bool result = watches.SaveAs(ToolHelpers.GetWatchSaveFileFromUser(watches.CurrentFileName));
+ if (result)
+ {
+ MessageLabel.Text = Path.GetFileName(CurrentFileName) + " saved";
+ Global.Config.RecentWatches.Add(watches.CurrentFileName);
+ }
}
}
}
@@ -945,7 +957,7 @@ namespace BizHawk.MultiClient
watches.Add(Searches[i]);
}
- if (watches.SaveAs())
+ if (watches.SaveAs(ToolHelpers.GetWatchSaveFileFromUser(watches.CurrentFileName)))
{
CurrentFileName = watches.CurrentFileName;
MessageLabel.Text = Path.GetFileName(CurrentFileName) + " saved";
diff --git a/BizHawk.MultiClient/tools/Watch/RamWatch.cs b/BizHawk.MultiClient/tools/Watch/RamWatch.cs
index f9781f5167..2cab1aa448 100644
--- a/BizHawk.MultiClient/tools/Watch/RamWatch.cs
+++ b/BizHawk.MultiClient/tools/Watch/RamWatch.cs
@@ -737,6 +737,16 @@ namespace BizHawk.MultiClient
WatchListView.Refresh();
}
+ private void SaveAs()
+ {
+ bool result = Watches.SaveAs(ToolHelpers.GetWatchSaveFileFromUser(Watches.CurrentFileName));
+ if (result)
+ {
+ UpdateMessageLabel(saved: true);
+ Global.Config.RecentWatches.Add(Watches.CurrentFileName);
+ }
+ }
+
#region Winform Events
private void NewRamWatch_Load(object sender, EventArgs e)
@@ -783,25 +793,27 @@ namespace BizHawk.MultiClient
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
bool append = sender == appendFileToolStripMenuItem;
- LoadWatchFile(WatchList.GetFileFromUser(Watches.CurrentFileName), append);
+ LoadWatchFile(ToolHelpers.GetWatchFileFromUser(Watches.CurrentFileName), append);
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
- if (Watches.Save())
+ if (!String.IsNullOrWhiteSpace(Watches.CurrentFileName))
{
- UpdateMessageLabel(saved: true);
+ if (Watches.Save())
+ {
+ UpdateMessageLabel(saved: true);
+ }
+ }
+ else
+ {
+ SaveAs();
}
}
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
- bool result = Watches.SaveAs();
- if (result)
- {
- UpdateMessageLabel(saved: true);
- Global.Config.RecentWatches.Add(Watches.CurrentFileName);
- }
+ SaveAs();
}
private void recentToolStripMenuItem_DropDownOpened(object sender, EventArgs e)