ToolManager - inject common things like config, mainform, and the tool manager itself to tools that inherit ToolFormBase

This commit is contained in:
adelikat 2019-12-22 10:25:36 -06:00
parent f8ed9f49eb
commit 77c04412d2
7 changed files with 82 additions and 67 deletions

View File

@ -92,15 +92,15 @@ namespace BizHawk.Client.EmuHawk
public bool Rewind() public bool Rewind()
{ {
// copy pasted from TasView_MouseWheel(), just without notch logic // copy pasted from TasView_MouseWheel(), just without notch logic
if (Mainform.IsSeeking && !Mainform.EmulatorPaused) if (MainForm.IsSeeking && !MainForm.EmulatorPaused)
{ {
Mainform.PauseOnFrame--; MainForm.PauseOnFrame--;
// that's a weird condition here, but for whatever reason it works best // that's a weird condition here, but for whatever reason it works best
if (Emulator.Frame >= Mainform.PauseOnFrame) if (Emulator.Frame >= MainForm.PauseOnFrame)
{ {
Mainform.PauseEmulator(); MainForm.PauseEmulator();
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
StopSeeking(); StopSeeking();
GoToPreviousFrame(); GoToPreviousFrame();
} }

View File

@ -81,19 +81,19 @@ namespace BizHawk.Client.EmuHawk
if (!fromMiddleClick) if (!fromMiddleClick)
{ {
if (Mainform.PauseOnFrame != null) if (MainForm.PauseOnFrame != null)
{ {
StopSeeking(true); // don't restore rec mode just yet, as with heavy editing checkbox updating causes lag StopSeeking(true); // don't restore rec mode just yet, as with heavy editing checkbox updating causes lag
} }
_seekStartFrame = Emulator.Frame; _seekStartFrame = Emulator.Frame;
} }
Mainform.PauseOnFrame = frame.Value; MainForm.PauseOnFrame = frame.Value;
int? diff = Mainform.PauseOnFrame - _seekStartFrame; int? diff = MainForm.PauseOnFrame - _seekStartFrame;
WasRecording = CurrentTasMovie.IsRecording() || WasRecording; WasRecording = CurrentTasMovie.IsRecording() || WasRecording;
TastudioPlayMode(); // suspend rec mode until seek ends, to allow mouse editing TastudioPlayMode(); // suspend rec mode until seek ends, to allow mouse editing
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
if (!_seekBackgroundWorker.IsBusy && diff > TasView.VisibleRows) if (!_seekBackgroundWorker.IsBusy && diff > TasView.VisibleRows)
{ {
@ -110,10 +110,10 @@ namespace BizHawk.Client.EmuHawk
WasRecording = false; WasRecording = false;
} }
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
if (_unpauseAfterSeeking) if (_unpauseAfterSeeking)
{ {
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
_unpauseAfterSeeking = false; _unpauseAfterSeeking = false;
} }
@ -173,7 +173,7 @@ namespace BizHawk.Client.EmuHawk
offsetY = 5; offsetY = 5;
} }
if (index == Emulator.Frame && index == Mainform.PauseOnFrame) if (index == Emulator.Frame && index == MainForm.PauseOnFrame)
{ {
bitmap = TasView.HorizontalOrientation ? bitmap = TasView.HorizontalOrientation ?
ts_v_arrow_green_blue : ts_v_arrow_green_blue :
@ -262,11 +262,11 @@ namespace BizHawk.Client.EmuHawk
{ {
TasMovieRecord record = CurrentTasMovie[index]; TasMovieRecord record = CurrentTasMovie[index];
if (Mainform.IsSeeking && Mainform.PauseOnFrame == index) if (MainForm.IsSeeking && MainForm.PauseOnFrame == index)
{ {
color = CurrentFrame_InputLog; color = CurrentFrame_InputLog;
} }
else if (!Mainform.IsSeeking && Emulator.Frame == index) else if (!MainForm.IsSeeking && Emulator.Frame == index)
{ {
color = CurrentFrame_InputLog; color = CurrentFrame_InputLog;
} }
@ -514,7 +514,7 @@ namespace BizHawk.Client.EmuHawk
if (e.Button == MouseButtons.Middle) if (e.Button == MouseButtons.Middle)
{ {
if (Mainform.EmulatorPaused) if (MainForm.EmulatorPaused)
{ {
TasMovieRecord record = CurrentTasMovie[LastPositionFrame]; TasMovieRecord record = CurrentTasMovie[LastPositionFrame];
if (!record.Lagged.HasValue && LastPositionFrame > Emulator.Frame) if (!record.Lagged.HasValue && LastPositionFrame > Emulator.Frame)
@ -523,12 +523,12 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
} }
else else
{ {
Mainform.PauseEmulator(); MainForm.PauseEmulator();
} }
return; return;
@ -604,7 +604,7 @@ namespace BizHawk.Client.EmuHawk
} }
else if (TasView.CurrentCell.Column.Type != ColumnType.Text) // User changed input else if (TasView.CurrentCell.Column.Type != ColumnType.Text) // User changed input
{ {
bool wasPaused = Mainform.EmulatorPaused; bool wasPaused = MainForm.EmulatorPaused;
if (ControllerType.BoolButtons.Contains(buttonName)) if (ControllerType.BoolButtons.Contains(buttonName))
{ {
@ -713,7 +713,7 @@ namespace BizHawk.Client.EmuHawk
// taseditor behavior // taseditor behavior
if (!wasPaused) if (!wasPaused)
{ {
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
} }
} }
@ -877,15 +877,15 @@ namespace BizHawk.Client.EmuHawk
} }
// warning: tastudio rewind hotkey/button logic is copy pasted from here! // warning: tastudio rewind hotkey/button logic is copy pasted from here!
if (Mainform.IsSeeking && !Mainform.EmulatorPaused) if (MainForm.IsSeeking && !MainForm.EmulatorPaused)
{ {
Mainform.PauseOnFrame -= notch; MainForm.PauseOnFrame -= notch;
// that's a weird condition here, but for whatever reason it works best // that's a weird condition here, but for whatever reason it works best
if (notch > 0 && Emulator.Frame >= Mainform.PauseOnFrame) if (notch > 0 && Emulator.Frame >= MainForm.PauseOnFrame)
{ {
Mainform.PauseEmulator(); MainForm.PauseEmulator();
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
StopSeeking(); StopSeeking();
GoToFrame(Emulator.Frame - notch); GoToFrame(Emulator.Frame - notch);
} }
@ -976,7 +976,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
if (_startCursorDrag && !Mainform.IsSeeking) if (_startCursorDrag && !MainForm.IsSeeking)
{ {
GoToFrame(e.NewCell.RowIndex.Value); GoToFrame(e.NewCell.RowIndex.Value);
} }

View File

@ -39,7 +39,7 @@ namespace BizHawk.Client.EmuHawk
private void NewTasMenuItem_Click(object sender, EventArgs e) private void NewTasMenuItem_Click(object sender, EventArgs e)
{ {
if (!Mainform.GameIsClosing) if (!MainForm.GameIsClosing)
{ {
StartNewTasMovie(); StartNewTasMovie();
} }
@ -78,7 +78,7 @@ namespace BizHawk.Client.EmuHawk
var result1 = MessageBox.Show("This is a regular movie, a new project must be created from it, in order to use in TAStudio\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); var result1 = MessageBox.Show("This is a regular movie, a new project must be created from it, in order to use in TAStudio\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result1 == DialogResult.OK) if (result1 == DialogResult.OK)
{ {
Mainform.StartNewMovie(MovieService.Get(ofd.FileName), false); MainForm.StartNewMovie(MovieService.Get(ofd.FileName), false);
ConvertCurrentMovieToTasproj(); ConvertCurrentMovieToTasproj();
StartNewMovieWrapper(false); StartNewMovieWrapper(false);
SetUpColumns(); SetUpColumns();
@ -168,7 +168,7 @@ namespace BizHawk.Client.EmuHawk
_autosaveTimer.Start(); _autosaveTimer.Start();
} }
Mainform.SetWindowText(); MainForm.SetWindowText();
GlobalWin.Sound.StartSound(); GlobalWin.Sound.StartSound();
} }
@ -865,7 +865,7 @@ namespace BizHawk.Client.EmuHawk
int goToFrame = CurrentTasMovie.LastStatedFrame; int goToFrame = CurrentTasMovie.LastStatedFrame;
do do
{ {
Mainform.FrameAdvance(); MainForm.FrameAdvance();
if (CurrentTasMovie.TasStateManager.HasState(Emulator.Frame)) if (CurrentTasMovie.TasStateManager.HasState(Emulator.Frame))
{ {
@ -1488,7 +1488,7 @@ namespace BizHawk.Client.EmuHawk
StartFromNowSeparator.Visible = StartNewProjectFromNowMenuItem.Visible || StartANewProjectFromSaveRamMenuItem.Visible; StartFromNowSeparator.Visible = StartNewProjectFromNowMenuItem.Visible || StartANewProjectFromSaveRamMenuItem.Visible;
RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.SelectedRows.Contains(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this). RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.SelectedRows.Contains(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this).
CancelSeekContextMenuItem.Enabled = Mainform.PauseOnFrame.HasValue; CancelSeekContextMenuItem.Enabled = MainForm.PauseOnFrame.HasValue;
BranchContextMenuItem.Visible = TasView.CurrentCell?.RowIndex == Emulator.Frame; BranchContextMenuItem.Visible = TasView.CurrentCell?.RowIndex == Emulator.Frame;
SelectBetweenMarkersContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Sel. bet. Markers"].Bindings; SelectBetweenMarkersContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Sel. bet. Markers"].Bindings;
@ -1501,7 +1501,7 @@ namespace BizHawk.Client.EmuHawk
private void CancelSeekContextMenuItem_Click(object sender, EventArgs e) private void CancelSeekContextMenuItem_Click(object sender, EventArgs e)
{ {
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
RefreshTasView(); RefreshTasView();
} }
@ -1519,7 +1519,7 @@ namespace BizHawk.Client.EmuHawk
TasMovie newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie( TasMovie newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie(
index, (byte[])StatableEmulator.SaveStateBinary().Clone()); index, (byte[])StatableEmulator.SaveStateBinary().Clone());
Mainform.PauseEmulator(); MainForm.PauseEmulator();
LoadFile(new FileInfo(newProject.Filename), true); LoadFile(new FileInfo(newProject.Filename), true);
} }
} }
@ -1539,7 +1539,7 @@ namespace BizHawk.Client.EmuHawk
GoToFrame(index); GoToFrame(index);
TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie( TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie(
SaveRamEmulator.CloneSaveRam()); SaveRamEmulator.CloneSaveRam());
Mainform.PauseEmulator(); MainForm.PauseEmulator();
LoadFile(new FileInfo(newProject.Filename), true); LoadFile(new FileInfo(newProject.Filename), true);
} }
else else

View File

@ -13,7 +13,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (frame <= Emulator.Frame) if (frame <= Emulator.Frame)
{ {
if ((Mainform.EmulatorPaused || !Mainform.IsSeeking) if ((MainForm.EmulatorPaused || !MainForm.IsSeeking)
&& !CurrentTasMovie.LastPositionStable) && !CurrentTasMovie.LastPositionStable)
{ {
LastPositionFrame = Emulator.Frame; LastPositionFrame = Emulator.Frame;
@ -42,11 +42,11 @@ namespace BizHawk.Client.EmuHawk
{ {
if (frame == Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame if (frame == Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame
{ {
bool wasPaused = Mainform.EmulatorPaused; bool wasPaused = MainForm.EmulatorPaused;
Mainform.FrameAdvance(); MainForm.FrameAdvance();
if (!wasPaused) if (!wasPaused)
{ {
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
} }
else else

View File

@ -21,7 +21,6 @@ namespace BizHawk.Client.EmuHawk
{ {
// TODO: UI flow that conveniently allows to start from savestate // TODO: UI flow that conveniently allows to start from savestate
public TasMovie CurrentTasMovie => Global.MovieSession.Movie as TasMovie; public TasMovie CurrentTasMovie => Global.MovieSession.Movie as TasMovie;
private MainForm Mainform => GlobalWin.MainForm;
public bool IsInMenuLoop { get; private set; } public bool IsInMenuLoop { get; private set; }
public string StatesPath => PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global", "TAStudio states"].Path, null); public string StatesPath => PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global", "TAStudio states"].Path, null);
@ -212,14 +211,14 @@ namespace BizHawk.Client.EmuHawk
this.Invoke(() => SavingProgressBar.Visible = true); this.Invoke(() => SavingProgressBar.Visible = true);
for (;;) for (;;)
{ {
if (_seekBackgroundWorker.CancellationPending || !IsHandleCreated || !Mainform.PauseOnFrame.HasValue) if (_seekBackgroundWorker.CancellationPending || !IsHandleCreated || !MainForm.PauseOnFrame.HasValue)
{ {
e.Cancel = true; e.Cancel = true;
break; break;
} }
int diff = Emulator.Frame - _seekStartFrame.Value; int diff = Emulator.Frame - _seekStartFrame.Value;
int unit = Mainform.PauseOnFrame.Value - _seekStartFrame.Value; int unit = MainForm.PauseOnFrame.Value - _seekStartFrame.Value;
double progress = 0; double progress = 0;
if (diff != 0 && unit != 0) if (diff != 0 && unit != 0)
@ -323,8 +322,8 @@ namespace BizHawk.Client.EmuHawk
private bool InitializeOnLoad() private bool InitializeOnLoad()
{ {
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
Mainform.PauseEmulator(); MainForm.PauseEmulator();
// Start Scenario 0: core needs a nag // Start Scenario 0: core needs a nag
// But do not nag if auto-loading // But do not nag if auto-loading
@ -526,11 +525,11 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.OSD.AddMessage("TAStudio engaged"); GlobalWin.OSD.AddMessage("TAStudio engaged");
SetTasMovieCallbacks(); SetTasMovieCallbacks();
SetTextProperty(); SetTextProperty();
Mainform.RelinquishControl(this); MainForm.RelinquishControl(this);
_originalEndAction = Global.Config.MovieEndAction; _originalEndAction = Global.Config.MovieEndAction;
Mainform.ClearRewindData(); MainForm.ClearRewindData();
Global.Config.MovieEndAction = MovieEndAction.Record; Global.Config.MovieEndAction = MovieEndAction.Record;
Mainform.SetMainformMovieInfo(); MainForm.SetMainformMovieInfo();
Global.MovieSession.ReadOnly = true; Global.MovieSession.ReadOnly = true;
SetSplicer(); SetSplicer();
} }
@ -681,7 +680,7 @@ namespace BizHawk.Client.EmuHawk
SetTasMovieCallbacks(movie as TasMovie); SetTasMovieCallbacks(movie as TasMovie);
bool result = Mainform.StartNewMovie(movie, record); bool result = MainForm.StartNewMovie(movie, record);
if (result) if (result)
{ {
CurrentTasMovie.TasStateManager.Capture(); // Capture frame 0 always. CurrentTasMovie.TasStateManager.Capture(); // Capture frame 0 always.
@ -744,17 +743,17 @@ namespace BizHawk.Client.EmuHawk
private void TastudioStopMovie() private void TastudioStopMovie()
{ {
Global.MovieSession.StopMovie(false); Global.MovieSession.StopMovie(false);
Mainform.SetMainformMovieInfo(); MainForm.SetMainformMovieInfo();
} }
private void DisengageTastudio() private void DisengageTastudio()
{ {
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
Mainform.AddOnScreenMessage("TAStudio disengaged"); MainForm.AddOnScreenMessage("TAStudio disengaged");
Global.MovieSession.Movie = MovieService.DefaultInstance; Global.MovieSession.Movie = MovieService.DefaultInstance;
Mainform.TakeBackControl(); MainForm.TakeBackControl();
Global.Config.MovieEndAction = _originalEndAction; Global.Config.MovieEndAction = _originalEndAction;
Mainform.SetMainformMovieInfo(); MainForm.SetMainformMovieInfo();
// Do not keep TAStudio's disk save states. // Do not keep TAStudio's disk save states.
// if (Directory.Exists(statesPath)) Directory.Delete(statesPath, true); // if (Directory.Exists(statesPath)) Directory.Delete(statesPath, true);
@ -849,7 +848,7 @@ namespace BizHawk.Client.EmuHawk
if (_autoRestorePaused.HasValue && !_autoRestorePaused.Value) if (_autoRestorePaused.HasValue && !_autoRestorePaused.Value)
{ {
// this happens when we're holding the left button while unpaused - view scrolls down, new input gets drawn, seek pauses // this happens when we're holding the left button while unpaused - view scrolls down, new input gets drawn, seek pauses
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
_autoRestorePaused = null; _autoRestorePaused = null;
@ -863,7 +862,7 @@ namespace BizHawk.Client.EmuHawk
return; return;
} }
_unpauseAfterSeeking = (fromRewinding || WasRecording) && !Mainform.EmulatorPaused; _unpauseAfterSeeking = (fromRewinding || WasRecording) && !MainForm.EmulatorPaused;
TastudioPlayMode(); TastudioPlayMode();
var closestState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame); var closestState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame);
if (closestState.Value.Length > 0 && (frame < Emulator.Frame || closestState.Key > Emulator.Frame)) if (closestState.Value.Length > 0 && (frame < Emulator.Frame || closestState.Key > Emulator.Frame))
@ -873,24 +872,24 @@ namespace BizHawk.Client.EmuHawk
if (fromLua) if (fromLua)
{ {
bool wasPaused = Mainform.EmulatorPaused; bool wasPaused = MainForm.EmulatorPaused;
// why not use this? because I'm not letting the form freely run. it all has to be under this loop. // why not use this? because I'm not letting the form freely run. it all has to be under this loop.
// i could use this and then poll StepRunLoop_Core() repeatedly, but.. that's basically what I'm doing // i could use this and then poll StepRunLoop_Core() repeatedly, but.. that's basically what I'm doing
// PauseOnFrame = frame; // PauseOnFrame = frame;
// can't re-enter lua while doing this // can't re-enter lua while doing this
Mainform.SuppressLua = true; MainForm.SuppressLua = true;
while (Emulator.Frame != frame) while (Emulator.Frame != frame)
{ {
Mainform.SeekFrameAdvance(); MainForm.SeekFrameAdvance();
} }
Mainform.SuppressLua = false; MainForm.SuppressLua = false;
if (!wasPaused) if (!wasPaused)
{ {
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
// lua botting users will want to re-activate record mode automatically -- it should be like nothing ever happened // lua botting users will want to re-activate record mode automatically -- it should be like nothing ever happened
@ -906,7 +905,7 @@ namespace BizHawk.Client.EmuHawk
if (frame > Emulator.Frame) if (frame > Emulator.Frame)
{ {
// make seek frame keep up with emulation on fast scrolls // make seek frame keep up with emulation on fast scrolls
if (Mainform.EmulatorPaused || Mainform.IsSeeking || fromRewinding || WasRecording) if (MainForm.EmulatorPaused || MainForm.IsSeeking || fromRewinding || WasRecording)
{ {
StartSeeking(frame); StartSeeking(frame);
} }
@ -956,7 +955,7 @@ namespace BizHawk.Client.EmuHawk
public void TogglePause() public void TogglePause()
{ {
Mainform.TogglePause(); MainForm.TogglePause();
} }
private void SetSplicer() private void SetSplicer()

View File

@ -13,6 +13,10 @@ namespace BizHawk.Client.EmuHawk
{ {
public class ToolFormBase : Form public class ToolFormBase : Form
{ {
public ToolManager Tools { get; set; }
public Config Config { get; set; }
public MainForm MainForm { get; set; }
public static FileInfo OpenFileDialog(string currentFile, string path, string fileType, string fileExt) public static FileInfo OpenFileDialog(string currentFile, string path, string fileType, string fileExt)
{ {
if (!Directory.Exists(path)) if (!Directory.Exists(path))
@ -92,10 +96,10 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public static void ViewInHexEditor(MemoryDomain domain, IEnumerable<long> addresses, WatchSize size) public void ViewInHexEditor(MemoryDomain domain, IEnumerable<long> addresses, WatchSize size)
{ {
GlobalWin.Tools.Load<HexEditor>(); Tools.Load<HexEditor>();
GlobalWin.Tools.HexEditor.SetToAddresses(addresses, domain, size); Tools.HexEditor.SetToAddresses(addresses, domain, size);
} }
protected void GenericDragEnter(object sender, DragEventArgs e) protected void GenericDragEnter(object sender, DragEventArgs e)
@ -110,7 +114,7 @@ namespace BizHawk.Client.EmuHawk
protected bool IsOnScreen(Point topLeft) protected bool IsOnScreen(Point topLeft)
{ {
return ToolManager.IsOnScreen(topLeft); return Tools.IsOnScreen(topLeft);
} }
} }
} }

View File

@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk
{ {
public class ToolManager public class ToolManager
{ {
private readonly Form _owner; private readonly MainForm _owner;
private readonly Config _config; private readonly Config _config;
private IExternalApiProvider _apiProvider; private IExternalApiProvider _apiProvider;
private IEmulator _emulator; private IEmulator _emulator;
@ -32,7 +32,7 @@ namespace BizHawk.Client.EmuHawk
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ToolManager"/> class. /// Initializes a new instance of the <see cref="ToolManager"/> class.
/// </summary> /// </summary>
public ToolManager(Form owner, Config config, IEmulator emulator) public ToolManager(MainForm owner, Config config, IEmulator emulator)
{ {
_owner = owner; _owner = owner;
_config = config; _config = config;
@ -60,6 +60,17 @@ namespace BizHawk.Client.EmuHawk
return (IToolForm)method.Invoke(this, new object[] { focus }); return (IToolForm)method.Invoke(this, new object[] { focus });
} }
// 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.MainForm = _owner;
}
}
/// <summary> /// <summary>
/// Loads the tool dialog T (T must implement <see cref="IToolForm"/>) , if it does not exist it will be created, if it is already open, it will be focused /// Loads the tool dialog T (T must implement <see cref="IToolForm"/>) , if it does not exist it will be created, if it is already open, it will be focused
/// </summary> /// </summary>
@ -135,6 +146,7 @@ namespace BizHawk.Client.EmuHawk
} }
ServiceInjector.UpdateServices(_emulator.ServiceProvider, newTool); ServiceInjector.UpdateServices(_emulator.ServiceProvider, newTool);
SetBaseProperties(newTool);
string toolType = typeof(T).ToString(); string toolType = typeof(T).ToString();
// auto settings // auto settings
@ -398,7 +410,7 @@ namespace BizHawk.Client.EmuHawk
return false; return false;
} }
public static bool IsOnScreen(Point topLeft) public bool IsOnScreen(Point topLeft)
{ {
return Screen.AllScreens.Any( return Screen.AllScreens.Any(
screen => screen.WorkingArea.Contains(topLeft)); screen => screen.WorkingArea.Contains(topLeft));