Skip to content

Commit 8bcd94d

Browse files
authored
Add IsRewinding tool/Lua API (#4497)
* Add IsRewinding tool/Lua API * Remove unused member
1 parent 7e44f2b commit 8bcd94d

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ public int GetWindowSize()
143143

144144
public bool IsTurbo() => _mainForm.IsTurboing;
145145

146+
public bool IsRewinding() => _mainForm.IsRewinding;
147+
146148
public bool LoadState(string name)
147149
=> _mainForm.LoadState(
148150
path: Path.Combine(_config.PathEntries.SaveStateAbsolutePath(Game.System), $"{name}.State"),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public interface IEmuClientApi : IDisposable, IExternalApi
8383

8484
bool IsTurbo();
8585

86+
bool IsRewinding();
87+
8688
/// <summary>
8789
/// Load a savestate specified by its name
8890
/// </summary>

src/BizHawk.Client.Common/IMainFormForApi.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public interface IMainFormForApi
2727
/// <remarks>only referenced from <c>EmuClientApi</c></remarks>
2828
bool IsTurboing { get; }
2929

30+
/// <remarks>only referenced from <c>EmuClientApi</c></remarks>
31+
bool IsRewinding { get; }
32+
3033
/// <remarks>only referenced from <see cref="CommApi"/></remarks>
3134
(HttpCommunication HTTP, MemoryMappedFiles MMF, SocketServer Sockets) NetworkingHelpers { get; }
3235

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ public bool IsTurbo()
156156
public bool IsSeeking()
157157
=> APIs.EmuClient.IsSeeking();
158158

159+
[LuaMethodExample("if ( client.isrewinding( ) ) then\r\n\tconsole.log( \"Returns true if emulator is rewinding, otherwise, false\" );\r\nend;")]
160+
[LuaMethod("isrewinding", "Returns true if emulator is rewinding, otherwise, false")]
161+
public bool IsRewinding()
162+
=> APIs.EmuClient.IsRewinding();
163+
159164
[LuaMethodExample("client.opencheats( );")]
160165
[LuaMethod("opencheats", "opens the Cheats dialog")]
161166
public void OpenCheats()

src/BizHawk.Client.EmuHawk/MainForm.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,7 @@ private set
11301130
private bool IsTurboSeeking => PauseOnFrame.HasValue && Config.TurboSeek;
11311131
public bool IsTurboing => InputManager.ClientControls["Turbo"] || IsTurboSeeking;
11321132
public bool IsFastForwarding => InputManager.ClientControls["Fast Forward"] || IsTurboing || InvisibleEmulation;
1133+
public bool IsRewinding { get; private set; }
11331134

11341135
/// <summary>
11351136
/// Used to disable secondary throttling (e.g. vsync, audio) for unthrottled modes or when the primary (clock) throttle is taking over (e.g. during fast forward/rewind).
@@ -2934,6 +2935,7 @@ private void StepRunLoop_Core(bool force = false)
29342935
}
29352936

29362937
bool isRewinding = Rewind(ref runFrame, currentTimestamp, out var returnToRecording);
2938+
IsRewinding = isRewinding;
29372939
_runloopFrameProgress |= isRewinding;
29382940

29392941
float atten = 0;

0 commit comments

Comments
 (0)