Pass in globals to Throttle and UpdateChecker

This commit is contained in:
YoshiRulz 2020-07-29 08:55:56 +10:00
parent fbb38d61fd
commit a54b9acba2
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
5 changed files with 26 additions and 17 deletions

View File

@ -2473,6 +2473,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (result == DialogResult.No)
{
UpdateChecker.GlobalConfig = Config;
UpdateChecker.IgnoreNewVersion();
UpdateChecker.BeginCheck(skipCheck: true); // Trigger event to hide new version notification
}

View File

@ -151,6 +151,7 @@ namespace BizHawk.Client.EmuHawk
this.BeginInvoke(() => { UpdateNotification.Visible = UpdateChecker.IsNewVersionAvailable; });
};
UpdateChecker.GlobalConfig = Config;
UpdateChecker.BeginCheck(); // Won't actually check unless enabled by user
}
@ -2772,7 +2773,7 @@ namespace BizHawk.Client.EmuHawk
_throttle.signal_frameAdvance = _runloopFrameAdvance;
_throttle.signal_continuousFrameAdvancing = _runloopFrameProgress;
_throttle.Step(true, -1);
_throttle.Step(Config, Sound, allowSleep: true, forceFrameSkip: -1);
}
public void FrameAdvance()

View File

@ -1,6 +1,8 @@
using System;
using System.Diagnostics;
using System.Threading;
using BizHawk.Client.Common;
using BizHawk.Common;
//this throttle is nitsuja's fine-tuned techniques from desmume
@ -21,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
public bool signal_continuousFrameAdvancing;
public bool signal_overrideSecondaryThrottle;
public void Step(bool allowSleep, int forceFrameSkip)
public void Step(Config config, Sound sound, bool allowSleep, int forceFrameSkip)
{
//TODO - figure out what allowSleep is supposed to be used for
//TODO - figure out what forceFrameSkip is supposed to be used for
@ -61,7 +63,7 @@ namespace BizHawk.Client.EmuHawk
else throw new InvalidOperationException();
#endif
int skipRate = (forceFrameSkip < 0) ? GlobalWin.Config.FrameSkip : forceFrameSkip;
int skipRate = (forceFrameSkip < 0) ? config.FrameSkip : forceFrameSkip;
int ffSkipRate = (forceFrameSkip < 0) ? 3 : forceFrameSkip;
if (lastSkipRate != skipRate)
@ -78,7 +80,7 @@ namespace BizHawk.Client.EmuHawk
{
//don't ever skip frames when continuous frame advancing. it's meant for precision work.
//but we DO need to throttle
if (GlobalWin.Config.ClockThrottle)
if (config.ClockThrottle)
extraThrottle = true;
}
else
@ -106,12 +108,12 @@ namespace BizHawk.Client.EmuHawk
if (framesToSkip < 1)
framesToSkip += ffSkipRate;
}
else if ((extraThrottle || signal_paused || GlobalWin.Config.ClockThrottle || signal_overrideSecondaryThrottle) && allowSleep)
else if ((extraThrottle || signal_paused || config.ClockThrottle || signal_overrideSecondaryThrottle) && allowSleep)
{
SpeedThrottle(signal_paused);
SpeedThrottle(sound, signal_paused);
}
if (GlobalWin.Config.AutoMinimizeSkipping && GlobalWin.Config.FrameSkip != 0)
if (config.AutoMinimizeSkipping && config.FrameSkip != 0)
{
if (!signal_continuousFrameAdvancing)
{
@ -304,7 +306,7 @@ namespace BizHawk.Client.EmuHawk
return rv;
}
void SpeedThrottle(bool paused)
void SpeedThrottle(Sound sound, bool paused)
{
AutoFrameSkip_BeforeThrottle();
@ -320,7 +322,7 @@ namespace BizHawk.Client.EmuHawk
if (elapsedTime >= timePerFrame)
{
int maxMissedFrames = (int)Math.Ceiling((GlobalWin.Sound.SoundMaxBufferDeficitMs / 1000.0) / ((double)timePerFrame / afsfreq));
int maxMissedFrames = (int)Math.Ceiling((sound.SoundMaxBufferDeficitMs / 1000.0) / ((double)timePerFrame / afsfreq));
if (maxMissedFrames < 3)
maxMissedFrames = 3;

View File

@ -3,6 +3,8 @@ using System.IO;
using System.Net;
using System.Threading;
using BizHawk.Client.Common;
using Newtonsoft.Json.Linq;
namespace BizHawk.Client.EmuHawk
@ -12,28 +14,30 @@ namespace BizHawk.Client.EmuHawk
private static readonly string _latestVersionInfoURL = "https://api.github.com/repos/TASVideos/BizHawk/releases/latest";
private static readonly TimeSpan _minimumCheckDuration = TimeSpan.FromHours(8);
public static Config GlobalConfig;
private static bool AutoCheckEnabled
{
get => GlobalWin.Config.UpdateAutoCheckEnabled;
set => GlobalWin.Config.UpdateAutoCheckEnabled = value;
get => GlobalConfig.UpdateAutoCheckEnabled;
set => GlobalConfig.UpdateAutoCheckEnabled = value;
}
private static DateTime? LastCheckTimeUTC
{
get => GlobalWin.Config.UpdateLastCheckTimeUtc;
set => GlobalWin.Config.UpdateLastCheckTimeUtc = value;
get => GlobalConfig.UpdateLastCheckTimeUtc;
set => GlobalConfig.UpdateLastCheckTimeUtc = value;
}
private static string LatestVersion
{
get => GlobalWin.Config.UpdateLatestVersion;
set => GlobalWin.Config.UpdateLatestVersion = value;
get => GlobalConfig.UpdateLatestVersion;
set => GlobalConfig.UpdateLatestVersion = value;
}
private static string IgnoreVersion
{
get => GlobalWin.Config.UpdateIgnoreVersion;
set => GlobalWin.Config.UpdateIgnoreVersion = value;
get => GlobalConfig.UpdateIgnoreVersion;
set => GlobalConfig.UpdateIgnoreVersion = value;
}
public static void BeginCheck(bool skipCheck = false)

View File

@ -75,6 +75,7 @@ namespace BizHawk.Client.EmuHawk
_config.UpdateAutoCheckEnabled = AutoCheckForUpdates.Checked;
if (_config.UpdateAutoCheckEnabled != oldUpdateAutoCheckEnabled)
{
UpdateChecker.GlobalConfig = _config;
if (!_config.UpdateAutoCheckEnabled)
{
UpdateChecker.ResetHistory();