move Global.Config to GlobalWin.Config

This commit is contained in:
adelikat 2020-06-06 14:43:46 -05:00
parent 5ab7f1a18e
commit 664c829a30
35 changed files with 169 additions and 168 deletions

View File

@ -5,7 +5,6 @@ namespace BizHawk.Client.Common
{ {
public static class Global public static class Global
{ {
public static Config Config { get; set; }
public static GameInfo Game { get; set; } public static GameInfo Game { get; set; }
public static FirmwareManager FirmwareManager { get; set; } public static FirmwareManager FirmwareManager { get; set; }
public static IMovieSession MovieSession { get; set; } public static IMovieSession MovieSession { get; set; }

View File

@ -736,7 +736,7 @@ namespace BizHawk.Client.EmuHawk
if (result) if (result)
{ {
// save to config and return it // save to config and return it
Global.Config.AviCodecToken = ret.Serialize(); GlobalWin.Config.AviCodecToken = ret.Serialize();
return ret; return ret;
} }
@ -967,10 +967,10 @@ namespace BizHawk.Client.EmuHawk
/// <exception cref="Exception">no default codec token in config</exception> /// <exception cref="Exception">no default codec token in config</exception>
public void SetDefaultVideoCodecToken() public void SetDefaultVideoCodecToken()
{ {
CodecToken ct = CodecToken.DeSerialize(Global.Config.AviCodecToken); CodecToken ct = CodecToken.DeSerialize(GlobalWin.Config.AviCodecToken);
if (ct == null) if (ct == null)
{ {
throw new Exception($"No default {nameof(Global.Config.AviCodecToken)} in config!"); throw new Exception($"No default {nameof(GlobalWin.Config.AviCodecToken)} in config!");
} }
_currVideoCodecToken = ct; _currVideoCodecToken = ct;

View File

@ -83,7 +83,7 @@ namespace BizHawk.Client.EmuHawk
foreach (var fp in fps) foreach (var fp in fps)
{ {
if (fp.ToString() == Global.Config.FFmpegFormat) if (fp.ToString() == GlobalWin.Config.FFmpegFormat)
{ {
if (fp.Custom) if (fp.Custom)
{ {
@ -124,7 +124,7 @@ namespace BizHawk.Client.EmuHawk
Custom = custom; Custom = custom;
Commandline = Custom Commandline = Custom
? Global.Config.FFmpegCustomCommand ? GlobalWin.Config.FFmpegCustomCommand
: commandline; : commandline;
DeduceFormat(Commandline); DeduceFormat(Commandline);
@ -155,7 +155,7 @@ namespace BizHawk.Client.EmuHawk
FFmpegWriterForm dlg = new FFmpegWriterForm(); FFmpegWriterForm dlg = new FFmpegWriterForm();
dlg.listBox1.Items.AddRange(FormatPreset.GetPresets()); dlg.listBox1.Items.AddRange(FormatPreset.GetPresets());
int i = dlg.listBox1.FindStringExact(Global.Config.FFmpegFormat); int i = dlg.listBox1.FindStringExact(GlobalWin.Config.FFmpegFormat);
if (i != ListBox.NoMatches) if (i != ListBox.NoMatches)
{ {
dlg.listBox1.SelectedIndex = i; dlg.listBox1.SelectedIndex = i;
@ -171,11 +171,11 @@ namespace BizHawk.Client.EmuHawk
else else
{ {
ret = (FormatPreset)dlg.listBox1.SelectedItem; ret = (FormatPreset)dlg.listBox1.SelectedItem;
Global.Config.FFmpegFormat = ret.ToString(); GlobalWin.Config.FFmpegFormat = ret.ToString();
if (ret.Custom) if (ret.Custom)
{ {
ret.Commandline = ret.Commandline =
Global.Config.FFmpegCustomCommand = GlobalWin.Config.FFmpegCustomCommand =
dlg.textBox1.Text; dlg.textBox1.Text;
ret.DeduceFormat(ret.Commandline); ret.DeduceFormat(ret.Commandline);

View File

@ -64,8 +64,8 @@ namespace BizHawk.Client.EmuHawk
{ {
return new GifToken(0, 0) return new GifToken(0, 0)
{ {
Frameskip = Global.Config.GifWriterFrameskip, Frameskip = GlobalWin.Config.GifWriterFrameskip,
FrameDelay = Global.Config.GifWriterDelay FrameDelay = GlobalWin.Config.GifWriterDelay
}; };
} }

View File

@ -15,16 +15,16 @@ namespace BizHawk.Client.EmuHawk
{ {
using var dlg = new GifWriterForm using var dlg = new GifWriterForm
{ {
numericUpDown1 = { Value = Global.Config.GifWriterFrameskip }, numericUpDown1 = { Value = GlobalWin.Config.GifWriterFrameskip },
numericUpDown2 = { Value = Global.Config.GifWriterDelay } numericUpDown2 = { Value = GlobalWin.Config.GifWriterDelay }
}; };
dlg.NumericUpDown2_ValueChanged(null, null); dlg.NumericUpDown2_ValueChanged(null, null);
var result = dlg.ShowDialog(parent); var result = dlg.ShowDialog(parent);
if (result.IsOk()) if (result.IsOk())
{ {
Global.Config.GifWriterFrameskip = (int)dlg.numericUpDown1.Value; GlobalWin.Config.GifWriterFrameskip = (int)dlg.numericUpDown1.Value;
Global.Config.GifWriterDelay = (int)dlg.numericUpDown2.Value; GlobalWin.Config.GifWriterDelay = (int)dlg.numericUpDown2.Value;
return GifWriter.GifToken.LoadFromConfig(); return GifWriter.GifToken.LoadFromConfig();
} }

View File

@ -535,15 +535,15 @@ namespace BizHawk.Client.EmuHawk
var ret = new CodecToken(); var ret = new CodecToken();
// load from config and sanitize // load from config and sanitize
int t = Math.Min(Math.Max(Global.Config.JmdThreads, 1), 6); int t = Math.Min(Math.Max(GlobalWin.Config.JmdThreads, 1), 6);
int c = Math.Min(Math.Max(Global.Config.JmdCompression, Deflater.NO_COMPRESSION), Deflater.BEST_COMPRESSION); int c = Math.Min(Math.Max(GlobalWin.Config.JmdCompression, Deflater.NO_COMPRESSION), Deflater.BEST_COMPRESSION);
if (!JmdForm.DoCompressionDlg(ref t, ref c, 1, 6, Deflater.NO_COMPRESSION, Deflater.BEST_COMPRESSION, hwnd)) if (!JmdForm.DoCompressionDlg(ref t, ref c, 1, 6, Deflater.NO_COMPRESSION, Deflater.BEST_COMPRESSION, hwnd))
return null; return null;
Global.Config.JmdThreads = ret.NumThreads = t; GlobalWin.Config.JmdThreads = ret.NumThreads = t;
Global.Config.JmdCompression = ret.CompressionLevel = c; GlobalWin.Config.JmdCompression = ret.CompressionLevel = c;
return ret; return ret;
} }
@ -784,9 +784,9 @@ namespace BizHawk.Client.EmuHawk
CodecToken ct = new CodecToken(); CodecToken ct = new CodecToken();
// load from config and sanitize // load from config and sanitize
int t = Math.Min(Math.Max(Global.Config.JmdThreads, 1), 6); int t = Math.Min(Math.Max(GlobalWin.Config.JmdThreads, 1), 6);
int c = Math.Min(Math.Max(Global.Config.JmdCompression, Deflater.NO_COMPRESSION), Deflater.BEST_COMPRESSION); int c = Math.Min(Math.Max(GlobalWin.Config.JmdCompression, Deflater.NO_COMPRESSION), Deflater.BEST_COMPRESSION);
ct.CompressionLevel = c; ct.CompressionLevel = c;
ct.NumThreads = t; ct.NumThreads = t;

View File

@ -34,7 +34,7 @@ namespace BizHawk.Client.EmuHawk
var ofd = new OpenFileDialog var ofd = new OpenFileDialog
{ {
FileName = $"{Global.Game.FilesystemSafeName()}.syncless.txt", FileName = $"{Global.Game.FilesystemSafeName()}.syncless.txt",
InitialDirectory = Global.Config.PathEntries.AvAbsolutePath() InitialDirectory = GlobalWin.Config.PathEntries.AvAbsolutePath()
}; };
if (ofd.ShowDialog() == DialogResult.Cancel) if (ofd.ShowDialog() == DialogResult.Cancel)

View File

@ -122,7 +122,7 @@ namespace BizHawk.Client.EmuHawk
/// Load a savestate specified by its name /// Load a savestate specified by its name
/// </summary> /// </summary>
/// <param name="name">Savestate friendly name</param> /// <param name="name">Savestate friendly name</param>
public static void LoadState(string name) => GlobalWin.MainForm.LoadState(Path.Combine(Global.Config.PathEntries.SaveStateAbsolutePath(Global.Game.System), $"{name}.State"), name, suppressOSD: false); public static void LoadState(string name) => GlobalWin.MainForm.LoadState(Path.Combine(GlobalWin.Config.PathEntries.SaveStateAbsolutePath(Global.Game.System), $"{name}.State"), name, suppressOSD: false);
/// <summary> /// <summary>
/// Raised before a quickload is done (just after pressing shortcut button) /// Raised before a quickload is done (just after pressing shortcut button)
@ -202,7 +202,7 @@ namespace BizHawk.Client.EmuHawk
/// Save a state with specified name /// Save a state with specified name
/// </summary> /// </summary>
/// <param name="name">Savestate friendly name</param> /// <param name="name">Savestate friendly name</param>
public static void SaveState(string name) => GlobalWin.MainForm.SaveState(Path.Combine(Global.Config.PathEntries.SaveStateAbsolutePath(Global.Game.System), $"{name}.State"), name, fromLua: false); public static void SaveState(string name) => GlobalWin.MainForm.SaveState(Path.Combine(GlobalWin.Config.PathEntries.SaveStateAbsolutePath(Global.Game.System), $"{name}.State"), name, fromLua: false);
/// <summary> /// <summary>
/// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements
@ -319,7 +319,7 @@ namespace BizHawk.Client.EmuHawk
public static void CloseRom() => GlobalWin.MainForm.CloseRom(); public static void CloseRom() => GlobalWin.MainForm.CloseRom();
public static void DisplayMessages(bool value) => Global.Config.DisplayMessages = value; public static void DisplayMessages(bool value) => GlobalWin.Config.DisplayMessages = value;
public static void EnableRewind(bool enabled) => GlobalWin.MainForm.EnableRewind(enabled); public static void EnableRewind(bool enabled) => GlobalWin.MainForm.EnableRewind(enabled);
@ -327,7 +327,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (numFrames > 0) if (numFrames > 0)
{ {
Global.Config.FrameSkip = numFrames; GlobalWin.Config.FrameSkip = numFrames;
GlobalWin.MainForm.FrameSkipMessage(); GlobalWin.MainForm.FrameSkipMessage();
} }
else else
@ -336,16 +336,16 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public static int GetTargetScanlineIntensity() => Global.Config.TargetScanlineFilterIntensity; public static int GetTargetScanlineIntensity() => GlobalWin.Config.TargetScanlineFilterIntensity;
public static int GetWindowSize() => Global.Config.TargetZoomFactors[Emulator.SystemId]; public static int GetWindowSize() => GlobalWin.Config.TargetZoomFactors[Emulator.SystemId];
public static void SetSoundOn(bool enable) public static void SetSoundOn(bool enable)
{ {
if (enable != Global.Config.SoundEnabled) GlobalWin.MainForm.ToggleSound(); if (enable != GlobalWin.Config.SoundEnabled) GlobalWin.MainForm.ToggleSound();
} }
public static bool GetSoundOn() => Global.Config.SoundEnabled; public static bool GetSoundOn() => GlobalWin.Config.SoundEnabled;
public static bool IsPaused() => GlobalWin.MainForm.EmulatorPaused; public static bool IsPaused() => GlobalWin.MainForm.EmulatorPaused;
@ -373,9 +373,9 @@ namespace BizHawk.Client.EmuHawk
public static void ScreenshotToClipboard() => GlobalWin.MainForm.TakeScreenshotToClipboard(); public static void ScreenshotToClipboard() => GlobalWin.MainForm.TakeScreenshotToClipboard();
public static void SetTargetScanlineIntensity(int val) => Global.Config.TargetScanlineFilterIntensity = val; public static void SetTargetScanlineIntensity(int val) => GlobalWin.Config.TargetScanlineFilterIntensity = val;
public static void SetScreenshotOSD(bool value) => Global.Config.ScreenshotCaptureOsd = value; public static void SetScreenshotOSD(bool value) => GlobalWin.Config.ScreenshotCaptureOsd = value;
public static int ScreenWidth() => GlobalWin.MainForm.PresentationPanel.NativeSize.Width; public static int ScreenWidth() => GlobalWin.MainForm.PresentationPanel.NativeSize.Width;
@ -383,7 +383,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10) if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10)
{ {
Global.Config.TargetZoomFactors[Emulator.SystemId] = size; GlobalWin.Config.TargetZoomFactors[Emulator.SystemId] = size;
GlobalWin.MainForm.FrameBufferResized(); GlobalWin.MainForm.FrameBufferResized();
GlobalWin.OSD.AddMessage($"Window size set to {size}x"); GlobalWin.OSD.AddMessage($"Window size set to {size}x");
} }

View File

@ -46,13 +46,13 @@ namespace BizHawk.Client.EmuHawk
private readonly Action<string> LogCallback; private readonly Action<string> LogCallback;
/// <summary>Using this property to get a reference to <see cref="Global.Config">Global.Config</see> is a terrible, horrible, no good, very bad idea. That's why it's not in the <see cref="IEmu">interface</see>.</summary> /// <summary>Using this property to get a reference to <see cref="GlobalWin.Config">GlobalWin.Config</see> is a terrible, horrible, no good, very bad idea. That's why it's not in the <see cref="IEmu">interface</see>.</summary>
public Config ForbiddenConfigReference public Config ForbiddenConfigReference
{ {
get get
{ {
ForbiddenConfigReferenceUsed = true; ForbiddenConfigReferenceUsed = true;
return Global.Config; return GlobalWin.Config;
} }
} }
@ -62,7 +62,7 @@ namespace BizHawk.Client.EmuHawk
public Action YieldCallback { get; set; } public Action YieldCallback { get; set; }
public void DisplayVsync(bool enabled) => Global.Config.VSync = enabled; public void DisplayVsync(bool enabled) => GlobalWin.Config.VSync = enabled;
public void FrameAdvance() => FrameAdvanceCallback(); public void FrameAdvance() => FrameAdvanceCallback();
@ -173,9 +173,9 @@ namespace BizHawk.Client.EmuHawk
else LogCallback($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); else LogCallback($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}");
} }
public void LimitFramerate(bool enabled) => Global.Config.ClockThrottle = enabled; public void LimitFramerate(bool enabled) => GlobalWin.Config.ClockThrottle = enabled;
public void MinimizeFrameskip(bool enabled) => Global.Config.AutoMinimizeSkipping = enabled; public void MinimizeFrameskip(bool enabled) => GlobalWin.Config.AutoMinimizeSkipping = enabled;
public void Yield() => YieldCallback(); public void Yield() => YieldCallback();

View File

@ -188,11 +188,11 @@ namespace BizHawk.Client.EmuHawk
public void RefreshUserShader() public void RefreshUserShader()
{ {
ShaderChain_user?.Dispose(); ShaderChain_user?.Dispose();
if (File.Exists(Global.Config.DispUserFilterPath)) if (File.Exists(GlobalWin.Config.DispUserFilterPath))
{ {
var fi = new FileInfo(Global.Config.DispUserFilterPath); var fi = new FileInfo(GlobalWin.Config.DispUserFilterPath);
using var stream = fi.OpenRead(); using var stream = fi.OpenRead();
ShaderChain_user = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.GetDirectoryName(Global.Config.DispUserFilterPath)); ShaderChain_user = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.GetDirectoryName(GlobalWin.Config.DispUserFilterPath));
} }
} }
@ -217,10 +217,10 @@ namespace BizHawk.Client.EmuHawk
// apply user's crop selections as a negative padding (believe it or not, this largely works) // apply user's crop selections as a negative padding (believe it or not, this largely works)
// is there an issue with the aspect ratio? I don't know--but if there is, there would be with the padding too // is there an issue with the aspect ratio? I don't know--but if there is, there would be with the padding too
padding.Left -= Global.Config.DispCropLeft; padding.Left -= GlobalWin.Config.DispCropLeft;
padding.Right -= Global.Config.DispCropRight; padding.Right -= GlobalWin.Config.DispCropRight;
padding.Top -= Global.Config.DispCropTop; padding.Top -= GlobalWin.Config.DispCropTop;
padding.Bottom -= Global.Config.DispCropBottom; padding.Bottom -= GlobalWin.Config.DispCropBottom;
return padding; return padding;
} }
@ -230,18 +230,18 @@ namespace BizHawk.Client.EmuHawk
// select user special FX shader chain // select user special FX shader chain
var selectedChainProperties = new Dictionary<string, object>(); var selectedChainProperties = new Dictionary<string, object>();
Filters.RetroShaderChain selectedChain = null; Filters.RetroShaderChain selectedChain = null;
if (Global.Config.TargetDisplayFilter == 1 && ShaderChain_hq2x != null && ShaderChain_hq2x.Available) if (GlobalWin.Config.TargetDisplayFilter == 1 && ShaderChain_hq2x != null && ShaderChain_hq2x.Available)
{ {
selectedChain = ShaderChain_hq2x; selectedChain = ShaderChain_hq2x;
} }
if (Global.Config.TargetDisplayFilter == 2 && ShaderChain_scanlines != null && ShaderChain_scanlines.Available) if (GlobalWin.Config.TargetDisplayFilter == 2 && ShaderChain_scanlines != null && ShaderChain_scanlines.Available)
{ {
selectedChain = ShaderChain_scanlines; selectedChain = ShaderChain_scanlines;
selectedChainProperties["uIntensity"] = 1.0f - Global.Config.TargetScanlineFilterIntensity / 256.0f; selectedChainProperties["uIntensity"] = 1.0f - GlobalWin.Config.TargetScanlineFilterIntensity / 256.0f;
} }
if (Global.Config.TargetDisplayFilter == 3 && ShaderChain_user != null && ShaderChain_user.Available) if (GlobalWin.Config.TargetDisplayFilter == 3 && ShaderChain_user != null && ShaderChain_user.Available)
{ {
selectedChain = ShaderChain_user; selectedChain = ShaderChain_user;
} }
@ -306,9 +306,9 @@ namespace BizHawk.Client.EmuHawk
AppendLuaLayer(chain, "emu"); AppendLuaLayer(chain, "emu");
if(includeUserFilters) if(includeUserFilters)
if (Global.Config.DispPrescale != 1) if (GlobalWin.Config.DispPrescale != 1)
{ {
var fPrescale = new Filters.PrescaleFilter() { Scale = Global.Config.DispPrescale }; var fPrescale = new Filters.PrescaleFilter() { Scale = GlobalWin.Config.DispPrescale };
chain.AddFilter(fPrescale, "user_prescale"); chain.AddFilter(fPrescale, "user_prescale");
} }
@ -317,7 +317,7 @@ namespace BizHawk.Client.EmuHawk
AppendRetroShaderChain(chain, "retroShader", selectedChain, selectedChainProperties); AppendRetroShaderChain(chain, "retroShader", selectedChain, selectedChainProperties);
// AutoPrescale makes no sense for a None final filter // AutoPrescale makes no sense for a None final filter
if (Global.Config.DispAutoPrescale && Global.Config.DispFinalFilter != (int)Filters.FinalPresentation.eFilterOption.None) if (GlobalWin.Config.DispAutoPrescale && GlobalWin.Config.DispFinalFilter != (int)Filters.FinalPresentation.eFilterOption.None)
{ {
var apf = new Filters.AutoPrescaleFilter(); var apf = new Filters.AutoPrescaleFilter();
chain.AddFilter(apf, "auto_prescale"); chain.AddFilter(apf, "auto_prescale");
@ -325,12 +325,12 @@ namespace BizHawk.Client.EmuHawk
//choose final filter //choose final filter
var finalFilter = Filters.FinalPresentation.eFilterOption.None; var finalFilter = Filters.FinalPresentation.eFilterOption.None;
if (Global.Config.DispFinalFilter == 1) if (GlobalWin.Config.DispFinalFilter == 1)
{ {
finalFilter = Filters.FinalPresentation.eFilterOption.Bilinear; finalFilter = Filters.FinalPresentation.eFilterOption.Bilinear;
} }
if (Global.Config.DispFinalFilter == 2) if (GlobalWin.Config.DispFinalFilter == 2)
{ {
finalFilter = Filters.FinalPresentation.eFilterOption.Bicubic; finalFilter = Filters.FinalPresentation.eFilterOption.Bicubic;
} }
@ -446,7 +446,7 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
public void UpdateSource(IVideoProvider videoProvider) public void UpdateSource(IVideoProvider videoProvider)
{ {
bool displayNothing = Global.Config.DispSpeedupFeatures == 0; bool displayNothing = GlobalWin.Config.DispSpeedupFeatures == 0;
var job = new JobInfo var job = new JobInfo
{ {
VideoProvider = videoProvider, VideoProvider = videoProvider,
@ -472,7 +472,7 @@ namespace BizHawk.Client.EmuHawk
public BitmapBuffer RenderVideoProvider(IVideoProvider videoProvider) public BitmapBuffer RenderVideoProvider(IVideoProvider videoProvider)
{ {
// TODO - we might need to gather more Global.Config.DispXXX properties here, so they can be overridden // TODO - we might need to gather more GlobalWin.Config.DispXXX properties here, so they can be overridden
var targetSize = new Size(videoProvider.BufferWidth, videoProvider.BufferHeight); var targetSize = new Size(videoProvider.BufferWidth, videoProvider.BufferHeight);
var padding = CalculateCompleteContentPadding(true,true); var padding = CalculateCompleteContentPadding(true,true);
targetSize.Width += padding.Horizontal; targetSize.Width += padding.Horizontal;
@ -551,12 +551,12 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
public Size CalculateClientSize(IVideoProvider videoProvider, int zoom) public Size CalculateClientSize(IVideoProvider videoProvider, int zoom)
{ {
bool arActive = Global.Config.DispFixAspectRatio; bool arActive = GlobalWin.Config.DispFixAspectRatio;
bool arSystem = Global.Config.DispManagerAR == EDispManagerAR.System; bool arSystem = GlobalWin.Config.DispManagerAR == EDispManagerAR.System;
bool arCustom = Global.Config.DispManagerAR == EDispManagerAR.Custom; bool arCustom = GlobalWin.Config.DispManagerAR == EDispManagerAR.Custom;
bool arCustomRatio = Global.Config.DispManagerAR == EDispManagerAR.CustomRatio; bool arCustomRatio = GlobalWin.Config.DispManagerAR == EDispManagerAR.CustomRatio;
bool arCorrect = arSystem || arCustom || arCustomRatio; bool arCorrect = arSystem || arCustom || arCustomRatio;
bool arInteger = Global.Config.DispFixScaleInteger; bool arInteger = GlobalWin.Config.DispFixScaleInteger;
int bufferWidth = videoProvider.BufferWidth; int bufferWidth = videoProvider.BufferWidth;
int bufferHeight = videoProvider.BufferHeight; int bufferHeight = videoProvider.BufferHeight;
@ -565,13 +565,13 @@ namespace BizHawk.Client.EmuHawk
if (arCustom) if (arCustom)
{ {
virtualWidth = Global.Config.DispCustomUserARWidth; virtualWidth = GlobalWin.Config.DispCustomUserARWidth;
virtualHeight = Global.Config.DispCustomUserARHeight; virtualHeight = GlobalWin.Config.DispCustomUserARHeight;
} }
if (arCustomRatio) if (arCustomRatio)
{ {
FixRatio(Global.Config.DispCustomUserArx, Global.Config.DispCustomUserAry, videoProvider.BufferWidth, videoProvider.BufferHeight, out virtualWidth, out virtualHeight); FixRatio(GlobalWin.Config.DispCustomUserArx, GlobalWin.Config.DispCustomUserAry, videoProvider.BufferWidth, videoProvider.BufferHeight, out virtualWidth, out virtualHeight);
} }
//TODO: it is bad that this is happening outside the filter chain //TODO: it is bad that this is happening outside the filter chain
@ -782,22 +782,22 @@ namespace BizHawk.Client.EmuHawk
presenterTextureHeight = vh = sz.Height; presenterTextureHeight = vh = sz.Height;
} }
if (Global.Config.DispFixAspectRatio) if (GlobalWin.Config.DispFixAspectRatio)
{ {
if (Global.Config.DispManagerAR == EDispManagerAR.System) if (GlobalWin.Config.DispManagerAR == EDispManagerAR.System)
{ {
//Already set //Already set
} }
if (Global.Config.DispManagerAR == EDispManagerAR.Custom) if (GlobalWin.Config.DispManagerAR == EDispManagerAR.Custom)
{ {
//not clear what any of these other options mean for "screen controlled" systems //not clear what any of these other options mean for "screen controlled" systems
vw = Global.Config.DispCustomUserARWidth; vw = GlobalWin.Config.DispCustomUserARWidth;
vh = Global.Config.DispCustomUserARHeight; vh = GlobalWin.Config.DispCustomUserARHeight;
} }
if (Global.Config.DispManagerAR == EDispManagerAR.CustomRatio) if (GlobalWin.Config.DispManagerAR == EDispManagerAR.CustomRatio)
{ {
//not clear what any of these other options mean for "screen controlled" systems //not clear what any of these other options mean for "screen controlled" systems
FixRatio(Global.Config.DispCustomUserArx, Global.Config.DispCustomUserAry, videoProvider.BufferWidth, videoProvider.BufferHeight, out vw, out vh); FixRatio(GlobalWin.Config.DispCustomUserArx, GlobalWin.Config.DispCustomUserAry, videoProvider.BufferWidth, videoProvider.BufferHeight, out vw, out vh);
} }
} }
@ -853,10 +853,10 @@ namespace BizHawk.Client.EmuHawk
fPresent.BackgroundColor = videoProvider.BackgroundColor; fPresent.BackgroundColor = videoProvider.BackgroundColor;
fPresent.GuiRenderer = Renderer; fPresent.GuiRenderer = Renderer;
fPresent.Flip = isGlTextureId; fPresent.Flip = isGlTextureId;
fPresent.Config_FixAspectRatio = Global.Config.DispFixAspectRatio; fPresent.Config_FixAspectRatio = GlobalWin.Config.DispFixAspectRatio;
fPresent.Config_FixScaleInteger = Global.Config.DispFixScaleInteger; fPresent.Config_FixScaleInteger = GlobalWin.Config.DispFixScaleInteger;
fPresent.Padding = ClientExtraPadding; fPresent.Padding = ClientExtraPadding;
fPresent.AutoPrescale = Global.Config.DispAutoPrescale; fPresent.AutoPrescale = GlobalWin.Config.DispAutoPrescale;
fPresent.GL = GL; fPresent.GL = GL;
} }
@ -907,7 +907,7 @@ namespace BizHawk.Client.EmuHawk
if (!job.Offscreen) if (!job.Offscreen)
{ {
//apply the vsync setting (should probably try to avoid repeating this) //apply the vsync setting (should probably try to avoid repeating this)
var vsync = Global.Config.VSyncThrottle || Global.Config.VSync; var vsync = GlobalWin.Config.VSyncThrottle || GlobalWin.Config.VSync;
//ok, now this is a bit undesirable. //ok, now this is a bit undesirable.
//maybe the user wants vsync, but not vsync throttle. //maybe the user wants vsync, but not vsync throttle.
@ -918,7 +918,7 @@ namespace BizHawk.Client.EmuHawk
vsync = false; vsync = false;
//for now, it's assumed that the presentation panel is the main window, but that may not always be true //for now, it's assumed that the presentation panel is the main window, but that may not always be true
if (vsync && Global.Config.DispAlternateVsync && Global.Config.VSyncThrottle) if (vsync && GlobalWin.Config.DispAlternateVsync && GlobalWin.Config.VSyncThrottle)
{ {
dx9 = GL as IGL_SlimDX9; dx9 = GL as IGL_SlimDX9;
if (dx9 != null) if (dx9 != null)

View File

@ -47,8 +47,8 @@ namespace BizHawk.Client.EmuHawk
MessageFont = blitter.GetFontType(nameof(MessageFont)); MessageFont = blitter.GetFontType(nameof(MessageFont));
} }
public Color FixedMessagesColor => Color.FromArgb(Global.Config.MessagesColor); public Color FixedMessagesColor => Color.FromArgb(GlobalWin.Config.MessagesColor);
public Color FixedAlertMessageColor => Color.FromArgb(Global.Config.AlertMessageColor); public Color FixedAlertMessageColor => Color.FromArgb(GlobalWin.Config.AlertMessageColor);
private PointF GetCoordinates(IBlitter g, MessagePosition position, string message) private PointF GetCoordinates(IBlitter g, MessagePosition position, string message)
{ {
@ -135,14 +135,14 @@ namespace BizHawk.Client.EmuHawk
private void DrawMessage(IBlitter g, UIMessage message, int yOffset) private void DrawMessage(IBlitter g, UIMessage message, int yOffset)
{ {
var point = GetCoordinates(g, Global.Config.Messages, message.Message); var point = GetCoordinates(g, GlobalWin.Config.Messages, message.Message);
var y = point.Y + yOffset; // TODO: clean me up var y = point.Y + yOffset; // TODO: clean me up
g.DrawString(message.Message, MessageFont, FixedMessagesColor, point.X, y); g.DrawString(message.Message, MessageFont, FixedMessagesColor, point.X, y);
} }
public void DrawMessages(IBlitter g) public void DrawMessages(IBlitter g)
{ {
if (!Global.Config.DisplayMessages) if (!GlobalWin.Config.DisplayMessages)
{ {
return; return;
} }
@ -151,13 +151,13 @@ namespace BizHawk.Client.EmuHawk
if (_messages.Any()) if (_messages.Any())
{ {
if (Global.Config.StackOSDMessages) if (GlobalWin.Config.StackOSDMessages)
{ {
int line = 1; int line = 1;
for (int i = _messages.Count - 1; i >= 0; i--, line++) for (int i = _messages.Count - 1; i >= 0; i--, line++)
{ {
int yOffset = (line - 1) * 18; int yOffset = (line - 1) * 18;
if (!Global.Config.Messages.Anchor.IsTop()) if (!GlobalWin.Config.Messages.Anchor.IsTop())
{ {
yOffset = 0 - yOffset; yOffset = 0 - yOffset;
} }
@ -258,11 +258,11 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
public void DrawScreenInfo(IBlitter g) public void DrawScreenInfo(IBlitter g)
{ {
if (Global.Config.DisplayFrameCounter && !Global.Game.IsNullInstance()) if (GlobalWin.Config.DisplayFrameCounter && !Global.Game.IsNullInstance())
{ {
string message = MakeFrameCounter(); string message = MakeFrameCounter();
var point = GetCoordinates(g, Global.Config.FrameCounter, message); var point = GetCoordinates(g, GlobalWin.Config.FrameCounter, message);
DrawOsdMessage(g, message, Color.FromArgb(Global.Config.MessagesColor), point.X, point.Y); DrawOsdMessage(g, message, Color.FromArgb(GlobalWin.Config.MessagesColor), point.X, point.Y);
if (GlobalWin.MainForm.IsLagFrame) if (GlobalWin.MainForm.IsLagFrame)
{ {
@ -270,27 +270,27 @@ namespace BizHawk.Client.EmuHawk
} }
} }
if (Global.Config.DisplayInput && !Global.Game.IsNullInstance()) if (GlobalWin.Config.DisplayInput && !Global.Game.IsNullInstance())
{ {
if (Global.MovieSession.Movie.IsPlaying() if (Global.MovieSession.Movie.IsPlaying()
|| (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 || (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 input = InputStrMovie();
var point = GetCoordinates(g, Global.Config.InputDisplay, input); var point = GetCoordinates(g, GlobalWin.Config.InputDisplay, input);
Color c = Color.FromArgb(Global.Config.MovieInput); Color c = Color.FromArgb(GlobalWin.Config.MovieInput);
g.DrawString(input, MessageFont, c, point.X, point.Y); g.DrawString(input, MessageFont, c, point.X, point.Y);
} }
else // TODO: message config -- allow setting of "previous", "mixed", and "auto" else // TODO: message config -- allow setting of "previous", "mixed", and "auto"
{ {
var previousColor = Color.Orange; var previousColor = Color.Orange;
Color immediateColor = Color.FromArgb(Global.Config.MessagesColor); Color immediateColor = Color.FromArgb(GlobalWin.Config.MessagesColor);
var autoColor = Color.Pink; var autoColor = Color.Pink;
var changedColor = Color.PeachPuff; var changedColor = Color.PeachPuff;
//we need some kind of string for calculating position when right-anchoring, of something like that //we need some kind of string for calculating position when right-anchoring, of something like that
var bgStr = InputStrOrAll(); var bgStr = InputStrOrAll();
var point = GetCoordinates(g, Global.Config.InputDisplay, bgStr); var point = GetCoordinates(g, GlobalWin.Config.InputDisplay, bgStr);
// now, we're going to render these repeatedly, with higher-priority things overriding // now, we're going to render these repeatedly, with higher-priority things overriding
@ -322,27 +322,27 @@ namespace BizHawk.Client.EmuHawk
if (Global.MovieSession.MultiTrack.IsActive) if (Global.MovieSession.MultiTrack.IsActive)
{ {
var point = GetCoordinates(g, Global.Config.MultitrackRecorder, Global.MovieSession.MultiTrack.Status); var point = GetCoordinates(g, GlobalWin.Config.MultitrackRecorder, Global.MovieSession.MultiTrack.Status);
DrawOsdMessage(g, Global.MovieSession.MultiTrack.Status, FixedMessagesColor, point.X, point.Y); DrawOsdMessage(g, Global.MovieSession.MultiTrack.Status, FixedMessagesColor, point.X, point.Y);
} }
if (Global.Config.DisplayFps && Fps != null) if (GlobalWin.Config.DisplayFps && Fps != null)
{ {
var point = GetCoordinates(g, Global.Config.Fps, Fps); var point = GetCoordinates(g, GlobalWin.Config.Fps, Fps);
DrawOsdMessage(g, Fps, FixedMessagesColor, point.X, point.Y); DrawOsdMessage(g, Fps, FixedMessagesColor, point.X, point.Y);
} }
if (Global.Config.DisplayLagCounter && GlobalWin.Emulator.CanPollInput()) if (GlobalWin.Config.DisplayLagCounter && GlobalWin.Emulator.CanPollInput())
{ {
var counter = GlobalWin.Emulator.AsInputPollable().LagCount.ToString(); var counter = GlobalWin.Emulator.AsInputPollable().LagCount.ToString();
var point = GetCoordinates(g, Global.Config.LagCounter, counter); var point = GetCoordinates(g, GlobalWin.Config.LagCounter, counter);
DrawOsdMessage(g, counter, FixedAlertMessageColor, point.X, point.Y); DrawOsdMessage(g, counter, FixedAlertMessageColor, point.X, point.Y);
} }
if (Global.Config.DisplayRerecordCount) if (GlobalWin.Config.DisplayRerecordCount)
{ {
string rerecordCount = MakeRerecordCount(); string rerecordCount = MakeRerecordCount();
var point = GetCoordinates(g, Global.Config.ReRecordCounter, rerecordCount); var point = GetCoordinates(g, GlobalWin.Config.ReRecordCounter, rerecordCount);
DrawOsdMessage(g, rerecordCount, FixedMessagesColor, point.X, point.Y); DrawOsdMessage(g, rerecordCount, FixedMessagesColor, point.X, point.Y);
} }
@ -364,11 +364,11 @@ namespace BizHawk.Client.EmuHawk
} }
var message = sb.ToString(); var message = sb.ToString();
var point = GetCoordinates(g, Global.Config.Autohold, message); var point = GetCoordinates(g, GlobalWin.Config.Autohold, message);
g.DrawString(message, MessageFont, Color.White, point.X, point.Y); g.DrawString(message, MessageFont, Color.White, point.X, point.Y);
} }
if (Global.MovieSession.Movie.IsActive() && Global.Config.DisplaySubtitles) if (Global.MovieSession.Movie.IsActive() && GlobalWin.Config.DisplaySubtitles)
{ {
var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(GlobalWin.Emulator.Frame); var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(GlobalWin.Emulator.Frame);

View File

@ -45,8 +45,8 @@ namespace BizHawk.Client.EmuHawk
return emulator switch return emulator switch
{ {
Snes9x _ => PromptToSwitchCore("Snes9x", "bsnes", () => Global.Config.PreferredCores["SNES"] = Cores.CoreNames.Bsnes), Snes9x _ => PromptToSwitchCore("Snes9x", "bsnes", () => GlobalWin.Config.PreferredCores["SNES"] = Cores.CoreNames.Bsnes),
QuickNES _ => PromptToSwitchCore("QuickNes", "NesHawk", () => Global.Config.PreferredCores["NES"] = Cores.CoreNames.NesHawk), QuickNES _ => PromptToSwitchCore("QuickNes", "NesHawk", () => GlobalWin.Config.PreferredCores["NES"] = Cores.CoreNames.NesHawk),
_ => true _ => true
}; };
} }

View File

@ -41,5 +41,7 @@ namespace BizHawk.Client.EmuHawk
public static bool DisableSecondaryThrottling { get; set; } public static bool DisableSecondaryThrottling { get; set; }
public static Dictionary<string, object> UserBag { get; set; } = new Dictionary<string, object>(); public static Dictionary<string, object> UserBag { get; set; } = new Dictionary<string, object>();
public static Config Config { get; set; }
} }
} }

View File

@ -120,7 +120,7 @@ namespace BizHawk.Client.EmuHawk
private readonly Thread UpdateThread; private readonly Thread UpdateThread;
public readonly HostInputAdapter Adapter = Global.Config.HostInputMethod switch public readonly HostInputAdapter Adapter = GlobalWin.Config.HostInputMethod switch
{ {
EHostInputMethod.OpenTK => new OpenTKInputAdapter(), EHostInputMethod.OpenTK => new OpenTKInputAdapter(),
EHostInputMethod.DirectInput => new DirectInputAdapter(), EHostInputMethod.DirectInput => new DirectInputAdapter(),

View File

@ -12,7 +12,7 @@ namespace BizHawk.Client.EmuHawk
public static Key Handle(Key key) public static Key Handle(Key key)
{ {
if (!Global.Config.HandleAlternateKeyboardLayouts) return key; if (!GlobalWin.Config.HandleAlternateKeyboardLayouts) return key;
ScanCode inputScanCode = SlimDXScanCodeMap[(int)key]; ScanCode inputScanCode = SlimDXScanCodeMap[(int)key];
Keys virtualKey = (Keys)BizHawk.Common.Win32Imports.MapVirtualKey((uint)inputScanCode, MAPVK_VSC_TO_VK_EX); Keys virtualKey = (Keys)BizHawk.Common.Win32Imports.MapVirtualKey((uint)inputScanCode, MAPVK_VSC_TO_VK_EX);
ScanCode standardScanCode = GetStandardScanCode(virtualKey); ScanCode standardScanCode = GetStandardScanCode(virtualKey);

View File

@ -875,8 +875,8 @@ namespace BizHawk.Client.EmuHawk
private Config Config private Config Config
{ {
get => Global.Config; get => GlobalWin.Config;
set => Global.Config = value; set => GlobalWin.Config = value;
} }
private ToolManager Tools => GlobalWin.Tools; private ToolManager Tools => GlobalWin.Tools;

View File

@ -108,24 +108,24 @@ namespace BizHawk.Client.EmuHawk
try try
{ {
Global.Config = ConfigService.Load<Config>(Config.DefaultIniPath); GlobalWin.Config = ConfigService.Load<Config>(Config.DefaultIniPath);
} }
catch (Exception e) catch (Exception e)
{ {
new ExceptionBox(e).ShowDialog(); new ExceptionBox(e).ShowDialog();
new ExceptionBox("Since your config file is corrupted or from a different BizHawk version, we're going to recreate it. Back it up before proceeding if you want to investigate further.").ShowDialog(); new ExceptionBox("Since your config file is corrupted or from a different BizHawk version, we're going to recreate it. Back it up before proceeding if you want to investigate further.").ShowDialog();
File.Delete(Config.DefaultIniPath); File.Delete(Config.DefaultIniPath);
Global.Config = ConfigService.Load<Config>(Config.DefaultIniPath); GlobalWin.Config = ConfigService.Load<Config>(Config.DefaultIniPath);
} }
Global.Config.ResolveDefaults(); GlobalWin.Config.ResolveDefaults();
StringLogUtil.DefaultToDisk = Global.Config.Movies.MoviesOnDisk; StringLogUtil.DefaultToDisk = GlobalWin.Config.Movies.MoviesOnDisk;
// super hacky! this needs to be done first. still not worth the trouble to make this system fully proper // super hacky! this needs to be done first. still not worth the trouble to make this system fully proper
if (Array.Exists(args, arg => arg.StartsWith("--gdi", StringComparison.InvariantCultureIgnoreCase))) if (Array.Exists(args, arg => arg.StartsWith("--gdi", StringComparison.InvariantCultureIgnoreCase)))
{ {
Global.Config.DispMethod = EDispMethod.GdiPlus; GlobalWin.Config.DispMethod = EDispMethod.GdiPlus;
} }
// create IGL context. we do this whether or not the user has selected OpenGL, so that we can run opengl-based emulator cores // create IGL context. we do this whether or not the user has selected OpenGL, so that we can run opengl-based emulator cores
@ -137,11 +137,11 @@ namespace BizHawk.Client.EmuHawk
//now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen //now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen
REDO_DISPMETHOD: REDO_DISPMETHOD:
if (Global.Config.DispMethod == EDispMethod.GdiPlus) if (GlobalWin.Config.DispMethod == EDispMethod.GdiPlus)
{ {
GlobalWin.GL = new IGL_GdiPlus(); GlobalWin.GL = new IGL_GdiPlus();
} }
else if (Global.Config.DispMethod == EDispMethod.SlimDX9) else if (GlobalWin.Config.DispMethod == EDispMethod.SlimDX9)
{ {
try try
{ {
@ -152,7 +152,7 @@ namespace BizHawk.Client.EmuHawk
new ExceptionBox(new Exception("Initialization of Direct3d 9 Display Method failed; falling back to GDI+", ex)).ShowDialog(); new ExceptionBox(new Exception("Initialization of Direct3d 9 Display Method failed; falling back to GDI+", ex)).ShowDialog();
// fallback // fallback
Global.Config.DispMethod = EDispMethod.GdiPlus; GlobalWin.Config.DispMethod = EDispMethod.GdiPlus;
goto REDO_DISPMETHOD; goto REDO_DISPMETHOD;
} }
} }
@ -164,7 +164,7 @@ namespace BizHawk.Client.EmuHawk
if (GlobalWin.IGL_GL.Version < 200) if (GlobalWin.IGL_GL.Version < 200)
{ {
// fallback // fallback
Global.Config.DispMethod = EDispMethod.GdiPlus; GlobalWin.Config.DispMethod = EDispMethod.GdiPlus;
goto REDO_DISPMETHOD; goto REDO_DISPMETHOD;
} }
} }
@ -179,7 +179,7 @@ namespace BizHawk.Client.EmuHawk
new ExceptionBox(new Exception("Initialization of Display Method failed; falling back to GDI+", ex)).ShowDialog(); new ExceptionBox(new Exception("Initialization of Display Method failed; falling back to GDI+", ex)).ShowDialog();
//fallback //fallback
Global.Config.DispMethod = EDispMethod.GdiPlus; GlobalWin.Config.DispMethod = EDispMethod.GdiPlus;
goto REDO_DISPMETHOD; goto REDO_DISPMETHOD;
} }
@ -196,7 +196,7 @@ namespace BizHawk.Client.EmuHawk
try try
{ {
if (Global.Config.SingleInstanceMode) if (GlobalWin.Config.SingleInstanceMode)
{ {
try try
{ {
@ -280,7 +280,7 @@ namespace BizHawk.Client.EmuHawk
// later, we look for NLua or KopiLua assembly names and redirect them to files located in the output/DLL/nlua directory // later, we look for NLua or KopiLua assembly names and redirect them to files located in the output/DLL/nlua directory
if (new AssemblyName(requested).Name == "NLua") if (new AssemblyName(requested).Name == "NLua")
{ {
//this method referencing Global.Config makes assemblies get loaded, which isnt smart from the assembly resolver. //this method referencing GlobalWin.Config makes assemblies get loaded, which isnt smart from the assembly resolver.
//so.. we're going to resort to something really bad. //so.. we're going to resort to something really bad.
//avert your eyes. //avert your eyes.
var configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini"); var configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini");

View File

@ -60,7 +60,7 @@ namespace BizHawk.Client.EmuHawk
public void StartSound() public void StartSound()
{ {
BufferSizeSamples = Sound.MillisecondsToSamples(Global.Config.SoundBufferSizeMs); BufferSizeSamples = Sound.MillisecondsToSamples(GlobalWin.Config.SoundBufferSizeMs);
// 35 to 65 milliseconds depending on how big the buffer is. This is a trade-off // 35 to 65 milliseconds depending on how big the buffer is. This is a trade-off
// between more frequent but less severe glitches (i.e. catching underruns before // between more frequent but less severe glitches (i.e. catching underruns before
@ -68,7 +68,7 @@ namespace BizHawk.Client.EmuHawk
// severe glitches. At least on my Windows 8 machines, the distance between the // severe glitches. At least on my Windows 8 machines, the distance between the
// play and write cursors can be up to 30 milliseconds, so that would be the // play and write cursors can be up to 30 milliseconds, so that would be the
// absolute minimum we could use here. // absolute minimum we could use here.
int minBufferFullnessMs = Math.Min(35 + ((Global.Config.SoundBufferSizeMs - 60) / 2), 65); int minBufferFullnessMs = Math.Min(35 + ((GlobalWin.Config.SoundBufferSizeMs - 60) / 2), 65);
MaxSamplesDeficit = BufferSizeSamples - Sound.MillisecondsToSamples(minBufferFullnessMs); MaxSamplesDeficit = BufferSizeSamples - Sound.MillisecondsToSamples(minBufferFullnessMs);
var format = new WaveFormat var format = new WaveFormat

View File

@ -30,7 +30,7 @@ namespace BizHawk.Client.EmuHawk
public void StartSound() public void StartSound()
{ {
BufferSizeSamples = Sound.MillisecondsToSamples(Global.Config.SoundBufferSizeMs); BufferSizeSamples = Sound.MillisecondsToSamples(GlobalWin.Config.SoundBufferSizeMs);
MaxSamplesDeficit = BufferSizeSamples; MaxSamplesDeficit = BufferSizeSamples;
_lastWriteTime = 0; _lastWriteTime = 0;

View File

@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk
public OpenALSoundOutput(Sound sound) public OpenALSoundOutput(Sound sound)
{ {
_sound = sound; _sound = sound;
string deviceName = GetDeviceNames().FirstOrDefault(n => n == Global.Config.SoundDevice); string deviceName = GetDeviceNames().FirstOrDefault(n => n == GlobalWin.Config.SoundDevice);
_context = new AudioContext(deviceName, Sound.SampleRate); _context = new AudioContext(deviceName, Sound.SampleRate);
} }
@ -54,7 +54,7 @@ namespace BizHawk.Client.EmuHawk
public void StartSound() public void StartSound()
{ {
BufferSizeSamples = Sound.MillisecondsToSamples(Global.Config.SoundBufferSizeMs); BufferSizeSamples = Sound.MillisecondsToSamples(GlobalWin.Config.SoundBufferSizeMs);
MaxSamplesDeficit = BufferSizeSamples; MaxSamplesDeficit = BufferSizeSamples;
_sourceID = AL.GenSource(); _sourceID = AL.GenSource();

View File

@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk
_device = new XAudio2(); _device = new XAudio2();
int? deviceIndex = Enumerable.Range(0, _device.DeviceCount) int? deviceIndex = Enumerable.Range(0, _device.DeviceCount)
.Select(n => (int?)n) .Select(n => (int?)n)
.FirstOrDefault(n => _device.GetDeviceDetails(n.Value).DisplayName == Global.Config.SoundDevice); .FirstOrDefault(n => _device.GetDeviceDetails(n.Value).DisplayName == GlobalWin.Config.SoundDevice);
_masteringVoice = deviceIndex == null ? _masteringVoice = deviceIndex == null ?
new MasteringVoice(_device, Sound.ChannelCount, Sound.SampleRate) : new MasteringVoice(_device, Sound.ChannelCount, Sound.SampleRate) :
new MasteringVoice(_device, Sound.ChannelCount, Sound.SampleRate, deviceIndex.Value); new MasteringVoice(_device, Sound.ChannelCount, Sound.SampleRate, deviceIndex.Value);
@ -64,7 +64,7 @@ namespace BizHawk.Client.EmuHawk
public void StartSound() public void StartSound()
{ {
BufferSizeSamples = Sound.MillisecondsToSamples(Global.Config.SoundBufferSizeMs); BufferSizeSamples = Sound.MillisecondsToSamples(GlobalWin.Config.SoundBufferSizeMs);
MaxSamplesDeficit = BufferSizeSamples; MaxSamplesDeficit = BufferSizeSamples;
var format = new WaveFormat var format = new WaveFormat

View File

@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk
public Sound(IntPtr mainWindowHandle) public Sound(IntPtr mainWindowHandle)
{ {
if (Global.Config.SoundOutputMethod != ESoundOutputMethod.Dummy) if (GlobalWin.Config.SoundOutputMethod != ESoundOutputMethod.Dummy)
{ {
if (OSTailoredCode.IsUnixHost) if (OSTailoredCode.IsUnixHost)
{ {
@ -31,11 +31,11 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
if (Global.Config.SoundOutputMethod == ESoundOutputMethod.OpenAL) if (GlobalWin.Config.SoundOutputMethod == ESoundOutputMethod.OpenAL)
_outputDevice = new OpenALSoundOutput(this); _outputDevice = new OpenALSoundOutput(this);
if (Global.Config.SoundOutputMethod == ESoundOutputMethod.DirectSound) if (GlobalWin.Config.SoundOutputMethod == ESoundOutputMethod.DirectSound)
_outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle, Global.Config.SoundDevice); _outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle, GlobalWin.Config.SoundDevice);
if (Global.Config.SoundOutputMethod == ESoundOutputMethod.XAudio2) if (GlobalWin.Config.SoundOutputMethod == ESoundOutputMethod.XAudio2)
_outputDevice = new XAudio2SoundOutput(this); _outputDevice = new XAudio2SoundOutput(this);
} }
} }
@ -64,7 +64,7 @@ namespace BizHawk.Client.EmuHawk
public void StartSound() public void StartSound()
{ {
if (_disposed) return; if (_disposed) return;
if (!Global.Config.SoundEnabled) return; if (!GlobalWin.Config.SoundEnabled) return;
if (IsStarted) return; if (IsStarted) return;
_outputDevice.StartSound(); _outputDevice.StartSound();
@ -138,7 +138,7 @@ namespace BizHawk.Client.EmuHawk
public void UpdateSound(float atten) public void UpdateSound(float atten)
{ {
if (!Global.Config.SoundEnabled || !IsStarted || _bufferedProvider == null || _disposed) if (!GlobalWin.Config.SoundEnabled || !IsStarted || _bufferedProvider == null || _disposed)
{ {
_bufferedProvider?.DiscardSamples(); _bufferedProvider?.DiscardSamples();
return; return;
@ -163,7 +163,7 @@ namespace BizHawk.Client.EmuHawk
} }
else if (_bufferedProvider == _outputProvider) else if (_bufferedProvider == _outputProvider)
{ {
if (Global.Config.SoundThrottle) if (GlobalWin.Config.SoundThrottle)
{ {
_outputProvider.BaseSoundProvider.GetSamplesSync(out samples, out sampleCount); _outputProvider.BaseSoundProvider.GetSamplesSync(out samples, out sampleCount);
sampleOffset = 0; sampleOffset = 0;

View File

@ -63,7 +63,7 @@ namespace BizHawk.Client.EmuHawk
else throw new InvalidOperationException(); else throw new InvalidOperationException();
#endif #endif
int skipRate = (forceFrameSkip < 0) ? Global.Config.FrameSkip : forceFrameSkip; int skipRate = (forceFrameSkip < 0) ? GlobalWin.Config.FrameSkip : forceFrameSkip;
int ffSkipRate = (forceFrameSkip < 0) ? 3 : forceFrameSkip; int ffSkipRate = (forceFrameSkip < 0) ? 3 : forceFrameSkip;
if (lastSkipRate != skipRate) if (lastSkipRate != skipRate)
@ -80,7 +80,7 @@ namespace BizHawk.Client.EmuHawk
{ {
//don't ever skip frames when continuous frame advancing. it's meant for precision work. //don't ever skip frames when continuous frame advancing. it's meant for precision work.
//but we DO need to throttle //but we DO need to throttle
if (Global.Config.ClockThrottle) if (GlobalWin.Config.ClockThrottle)
extraThrottle = true; extraThrottle = true;
} }
else else
@ -108,12 +108,12 @@ namespace BizHawk.Client.EmuHawk
if (framesToSkip < 1) if (framesToSkip < 1)
framesToSkip += ffSkipRate; framesToSkip += ffSkipRate;
} }
else if ((extraThrottle || signal_paused || Global.Config.ClockThrottle || signal_overrideSecondaryThrottle) && allowSleep) else if ((extraThrottle || signal_paused || GlobalWin.Config.ClockThrottle || signal_overrideSecondaryThrottle) && allowSleep)
{ {
SpeedThrottle(signal_paused); SpeedThrottle(signal_paused);
} }
if (Global.Config.AutoMinimizeSkipping && Global.Config.FrameSkip != 0) if (GlobalWin.Config.AutoMinimizeSkipping && GlobalWin.Config.FrameSkip != 0)
{ {
if (!signal_continuousFrameAdvancing) if (!signal_continuousFrameAdvancing)
{ {

View File

@ -16,26 +16,26 @@ namespace BizHawk.Client.EmuHawk
private static bool AutoCheckEnabled private static bool AutoCheckEnabled
{ {
get => Global.Config.UpdateAutoCheckEnabled; get => GlobalWin.Config.UpdateAutoCheckEnabled;
set => Global.Config.UpdateAutoCheckEnabled = value; set => GlobalWin.Config.UpdateAutoCheckEnabled = value;
} }
private static DateTime? LastCheckTimeUTC private static DateTime? LastCheckTimeUTC
{ {
get => Global.Config.UpdateLastCheckTimeUtc; get => GlobalWin.Config.UpdateLastCheckTimeUtc;
set => Global.Config.UpdateLastCheckTimeUtc = value; set => GlobalWin.Config.UpdateLastCheckTimeUtc = value;
} }
private static string LatestVersion private static string LatestVersion
{ {
get => Global.Config.UpdateLatestVersion; get => GlobalWin.Config.UpdateLatestVersion;
set => Global.Config.UpdateLatestVersion = value; set => GlobalWin.Config.UpdateLatestVersion = value;
} }
private static string IgnoreVersion private static string IgnoreVersion
{ {
get => Global.Config.UpdateIgnoreVersion; get => GlobalWin.Config.UpdateIgnoreVersion;
set => Global.Config.UpdateIgnoreVersion = value; set => GlobalWin.Config.UpdateIgnoreVersion = value;
} }
public static void BeginCheck(bool skipCheck = false) public static void BeginCheck(bool skipCheck = false)

View File

@ -48,7 +48,7 @@ namespace BizHawk.Client.EmuHawk
{ {
PopulatePlatforms(); PopulatePlatforms();
var selectedSystemId = Global.Config.PreferredPlatformsForExtensions[FileExtension]; var selectedSystemId = GlobalWin.Config.PreferredPlatformsForExtensions[FileExtension];
if (!string.IsNullOrEmpty(selectedSystemId)) if (!string.IsNullOrEmpty(selectedSystemId))
{ {
var selectedSystem = _availableSystems.FirstOrDefault(s => s.SystemId == selectedSystemId); var selectedSystem = _availableSystems.FirstOrDefault(s => s.SystemId == selectedSystemId);

View File

@ -471,7 +471,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
Global.Config.FirmwareUserSpecifications[fr.ConfigKey] = filePath; GlobalWin.Config.FirmwareUserSpecifications[fr.ConfigKey] = filePath;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -490,7 +490,7 @@ namespace BizHawk.Client.EmuHawk
foreach (ListViewItem lvi in lvFirmwares.SelectedItems) foreach (ListViewItem lvi in lvFirmwares.SelectedItems)
{ {
var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord; var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord;
Global.Config.FirmwareUserSpecifications.Remove(fr.ConfigKey); GlobalWin.Config.FirmwareUserSpecifications.Remove(fr.ConfigKey);
} }
DoScan(); DoScan();
@ -584,7 +584,7 @@ namespace BizHawk.Client.EmuHawk
return; return;
} }
using var pathConfig = new PathConfig(_mainForm, Global.Config); using var pathConfig = new PathConfig(_mainForm, GlobalWin.Config);
pathConfig.ShowDialog(this); pathConfig.ShowDialog(this);
RefreshBasePath(); RefreshBasePath();
} }

View File

@ -92,7 +92,7 @@ namespace BizHawk.Client.EmuHawk
public void SaveFile() public void SaveFile()
{ {
string path = Global.Config.PathEntries.ScreenshotAbsolutePathFor(GlobalWin.Emulator.SystemId); string path = GlobalWin.Config.PathEntries.ScreenshotAbsolutePathFor(GlobalWin.Emulator.SystemId);
var di = new DirectoryInfo(path); var di = new DirectoryInfo(path);

View File

@ -308,7 +308,7 @@ namespace BizHawk.Client.EmuHawk
{ {
using var ofd = new OpenFileDialog using var ofd = new OpenFileDialog
{ {
InitialDirectory = Global.Config.PathEntries.ScreenshotAbsolutePathFor("GB"), InitialDirectory = GlobalWin.Config.PathEntries.ScreenshotAbsolutePathFor("GB"),
Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(), Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(),
RestoreDirectory = true RestoreDirectory = true
}; };
@ -344,7 +344,7 @@ namespace BizHawk.Client.EmuHawk
{ {
using var sfd = new SaveFileDialog using var sfd = new SaveFileDialog
{ {
InitialDirectory = Global.Config.PathEntries.PalettesAbsolutePathFor("GB"), InitialDirectory = GlobalWin.Config.PathEntries.PalettesAbsolutePathFor("GB"),
FileName = $"{Global.Game.Name}.pal", FileName = $"{Global.Game.Name}.pal",
Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(), Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(),
RestoreDirectory = true RestoreDirectory = true

View File

@ -70,7 +70,7 @@ namespace BizHawk.Client.EmuHawk
_files = new List<string>(files); _files = new List<string>(files);
_numFrames = numFrames; _numFrames = numFrames;
_ldr = new RomLoader(Global.Config); _ldr = new RomLoader(GlobalWin.Config);
_ldr.OnLoadError += OnLoadError; _ldr.OnLoadError += OnLoadError;
_ldr.ChooseArchive = ChooseArchive; _ldr.ChooseArchive = ChooseArchive;
_comm = mainForm.CreateCoreComm(); _comm = mainForm.CreateCoreComm();

View File

@ -25,12 +25,12 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
static ExternalToolManager() static ExternalToolManager()
{ {
if(!Directory.Exists(Global.Config.PathEntries["Global", "External Tools"].Path)) if(!Directory.Exists(GlobalWin.Config.PathEntries["Global", "External Tools"].Path))
{ {
Directory.CreateDirectory(Global.Config.PathEntries["Global", "External Tools"].Path); Directory.CreateDirectory(GlobalWin.Config.PathEntries["Global", "External Tools"].Path);
} }
DirectoryMonitor = new FileSystemWatcher(Global.Config.PathEntries["Global", "External Tools"].Path, "*.dll") DirectoryMonitor = new FileSystemWatcher(GlobalWin.Config.PathEntries["Global", "External Tools"].Path, "*.dll")
{ {
IncludeSubdirectories = false IncludeSubdirectories = false
, NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName , NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName

View File

@ -106,7 +106,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (numFrames >= 0) if (numFrames >= 0)
{ {
Global.Config.FrameSkip = numFrames; GlobalWin.Config.FrameSkip = numFrames;
MainForm.FrameSkipMessage(); MainForm.FrameSkipMessage();
} }
else else
@ -155,14 +155,14 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod("gettargetscanlineintensity", "Gets the current scanline intensity setting, used for the scanline display filter")] [LuaMethod("gettargetscanlineintensity", "Gets the current scanline intensity setting, used for the scanline display filter")]
public static int GetTargetScanlineIntensity() public static int GetTargetScanlineIntensity()
{ {
return Global.Config.TargetScanlineFilterIntensity; return GlobalWin.Config.TargetScanlineFilterIntensity;
} }
[LuaMethodExample("local incliget = client.getwindowsize( );")] [LuaMethodExample("local incliget = client.getwindowsize( );")]
[LuaMethod("getwindowsize", "Gets the main window's size Possible values are 1, 2, 3, 4, 5, and 10")] [LuaMethod("getwindowsize", "Gets the main window's size Possible values are 1, 2, 3, 4, 5, and 10")]
public int GetWindowSize() public int GetWindowSize()
{ {
return Global.Config.TargetZoomFactors[Emulator.SystemId]; return GlobalWin.Config.TargetZoomFactors[Emulator.SystemId];
} }
[LuaMethodExample("client.SetGameExtraPadding( 5, 10, 15, 20 );")] [LuaMethodExample("client.SetGameExtraPadding( 5, 10, 15, 20 );")]
@ -301,14 +301,14 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod("settargetscanlineintensity", "Sets the current scanline intensity setting, used for the scanline display filter")] [LuaMethod("settargetscanlineintensity", "Sets the current scanline intensity setting, used for the scanline display filter")]
public static void SetTargetScanlineIntensity(int val) public static void SetTargetScanlineIntensity(int val)
{ {
Global.Config.TargetScanlineFilterIntensity = val; GlobalWin.Config.TargetScanlineFilterIntensity = val;
} }
[LuaMethodExample("client.setscreenshotosd( true );")] [LuaMethodExample("client.setscreenshotosd( true );")]
[LuaMethod("setscreenshotosd", "Sets the screenshot Capture OSD property of the client")] [LuaMethod("setscreenshotosd", "Sets the screenshot Capture OSD property of the client")]
public static void SetScreenshotOSD(bool value) public static void SetScreenshotOSD(bool value)
{ {
Global.Config.ScreenshotCaptureOsd = value; GlobalWin.Config.ScreenshotCaptureOsd = value;
} }
[LuaMethodExample("local incliscr = client.screenwidth( );")] [LuaMethodExample("local incliscr = client.screenwidth( );")]
@ -324,7 +324,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10) if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10)
{ {
Global.Config.TargetZoomFactors[Emulator.SystemId] = size; GlobalWin.Config.TargetZoomFactors[Emulator.SystemId] = size;
MainForm.FrameBufferResized(); MainForm.FrameBufferResized();
MainForm.AddOnScreenMessage($"Window size set to {size}x"); MainForm.AddOnScreenMessage($"Window size set to {size}x");
} }
@ -352,7 +352,7 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod("getconfig", "gets the current config settings object")] [LuaMethod("getconfig", "gets the current config settings object")]
public object GetConfig() public object GetConfig()
{ {
return Global.Config; return GlobalWin.Config;
} }
[LuaMethodExample("client.togglepause( );")] [LuaMethodExample("client.togglepause( );")]
@ -431,7 +431,7 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod("displaymessages", "sets whether or not on screen messages will display")] [LuaMethod("displaymessages", "sets whether or not on screen messages will display")]
public void DisplayMessages(bool value) public void DisplayMessages(bool value)
{ {
Global.Config.DisplayMessages = value; GlobalWin.Config.DisplayMessages = value;
} }
[LuaMethodExample("client.saveram( );")] [LuaMethodExample("client.saveram( );")]

View File

@ -194,7 +194,7 @@ namespace BizHawk.Client.EmuHawk
if (movie.InputLogLength >= _emulator.Frame) if (movie.InputLogLength >= _emulator.Frame)
{ {
movie.SwitchToPlay(); movie.SwitchToPlay();
Global.Config.Movies.MovieEndAction = MovieEndAction.Record; GlobalWin.Config.Movies.MovieEndAction = MovieEndAction.Record;
} }
} }

View File

@ -185,7 +185,7 @@ namespace BizHawk.Client.EmuHawk
using var sfd = new SaveFileDialog using var sfd = new SaveFileDialog
{ {
FileName = $"{Global.Game.FilesystemSafeName()}-Nametables", FileName = $"{Global.Game.FilesystemSafeName()}-Nametables",
InitialDirectory = Global.Config.PathEntries.ScreenshotAbsolutePathFor("NES"), InitialDirectory = GlobalWin.Config.PathEntries.ScreenshotAbsolutePathFor("NES"),
Filter = FilesystemFilterSet.Screenshots.ToString(), Filter = FilesystemFilterSet.Screenshots.ToString(),
RestoreDirectory = true RestoreDirectory = true
}; };

View File

@ -502,7 +502,7 @@ namespace BizHawk.Client.EmuHawk
public void NonExistentBranchMessage(int slot) public void NonExistentBranchMessage(int slot)
{ {
string binding = Global.Config.HotkeyBindings.First(x => x.DisplayName == "Add Branch").Bindings; string binding = GlobalWin.Config.HotkeyBindings.First(x => x.DisplayName == "Add Branch").Bindings;
Tastudio.MainForm.AddOnScreenMessage($"Branch {slot} does not exist"); Tastudio.MainForm.AddOnScreenMessage($"Branch {slot} does not exist");
Tastudio.MainForm.AddOnScreenMessage($"Use {binding} to add branches"); Tastudio.MainForm.AddOnScreenMessage($"Use {binding} to add branches");
} }

View File

@ -29,7 +29,7 @@ namespace BizHawk.Client.EmuHawk
_movie.Author = AuthorTextBox.Text; _movie.Author = AuthorTextBox.Text;
if (MakeDefaultCheckbox.Checked) if (MakeDefaultCheckbox.Checked)
{ {
Global.Config.DefaultAuthor = AuthorTextBox.Text; GlobalWin.Config.DefaultAuthor = AuthorTextBox.Text;
} }
_movie.EmulatorVersion = EmulatorVersionTextBox.Text; _movie.EmulatorVersion = EmulatorVersionTextBox.Text;
@ -49,7 +49,7 @@ namespace BizHawk.Client.EmuHawk
private void DefaultAuthorButton_Click(object sender, EventArgs e) private void DefaultAuthorButton_Click(object sender, EventArgs e)
{ {
AuthorTextBox.Text = Global.Config.DefaultAuthor; AuthorTextBox.Text = GlobalWin.Config.DefaultAuthor;
} }
} }
} }