move Global.Emulator to GlobalWin.Emulator now that no Client.Common files reference it
This commit is contained in:
parent
5b7d612238
commit
87c48879fc
|
@ -6,7 +6,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public static class Global
|
||||
{
|
||||
public static IEmulator Emulator { get; set; }
|
||||
public static Config Config { get; set; }
|
||||
public static GameInfo Game { get; set; }
|
||||
public static CheatCollection CheatList { get; set; } = new CheatCollection();
|
||||
|
|
|
@ -408,10 +408,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
get
|
||||
{
|
||||
switch (Global.Emulator.SystemId)
|
||||
switch (GlobalWin.Emulator.SystemId)
|
||||
{
|
||||
case "PCE":
|
||||
return ((PCEngine) Global.Emulator).Type switch
|
||||
return ((PCEngine) GlobalWin.Emulator).Type switch
|
||||
{
|
||||
NecSystemType.TurboGrafx => SystemInfo.PCE,
|
||||
NecSystemType.TurboCD => SystemInfo.PCECD,
|
||||
|
@ -419,17 +419,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
case "SMS":
|
||||
var sms = (SMS) Global.Emulator;
|
||||
var sms = (SMS) GlobalWin.Emulator;
|
||||
return sms.IsSG1000
|
||||
? SystemInfo.SG
|
||||
: sms.IsGameGear
|
||||
? SystemInfo.GG
|
||||
: SystemInfo.SMS;
|
||||
case "GB":
|
||||
if (Global.Emulator is Gameboy gb) return gb.IsCGBMode() ? SystemInfo.GBC : SystemInfo.GB;
|
||||
if (GlobalWin.Emulator is Gameboy gb) return gb.IsCGBMode() ? SystemInfo.GBC : SystemInfo.GB;
|
||||
return SystemInfo.DualGB;
|
||||
default:
|
||||
return SystemInfo.FindByCoreSystem(SystemIdConverter.Convert(Global.Emulator.SystemId));
|
||||
return SystemInfo.FindByCoreSystem(SystemIdConverter.Convert(GlobalWin.Emulator.SystemId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (_currentVideoProvider == null)
|
||||
{
|
||||
_currentVideoProvider = Global.Emulator.AsVideoProviderOrDefault();
|
||||
_currentVideoProvider = GlobalWin.Emulator.AsVideoProviderOrDefault();
|
||||
}
|
||||
|
||||
Initialized = true;
|
||||
|
@ -395,7 +395,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (_currentVideoProvider == null)
|
||||
{
|
||||
_currentVideoProvider = Global.Emulator.AsVideoProviderOrDefault();
|
||||
_currentVideoProvider = GlobalWin.Emulator.AsVideoProviderOrDefault();
|
||||
}
|
||||
return GlobalWin.DisplayManager.RenderVideoProvider(_currentVideoProvider);
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
// an experimental feature
|
||||
if (source && Global.Emulator is Octoshock psx)
|
||||
if (source && GlobalWin.Emulator is Octoshock psx)
|
||||
{
|
||||
var corePadding = psx.VideoProvider_Padding;
|
||||
padding.Left += corePadding.Width / 2;
|
||||
|
@ -460,7 +460,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
Filters.BaseFilter CreateCoreScreenControl()
|
||||
{
|
||||
if (Global.Emulator is MelonDS nds)
|
||||
if (GlobalWin.Emulator is MelonDS nds)
|
||||
{
|
||||
//TODO: need to pipe layout settings into here now
|
||||
var filter = new Filters.ScreenControlNDS(nds);
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var sb = new StringBuilder();
|
||||
sb
|
||||
.Append(Global.Emulator.Frame)
|
||||
.Append(GlobalWin.Emulator.Frame)
|
||||
.Append('/')
|
||||
.Append(Global.MovieSession.Movie.FrameCount)
|
||||
.Append(" (Finished)");
|
||||
|
@ -82,14 +82,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var sb = new StringBuilder();
|
||||
sb
|
||||
.Append(Global.Emulator.Frame)
|
||||
.Append(GlobalWin.Emulator.Frame)
|
||||
.Append('/')
|
||||
.Append(Global.MovieSession.Movie.FrameCount);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
return Global.Emulator.Frame.ToString();
|
||||
return GlobalWin.Emulator.Frame.ToString();
|
||||
}
|
||||
|
||||
private readonly List<UIMessage> _messages = new List<UIMessage>(5);
|
||||
|
@ -200,7 +200,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (Global.MovieSession.Movie.IsPlayingOrRecording())
|
||||
{
|
||||
var state = Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1);
|
||||
var state = Global.MovieSession.Movie.GetInputState(GlobalWin.Emulator.Frame - 1);
|
||||
if (state != null)
|
||||
{
|
||||
return MakeStringFor(state);
|
||||
|
@ -214,9 +214,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
IController m = Global.InputManager.AutofireStickyXorAdapter;
|
||||
|
||||
if (Global.MovieSession.Movie.IsPlayingOrRecording() && Global.Emulator.Frame > 0)
|
||||
if (Global.MovieSession.Movie.IsPlayingOrRecording() && GlobalWin.Emulator.Frame > 0)
|
||||
{
|
||||
m = m.Or(Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1));
|
||||
m = m.Or(Global.MovieSession.Movie.GetInputState(GlobalWin.Emulator.Frame - 1));
|
||||
}
|
||||
|
||||
return MakeStringFor(m);
|
||||
|
@ -224,7 +224,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private string MakeStringFor(IController controller)
|
||||
{
|
||||
return new Bk2InputDisplayGenerator(Global.Emulator.SystemId, controller).Generate();
|
||||
return new Bk2InputDisplayGenerator(GlobalWin.Emulator.SystemId, controller).Generate();
|
||||
}
|
||||
|
||||
public string MakeIntersectImmediatePrevious()
|
||||
|
@ -232,7 +232,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (Global.MovieSession.Movie.IsActive())
|
||||
{
|
||||
var m = Global.MovieSession.Movie.IsPlayingOrRecording()
|
||||
? Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1)
|
||||
? Global.MovieSession.Movie.GetInputState(GlobalWin.Emulator.Frame - 1)
|
||||
: Global.MovieSession.MovieController;
|
||||
|
||||
return MakeStringFor(Global.InputManager.AutofireStickyXorAdapter.And(m));
|
||||
|
@ -266,14 +266,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (GlobalWin.MainForm.IsLagFrame)
|
||||
{
|
||||
DrawOsdMessage(g, Global.Emulator.Frame.ToString(), FixedAlertMessageColor, point.X, point.Y);
|
||||
DrawOsdMessage(g, GlobalWin.Emulator.Frame.ToString(), FixedAlertMessageColor, point.X, point.Y);
|
||||
}
|
||||
}
|
||||
|
||||
if (Global.Config.DisplayInput && !Global.Game.IsNullInstance())
|
||||
{
|
||||
if (Global.MovieSession.Movie.IsPlaying()
|
||||
|| (Global.MovieSession.Movie.IsFinished() && Global.Emulator.Frame == Global.MovieSession.Movie.InputLogLength)) // Account for the last frame of the movie, the movie state is immediately "Finished" here but we still want to show the input
|
||||
|| (Global.MovieSession.Movie.IsFinished() && GlobalWin.Emulator.Frame == Global.MovieSession.Movie.InputLogLength)) // Account for the last frame of the movie, the movie state is immediately "Finished" here but we still want to show the input
|
||||
{
|
||||
var input = InputStrMovie();
|
||||
var point = GetCoordinates(g, Global.Config.InputDisplay, input);
|
||||
|
@ -332,9 +332,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
DrawOsdMessage(g, Fps, FixedMessagesColor, point.X, point.Y);
|
||||
}
|
||||
|
||||
if (Global.Config.DisplayLagCounter && Global.Emulator.CanPollInput())
|
||||
if (Global.Config.DisplayLagCounter && GlobalWin.Emulator.CanPollInput())
|
||||
{
|
||||
var counter = Global.Emulator.AsInputPollable().LagCount.ToString();
|
||||
var counter = GlobalWin.Emulator.AsInputPollable().LagCount.ToString();
|
||||
var point = GetCoordinates(g, Global.Config.LagCounter, counter);
|
||||
DrawOsdMessage(g, counter, FixedAlertMessageColor, point.X, point.Y);
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (Global.MovieSession.Movie.IsActive() && Global.Config.DisplaySubtitles)
|
||||
{
|
||||
var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(Global.Emulator.Frame);
|
||||
var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(GlobalWin.Emulator.Frame);
|
||||
|
||||
foreach (var sub in subList)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using BizHawk.Bizware.BizwareGL;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
// ReSharper disable StyleCop.SA1401
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
@ -8,6 +9,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
public static MainForm MainForm;
|
||||
public static ToolManager Tools;
|
||||
|
||||
public static IEmulator Emulator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the IGL to be used for rendering
|
||||
/// </summary>
|
||||
|
|
|
@ -778,13 +778,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
// This is a quick hack to reduce the dependency on Globals
|
||||
private IEmulator Emulator
|
||||
{
|
||||
get => Global.Emulator;
|
||||
get => GlobalWin.Emulator;
|
||||
|
||||
set
|
||||
{
|
||||
Global.Emulator = value;
|
||||
_currentVideoProvider = Global.Emulator.AsVideoProviderOrDefault();
|
||||
_currentSoundProvider = Global.Emulator.AsSoundProviderOrDefault();
|
||||
GlobalWin.Emulator = value;
|
||||
_currentVideoProvider = GlobalWin.Emulator.AsVideoProviderOrDefault();
|
||||
_currentSoundProvider = GlobalWin.Emulator.AsSoundProviderOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else if (source.SyncMode == SyncSoundMode.Async)
|
||||
{
|
||||
_bufferedAsync.RecalculateMagic(Global.Emulator.VsyncRate());
|
||||
_bufferedAsync.RecalculateMagic(GlobalWin.Emulator.VsyncRate());
|
||||
_bufferedProvider = _bufferedAsync;
|
||||
}
|
||||
else throw new InvalidOperationException("Unsupported sync mode.");
|
||||
|
@ -122,7 +122,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
internal void HandleInitializationOrUnderrun(bool isUnderrun, ref int samplesNeeded)
|
||||
{
|
||||
// Fill device buffer with silence but leave enough room for one frame
|
||||
int samplesPerFrame = (int)Math.Round(SampleRate / (double)Global.Emulator.VsyncRate());
|
||||
int samplesPerFrame = (int)Math.Round(SampleRate / (double)GlobalWin.Emulator.VsyncRate());
|
||||
int silenceSamples = Math.Max(samplesNeeded - samplesPerFrame, 0);
|
||||
_outputDevice.WriteSamples(new short[silenceSamples * 2], 0, silenceSamples);
|
||||
samplesNeeded -= silenceSamples;
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public bool LogDebug { get; set; }
|
||||
|
||||
private double AdvertisedSamplesPerFrame => SampleRate / Global.Emulator.VsyncRate();
|
||||
private double AdvertisedSamplesPerFrame => SampleRate / GlobalWin.Emulator.VsyncRate();
|
||||
|
||||
/// <exception cref="InvalidOperationException">not constructed in standalone mode</exception>
|
||||
public void GetSamples(short[] samples)
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void SaveFile()
|
||||
{
|
||||
string path = Global.Config.PathEntries.ScreenshotAbsolutePathFor(Global.Emulator.SystemId);
|
||||
string path = Global.Config.PathEntries.ScreenshotAbsolutePathFor(GlobalWin.Emulator.SystemId);
|
||||
|
||||
var di = new DirectoryInfo(path);
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private static void DoColorChooserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s, bool fromMenu)
|
||||
{
|
||||
using var dlg = new ColorChooserForm();
|
||||
var gb = Global.Emulator as Gameboy;
|
||||
var gb = GlobalWin.Emulator as Gameboy;
|
||||
if (fromMenu)
|
||||
{
|
||||
s = gb.GetSettings();
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
using var dlg = new DGBPrefs();
|
||||
dlg.PutSettings(s, ss);
|
||||
|
||||
var emu = (GambatteLink)Global.Emulator;
|
||||
var emu = (GambatteLink)GlobalWin.Emulator;
|
||||
dlg.gbPrefControl1.ColorGameBoy = emu.IsCGBMode(false);
|
||||
dlg.gbPrefControl2.ColorGameBoy = emu.IsCGBMode(true);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_mainForm = mainForm;
|
||||
InitializeComponent();
|
||||
|
||||
var settable = new SettingsAdapter(Global.Emulator);
|
||||
var settable = new SettingsAdapter(GlobalWin.Emulator);
|
||||
|
||||
if (settable.HasSettings && !ignoreSettings)
|
||||
{
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
item.Tag = (externalToolFile.Location, entryPoint.FullName); // Tag set => no errors (show custom icon even when disabled)
|
||||
if (applicabilityAttrs.Count == 1)
|
||||
{
|
||||
var system = ClientApi.SystemIdConverter.Convert(Global.Emulator.SystemId);
|
||||
var system = ClientApi.SystemIdConverter.Convert(GlobalWin.Emulator.SystemId);
|
||||
if (applicabilityAttrs[0].NotApplicableTo(system))
|
||||
{
|
||||
item.ToolTipText = system == CoreSystem.Null
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var guid = FunctionView.Items[index].SubItems[2].Text;
|
||||
var nlf = _registeredFunctions[guid];
|
||||
_registeredFunctions.Remove(nlf, Global.Emulator); // TODO: don't use Global
|
||||
_registeredFunctions.Remove(nlf, GlobalWin.Emulator); // TODO: don't use Global
|
||||
}
|
||||
|
||||
PopulateListView();
|
||||
|
@ -107,7 +107,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void RemoveAllBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
_registeredFunctions.Clear(Global.Emulator); // TODO: don't use Global
|
||||
_registeredFunctions.Clear(GlobalWin.Emulator); // TODO: don't use Global
|
||||
PopulateListView();
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public override void Close()
|
||||
{
|
||||
RegisteredFunctions.Clear(Global.Emulator); // TODO: don't use globals
|
||||
RegisteredFunctions.Clear(GlobalWin.Emulator); // TODO: don't use globals
|
||||
FormsLibrary.DestroyAll();
|
||||
_lua.Close();
|
||||
_lua = new Lua();
|
||||
|
|
Loading…
Reference in New Issue