Replace class Win32LuaLibraries.ResumeResult with tuples

This commit is contained in:
YoshiRulz 2020-11-25 19:01:37 +10:00
parent fd4a534fa7
commit 20111fb4a2
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 8 additions and 24 deletions

View File

@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk
public abstract void EndLuaDrawing();
public abstract void ExecuteString(string command);
public abstract void Restart(IEmulatorServiceProvider newServiceProvider);
public abstract Win32LuaLibraries.ResumeResult ResumeScript(LuaFile lf);
public abstract (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf);
public abstract void SpawnAndSetFileThread(string pathToLoad, LuaFile lf);
public abstract void StartLuaDrawing();
public abstract void WindowClosed(IntPtr handle);

View File

@ -40,11 +40,9 @@ namespace BizHawk.Client.EmuHawk
public override void Restart(IEmulatorServiceProvider newServiceProvider)
{
}
private static readonly Win32LuaLibraries.ResumeResult EmptyResumeResult = new Win32LuaLibraries.ResumeResult();
public override Win32LuaLibraries.ResumeResult ResumeScript(LuaFile lf)
{
return EmptyResumeResult;
}
public override (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf) => (false, false);
public override void SpawnAndSetFileThread(string pathToLoad, LuaFile lf)
{
}

View File

@ -198,7 +198,7 @@ namespace BizHawk.Client.EmuHawk
public override void RunScheduledDisposes() => _lua.RunScheduledDisposes();
public override ResumeResult ResumeScript(LuaFile lf)
public override (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf)
{
_currThread = lf.Thread;
@ -214,17 +214,9 @@ namespace BizHawk.Client.EmuHawk
_currThread.RunScheduledDisposes();
_currThread = null;
var result = new ResumeResult();
if (execResult == 0)
{
// terminated
result.Terminated = true;
}
else
{
// yielded
result.WaitForFrame = FrameAdvanceRequested;
}
var result = execResult == 0
? (WaitForFrame: false, Terminated: true) // terminated
: (WaitForFrame: FrameAdvanceRequested, Terminated: false); // yielded
FrameAdvanceRequested = false;
return result;
@ -250,11 +242,5 @@ namespace BizHawk.Client.EmuHawk
{
_currThread.Yield(0);
}
public class ResumeResult
{
public bool WaitForFrame { get; set; }
public bool Terminated { get; set; }
}
}
}