Lua console - misc cleanups, remove some unused code
This commit is contained in:
parent
cf6c8c6dde
commit
80150f70be
|
@ -149,11 +149,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void Restart()
|
||||
{
|
||||
List<LuaFile> runningScripts = new List<LuaFile>();
|
||||
var runningScripts = new List<LuaFile>();
|
||||
|
||||
if (LuaImp != null) // Things we need to do with the existing LuaImp before we can make a new one
|
||||
{
|
||||
if (LuaImp.IsRebootingCore == true)
|
||||
if (LuaImp.IsRebootingCore)
|
||||
{
|
||||
// Even if the lua console is self-rebooting from client.reboot_core() we still want to re-inject dependencies
|
||||
LuaImp.Restart(Emulator.ServiceProvider);
|
||||
|
@ -188,8 +188,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
var currentScripts = LuaImp?.ScriptList; // Temp fix for now
|
||||
LuaImp = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
||||
? (PlatformEmuLuaLibrary) new EmuLuaLibrary(Emulator.ServiceProvider)
|
||||
: (PlatformEmuLuaLibrary) new NotReallyLuaLibrary();
|
||||
? (PlatformEmuLuaLibrary)new EmuLuaLibrary(Emulator.ServiceProvider)
|
||||
: (PlatformEmuLuaLibrary)new NotReallyLuaLibrary();
|
||||
if (currentScripts != null)
|
||||
{
|
||||
LuaImp.ScriptList.AddRange(currentScripts);
|
||||
|
@ -255,7 +255,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void OnChanged(object source, FileSystemEventArgs e)
|
||||
{
|
||||
string message = $"File: {e.FullPath} {e.ChangeType}";
|
||||
Invoke(new MethodInvoker(delegate
|
||||
{
|
||||
RefreshScriptMenuItem_Click(null, null);
|
||||
|
@ -265,7 +264,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void LoadLuaFile(string path)
|
||||
{
|
||||
var processedPath = PathManager.TryMakeRelative(path);
|
||||
string pathToLoad = ProcessPath(processedPath);
|
||||
|
||||
if (LuaAlreadyInSession(processedPath) == false)
|
||||
{
|
||||
|
@ -591,16 +589,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public bool WaitOne(int timeout)
|
||||
{
|
||||
if (!IsHandleCreated || IsDisposed)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return LuaImp.LuaWait.WaitOne(timeout);
|
||||
}
|
||||
|
||||
private FileInfo GetSaveFileFromUser()
|
||||
{
|
||||
var sfd = new SaveFileDialog();
|
||||
|
@ -643,13 +631,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void LoadSessionFromRecent(string path)
|
||||
{
|
||||
var doload = true;
|
||||
var load = true;
|
||||
if (LuaImp.ScriptList.Changes)
|
||||
{
|
||||
doload = AskSaveChanges();
|
||||
load = AskSaveChanges();
|
||||
}
|
||||
|
||||
if (doload)
|
||||
if (load)
|
||||
{
|
||||
if (!LuaImp.ScriptList.LoadLuaSession(path))
|
||||
{
|
||||
|
@ -829,7 +817,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
File.WriteAllText(sfd.FileName, defaultTemplate);
|
||||
LuaImp.ScriptList.Add(new LuaFile(Path.GetFileNameWithoutExtension(sfd.FileName), sfd.FileName));
|
||||
UpdateDialog();
|
||||
System.Diagnostics.Process.Start(sfd.FileName);
|
||||
Process.Start(sfd.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -854,15 +842,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
EnableLuaFile(file);
|
||||
}
|
||||
|
||||
else if (!file.Enabled && file.Thread != null)
|
||||
{
|
||||
LuaImp.CallExitEvent(file);
|
||||
|
||||
var items = SelectedItems.ToList();
|
||||
foreach (var sitem in items)
|
||||
foreach (var selectedItem in items)
|
||||
{
|
||||
var temp = sitem;
|
||||
var temp = selectedItem;
|
||||
var functions = LuaImp.GetRegisteredFunctions().Where(lf => lf.Lua == temp.Thread).ToList();
|
||||
foreach (var function in functions)
|
||||
{
|
||||
|
@ -988,7 +975,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
File.WriteAllText(sfd.FileName, text);
|
||||
LuaImp.ScriptList.Add(new LuaFile(Path.GetFileNameWithoutExtension(sfd.FileName), sfd.FileName));
|
||||
UpdateDialog();
|
||||
System.Diagnostics.Process.Start(sfd.FileName);
|
||||
Process.Start(sfd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1023,12 +1010,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
LuaImp.ScriptList.Insert(index - 1, file);
|
||||
}
|
||||
|
||||
var newindices = indices.Select(t => t - 1).ToList();
|
||||
var newIndices = indices.Select(t => t - 1).ToList();
|
||||
|
||||
LuaListView.SelectedIndices.Clear();
|
||||
foreach (var newi in newindices)
|
||||
foreach (var i in newIndices)
|
||||
{
|
||||
LuaListView.SelectItem(newi, true);
|
||||
LuaListView.SelectItem(i, true);
|
||||
}
|
||||
|
||||
UpdateDialog();
|
||||
|
@ -1049,12 +1036,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
LuaImp.ScriptList.Insert(indices[i] + 1, file);
|
||||
}
|
||||
|
||||
var newindices = indices.Select(t => t + 1).ToList();
|
||||
var newIndices = indices.Select(t => t + 1).ToList();
|
||||
|
||||
LuaListView.SelectedIndices.Clear();
|
||||
foreach (var newi in newindices)
|
||||
foreach (var i in newIndices)
|
||||
{
|
||||
LuaListView.SelectItem(newi, true);
|
||||
LuaListView.SelectItem(i, true);
|
||||
}
|
||||
|
||||
UpdateDialog();
|
||||
|
@ -1208,7 +1195,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void OnlineDocsMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start("http://tasvideos.org/BizHawk/LuaFunctions.html");
|
||||
Process.Start("http://tasvideos.org/BizHawk/LuaFunctions.html");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1262,12 +1249,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
foreach (var path in filePaths)
|
||||
{
|
||||
if (Path.GetExtension(path).ToLower() == ".lua" || Path.GetExtension(path).ToLower() == ".txt")
|
||||
if (Path.GetExtension(path)?.ToLower() == ".lua" || Path.GetExtension(path)?.ToLower() == ".txt")
|
||||
{
|
||||
LoadLuaFile(path);
|
||||
UpdateDialog();
|
||||
}
|
||||
else if (Path.GetExtension(path).ToLower() == ".luases")
|
||||
else if (Path.GetExtension(path)?.ToLower() == ".luases")
|
||||
{
|
||||
LuaImp.ScriptList.LoadLuaSession(path);
|
||||
RunLuaScripts();
|
||||
|
@ -1453,7 +1440,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
// Stupid designer
|
||||
protected void DragEnterWrapper(object sender, DragEventArgs e)
|
||||
{
|
||||
base.GenericDragEnter(sender, e);
|
||||
GenericDragEnter(sender, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -180,10 +180,12 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=autorestore/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autosave/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=bsnes/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=frameadvance/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FCEUX/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=feos/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=greenzone/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=greenzoned/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=luases/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mainform/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=savestate/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=savestates/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
Loading…
Reference in New Issue