move Global.Game to GlobaWin.Game
This commit is contained in:
parent
886c687817
commit
ff61fc3c71
|
@ -1,11 +1,7 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
|
||||
// ReSharper disable StyleCop.SA1401
|
||||
namespace BizHawk.Client.Common
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public static class Global
|
||||
{
|
||||
public static GameInfo Game { get; set; }
|
||||
public static IMovieSession MovieSession { get; set; }
|
||||
public static InputManager InputManager { get; } = new InputManager();
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var ofd = new OpenFileDialog
|
||||
{
|
||||
FileName = $"{Global.Game.FilesystemSafeName()}.syncless.txt",
|
||||
FileName = $"{GlobalWin.Game.FilesystemSafeName()}.syncless.txt",
|
||||
InitialDirectory = GlobalWin.Config.PathEntries.AvAbsolutePath()
|
||||
};
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// Load a savestate specified by its name
|
||||
/// </summary>
|
||||
/// <param name="name">Savestate friendly name</param>
|
||||
public static void LoadState(string name) => GlobalWin.MainForm.LoadState(Path.Combine(GlobalWin.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(GlobalWin.Game.System), $"{name}.State"), name, suppressOSD: false);
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
/// <param name="name">Savestate friendly name</param>
|
||||
public static void SaveState(string name) => GlobalWin.MainForm.SaveState(Path.Combine(GlobalWin.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(GlobalWin.Game.System), $"{name}.State"), name, fromLua: false);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return default;
|
||||
}
|
||||
|
||||
public string GetSystemId() => Global.Game.System;
|
||||
public string GetSystemId() => GlobalWin.Game.System;
|
||||
|
||||
public bool IsLagged()
|
||||
{
|
||||
|
|
|
@ -9,23 +9,23 @@ namespace BizHawk.Client.EmuHawk
|
|||
[OptionalService]
|
||||
private IBoardInfo BoardInfo { get; set; }
|
||||
|
||||
public string GetRomName() => Global.Game?.Name ?? "";
|
||||
public string GetRomName() => GlobalWin.Game?.Name ?? "";
|
||||
|
||||
public string GetRomHash() => Global.Game?.Hash ?? "";
|
||||
public string GetRomHash() => GlobalWin.Game?.Hash ?? "";
|
||||
|
||||
public bool InDatabase() => Global.Game?.NotInDatabase == false;
|
||||
public bool InDatabase() => GlobalWin.Game?.NotInDatabase == false;
|
||||
|
||||
public string GetStatus() => Global.Game?.Status.ToString();
|
||||
public string GetStatus() => GlobalWin.Game?.Status.ToString();
|
||||
|
||||
public bool IsStatusBad() => Global.Game?.IsRomStatusBad() != false;
|
||||
public bool IsStatusBad() => GlobalWin.Game?.IsRomStatusBad() != false;
|
||||
|
||||
public string GetBoardType() => BoardInfo?.BoardName ?? "";
|
||||
|
||||
public Dictionary<string, string> GetOptions()
|
||||
{
|
||||
var options = new Dictionary<string, string>();
|
||||
if (Global.Game == null) return options;
|
||||
foreach (var option in Global.Game.GetOptionsDict()) options[option.Key] = option.Value;
|
||||
if (GlobalWin.Game == null) return options;
|
||||
foreach (var option in GlobalWin.Game.GetOptionsDict()) options[option.Key] = option.Value;
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// </summary>
|
||||
public void DrawScreenInfo(IBlitter g)
|
||||
{
|
||||
if (GlobalWin.Config.DisplayFrameCounter && !Global.Game.IsNullInstance())
|
||||
if (GlobalWin.Config.DisplayFrameCounter && !GlobalWin.Game.IsNullInstance())
|
||||
{
|
||||
string message = MakeFrameCounter();
|
||||
var point = GetCoordinates(g, GlobalWin.Config.FrameCounter, message);
|
||||
|
@ -270,7 +270,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
if (GlobalWin.Config.DisplayInput && !Global.Game.IsNullInstance())
|
||||
if (GlobalWin.Config.DisplayInput && !GlobalWin.Game.IsNullInstance())
|
||||
{
|
||||
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
|
||||
|
|
|
@ -44,5 +44,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public static Config Config { get; set; }
|
||||
public static FirmwareManager FirmwareManager { get; set; }
|
||||
public static GameInfo Game { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void HideShowGameDbButton()
|
||||
{
|
||||
AddToGameDbBtn.Visible = Emulator.CanGenerateGameDBEntries()
|
||||
&& (Global.Game.Status == RomStatus.Unknown || Global.Game.Status == RomStatus.NotInDatabase);
|
||||
&& (GlobalWin.Game.Status == RomStatus.Unknown || GlobalWin.Game.Status == RomStatus.NotInDatabase);
|
||||
}
|
||||
|
||||
private void AddToGameDbBtn_Click(object sender, EventArgs e)
|
||||
|
@ -148,7 +148,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var gameDbEntry = Emulator.AsGameDBEntryGenerator().GenerateGameDbEntry();
|
||||
var userDb = Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb_user.txt");
|
||||
Global.Game.Status = gameDbEntry.Status = picker.PickedStatus;
|
||||
GlobalWin.Game.Status = gameDbEntry.Status = picker.PickedStatus;
|
||||
Database.SaveDatabaseEntry(userDb, gameDbEntry);
|
||||
MainForm.UpdateDumpIcon();
|
||||
HideShowGameDbButton();
|
||||
|
|
|
@ -890,8 +890,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private GameInfo Game
|
||||
{
|
||||
get => Global.Game;
|
||||
set => Global.Game = value;
|
||||
get => GlobalWin.Game;
|
||||
set => GlobalWin.Game = value;
|
||||
}
|
||||
|
||||
private Sound Sound => GlobalWin.Sound;
|
||||
|
@ -3679,10 +3679,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
//path = ioa_openrom.Path;
|
||||
}
|
||||
|
||||
var oldGame = Global.Game;
|
||||
var oldGame = GlobalWin.Game;
|
||||
var result = loader.LoadRom(path, nextComm, ioaRetro?.CorePath);
|
||||
|
||||
Global.Game = result ? loader.Game : oldGame;
|
||||
GlobalWin.Game = result ? loader.Game : oldGame;
|
||||
|
||||
// we need to replace the path in the OpenAdvanced with the canonical one the user chose.
|
||||
// It can't be done until loader.LoadRom happens (for CanonicalFullPath)
|
||||
|
@ -3967,7 +3967,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
CloseGame(clearSram);
|
||||
Emulator = new NullEmulator();
|
||||
Global.Game = GameInfo.NullInstance;
|
||||
GlobalWin.Game = GameInfo.NullInstance;
|
||||
|
||||
Tools.Restart(Emulator);
|
||||
RewireSound();
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
try
|
||||
{
|
||||
var coreComm = _mainForm.CreateCoreComm();
|
||||
using var retro = new LibretroCore(coreComm, Global.Game, core);
|
||||
using var retro = new LibretroCore(coreComm, GlobalWin.Game, core);
|
||||
btnLibretroLaunchGame.Enabled = true;
|
||||
if (retro.Description.SupportsNoGame)
|
||||
btnLibretroLaunchNoGame.Enabled = true;
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
FileName = $"{Global.Game.FilesystemSafeName()}-Palettes",
|
||||
FileName = $"{GlobalWin.Game.FilesystemSafeName()}-Palettes",
|
||||
InitialDirectory = path,
|
||||
Filter = FilesystemFilterSet.Screenshots.ToString(),
|
||||
RestoreDirectory = true
|
||||
|
|
|
@ -345,7 +345,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
InitialDirectory = GlobalWin.Config.PathEntries.PalettesAbsolutePathFor("GB"),
|
||||
FileName = $"{Global.Game.Name}.pal",
|
||||
FileName = $"{GlobalWin.Game.Name}.pal",
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(),
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SetDefaultFocusedTab()
|
||||
{
|
||||
var tab = FindTabByName(Global.Game.System);
|
||||
var tab = FindTabByName(GlobalWin.Game.System);
|
||||
if (tab != null)
|
||||
{
|
||||
PathTabControl.SelectTab(tab);
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
movieToRecord.PopulateWithDefaultHeaderValues(
|
||||
_emulator,
|
||||
Global.Game,
|
||||
GlobalWin.Game,
|
||||
GlobalWin.FirmwareManager,
|
||||
AuthorBox.Text ?? _config.DefaultAuthor);
|
||||
movieToRecord.Save();
|
||||
|
|
|
@ -481,7 +481,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
try
|
||||
{
|
||||
_autoloading = true;
|
||||
var autoResumeFile = $"{Global.Game.FilesystemSafeName()}.cdl";
|
||||
var autoResumeFile = $"{GlobalWin.Game.FilesystemSafeName()}.cdl";
|
||||
var autoResumeDir = Config.PathEntries.LogAbsolutePath();
|
||||
var autoResumePath = Path.Combine(autoResumeDir, autoResumeFile);
|
||||
if (File.Exists(autoResumePath))
|
||||
|
|
|
@ -118,7 +118,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var file = SaveFileDialog(
|
||||
MainForm.CheatList.CurrentFileName,
|
||||
Config.PathEntries.CheatsAbsolutePath(Global.Game.System),
|
||||
Config.PathEntries.CheatsAbsolutePath(GlobalWin.Game.System),
|
||||
"Cheat Files",
|
||||
"cht");
|
||||
|
||||
|
@ -350,7 +350,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var file = OpenFileDialog(
|
||||
MainForm.CheatList.CurrentFileName,
|
||||
Config.PathEntries.CheatsAbsolutePath(Global.Game.System),
|
||||
Config.PathEntries.CheatsAbsolutePath(GlobalWin.Game.System),
|
||||
"Cheat Files",
|
||||
"cht");
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
: "This tool doesn't work with this system";
|
||||
return item;
|
||||
}
|
||||
if (applicabilityAttrs[0].NotApplicableTo(Global.Game.Hash, system))
|
||||
if (applicabilityAttrs[0].NotApplicableTo(GlobalWin.Game.Hash, system))
|
||||
{
|
||||
item.ToolTipText = "This tool doesn't work with this game";
|
||||
return item;
|
||||
|
|
|
@ -912,7 +912,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
, FileName =
|
||||
_domain.Name == "File on Disk"
|
||||
? RomName
|
||||
: Global.Game.FilesystemSafeName()
|
||||
: GlobalWin.Game.FilesystemSafeName()
|
||||
};
|
||||
|
||||
var result = sfd.ShowHawkDialog();
|
||||
|
@ -925,7 +925,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
FileName = _domain.Name == "File on Disk"
|
||||
? $"{Path.GetFileNameWithoutExtension(RomName)}.txt"
|
||||
: Global.Game.FilesystemSafeName(),
|
||||
: GlobalWin.Game.FilesystemSafeName(),
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.TextFiles).ToString(),
|
||||
InitialDirectory = RomDirectory,
|
||||
RestoreDirectory = true
|
||||
|
|
|
@ -635,9 +635,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
sfd.FileName = Path.GetFileNameWithoutExtension(LuaImp.ScriptList.Filename);
|
||||
sfd.InitialDirectory = Path.GetDirectoryName(LuaImp.ScriptList.Filename);
|
||||
}
|
||||
else if (Global.Game != null)
|
||||
else if (GlobalWin.Game != null)
|
||||
{
|
||||
sfd.FileName = Global.Game.FilesystemSafeName();
|
||||
sfd.FileName = GlobalWin.Game.FilesystemSafeName();
|
||||
sfd.InitialDirectory = Config.PathEntries.LuaAbsolutePath();
|
||||
}
|
||||
else
|
||||
|
@ -834,7 +834,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DefaultExt = ".lua",
|
||||
FileName = !string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename)
|
||||
? Path.GetFileNameWithoutExtension(LuaImp.ScriptList.Filename)
|
||||
: Path.GetFileNameWithoutExtension(Global.Game.Name),
|
||||
: Path.GetFileNameWithoutExtension(GlobalWin.Game.Name),
|
||||
OverwritePrompt = true,
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.LuaScripts).ToString()
|
||||
};
|
||||
|
|
|
@ -260,7 +260,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return Config.PathEntries.AbsolutePathFor(Path.Combine(
|
||||
Config.PathEntries["Global", "Macros"].Path,
|
||||
Global.Game.FilesystemSafeName()), null);
|
||||
GlobalWin.Game.FilesystemSafeName()), null);
|
||||
}
|
||||
|
||||
public bool SaveMacroAs(MovieZone macro)
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
AddButton_Click(null, null);
|
||||
AddButton_Click(null, null);
|
||||
|
||||
if (!Global.Game.IsNullInstance() && !MainForm.CurrentlyOpenRom.EndsWith(".xml"))
|
||||
if (!GlobalWin.Game.IsNullInstance() && !MainForm.CurrentlyOpenRom.EndsWith(".xml"))
|
||||
{
|
||||
if (MainForm.CurrentlyOpenRom.Contains("|"))
|
||||
{
|
||||
|
@ -215,12 +215,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
string filename = "";
|
||||
string initialDirectory = Config.PathEntries.MultiDiskAbsolutePath();
|
||||
|
||||
if (!Global.Game.IsNullInstance())
|
||||
if (!GlobalWin.Game.IsNullInstance())
|
||||
{
|
||||
filename = NameBox.Text;
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
{
|
||||
filename = Path.ChangeExtension(Global.Game.FilesystemSafeName(), ".xml");
|
||||
filename = Path.ChangeExtension(GlobalWin.Game.FilesystemSafeName(), ".xml");
|
||||
}
|
||||
|
||||
initialDirectory = Path.GetDirectoryName(filename);
|
||||
|
|
|
@ -184,7 +184,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
FileName = $"{Global.Game.FilesystemSafeName()}-Nametables",
|
||||
FileName = $"{GlobalWin.Game.FilesystemSafeName()}-Nametables",
|
||||
InitialDirectory = GlobalWin.Config.PathEntries.ScreenshotAbsolutePathFor("NES"),
|
||||
Filter = FilesystemFilterSet.Screenshots.ToString(),
|
||||
RestoreDirectory = true
|
||||
|
|
|
@ -314,7 +314,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var sfd = new SaveFileDialog
|
||||
{
|
||||
FileName = $"{Global.Game.FilesystemSafeName()}-{suffix}",
|
||||
FileName = $"{GlobalWin.Game.FilesystemSafeName()}-{suffix}",
|
||||
InitialDirectory = Config.PathEntries.ScreenshotAbsolutePathFor("NES"),
|
||||
Filter = FilesystemFilterSet.Screenshots.ToString(),
|
||||
RestoreDirectory = true
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (CurrentTasMovie != null)
|
||||
{
|
||||
if (Global.Game.Hash != CurrentTasMovie.Hash)
|
||||
if (GlobalWin.Game.Hash != CurrentTasMovie.Hash)
|
||||
{
|
||||
TastudioStopMovie();
|
||||
TasView.AllColumns.Clear();
|
||||
|
|
|
@ -686,7 +686,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
tasMovie.PopulateWithDefaultHeaderValues(
|
||||
Emulator,
|
||||
Global.Game,
|
||||
GlobalWin.Game,
|
||||
GlobalWin.FirmwareManager,
|
||||
Config.DefaultAuthor);
|
||||
|
||||
|
@ -813,7 +813,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return Path.Combine(
|
||||
Config.PathEntries.MovieAbsolutePath(),
|
||||
$"{Global.Game.FilesystemSafeName()}.{MovieService.TasMovieExtension}");
|
||||
$"{GlobalWin.Game.FilesystemSafeName()}.{MovieService.TasMovieExtension}");
|
||||
}
|
||||
|
||||
private void SaveTas()
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
FileName = !string.IsNullOrWhiteSpace(currentFile)
|
||||
? Path.GetFileName(currentFile)
|
||||
: $"{Global.Game.FilesystemSafeName()}.{fileExt}",
|
||||
: $"{GlobalWin.Game.FilesystemSafeName()}.{fileExt}",
|
||||
InitialDirectory = path,
|
||||
Filter = new FilesystemFilterSet(new FilesystemFilter(fileType, new[] { fileExt })).ToString(),
|
||||
RestoreDirectory = true
|
||||
|
@ -83,7 +83,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
FileName = !string.IsNullOrWhiteSpace(currentFile)
|
||||
? Path.GetFileName(currentFile)
|
||||
: $"{Global.Game.FilesystemSafeName()}.{fileExt}",
|
||||
: $"{GlobalWin.Game.FilesystemSafeName()}.{fileExt}",
|
||||
InitialDirectory = path,
|
||||
Filter = new FilesystemFilterSet(new FilesystemFilter(fileType, new[] { fileExt })).ToString(),
|
||||
RestoreDirectory = true
|
||||
|
|
|
@ -774,7 +774,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public string GenerateDefaultCheatFilename()
|
||||
{
|
||||
var path = _config.PathEntries.CheatsAbsolutePath(Global.Game.System);
|
||||
var path = _config.PathEntries.CheatsAbsolutePath(GlobalWin.Game.System);
|
||||
|
||||
var f = new FileInfo(path);
|
||||
if (f.Directory != null && f.Directory.Exists == false)
|
||||
|
@ -782,7 +782,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
f.Directory.Create();
|
||||
}
|
||||
|
||||
return Path.Combine(path, $"{Global.Game.FilesystemSafeName()}.cht");
|
||||
return Path.Combine(path, $"{GlobalWin.Game.FilesystemSafeName()}.cht");
|
||||
}
|
||||
|
||||
public void UpdateCheatRelatedTools(object sender, CheatCollection.CheatListEventArgs e)
|
||||
|
|
|
@ -274,12 +274,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
using var sfd = new SaveFileDialog();
|
||||
if (LogFile == null)
|
||||
{
|
||||
sfd.FileName = Global.Game.FilesystemSafeName() + _extension;
|
||||
sfd.FileName = GlobalWin.Game.FilesystemSafeName() + _extension;
|
||||
sfd.InitialDirectory = Config.PathEntries.LogAbsolutePath();
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(LogFile.FullName))
|
||||
{
|
||||
sfd.FileName = Global.Game.FilesystemSafeName();
|
||||
sfd.FileName = GlobalWin.Game.FilesystemSafeName();
|
||||
sfd.InitialDirectory = Path.GetDirectoryName(LogFile.FullName);
|
||||
}
|
||||
else
|
||||
|
@ -439,7 +439,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
FileBox.Visible = true;
|
||||
BrowseBox.Visible = true;
|
||||
var name = Global.Game.FilesystemSafeName();
|
||||
var name = GlobalWin.Game.FilesystemSafeName();
|
||||
var filename = Path.Combine(Config.PathEntries.LogAbsolutePath(), name) + _extension;
|
||||
LogFile = new FileInfo(filename);
|
||||
if (LogFile.Directory != null && !LogFile.Directory.Exists)
|
||||
|
|
Loading…
Reference in New Issue