Pass globals to DisplayManager as with OSDManager

* moved initialisation of global `OSDManager` to `DisplayManager` ctor again
* `DisplayManager.UpdateGlobals` calls `DisplayManager.OSD.UpdateGlobals`
* goodbye `GlobalWin.Emulator` and `GlobalWin._mainForm` :)
This commit is contained in:
YoshiRulz 2020-11-30 19:09:24 +10:00
parent c991babdce
commit 453ea2b1bb
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 17 additions and 15 deletions

View File

@ -51,13 +51,15 @@ namespace BizHawk.Client.EmuHawk
public readonly OSDManager OSD;
private Config GlobalConfig => GlobalWin.Config;
private Config GlobalConfig;
private IEmulator GlobalEmulator => GlobalWin.Emulator;
private IEmulator GlobalEmulator;
public DisplayManager(OSDManager osd, IGL gl, PresentationPanel presentationPanel, Func<bool> getIsSecondaryThrottlingDisabled)
public DisplayManager(Config config, IEmulator emulator, InputManager inputManager, IMovieSession movieSession, IGL gl, PresentationPanel presentationPanel, Func<bool> getIsSecondaryThrottlingDisabled)
{
OSD = osd;
GlobalConfig = config;
GlobalEmulator = emulator;
OSD = new OSDManager(config, emulator, inputManager, movieSession);
_getIsSecondaryThrottlingDisabled = getIsSecondaryThrottlingDisabled;
_gl = gl;
@ -136,6 +138,13 @@ namespace BizHawk.Client.EmuHawk
RefreshUserShader();
}
public void UpdateGlobals(Config config, IEmulator emulator)
{
GlobalConfig = config;
GlobalEmulator = emulator;
OSD.UpdateGlobals(config, emulator);
}
public bool Disposed { get; private set; }
public void Dispose()

View File

@ -1,15 +1,10 @@
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
// ReSharper disable StyleCop.SA1401
namespace BizHawk.Client.EmuHawk
{
public static class GlobalWin
{
public static MainForm _mainForm { get; set; }
public static IEmulator Emulator => _mainForm.Emulator;
public static Sound Sound;
public static Config Config { get; set; }

View File

@ -279,8 +279,6 @@ namespace BizHawk.Client.EmuHawk
Database.InitializeDatabase(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb.txt"));
BootGodDb.Initialize(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb"));
GlobalWin._mainForm = this;
_config = config; // skips assignment to GlobalWin.Config as Program already did that
GL = gl;
@ -339,7 +337,7 @@ namespace BizHawk.Client.EmuHawk
{
GraphicsControl = { MainWindow = true }
};
DisplayManager = new DisplayManager(new OSDManager(Config, Emulator, InputManager, MovieSession), GL, _presentationPanel, () => DisableSecondaryThrottling);
DisplayManager = new DisplayManager(Config, Emulator, InputManager, MovieSession, GL, _presentationPanel, () => DisableSecondaryThrottling);
Controls.Add(_presentationPanel);
Controls.SetChildIndex(_presentationPanel, 0);
@ -2796,7 +2794,7 @@ namespace BizHawk.Client.EmuHawk
InputManager.SyncControls(Emulator, MovieSession, Config);
Tools.Restart(Config, Emulator, Game);
ExtToolManager.Restart(Config.PathEntries);
OSD.UpdateGlobals(Config, Emulator);
DisplayManager.UpdateGlobals(Config, Emulator);
AddOnScreenMessage($"Config file loaded: {iniPath}");
}
@ -3773,7 +3771,7 @@ namespace BizHawk.Client.EmuHawk
CurrentlyOpenRom = oaOpenrom?.Path ?? openAdvancedArgs;
CurrentlyOpenRomArgs = args;
OnRomChanged();
OSD.UpdateGlobals(Config, Emulator);
DisplayManager.UpdateGlobals(Config, Emulator);
DisplayManager.Blank();
CreateRewinder();
@ -3923,7 +3921,7 @@ namespace BizHawk.Client.EmuHawk
Tools.Restart(Config, Emulator, Game);
RewireSound();
ClearHolds();
OSD.UpdateGlobals(Config, Emulator);
DisplayManager.UpdateGlobals(Config, Emulator);
InputManager.SyncControls(Emulator, MovieSession, Config);
Tools.UpdateCheatRelatedTools(null, null);
PauseOnFrame = null;