diff --git a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs index 1f960f340f..43a2f92af1 100644 --- a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs +++ b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs @@ -131,7 +131,7 @@ namespace BizHawk.Client.EmuHawk.WinFormExtensions public static DialogResult ShowHawkDialog(this CommonDialog form) { GlobalWin.Sound.StopSound(); - using var tempForm = new Form() { TopMost = true }; + using var tempForm = new Form { TopMost = true }; var result = form.ShowDialog(tempForm); GlobalWin.Sound.StartSound(); return result; diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index af9d3c1e37..861df0181c 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -431,24 +431,6 @@ namespace BizHawk.Client.EmuHawk return path; } - private static FileInfo GetFileFromUser(string filter) - { - var ofd = new OpenFileDialog - { - InitialDirectory = PathManager.GetLuaPath(), - Filter = filter, - RestoreDirectory = true - }; - - if (!Directory.Exists(ofd.InitialDirectory)) - { - Directory.CreateDirectory(ofd.InitialDirectory); - } - - var result = ofd.ShowHawkDialog(); - return result == DialogResult.OK ? new FileInfo(ofd.FileName) : null; - } - private void UpdateNumberOfScripts() { var message = ""; @@ -720,10 +702,23 @@ namespace BizHawk.Client.EmuHawk private void OpenSessionMenuItem_Click(object sender, EventArgs e) { - var file = GetFileFromUser("Lua Session Files (*.luases)|*.luases|All Files|*.*"); - if (file != null) + var ofd = new OpenFileDialog { - LuaImp.ScriptList.LoadLuaSession(file.FullName); + InitialDirectory = PathManager.GetLuaPath(), + Filter = "Lua Session Files (*.luases)|*.luases|All Files|*.*", + RestoreDirectory = true, + Multiselect = false + }; + + if (!Directory.Exists(ofd.InitialDirectory)) + { + Directory.CreateDirectory(ofd.InitialDirectory); + } + + var result = ofd.ShowHawkDialog(); + if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(ofd.FileName)) + { + LuaImp.ScriptList.LoadLuaSession(ofd.FileName); RunLuaScripts(); UpdateDialog(); LuaImp.ScriptList.Changes = false; @@ -813,10 +808,27 @@ namespace BizHawk.Client.EmuHawk private void OpenScriptMenuItem_Click(object sender, EventArgs e) { - var file = GetFileFromUser("Lua Scripts (*.lua)|*.lua|Text (*.text)|*.txt|All Files|*.*"); - if (file != null) + var ofd = new OpenFileDialog { - LoadLuaFile(file.FullName); + InitialDirectory = PathManager.GetLuaPath(), + Filter = "Lua Scripts (*.lua)|*.lua|Text (*.text)|*.txt|All Files|*.*", + RestoreDirectory = true, + Multiselect = true + }; + + if (!Directory.Exists(ofd.InitialDirectory)) + { + Directory.CreateDirectory(ofd.InitialDirectory); + } + + var result = ofd.ShowHawkDialog(); + if (result == DialogResult.OK && ofd.FileNames != null) + { + foreach (var file in ofd.FileNames) + { + LoadLuaFile(file); + } + UpdateDialog(); } }