Game Game.IsNullInstance a null-safe extension method, and a few other cleanups
This commit is contained in:
parent
6ae1eac464
commit
8802d75527
|
@ -293,7 +293,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void DrawScreenInfo(IBlitter g)
|
public void DrawScreenInfo(IBlitter g)
|
||||||
{
|
{
|
||||||
if (Global.Config.DisplayFrameCounter && !Global.Game.IsNullInstance)
|
if (Global.Config.DisplayFrameCounter && !Global.Game.IsNullInstance())
|
||||||
{
|
{
|
||||||
string message = MakeFrameCounter();
|
string message = MakeFrameCounter();
|
||||||
float x = GetX(g, Global.Config.DispFrameCx, Global.Config.DispFrameanchor, message);
|
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)
|
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
|
|| (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
|
||||||
|
|
|
@ -18,7 +18,6 @@ using BizHawk.Bizware.BizwareGL;
|
||||||
|
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||||
using BizHawk.Emulation.Cores.Calculators;
|
|
||||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
|
using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
|
||||||
using BizHawk.Emulation.Cores.Nintendo.GBA;
|
using BizHawk.Emulation.Cores.Nintendo.GBA;
|
||||||
using BizHawk.Emulation.Cores.Nintendo.NES;
|
using BizHawk.Emulation.Cores.Nintendo.NES;
|
||||||
|
@ -245,8 +244,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
string xmlPath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.xml");
|
string xmlPath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.xml");
|
||||||
string x7zPath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.7z");
|
string x7zPath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.7z");
|
||||||
bool loadXml = File.Exists(xmlPath);
|
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();
|
nesCartFile.BindFirst();
|
||||||
|
@ -255,7 +253,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return nesCartFile
|
return nesCartFile
|
||||||
.GetStream()
|
.GetStream()
|
||||||
.ReadAllBytes();
|
.ReadAllBytes();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -413,7 +410,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
// If user picked a game, then do the commandline logic
|
// If user picked a game, then do the commandline logic
|
||||||
if (!Global.Game.IsNullInstance)
|
if (!Global.Game.IsNullInstance())
|
||||||
{
|
{
|
||||||
var movie = MovieService.Get(_argParser.cmdMovie);
|
var movie = MovieService.Get(_argParser.cmdMovie);
|
||||||
Global.MovieSession.ReadOnly = true;
|
Global.MovieSession.ReadOnly = true;
|
||||||
|
@ -440,13 +437,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else if (Global.Config.RecentMovies.AutoLoad && !Global.Config.RecentMovies.Empty)
|
else if (Global.Config.RecentMovies.AutoLoad && !Global.Config.RecentMovies.Empty)
|
||||||
{
|
{
|
||||||
if (Global.Game.IsNullInstance)
|
if (Global.Game.IsNullInstance())
|
||||||
{
|
{
|
||||||
OpenRom();
|
OpenRom();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If user picked a game, then do the autoload logic
|
// 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))
|
if (File.Exists(Global.Config.RecentMovies.MostRecent))
|
||||||
{
|
{
|
||||||
|
@ -464,7 +461,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_needsFullscreenOnLoad = true;
|
_needsFullscreenOnLoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Global.Game.IsNullInstance)
|
if (!Global.Game.IsNullInstance())
|
||||||
{
|
{
|
||||||
if (_argParser.cmdLoadState != null)
|
if (_argParser.cmdLoadState != null)
|
||||||
{
|
{
|
||||||
|
@ -1786,7 +1783,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private void HandlePlatformMenus()
|
private void HandlePlatformMenus()
|
||||||
{
|
{
|
||||||
var system = "";
|
var system = "";
|
||||||
if (!Global.Game.IsNullInstance)
|
if (!Global.Game.IsNullInstance())
|
||||||
{
|
{
|
||||||
system = Emulator.SystemId;
|
system = Emulator.SystemId;
|
||||||
}
|
}
|
||||||
|
@ -3015,7 +3012,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
bool render = !InvisibleEmulation && (!_throttle.skipNextFrame || (_currAviWriter?.UsesVideo ?? false));
|
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();
|
Global.MovieSession.HandleMovieAfterFrameLoop();
|
||||||
|
|
||||||
|
@ -3054,12 +3051,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
UpdateToolsAfter(SuppressLua);
|
UpdateToolsAfter(SuppressLua);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PauseAvi && new_frame && !InvisibleEmulation)
|
if (!PauseAvi && newFrame && !InvisibleEmulation)
|
||||||
{
|
{
|
||||||
AvFrameAdvance();
|
AvFrameAdvance();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_frame)
|
if (newFrame)
|
||||||
{
|
{
|
||||||
_framesSinceLastFpsUpdate++;
|
_framesSinceLastFpsUpdate++;
|
||||||
|
|
||||||
|
@ -4169,8 +4166,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handled;
|
ClientApi.OnBeforeQuickSave(this, quickSlotName, out var handled);
|
||||||
ClientApi.OnBeforeQuickSave(this, quickSlotName, out handled);
|
|
||||||
if (handled)
|
if (handled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -4244,7 +4240,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var result = sfd.ShowHawkDialog();
|
var result = sfd.ShowHawkDialog();
|
||||||
if (result == DialogResult.OK)
|
if (result == DialogResult.OK)
|
||||||
{
|
{
|
||||||
SaveState(sfd.FileName, sfd.FileName, false);
|
SaveState(sfd.FileName, sfd.FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
AddButton_Click(null, null);
|
AddButton_Click(null, null);
|
||||||
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("|"))
|
if (GlobalWin.MainForm.CurrentlyOpenRom.Contains("|"))
|
||||||
{
|
{
|
||||||
|
@ -240,7 +240,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
string filename = "";
|
string filename = "";
|
||||||
string initialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MultiDiskBundlesFragment, "Global_NULL");
|
string initialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MultiDiskBundlesFragment, "Global_NULL");
|
||||||
|
|
||||||
if (!Global.Game.IsNullInstance)
|
if (!Global.Game.IsNullInstance())
|
||||||
{
|
{
|
||||||
filename = NameBox.Text;
|
filename = NameBox.Text;
|
||||||
if (string.IsNullOrWhiteSpace(filename))
|
if (string.IsNullOrWhiteSpace(filename))
|
||||||
|
|
|
@ -46,8 +46,6 @@ namespace BizHawk.Emulation.Common
|
||||||
NotInDatabase = false
|
NotInDatabase = false
|
||||||
};
|
};
|
||||||
|
|
||||||
public bool IsNullInstance => System == "NULL";
|
|
||||||
|
|
||||||
internal GameInfo(CompactGameInfo cgi)
|
internal GameInfo(CompactGameInfo cgi)
|
||||||
{
|
{
|
||||||
Name = cgi.Name;
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue