ToolManager - take a Form owner in the constructor and pass it in to any tools that are also Form objects (all of them). ToolBox - use the Parent property instead of GlobalWin.MainForm now that it is populated

This commit is contained in:
adelikat 2015-02-22 04:02:30 +00:00
parent 1514faf300
commit 41950cb9e0
3 changed files with 15 additions and 3 deletions

View File

@ -289,7 +289,7 @@ namespace BizHawk.Client.EmuHawk
}
GlobalWin.Sound.StartSound();
InputManager.RewireInputChain();
GlobalWin.Tools = new ToolManager();
GlobalWin.Tools = new ToolManager(this);
RewireSound();
// Workaround for windows, location is -32000 when minimized, if they close it during this time, that's what gets saved

View File

@ -28,8 +28,8 @@ namespace BizHawk.Client.EmuHawk
private void ToolBox_Load(object sender, EventArgs e)
{
Location = new Point(
GlobalWin.MainForm.Location.X + GlobalWin.MainForm.Size.Width,
GlobalWin.MainForm.Location.Y
Owner.Location.X + Owner.Size.Width,
Owner.Location.Y
);
}

View File

@ -16,6 +16,13 @@ namespace BizHawk.Client.EmuHawk
{
public class ToolManager
{
public ToolManager(Form owner)
{
_owner = owner;
}
private readonly Form _owner;
// TODO: merge ToolHelper code where logical
// For instance, add an IToolForm property called UsesCheats, so that a UpdateCheatRelatedTools() method can update all tools of this type
// Also a UsesRam, and similar method
@ -62,6 +69,11 @@ namespace BizHawk.Client.EmuHawk
var newTool = CreateInstance(toolType);
if (newTool is Form)
{
(newTool as Form).Owner = GlobalWin.MainForm;
}
ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, newTool);
// auto settings