Skip to content

Commit 22b963d

Browse files
committed
Allow Lua to reliably restore pause state after a seek.
1 parent e57b8f7 commit 22b963d

File tree

7 files changed

+13
-8
lines changed

7 files changed

+13
-8
lines changed

src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public void SpeedMode(int percent)
228228

229229
public Point TransformPoint(Point point) => _displayManager.TransformPoint(point);
230230

231-
public void Unpause() => _mainForm.UnpauseEmulator();
231+
public bool Unpause() => _mainForm.UnpauseEmulator();
232232

233233
public void UnpauseAv() => _mainForm.PauseAvi = false;
234234

src/BizHawk.Client.Common/Api/Interfaces/IEmuClientApi.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ public interface IEmuClientApi : IDisposable, IExternalApi
154154

155155
Point TransformPoint(Point point);
156156

157-
void Unpause();
157+
/// <returns>True if <see cref="Pause"/> should be called if you want to restore the previous pause state.
158+
/// <br/>Note that this is not the same as checking <see cref="IsPaused"/> before unpausing.
159+
/// If the user was holding frame advance, emulation will have already been unpaused and releasing frame advance will not pause.</returns>
160+
bool Unpause();
158161

159162
void UnpauseAv();
160163

src/BizHawk.Client.Common/IMainFormForApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public interface IMainFormForApi
128128
void ToggleSound();
129129

130130
/// <remarks>only referenced from <see cref="EmuClientApi"/></remarks>
131-
void UnpauseEmulator();
131+
bool UnpauseEmulator();
132132

133133
/// <remarks>only referenced from <see cref="EmuClientApi"/></remarks>
134134
event BeforeQuickLoadEventHandler QuicksaveLoad;

src/BizHawk.Client.Common/lua/CommonLibs/ClientLuaLibrary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ public LuaTable TransformPoint(int x, int y) {
304304
}
305305

306306
[LuaMethodExample("client.unpause( );")]
307-
[LuaMethod("unpause", "Unpauses the emulator")]
308-
public void Unpause()
307+
[LuaMethod("unpause", "Unpauses the emulator. Returns True if client.pause should be called if you want to restore the previous pause state. Note that this is not the same as checking client.ispaused before unpausing. If the user was holding frame advance, emulation will have already been unpaused and releasing frame advance will not pause.")]
308+
public bool Unpause()
309309
=> APIs.EmuClient.Unpause();
310310

311311
[LuaMethodExample("client.unpause_av( );")]

src/BizHawk.Client.EmuHawk/IMainFormForTools.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public interface IMainFormForTools : IDialogController
8585
void TogglePause();
8686

8787
/// <remarks>referenced by 3 or more tools</remarks>
88-
void UnpauseEmulator();
88+
bool UnpauseEmulator();
8989

9090
/// <remarks>only referenced from <see cref="BasicBot"/></remarks>
9191
void Unthrottle();

src/BizHawk.Client.EmuHawk/MainForm.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,9 +1367,11 @@ public void PauseEmulator()
13671367
EmulatorPaused = true;
13681368
}
13691369

1370-
public void UnpauseEmulator()
1370+
public bool UnpauseEmulator()
13711371
{
1372+
bool ret = _emulatorPaused;
13721373
EmulatorPaused = false;
1374+
return ret;
13731375
}
13741376

13751377
public void TogglePause()

src/BizHawk.Client.EmuHawk/RetroAchievements/RAIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public RAIntegration(
137137
clientVer: $"{VersionInfo.MainVersion}{(VersionInfo.DeveloperBuild ? "-dev" : string.Empty)}");
138138

139139
_isActive = () => !Emu.IsNull();
140-
_unpause = _mainForm.UnpauseEmulator;
140+
_unpause = () => _ = _mainForm.UnpauseEmulator();
141141
_pause = _mainForm.PauseEmulator;
142142
_rebuildMenu = RebuildMenu;
143143
_estimateTitle = buffer =>

0 commit comments

Comments
 (0)