remove GlobalWin.Game usage in ToolFormBase

This commit is contained in:
adelikat 2020-11-27 14:59:50 -06:00
parent cd146c0f79
commit e9ca84f8bd
6 changed files with 39 additions and 9 deletions

View File

@ -359,8 +359,14 @@ namespace BizHawk.Client.EmuHawk
private void SaveAsMenuItem_Click(object sender, EventArgs e)
{
var fileName = CurrentFileName;
if (string.IsNullOrWhiteSpace(fileName))
{
fileName = Game.FilesystemSafeName();
}
var file = SaveFileDialog(
CurrentFileName,
fileName,
Config.PathEntries.ToolsAbsolutePath(),
"Bot files",
"bot",

View File

@ -384,8 +384,14 @@ namespace BizHawk.Client.EmuHawk
/// </summary>
private bool RunSaveAs()
{
var fileName = _currentFilename;
if (string.IsNullOrWhiteSpace(fileName))
{
fileName = Game.FilesystemSafeName();
}
var file = SaveFileDialog(
_currentFilename,
fileName,
Config.PathEntries.LogAbsolutePath(),
"Code Data Logger Files",
"cdl",

View File

@ -139,8 +139,14 @@ namespace BizHawk.Client.EmuHawk
private bool SaveAs()
{
var fileName = MainForm.CheatList.CurrentFileName;
if (string.IsNullOrWhiteSpace(fileName))
{
fileName = Game.FilesystemSafeName();
}
var file = SaveFileDialog(
MainForm.CheatList.CurrentFileName,
fileName,
Config.PathEntries.CheatsAbsolutePath(Game.System),
"Cheat Files",
"cht",

View File

@ -86,9 +86,7 @@ namespace BizHawk.Client.EmuHawk
using var sfd = new SaveFileDialog
{
FileName = !string.IsNullOrWhiteSpace(currentFile)
? Path.GetFileName(currentFile)
: $"{GlobalWin.Game.FilesystemSafeName()}.{fileExt}",
FileName = Path.GetFileName(currentFile),
InitialDirectory = path,
Filter = new FilesystemFilterSet(new FilesystemFilter(fileType, new[] { fileExt })).ToString(),
RestoreDirectory = true

View File

@ -975,6 +975,13 @@ namespace BizHawk.Client.EmuHawk
sender == TruncateFromFileMenuItem);
}
private string CurrentFileName()
{
return !string.IsNullOrWhiteSpace(_currentFileName)
? _currentFileName
: Game.FilesystemSafeName();
}
private void SaveMenuItem_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(_currentFileName))
@ -996,7 +1003,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
var result = watches.SaveAs(GetWatchSaveFileFromUser(watches.CurrentFileName));
var result = watches.SaveAs(GetWatchSaveFileFromUser(CurrentFileName()));
if (result)
{
MessageLabel.Text = $"{Path.GetFileName(_currentFileName)} saved";
@ -1014,7 +1021,7 @@ namespace BizHawk.Client.EmuHawk
watches.Add(_searches[i]);
}
if (watches.SaveAs(GetWatchSaveFileFromUser(watches.CurrentFileName)))
if (watches.SaveAs(GetWatchSaveFileFromUser(CurrentFileName())))
{
_currentFileName = watches.CurrentFileName;
MessageLabel.Text = $"{Path.GetFileName(_currentFileName)} saved";

View File

@ -525,9 +525,16 @@ namespace BizHawk.Client.EmuHawk
WatchListView.Refresh();
}
private string CurrentFileName()
{
return !string.IsNullOrWhiteSpace(_watches.CurrentFileName)
? _watches.CurrentFileName
: Game.FilesystemSafeName();
}
private void SaveAs()
{
var result = _watches.SaveAs(GetWatchSaveFileFromUser(_watches.CurrentFileName));
var result = _watches.SaveAs(GetWatchSaveFileFromUser(CurrentFileName()));
if (result)
{
UpdateStatusBar(saved: true);