Lua console - unify Save/SaveAs logic and remove a now unnecessary LuaFileList method

This commit is contained in:
adelikat 2020-05-31 11:17:35 -05:00
parent 5a44a99118
commit 4be160a71f
2 changed files with 14 additions and 26 deletions

View File

@ -94,15 +94,6 @@ namespace BizHawk.Client.Common
Filename = path;
return true;
}
public void SaveSession()
{
if (!string.IsNullOrWhiteSpace(Filename))
{
SaveSession(Filename);
}
}
public void SaveSession(string path)

View File

@ -690,14 +690,7 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Sound.StartSound();
if (result == DialogResult.Yes)
{
if (!string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename))
{
LuaImp.ScriptList.SaveSession();
}
else
{
SaveSessionAs();
}
SaveOrSaveAs();
return true;
}
@ -725,6 +718,18 @@ namespace BizHawk.Client.EmuHawk
}
}
private void SaveOrSaveAs()
{
if (!string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename))
{
LuaImp.ScriptList.SaveSession(LuaImp.ScriptList.Filename);
}
else
{
SaveSessionAs();
}
}
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
{
SaveSessionMenuItem.Enabled = LuaImp.ScriptList.Changes;
@ -780,15 +785,7 @@ namespace BizHawk.Client.EmuHawk
{
if (LuaImp.ScriptList.Changes)
{
if (!string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename))
{
LuaImp.ScriptList.SaveSession();
}
else
{
SaveSessionAs();
}
SaveOrSaveAs();
OutputMessages.Text = $"{Path.GetFileName(LuaImp.ScriptList.Filename)} saved.";
}
}