diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs
index 6d2cf3b9f8..65decb7aeb 100644
--- a/BizHawk.Client.EmuHawk/MainForm.Events.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs
@@ -45,61 +45,61 @@ namespace BizHawk.Client.EmuHawk
SaveState0MenuItem.Font = new Font(
SaveState0MenuItem.Font.FontFamily,
SaveState0MenuItem.Font.Size,
- StateSlots.HasSlot(0) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
+ _stateSlots.HasSlot(0) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
);
SaveState1MenuItem.Font = new Font(
SaveState1MenuItem.Font.FontFamily,
SaveState1MenuItem.Font.Size,
- StateSlots.HasSlot(1) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
+ _stateSlots.HasSlot(1) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
);
SaveState2MenuItem.Font = new Font(
SaveState2MenuItem.Font.FontFamily,
SaveState2MenuItem.Font.Size,
- StateSlots.HasSlot(2) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
+ _stateSlots.HasSlot(2) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
);
SaveState3MenuItem.Font = new Font(
SaveState3MenuItem.Font.FontFamily,
SaveState3MenuItem.Font.Size,
- StateSlots.HasSlot(3) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
+ _stateSlots.HasSlot(3) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
);
SaveState4MenuItem.Font = new Font(
SaveState4MenuItem.Font.FontFamily,
SaveState4MenuItem.Font.Size,
- StateSlots.HasSlot(4) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
+ _stateSlots.HasSlot(4) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
);
SaveState5MenuItem.Font = new Font(
SaveState5MenuItem.Font.FontFamily,
SaveState5MenuItem.Font.Size,
- StateSlots.HasSlot(5) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
+ _stateSlots.HasSlot(5) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
);
SaveState6MenuItem.Font = new Font(
SaveState6MenuItem.Font.FontFamily,
SaveState6MenuItem.Font.Size,
- StateSlots.HasSlot(6) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
+ _stateSlots.HasSlot(6) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
);
SaveState7MenuItem.Font = new Font(
SaveState7MenuItem.Font.FontFamily,
SaveState7MenuItem.Font.Size,
- StateSlots.HasSlot(7) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
+ _stateSlots.HasSlot(7) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
);
SaveState8MenuItem.Font = new Font(
SaveState8MenuItem.Font.FontFamily,
SaveState8MenuItem.Font.Size,
- StateSlots.HasSlot(8) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
+ _stateSlots.HasSlot(8) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
);
SaveState9MenuItem.Font = new Font(
SaveState9MenuItem.Font.FontFamily,
SaveState9MenuItem.Font.Size,
- StateSlots.HasSlot(9) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
+ _stateSlots.HasSlot(9) ? (FontStyle.Italic | FontStyle.Bold) : FontStyle.Regular
);
SaveState1MenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Save State 1"].Bindings;
@@ -145,16 +145,16 @@ namespace BizHawk.Client.EmuHawk
AutoloadLastSlotMenuItem.Checked = Global.Config.AutoLoadLastSaveSlot;
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);
+ 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)
@@ -262,7 +262,7 @@ namespace BizHawk.Client.EmuHawk
StopAVIMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Stop A/V"].Bindings;
CaptureOSDMenuItem.Checked = Global.Config.AVI_CaptureOSD;
- if (CurrAviWriter == null)
+ if (_currAviWriter == null)
{
RecordAVMenuItem.Enabled = true;
StopAVIMenuItem.Enabled = false;
@@ -282,12 +282,12 @@ namespace BizHawk.Client.EmuHawk
private void OpenRomMenuItem_Click(object sender, EventArgs e)
{
- OpenROM();
+ OpenRom();
}
private void CloseRomMenuItem_Click(object sender, EventArgs e)
{
- CloseROM();
+ CloseRom();
}
private void Savestate1MenuItem_Click(object sender, EventArgs e) { SaveState("QuickSave1"); }
@@ -356,12 +356,12 @@ namespace BizHawk.Client.EmuHawk
private void SaveToCurrentSlotMenuItem_Click(object sender, EventArgs e)
{
- SaveState("QuickSave" + Global.Config.SaveSlot.ToString());
+ SaveState("QuickSave" + Global.Config.SaveSlot);
}
private void LoadCurrentSlotMenuItem_Click(object sender, EventArgs e)
{
- LoadState("QuickSave" + Global.Config.SaveSlot.ToString());
+ LoadState("QuickSave" + Global.Config.SaveSlot);
}
private void ReadonlyMenuItem_Click(object sender, EventArgs e)
@@ -416,13 +416,9 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Sound.StopSound();
var result = ofd.ShowDialog();
GlobalWin.Sound.StartSound();
- if (result != DialogResult.OK)
+ if (result == DialogResult.OK)
{
- return;
- }
- else
- {
- foreach (string fn in ofd.FileNames)
+ foreach (var fn in ofd.FileNames)
{
ProcessMovieImport(fn);
}
@@ -476,9 +472,9 @@ namespace BizHawk.Client.EmuHawk
private void ScreenshotAsMenuItem_Click(object sender, EventArgs e)
{
- string path = String.Format(PathManager.ScreenshotPrefix(Global.Game) + ".{0:yyyy-MM-dd HH.mm.ss}.png", DateTime.Now);
+ var path = String.Format(PathManager.ScreenshotPrefix(Global.Game) + ".{0:yyyy-MM-dd HH.mm.ss}.png", DateTime.Now);
- SaveFileDialog sfd = new SaveFileDialog
+ var sfd = new SaveFileDialog
{
InitialDirectory = Path.GetDirectoryName(path),
FileName = Path.GetFileName(path),
@@ -520,14 +516,7 @@ namespace BizHawk.Client.EmuHawk
{
RebootCoreMenuItem.Enabled = !(Global.Emulator is NullEmulator);
- if (didMenuPause)
- {
- PauseMenuItem.Checked = wasPaused;
- }
- else
- {
- PauseMenuItem.Checked = EmulatorPaused;
- }
+ PauseMenuItem.Checked = _didMenuPause ? _wasPaused : EmulatorPaused;
SoftResetMenuItem.Enabled = Global.Emulator.ControllerDefinition.BoolButtons.Contains("Reset") &&
(!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished);
@@ -683,7 +672,7 @@ namespace BizHawk.Client.EmuHawk
{
Global.Config.DisplayStatusBar ^= true;
- if (!InFullscreen)
+ if (!_inFullscreen)
{
MainStatusBar.Visible = Global.Config.DisplayStatusBar;
PerformLayout();
@@ -813,7 +802,7 @@ namespace BizHawk.Client.EmuHawk
private void ControllersMenuItem_Click(object sender, EventArgs e)
{
- ControllerConfig controller = new ControllerConfig(Global.Emulator.ControllerDefinition);
+ var controller = new ControllerConfig(Global.Emulator.ControllerDefinition);
if (controller.ShowDialog() == DialogResult.OK)
{
InitControls();
@@ -823,7 +812,7 @@ namespace BizHawk.Client.EmuHawk
private void HotkeysMenuItem_Click(object sender, EventArgs e)
{
- HotkeyConfig hotkeys = new HotkeyConfig();
+ var hotkeys = new HotkeyConfig();
if (hotkeys.ShowDialog() == DialogResult.OK)
{
InitControls();
@@ -843,7 +832,7 @@ namespace BizHawk.Client.EmuHawk
private void SoundMenuItem_Click(object sender, EventArgs e)
{
- SoundConfig sound = new SoundConfig();
+ var sound = new SoundConfig();
if (sound.ShowDialog() == DialogResult.OK)
{
RewireSound();
@@ -868,53 +857,27 @@ namespace BizHawk.Client.EmuHawk
private void EnableContextMenuMenuItem_Click(object sender, EventArgs e)
{
Global.Config.ShowContextMenu ^= true;
- if (Global.Config.ShowContextMenu)
- {
- GlobalWin.OSD.AddMessage("Context menu enabled");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Context menu disabled");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.ShowContextMenu ? "Context menu enabled" : "Context menu disabled");
}
private void BackupSavestatesMenuItem_Click(object sender, EventArgs e)
{
Global.Config.BackupSavestates ^= true;
- if (Global.Config.BackupSavestates)
- {
- GlobalWin.OSD.AddMessage("Backup savestates enabled");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Backup savestates disabled");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.BackupSavestates ? "Backup savestates enabled" : "Backup savestates disabled");
}
private void AutoSavestatesMenuItem_Click(object sender, EventArgs e)
{
Global.Config.AutoSavestates ^= true;
- if (Global.Config.AutoSavestates)
- {
- GlobalWin.OSD.AddMessage("AutoSavestates enabled");
- }
- else
- {
- GlobalWin.OSD.AddMessage("AutoSavestates disabled");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.AutoSavestates ? "AutoSavestates enabled" : "AutoSavestates disabled");
}
private void ScreenshotWithSavestatesMenuItem_Click(object sender, EventArgs e)
{
Global.Config.SaveScreenshotWithStates ^= true;
- if (Global.Config.SaveScreenshotWithStates)
- {
- GlobalWin.OSD.AddMessage("Screenshots will be saved in savestates");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Screenshots will not be saved in savestates");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.SaveScreenshotWithStates
+ ? "Screenshots will be saved in savestates"
+ : "Screenshots will not be saved in savestates");
}
private void frameAdvanceSkipLagFramesToolStripMenuItem_Click(object sender, EventArgs e)
@@ -925,14 +888,7 @@ namespace BizHawk.Client.EmuHawk
private void BackupSaveramMenuItem_Click(object sender, EventArgs e)
{
Global.Config.BackupSaveram ^= true;
- if (Global.Config.BackupSaveram)
- {
- GlobalWin.OSD.AddMessage("Backup saveram enabled");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Backup saveram disabled");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.BackupSaveram ? "Backup saveram enabled" : "Backup saveram disabled");
}
private void PauseWhenMenuActivatedMenuItem_Click(object sender, EventArgs e)
@@ -1002,7 +958,7 @@ namespace BizHawk.Client.EmuHawk
Global.Config.ClockThrottle ^= true;
if (Global.Config.ClockThrottle)
{
- bool old = Global.Config.SoundThrottle;
+ var old = Global.Config.SoundThrottle;
Global.Config.SoundThrottle = false;
if (old)
{
@@ -1025,7 +981,7 @@ namespace BizHawk.Client.EmuHawk
if (Global.Config.SoundThrottle)
{
Global.Config.ClockThrottle = false;
- bool old = Global.Config.VSyncThrottle;
+ var old = Global.Config.VSyncThrottle;
Global.Config.VSyncThrottle = false;
if (old)
{
@@ -1041,7 +997,7 @@ namespace BizHawk.Client.EmuHawk
if (Global.Config.VSyncThrottle)
{
Global.Config.ClockThrottle = false;
- bool old = Global.Config.SoundThrottle;
+ var old = Global.Config.SoundThrottle;
Global.Config.SoundThrottle = false;
if (old)
{
@@ -1224,7 +1180,7 @@ namespace BizHawk.Client.EmuHawk
private void NESGameGenieCodesMenuItem_Click(object sender, EventArgs e)
{
- LoadGameGenieEC();
+ LoadGameGenieEc();
}
private void NESGraphicSettingsMenuItem_Click(object sender, EventArgs e)
@@ -1294,7 +1250,7 @@ namespace BizHawk.Client.EmuHawk
SMSEnableFMChipMenuItem.Visible =
SMSOverclockMenuItem.Visible =
SMSForceStereoMenuItem.Visible =
- !(Global.Game.System == "GG");
+ Global.Game.System != "GG";
ShowClippedRegionsMenuItem.Visible =
HighlightActiveDisplayRegionMenuItem.Visible =
@@ -1346,7 +1302,7 @@ namespace BizHawk.Client.EmuHawk
private void GGGameGenieMenuItem_Click(object sender, EventArgs e)
{
- LoadGameGenieEC();
+ LoadGameGenieEc();
}
#endregion
@@ -1373,9 +1329,9 @@ namespace BizHawk.Client.EmuHawk
private void LoadTIFileMenuItem_Click(object sender, EventArgs e)
{
- OpenFileDialog OFD = new OpenFileDialog();
+ var OFD = new OpenFileDialog();
- if (OFD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ if (OFD.ShowDialog() == DialogResult.OK)
{
try
{
@@ -1383,7 +1339,7 @@ namespace BizHawk.Client.EmuHawk
}
catch (IOException ex)
{
- string Message = String.Format("Invalid file format. Reason: {0} \nForce transfer? This may cause the calculator to crash.", ex.Message);
+ var Message = String.Format("Invalid file format. Reason: {0} \nForce transfer? This may cause the calculator to crash.", ex.Message);
if (MessageBox.Show(Message, "Upload Failed", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
{
@@ -1421,14 +1377,9 @@ namespace BizHawk.Client.EmuHawk
(Global.Emulator as Atari2600).SetBw(Global.Config.Atari2600_BW);
}
- if (Global.Config.Atari2600_BW)
- {
- GlobalWin.OSD.AddMessage("Setting the Black and White Switch to On");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Setting the Black and White Switch to Off");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.Atari2600_BW
+ ? "Setting the Black and White Switch to On"
+ : "Setting the Black and White Switch to Off");
}
private void AtariLeftDifficultyMenuItem_Click(object sender, EventArgs e)
@@ -1440,14 +1391,9 @@ namespace BizHawk.Client.EmuHawk
(Global.Emulator as Atari2600).SetP0Diff(Global.Config.Atari2600_BW);
}
- if (Global.Config.Atari2600_LeftDifficulty)
- {
- GlobalWin.OSD.AddMessage("Setting Left Difficulty to B");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Setting Left Difficulty to A");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.Atari2600_LeftDifficulty
+ ? "Setting Left Difficulty to B"
+ : "Setting Left Difficulty to A");
}
private void AtariRightDifficultyMenuItem_Click(object sender, EventArgs e)
@@ -1459,14 +1405,9 @@ namespace BizHawk.Client.EmuHawk
(Global.Emulator as Atari2600).SetP1Diff(Global.Config.Atari2600_BW);
}
- if (Global.Config.Atari2600_RightDifficulty)
- {
- GlobalWin.OSD.AddMessage("Setting Right Difficulty to B");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Setting Right Difficulty to A");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.Atari2600_RightDifficulty
+ ? "Setting Right Difficulty to B"
+ : "Setting Right Difficulty to A");
}
private void AtariShowBGMenuItem_Click(object sender, EventArgs e)
@@ -1572,7 +1513,7 @@ namespace BizHawk.Client.EmuHawk
private void GBGameGenieMenuItem_Click(object sender, EventArgs e)
{
- LoadGameGenieEC();
+ LoadGameGenieEc();
}
#endregion
@@ -1677,7 +1618,7 @@ namespace BizHawk.Client.EmuHawk
private void SnesGameGenieMenuItem_Click(object sender, EventArgs e)
{
- LoadGameGenieEC();
+ LoadGameGenieEc();
}
private void SnesOptionsMenuItem_Click(object sender, EventArgs e)
@@ -1724,6 +1665,7 @@ namespace BizHawk.Client.EmuHawk
{
if (new N64VideoPluginconfig().ShowDialog() == DialogResult.OK)
{
+ GlobalWin.MainForm.FlagNeedsReboot();
GlobalWin.OSD.AddMessage("Plugin settings saved");
}
else
@@ -1780,20 +1722,20 @@ namespace BizHawk.Client.EmuHawk
private void MainFormContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
- wasPaused = EmulatorPaused;
- didMenuPause = true;
+ _wasPaused = EmulatorPaused;
+ _didMenuPause = true;
PauseEmulator();
- OpenRomContextMenuItem.Visible = (Global.Emulator is NullEmulator) || InFullscreen;
+ OpenRomContextMenuItem.Visible = (Global.Emulator is NullEmulator) || _inFullscreen;
ShowMenuContextMenuItem.Visible =
ShowMenuContextMenuSeparator.Visible =
- InFullscreen;
+ _inFullscreen;
LoadLastRomContextMenuItem.Visible =
(Global.Emulator is NullEmulator);
- StopAVContextMenuItem.Visible = CurrAviWriter != null;
+ StopAVContextMenuItem.Visible = _currAviWriter != null;
ContextSeparator_AfterMovie.Visible =
ContextSeparator_AfterUndo.Visible =
@@ -1819,7 +1761,7 @@ namespace BizHawk.Client.EmuHawk
AddSubtitleContextMenuItem.Visible = !(Global.Emulator is NullEmulator) && Global.MovieSession.Movie.IsActive && Global.ReadOnly;
- ConfigContextMenuItem.Visible = InFullscreen;
+ ConfigContextMenuItem.Visible = _inFullscreen;
ClearSRAMContextMenuItem.Visible = File.Exists(PathManager.SaveRamPath(Global.Game));
@@ -1852,14 +1794,14 @@ namespace BizHawk.Client.EmuHawk
if (file.Exists)
{
UndoSavestateContextMenuItem.Enabled = true;
- if (StateSlots.IsRedo(Global.Config.SaveSlot))
+ if (_stateSlots.IsRedo(Global.Config.SaveSlot))
{
- UndoSavestateContextMenuItem.Text = "Redo Save to slot " + Global.Config.SaveSlot.ToString();
+ UndoSavestateContextMenuItem.Text = "Redo Save to slot " + Global.Config.SaveSlot;
UndoSavestateContextMenuItem.Image = Properties.Resources.redo;
}
else
{
- UndoSavestateContextMenuItem.Text = "Undo Save to slot " + Global.Config.SaveSlot.ToString();
+ UndoSavestateContextMenuItem.Text = "Undo Save to slot " + Global.Config.SaveSlot;
UndoSavestateContextMenuItem.Image = Properties.Resources.undo;
}
}
@@ -1870,22 +1812,15 @@ namespace BizHawk.Client.EmuHawk
UndoSavestateContextMenuItem.Image = Properties.Resources.undo;
}
- if (InFullscreen)
+ if (_inFullscreen)
{
- if (MainMenuStrip.Visible)
- {
- ShowMenuContextMenuItem.Text = "Hide Menu";
- }
- else
- {
- ShowMenuContextMenuItem.Text = "Show Menu";
- }
+ ShowMenuContextMenuItem.Text = MainMenuStrip.Visible ? "Hide Menu" : "Show Menu";
}
}
private void MainFormContextMenu_Closing(object sender, ToolStripDropDownClosingEventArgs e)
{
- if (!wasPaused)
+ if (!_wasPaused)
{
UnpauseEmulator();
}
@@ -1911,7 +1846,7 @@ namespace BizHawk.Client.EmuHawk
{
if (Global.MovieSession.Movie.IsActive)
{
- EditSubtitlesForm form = new EditSubtitlesForm { ReadOnly = Global.ReadOnly };
+ var form = new EditSubtitlesForm { ReadOnly = Global.ReadOnly };
form.GetMovie(Global.MovieSession.Movie);
form.ShowDialog();
}
@@ -1919,11 +1854,11 @@ namespace BizHawk.Client.EmuHawk
private void AddSubtitleContextMenuItem_Click(object sender, EventArgs e)
{
- SubtitleMaker subForm = new SubtitleMaker();
+ var subForm = new SubtitleMaker();
subForm.DisableFrame();
int index = -1;
- Subtitle sub = new Subtitle();
+ var sub = new Subtitle();
for (int x = 0; x < Global.MovieSession.Movie.Subtitles.Count; x++)
{
sub = Global.MovieSession.Movie.Subtitles[x];
@@ -1956,7 +1891,7 @@ namespace BizHawk.Client.EmuHawk
{
if (Global.MovieSession.Movie.IsActive)
{
- EditCommentsForm form = new EditCommentsForm();
+ var form = new EditCommentsForm();
form.GetMovie(Global.MovieSession.Movie);
form.ShowDialog();
}
@@ -1976,7 +1911,7 @@ namespace BizHawk.Client.EmuHawk
private void ClearSRAMContextMenuItem_Click(object sender, EventArgs e)
{
- CloseROM(clearSRAM: true);
+ CloseRom(clearSram: true);
}
private void ShowMenuContextMenuItem_Click(object sender, EventArgs e)
@@ -2015,7 +1950,7 @@ namespace BizHawk.Client.EmuHawk
if (e.Button == MouseButtons.Left)
{
- if (StateSlots.HasSlot(slot))
+ if (_stateSlots.HasSlot(slot))
{
LoadState("QuickSave" + slot);
}
@@ -2060,11 +1995,11 @@ namespace BizHawk.Client.EmuHawk
{
if (!Global.Config.RunInBackground)
{
- if (!wasPaused)
+ if (!_wasPaused)
{
UnpauseEmulator();
}
- wasPaused = false;
+ _wasPaused = false;
}
}
@@ -2074,7 +2009,7 @@ namespace BizHawk.Client.EmuHawk
{
if (EmulatorPaused)
{
- wasPaused = true;
+ _wasPaused = true;
}
PauseEmulator();
}
@@ -2107,7 +2042,7 @@ namespace BizHawk.Client.EmuHawk
protected override void OnClosed(EventArgs e)
{
- exit = true;
+ _exit = true;
base.OnClosed(e);
}
@@ -2121,8 +2056,8 @@ namespace BizHawk.Client.EmuHawk
HandlePlatformMenus();
if (Global.Config.PauseWhenMenuActivated)
{
- wasPaused = EmulatorPaused;
- didMenuPause = true;
+ _wasPaused = EmulatorPaused;
+ _didMenuPause = true;
PauseEmulator();
}
}
@@ -2130,7 +2065,7 @@ namespace BizHawk.Client.EmuHawk
private void MainformMenu_MenuDeactivate(object sender, EventArgs e)
{
GlobalWin.DisplayManager.NeedsToPaint = true;
- if (!wasPaused)
+ if (!_wasPaused)
{
UnpauseEmulator();
}
@@ -2143,9 +2078,9 @@ namespace BizHawk.Client.EmuHawk
private void FormDragDrop(object sender, DragEventArgs e)
{
- string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
- bool isLua = false;
- foreach (string path in filePaths)
+ var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
+ var isLua = false;
+ foreach (var path in filePaths)
{
var extension = Path.GetExtension(path);
if (extension != null && extension.ToUpper() == ".LUA")
@@ -2196,7 +2131,7 @@ namespace BizHawk.Client.EmuHawk
//tries to open a legacy movie format as if it were a BKM, by importing it
if (CurrentlyOpenRom == null)
{
- OpenROM();
+ OpenRom();
}
else
{
diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs
index f1305db490..1b2876bb19 100644
--- a/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.cs
@@ -69,7 +69,7 @@ namespace BizHawk.Client.EmuHawk
MessageCallback = GlobalWin.OSD.AddMessage,
AskYesNoCallback = StateErrorAskUser
};
- MainWait = new AutoResetEvent(false);
+ _mainWait = new AutoResetEvent(false);
Icon = Properties.Resources.logo;
InitializeComponent();
Global.Game = GameInfo.GetNullGame();
@@ -79,7 +79,7 @@ namespace BizHawk.Client.EmuHawk
DisplayLogWindowMenuItem.Checked = true;
}
- throttle = new Throttle();
+ _throttle = new Throttle();
FFMpeg.FFMpegPath = PathManager.MakeProgramRelativePath(Global.Config.FFMpegPath);
@@ -93,7 +93,7 @@ namespace BizHawk.Client.EmuHawk
//we could background thread this later instead if we wanted to be real clever
NES.BootGodDB.GetDatabaseBytes = () =>
{
- using (HawkFile NesCartFile = new HawkFile(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.7z")).BindFirst())
+ using (var NesCartFile = new HawkFile(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.7z")).BindFirst())
return Util.ReadAllBytes(NesCartFile.GetStream());
};
@@ -179,7 +179,7 @@ namespace BizHawk.Client.EmuHawk
else if (arg.StartsWith("--dump-name="))
cmdDumpName = arg.Substring(arg.IndexOf('=') + 1);
else if (arg.StartsWith("--dump-length="))
- int.TryParse(arg.Substring(arg.IndexOf('=') + 1), out autoDumpLength);
+ int.TryParse(arg.Substring(arg.IndexOf('=') + 1), out _autoDumpLength);
else if (arg.StartsWith("--dump-close"))
autoCloseOnDump = true;
else
@@ -204,16 +204,16 @@ namespace BizHawk.Client.EmuHawk
{
if (Global.Game == null)
{
- OpenROM();
+ OpenRom();
}
else
{
- Movie movie = new Movie(cmdMovie);
+ var movie = new Movie(cmdMovie);
Global.ReadOnly = true;
// if user is dumping and didnt supply dump length, make it as long as the loaded movie
- if (autoDumpLength == 0)
+ if (_autoDumpLength == 0)
{
- autoDumpLength = movie.RawFrames;
+ _autoDumpLength = movie.RawFrames;
}
StartNewMovie(movie, false);
Global.Config.RecentMovies.Add(cmdMovie);
@@ -223,7 +223,7 @@ namespace BizHawk.Client.EmuHawk
{
if (Global.Game == null)
{
- OpenROM();
+ OpenRom();
}
else
{
@@ -237,7 +237,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (Global.Config.AutoLoadLastSaveSlot && Global.Game != null)
{
- LoadState("QuickSave" + Global.Config.SaveSlot.ToString());
+ LoadState("QuickSave" + Global.Config.SaveSlot);
}
if (Global.Config.RecentWatches.AutoLoad)
@@ -270,7 +270,7 @@ namespace BizHawk.Client.EmuHawk
}
if (Global.Config.NESGGAutoload && Global.Emulator is NES)
{
- LoadGameGenieEC();
+ LoadGameGenieEc();
}
if (Global.Config.AutoLoadGBGPUView && Global.Emulator is Gameboy)
{
@@ -336,7 +336,7 @@ namespace BizHawk.Client.EmuHawk
UpdateStatusSlots();
- renderTarget.Paint += (o, e) =>
+ _renderTarget.Paint += (o, e) =>
{
GlobalWin.DisplayManager.NeedsToPaint = true;
};
@@ -380,8 +380,10 @@ namespace BizHawk.Client.EmuHawk
if (GlobalWin.DisplayManager.NeedsToPaint) { Render(); }
CheckMessages();
- if (exit)
+ if (_exit)
+ {
break;
+ }
Thread.Sleep(0);
}
@@ -423,6 +425,12 @@ namespace BizHawk.Client.EmuHawk
#region Public Methods
+ public void FlagNeedsReboot()
+ {
+ RebootStatusBarIcon.Visible = true;
+ GlobalWin.OSD.AddMessage("Core reboot needed for this setting");
+ }
+
///
/// Controls whether the app generates input events. should be turned off for most modal dialogs
///
@@ -469,7 +477,7 @@ namespace BizHawk.Client.EmuHawk
{
if (ie.LogicalButton.Alt && ie.LogicalButton.Button.Length == 1)
{
- char c = ie.LogicalButton.Button.ToLower()[0];
+ var c = ie.LogicalButton.Button.ToLower()[0];
if (c >= 'a' && c <= 'z' || c == ' ')
{
SendAltKeyChar(c);
@@ -628,7 +636,7 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.OSD.AddMessage(fi.Name + " saved.");
}
- public void LoadGameGenieEC()
+ public void LoadGameGenieEc()
{
if (Global.Emulator is NES)
{
@@ -665,8 +673,8 @@ namespace BizHawk.Client.EmuHawk
int zoom = Global.Config.TargetZoomFactor;
var area = Screen.FromControl(this).WorkingArea;
- int borderWidth = Size.Width - renderTarget.Size.Width;
- int borderHeight = Size.Height - renderTarget.Size.Height;
+ int borderWidth = Size.Width - _renderTarget.Size.Width;
+ int borderHeight = Size.Height - _renderTarget.Size.Height;
// start at target zoom and work way down until we find acceptable zoom
for (; zoom >= 1; zoom--)
@@ -694,7 +702,7 @@ namespace BizHawk.Client.EmuHawk
public void ToggleFullscreen()
{
- if (InFullscreen == false)
+ if (_inFullscreen == false)
{
_windowed_location = Location;
FormBorderStyle = FormBorderStyle.None;
@@ -706,7 +714,7 @@ namespace BizHawk.Client.EmuHawk
MainStatusBar.Visible = false;
PerformLayout();
GlobalWin.RenderPanel.Resized = true;
- InFullscreen = true;
+ _inFullscreen = true;
}
else
{
@@ -717,7 +725,7 @@ namespace BizHawk.Client.EmuHawk
Location = _windowed_location;
PerformLayout();
FrameBufferResized();
- InFullscreen = false;
+ _inFullscreen = false;
}
}
@@ -742,7 +750,7 @@ namespace BizHawk.Client.EmuHawk
LogWindowAsConsoleMenuItem.Enabled = true;
}
- public void SetNESSoundChannels()
+ public void SetNesSoundChannels()
{
NES nes = Global.Emulator as NES;
nes.SetSquare1(Global.Config.NESSquare1);
@@ -772,7 +780,7 @@ namespace BizHawk.Client.EmuHawk
public void FrameSkipMessage()
{
- GlobalWin.OSD.AddMessage("Frameskipping set to " + Global.Config.FrameSkip.ToString());
+ GlobalWin.OSD.AddMessage("Frameskipping set to " + Global.Config.FrameSkip);
}
public void UpdateCheatStatus()
@@ -793,238 +801,166 @@ namespace BizHawk.Client.EmuHawk
public void SNES_ToggleBG1(bool? setto = null)
{
- if (Global.Emulator is LibsnesCore)
+ if (!(Global.Emulator is LibsnesCore)) return;
+ if (setto.HasValue)
{
- if (setto.HasValue)
- {
- Global.Config.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_0 = setto.Value;
- }
- else
- {
- Global.Config.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_0 ^= true;
- }
-
- CoreFileProvider.SyncCoreCommInputSignals();
- if (Global.Config.SNES_ShowBG1_1)
- {
- GlobalWin.OSD.AddMessage("BG 1 Layer On");
- }
- else
- {
- GlobalWin.OSD.AddMessage("BG 1 Layer Off");
- }
+ Global.Config.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_0 = setto.Value;
}
+ else
+ {
+ Global.Config.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_0 ^= true;
+ }
+
+ CoreFileProvider.SyncCoreCommInputSignals();
+ GlobalWin.OSD.AddMessage(Global.Config.SNES_ShowBG1_1 ? "BG 1 Layer On" : "BG 1 Layer Off");
}
public void SNES_ToggleBG2(bool? setto = null)
{
- if (Global.Emulator is LibsnesCore)
+ if (!(Global.Emulator is LibsnesCore)) return;
+ if (setto.HasValue)
{
- if (setto.HasValue)
- {
- Global.Config.SNES_ShowBG2_1 = Global.Config.SNES_ShowBG2_0 = setto.Value;
- }
- else
- {
- Global.Config.SNES_ShowBG2_1 = Global.Config.SNES_ShowBG2_0 ^= true;
- }
- CoreFileProvider.SyncCoreCommInputSignals();
- if (Global.Config.SNES_ShowBG2_1)
- {
- GlobalWin.OSD.AddMessage("BG 2 Layer On");
- }
- else
- {
- GlobalWin.OSD.AddMessage("BG 2 Layer Off");
- }
+ Global.Config.SNES_ShowBG2_1 = Global.Config.SNES_ShowBG2_0 = setto.Value;
}
+ else
+ {
+ Global.Config.SNES_ShowBG2_1 = Global.Config.SNES_ShowBG2_0 ^= true;
+ }
+ CoreFileProvider.SyncCoreCommInputSignals();
+ GlobalWin.OSD.AddMessage(Global.Config.SNES_ShowBG2_1 ? "BG 2 Layer On" : "BG 2 Layer Off");
}
public void SNES_ToggleBG3(bool? setto = null)
{
- if (Global.Emulator is LibsnesCore)
+ if (!(Global.Emulator is LibsnesCore)) return;
+ if (setto.HasValue)
{
- if (setto.HasValue)
- {
- Global.Config.SNES_ShowBG3_1 = Global.Config.SNES_ShowBG3_0 = setto.Value;
- }
- else
- {
- Global.Config.SNES_ShowBG3_1 = Global.Config.SNES_ShowBG3_0 ^= true;
- }
- CoreFileProvider.SyncCoreCommInputSignals();
- if (Global.Config.SNES_ShowBG3_1)
- {
- GlobalWin.OSD.AddMessage("BG 3 Layer On");
- }
- else
- {
- GlobalWin.OSD.AddMessage("BG 3 Layer Off");
- }
+ Global.Config.SNES_ShowBG3_1 = Global.Config.SNES_ShowBG3_0 = setto.Value;
}
+ else
+ {
+ Global.Config.SNES_ShowBG3_1 = Global.Config.SNES_ShowBG3_0 ^= true;
+ }
+ CoreFileProvider.SyncCoreCommInputSignals();
+ GlobalWin.OSD.AddMessage(Global.Config.SNES_ShowBG3_1 ? "BG 3 Layer On" : "BG 3 Layer Off");
}
public void SNES_ToggleBG4(bool? setto = null)
{
- if (Global.Emulator is LibsnesCore)
+ if (!(Global.Emulator is LibsnesCore)) return;
+ if (setto.HasValue)
{
- if (setto.HasValue)
- {
- Global.Config.SNES_ShowBG4_1 = Global.Config.SNES_ShowBG4_0 = setto.Value;
- }
- else
- {
- Global.Config.SNES_ShowBG4_1 = Global.Config.SNES_ShowBG4_0 ^= true;
- }
- CoreFileProvider.SyncCoreCommInputSignals();
- if (Global.Config.SNES_ShowBG4_1)
- {
- GlobalWin.OSD.AddMessage("BG 4 Layer On");
- }
- else
- {
- GlobalWin.OSD.AddMessage("BG 4 Layer Off");
- }
+ Global.Config.SNES_ShowBG4_1 = Global.Config.SNES_ShowBG4_0 = setto.Value;
}
+ else
+ {
+ Global.Config.SNES_ShowBG4_1 = Global.Config.SNES_ShowBG4_0 ^= true;
+ }
+ CoreFileProvider.SyncCoreCommInputSignals();
+ GlobalWin.OSD.AddMessage(Global.Config.SNES_ShowBG4_1 ? "BG 4 Layer On" : "BG 4 Layer Off");
}
public void SNES_ToggleOBJ1(bool? setto = null)
{
- if (Global.Emulator is LibsnesCore)
+ if (!(Global.Emulator is LibsnesCore)) return;
+ if (setto.HasValue)
{
- if (setto.HasValue)
- {
- Global.Config.SNES_ShowOBJ1 = setto.Value;
- }
- else
- {
- Global.Config.SNES_ShowOBJ1 ^= true;
- }
- CoreFileProvider.SyncCoreCommInputSignals();
- if (Global.Config.SNES_ShowOBJ1)
- {
- GlobalWin.OSD.AddMessage("OBJ 1 Layer On");
- }
- else
- {
- GlobalWin.OSD.AddMessage("OBJ 1 Layer Off");
- }
+ Global.Config.SNES_ShowOBJ1 = setto.Value;
}
+ else
+ {
+ Global.Config.SNES_ShowOBJ1 ^= true;
+ }
+ CoreFileProvider.SyncCoreCommInputSignals();
+ GlobalWin.OSD.AddMessage(Global.Config.SNES_ShowOBJ1 ? "OBJ 1 Layer On" : "OBJ 1 Layer Off");
}
public void SNES_ToggleOBJ2(bool? setto = null)
{
- if (Global.Emulator is LibsnesCore)
+ if (!(Global.Emulator is LibsnesCore)) return;
+ if (setto.HasValue)
{
- if (setto.HasValue)
- {
- Global.Config.SNES_ShowOBJ2 = setto.Value;
- }
- else
- {
- Global.Config.SNES_ShowOBJ2 ^= true;
- }
- CoreFileProvider.SyncCoreCommInputSignals();
- if (Global.Config.SNES_ShowOBJ2)
- {
- GlobalWin.OSD.AddMessage("OBJ 2 Layer On");
- }
- else
- {
- GlobalWin.OSD.AddMessage("OBJ 2 Layer Off");
- }
+ Global.Config.SNES_ShowOBJ2 = setto.Value;
}
+ else
+ {
+ Global.Config.SNES_ShowOBJ2 ^= true;
+ }
+ CoreFileProvider.SyncCoreCommInputSignals();
+ GlobalWin.OSD.AddMessage(Global.Config.SNES_ShowOBJ2 ? "OBJ 2 Layer On" : "OBJ 2 Layer Off");
}
public void SNES_ToggleOBJ3(bool? setto = null)
{
- if (Global.Emulator is LibsnesCore)
+ if (!(Global.Emulator is LibsnesCore)) return;
+ if (setto.HasValue)
{
- if (setto.HasValue)
- {
- Global.Config.SNES_ShowOBJ3 = setto.Value;
- }
- else
- {
- Global.Config.SNES_ShowOBJ3 ^= true;
- }
- CoreFileProvider.SyncCoreCommInputSignals();
- if (Global.Config.SNES_ShowOBJ3)
- {
- GlobalWin.OSD.AddMessage("OBJ 3 Layer On");
- }
- else
- {
- GlobalWin.OSD.AddMessage("OBJ 3 Layer Off");
- }
+ Global.Config.SNES_ShowOBJ3 = setto.Value;
}
+ else
+ {
+ Global.Config.SNES_ShowOBJ3 ^= true;
+ }
+ CoreFileProvider.SyncCoreCommInputSignals();
+ GlobalWin.OSD.AddMessage(Global.Config.SNES_ShowOBJ3 ? "OBJ 3 Layer On" : "OBJ 3 Layer Off");
}
public void SNES_ToggleOBJ4(bool? setto = null)
{
- if (Global.Emulator is LibsnesCore)
+ if (!(Global.Emulator is LibsnesCore)) return;
+ if (setto.HasValue)
{
- if (setto.HasValue)
- {
- Global.Config.SNES_ShowOBJ4 = setto.Value;
- }
- else
- {
- Global.Config.SNES_ShowOBJ4 ^= true;
- }
- CoreFileProvider.SyncCoreCommInputSignals();
- if (Global.Config.SNES_ShowOBJ4)
- {
- GlobalWin.OSD.AddMessage("OBJ 4 Layer On");
- }
- else
- {
- GlobalWin.OSD.AddMessage("OBJ 4 Layer Off");
- }
+ Global.Config.SNES_ShowOBJ4 = setto.Value;
}
+ else
+ {
+ Global.Config.SNES_ShowOBJ4 ^= true;
+ }
+ CoreFileProvider.SyncCoreCommInputSignals();
+ GlobalWin.OSD.AddMessage(Global.Config.SNES_ShowOBJ4 ? "OBJ 4 Layer On" : "OBJ 4 Layer Off");
}
#endregion
#region Private variables
- private int lastWidth = -1;
- private int lastHeight = -1;
- private Control renderTarget;
- private RetainedViewportPanel retainedPanel;
- private readonly SaveSlotManager StateSlots = new SaveSlotManager();
- private readonly Dictionary SNES_prepared = new Dictionary();
+ private int _lastWidth = -1;
+ private int _lastHeight = -1;
+ private Control _renderTarget;
+ private RetainedViewportPanel _retainedPanel;
+ private readonly SaveSlotManager _stateSlots = new SaveSlotManager();
+ private readonly Dictionary _snesPrepared = new Dictionary();
//avi/wav state
- private IVideoWriter CurrAviWriter;
- private ISoundProvider AviSoundInput;
- private MetaspuSoundProvider DumpProxy; //an audio proxy used for dumping
- private long SoundRemainder; //audio timekeeping for video dumping
- private int avwriter_resizew;
- private int avwriter_resizeh;
- private EventWaitHandle MainWait;
- private bool exit;
- private bool runloop_frameProgress;
+ private IVideoWriter _currAviWriter;
+ private ISoundProvider _aviSoundInput;
+ private MetaspuSoundProvider _dumpProxy; //an audio proxy used for dumping
+ private long _soundRemainder; //audio timekeeping for video dumping
+ private int _avwriterResizew;
+ private int _avwriterResizeh;
+ private EventWaitHandle _mainWait;
+ private bool _exit;
+ private bool _runloopFrameProgress;
private DateTime FrameAdvanceTimestamp = DateTime.MinValue;
- private int runloop_fps;
- private int runloop_last_fps;
- private bool runloop_frameadvance;
- private DateTime runloop_second;
- private bool runloop_last_ff;
+ private int _runloopFps;
+ private int _runloopLastFps;
+ private bool _runloopFrameadvance;
+ private DateTime _runloopSecond;
+ private bool _runloopLastFf;
- private readonly Throttle throttle;
- private bool unthrottled;
+ private readonly Throttle _throttle;
+ private bool _unthrottled;
//For handling automatic pausing when entering the menu
- private bool wasPaused;
- private bool didMenuPause;
+ private bool _wasPaused;
+ private bool _didMenuPause;
- private bool InFullscreen;
+ private bool _inFullscreen;
private Point _windowed_location;
- private int autoDumpLength;
- private bool autoCloseOnDump = false;
- private int LastOpenRomFilter;
+ private int _autoDumpLength;
+ private readonly bool autoCloseOnDump;
+ private int _lastOpenRomFilter;
// workaround for possible memory leak in SysdrawingRenderPanel
private RetainedViewportPanel captureosd_rvp;
@@ -1033,21 +969,7 @@ namespace BizHawk.Client.EmuHawk
#endregion
#region Private methods
-
- private void UpdateToolsBefore(bool fromLua = false)
- {
- if (GlobalWin.Tools.Has())
- {
- if (!fromLua)
- {
- GlobalWin.Tools.LuaConsole.StartLuaDrawing();
- }
- GlobalWin.Tools.LuaConsole.LuaImp.CallFrameBeforeEvent();
- }
- GlobalWin.Tools.UpdateBefore();
- }
-
- private void UpdateToolsLoadstate()
+ private static void UpdateToolsLoadstate()
{
if (GlobalWin.Tools.Has())
{
@@ -1057,26 +979,11 @@ namespace BizHawk.Client.EmuHawk
private void UpdateToolsAfter(bool fromLua = false)
{
- if (!fromLua && GlobalWin.Tools.Has())
- {
- GlobalWin.Tools.LuaConsole.ResumeScripts(true);
- }
-
- GlobalWin.Tools.UpdateAfter();
+ GlobalWin.Tools.UpdateToolsAfter(fromLua);
HandleToggleLight();
-
- if (GlobalWin.Tools.Has())
- {
- GlobalWin.Tools.LuaConsole.LuaImp.CallFrameAfterEvent();
- if (!fromLua)
- {
- GlobalWin.DisplayManager.PreFrameUpdateLuaSource();
- GlobalWin.Tools.LuaConsole.EndLuaDrawing();
- }
- }
}
- private void ClearAutohold()
+ private static void ClearAutohold()
{
Global.StickyXORAdapter.ClearStickies();
Global.AutofireStickyXORAdapter.ClearStickies();
@@ -1098,8 +1005,8 @@ namespace BizHawk.Client.EmuHawk
return false;
case "Pause": TogglePause(); break;
case "Toggle Throttle":
- unthrottled ^= true;
- GlobalWin.OSD.AddMessage("Unthrottled: " + unthrottled);
+ _unthrottled ^= true;
+ GlobalWin.OSD.AddMessage("Unthrottled: " + _unthrottled);
break;
case "Soft Reset": SoftReset(); break;
case "Hard Reset": HardReset(); break;
@@ -1108,8 +1015,8 @@ namespace BizHawk.Client.EmuHawk
case "Clear Autohold": ClearAutohold(); break;
case "Screenshot": TakeScreenshot(); break;
case "Full Screen": ToggleFullscreen(); break;
- case "Open ROM": OpenROM(); break;
- case "Close ROM": CloseROM(); break;
+ case "Open ROM": OpenRom(); break;
+ case "Close ROM": CloseRom(); break;
case "Display FPS": ToggleFPS(); break;
case "Frame Counter": ToggleFrameCounter(); break;
case "Lag Counter": ToggleLagCounter(); break;
@@ -1166,7 +1073,6 @@ namespace BizHawk.Client.EmuHawk
case "Previous Slot": PreviousSlot(); break;
case "Next Slot": NextSlot(); break;
-
case "Toggle read-only": ToggleReadOnly(); break;
case "Play Movie": LoadPlayMovieDialog(); break;
case "Record Movie": LoadRecordMovieDialog(); break;
@@ -1222,7 +1128,7 @@ namespace BizHawk.Client.EmuHawk
{
Global.MovieSession.MultiTrack.CurrentPlayer = 1;
}
- GlobalWin.OSD.MT = "Recording Player " + Global.MovieSession.MultiTrack.CurrentPlayer.ToString();
+ GlobalWin.OSD.MT = "Recording Player " + Global.MovieSession.MultiTrack.CurrentPlayer;
GlobalWin.DisplayManager.NeedsToPaint = true;
break;
case "MT Decrement Player":
@@ -1232,7 +1138,7 @@ namespace BizHawk.Client.EmuHawk
{
Global.MovieSession.MultiTrack.CurrentPlayer = 5;//TODO: Replace with console's maximum or current maximum players??!
}
- GlobalWin.OSD.MT = "Recording Player " + Global.MovieSession.MultiTrack.CurrentPlayer.ToString();
+ GlobalWin.OSD.MT = "Recording Player " + Global.MovieSession.MultiTrack.CurrentPlayer;
GlobalWin.DisplayManager.NeedsToPaint = true;
break;
case "Movie Poke": ToggleModePokeMode(); break;
@@ -1334,7 +1240,7 @@ namespace BizHawk.Client.EmuHawk
DumpStatusButton.ToolTipText = annotation;
}
- private void LoadSaveRam()
+ private static void LoadSaveRam()
{
try //zero says: this is sort of sketchy... but this is no time for rearchitecting
{
@@ -1357,19 +1263,22 @@ namespace BizHawk.Client.EmuHawk
private static void SaveRam()
{
- string path = PathManager.SaveRamPath(Global.Game);
-
+ var path = PathManager.SaveRamPath(Global.Game);
var f = new FileInfo(path);
if (f.Directory != null && f.Directory.Exists == false)
+ {
f.Directory.Create();
+ }
//Make backup first
if (Global.Config.BackupSaveram && f.Exists)
{
- string backup = path + ".bak";
+ var backup = path + ".bak";
var backupFile = new FileInfo(backup);
if (backupFile.Exists)
+ {
backupFile.Delete();
+ }
f.CopyTo(backup);
}
@@ -1394,11 +1303,11 @@ namespace BizHawk.Client.EmuHawk
private void RewireSound()
{
- if (DumpProxy != null)
+ if (_dumpProxy != null)
{
// we're video dumping, so async mode only and use the DumpProxy.
// note that the avi dumper has already rewired the emulator itself in this case.
- GlobalWin.Sound.SetAsyncInputPin(DumpProxy);
+ GlobalWin.Sound.SetAsyncInputPin(_dumpProxy);
}
else if (Global.Config.SoundThrottle)
{
@@ -1421,23 +1330,25 @@ namespace BizHawk.Client.EmuHawk
}
}
- private static Controller BindToDefinition(ControllerDefinition def, Dictionary> allbinds, Dictionary> analogbinds)
+ private static Controller BindToDefinition(ControllerDefinition def, IDictionary> allbinds, IDictionary> analogbinds)
{
var ret = new Controller(def);
Dictionary binds;
if (allbinds.TryGetValue(def.Name, out binds))
{
- foreach (string cbutton in def.BoolButtons)
+ foreach (var cbutton in def.BoolButtons)
{
string bind;
if (binds.TryGetValue(cbutton, out bind))
+ {
ret.BindMulti(cbutton, bind);
+ }
}
}
Dictionary abinds;
if (analogbinds.TryGetValue(def.Name, out abinds))
{
- foreach (string cbutton in def.FloatControls)
+ foreach (var cbutton in def.FloatControls)
{
Config.AnalogBind bind;
if (abinds.TryGetValue(cbutton, out bind))
@@ -1449,17 +1360,19 @@ namespace BizHawk.Client.EmuHawk
return ret;
}
- private static AutofireController BindToDefinitionAF(ControllerDefinition def, Dictionary> allbinds)
+ private static AutofireController BindToDefinitionAF(ControllerDefinition def, IDictionary> allbinds)
{
var ret = new AutofireController(def);
Dictionary binds;
if (allbinds.TryGetValue(def.Name, out binds))
{
- foreach (string cbutton in def.BoolButtons)
+ foreach (var cbutton in def.BoolButtons)
{
string bind;
if (binds.TryGetValue(cbutton, out bind))
+ {
ret.BindMulti(cbutton, bind);
+ }
}
}
return ret;
@@ -1487,7 +1400,7 @@ namespace BizHawk.Client.EmuHawk
private void HandlePlatformMenus()
{
- string system = String.Empty;
+ var system = String.Empty;
if (Global.Game != null)
{
@@ -1519,7 +1432,7 @@ namespace BizHawk.Client.EmuHawk
break;
case "NES":
NESSubMenu.Visible = true;
- NESSpecialMenuControls();
+ NesSpecialMenuControls();
break;
case "PCE":
case "PCECD":
@@ -1568,9 +1481,9 @@ namespace BizHawk.Client.EmuHawk
}
}
- private string DisplayNameForSystem(string system)
+ private static string DisplayNameForSystem(string system)
{
- string str = String.Empty;
+ var str = String.Empty;
switch (system)
{
case "INTV": str = "Intellivision"; break;
@@ -1596,11 +1509,15 @@ namespace BizHawk.Client.EmuHawk
case "DGB": str = "Game Boy Link"; break;
}
- if (VersionInfo.INTERIM) str += " (interim)";
+ if (VersionInfo.INTERIM)
+ {
+ str += " (interim)";
+ }
+
return str;
}
- private void InitControls()
+ private static void InitControls()
{
var controls = new Controller(
new ControllerDefinition
@@ -1620,21 +1537,23 @@ namespace BizHawk.Client.EmuHawk
}
- private bool IsValidMovieExtension(string ext)
+ private static bool IsValidMovieExtension(string ext)
{
if (ext.ToUpper() == "." + Global.Config.MovieExtension)
+ {
return true;
- else if (ext.ToUpper() == ".TAS")
- return true;
- else if (ext.ToUpper() == ".BKM")
+ }
+ else if (ext.ToUpper() == ".TAS" || ext.ToUpper() == ".BKM")
+ {
return true;
+ }
return false;
}
private void LoadMoviesFromRecent(string path)
{
- Movie movie = new Movie(path);
+ var movie = new Movie(path);
if (!movie.Loaded)
{
@@ -1684,16 +1603,16 @@ namespace BizHawk.Client.EmuHawk
private string SNES_Prepare(string profile)
{
SNES_Check(profile);
- if (SNES_prepared[profile] == null)
+ if (_snesPrepared[profile] == null)
{
throw new InvalidOperationException("Couldn't locate the executable for SNES emulation for profile: " + profile + ". Please make sure you're using a fresh dearchive of a BizHawk distribution.");
}
- return SNES_prepared[profile];
+ return _snesPrepared[profile];
}
private void SNES_Check(string profile)
{
- if (SNES_prepared.ContainsKey(profile)) return;
+ if (_snesPrepared.ContainsKey(profile)) return;
const string bits = "32";
@@ -1701,17 +1620,21 @@ namespace BizHawk.Client.EmuHawk
//if (Win32.Is64BitOperatingSystem)
// bits = "64";
- string exename = "libsneshawk-" + bits + "-" + profile.ToLower() + ".exe";
+ var exename = "libsneshawk-" + bits + "-" + profile.ToLower() + ".exe";
+ var thisDir = PathManager.GetExeDirectoryAbsolute();
+ var exePath = Path.Combine(thisDir, exename);
- string thisDir = PathManager.GetExeDirectoryAbsolute();
- string exePath = Path.Combine(thisDir, exename);
if (!File.Exists(exePath))
+ {
exePath = Path.Combine(Path.Combine(thisDir, "dll"), exename);
+ }
if (!File.Exists(exePath))
+ {
exePath = null;
+ }
- SNES_prepared[profile] = exePath;
+ _snesPrepared[profile] = exePath;
}
private void SyncPresentationMode()
@@ -1721,41 +1644,41 @@ namespace BizHawk.Client.EmuHawk
#if WINDOWS
bool gdi = Global.Config.DisplayGDI || GlobalWin.Direct3D == null;
#endif
- if (renderTarget != null)
+ if (_renderTarget != null)
{
- renderTarget.Dispose();
- Controls.Remove(renderTarget);
+ _renderTarget.Dispose();
+ Controls.Remove(_renderTarget);
}
- if (retainedPanel != null) retainedPanel.Dispose();
+ if (_retainedPanel != null) _retainedPanel.Dispose();
if (GlobalWin.RenderPanel != null) GlobalWin.RenderPanel.Dispose();
#if WINDOWS
if (gdi)
#endif
- renderTarget = retainedPanel = new RetainedViewportPanel();
+ _renderTarget = _retainedPanel = new RetainedViewportPanel();
#if WINDOWS
- else renderTarget = new ViewportPanel();
+ else _renderTarget = new ViewportPanel();
#endif
- Controls.Add(renderTarget);
- Controls.SetChildIndex(renderTarget, 0);
+ Controls.Add(_renderTarget);
+ Controls.SetChildIndex(_renderTarget, 0);
- renderTarget.Dock = DockStyle.Fill;
- renderTarget.BackColor = Color.Black;
+ _renderTarget.Dock = DockStyle.Fill;
+ _renderTarget.BackColor = Color.Black;
#if WINDOWS
if (gdi)
{
#endif
- GlobalWin.RenderPanel = new SysdrawingRenderPanel(retainedPanel);
- retainedPanel.ActivateThreaded();
+ GlobalWin.RenderPanel = new SysdrawingRenderPanel(_retainedPanel);
+ _retainedPanel.ActivateThreaded();
#if WINDOWS
}
else
{
try
{
- var d3dPanel = new Direct3DRenderPanel(GlobalWin.Direct3D, renderTarget);
+ var d3dPanel = new Direct3DRenderPanel(GlobalWin.Direct3D, _renderTarget);
d3dPanel.CreateDevice();
GlobalWin.RenderPanel = d3dPanel;
}
@@ -1776,21 +1699,21 @@ namespace BizHawk.Client.EmuHawk
{
bool fastforward = Global.ClientControls["Fast Forward"] || FastForward;
bool superfastforward = Global.ClientControls["Turbo"];
- Global.ForceNoThrottle = unthrottled || fastforward;
+ Global.ForceNoThrottle = _unthrottled || fastforward;
// realtime throttle is never going to be so exact that using a double here is wrong
- throttle.SetCoreFps(Global.Emulator.CoreComm.VsyncRate);
+ _throttle.SetCoreFps(Global.Emulator.CoreComm.VsyncRate);
- throttle.signal_paused = EmulatorPaused || Global.Emulator is NullEmulator;
- throttle.signal_unthrottle = unthrottled || superfastforward;
+ _throttle.signal_paused = EmulatorPaused || Global.Emulator is NullEmulator;
+ _throttle.signal_unthrottle = _unthrottled || superfastforward;
if (fastforward)
{
- throttle.SetSpeedPercent(Global.Config.SpeedPercentAlternate);
+ _throttle.SetSpeedPercent(Global.Config.SpeedPercentAlternate);
}
else
{
- throttle.SetSpeedPercent(Global.Config.SpeedPercent);
+ _throttle.SetSpeedPercent(Global.Config.SpeedPercent);
}
}
@@ -1811,21 +1734,23 @@ namespace BizHawk.Client.EmuHawk
private void Shutdown()
{
- if (CurrAviWriter != null)
+ if (_currAviWriter != null)
{
- CurrAviWriter.CloseFile();
- CurrAviWriter = null;
+ _currAviWriter.CloseFile();
+ _currAviWriter = null;
}
}
- private void CheckMessages()
+ private static void CheckMessages()
{
Application.DoEvents();
if (ActiveForm != null)
+ {
ScreenSaver.ResetTimerPeriodically();
+ }
}
- private unsafe Image MakeScreenshotImage()
+ private static unsafe Image MakeScreenshotImage()
{
var video = Global.Emulator.VideoProvider;
var image = new Bitmap(video.BufferWidth, video.BufferHeight, PixelFormat.Format32bppArgb);
@@ -1865,21 +1790,23 @@ namespace BizHawk.Client.EmuHawk
}
var sfd = new SaveFileDialog();
- string path = PathManager.GetSaveStatePath(Global.Game);
+ var path = PathManager.GetSaveStatePath(Global.Game);
sfd.InitialDirectory = path;
sfd.FileName = PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave0.State";
var file = new FileInfo(path);
if (file.Directory != null && file.Directory.Exists == false)
+ {
file.Directory.Create();
+ }
GlobalWin.Sound.StopSound();
var result = sfd.ShowDialog();
GlobalWin.Sound.StartSound();
- if (result != DialogResult.OK)
- return;
-
- SaveStateFile(sfd.FileName, sfd.FileName, false);
+ if (result == DialogResult.OK)
+ {
+ SaveStateFile(sfd.FileName, sfd.FileName, false);
+ }
}
private void LoadStateAs()
@@ -1904,19 +1831,21 @@ namespace BizHawk.Client.EmuHawk
return;
if (File.Exists(ofd.FileName) == false)
+ {
return;
+ }
LoadStateFile(ofd.FileName, Path.GetFileName(ofd.FileName));
}
- private void SaveSlotSelectedMessage()
+ private static void SaveSlotSelectedMessage()
{
GlobalWin.OSD.AddMessage("Slot " + Global.Config.SaveSlot + " selected.");
}
- private VideoPluginSettings N64GenerateVideoSettings(GameInfo game, bool hasmovie)
+ private static VideoPluginSettings N64GenerateVideoSettings(GameInfo game, bool hasmovie)
{
- string PluginToUse = String.Empty;
+ var PluginToUse = String.Empty;
if (hasmovie && Global.MovieSession.Movie.Header.HeaderParams[MovieHeader.PLATFORM] == "N64" && Global.MovieSession.Movie.Header.HeaderParams.ContainsKey(MovieHeader.VIDEOPLUGIN))
{
@@ -1928,7 +1857,7 @@ namespace BizHawk.Client.EmuHawk
PluginToUse = Global.Config.N64VidPlugin;
}
- VideoPluginSettings video_settings = new VideoPluginSettings(PluginToUse, Global.Config.N64VideoSizeX, Global.Config.N64VideoSizeY);
+ var video_settings = new VideoPluginSettings(PluginToUse, Global.Config.N64VideoSizeX, Global.Config.N64VideoSizeY);
if (PluginToUse == "Rice")
{
@@ -1948,12 +1877,12 @@ namespace BizHawk.Client.EmuHawk
if (hasmovie && Global.MovieSession.Movie.Header.HeaderParams[MovieHeader.PLATFORM] == "N64" && Global.MovieSession.Movie.Header.HeaderParams.ContainsKey(MovieHeader.VIDEOPLUGIN))
{
- List settings = new List(video_settings.Parameters.Keys);
- foreach (string setting in settings)
+ var settings = new List(video_settings.Parameters.Keys);
+ foreach (var setting in settings)
{
if (Global.MovieSession.Movie.Header.HeaderParams.ContainsKey(setting))
{
- string Value = Global.MovieSession.Movie.Header.HeaderParams[setting];
+ var Value = Global.MovieSession.Movie.Header.HeaderParams[setting];
if (video_settings.Parameters[setting] is bool)
{
try
@@ -1961,15 +1890,6 @@ namespace BizHawk.Client.EmuHawk
video_settings.Parameters[setting] = bool.Parse(Value);
}
catch { }
- /*
- if (Value == "True")
- {
- video_settings.Parameters[setting] = true;
- }
- else if (Value == "False")
- {
- video_settings.Parameters[setting] = false;
- }*/
}
else if (video_settings.Parameters[setting] is int)
{
@@ -1989,10 +1909,10 @@ namespace BizHawk.Client.EmuHawk
private void Render()
{
var video = Global.Emulator.VideoProvider;
- if (video.BufferHeight != lastHeight || video.BufferWidth != lastWidth)
+ if (video.BufferHeight != _lastHeight || video.BufferWidth != _lastWidth)
{
- lastWidth = video.BufferWidth;
- lastHeight = video.BufferHeight;
+ _lastWidth = video.BufferWidth;
+ _lastHeight = video.BufferHeight;
FrameBufferResized();
}
@@ -2002,7 +1922,7 @@ namespace BizHawk.Client.EmuHawk
//sends a simulation of a plain alt key keystroke
private void SendPlainAltKey(int lparam)
{
- Message m = new Message { WParam = new IntPtr(0xF100), LParam = new IntPtr(lparam), Msg = 0x0112, HWnd = Handle };
+ var m = new Message { WParam = new IntPtr(0xF100), LParam = new IntPtr(lparam), Msg = 0x0112, HWnd = Handle };
base.WndProc(ref m);
}
@@ -2012,22 +1932,22 @@ namespace BizHawk.Client.EmuHawk
typeof(ToolStrip).InvokeMember("ProcessMnemonicInternal", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, null, MainformMenu, new object[] { c });
}
- private string FormatFilter(params string[] args)
+ private static string FormatFilter(params string[] args)
{
var sb = new StringBuilder();
if (args.Length % 2 != 0) throw new ArgumentException();
- int num = args.Length / 2;
+ var num = args.Length / 2;
for (int i = 0; i < num; i++)
{
sb.AppendFormat("{0} ({1})|{1}", args[i * 2], args[i * 2 + 1]);
if (i != num - 1) sb.Append('|');
}
- string str = sb.ToString().Replace("%ARCH%", "*.zip;*.rar;*.7z");
+ var str = sb.ToString().Replace("%ARCH%", "*.zip;*.rar;*.7z");
str = str.Replace(";", "; ");
return str;
}
- private void OpenROM()
+ private void OpenRom()
{
var ofd = new OpenFileDialog { InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId) };
@@ -2081,7 +2001,7 @@ namespace BizHawk.Client.EmuHawk
}
ofd.RestoreDirectory = false;
- ofd.FilterIndex = LastOpenRomFilter;
+ ofd.FilterIndex = _lastOpenRomFilter;
GlobalWin.Sound.StopSound();
var result = ofd.ShowDialog();
@@ -2090,7 +2010,7 @@ namespace BizHawk.Client.EmuHawk
return;
var file = new FileInfo(ofd.FileName);
Global.Config.LastRomPath = file.DirectoryName;
- LastOpenRomFilter = ofd.FilterIndex;
+ _lastOpenRomFilter = ofd.FilterIndex;
LoadRom(file.FullName);
}
@@ -2114,10 +2034,17 @@ namespace BizHawk.Client.EmuHawk
private void PreviousSlot()
{
if (Global.Config.SaveSlot == 0)
- Global.Config.SaveSlot = 9; //Wrap to end of slot list
+ {
+ Global.Config.SaveSlot = 9; //Wrap to end of slot list
+ }
else if (Global.Config.SaveSlot > 9)
- Global.Config.SaveSlot = 9; //Meh, just in case
- else Global.Config.SaveSlot--;
+ {
+ Global.Config.SaveSlot = 9; //Meh, just in case
+ }
+ else
+ {
+ Global.Config.SaveSlot--;
+ }
SaveSlotSelectedMessage();
UpdateStatusSlots();
}
@@ -2125,35 +2052,43 @@ namespace BizHawk.Client.EmuHawk
private void NextSlot()
{
if (Global.Config.SaveSlot >= 9)
- Global.Config.SaveSlot = 0; //Wrap to beginning of slot list
+ {
+ Global.Config.SaveSlot = 0; //Wrap to beginning of slot list
+ }
else if (Global.Config.SaveSlot < 0)
- Global.Config.SaveSlot = 0; //Meh, just in case
- else Global.Config.SaveSlot++;
+ {
+ Global.Config.SaveSlot = 0; //Meh, just in case
+ }
+ else
+ {
+ Global.Config.SaveSlot++;
+ }
+
SaveSlotSelectedMessage();
UpdateStatusSlots();
}
- private void ToggleFPS()
+ private static void ToggleFPS()
{
Global.Config.DisplayFPS ^= true;
}
- private void ToggleFrameCounter()
+ private static void ToggleFrameCounter()
{
Global.Config.DisplayFrameCounter ^= true;
}
- private void ToggleLagCounter()
+ private static void ToggleLagCounter()
{
Global.Config.DisplayLagCounter ^= true;
}
- private void ToggleInputDisplay()
+ private static void ToggleInputDisplay()
{
Global.Config.DisplayInput ^= true;
}
- private void ToggleReadOnly()
+ private static void ToggleReadOnly()
{
if (Global.MovieSession.Movie.IsActive)
{
@@ -2173,25 +2108,29 @@ namespace BizHawk.Client.EmuHawk
}
}
- private void VolumeUp()
+ private static void VolumeUp()
{
Global.Config.SoundVolume += 10;
if (Global.Config.SoundVolume > 100)
+ {
Global.Config.SoundVolume = 100;
+ }
GlobalWin.Sound.ChangeVolume(Global.Config.SoundVolume);
- GlobalWin.OSD.AddMessage("Volume " + Global.Config.SoundVolume.ToString());
+ GlobalWin.OSD.AddMessage("Volume " + Global.Config.SoundVolume);
}
- private void VolumeDown()
+ private static void VolumeDown()
{
Global.Config.SoundVolume -= 10;
if (Global.Config.SoundVolume < 0)
+ {
Global.Config.SoundVolume = 0;
+ }
GlobalWin.Sound.ChangeVolume(Global.Config.SoundVolume);
- GlobalWin.OSD.AddMessage("Volume " + Global.Config.SoundVolume.ToString());
+ GlobalWin.OSD.AddMessage("Volume " + Global.Config.SoundVolume);
}
- private void SoftReset()
+ private static void SoftReset()
{
//is it enough to run this for one frame? maybe..
if (Global.Emulator.ControllerDefinition.BoolButtons.Contains("Reset"))
@@ -2204,7 +2143,7 @@ namespace BizHawk.Client.EmuHawk
}
}
- private void HardReset()
+ private static void HardReset()
{
//is it enough to run this for one frame? maybe..
if (Global.Emulator.ControllerDefinition.BoolButtons.Contains("Power"))
@@ -2219,18 +2158,18 @@ namespace BizHawk.Client.EmuHawk
private void UpdateStatusSlots()
{
- StateSlots.Update();
+ _stateSlots.Update();
- Slot1StatusButton.ForeColor = StateSlots.HasSlot(1) ? Color.Black : Color.Black;
- Slot2StatusButton.ForeColor = StateSlots.HasSlot(2) ? Color.Black : Color.Black;
- Slot3StatusButton.ForeColor = StateSlots.HasSlot(3) ? Color.Black : Color.Black;
- Slot4StatusButton.ForeColor = StateSlots.HasSlot(4) ? Color.Black : Color.Black;
- Slot5StatusButton.ForeColor = StateSlots.HasSlot(5) ? Color.Black : Color.Black;
- Slot6StatusButton.ForeColor = StateSlots.HasSlot(6) ? Color.Black : Color.Black;
- Slot7StatusButton.ForeColor = StateSlots.HasSlot(7) ? Color.Black : Color.Black;
- Slot8StatusButton.ForeColor = StateSlots.HasSlot(8) ? Color.Black : Color.Black;
- Slot9StatusButton.ForeColor = StateSlots.HasSlot(9) ? Color.Black : Color.Black;
- Slot0StatusButton.ForeColor = StateSlots.HasSlot(0) ? Color.Black : Color.Black;
+ Slot1StatusButton.ForeColor = _stateSlots.HasSlot(1) ? Color.Black : Color.Black;
+ Slot2StatusButton.ForeColor = _stateSlots.HasSlot(2) ? Color.Black : Color.Black;
+ Slot3StatusButton.ForeColor = _stateSlots.HasSlot(3) ? Color.Black : Color.Black;
+ Slot4StatusButton.ForeColor = _stateSlots.HasSlot(4) ? Color.Black : Color.Black;
+ Slot5StatusButton.ForeColor = _stateSlots.HasSlot(5) ? Color.Black : Color.Black;
+ Slot6StatusButton.ForeColor = _stateSlots.HasSlot(6) ? Color.Black : Color.Black;
+ Slot7StatusButton.ForeColor = _stateSlots.HasSlot(7) ? Color.Black : Color.Black;
+ Slot8StatusButton.ForeColor = _stateSlots.HasSlot(8) ? Color.Black : Color.Black;
+ Slot9StatusButton.ForeColor = _stateSlots.HasSlot(9) ? Color.Black : Color.Black;
+ Slot0StatusButton.ForeColor = _stateSlots.HasSlot(0) ? Color.Black : Color.Black;
Slot1StatusButton.BackColor = SystemColors.Control;
Slot2StatusButton.BackColor = SystemColors.Control;
@@ -2377,7 +2316,7 @@ namespace BizHawk.Client.EmuHawk
SetSpeedPercent(newp);
}
- private void SaveMovie()
+ private static void SaveMovie()
{
if (Global.MovieSession.Movie.IsActive)
{
@@ -2435,59 +2374,33 @@ namespace BizHawk.Client.EmuHawk
}
}
- private void ToggleModePokeMode()
+ private static void ToggleModePokeMode()
{
Global.Config.MoviePlaybackPokeMode ^= true;
- if (Global.Config.MoviePlaybackPokeMode)
- {
- GlobalWin.OSD.AddMessage("Movie Poke mode enabled");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Movie Poke mode disabled");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.MoviePlaybackPokeMode ? "Movie Poke mode enabled" : "Movie Poke mode disabled");
}
- private void ToggleBackgroundInput()
+ private static void ToggleBackgroundInput()
{
Global.Config.AcceptBackgroundInput ^= true;
- if (Global.Config.AcceptBackgroundInput)
- {
- GlobalWin.OSD.AddMessage("Background Input enabled");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Background Input disabled");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.AcceptBackgroundInput
+ ? "Background Input enabled"
+ : "Background Input disabled");
}
- private void LimitFrameRateMessage()
+ private static void LimitFrameRateMessage()
{
- if (Global.Config.ClockThrottle)
- {
- GlobalWin.OSD.AddMessage("Framerate limiting on");
- }
- else
- {
- GlobalWin.OSD.AddMessage("Framerate limiting off");
- }
+ GlobalWin.OSD.AddMessage(Global.Config.ClockThrottle ? "Framerate limiting on" : "Framerate limiting off");
}
- private void VsyncMessage()
+ private static void VsyncMessage()
{
GlobalWin.OSD.AddMessage(
"Display Vsync set to " + (Global.Config.VSyncThrottle ? "on" : "off")
);
}
- private void MinimizeFrameskipMessage()
- {
- GlobalWin.OSD.AddMessage(
- "Autominimizing set to " + (Global.Config.AutoMinimizeSkipping ? "on" : "off")
- );
- }
-
- private bool StateErrorAskUser(string title, string message)
+ private static bool StateErrorAskUser(string title, string message)
{
var result = MessageBox.Show(message,
title,
@@ -2511,9 +2424,7 @@ namespace BizHawk.Client.EmuHawk
protected override bool ProcessDialogChar(char charCode)
{
//this is necessary to trap alt+char combinations so that only our hotkey system gets them
- if ((ModifierKeys & Keys.Alt) != 0)
- return true;
- else return base.ProcessDialogChar(charCode);
+ return (ModifierKeys & Keys.Alt) != 0 || base.ProcessDialogChar(charCode);
}
#endregion
@@ -2523,16 +2434,16 @@ namespace BizHawk.Client.EmuHawk
private void StepRunLoop_Throttle()
{
SyncThrottle();
- throttle.signal_frameAdvance = runloop_frameadvance;
- throttle.signal_continuousframeAdvancing = runloop_frameProgress;
+ _throttle.signal_frameAdvance = _runloopFrameadvance;
+ _throttle.signal_continuousframeAdvancing = _runloopFrameProgress;
- throttle.Step(true, -1);
+ _throttle.Step(true, -1);
}
private void StepRunLoop_Core()
{
bool runFrame = false;
- runloop_frameadvance = false;
+ _runloopFrameadvance = false;
DateTime now = DateTime.Now;
bool suppressCaptureRewind = false;
@@ -2551,7 +2462,7 @@ namespace BizHawk.Client.EmuHawk
{
PauseEmulator();
runFrame = true;
- runloop_frameadvance = true;
+ _runloopFrameadvance = true;
FrameAdvanceTimestamp = now;
}
else
@@ -2560,7 +2471,7 @@ namespace BizHawk.Client.EmuHawk
if (frameProgressTimeElapsed)
{
runFrame = true;
- runloop_frameProgress = true;
+ _runloopFrameProgress = true;
UnpauseEmulator();
}
}
@@ -2568,9 +2479,9 @@ namespace BizHawk.Client.EmuHawk
else
{
//handle release of frame advance: do we need to deactivate FrameProgress?
- if (runloop_frameProgress)
+ if (_runloopFrameProgress)
{
- runloop_frameProgress = false;
+ _runloopFrameProgress = false;
PauseEmulator();
}
FrameAdvanceTimestamp = DateTime.MinValue;
@@ -2615,32 +2526,32 @@ namespace BizHawk.Client.EmuHawk
{
bool ff = Global.ClientControls["Fast Forward"] || Global.ClientControls["Turbo"];
bool fff = Global.ClientControls["Turbo"];
- bool updateFpsString = (runloop_last_ff != ff);
- runloop_last_ff = ff;
+ bool updateFpsString = (_runloopLastFf != ff);
+ _runloopLastFf = ff;
//client input-related duties
GlobalWin.OSD.ClearGUIText();
if (!fff)
{
- UpdateToolsBefore();
+ GlobalWin.Tools.UpdateToolsBefore();
}
Global.ClickyVirtualPadController.FrameTick();
- runloop_fps++;
+ _runloopFps++;
- if ((DateTime.Now - runloop_second).TotalSeconds > 1)
+ if ((DateTime.Now - _runloopSecond).TotalSeconds > 1)
{
- runloop_last_fps = runloop_fps;
- runloop_second = DateTime.Now;
- runloop_fps = 0;
+ _runloopLastFps = _runloopFps;
+ _runloopSecond = DateTime.Now;
+ _runloopFps = 0;
updateFpsString = true;
}
if (updateFpsString)
{
- string fps_string = runloop_last_fps + " fps";
+ string fps_string = _runloopLastFps + " fps";
if (fff)
{
fps_string += " >>>>";
@@ -2654,16 +2565,16 @@ namespace BizHawk.Client.EmuHawk
if (!suppressCaptureRewind && RewindActive) CaptureRewindState();
- if (!runloop_frameadvance) genSound = true;
+ if (!_runloopFrameadvance) genSound = true;
else if (!Global.Config.MuteFrameAdvance)
genSound = true;
Global.MovieSession.HandleMovieOnFrameLoop();
- coreskipaudio = Global.ClientControls["Turbo"] && CurrAviWriter == null;
+ coreskipaudio = Global.ClientControls["Turbo"] && _currAviWriter == null;
//=======================================
Global.CheatList.Pulse();
- Global.Emulator.FrameAdvance(!throttle.skipnextframe || CurrAviWriter != null, !coreskipaudio);
+ Global.Emulator.FrameAdvance(!_throttle.skipnextframe || _currAviWriter != null, !coreskipaudio);
GlobalWin.DisplayManager.NeedsToPaint = true;
Global.CheatList.Pulse();
//=======================================
@@ -2741,7 +2652,7 @@ namespace BizHawk.Client.EmuHawk
///
private void _RecordAVI(string videowritername, string filename, bool unattended)
{
- if (CurrAviWriter != null) return;
+ if (_currAviWriter != null) return;
// select IVideoWriter to use
IVideoWriter aw = null;
@@ -2761,7 +2672,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
- aw = VideoWriterChooserForm.DoVideoWriterChoserDlg(video_writers, GlobalWin.MainForm, out avwriter_resizew, out avwriter_resizeh);
+ aw = VideoWriterChooserForm.DoVideoWriterChoserDlg(video_writers, GlobalWin.MainForm, out _avwriterResizew, out _avwriterResizeh);
}
foreach (var w in video_writers)
@@ -2782,8 +2693,8 @@ namespace BizHawk.Client.EmuHawk
try
{
aw.SetMovieParameters(Global.Emulator.CoreComm.VsyncNum, Global.Emulator.CoreComm.VsyncDen);
- if (avwriter_resizew > 0 && avwriter_resizeh > 0)
- aw.SetVideoParameters(avwriter_resizew, avwriter_resizeh);
+ if (_avwriterResizew > 0 && _avwriterResizeh > 0)
+ aw.SetVideoParameters(_avwriterResizew, _avwriterResizeh);
else
aw.SetVideoParameters(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight);
aw.SetAudioParameters(44100, 2, 16);
@@ -2839,7 +2750,7 @@ namespace BizHawk.Client.EmuHawk
}
//commit the avi writing last, in case there were any errors earlier
- CurrAviWriter = aw;
+ _currAviWriter = aw;
GlobalWin.OSD.AddMessage("A/V capture started");
AVIStatusLabel.Image = Properties.Resources.AVI;
AVIStatusLabel.ToolTipText = "A/V capture in progress";
@@ -2855,73 +2766,73 @@ namespace BizHawk.Client.EmuHawk
// do sound rewire. the plan is to eventually have AVI writing support syncsound input, but it doesn't for the moment
if (!Global.Emulator.StartAsyncSound())
- AviSoundInput = new MetaspuAsync(Global.Emulator.SyncSoundProvider, ESynchMethod.ESynchMethod_V);
+ _aviSoundInput = new MetaspuAsync(Global.Emulator.SyncSoundProvider, ESynchMethod.ESynchMethod_V);
else
- AviSoundInput = Global.Emulator.SoundProvider;
- DumpProxy = new MetaspuSoundProvider(ESynchMethod.ESynchMethod_V);
- SoundRemainder = 0;
+ _aviSoundInput = Global.Emulator.SoundProvider;
+ _dumpProxy = new MetaspuSoundProvider(ESynchMethod.ESynchMethod_V);
+ _soundRemainder = 0;
RewireSound();
}
private void AbortAVI()
{
- if (CurrAviWriter == null)
+ if (_currAviWriter == null)
{
- DumpProxy = null;
+ _dumpProxy = null;
RewireSound();
return;
}
- CurrAviWriter.Dispose();
- CurrAviWriter = null;
+ _currAviWriter.Dispose();
+ _currAviWriter = null;
GlobalWin.OSD.AddMessage("A/V capture aborted");
AVIStatusLabel.Image = Properties.Resources.Blank;
AVIStatusLabel.ToolTipText = "";
AVIStatusLabel.Visible = false;
- AviSoundInput = null;
- DumpProxy = null; // return to normal sound output
- SoundRemainder = 0;
+ _aviSoundInput = null;
+ _dumpProxy = null; // return to normal sound output
+ _soundRemainder = 0;
RewireSound();
}
private void StopAVI()
{
- if (CurrAviWriter == null)
+ if (_currAviWriter == null)
{
- DumpProxy = null;
+ _dumpProxy = null;
RewireSound();
return;
}
- CurrAviWriter.CloseFile();
- CurrAviWriter.Dispose();
- CurrAviWriter = null;
+ _currAviWriter.CloseFile();
+ _currAviWriter.Dispose();
+ _currAviWriter = null;
GlobalWin.OSD.AddMessage("A/V capture stopped");
AVIStatusLabel.Image = Properties.Resources.Blank;
AVIStatusLabel.ToolTipText = "";
AVIStatusLabel.Visible = false;
- AviSoundInput = null;
- DumpProxy = null; // return to normal sound output
- SoundRemainder = 0;
+ _aviSoundInput = null;
+ _dumpProxy = null; // return to normal sound output
+ _soundRemainder = 0;
RewireSound();
}
private void AVIFrameAdvance()
{
GlobalWin.DisplayManager.NeedsToPaint = true;
- if (CurrAviWriter != null)
+ if (_currAviWriter != null)
{
- long nsampnum = 44100 * (long)Global.Emulator.CoreComm.VsyncDen + SoundRemainder;
+ long nsampnum = 44100 * (long)Global.Emulator.CoreComm.VsyncDen + _soundRemainder;
long nsamp = nsampnum / Global.Emulator.CoreComm.VsyncNum;
// exactly remember fractional parts of an audio sample
- SoundRemainder = nsampnum % Global.Emulator.CoreComm.VsyncNum;
+ _soundRemainder = nsampnum % Global.Emulator.CoreComm.VsyncNum;
short[] temp = new short[nsamp * 2];
- AviSoundInput.GetSamples(temp);
- DumpProxy.buffer.enqueue_samples(temp, (int)nsamp);
+ _aviSoundInput.GetSamples(temp);
+ _dumpProxy.buffer.enqueue_samples(temp, (int)nsamp);
try
{
IVideoProvider output;
- if (avwriter_resizew > 0 && avwriter_resizeh > 0)
+ if (_avwriterResizew > 0 && _avwriterResizeh > 0)
{
Bitmap bmpin;
if (Global.Config.AVI_CaptureOSD)
@@ -2933,7 +2844,7 @@ namespace BizHawk.Client.EmuHawk
System.Runtime.InteropServices.Marshal.Copy(Global.Emulator.VideoProvider.GetVideoBuffer(), 0, lockdata.Scan0, bmpin.Width * bmpin.Height);
bmpin.UnlockBits(lockdata);
}
- Bitmap bmpout = new Bitmap(avwriter_resizew, avwriter_resizeh, PixelFormat.Format32bppArgb);
+ Bitmap bmpout = new Bitmap(_avwriterResizew, _avwriterResizeh, PixelFormat.Format32bppArgb);
using (Graphics g = Graphics.FromImage(bmpout))
g.DrawImage(bmpin, new Rectangle(0, 0, bmpout.Width, bmpout.Height));
bmpin.Dispose();
@@ -2947,11 +2858,11 @@ namespace BizHawk.Client.EmuHawk
output = Global.Emulator.VideoProvider;
}
- CurrAviWriter.AddFrame(output);
+ _currAviWriter.AddFrame(output);
if (output is BmpVideoProvder)
(output as BmpVideoProvder).Dispose();
- CurrAviWriter.AddSamples(temp);
+ _currAviWriter.AddSamples(temp);
}
catch (Exception e)
{
@@ -2959,15 +2870,15 @@ namespace BizHawk.Client.EmuHawk
AbortAVI();
}
- if (autoDumpLength > 0)
+ if (_autoDumpLength > 0)
{
- autoDumpLength--;
- if (autoDumpLength == 0) // finish
+ _autoDumpLength--;
+ if (_autoDumpLength == 0) // finish
{
StopAVI();
if (autoCloseOnDump)
{
- exit = true;
+ _exit = true;
}
}
}
@@ -2979,7 +2890,7 @@ namespace BizHawk.Client.EmuHawk
#region Scheduled for refactor
- private void NESSpeicalMenuAdd(string name, string button, string msg) //TODO: don't do this, put these into the menu but hide them in the dropdownopened event as needed
+ private void NesSpeicalMenuAdd(string name, string button, string msg) //TODO: don't do this, put these into the menu but hide them in the dropdownopened event as needed
{
NESSpecialControlsMenuItem.Visible = true;
NESSpecialControlsMenuItem.DropDownItems.Add(name, null, delegate
@@ -2995,27 +2906,36 @@ namespace BizHawk.Client.EmuHawk
});
}
- private void NESSpecialMenuControls() //Ditto
+ private void NesSpecialMenuControls() //Ditto
{
// ugly and hacky
NESSpecialControlsMenuItem.Visible = false;
NESSpecialControlsMenuItem.DropDownItems.Clear();
var ss = Global.Emulator.ControllerDefinition.BoolButtons;
if (ss.Contains("FDS Eject"))
- NESSpeicalMenuAdd("Eject Disk", "FDS Eject", "FDS Disk Ejected.");
+ {
+ NesSpeicalMenuAdd("Eject Disk", "FDS Eject", "FDS Disk Ejected.");
+ }
+
for (int i = 0; i < 16; i++)
{
- string s = "FDS Insert " + i;
+ var s = "FDS Insert " + i;
if (ss.Contains(s))
- NESSpeicalMenuAdd("Insert Disk " + i, s, "FDS Disk " + i + " inserted.");
+ {
+ NesSpeicalMenuAdd("Insert Disk " + i, s, "FDS Disk " + i + " inserted.");
+ }
}
if (ss.Contains("VS Coin 1"))
- NESSpeicalMenuAdd("Insert Coin 1", "VS Coin 1", "Coin 1 inserted.");
+ {
+ NesSpeicalMenuAdd("Insert Coin 1", "VS Coin 1", "Coin 1 inserted.");
+ }
if (ss.Contains("VS Coin 2"))
- NESSpeicalMenuAdd("Insert Coin 2", "VS Coin 2", "Coin 2 inserted.");
+ {
+ NesSpeicalMenuAdd("Insert Coin 2", "VS Coin 2", "Coin 2 inserted.");
+ }
}
- private void RewireInputChain() //Move to Client.Common
+ private static void RewireInputChain() //Move to Client.Common
{
GlobalWin.ControllerInputCoalescer = new ControllerInputCoalescer { Type = Global.ActiveController.Type };
@@ -3038,12 +2958,16 @@ namespace BizHawk.Client.EmuHawk
//connect the movie session before MovieOutputHardpoint if it is doing anything
//otherwise connect the MovieInputSourceAdapter to it, effectively bypassing the movie session
if (Global.MovieSession.Movie != null)
+ {
Global.MovieOutputHardpoint.Source = Global.MovieSession.MovieControllerAdapter;
+ }
else
+ {
Global.MovieOutputHardpoint.Source = Global.MovieInputSourceAdapter;
+ }
}
- private void SyncControls() //Move to client.comon
+ private static void SyncControls() //Move to client.comon
{
var def = Global.Emulator.ControllerDefinition;
@@ -3062,7 +2986,7 @@ namespace BizHawk.Client.EmuHawk
if (path == null) return false;
using (var file = new HawkFile())
{
- string[] romExtensions = new[] { "SMS", "SMC", "SFC", "PCE", "SGX", "GG", "SG", "BIN", "GEN", "MD", "SMD", "GB", "NES", "FDS", "ROM", "INT", "GBC", "UNF", "A78", "CRT", "COL", "XML", "Z64", "V64", "N64" };
+ var romExtensions = new[] { "SMS", "SMC", "SFC", "PCE", "SGX", "GG", "SG", "BIN", "GEN", "MD", "SMD", "GB", "NES", "FDS", "ROM", "INT", "GBC", "UNF", "A78", "CRT", "COL", "XML", "Z64", "V64", "N64" };
//lets not use this unless we need to
//file.NonArchiveExtensions = romExtensions;
@@ -3089,7 +3013,7 @@ namespace BizHawk.Client.EmuHawk
IEmulator nextEmulator = null;
RomGame rom = null;
GameInfo game = null;
- CoreComm nextComm = new CoreComm();
+ var nextComm = new CoreComm();
CoreFileProvider.SyncCoreCommInputSignals(nextComm);
try
@@ -3097,11 +3021,7 @@ namespace BizHawk.Client.EmuHawk
string ext = file.Extension.ToLower();
if (ext == ".iso" || ext == ".cue")
{
- Disc disc;
- if (ext == ".iso")
- disc = Disc.FromIsoPath(path);
- else
- disc = Disc.FromCuePath(path, new CueBinPrefs());
+ Disc disc = ext == ".iso" ? Disc.FromIsoPath(path) : Disc.FromCuePath(path, new CueBinPrefs());
var hash = disc.GetHash();
game = Database.CheckDatabase(hash);
if (game == null)
@@ -3161,7 +3081,7 @@ namespace BizHawk.Client.EmuHawk
case "PCE":
case "PCECD":
{
- string biosPath = Global.FirmwareManager.Request("PCECD", "Bios");
+ var biosPath = Global.FirmwareManager.Request("PCECD", "Bios");
if (File.Exists(biosPath) == false)
{
MessageBox.Show("PCE-CD System Card not found. Please check the BIOS path in Config->Paths->PC Engine.");
@@ -3217,7 +3137,7 @@ namespace BizHawk.Client.EmuHawk
if (Global.Config.GB_GBACGB) R.AddOption("GBACGB");
if (Global.Config.GB_MulticartCompat) R.AddOption("MulitcartCompat");
- GambatteLink gbl = new GambatteLink(nextComm, L, XMLG.Assets["LeftRom"], R, XMLG.Assets["RightRom"]);
+ var gbl = new GambatteLink(nextComm, L, XMLG.Assets["LeftRom"], R, XMLG.Assets["RightRom"]);
nextEmulator = gbl;
// other stuff todo
break;
@@ -3228,7 +3148,7 @@ namespace BizHawk.Client.EmuHawk
}
catch (Exception ex)
{
- System.Windows.Forms.MessageBox.Show(ex.ToString(), "XMLGame Load Error");
+ MessageBox.Show(ex.ToString(), "XMLGame Load Error");
}
}
else // most extensions
@@ -3301,7 +3221,7 @@ namespace BizHawk.Client.EmuHawk
case "NES":
{
//TODO - move into nes core
- string biosPath = nextComm.CoreFileProvider.PathFirmware("NES", "Bios_FDS");
+ var biosPath = nextComm.CoreFileProvider.PathFirmware("NES", "Bios_FDS");
byte[] bios = null;
if (File.Exists(biosPath))
{
@@ -3310,13 +3230,13 @@ namespace BizHawk.Client.EmuHawk
if (bios.Length == 40976)
{
MessageBox.Show(this, "Your FDS BIOS is a bad dump. BizHawk will attempt to use it, but no guarantees! You should find a new one.");
- byte[] tmp = new byte[8192];
+ var tmp = new byte[8192];
Buffer.BlockCopy(bios, 16 + 8192 * 3, tmp, 0, 8192);
bios = tmp;
}
}
- NES nes = new NES(nextComm, game, rom.FileData, bios, Global.MovieSession.Movie.Header.BoardProperties)
+ var nes = new NES(nextComm, game, rom.FileData, bios, Global.MovieSession.Movie.Header.BoardProperties)
{
SoundOn = Global.Config.SoundEnabled,
NTSC_FirstDrawLine = Global.Config.NTSC_NESTopLine,
@@ -3341,7 +3261,7 @@ namespace BizHawk.Client.EmuHawk
if (Global.Config.GB_ForceDMG) game.AddOption("ForceDMG");
if (Global.Config.GB_GBACGB) game.AddOption("GBACGB");
if (Global.Config.GB_MulticartCompat) game.AddOption("MulitcartCompat");
- Gameboy gb = new Gameboy(nextComm, game, rom.FileData);
+ var gb = new Gameboy(nextComm, game, rom.FileData);
nextEmulator = gb;
if (gb.IsCGBMode())
{
@@ -3351,11 +3271,13 @@ namespace BizHawk.Client.EmuHawk
{
try
{
- using (StreamReader f = new StreamReader(Global.Config.GB_PaletteFile))
+ using (var f = new StreamReader(Global.Config.GB_PaletteFile))
{
int[] colors = ColorChooserForm.LoadPalFile(f);
if (colors != null)
+ {
gb.ChangeDMGColors(colors);
+ }
}
}
catch { }
@@ -3363,7 +3285,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
- string sgbromPath = Global.FirmwareManager.Request("SNES", "Rom_SGB");
+ var sgbromPath = Global.FirmwareManager.Request("SNES", "Rom_SGB");
byte[] sgbrom;
try
{
@@ -3399,8 +3321,8 @@ namespace BizHawk.Client.EmuHawk
//}
break;
case "Coleco":
- string colbiosPath = Global.FirmwareManager.Request("Coleco", "Bios");
- FileInfo colfile = colbiosPath != null ? new FileInfo(colbiosPath) : null;
+ var colbiosPath = Global.FirmwareManager.Request("Coleco", "Bios");
+ var colfile = colbiosPath != null ? new FileInfo(colbiosPath) : null;
if (colfile == null || !colfile.Exists)
{
MessageBox.Show("Unable to find the required ColecoVision BIOS file - \n" + colbiosPath, "Unable to load BIOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -3408,32 +3330,36 @@ namespace BizHawk.Client.EmuHawk
}
else
{
- ColecoVision c = new ColecoVision(nextComm, game, rom.RomData, colbiosPath, Global.Config.ColecoSkipBiosIntro);
+ var c = new ColecoVision(nextComm, game, rom.RomData, colbiosPath, Global.Config.ColecoSkipBiosIntro);
nextEmulator = c;
}
break;
case "INTV":
{
- Intellivision intv = new Intellivision(nextComm, game, rom.RomData);
- string eromPath = Global.FirmwareManager.Request("INTV", "EROM");
+ var intv = new Intellivision(nextComm, game, rom.RomData);
+ var eromPath = Global.FirmwareManager.Request("INTV", "EROM");
if (!File.Exists(eromPath))
+ {
throw new InvalidOperationException("Specified EROM path does not exist:\n\n" + eromPath);
+ }
intv.LoadExecutiveRom(eromPath);
- string gromPath = Global.FirmwareManager.Request("INTV", "GROM");
+ var gromPath = Global.FirmwareManager.Request("INTV", "GROM");
if (!File.Exists(gromPath))
+ {
throw new InvalidOperationException("Specified GROM path does not exist:\n\n" + gromPath);
+ }
intv.LoadGraphicsRom(gromPath);
nextEmulator = intv;
}
break;
case "A78":
- string ntsc_biospath = Global.FirmwareManager.Request("A78", "Bios_NTSC");
- string pal_biospath = Global.FirmwareManager.Request("A78", "Bios_PAL");
- string hsbiospath = Global.FirmwareManager.Request("A78", "Bios_HSC");
+ var ntsc_biospath = Global.FirmwareManager.Request("A78", "Bios_NTSC");
+ var pal_biospath = Global.FirmwareManager.Request("A78", "Bios_PAL");
+ var hsbiospath = Global.FirmwareManager.Request("A78", "Bios_HSC");
- FileInfo ntscfile = ntsc_biospath != null ? new FileInfo(ntsc_biospath) : null;
- FileInfo palfile = pal_biospath != null ? new FileInfo(pal_biospath) : null;
- FileInfo hsfile = hsbiospath != null ? new FileInfo(hsbiospath) : null;
+ var ntscfile = ntsc_biospath != null ? new FileInfo(ntsc_biospath) : null;
+ var palfile = pal_biospath != null ? new FileInfo(pal_biospath) : null;
+ var hsfile = hsbiospath != null ? new FileInfo(hsbiospath) : null;
byte[] NTSC_BIOS7800 = null;
byte[] PAL_BIOS7800 = null;
@@ -3441,7 +3367,6 @@ namespace BizHawk.Client.EmuHawk
if (ntscfile == null || !ntscfile.Exists)
{
MessageBox.Show("Unable to find the required Atari 7800 BIOS file - \n" + ntsc_biospath + "\nIf the selected game requires it, it may crash", "Unable to load BIOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
- //throw new Exception();
}
else
{
@@ -3451,7 +3376,6 @@ namespace BizHawk.Client.EmuHawk
if (palfile == null || !palfile.Exists)
{
MessageBox.Show("Unable to find the required Atari 7800 BIOS file - \n" + pal_biospath + "\nIf the selected game requires it, it may crash", "Unable to load BIOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
- //throw new Exception();
}
else
{
@@ -3468,7 +3392,7 @@ namespace BizHawk.Client.EmuHawk
HighScoreBIOS = File.ReadAllBytes(hsbiospath);
}
- string gamedbpath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "EMU7800.csv");
+ var gamedbpath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "EMU7800.csv");
try
{
var a78 = new Atari7800(nextComm, game, rom.RomData, NTSC_BIOS7800, PAL_BIOS7800, HighScoreBIOS, gamedbpath);
@@ -3488,7 +3412,7 @@ namespace BizHawk.Client.EmuHawk
case "GBA":
if (VersionInfo.INTERIM)
{
- string gbabiospath = Global.FirmwareManager.Request("GBA", "Bios");
+ var gbabiospath = Global.FirmwareManager.Request("GBA", "Bios");
byte[] gbabios;
if (File.Exists(gbabiospath))
@@ -3508,7 +3432,7 @@ namespace BizHawk.Client.EmuHawk
break;
case "N64":
Global.Game = game;
- VideoPluginSettings video_settings = N64GenerateVideoSettings(game, hasmovie);
+ var video_settings = N64GenerateVideoSettings(game, hasmovie);
int SaveType = 0;
if (game.OptionValue("SaveType") == "EEPROM_16K")
{
@@ -3528,8 +3452,6 @@ namespace BizHawk.Client.EmuHawk
return false;
}
- if (nextEmulator == null) throw new Exception("No core could load the rom.");
-
CloseGame();
Global.Emulator.Dispose();
Global.Emulator = nextEmulator;
@@ -3550,7 +3472,7 @@ namespace BizHawk.Client.EmuHawk
if (nes.GameName != null)
Global.Game.Name = nes.GameName;
Global.Game.Status = nes.RomStatus;
- SetNESSoundChannels();
+ SetNesSoundChannels();
}
Text = DisplayNameForSystem(game.System) + " - " + game.Name;
@@ -3600,7 +3522,7 @@ namespace BizHawk.Client.EmuHawk
CurrentlyOpenRom = file.CanonicalFullPath;
HandlePlatformMenus();
- StateSlots.Clear();
+ _stateSlots.Clear();
UpdateStatusSlots();
UpdateDumpIcon();
@@ -3623,19 +3545,23 @@ namespace BizHawk.Client.EmuHawk
return;
}
- string path = PathManager.SaveStatePrefix(Global.Game) + "." + name + ".State";
+ var path = PathManager.SaveStatePrefix(Global.Game) + "." + name + ".State";
var file = new FileInfo(path);
if (file.Directory != null && file.Directory.Exists == false)
+ {
file.Directory.Create();
+ }
//Make backup first
if (Global.Config.BackupSavestates && file.Exists)
{
- string backup = path + ".bak";
+ var backup = path + ".bak";
var backupFile = new FileInfo(backup);
if (backupFile.Exists)
+ {
backupFile.Delete();
+ }
file.CopyTo(backup);
}
@@ -3667,7 +3593,7 @@ namespace BizHawk.Client.EmuHawk
{
SetMainformMovieInfo();
GlobalWin.OSD.ClearGUIText();
- UpdateToolsBefore(fromLua);
+ GlobalWin.Tools.UpdateToolsBefore(fromLua);
UpdateToolsAfter(fromLua);
UpdateToolsLoadstate();
GlobalWin.OSD.AddMessage("Loaded state: " + name);
@@ -3702,16 +3628,16 @@ namespace BizHawk.Client.EmuHawk
//whats the difference between these two methods??
//its very tricky. rename to be more clear or combine them.
- private void CloseGame(bool clearSRAM = false)
+ private void CloseGame(bool clearSram = false)
{
if (Global.Config.AutoSavestates && Global.Emulator is NullEmulator == false)
{
SaveState("Auto");
}
- if (clearSRAM)
+ if (clearSram)
{
- string path = PathManager.SaveRamPath(Global.Game);
+ var path = PathManager.SaveRamPath(Global.Game);
if (File.Exists(path))
{
File.Delete(path);
@@ -3734,11 +3660,11 @@ namespace BizHawk.Client.EmuHawk
RebootStatusBarIcon.Visible = false;
}
- public void CloseROM(bool clearSRAM = false)
+ public void CloseRom(bool clearSram = false)
{
if (GlobalWin.Tools.AskSave())
{
- CloseGame(clearSRAM);
+ CloseGame(clearSram);
Global.CoreComm = new CoreComm();
CoreFileProvider.SyncCoreCommInputSignals();
Global.Emulator = new NullEmulator(Global.CoreComm);
@@ -3751,7 +3677,7 @@ namespace BizHawk.Client.EmuHawk
Cheats_Restart();
Text = "BizHawk" + (VersionInfo.INTERIM ? " (interim) " : String.Empty);
HandlePlatformMenus();
- StateSlots.Clear();
+ _stateSlots.Clear();
UpdateDumpIcon();
}
}
@@ -3774,35 +3700,40 @@ namespace BizHawk.Client.EmuHawk
temp.CopyTo(path);
temp.Delete();
- StateSlots.ToggleRedo(Global.Config.SaveSlot);
+ _stateSlots.ToggleRedo(Global.Config.SaveSlot);
}
- private void ProcessMovieImport(string fn) //Nothing Winform Specific here, move to Movie import
+ private static void ProcessMovieImport(string fn) //Nothing Winform Specific here, move to Movie import
{
- string d = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null);
+ var d = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null);
string errorMsg;
string warningMsg;
- Movie m = MovieImport.ImportFile(fn, out errorMsg, out warningMsg);
- if (errorMsg.Length > 0)
+ var m = MovieImport.ImportFile(fn, out errorMsg, out warningMsg);
+
+ if (!String.IsNullOrWhiteSpace(errorMsg))
+ {
MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- if (warningMsg.Length > 0)
+ }
+
+ if (!String.IsNullOrWhiteSpace(warningMsg))
+ {
GlobalWin.OSD.AddMessage(warningMsg);
+ }
else
+ {
GlobalWin.OSD.AddMessage(Path.GetFileName(fn) + " imported as " + "Movies\\" +
- Path.GetFileName(fn) + "." + Global.Config.MovieExtension);
+ Path.GetFileName(fn) + "." + Global.Config.MovieExtension);
+ }
+
if (!Directory.Exists(d))
+ {
Directory.CreateDirectory(d);
+ }
- string outPath = Path.Combine(d, (Path.GetFileName(fn) + "." + Global.Config.MovieExtension));
+ var outPath = Path.Combine(d, (Path.GetFileName(fn) + "." + Global.Config.MovieExtension));
m.SaveAs(outPath);
}
- public void FlagNeedsReboot() //Make private, config dialogs use it and it can be called after they close
- {
- RebootStatusBarIcon.Visible = true;
- GlobalWin.OSD.AddMessage("Core reboot needed for this setting");
- }
-
#endregion
}
}
diff --git a/BizHawk.Client.EmuHawk/config/GifAnimator.cs b/BizHawk.Client.EmuHawk/config/GifAnimator.cs
index 663662db81..5d7166e589 100644
--- a/BizHawk.Client.EmuHawk/config/GifAnimator.cs
+++ b/BizHawk.Client.EmuHawk/config/GifAnimator.cs
@@ -1,10 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
@@ -72,12 +66,12 @@ namespace BizHawk.Client.EmuHawk
case (10): Global.Config.GifAnimatorSpeed = 32; break;
}
- this.Close();
+ Close();
}
private void button1_Click(object sender, EventArgs e)
{
- this.Close();
+ Close();
}
}
}
diff --git a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs
index 7d978480f9..e14b8b42c0 100644
--- a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs
+++ b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs
@@ -1,10 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
@@ -35,13 +29,12 @@ namespace BizHawk.Client.EmuHawk
private void SaveSettings()
{
//Global
- string video_settings = VideoResolutionComboBox.SelectedItem.ToString();
- string[] strArr = video_settings.Split('x');
+ var video_settings = VideoResolutionComboBox.SelectedItem.ToString();
+ var strArr = video_settings.Split('x');
Global.Config.N64VideoSizeX = Int32.Parse(strArr[0].Trim());
Global.Config.N64VideoSizeY = Int32.Parse(strArr[1].Trim());
Global.Config.N64VidPlugin = PluginComboBox.Text;
- GlobalWin.MainForm.FlagNeedsReboot(); //TODO: this won't always be necessary, keep that in mind
-
+
//Rice
Global.Config.RicePlugin.NormalAlphaBlender = RiceNormalAlphaBlender_CB.Checked;
Global.Config.RicePlugin.FastTextureLoading = RiceFastTextureLoading_CB.Checked;
@@ -144,25 +137,21 @@ namespace BizHawk.Client.EmuHawk
Global.Config.GlidePlugin.disable_auxbuf = Glide_disable_auxbuf.Checked;
Global.Config.GlidePlugin.fb_get_info = Glide_fb_get_info.Checked;
- if (InputValidate.IsValidSignedNumber(Glide_offset_x.Text))
- Global.Config.GlidePlugin.offset_x = int.Parse(Glide_offset_x.Text);
- else
- Global.Config.GlidePlugin.offset_x = 0;
+ Global.Config.GlidePlugin.offset_x =
+ InputValidate.IsValidSignedNumber(Glide_offset_x.Text) ?
+ int.Parse(Glide_offset_x.Text) : 0;
- if (InputValidate.IsValidSignedNumber(Glide_offset_y.Text))
- Global.Config.GlidePlugin.offset_y = int.Parse(Glide_offset_y.Text);
- else
- Global.Config.GlidePlugin.offset_y = 0;
+ Global.Config.GlidePlugin.offset_y =
+ InputValidate.IsValidSignedNumber(Glide_offset_y.Text) ?
+ int.Parse(Glide_offset_y.Text) : 0;
- if (InputValidate.IsValidSignedNumber(Glide_scale_x.Text))
- Global.Config.GlidePlugin.scale_x = int.Parse(Glide_scale_x.Text);
- else
- Global.Config.GlidePlugin.scale_x = 100000;
+ Global.Config.GlidePlugin.scale_x =
+ InputValidate.IsValidSignedNumber(Glide_scale_x.Text) ?
+ int.Parse(Glide_scale_x.Text) : 100000;
- if (InputValidate.IsValidSignedNumber(Glide_scale_y.Text))
- Global.Config.GlidePlugin.scale_y = int.Parse(Glide_scale_y.Text);
- else
- Global.Config.GlidePlugin.scale_y = 100000;
+ Global.Config.GlidePlugin.scale_y =
+ InputValidate.IsValidSignedNumber(Glide_scale_y.Text) ?
+ int.Parse(Glide_scale_y.Text) : 100000;
Global.Config.GlidePlugin.UseDefaultHacks = GlideUseDefaultHacks1.Checked || GlideUseDefaultHacks2.Checked;
Global.Config.GlidePlugin.alt_tex_size = Glide_alt_tex_size.Checked;
@@ -189,29 +178,24 @@ namespace BizHawk.Client.EmuHawk
Global.Config.GlidePlugin.use_sts1_only = Glide_use_sts1_only.Checked;
Global.Config.GlidePlugin.wrap_big_tex = Glide_wrap_big_tex.Checked;
- if (InputValidate.IsValidSignedNumber(Glide_depth_bias.Text))
- Global.Config.GlidePlugin.depth_bias = int.Parse(Glide_depth_bias.Text);
- else
- Global.Config.GlidePlugin.depth_bias = 20;
+ Global.Config.GlidePlugin.depth_bias =
+ InputValidate.IsValidSignedNumber(Glide_depth_bias.Text) ?
+ int.Parse(Glide_depth_bias.Text) : 20;
Global.Config.GlidePlugin.filtering = Glide_filtering.SelectedIndex;
- if (InputValidate.IsValidSignedNumber(Glide_fix_tex_coord.Text))
- Global.Config.GlidePlugin.fix_tex_coord = int.Parse(Glide_fix_tex_coord.Text);
- else
- Global.Config.GlidePlugin.fix_tex_coord = 0;
+ Global.Config.GlidePlugin.fix_tex_coord = InputValidate.IsValidSignedNumber(Glide_fix_tex_coord.Text) ?
+ int.Parse(Glide_fix_tex_coord.Text) : 0;
Global.Config.GlidePlugin.lodmode = Glide_lodmode.SelectedIndex;
- if (InputValidate.IsValidSignedNumber(Glide_stipple_mode.Text))
- Global.Config.GlidePlugin.stipple_mode = int.Parse(Glide_stipple_mode.Text);
- else
- Global.Config.GlidePlugin.stipple_mode = 2;
+ Global.Config.GlidePlugin.stipple_mode =
+ InputValidate.IsValidSignedNumber(Glide_stipple_mode.Text) ?
+ int.Parse(Glide_stipple_mode.Text) : 2;
- if (InputValidate.IsValidSignedNumber(Glide_stipple_pattern.Text))
- Global.Config.GlidePlugin.stipple_pattern = int.Parse(Glide_stipple_pattern.Text);
- else
- Global.Config.GlidePlugin.stipple_pattern = 1041204192;
+ Global.Config.GlidePlugin.stipple_pattern =
+ InputValidate.IsValidSignedNumber(Glide_stipple_pattern.Text) ?
+ int.Parse(Glide_stipple_pattern.Text) : 1041204192;
Global.Config.GlidePlugin.swapmode = Glide_swapmode.SelectedIndex;
Global.Config.GlidePlugin.enable_hacks_for_game = Glide_enable_hacks_for_game.SelectedIndex;
@@ -240,15 +224,13 @@ namespace BizHawk.Client.EmuHawk
Global.Config.Glide64mk2Plugin.alt_tex_size = Glide64mk2_alt_tex_size.Checked;
Global.Config.Glide64mk2Plugin.swapmode = Glide64mk2_swapmode.SelectedIndex;
- if (InputValidate.IsValidSignedNumber(Glide64mk2_stipple_pattern.Text))
- Global.Config.Glide64mk2Plugin.stipple_pattern = int.Parse(Glide64mk2_stipple_pattern.Text);
- else
- Global.Config.Glide64mk2Plugin.stipple_pattern = 1041204192;
+ Global.Config.Glide64mk2Plugin.stipple_pattern =
+ InputValidate.IsValidSignedNumber(Glide64mk2_stipple_pattern.Text) ?
+ int.Parse(Glide64mk2_stipple_pattern.Text) : 1041204192;
- if (InputValidate.IsValidSignedNumber(Glide64mk2_stipple_mode.Text))
- Global.Config.Glide64mk2Plugin.stipple_mode = int.Parse(Glide64mk2_stipple_mode.Text);
- else
- Global.Config.Glide64mk2Plugin.stipple_mode = 2;
+ Global.Config.Glide64mk2Plugin.stipple_mode =
+ InputValidate.IsValidSignedNumber(Glide64mk2_stipple_mode.Text) ?
+ int.Parse(Glide64mk2_stipple_mode.Text) : 2;
Global.Config.Glide64mk2Plugin.lodmode = Glide64mk2_lodmode.SelectedIndex;
Global.Config.Glide64mk2Plugin.filtering = Glide64mk2_filtering.SelectedIndex;
@@ -276,11 +258,11 @@ namespace BizHawk.Client.EmuHawk
{
//Load Variables
//Global
- string video_setting = Global.Config.N64VideoSizeX.ToString()
+ var video_setting = Global.Config.N64VideoSizeX
+ " x "
- + Global.Config.N64VideoSizeY.ToString();
+ + Global.Config.N64VideoSizeY;
- int index = VideoResolutionComboBox.Items.IndexOf(video_setting);
+ var index = VideoResolutionComboBox.Items.IndexOf(video_setting);
if (index >= 0)
{
VideoResolutionComboBox.SelectedIndex = index;
@@ -331,7 +313,7 @@ namespace BizHawk.Client.EmuHawk
RiceColorQuality_Combo.SelectedIndex = Global.Config.RicePlugin.ColorQuality;
RiceOpenGLRenderSetting_Combo.SelectedIndex = Global.Config.RicePlugin.OpenGLRenderSetting;
RiceAnisotropicFiltering_TB.Value = Global.Config.RicePlugin.AnisotropicFiltering;
- AnisotropicFiltering_LB.Text = "Anisotropic Filtering: " + RiceAnisotropicFiltering_TB.Value.ToString();
+ AnisotropicFiltering_LB.Text = "Anisotropic Filtering: " + RiceAnisotropicFiltering_TB.Value;
RiceUseDefaultHacks_CB.Checked = Global.Config.RicePlugin.UseDefaultHacks;
@@ -487,7 +469,7 @@ namespace BizHawk.Client.EmuHawk
private void RiceAnisotropicFiltering_TB_Scroll_1(object sender, EventArgs e)
{
- AnisotropicFiltering_LB.Text = "Anisotropic Filtering: " + RiceAnisotropicFiltering_TB.Value.ToString();
+ AnisotropicFiltering_LB.Text = "Anisotropic Filtering: " + RiceAnisotropicFiltering_TB.Value;
}
private void RiceUseDefaultHacks_CB_CheckedChanged(object sender, EventArgs e)
@@ -633,18 +615,19 @@ namespace BizHawk.Client.EmuHawk
public bool GetBoolFromDB(string parameter)
{
- if (Global.Game.OptionPresent(parameter) && Global.Game.OptionValue(parameter) == "true")
- return true;
- else
- return false;
+ return Global.Game.OptionPresent(parameter) && Global.Game.OptionValue(parameter) == "true";
}
public int GetIntFromDB(string parameter, int defaultVal)
{
if (Global.Game.OptionPresent(parameter) && InputValidate.IsValidUnsignedNumber(Global.Game.OptionValue(parameter)))
+ {
return int.Parse(Global.Game.OptionValue(parameter));
+ }
else
+ {
return defaultVal;
+ }
}
public void ToggleRiceHackCheckboxEnable (bool val)
diff --git a/BizHawk.Client.EmuHawk/config/NES/NESSoundConfig.cs b/BizHawk.Client.EmuHawk/config/NES/NESSoundConfig.cs
index 2f9aedf427..ccd0e9ac5d 100644
--- a/BizHawk.Client.EmuHawk/config/NES/NESSoundConfig.cs
+++ b/BizHawk.Client.EmuHawk/config/NES/NESSoundConfig.cs
@@ -65,7 +65,7 @@ namespace BizHawk.Client.EmuHawk
Global.Config.NESTriangle = tr;
Global.Config.NESNoise = no;
Global.Config.NESDMC = dmc;
- GlobalWin.MainForm.SetNESSoundChannels();
+ GlobalWin.MainForm.SetNesSoundChannels();
Close();
}
@@ -73,35 +73,35 @@ namespace BizHawk.Client.EmuHawk
{
label6.Text = trackBar1.Value.ToString();
Global.Config.NESSquare1 = trackBar1.Value;
- GlobalWin.MainForm.SetNESSoundChannels();
+ GlobalWin.MainForm.SetNesSoundChannels();
}
private void trackBar2_ValueChanged(object sender, EventArgs e)
{
label7.Text = trackBar2.Value.ToString();
Global.Config.NESSquare2 = trackBar2.Value;
- GlobalWin.MainForm.SetNESSoundChannels();
+ GlobalWin.MainForm.SetNesSoundChannels();
}
private void trackBar3_ValueChanged(object sender, EventArgs e)
{
label8.Text = trackBar3.Value.ToString();
Global.Config.NESTriangle = trackBar3.Value;
- GlobalWin.MainForm.SetNESSoundChannels();
+ GlobalWin.MainForm.SetNesSoundChannels();
}
private void trackBar4_ValueChanged(object sender, EventArgs e)
{
label9.Text = trackBar4.Value.ToString();
Global.Config.NESNoise = trackBar4.Value;
- GlobalWin.MainForm.SetNESSoundChannels();
+ GlobalWin.MainForm.SetNesSoundChannels();
}
private void trackBar5_ValueChanged(object sender, EventArgs e)
{
label10.Text = trackBar5.Value.ToString();
Global.Config.NESDMC = trackBar5.Value;
- GlobalWin.MainForm.SetNESSoundChannels();
+ GlobalWin.MainForm.SetNesSoundChannels();
}
}
}
diff --git a/BizHawk.Client.EmuHawk/config/RewindConfig.cs b/BizHawk.Client.EmuHawk/config/RewindConfig.cs
index 592ca13573..c244920e9e 100644
--- a/BizHawk.Client.EmuHawk/config/RewindConfig.cs
+++ b/BizHawk.Client.EmuHawk/config/RewindConfig.cs
@@ -8,10 +8,10 @@ namespace BizHawk.Client.EmuHawk
{
public partial class RewindConfig : Form
{
- private long StateSize;
- private int MediumStateSize;
- private int LargeStateSize;
- private int StateSizeCategory = 1; //1 = small, 2 = med, 3 = larg //TODO: enum
+ private long _stateSize;
+ private int _mediumStateSize;
+ private int _largeStateSize;
+ private int _stateSizeCategory = 1; //1 = small, 2 = med, 3 = larg //TODO: enum
public RewindConfig()
{
InitializeComponent();
@@ -30,14 +30,14 @@ namespace BizHawk.Client.EmuHawk
RewindFramesUsedLabel.Text = "N/A";
}
-
+
DiskBufferCheckbox.Checked = Global.Config.Rewind_OnDisk;
RewindIsThreadedCheckbox.Checked = Global.Config.Rewind_IsThreaded;
- StateSize = Global.Emulator.SaveStateBinary().Length;
+ _stateSize = Global.Emulator.SaveStateBinary().Length;
BufferSizeUpDown.Value = Global.Config.Rewind_BufferSize;
- MediumStateSize = Global.Config.Rewind_MediumStateSize;
- LargeStateSize = Global.Config.Rewind_LargeStateSize;
+ _mediumStateSize = Global.Config.Rewind_MediumStateSize;
+ _largeStateSize = Global.Config.Rewind_LargeStateSize;
UseDeltaCompression.Checked = Global.Config.Rewind_UseDelta;
@@ -55,20 +55,20 @@ namespace BizHawk.Client.EmuHawk
SetStateSize();
- int medium_state_size_kb = Global.Config.Rewind_MediumStateSize / 1024;
- int large_state_size_kb = Global.Config.Rewind_LargeStateSize / 1024;
+ var medium_state_size_kb = Global.Config.Rewind_MediumStateSize / 1024;
+ var large_state_size_kb = Global.Config.Rewind_LargeStateSize / 1024;
MediumStateTrackbar.Value = medium_state_size_kb;
- MediumStateUpDown.Value = (decimal)medium_state_size_kb;
+ MediumStateUpDown.Value = medium_state_size_kb;
LargeStateTrackbar.Value = large_state_size_kb;
- LargeStateUpDown.Value = (decimal)large_state_size_kb;
+ LargeStateUpDown.Value = large_state_size_kb;
}
private void SetStateSize()
{
- double num = StateSize / 1024.0;
+ double num = _stateSize / 1024.0;
- if (num >= 1024)
+ if (num >= 1024)
{
num /= 1024.0;
StateSizeLabel.Text = String.Format("{0:0.00}", num) + " mb";
@@ -79,34 +79,34 @@ namespace BizHawk.Client.EmuHawk
}
- SmallLabel1.Text = "Small savestates (less than " + (MediumStateSize / 1024).ToString() + "kb)";
- MediumLabel1.Text = "Medium savestates (" + (MediumStateSize / 1024).ToString()
- + " - " + (LargeStateSize / 1024) + "kb)";
- LargeLabel1.Text = "Large savestates (" + (LargeStateSize / 1024) + "kb or more)";
+ SmallLabel1.Text = "Small savestates (less than " + (_mediumStateSize / 1024) + "kb)";
+ MediumLabel1.Text = "Medium savestates (" + (_mediumStateSize / 1024)
+ + " - " + (_largeStateSize / 1024) + "kb)";
+ LargeLabel1.Text = "Large savestates (" + (_largeStateSize / 1024) + "kb or more)";
- if (StateSize >= LargeStateSize)
+ if (_stateSize >= _largeStateSize)
{
- StateSizeCategory = 3;
- SmallLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
+ _stateSizeCategory = 3;
+ SmallLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
MediumLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
LargeLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Italic);
}
- else if (StateSize >= MediumStateSize)
+ else if (_stateSize >= _mediumStateSize)
{
- StateSizeCategory = 2;
- SmallLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
+ _stateSizeCategory = 2;
+ SmallLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
MediumLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Italic);
LargeLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
}
else
{
- StateSizeCategory = 1;
- SmallLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Italic);
+ _stateSizeCategory = 1;
+ SmallLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Italic);
MediumLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
LargeLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
}
- CalculateEstimates();
+ CalculateEstimates();
}
private void Cancel_Click(object sender, EventArgs e)
@@ -147,7 +147,7 @@ namespace BizHawk.Client.EmuHawk
private void SetSmallEnabled()
{
SmallLabel1.Enabled = SmallLabel2.Enabled
- = SmallSavestateNumeric.Enabled = SmallLabel3.Enabled
+ = SmallSavestateNumeric.Enabled = SmallLabel3.Enabled
= SmallStateEnabledBox.Checked;
}
@@ -203,8 +203,8 @@ namespace BizHawk.Client.EmuHawk
LargeStateUpDown.Value = MediumStateUpDown.Value;
LargeStateTrackbar.Value = (int)MediumStateUpDown.Value;
}
- MediumStateSize = MediumStateTrackbar.Value * 1024;
- LargeStateSize = LargeStateTrackbar.Value * 1024;
+ _mediumStateSize = MediumStateTrackbar.Value * 1024;
+ _largeStateSize = LargeStateTrackbar.Value * 1024;
SetStateSize();
}
@@ -216,8 +216,8 @@ namespace BizHawk.Client.EmuHawk
LargeStateUpDown.Value = MediumStateUpDown.Value;
LargeStateTrackbar.Value = (int)MediumStateUpDown.Value;
}
- MediumStateSize = MediumStateTrackbar.Value * 1024;
- LargeStateSize = LargeStateTrackbar.Value * 1024;
+ _mediumStateSize = MediumStateTrackbar.Value * 1024;
+ _largeStateSize = LargeStateTrackbar.Value * 1024;
SetStateSize();
}
@@ -232,8 +232,8 @@ namespace BizHawk.Client.EmuHawk
{
LargeStateUpDown.Value = (sender as TrackBar).Value;
}
- MediumStateSize = MediumStateTrackbar.Value * 1024;
- LargeStateSize = LargeStateTrackbar.Value * 1024;
+ _mediumStateSize = MediumStateTrackbar.Value * 1024;
+ _largeStateSize = LargeStateTrackbar.Value * 1024;
SetStateSize();
}
@@ -248,82 +248,82 @@ namespace BizHawk.Client.EmuHawk
{
LargeStateTrackbar.Value = (int)(sender as NumericUpDown).Value;
}
- MediumStateSize = MediumStateTrackbar.Value * 1024;
- LargeStateSize = LargeStateTrackbar.Value * 1024;
+ _mediumStateSize = MediumStateTrackbar.Value * 1024;
+ _largeStateSize = LargeStateTrackbar.Value * 1024;
SetStateSize();
}
- private void CalculateEstimates()
- {
- long avg_state_size = 0;
+ private void CalculateEstimates()
+ {
+ long avg_state_size;
- if (UseDeltaCompression.Checked || StateSize == 0)
- {
+ if (UseDeltaCompression.Checked || _stateSize == 0)
+ {
- if (GlobalWin.MainForm.Rewind_Count > 0)
- {
- avg_state_size = (long)(GlobalWin.MainForm.Rewind_Size / GlobalWin.MainForm.Rewind_Count);
- }
- else
- {
- avg_state_size = Global.Emulator.SaveStateBinary().Length;
- }
- }
- else
- {
- avg_state_size = StateSize;
- }
+ if (GlobalWin.MainForm.Rewind_Count > 0)
+ {
+ avg_state_size = GlobalWin.MainForm.Rewind_Size / GlobalWin.MainForm.Rewind_Count;
+ }
+ else
+ {
+ avg_state_size = Global.Emulator.SaveStateBinary().Length;
+ }
+ }
+ else
+ {
+ avg_state_size = _stateSize;
+ }
- long buffer_size = (long)(BufferSizeUpDown.Value);
- buffer_size *= 1024 * 1024;
- long est_frames = buffer_size / avg_state_size;
+ var buffer_size = (long)(BufferSizeUpDown.Value);
+ buffer_size *= 1024 * 1024;
+ var est_frames = buffer_size / avg_state_size;
-
- long est_frequency = 0;
- switch (StateSizeCategory)
- {
- case 1:
- est_frequency = (long)SmallSavestateNumeric.Value;
- break;
- case 2:
- est_frequency = (long)MediumSavestateNumeric.Value;
- break;
- case 3:
- est_frequency = (long)LargeSavestateNumeric.Value;
- break;
- }
- long est_total_frames = est_frames * est_frequency;
- double minutes = est_total_frames / 60 / 60;
- AverageStoredStateSizeLabel.Text = String.Format("{0:n0}", avg_state_size) + " bytes";
- ApproxFramesLabel.Text = String.Format("{0:n0}", est_frames) + " frames";
- EstTimeLabel.Text = String.Format("{0:n}", minutes) + " minutes";
- }
+ long est_frequency = 0;
+ switch (_stateSizeCategory)
+ {
+ case 1:
+ est_frequency = (long)SmallSavestateNumeric.Value;
+ break;
+ case 2:
+ est_frequency = (long)MediumSavestateNumeric.Value;
+ break;
+ case 3:
+ est_frequency = (long)LargeSavestateNumeric.Value;
+ break;
+ }
+ long est_total_frames = est_frames * est_frequency;
+ double minutes = est_total_frames / 60 / 60;
- private void BufferSizeUpDown_ValueChanged(object sender, EventArgs e)
- {
- CalculateEstimates();
- }
+ AverageStoredStateSizeLabel.Text = String.Format("{0:n0}", avg_state_size) + " bytes";
+ ApproxFramesLabel.Text = String.Format("{0:n0}", est_frames) + " frames";
+ EstTimeLabel.Text = String.Format("{0:n}", minutes) + " minutes";
+ }
- private void UseDeltaCompression_CheckedChanged(object sender, EventArgs e)
- {
- CalculateEstimates();
- }
+ private void BufferSizeUpDown_ValueChanged(object sender, EventArgs e)
+ {
+ CalculateEstimates();
+ }
- private void SmallSavestateNumeric_ValueChanged(object sender, EventArgs e)
- {
- CalculateEstimates();
- }
+ private void UseDeltaCompression_CheckedChanged(object sender, EventArgs e)
+ {
+ CalculateEstimates();
+ }
- private void MediumSavestateNumeric_ValueChanged(object sender, EventArgs e)
- {
- CalculateEstimates();
- }
+ private void SmallSavestateNumeric_ValueChanged(object sender, EventArgs e)
+ {
+ CalculateEstimates();
+ }
- private void LargeSavestateNumeric_ValueChanged(object sender, EventArgs e)
- {
- CalculateEstimates();
- }
+ private void MediumSavestateNumeric_ValueChanged(object sender, EventArgs e)
+ {
+ CalculateEstimates();
+ }
+
+ private void LargeSavestateNumeric_ValueChanged(object sender, EventArgs e)
+ {
+ CalculateEstimates();
+ }
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs
index 389ac51f19..9fd08ffe72 100644
--- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs
+++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs
@@ -673,7 +673,7 @@ namespace BizHawk.Client.EmuHawk
private void OpenGameGenieEncoderDecoderMenuItem_Click(object sender, EventArgs e)
{
- GlobalWin.MainForm.LoadGameGenieEC();
+ GlobalWin.MainForm.LoadGameGenieEc();
}
#endregion
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs
index 7f1db898f2..d6e8760a92 100644
--- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs
+++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs
@@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk
public static void client_closerom()
{
- GlobalWin.MainForm.CloseROM();
+ GlobalWin.MainForm.CloseRom();
}
public static void client_enablerewind(object boolean)
diff --git a/BizHawk.Client.EmuHawk/tools/ToolBox.cs b/BizHawk.Client.EmuHawk/tools/ToolBox.cs
index 09df110f02..b5790c572f 100644
--- a/BizHawk.Client.EmuHawk/tools/ToolBox.cs
+++ b/BizHawk.Client.EmuHawk/tools/ToolBox.cs
@@ -125,7 +125,7 @@ namespace BizHawk.Client.EmuHawk
private void NESGameGenie_Click(object sender, EventArgs e)
{
- GlobalWin.MainForm.LoadGameGenieEC();
+ GlobalWin.MainForm.LoadGameGenieEc();
}
private void NESNameTable_Click(object sender, EventArgs e)
@@ -161,17 +161,17 @@ namespace BizHawk.Client.EmuHawk
private void SNESGameGenie_Click(object sender, EventArgs e)
{
- GlobalWin.MainForm.LoadGameGenieEC();
+ GlobalWin.MainForm.LoadGameGenieEc();
}
private void GGGameGenie_Click(object sender, EventArgs e)
{
- GlobalWin.MainForm.LoadGameGenieEC();
+ GlobalWin.MainForm.LoadGameGenieEc();
}
private void GBGameGenie_Click(object sender, EventArgs e)
{
- GlobalWin.MainForm.LoadGameGenieEC();
+ GlobalWin.MainForm.LoadGameGenieEc();
}
diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs
index 0f211e53b0..7a43fac284 100644
--- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs
+++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
@@ -211,6 +209,39 @@ namespace BizHawk.Client.EmuHawk
}
}
+ public void UpdateToolsBefore(bool fromLua = false)
+ {
+ if (Has())
+ {
+ if (!fromLua)
+ {
+ LuaConsole.StartLuaDrawing();
+ }
+ LuaConsole.LuaImp.CallFrameBeforeEvent();
+ }
+ UpdateBefore();
+ }
+
+ public void UpdateToolsAfter(bool fromLua = false)
+ {
+ if (!fromLua && Has())
+ {
+ LuaConsole.ResumeScripts(true);
+ }
+
+ GlobalWin.Tools.UpdateAfter();
+
+ if (Has())
+ {
+ LuaConsole.LuaImp.CallFrameAfterEvent();
+ if (!fromLua)
+ {
+ GlobalWin.DisplayManager.PreFrameUpdateLuaSource();
+ LuaConsole.EndLuaDrawing();
+ }
+ }
+ }
+
//Note: Referencing these properties creates an instance of the tool and persists it. They should be referenced by type if this is not desired
#region Tools