Sort out the mess that is creating and updating the global Config
hopefully this kills a few subtle bugs re: `Config` > `Load Config`
This commit is contained in:
parent
3de87af5de
commit
0899369d1a
|
@ -273,13 +273,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
CloseRomContextMenuItem.Image = Properties.Resources.Close;
|
CloseRomContextMenuItem.Image = Properties.Resources.Close;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainForm(string[] args)
|
public MainForm(Config config, string[] args)
|
||||||
{
|
{
|
||||||
//do this threaded stuff early so it has plenty of time to run in background
|
//do this threaded stuff early so it has plenty of time to run in background
|
||||||
Database.InitializeDatabase(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb.txt"));
|
Database.InitializeDatabase(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb.txt"));
|
||||||
BootGodDb.Initialize(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb"));
|
BootGodDb.Initialize(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb"));
|
||||||
|
|
||||||
base.Config = Config;
|
_config = config; // skips assignment to GlobalWin.Config as Program already did that
|
||||||
|
|
||||||
InputManager.ControllerInputCoalescer = new ControllerInputCoalescer();
|
InputManager.ControllerInputCoalescer = new ControllerInputCoalescer();
|
||||||
FirmwareManager = new FirmwareManager();
|
FirmwareManager = new FirmwareManager();
|
||||||
|
@ -850,10 +850,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private ISoundProvider _currentSoundProvider = new NullSound(44100 / 60); // Reasonable default until we have a core instance
|
private ISoundProvider _currentSoundProvider = new NullSound(44100 / 60); // Reasonable default until we have a core instance
|
||||||
|
|
||||||
|
/// <remarks>don't use this, use <see cref="Config"/></remarks>
|
||||||
|
private Config _config;
|
||||||
|
|
||||||
private new Config Config
|
private new Config Config
|
||||||
{
|
{
|
||||||
get => GlobalWin.Config;
|
get => _config;
|
||||||
set => GlobalWin.Config = base.Config = value;
|
set => GlobalWin.Config = base.Config = _config = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly ToolManager Tools;
|
public readonly ToolManager Tools;
|
||||||
|
@ -2784,6 +2787,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Config.ResolveDefaults();
|
Config.ResolveDefaults();
|
||||||
InitControls(); // rebind hotkeys
|
InitControls(); // rebind hotkeys
|
||||||
InputManager.SyncControls(Emulator, MovieSession, Config);
|
InputManager.SyncControls(Emulator, MovieSession, Config);
|
||||||
|
Tools.Restart(Config, Emulator, Game);
|
||||||
AddOnScreenMessage($"Config file loaded: {iniPath}");
|
AddOnScreenMessage($"Config file loaded: {iniPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3742,7 +3746,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tools.Restart(Emulator, Game);
|
Tools.Restart(Config, Emulator, Game);
|
||||||
|
|
||||||
if (Config.Cheats.LoadFileByGame && Emulator.HasMemoryDomains())
|
if (Config.Cheats.LoadFileByGame && Emulator.HasMemoryDomains())
|
||||||
{
|
{
|
||||||
|
@ -3906,7 +3910,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Emulator = new NullEmulator();
|
Emulator = new NullEmulator();
|
||||||
EmuClient.Game = GlobalWin.Game = GameInfo.NullInstance;
|
EmuClient.Game = GlobalWin.Game = GameInfo.NullInstance;
|
||||||
CreateRewinder();
|
CreateRewinder();
|
||||||
Tools.Restart(Emulator, Game);
|
Tools.Restart(Config, Emulator, Game);
|
||||||
RewireSound();
|
RewireSound();
|
||||||
ClearHolds();
|
ClearHolds();
|
||||||
InputManager.SyncControls(Emulator, MovieSession, Config);
|
InputManager.SyncControls(Emulator, MovieSession, Config);
|
||||||
|
|
|
@ -220,7 +220,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var mf = new MainForm(args);
|
var mf = new MainForm(GlobalWin.Config, args);
|
||||||
// var title = mf.Text;
|
// var title = mf.Text;
|
||||||
mf.Show();
|
mf.Show();
|
||||||
// mf.Text = title;
|
// mf.Text = title;
|
||||||
|
@ -346,7 +346,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
protected override void OnCreateMainForm()
|
protected override void OnCreateMainForm()
|
||||||
{
|
{
|
||||||
MainForm = new MainForm(cmdArgs);
|
MainForm = new MainForm(GlobalWin.Config, cmdArgs);
|
||||||
var title = MainForm.Text;
|
var title = MainForm.Text;
|
||||||
MainForm.Show();
|
MainForm.Show();
|
||||||
MainForm.Text = title;
|
MainForm.Text = title;
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public class ToolManager
|
public class ToolManager
|
||||||
{
|
{
|
||||||
private readonly MainForm _owner;
|
private readonly MainForm _owner;
|
||||||
private readonly Config _config;
|
private Config _config;
|
||||||
private readonly DisplayManager _displayManager;
|
private readonly DisplayManager _displayManager;
|
||||||
private readonly InputManager _inputManager;
|
private readonly InputManager _inputManager;
|
||||||
private IExternalApiProvider _apiProvider;
|
private IExternalApiProvider _apiProvider;
|
||||||
|
@ -83,16 +83,17 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// If the form inherits ToolFormBase, it will set base properties such as Tools, Config, etc
|
// If the form inherits ToolFormBase, it will set base properties such as Tools, Config, etc
|
||||||
private void SetBaseProperties(IToolForm form)
|
private void SetBaseProperties(IToolForm form)
|
||||||
{
|
{
|
||||||
if (form is ToolFormBase tool)
|
if (!(form is FormBase f)) return;
|
||||||
{
|
|
||||||
tool.Tools = this;
|
f.Config = _config;
|
||||||
tool.Config = _config;
|
if (!(form is ToolFormBase tool)) return;
|
||||||
tool.DisplayManager = _displayManager;
|
|
||||||
tool.InputManager = _inputManager;
|
tool.Tools = this;
|
||||||
tool.MainForm = _owner;
|
tool.DisplayManager = _displayManager;
|
||||||
tool.MovieSession = _movieSession;
|
tool.InputManager = _inputManager;
|
||||||
tool.Game = _game;
|
tool.MainForm = _owner;
|
||||||
}
|
tool.MovieSession = _movieSession;
|
||||||
|
tool.Game = _game;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -505,8 +506,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart(IEmulator emulator, IGameInfo game)
|
public void Restart(Config config, IEmulator emulator, IGameInfo game)
|
||||||
{
|
{
|
||||||
|
_config = config;
|
||||||
_emulator = emulator;
|
_emulator = emulator;
|
||||||
_game = game;
|
_game = game;
|
||||||
ApiProvider = ApiManager.Restart(_emulator.ServiceProvider, _owner, _displayManager, _inputManager, _movieSession, this, _config, _emulator, _game);
|
ApiProvider = ApiManager.Restart(_emulator.ServiceProvider, _owner, _displayManager, _inputManager, _movieSession, this, _config, _emulator, _game);
|
||||||
|
|
Loading…
Reference in New Issue