Make Global fields into properties, a bit of cleanup

This commit is contained in:
adelikat 2020-03-15 17:08:34 -05:00
parent 80c36d8155
commit 67926a2de4
2 changed files with 24 additions and 27 deletions

View File

@ -6,28 +6,28 @@ namespace BizHawk.Client.Common
{
public static class Global
{
public static IEmulator Emulator;
public static Config Config;
public static GameInfo Game;
public static CheatCollection CheatList;
public static FirmwareManager FirmwareManager;
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();
public static FirmwareManager FirmwareManager { get; set; }
public static IMovieSession MovieSession = new MovieSession();
public static IMovieSession MovieSession { get; set; } = new MovieSession();
/// <summary>
/// Used to disable secondary throttling (e.g. vsync, audio) for unthrottled modes or when the primary (clock) throttle is taking over (e.g. during fast forward/rewind).
/// </summary>
public static bool DisableSecondaryThrottling;
public static bool DisableSecondaryThrottling { get; set; }
/// <summary>
/// The maximum number of milliseconds the sound output buffer can go below full before causing a noticeable sound interruption.
/// </summary>
public static int SoundMaxBufferDeficitMs;
public static int SoundMaxBufferDeficitMs { get; set; }
// the movie will be spliced in between these if it is present
public static readonly CopyControllerAdapter MovieInputSourceAdapter = new CopyControllerAdapter();
public static readonly CopyControllerAdapter MovieOutputHardpoint = new CopyControllerAdapter();
public static readonly MultitrackRewiringControllerAdapter MultitrackRewiringAdapter = new MultitrackRewiringControllerAdapter();
public static CopyControllerAdapter MovieInputSourceAdapter { get; } = new CopyControllerAdapter();
public static CopyControllerAdapter MovieOutputHardpoint { get; } = new CopyControllerAdapter();
public static MultitrackRewiringControllerAdapter MultitrackRewiringAdapter { get; } = new MultitrackRewiringControllerAdapter();
// don't take my word for it, since the final word is actually in RewireInputChain, but here is a guide...
// user -> Input -> ActiveController -> UDLR -> StickyXORPlayerInputAdapter -> TurboAdapter(TBD) -> Lua(?TBD?) -> ..
@ -35,39 +35,39 @@ namespace BizHawk.Client.Common
// (1)->Input Display
// the original source controller, bound to the user, sort of the "input" port for the chain, i think
public static Controller ActiveController;
public static Controller ActiveController { get; set; }
// rapid fire version on the user controller, has its own key bindings and is OR'ed against ActiveController
public static AutofireController AutoFireController;
public static AutofireController AutoFireController { get; set; }
// the "output" port for the controller chain.
public static readonly CopyControllerAdapter ControllerOutput = new CopyControllerAdapter();
public static CopyControllerAdapter ControllerOutput { get; } = new CopyControllerAdapter();
public static readonly UdlrControllerAdapter UD_LR_ControllerAdapter = new UdlrControllerAdapter();
public static UdlrControllerAdapter UD_LR_ControllerAdapter { get; } = new UdlrControllerAdapter();
public static readonly AutoFireStickyXorAdapter AutofireStickyXORAdapter = new AutoFireStickyXorAdapter();
public static AutoFireStickyXorAdapter AutofireStickyXORAdapter { get; } = new AutoFireStickyXorAdapter();
/// <summary>
/// provides an opportunity to mutate the player's input in an autohold style
/// </summary>
public static readonly StickyXorAdapter StickyXORAdapter = new StickyXorAdapter();
public static StickyXorAdapter StickyXORAdapter { get; } = new StickyXorAdapter();
/// <summary>
/// Used to AND to another controller, used for <see cref="JoypadApi.Set(System.Collections.Generic.Dictionary{string,bool},System.Nullable{int})">JoypadApi.Set</see>
/// Used to AND to another controller, used for <see cref="JoypadApi.Set(Dictionary{string, bool}, int?)">JoypadApi.Set</see>
/// </summary>
public static readonly OverrideAdapter ButtonOverrideAdaptor = new OverrideAdapter();
public static OverrideAdapter ButtonOverrideAdaptor { get; } = new OverrideAdapter();
/// <summary>
/// fire off one-frame logical button clicks here. useful for things like ti-83 virtual pad and reset buttons
/// </summary>
public static readonly ClickyVirtualPadController ClickyVirtualPadController = new ClickyVirtualPadController();
public static ClickyVirtualPadController ClickyVirtualPadController { get; } = new ClickyVirtualPadController();
public static Controller ClientControls;
public static Controller ClientControls { get; set; }
// Input state which has been estine for game controller inputs are coalesce here
// Input state for game controller inputs are coalesced here
// This relies on a client specific implementation!
public static SimpleController ControllerInputCoalescer;
public static SimpleController ControllerInputCoalescer { get; set; }
public static Dictionary<string, object> UserBag = new Dictionary<string, object>();
public static Dictionary<string, object> UserBag { get; set; } = new Dictionary<string, object>();
}
}

View File

@ -228,7 +228,6 @@ namespace BizHawk.Client.EmuHawk
Emulator = new NullEmulator();
GlobalWin.Tools = new ToolManager(this, Config, Emulator);
Global.CheatList = new CheatCollection();
CheatList.Changed += Tools.UpdateCheatRelatedTools;
UpdateStatusSlots();
@ -841,8 +840,6 @@ namespace BizHawk.Client.EmuHawk
set => Global.Game = value;
}
private GLManager GLManager => GlobalWin.GLManager;
private Sound Sound => GlobalWin.Sound;
private CheatCollection CheatList => Global.CheatList;
private AutofireController AutoFireController => Global.AutoFireController;