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;
|
||||
}
|
||||
|
||||
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
|
||||
Database.InitializeDatabase(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb.txt"));
|
||||
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();
|
||||
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
|
||||
|
||||
/// <remarks>don't use this, use <see cref="Config"/></remarks>
|
||||
private Config _config;
|
||||
|
||||
private new Config Config
|
||||
{
|
||||
get => GlobalWin.Config;
|
||||
set => GlobalWin.Config = base.Config = value;
|
||||
get => _config;
|
||||
set => GlobalWin.Config = base.Config = _config = value;
|
||||
}
|
||||
|
||||
public readonly ToolManager Tools;
|
||||
|
@ -2784,6 +2787,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Config.ResolveDefaults();
|
||||
InitControls(); // rebind hotkeys
|
||||
InputManager.SyncControls(Emulator, MovieSession, Config);
|
||||
Tools.Restart(Config, Emulator, Game);
|
||||
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())
|
||||
{
|
||||
|
@ -3906,7 +3910,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Emulator = new NullEmulator();
|
||||
EmuClient.Game = GlobalWin.Game = GameInfo.NullInstance;
|
||||
CreateRewinder();
|
||||
Tools.Restart(Emulator, Game);
|
||||
Tools.Restart(Config, Emulator, Game);
|
||||
RewireSound();
|
||||
ClearHolds();
|
||||
InputManager.SyncControls(Emulator, MovieSession, Config);
|
||||
|
|
|
@ -220,7 +220,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
var mf = new MainForm(args);
|
||||
var mf = new MainForm(GlobalWin.Config, args);
|
||||
// var title = mf.Text;
|
||||
mf.Show();
|
||||
// mf.Text = title;
|
||||
|
@ -346,7 +346,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
protected override void OnCreateMainForm()
|
||||
{
|
||||
MainForm = new MainForm(cmdArgs);
|
||||
MainForm = new MainForm(GlobalWin.Config, cmdArgs);
|
||||
var title = MainForm.Text;
|
||||
MainForm.Show();
|
||||
MainForm.Text = title;
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public class ToolManager
|
||||
{
|
||||
private readonly MainForm _owner;
|
||||
private readonly Config _config;
|
||||
private Config _config;
|
||||
private readonly DisplayManager _displayManager;
|
||||
private readonly InputManager _inputManager;
|
||||
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
|
||||
private void SetBaseProperties(IToolForm form)
|
||||
{
|
||||
if (form is ToolFormBase tool)
|
||||
{
|
||||
tool.Tools = this;
|
||||
tool.Config = _config;
|
||||
tool.DisplayManager = _displayManager;
|
||||
tool.InputManager = _inputManager;
|
||||
tool.MainForm = _owner;
|
||||
tool.MovieSession = _movieSession;
|
||||
tool.Game = _game;
|
||||
}
|
||||
if (!(form is FormBase f)) return;
|
||||
|
||||
f.Config = _config;
|
||||
if (!(form is ToolFormBase tool)) return;
|
||||
|
||||
tool.Tools = this;
|
||||
tool.DisplayManager = _displayManager;
|
||||
tool.InputManager = _inputManager;
|
||||
tool.MainForm = _owner;
|
||||
tool.MovieSession = _movieSession;
|
||||
tool.Game = _game;
|
||||
}
|
||||
|
||||
/// <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;
|
||||
_game = game;
|
||||
ApiProvider = ApiManager.Restart(_emulator.ServiceProvider, _owner, _displayManager, _inputManager, _movieSession, this, _config, _emulator, _game);
|
||||
|
|
Loading…
Reference in New Issue