add hotkey to toggle the last used lua script
This commit is contained in:
parent
b10f8969ac
commit
b6efbfe54b
|
@ -174,6 +174,7 @@ namespace BizHawk.Client.Common
|
|||
Bind("Analog", "X Down Large", toolTip: "For Virtual Pad");
|
||||
|
||||
Bind("Tools", "Toggle All Cheats");
|
||||
Bind("Tools", "Toggle Last Lua Script");
|
||||
|
||||
Bind("NDS", "Next Screen Layout");
|
||||
Bind("NDS", "Previous Screen Layout");
|
||||
|
|
|
@ -311,6 +311,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
case "Lua Console":
|
||||
OpenLuaConsole();
|
||||
break;
|
||||
case "Toggle Last Lua Script":
|
||||
if (Tools.IsLoaded<LuaConsole>())
|
||||
{
|
||||
Tools.LuaConsole.ToggleLastLuaScript();
|
||||
}
|
||||
break;
|
||||
case "Cheats":
|
||||
Tools.Load<Cheats>();
|
||||
break;
|
||||
|
|
|
@ -11,7 +11,6 @@ using System.Windows.Forms;
|
|||
using BizHawk.Client.Common;
|
||||
using BizHawk.Client.EmuHawk.Properties;
|
||||
using BizHawk.Client.EmuHawk.ToolExtensions;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Common.CollectionExtensions;
|
||||
using BizHawk.Common.PathExtensions;
|
||||
using BizHawk.Common.StringExtensions;
|
||||
|
@ -29,15 +28,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static readonly FilesystemFilterSet ScriptsAndTextFilesFSFilterSet = new(FilesystemFilter.LuaScripts, FilesystemFilter.TextFiles);
|
||||
|
||||
private static readonly FilesystemFilterSet SessionsFSFilterSet = new FilesystemFilterSet(new FilesystemFilter("Lua Session Files", new[] { "luases" }));
|
||||
private static readonly FilesystemFilterSet SessionsFSFilterSet = new(new FilesystemFilter("Lua Session Files", new[] { "luases" }));
|
||||
|
||||
public static Icon ToolIcon
|
||||
=> Resources.TextDocIcon;
|
||||
|
||||
private readonly LuaAutocompleteInstaller _luaAutoInstaller = new LuaAutocompleteInstaller();
|
||||
private readonly LuaAutocompleteInstaller _luaAutoInstaller = new();
|
||||
private readonly Dictionary<LuaFile, FileSystemWatcher> _watches = new();
|
||||
|
||||
private readonly int _defaultSplitDistance;
|
||||
private LuaFile _lastScriptUsed = null;
|
||||
|
||||
[RequiredService]
|
||||
private IEmulator Emulator { get; set; }
|
||||
|
@ -45,7 +45,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private bool _sortReverse;
|
||||
private string _lastColumnSorted;
|
||||
|
||||
private readonly List<string> _consoleCommandHistory = new List<string>();
|
||||
private readonly List<string> _consoleCommandHistory = new();
|
||||
private int _consoleCommandHistoryIndex = -1;
|
||||
|
||||
public ToolDialogSettings.ColumnList Columns { get; set; }
|
||||
|
@ -56,9 +56,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Columns = new List<RollColumn>
|
||||
{
|
||||
new RollColumn { Name = IconColumnName, Text = " ", Visible = true, UnscaledWidth = 22, Type = ColumnType.Image },
|
||||
new RollColumn { Name = ScriptColumnName, Text = "Script", Visible = true, UnscaledWidth = 92, Type = ColumnType.Text },
|
||||
new RollColumn { Name = PathColumnName, Text = "Path", Visible = true, UnscaledWidth = 300, Type = ColumnType.Text }
|
||||
new() { Name = IconColumnName, Text = " ", Visible = true, UnscaledWidth = 22, Type = ColumnType.Image },
|
||||
new() { Name = ScriptColumnName, Text = "Script", Visible = true, UnscaledWidth = 92, Type = ColumnType.Text },
|
||||
new() { Name = PathColumnName, Text = "Path", Visible = true, UnscaledWidth = 300, Type = ColumnType.Text }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -247,6 +247,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
UpdateDialog();
|
||||
}
|
||||
|
||||
public void ToggleLastLuaScript()
|
||||
{
|
||||
if (_lastScriptUsed is not null)
|
||||
{
|
||||
ToggleLuaScript(_lastScriptUsed);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetColumns()
|
||||
{
|
||||
LuaListView.AllColumns.AddRange(Settings.Columns);
|
||||
|
@ -1488,7 +1496,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
file.Toggle();
|
||||
|
||||
_lastScriptUsed = file;
|
||||
if (file.Enabled && file.Thread is null)
|
||||
{
|
||||
LuaImp.RegisteredFunctions.RemoveForFile(file, Emulator); // First remove any existing registered functions for this file
|
||||
|
@ -1499,6 +1507,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
DisableLuaScript(file);
|
||||
// there used to be a call here which did a redraw of the Gui/OSD, which included a call to `Tools.UpdateToolsAfter` --yoshi
|
||||
}
|
||||
|
||||
LuaListView.Refresh();
|
||||
}
|
||||
|
||||
private void DisableLuaScript(LuaFile file)
|
||||
|
|
Loading…
Reference in New Issue