diff --git a/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs index b4555283ae..ab7d406c5f 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs @@ -293,7 +293,7 @@ namespace BizHawk.Client.EmuHawk /// public void DrawScreenInfo(IBlitter g) { - if (Global.Config.DisplayFrameCounter && !Global.Game.IsNullInstance) + if (Global.Config.DisplayFrameCounter && !Global.Game.IsNullInstance()) { string message = MakeFrameCounter(); float x = GetX(g, Global.Config.DispFrameCx, Global.Config.DispFrameanchor, message); @@ -307,7 +307,7 @@ namespace BizHawk.Client.EmuHawk } } - if (Global.Config.DisplayInput && !Global.Game.IsNullInstance) + if (Global.Config.DisplayInput && !Global.Game.IsNullInstance()) { if ((Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished) || (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 diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index f6af9b3e60..a11fde2494 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -18,7 +18,6 @@ using BizHawk.Bizware.BizwareGL; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; -using BizHawk.Emulation.Cores.Calculators; using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES; using BizHawk.Emulation.Cores.Nintendo.GBA; using BizHawk.Emulation.Cores.Nintendo.NES; @@ -245,17 +244,15 @@ namespace BizHawk.Client.EmuHawk string xmlPath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.xml"); string x7zPath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.7z"); bool loadXml = File.Exists(xmlPath); - using (var nesCartFile = new HawkFile(loadXml ? xmlPath : x7zPath)) + using var nesCartFile = new HawkFile(loadXml ? xmlPath : x7zPath); + if (!loadXml) { - if (!loadXml) - { - nesCartFile.BindFirst(); - } - - return nesCartFile - .GetStream() - .ReadAllBytes(); + nesCartFile.BindFirst(); } + + return nesCartFile + .GetStream() + .ReadAllBytes(); }; try { @@ -413,7 +410,7 @@ namespace BizHawk.Client.EmuHawk } // If user picked a game, then do the commandline logic - if (!Global.Game.IsNullInstance) + if (!Global.Game.IsNullInstance()) { var movie = MovieService.Get(_argParser.cmdMovie); Global.MovieSession.ReadOnly = true; @@ -440,13 +437,13 @@ namespace BizHawk.Client.EmuHawk } else if (Global.Config.RecentMovies.AutoLoad && !Global.Config.RecentMovies.Empty) { - if (Global.Game.IsNullInstance) + if (Global.Game.IsNullInstance()) { OpenRom(); } // If user picked a game, then do the autoload logic - if (!Global.Game.IsNullInstance) + if (!Global.Game.IsNullInstance()) { if (File.Exists(Global.Config.RecentMovies.MostRecent)) { @@ -464,7 +461,7 @@ namespace BizHawk.Client.EmuHawk _needsFullscreenOnLoad = true; } - if (!Global.Game.IsNullInstance) + if (!Global.Game.IsNullInstance()) { if (_argParser.cmdLoadState != null) { @@ -1786,7 +1783,7 @@ namespace BizHawk.Client.EmuHawk private void HandlePlatformMenus() { var system = ""; - if (!Global.Game.IsNullInstance) + if (!Global.Game.IsNullInstance()) { system = Emulator.SystemId; } @@ -3015,7 +3012,7 @@ namespace BizHawk.Client.EmuHawk } bool render = !InvisibleEmulation && (!_throttle.skipNextFrame || (_currAviWriter?.UsesVideo ?? false)); - bool new_frame = Emulator.FrameAdvance(Global.ControllerOutput, render, renderSound); + bool newFrame = Emulator.FrameAdvance(Global.ControllerOutput, render, renderSound); Global.MovieSession.HandleMovieAfterFrameLoop(); @@ -3054,12 +3051,12 @@ namespace BizHawk.Client.EmuHawk UpdateToolsAfter(SuppressLua); } - if (!PauseAvi && new_frame && !InvisibleEmulation) + if (!PauseAvi && newFrame && !InvisibleEmulation) { AvFrameAdvance(); } - if (new_frame) + if (newFrame) { _framesSinceLastFpsUpdate++; @@ -4169,8 +4166,7 @@ namespace BizHawk.Client.EmuHawk return; } - bool handled; - ClientApi.OnBeforeQuickSave(this, quickSlotName, out handled); + ClientApi.OnBeforeQuickSave(this, quickSlotName, out var handled); if (handled) { return; @@ -4244,7 +4240,7 @@ namespace BizHawk.Client.EmuHawk var result = sfd.ShowHawkDialog(); if (result == DialogResult.OK) { - SaveState(sfd.FileName, sfd.FileName, false); + SaveState(sfd.FileName, sfd.FileName); } if (GlobalWin.Tools.IsLoaded()) diff --git a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs index 7f8887e6bc..57329728f3 100644 --- a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs +++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs @@ -31,7 +31,7 @@ namespace BizHawk.Client.EmuHawk AddButton_Click(null, null); AddButton_Click(null, null); - if (!Global.Game.IsNullInstance && !GlobalWin.MainForm.CurrentlyOpenRom.EndsWith(".xml")) + if (!Global.Game.IsNullInstance() && !GlobalWin.MainForm.CurrentlyOpenRom.EndsWith(".xml")) { if (GlobalWin.MainForm.CurrentlyOpenRom.Contains("|")) { @@ -240,7 +240,7 @@ namespace BizHawk.Client.EmuHawk string filename = ""; string initialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MultiDiskBundlesFragment, "Global_NULL"); - if (!Global.Game.IsNullInstance) + if (!Global.Game.IsNullInstance()) { filename = NameBox.Text; if (string.IsNullOrWhiteSpace(filename)) diff --git a/BizHawk.Emulation.Common/Database/GameInfo.cs b/BizHawk.Emulation.Common/Database/GameInfo.cs index ca6fab1b24..59e2338c1e 100644 --- a/BizHawk.Emulation.Common/Database/GameInfo.cs +++ b/BizHawk.Emulation.Common/Database/GameInfo.cs @@ -46,8 +46,6 @@ namespace BizHawk.Emulation.Common NotInDatabase = false }; - public bool IsNullInstance => System == "NULL"; - internal GameInfo(CompactGameInfo cgi) { Name = cgi.Name; @@ -179,4 +177,12 @@ namespace BizHawk.Emulation.Common } } } + + public static class GameInfoExtensions + { + public static bool IsNullInstance(this GameInfo game) + { + return game == null || game.System == "NULL"; + } + } }