2013-09-07 05:17:29 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2013-10-25 00:57:23 +00:00
|
|
|
|
using System.IO;
|
2013-09-07 05:17:29 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2013-11-04 01:39:19 +00:00
|
|
|
|
using BizHawk.Emulation.Common;
|
2014-09-01 18:43:41 +00:00
|
|
|
|
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Client.Common;
|
2014-07-27 15:22:30 +00:00
|
|
|
|
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
2013-10-25 00:57:23 +00:00
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2013-09-07 05:17:29 +00:00
|
|
|
|
{
|
2013-11-28 22:06:38 +00:00
|
|
|
|
public static class ToolHelpers
|
2013-09-07 05:17:29 +00:00
|
|
|
|
{
|
2013-12-10 02:13:50 +00:00
|
|
|
|
public static FileInfo GetTasProjFileFromUser(string currentFile)
|
|
|
|
|
{
|
|
|
|
|
var ofd = new OpenFileDialog();
|
2014-03-01 16:30:06 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(currentFile))
|
2013-12-10 02:13:50 +00:00
|
|
|
|
{
|
|
|
|
|
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-13 05:20:50 +00:00
|
|
|
|
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);
|
2013-12-10 02:13:50 +00:00
|
|
|
|
ofd.Filter = "Tas Project Files (*.tasproj)|*.tasproj|All Files|*.*";
|
|
|
|
|
ofd.RestoreDirectory = true;
|
|
|
|
|
|
|
|
|
|
var result = ofd.ShowHawkDialog();
|
|
|
|
|
if (result != DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new FileInfo(ofd.FileName);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-10 01:45:45 +00:00
|
|
|
|
public static FileInfo GetTasProjSaveFileFromUser(string currentFile)
|
|
|
|
|
{
|
|
|
|
|
var sfd = new SaveFileDialog();
|
2014-03-01 16:30:06 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(currentFile))
|
2013-12-10 01:45:45 +00:00
|
|
|
|
{
|
|
|
|
|
sfd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
|
|
|
|
sfd.InitialDirectory = Path.GetDirectoryName(currentFile);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-01-02 17:22:17 +00:00
|
|
|
|
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
|
2013-12-13 05:20:50 +00:00
|
|
|
|
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);
|
2013-12-10 01:45:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sfd.Filter = "Tas Project Files (*.tasproj)|*.tasproj|All Files|*.*";
|
|
|
|
|
sfd.RestoreDirectory = true;
|
|
|
|
|
var result = sfd.ShowHawkDialog();
|
|
|
|
|
if (result != DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new FileInfo(sfd.FileName);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-27 07:54:00 +00:00
|
|
|
|
public static FileInfo GetWatchFileFromUser(string currentFile)
|
|
|
|
|
{
|
|
|
|
|
var ofd = new OpenFileDialog();
|
2014-03-01 16:30:06 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(currentFile))
|
2013-10-27 07:54:00 +00:00
|
|
|
|
{
|
|
|
|
|
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
|
|
|
|
}
|
2013-11-28 22:06:38 +00:00
|
|
|
|
|
2013-12-13 05:20:50 +00:00
|
|
|
|
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null);
|
2013-10-27 07:54:00 +00:00
|
|
|
|
ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
|
|
|
|
|
ofd.RestoreDirectory = true;
|
|
|
|
|
|
2013-11-28 22:39:00 +00:00
|
|
|
|
var result = ofd.ShowHawkDialog();
|
2013-10-27 07:54:00 +00:00
|
|
|
|
if (result != DialogResult.OK)
|
2013-11-28 22:06:38 +00:00
|
|
|
|
{
|
2013-10-27 07:54:00 +00:00
|
|
|
|
return null;
|
2013-11-28 22:06:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new FileInfo(ofd.FileName);
|
2013-10-27 07:54:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FileInfo GetWatchSaveFileFromUser(string currentFile)
|
|
|
|
|
{
|
|
|
|
|
var sfd = new SaveFileDialog();
|
2014-03-01 16:30:06 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(currentFile))
|
2013-10-27 07:54:00 +00:00
|
|
|
|
{
|
|
|
|
|
sfd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
|
|
|
|
sfd.InitialDirectory = Path.GetDirectoryName(currentFile);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-01-02 17:22:17 +00:00
|
|
|
|
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
|
2013-12-13 05:20:50 +00:00
|
|
|
|
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null);
|
2013-10-27 07:54:00 +00:00
|
|
|
|
}
|
2013-11-28 22:06:38 +00:00
|
|
|
|
|
2013-10-27 07:54:00 +00:00
|
|
|
|
sfd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
|
|
|
|
|
sfd.RestoreDirectory = true;
|
2013-11-28 22:39:00 +00:00
|
|
|
|
var result = sfd.ShowHawkDialog();
|
2013-10-27 07:54:00 +00:00
|
|
|
|
if (result != DialogResult.OK)
|
2013-11-28 22:06:38 +00:00
|
|
|
|
{
|
2013-10-27 07:54:00 +00:00
|
|
|
|
return null;
|
2013-11-28 22:06:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new FileInfo(sfd.FileName);
|
2013-10-27 07:54:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-25 00:57:23 +00:00
|
|
|
|
public static FileInfo GetCheatFileFromUser(string currentFile)
|
|
|
|
|
{
|
|
|
|
|
var ofd = new OpenFileDialog();
|
2014-03-01 16:30:06 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(currentFile))
|
2013-10-25 00:57:23 +00:00
|
|
|
|
{
|
|
|
|
|
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
|
|
|
|
}
|
2013-11-28 22:06:38 +00:00
|
|
|
|
|
2013-10-25 00:57:23 +00:00
|
|
|
|
ofd.InitialDirectory = PathManager.GetCheatsPath(Global.Game);
|
|
|
|
|
ofd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
|
|
|
|
|
ofd.RestoreDirectory = true;
|
|
|
|
|
|
2013-11-28 22:39:00 +00:00
|
|
|
|
var result = ofd.ShowHawkDialog();
|
2013-10-25 00:57:23 +00:00
|
|
|
|
if (result != DialogResult.OK)
|
2013-11-28 22:06:38 +00:00
|
|
|
|
{
|
2013-10-25 00:57:23 +00:00
|
|
|
|
return null;
|
2013-11-28 22:06:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new FileInfo(ofd.FileName);
|
2013-10-25 00:57:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FileInfo GetCheatSaveFileFromUser(string currentFile)
|
|
|
|
|
{
|
|
|
|
|
var sfd = new SaveFileDialog();
|
2014-03-01 16:30:06 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(currentFile))
|
2013-10-25 00:57:23 +00:00
|
|
|
|
{
|
|
|
|
|
sfd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
|
|
|
|
}
|
2013-11-28 22:06:38 +00:00
|
|
|
|
|
2013-10-25 00:57:23 +00:00
|
|
|
|
sfd.InitialDirectory = PathManager.GetCheatsPath(Global.Game);
|
|
|
|
|
sfd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
|
|
|
|
|
sfd.RestoreDirectory = true;
|
2013-11-28 22:39:00 +00:00
|
|
|
|
var result = sfd.ShowHawkDialog();
|
2013-10-25 00:57:23 +00:00
|
|
|
|
if (result != DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 12:22:53 +00:00
|
|
|
|
return new FileInfo(sfd.FileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FileInfo GetCdlFileFromUser(string currentFile)
|
|
|
|
|
{
|
|
|
|
|
var ofd = new OpenFileDialog
|
|
|
|
|
{
|
|
|
|
|
Filter = "Code Data Logger Files (*.cdl)|*.cdl|All Files|*.*",
|
|
|
|
|
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null),
|
|
|
|
|
RestoreDirectory = true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(currentFile))
|
|
|
|
|
{
|
|
|
|
|
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = ofd.ShowHawkDialog();
|
|
|
|
|
if (result != DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new FileInfo(ofd.FileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FileInfo GetCdlSaveFileFromUser(string currentFile)
|
|
|
|
|
{
|
|
|
|
|
var sfd = new SaveFileDialog
|
|
|
|
|
{
|
|
|
|
|
Filter = "Code Data Logger Files (*.cdl)|*.cdl|All Files|*.*",
|
|
|
|
|
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null),
|
|
|
|
|
RestoreDirectory = true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(currentFile))
|
|
|
|
|
{
|
|
|
|
|
sfd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = sfd.ShowHawkDialog();
|
|
|
|
|
if (result != DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new FileInfo(sfd.FileName);
|
2013-10-25 00:57:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-16 16:30:20 +00:00
|
|
|
|
public static void UpdateCheatRelatedTools(object sender, CheatCollection.CheatListEventArgs e)
|
2013-09-23 16:01:19 +00:00
|
|
|
|
{
|
2014-09-01 18:43:41 +00:00
|
|
|
|
if (Global.Emulator.HasMemoryDomains())
|
2013-11-07 20:33:29 +00:00
|
|
|
|
{
|
2014-09-01 18:43:41 +00:00
|
|
|
|
GlobalWin.Tools.UpdateValues<RamWatch>();
|
|
|
|
|
GlobalWin.Tools.UpdateValues<RamSearch>();
|
|
|
|
|
GlobalWin.Tools.UpdateValues<HexEditor>();
|
|
|
|
|
|
|
|
|
|
if (GlobalWin.Tools.Has<Cheats>())
|
|
|
|
|
{
|
|
|
|
|
GlobalWin.Tools.Cheats.UpdateDialog();
|
|
|
|
|
}
|
2013-11-07 20:33:29 +00:00
|
|
|
|
|
2014-09-01 18:43:41 +00:00
|
|
|
|
GlobalWin.MainForm.UpdateCheatStatus();
|
|
|
|
|
}
|
2013-10-14 01:37:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-18 18:01:27 +00:00
|
|
|
|
public static void ViewInHexEditor(MemoryDomain domain, IEnumerable<long> addresses, Watch.WatchSize size)
|
2013-09-29 16:09:48 +00:00
|
|
|
|
{
|
2013-11-03 16:07:58 +00:00
|
|
|
|
GlobalWin.Tools.Load<HexEditor>();
|
2014-07-28 01:24:57 +00:00
|
|
|
|
GlobalWin.Tools.HexEditor.SetToAddresses(addresses, domain, size);
|
2013-09-29 16:09:48 +00:00
|
|
|
|
}
|
2013-09-07 05:17:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|