a round of cleanup on MianForm.cs, and an attempt to start organizing methods and variables to make it easier to pull out logic in future refactoring
This commit is contained in:
parent
49d9953c40
commit
187e169de9
|
@ -24,9 +24,12 @@ namespace BizHawk.Client.Common
|
|||
return Path.Combine(Path.GetDirectoryName(SubfileDirectory) ?? String.Empty, fname);
|
||||
}
|
||||
|
||||
public static void SyncCoreCommInputSignals()
|
||||
public static void SyncCoreCommInputSignals(CoreComm target = null)
|
||||
{
|
||||
CoreComm target = Global.CoreComm;
|
||||
if (target == null)
|
||||
{
|
||||
target = Global.CoreComm;
|
||||
}
|
||||
|
||||
var cfp = new CoreFileProvider();
|
||||
target.CoreFileProvider = cfp;
|
||||
|
|
|
@ -50,6 +50,11 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public bool HasSlot(int slot)
|
||||
{
|
||||
if (Global.Emulator is NullEmulator)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (slot < 0 || slot > 10)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace BizHawk.Client.Common
|
|||
public Movie Movie;
|
||||
public MovieControllerAdapter MovieControllerAdapter = new MovieControllerAdapter();
|
||||
public bool EditorMode { get; set; }
|
||||
public Action ClearSRAMCallback; //Required
|
||||
public Action<string> MessageCallback; //Not Required
|
||||
public Func<string, string, bool> AskYesNoCallback; //Not Required
|
||||
|
||||
|
@ -428,7 +427,7 @@ namespace BizHawk.Client.Common
|
|||
var result = Movie.CheckTimeLines(reader, OnlyGUID: !Global.ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG);
|
||||
if (result == Movie.LoadStateResult.Pass)
|
||||
{
|
||||
ClearSRAMCallback();
|
||||
Global.Emulator.ClearSaveRam();
|
||||
Movie.StartRecording();
|
||||
reader.BaseStream.Position = 0;
|
||||
reader.DiscardBufferedData();
|
||||
|
@ -444,7 +443,7 @@ namespace BizHawk.Client.Common
|
|||
var newresult = Movie.CheckTimeLines(reader, OnlyGUID: !Global.ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG);
|
||||
if (newresult == Movie.LoadStateResult.Pass)
|
||||
{
|
||||
ClearSRAMCallback();
|
||||
Global.Emulator.ClearSaveRam();
|
||||
Movie.StartRecording();
|
||||
reader.BaseStream.Position = 0;
|
||||
reader.DiscardBufferedData();
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace BizHawk.MultiClient
|
|||
Closing += (o, e) =>
|
||||
{
|
||||
Global.Config.ShowLogWindow = false;
|
||||
GlobalWinF.MainForm.notifyLogWindowClosing();
|
||||
GlobalWinF.MainForm.NotifyLogWindowClosing();
|
||||
LogConsole.notifyLogWindowClosing();
|
||||
SaveConfigSettings();
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace BizHawk.MultiClient
|
|||
AVSubMenu.Enabled =
|
||||
ScreenshotSubMenu.Enabled =
|
||||
CloseRomMenuItem.Enabled =
|
||||
!IsNullEmulator();
|
||||
!(Global.Emulator is NullEmulator);
|
||||
}
|
||||
|
||||
private void RecentRomMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
|
@ -123,7 +123,7 @@ namespace BizHawk.MultiClient
|
|||
SaveState8MenuItem.Enabled =
|
||||
SaveState9MenuItem.Enabled =
|
||||
SaveState0MenuItem.Enabled =
|
||||
!IsNullEmulator();
|
||||
!(Global.Emulator is NullEmulator);
|
||||
}
|
||||
|
||||
private void LoadStateSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
|
@ -142,17 +142,17 @@ namespace BizHawk.MultiClient
|
|||
|
||||
AutoloadLastSlotMenuItem.Checked = Global.Config.AutoLoadLastSaveSlot;
|
||||
|
||||
LoadNamedStateMenuItem.Enabled = !IsNullEmulator();
|
||||
LoadState1MenuItem.Enabled = !IsNullEmulator() && StateSlots.HasSlot(1);
|
||||
LoadState2MenuItem.Enabled = !IsNullEmulator() && StateSlots.HasSlot(2);
|
||||
LoadState3MenuItem.Enabled = !IsNullEmulator() && StateSlots.HasSlot(3);
|
||||
LoadState4MenuItem.Enabled = !IsNullEmulator() && StateSlots.HasSlot(4);
|
||||
LoadState5MenuItem.Enabled = !IsNullEmulator() && StateSlots.HasSlot(5);
|
||||
LoadState6MenuItem.Enabled = !IsNullEmulator() && StateSlots.HasSlot(6);
|
||||
LoadState7MenuItem.Enabled = !IsNullEmulator() && StateSlots.HasSlot(7);
|
||||
LoadState8MenuItem.Enabled = !IsNullEmulator() && StateSlots.HasSlot(8);
|
||||
LoadState9MenuItem.Enabled = !IsNullEmulator() && StateSlots.HasSlot(9);
|
||||
LoadState0MenuItem.Enabled = !IsNullEmulator() && StateSlots.HasSlot(0);
|
||||
LoadNamedStateMenuItem.Enabled = !(Global.Emulator is NullEmulator);
|
||||
LoadState1MenuItem.Enabled = StateSlots.HasSlot(1);
|
||||
LoadState2MenuItem.Enabled = StateSlots.HasSlot(2);
|
||||
LoadState3MenuItem.Enabled = StateSlots.HasSlot(3);
|
||||
LoadState4MenuItem.Enabled = StateSlots.HasSlot(4);
|
||||
LoadState5MenuItem.Enabled = StateSlots.HasSlot(5);
|
||||
LoadState6MenuItem.Enabled = StateSlots.HasSlot(6);
|
||||
LoadState7MenuItem.Enabled = StateSlots.HasSlot(7);
|
||||
LoadState8MenuItem.Enabled = StateSlots.HasSlot(8);
|
||||
LoadState9MenuItem.Enabled = StateSlots.HasSlot(9);
|
||||
LoadState0MenuItem.Enabled = StateSlots.HasSlot(0);
|
||||
}
|
||||
|
||||
private void SaveSlotSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
|
@ -172,7 +172,7 @@ namespace BizHawk.MultiClient
|
|||
SaveToCurrentSlotMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Quick Save"].Bindings;
|
||||
LoadCurrentSlotMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Quick Load"].Bindings;
|
||||
|
||||
SaveToCurrentSlotMenuItem.Enabled = LoadCurrentSlotMenuItem.Enabled = !IsNullEmulator();
|
||||
SaveToCurrentSlotMenuItem.Enabled = LoadCurrentSlotMenuItem.Enabled = !(Global.Emulator is NullEmulator);
|
||||
|
||||
SelectSlot0MenuItem.Checked = false;
|
||||
SelectSlot1MenuItem.Checked = false;
|
||||
|
@ -516,7 +516,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void emulationToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RebootCoreMenuItem.Enabled = !IsNullEmulator();
|
||||
RebootCoreMenuItem.Enabled = !(Global.Emulator is NullEmulator);
|
||||
|
||||
if (didMenuPause)
|
||||
{
|
||||
|
@ -1782,26 +1782,26 @@ namespace BizHawk.MultiClient
|
|||
didMenuPause = true;
|
||||
PauseEmulator();
|
||||
|
||||
OpenRomContextMenuItem.Visible = IsNullEmulator() || InFullscreen;
|
||||
OpenRomContextMenuItem.Visible = (Global.Emulator is NullEmulator) || InFullscreen;
|
||||
|
||||
ShowMenuContextMenuItem.Visible =
|
||||
ShowMenuContextMenuSeparator.Visible =
|
||||
InFullscreen;
|
||||
|
||||
LoadLastRomContextMenuItem.Visible =
|
||||
IsNullEmulator();
|
||||
(Global.Emulator is NullEmulator);
|
||||
|
||||
ContextSeparator_AfterMovie.Visible =
|
||||
ContextSeparator_AfterUndo.Visible =
|
||||
ScreenshotContextMenuItem.Visible =
|
||||
CloseRomContextMenuItem.Visible =
|
||||
UndoSavestateContextMenuItem.Visible =
|
||||
!IsNullEmulator();
|
||||
!(Global.Emulator is NullEmulator);
|
||||
|
||||
RecordMovieContextMenuItem.Visible =
|
||||
PlayMovieContextMenuItem.Visible =
|
||||
LoadLastMovieContextMenuItem.Visible =
|
||||
!IsNullEmulator() && !Global.MovieSession.Movie.IsActive;
|
||||
!(Global.Emulator is NullEmulator) && !Global.MovieSession.Movie.IsActive;
|
||||
|
||||
RestartMovieContextMenuItem.Visible =
|
||||
StopMovieContextMenuItem.Visible =
|
||||
|
@ -1813,7 +1813,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
StopNoSaveContextMenuItem.Visible = Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.HasChanges;
|
||||
|
||||
AddSubtitleContextMenuItem.Visible = !IsNullEmulator() && Global.MovieSession.Movie.IsActive && Global.ReadOnly;
|
||||
AddSubtitleContextMenuItem.Visible = !(Global.Emulator is NullEmulator) && Global.MovieSession.Movie.IsActive && Global.ReadOnly;
|
||||
|
||||
ConfigContextMenuItem.Visible = InFullscreen;
|
||||
|
||||
|
@ -1977,7 +1977,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void ShowMenuContextMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ShowHideMenu();
|
||||
MainMenuStrip.Visible ^= true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -19,7 +19,6 @@ namespace BizHawk.MultiClient
|
|||
Global.MovieSession = new MovieSession
|
||||
{
|
||||
Movie = m,
|
||||
ClearSRAMCallback = ClearSaveRAM,
|
||||
MessageCallback = GlobalWinF.OSD.AddMessage,
|
||||
AskYesNoCallback = StateErrorAskUser
|
||||
};
|
||||
|
@ -42,13 +41,13 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
if (record)
|
||||
{
|
||||
GlobalWinF.MainForm.ClearSaveRAM();
|
||||
Global.Emulator.ClearSaveRam();
|
||||
Global.MovieSession.Movie.StartRecording();
|
||||
Global.ReadOnly = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalWinF.MainForm.ClearSaveRAM();
|
||||
Global.Emulator.ClearSaveRam();
|
||||
Global.MovieSession.Movie.StartPlayback();
|
||||
}
|
||||
SetMainformMovieInfo();
|
||||
|
@ -115,7 +114,7 @@ namespace BizHawk.MultiClient
|
|||
LoadStateFile(Global.MovieSession.Movie.Filename, Path.GetFileName(Global.MovieSession.Movie.Filename));
|
||||
Global.Emulator.ResetFrameCounter();
|
||||
}
|
||||
GlobalWinF.MainForm.ClearSaveRAM();
|
||||
Global.Emulator.ClearSaveRam();
|
||||
Global.MovieSession.Movie.StartPlayback();
|
||||
SetMainformMovieInfo();
|
||||
GlobalWinF.OSD.AddMessage("Replaying movie file in read-only mode");
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -152,7 +152,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public static void client_paint()
|
||||
{
|
||||
GlobalWinF.MainForm.ForcePaint();
|
||||
GlobalWinF.DisplayManager.NeedsToPaint = true;
|
||||
}
|
||||
|
||||
public static void client_pause()
|
||||
|
|
Loading…
Reference in New Issue