tastudio: GlobalWin.MainForm alias

almost 100 cases of usage is worth it

make "recent rom not found" window topmost
This commit is contained in:
feos 2016-08-29 19:38:36 +03:00 committed by adelikat
parent 8be0c6fe51
commit 5761b6b7ce
6 changed files with 75 additions and 69 deletions

View File

@ -221,7 +221,8 @@ namespace BizHawk.Client.EmuHawk.ToolExtensions
}
else
{
var result = MessageBox.Show("Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
// ensure topmost, not to have to minimize everything to see and use our modal window, if it somehow got covered
var result = MessageBox.Show(new Form(){TopMost = true},"Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (result == DialogResult.Yes)
{
if (encodedPath != null)

View File

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

View File

@ -62,9 +62,9 @@ namespace BizHawk.Client.EmuHawk
{
if (_autoRestorePaused == null)
{
_autoRestorePaused = GlobalWin.MainForm.EmulatorPaused;
if (GlobalWin.MainForm.IsSeeking) // If seeking, do not shorten seek.
_autoRestoreFrame = GlobalWin.MainForm.PauseOnFrame;
_autoRestorePaused = Mainform.EmulatorPaused;
if (Mainform.IsSeeking) // If seeking, do not shorten seek.
_autoRestoreFrame = Mainform.PauseOnFrame;
}
GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastValidFrame);
@ -77,10 +77,10 @@ namespace BizHawk.Client.EmuHawk
return;
_seekStartFrame = Emulator.Frame;
GlobalWin.MainForm.PauseOnFrame = frame.Value;
int? diff = GlobalWin.MainForm.PauseOnFrame - _seekStartFrame;
Mainform.PauseOnFrame = frame.Value;
int? diff = Mainform.PauseOnFrame - _seekStartFrame;
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
if (!_seekBackgroundWorker.IsBusy && diff.Value > TasView.VisibleRows)
_seekBackgroundWorker.RunWorkerAsync();
@ -151,7 +151,7 @@ namespace BizHawk.Client.EmuHawk
if (columnName == CursorColumnName)
{
if (index == Emulator.Frame && index == GlobalWin.MainForm.PauseOnFrame)
if (index == Emulator.Frame && index == Mainform.PauseOnFrame)
{
bitmap = TasView.HorizontalOrientation ?
ts_v_arrow_green_blue :
@ -224,11 +224,11 @@ namespace BizHawk.Client.EmuHawk
{
TasMovieRecord record = CurrentTasMovie[index];
if (GlobalWin.MainForm.IsSeeking && GlobalWin.MainForm.PauseOnFrame == index)
if (Mainform.IsSeeking && Mainform.PauseOnFrame == index)
{
color = CurrentFrame_InputLog;
}
else if (!GlobalWin.MainForm.IsSeeking && Emulator.Frame == index)
else if (!Mainform.IsSeeking && Emulator.Frame == index)
{
color = CurrentFrame_InputLog;
}
@ -401,17 +401,17 @@ namespace BizHawk.Client.EmuHawk
if (e.Button == MouseButtons.Middle)
{
if (GlobalWin.MainForm.EmulatorPaused)
if (Mainform.EmulatorPaused)
{
TasMovieRecord record = CurrentTasMovie[LastPositionFrame];
if (!record.Lagged.HasValue && LastPositionFrame > Global.Emulator.Frame)
StartSeeking(LastPositionFrame);
else
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
else
{
GlobalWin.MainForm.PauseEmulator();
Mainform.PauseEmulator();
}
return;
}
@ -466,11 +466,11 @@ namespace BizHawk.Client.EmuHawk
}
else // User changed input
{
bool wasPaused = GlobalWin.MainForm.EmulatorPaused;
bool wasPaused = Mainform.EmulatorPaused;
if (Emulator.Frame > frame || CurrentTasMovie.LastValidFrame > frame)
{
if (wasPaused && !GlobalWin.MainForm.IsSeeking && !CurrentTasMovie.LastPositionStable)
if (wasPaused && !Mainform.IsSeeking && !CurrentTasMovie.LastPositionStable)
{
LastPositionFrame = Emulator.Frame;
CurrentTasMovie.LastPositionStable = true; // until new frame is emulated
@ -550,7 +550,7 @@ namespace BizHawk.Client.EmuHawk
// taseditor behavior
if (!wasPaused)
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
}
else if (e.Button == System.Windows.Forms.MouseButtons.Right)
@ -670,15 +670,15 @@ namespace BizHawk.Client.EmuHawk
if (notch > 1)
notch *= 2;
// warning: tastudio rewind hotket/button logic is copypasted from here!
if (GlobalWin.MainForm.IsSeeking && !GlobalWin.MainForm.EmulatorPaused)
// warning: tastudio rewind hotkey/button logic is copypasted from here!
if (Mainform.IsSeeking && !Mainform.EmulatorPaused)
{
GlobalWin.MainForm.PauseOnFrame -= notch;
Mainform.PauseOnFrame -= notch;
// that's a weird condition here, but for whatever reason it works best
if (notch > 0 && Global.Emulator.Frame >= GlobalWin.MainForm.PauseOnFrame)
if (notch > 0 && Global.Emulator.Frame >= Mainform.PauseOnFrame)
{
GlobalWin.MainForm.PauseEmulator();
GlobalWin.MainForm.PauseOnFrame = null;
Mainform.PauseEmulator();
Mainform.PauseOnFrame = null;
StopSeeking();
GoToFrame(Emulator.Frame - notch);
}

View File

@ -41,7 +41,7 @@ namespace BizHawk.Client.EmuHawk
private void NewTasMenuItem_Click(object sender, EventArgs e)
{
if (GlobalWin.MainForm.GameIsClosing)
if (Mainform.GameIsClosing)
{
Close();
}
@ -387,7 +387,7 @@ namespace BizHawk.Client.EmuHawk
// TODO: if highlighting 2 rows and pasting 3, only paste 2 of them
// FCEUX Taseditor does't do this, but I think it is the expected behavior in editor programs
var wasPaused = GlobalWin.MainForm.EmulatorPaused;
var wasPaused = Mainform.EmulatorPaused;
if (_tasClipboard.Any())
{
@ -404,7 +404,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
}
else
@ -416,7 +416,7 @@ namespace BizHawk.Client.EmuHawk
private void PasteInsertMenuItem_Click(object sender, EventArgs e)
{
var wasPaused = GlobalWin.MainForm.EmulatorPaused;
var wasPaused = Mainform.EmulatorPaused;
if (_tasClipboard.Any())
{
@ -433,7 +433,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
}
else
@ -447,7 +447,7 @@ namespace BizHawk.Client.EmuHawk
{
if (TasView.AnyRowsSelected)
{
var wasPaused = GlobalWin.MainForm.EmulatorPaused;
var wasPaused = Mainform.EmulatorPaused;
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
var rollBackFrame = TasView.FirstSelectedIndex.Value;
@ -480,7 +480,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
}
else
@ -494,7 +494,7 @@ namespace BizHawk.Client.EmuHawk
{
if (TasView.AnyRowsSelected)
{
bool wasPaused = GlobalWin.MainForm.EmulatorPaused;
bool wasPaused = Mainform.EmulatorPaused;
bool needsToRollback = !(TasView.FirstSelectedIndex > Emulator.Frame);
int rollBackFrame = TasView.FirstSelectedIndex.Value;
@ -514,7 +514,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
}
else
@ -528,7 +528,7 @@ namespace BizHawk.Client.EmuHawk
{
if (TasView.AnyRowsSelected)
{
var wasPaused = GlobalWin.MainForm.EmulatorPaused;
var wasPaused = Mainform.EmulatorPaused;
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
var rollBackFrame = TasView.FirstSelectedIndex.Value;
if (rollBackFrame >= CurrentTasMovie.InputLogLength)
@ -549,7 +549,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
}
else
@ -563,7 +563,7 @@ namespace BizHawk.Client.EmuHawk
{
if (TasView.AnyRowsSelected)
{
var wasPaused = GlobalWin.MainForm.EmulatorPaused;
var wasPaused = Mainform.EmulatorPaused;
var framesToInsert = TasView.SelectedRows.ToList();
var insertionFrame = Math.Min(TasView.LastSelectedIndex.Value + 1, CurrentTasMovie.InputLogLength);
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
@ -583,7 +583,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
}
else
@ -595,7 +595,7 @@ namespace BizHawk.Client.EmuHawk
private void InsertFrameMenuItem_Click(object sender, EventArgs e)
{
var wasPaused = GlobalWin.MainForm.EmulatorPaused;
var wasPaused = Mainform.EmulatorPaused;
var insertionFrame = TasView.AnyRowsSelected ? TasView.FirstSelectedIndex.Value : 0;
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
@ -610,7 +610,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
}
else
@ -621,7 +621,7 @@ namespace BizHawk.Client.EmuHawk
private void InsertNumFramesMenuItem_Click(object sender, EventArgs e)
{
bool wasPaused = GlobalWin.MainForm.EmulatorPaused;
bool wasPaused = Mainform.EmulatorPaused;
int insertionFrame = TasView.AnyRowsSelected ? TasView.FirstSelectedIndex.Value : 0;
bool needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
@ -641,7 +641,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
}
else
@ -720,7 +720,7 @@ namespace BizHawk.Client.EmuHawk
int goToFrame = CurrentTasMovie.TasStateManager.LastEmulatedFrame;
do
{
GlobalWin.MainForm.FrameAdvance();
Mainform.FrameAdvance();
if (CurrentTasMovie.TasStateManager.HasState(Emulator.Frame))
{
@ -936,7 +936,7 @@ namespace BizHawk.Client.EmuHawk
{
new MovieHeaderEditor(CurrentTasMovie)
{
Owner = GlobalWin.MainForm,
Owner = Mainform,
Location = this.ChildPointToScreen(TasView)
}.Show();
UpdateChangesIndicator();
@ -946,7 +946,7 @@ namespace BizHawk.Client.EmuHawk
{
new StateHistorySettingsForm(CurrentTasMovie.TasStateManager.Settings)
{
Owner = GlobalWin.MainForm,
Owner = Mainform,
Location = this.ChildPointToScreen(TasView),
Statable = this.StatableEmulator
}.ShowDialog();
@ -1231,13 +1231,13 @@ namespace BizHawk.Client.EmuHawk
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).
CancelSeekContextMenuItem.Enabled = GlobalWin.MainForm.PauseOnFrame.HasValue;
CancelSeekContextMenuItem.Enabled = Mainform.PauseOnFrame.HasValue;
BranchContextMenuItem.Visible = TasView.CurrentCell.RowIndex == Emulator.Frame;
}
private void CancelSeekContextMenuItem_Click(object sender, EventArgs e)
{
GlobalWin.MainForm.PauseOnFrame = null;
Mainform.PauseOnFrame = null;
RefreshTasView();
}
@ -1255,7 +1255,7 @@ namespace BizHawk.Client.EmuHawk
TasMovie newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie(
index, (byte[])StatableEmulator.SaveStateBinary().Clone());
GlobalWin.MainForm.PauseEmulator();
Mainform.PauseEmulator();
LoadFile(new FileInfo(newProject.Filename), true);
}
}
@ -1270,7 +1270,7 @@ namespace BizHawk.Client.EmuHawk
TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie(
SaveRamEmulator.CloneSaveRam());
GlobalWin.MainForm.PauseEmulator();
Mainform.PauseEmulator();
LoadFile(new FileInfo(newProject.Filename), true);
}
}

View File

@ -43,10 +43,10 @@ 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
{
bool wasPaused = GlobalWin.MainForm.EmulatorPaused;
GlobalWin.MainForm.FrameAdvance();
bool wasPaused = Mainform.EmulatorPaused;
Mainform.FrameAdvance();
if (!wasPaused)
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
else
{

View File

@ -110,10 +110,15 @@ namespace BizHawk.Client.EmuHawk
get { return Global.MovieSession.Movie as TasMovie; }
}
public MainForm Mainform
{
get { return GlobalWin.MainForm; }
}
/// <summary>
/// Separates "restore last position" logic from seeking caused by navigation.
/// TASEditor never kills LastPositionFrame, and it only pauses on it,
/// if it hasn't been greenzoned beforehand and middle mouse button was pressed
/// if it hasn't been greenzoned beforehand and middle mouse button was pressed.
/// </summary>
public int LastPositionFrame { get; set; }
@ -250,7 +255,7 @@ namespace BizHawk.Client.EmuHawk
}
int diff = Global.Emulator.Frame - _seekStartFrame.Value;
int unit = GlobalWin.MainForm.PauseOnFrame.Value - _seekStartFrame.Value;
int unit = Mainform.PauseOnFrame.Value - _seekStartFrame.Value;
double progress = 0;
if (diff != 0 && unit != 0)
@ -509,16 +514,16 @@ namespace BizHawk.Client.EmuHawk
private void EngageTastudio()
{
GlobalWin.MainForm.PauseOnFrame = null;
Mainform.PauseOnFrame = null;
GlobalWin.OSD.AddMessage("TAStudio engaged");
SetTasMovieCallbacks();
SetTextProperty();
GlobalWin.MainForm.PauseEmulator();
GlobalWin.MainForm.RelinquishControl(this);
Mainform.PauseEmulator();
Mainform.RelinquishControl(this);
_originalEndAction = Global.Config.MovieEndAction;
GlobalWin.MainForm.ClearRewindData();
Mainform.ClearRewindData();
Global.Config.MovieEndAction = MovieEndAction.Record;
GlobalWin.MainForm.SetMainformMovieInfo();
Mainform.SetMainformMovieInfo();
Global.MovieSession.ReadOnly = true;
}
@ -652,7 +657,7 @@ namespace BizHawk.Client.EmuHawk
if (movie == null)
movie = CurrentTasMovie;
SetTasMovieCallbacks(movie as TasMovie);
bool result = GlobalWin.MainForm.StartNewMovie(movie, record);
bool result = Mainform.StartNewMovie(movie, record);
TastudioPlayMode();
_initializing = false;
@ -704,17 +709,17 @@ namespace BizHawk.Client.EmuHawk
private void TastudioStopMovie()
{
Global.MovieSession.StopMovie(false);
GlobalWin.MainForm.SetMainformMovieInfo();
Mainform.SetMainformMovieInfo();
}
private void DisengageTastudio()
{
GlobalWin.MainForm.PauseOnFrame = null;
Mainform.PauseOnFrame = null;
GlobalWin.OSD.AddMessage("TAStudio disengaged");
Global.MovieSession.Movie = MovieService.DefaultInstance;
GlobalWin.MainForm.TakeBackControl();
Mainform.TakeBackControl();
Global.Config.MovieEndAction = _originalEndAction;
GlobalWin.MainForm.SetMainformMovieInfo();
Mainform.SetMainformMovieInfo();
// Do not keep TAStudio's disk save states.
//if (Directory.Exists(statesPath)) Directory.Delete(statesPath, true);
//TODO - do we need to dispose something here instead?
@ -801,7 +806,7 @@ namespace BizHawk.Client.EmuHawk
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
GlobalWin.MainForm.UnpauseEmulator();
Mainform.UnpauseEmulator();
}
_autoRestorePaused = null;
}
@ -824,7 +829,7 @@ namespace BizHawk.Client.EmuHawk
// frame == Emualtor.Frame when frame == 0
if (frame > Emulator.Frame)
{
if (GlobalWin.MainForm.EmulatorPaused || GlobalWin.MainForm.IsSeeking) // make seek frame keep up with emulation on fast scrolls
if (Mainform.EmulatorPaused || Mainform.IsSeeking) // make seek frame keep up with emulation on fast scrolls
{
StartSeeking(frame);
}
@ -866,7 +871,7 @@ namespace BizHawk.Client.EmuHawk
public void TogglePause()
{
GlobalWin.MainForm.TogglePause();
Mainform.TogglePause();
}
private void SetSplicer()