Add IEmuClientApi method (+Lua) for getting approximate framerate

This commit is contained in:
YoshiRulz 2021-09-19 01:50:03 +10:00 committed by James Groom
parent f56a98116e
commit 98ee0d446f
5 changed files with 14 additions and 0 deletions

View File

@ -89,6 +89,8 @@ namespace BizHawk.Client.Common
_mainForm.FrameSkipMessage();
}
public int GetApproxFramerate() => _mainForm.GetApproxFramerate();
public bool GetSoundOn() => _config.SoundEnabled;
public int GetTargetScanlineIntensity() => _config.TargetScanlineFilterIntensity;

View File

@ -63,6 +63,9 @@ namespace BizHawk.Client.Common
void FrameSkip(int numFrames);
/// <returns>the (host) framerate, approximated from frame durations</returns>
int GetApproxFramerate();
bool GetSoundOn();
int GetTargetScanlineIntensity();

View File

@ -59,6 +59,9 @@ namespace BizHawk.Client.Common
void FrameSkipMessage();
/// <remarks>only referenced from <see cref="EmuClientApi"/></remarks>
int GetApproxFramerate();
/// <remarks>only referenced from <see cref="SaveStateApi"/></remarks>
void LoadQuickSave(string quickSlotName, bool suppressOSD = false);

View File

@ -112,6 +112,10 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodExample("local sounds_terrible = client.get_approx_framerate() < 55;")]
[LuaMethod("get_approx_framerate", "Gets the (host) framerate, approximated from frame durations.")]
public int GetApproxFramerate() => APIs.EmuClient.GetApproxFramerate();
[LuaMethodExample("local incliget = client.gettargetscanlineintensity( );")]
[LuaMethod("gettargetscanlineintensity", "Gets the current scanline intensity setting, used for the scanline display filter")]
public int GetTargetScanlineIntensity() => APIs.EmuClient.GetTargetScanlineIntensity();

View File

@ -1608,6 +1608,8 @@ namespace BizHawk.Client.EmuHawk
private int _framesSinceLastFpsUpdate;
private long _timestampLastFpsUpdate;
public int GetApproxFramerate() => _lastFpsRounded;
private readonly Throttle _throttle;
private bool _unthrottled;