diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs index 88eb744eee..f1871c0a92 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -1809,7 +1809,7 @@ this.GBInSGBMenuItem.Name = "GBInSGBMenuItem"; this.GBInSGBMenuItem.Size = new System.Drawing.Size(239, 22); this.GBInSGBMenuItem.Text = "GB in SGB"; - this.GBInSGBMenuItem.Click += new System.EventHandler(this.GBInSGBMenuItem_Click); + this.GBInSGBMenuItem.Click += new System.EventHandler(this.GbInSgbMenuItem_Click); // // NesInQuickNESMenuItem // @@ -2678,7 +2678,7 @@ this.LoadGBInSGBMenuItem.Name = "LoadGBInSGBMenuItem"; this.LoadGBInSGBMenuItem.Size = new System.Drawing.Size(233, 22); this.LoadGBInSGBMenuItem.Text = "Load GB in SGB"; - this.LoadGBInSGBMenuItem.Click += new System.EventHandler(this.LoadGBInSGBMenuItem_Click); + this.LoadGBInSGBMenuItem.Click += new System.EventHandler(this.LoadGbInSgbMenuItem_Click); // // toolStripSeparator28 // @@ -2690,7 +2690,7 @@ this.GBGPUViewerMenuItem.Name = "GBGPUViewerMenuItem"; this.GBGPUViewerMenuItem.Size = new System.Drawing.Size(233, 22); this.GBGPUViewerMenuItem.Text = "GPU Viewer"; - this.GBGPUViewerMenuItem.Click += new System.EventHandler(this.GBGPUViewerMenuItem_Click); + this.GBGPUViewerMenuItem.Click += new System.EventHandler(this.GbGpuViewerMenuItem_Click); // // GBGameGenieMenuItem // @@ -2725,14 +2725,14 @@ this.GBAmGBAMenuItem.Name = "GBAmGBAMenuItem"; this.GBAmGBAMenuItem.Size = new System.Drawing.Size(125, 22); this.GBAmGBAMenuItem.Text = "mGBA"; - this.GBAmGBAMenuItem.Click += new System.EventHandler(this.GBAmGBAMenuItem_Click); + this.GBAmGBAMenuItem.Click += new System.EventHandler(this.UsemGBAMenuItem_Click); // // GBAVBANextMenuItem // this.GBAVBANextMenuItem.Name = "GBAVBANextMenuItem"; this.GBAVBANextMenuItem.Size = new System.Drawing.Size(125, 22); this.GBAVBANextMenuItem.Text = "&VBA-Next"; - this.GBAVBANextMenuItem.Click += new System.EventHandler(this.GBAVBANextMenuItem_Click); + this.GBAVBANextMenuItem.Click += new System.EventHandler(this.UseVbaNextMenuItem_Click); // // GBAcoresettingsToolStripMenuItem1 // @@ -2907,7 +2907,7 @@ this.SnesGBInSGBMenuItem.Name = "SnesGBInSGBMenuItem"; this.SnesGBInSGBMenuItem.Size = new System.Drawing.Size(233, 22); this.SnesGBInSGBMenuItem.Text = "Load GB in SGB"; - this.SnesGBInSGBMenuItem.Click += new System.EventHandler(this.SnesGBInSGBMenuItem_Click); + this.SnesGBInSGBMenuItem.Click += new System.EventHandler(this.SnesGbInSgbMenuItem_Click); // // SnesGameGenieMenuItem // @@ -3063,7 +3063,7 @@ this.GenesisGameGenieECDC.Name = "GenesisGameGenieECDC"; this.GenesisGameGenieECDC.Size = new System.Drawing.Size(233, 22); this.GenesisGameGenieECDC.Text = "&Game Genie Encoder/Decoder"; - this.GenesisGameGenieECDC.Click += new System.EventHandler(this.GenesisGameGenieECDC_Click); + this.GenesisGameGenieECDC.Click += new System.EventHandler(this.GenesisGameGenieEcDc_Click); // // toolStripSeparator26 // @@ -3783,7 +3783,7 @@ this.GBInSGBContextMenuItem.Name = "GBInSGBContextMenuItem"; this.GBInSGBContextMenuItem.Size = new System.Drawing.Size(163, 22); this.GBInSGBContextMenuItem.Text = "GB in SGB"; - this.GBInSGBContextMenuItem.Click += new System.EventHandler(this.GBInSGBMenuItem_Click); + this.GBInSGBContextMenuItem.Click += new System.EventHandler(this.GbInSgbMenuItem_Click); // // NesInQuickNESContextMenuItem // @@ -3852,7 +3852,7 @@ // this.timerMouseIdle.Enabled = true; this.timerMouseIdle.Interval = 2000; - this.timerMouseIdle.Tick += new System.EventHandler(this.timerMouseIdle_Tick); + this.timerMouseIdle.Tick += new System.EventHandler(this.TimerMouseIdle_Tick); // // toolStripSeparator36 // diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 3e2ea25636..b5dc29e294 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -796,12 +796,24 @@ namespace BizHawk.Client.EmuHawk switch (Global.Config.TargetZoomFactors[Emulator.SystemId]) { - case 1: x1MenuItem.Checked = true; break; - case 2: x2MenuItem.Checked = true; break; - case 3: x3MenuItem.Checked = true; break; - case 4: x4MenuItem.Checked = true; break; - case 5: x5MenuItem.Checked = true; break; - case 10: mzMenuItem.Checked = true; break; + case 1: + x1MenuItem.Checked = true; + break; + case 2: + x2MenuItem.Checked = true; + break; + case 3: + x3MenuItem.Checked = true; + break; + case 4: + x4MenuItem.Checked = true; + break; + case 5: + x5MenuItem.Checked = true; + break; + case 10: + mzMenuItem.Checked = true; + break; } } @@ -988,7 +1000,7 @@ namespace BizHawk.Client.EmuHawk { if (e is RomLoader.RomErrorArgs) { - var args = e as RomLoader.RomErrorArgs; + var args = (RomLoader.RomErrorArgs)e; var result = new FirmwaresConfig(true, args.RomPath).ShowDialog(); args.Retry = result == DialogResult.Retry; } @@ -1176,7 +1188,7 @@ namespace BizHawk.Client.EmuHawk UpdateKeyPriorityIcon(); } - private void GBInSGBMenuItem_Click(object sender, EventArgs e) + private void GbInSgbMenuItem_Click(object sender, EventArgs e) { Global.Config.GB_AsSGB ^= true; @@ -1912,6 +1924,7 @@ namespace BizHawk.Client.EmuHawk private void LoadTIFileMenuItem_Click(object sender, EventArgs e) { + var ti83 = (TI83)Emulator; var ofd = new OpenFileDialog { InitialDirectory = PathManager.GetRomsPath(Emulator.SystemId), @@ -1923,15 +1936,15 @@ namespace BizHawk.Client.EmuHawk { try { - (Emulator as TI83).LinkPort.SendFileToCalc(File.OpenRead(ofd.FileName), true); + ti83.LinkPort.SendFileToCalc(File.OpenRead(ofd.FileName), true); } catch (IOException ex) { - var Message = $"Invalid file format. Reason: {ex.Message} \nForce transfer? This may cause the calculator to crash."; + var message = $"Invalid file format. Reason: {ex.Message} \nForce transfer? This may cause the calculator to crash."; - if (MessageBox.Show(Message, "Upload Failed", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + if (MessageBox.Show(message, "Upload Failed", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { - (Emulator as TI83).LinkPort.SendFileToCalc(File.OpenRead(ofd.FileName), false); + ti83.LinkPort.SendFileToCalc(File.OpenRead(ofd.FileName), false); } } } @@ -1939,14 +1952,9 @@ namespace BizHawk.Client.EmuHawk private void TI83PaletteMenuItem_Click(object sender, EventArgs e) { - if (new TI83PaletteConfig().ShowDialog() == DialogResult.OK) - { - GlobalWin.OSD.AddMessage("Palette settings saved"); - } - else - { - GlobalWin.OSD.AddMessage("Palette config aborted"); - } + GlobalWin.OSD.AddMessage(new TI83PaletteConfig().ShowDialog() == DialogResult.OK + ? "Palette settings saved" + : "Palette config aborted"); } #endregion @@ -1979,7 +1987,7 @@ namespace BizHawk.Client.EmuHawk PutCoreSyncSettings(s); } - private void GBAInCGBModeMenuItem_Click(object sender, EventArgs e) + private void GbaInCgbModeMenuItem_Click(object sender, EventArgs e) { var s = ((Gameboy)Emulator).GetSyncSettings(); s.GBACGB ^= true; @@ -2006,12 +2014,12 @@ namespace BizHawk.Client.EmuHawk } } - private void LoadGBInSGBMenuItem_Click(object sender, EventArgs e) + private void LoadGbInSgbMenuItem_Click(object sender, EventArgs e) { - SnesGBInSGBMenuItem_Click(sender, e); + SnesGbInSgbMenuItem_Click(sender, e); } - private void GBGPUViewerMenuItem_Click(object sender, EventArgs e) + private void GbGpuViewerMenuItem_Click(object sender, EventArgs e) { GlobalWin.Tools.Load(); } @@ -2030,13 +2038,13 @@ namespace BizHawk.Client.EmuHawk GlobalWin.Tools.Load(); } - private void GBAmGBAMenuItem_Click(object sender, EventArgs e) + private void UsemGBAMenuItem_Click(object sender, EventArgs e) { Global.Config.GBA_UsemGBA = true; FlagNeedsReboot(); } - private void GBAVBANextMenuItem_Click(object sender, EventArgs e) + private void UseVbaNextMenuItem_Click(object sender, EventArgs e) { Global.Config.GBA_UsemGBA = false; FlagNeedsReboot(); @@ -2093,7 +2101,7 @@ namespace BizHawk.Client.EmuHawk private void SNESSubMenu_DropDownOpened(object sender, EventArgs e) { - if ((Emulator as LibsnesCore).IsSGB) + if (((LibsnesCore)Emulator).IsSGB) { SnesGBInSGBMenuItem.Visible = true; SnesGBInSGBMenuItem.Checked = Global.Config.GB_AsSGB; @@ -2179,7 +2187,7 @@ namespace BizHawk.Client.EmuHawk GlobalWin.Tools.Load(); } - private void SnesGBInSGBMenuItem_Click(object sender, EventArgs e) + private void SnesGbInSgbMenuItem_Click(object sender, EventArgs e) { Global.Config.GB_AsSGB ^= true; FlagNeedsReboot(); @@ -2233,8 +2241,8 @@ namespace BizHawk.Client.EmuHawk var s = ((N64)Emulator).GetSettings(); MupenStyleLagMenuItem.Checked = s.UseMupenStyleLag; - N64ExpansionSlotMenuItem.Checked = (Emulator as N64).UsingExpansionSlot; - N64ExpansionSlotMenuItem.Enabled = !(Emulator as N64).IsOverridingUserExpansionSlotSetting; + N64ExpansionSlotMenuItem.Checked = ((N64)Emulator).UsingExpansionSlot; + N64ExpansionSlotMenuItem.Enabled = !((N64)Emulator).IsOverridingUserExpansionSlotSetting; } private void N64PluginSettingsMenuItem_Click(object sender, EventArgs e) @@ -2323,7 +2331,7 @@ namespace BizHawk.Client.EmuHawk GenericCoreConfig.DoDialog(this, "Genesis Settings"); } - private void GenesisGameGenieECDC_Click(object sender, EventArgs e) + private void GenesisGameGenieEcDc_Click(object sender, EventArgs e) { GlobalWin.Tools.Load(); } @@ -2360,7 +2368,7 @@ namespace BizHawk.Client.EmuHawk if (Emulator is AppleII) { - var appleII = Emulator as AppleII; + var appleII = (AppleII)Emulator; for (int i = 0; i < appleII.DiskCount; i++) { var menuItem = new ToolStripMenuItem @@ -2389,7 +2397,7 @@ namespace BizHawk.Client.EmuHawk { if (Emulator is C64) { - C64DisksSubMenu.Enabled = (Emulator as C64).DiskCount > 1; + C64DisksSubMenu.Enabled = ((C64)Emulator).DiskCount > 1; } } @@ -2399,7 +2407,7 @@ namespace BizHawk.Client.EmuHawk if (Emulator is C64) { - var c64 = Emulator as C64; + var c64 = (C64)Emulator; for (int i = 0; i < c64.DiskCount; i++) { var menuItem = new ToolStripMenuItem @@ -2837,6 +2845,7 @@ namespace BizHawk.Client.EmuHawk { UnpauseEmulator(); } + _wasPaused = false; } } @@ -2854,7 +2863,7 @@ namespace BizHawk.Client.EmuHawk } } - private void timerMouseIdle_Tick(object sender, EventArgs e) + private void TimerMouseIdle_Tick(object sender, EventArgs e) { if (_inFullscreen && Global.Config.DispChrome_Fullscreen_AutohideMouse) { diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index b9aa1d8d70..a42a283b2f 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -49,10 +49,10 @@ namespace BizHawk.Client.EmuHawk ToolFormBase.UpdateCheatRelatedTools(null, null); RebootStatusBarIcon.Visible = false; UpdateNotification.Visible = false; - StatusBarDiskLightOnImage = Properties.Resources.LightOn; - StatusBarDiskLightOffImage = Properties.Resources.LightOff; - LinkCableOn = Properties.Resources.connect_16x16; - LinkCableOff = Properties.Resources.noconnect_16x16; + _statusBarDiskLightOnImage = Properties.Resources.LightOn; + _statusBarDiskLightOffImage = Properties.Resources.LightOff; + _linkCableOn = Properties.Resources.connect_16x16; + _linkCableOff = Properties.Resources.noconnect_16x16; UpdateCoreStatusBarButton(); if (Global.Config.FirstBoot) { @@ -137,14 +137,14 @@ namespace BizHawk.Client.EmuHawk string xmlPath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.xml"); string x7zPath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.7z"); bool loadXml = File.Exists(xmlPath); - using (var NesCartFile = new HawkFile(loadXml ? xmlPath : x7zPath)) + using (var nesCartFile = new HawkFile(loadXml ? xmlPath : x7zPath)) { if (!loadXml) { - NesCartFile.BindFirst(); + nesCartFile.BindFirst(); } - return NesCartFile + return nesCartFile .GetStream() .ReadAllBytes(); } @@ -299,7 +299,7 @@ namespace BizHawk.Client.EmuHawk CoreFileProvider.SyncCoreCommInputSignals(comm); Emulator = new NullEmulator(comm, Global.Config.GetCoreSettings()); Global.ActiveController = new Controller(NullController.Instance.Definition); - Global.AutoFireController = AutofireNullControls; + Global.AutoFireController = _autofireNullControls; Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); try { @@ -480,7 +480,7 @@ namespace BizHawk.Client.EmuHawk }; } - private bool _supressSyncSettingsWarning = false; + private readonly bool _supressSyncSettingsWarning; public int ProgramRunLoop() { @@ -509,7 +509,7 @@ namespace BizHawk.Client.EmuHawk // handle events and dispatch as a hotkey action, or a hotkey button, or an input button ProcessInput(); - Global.ClientControls.LatchFromPhysical(HotkeyCoalescer); + Global.ClientControls.LatchFromPhysical(_hotkeyCoalescer); Global.ActiveController.LatchFromPhysical(Global.ControllerInputCoalescer); @@ -627,20 +627,18 @@ namespace BizHawk.Client.EmuHawk #region Properties - public string CurrentlyOpenRom { get; set; } // todo - delete me and use only args instead - public LoadRomArgs CurrentlyOpenRomArgs { get; set; } - public bool PauseAVI { get; set; } + public string CurrentlyOpenRom { get; private set; } // todo - delete me and use only args instead + public LoadRomArgs CurrentlyOpenRomArgs { get; private set; } + public bool PauseAvi { get; set; } public bool PressFrameAdvance { get; set; } public bool HoldFrameAdvance { get; set; } // necessary for tastudio > button public bool PressRewind { get; set; } // necessary for tastudio < button public bool FastForward { get; set; } - public bool TurboFastForward { get; set; } - public bool RestoreReadWriteOnStop { get; set; } // runloop won't exec lua public bool SuppressLua { get; set; } - public long MouseWheelTracker { get; set; } + public long MouseWheelTracker { get; private set; } private int? _pauseOnFrame; public int? PauseOnFrame // If set, upon completion of this frame, the client wil pause @@ -666,9 +664,9 @@ namespace BizHawk.Client.EmuHawk public bool IsSeeking => PauseOnFrame.HasValue; - public bool IsTurboSeeking => PauseOnFrame.HasValue && Global.Config.TurboSeek; - - public bool IsTurboing => Global.ClientControls["Turbo"] || IsTurboSeeking; + private bool IsTurboSeeking => PauseOnFrame.HasValue && Global.Config.TurboSeek; + + private bool IsTurboing => Global.ClientControls["Turbo"] || IsTurboSeeking; #endregion @@ -711,7 +709,7 @@ namespace BizHawk.Client.EmuHawk return false; } - var ts = ActiveForm as TAStudio; + var ts = (TAStudio)ActiveForm; if (ts.IsInMenuLoop) { return false; @@ -832,7 +830,7 @@ namespace BizHawk.Client.EmuHawk // hotkeys which arent handled as actions get coalesced as pollable virtual client buttons if (!handled) { - HotkeyCoalescer.Receive(ie); + _hotkeyCoalescer.Receive(ie); } break; @@ -849,7 +847,7 @@ namespace BizHawk.Client.EmuHawk // hotkeys which arent handled as actions get coalesced as pollable virtual client buttons if (!handled) { - HotkeyCoalescer.Receive(ie); + _hotkeyCoalescer.Receive(ie); } } @@ -864,7 +862,7 @@ namespace BizHawk.Client.EmuHawk // hotkeys which arent handled as actions get coalesced as pollable virtual client buttons if (!handled) { - HotkeyCoalescer.Receive(ie); + _hotkeyCoalescer.Receive(ie); // Check for hotkeys that may not be handled through Checkhotkey() method, reject controller input mapped to these if (!triggers.Any(IsInternalHotkey)) @@ -883,15 +881,15 @@ namespace BizHawk.Client.EmuHawk // hackish if (o.Item1 == "WMouse X") { - var P = GlobalWin.DisplayManager.UntransformPoint(new Point((int)o.Item2, 0)); - float x = P.X / (float)_currentVideoProvider.BufferWidth; + var p = GlobalWin.DisplayManager.UntransformPoint(new Point((int)o.Item2, 0)); + float x = p.X / (float)_currentVideoProvider.BufferWidth; return new Tuple("WMouse X", (x * 20000) - 10000); } if (o.Item1 == "WMouse Y") { - var P = GlobalWin.DisplayManager.UntransformPoint(new Point(0, (int)o.Item2)); - float y = P.Y / (float)_currentVideoProvider.BufferHeight; + var p = GlobalWin.DisplayManager.UntransformPoint(new Point(0, (int)o.Item2)); + float y = p.Y / (float)_currentVideoProvider.BufferHeight; return new Tuple("WMouse Y", (y * 20000) - 10000); } @@ -901,7 +899,7 @@ namespace BizHawk.Client.EmuHawk public void RebootCore() { - var ioa = OpenAdvancedSerializer.ParseWithLegacy(CurrentlyOpenRomPoopForAdvancedLoaderPleaseRefactorME); + var ioa = OpenAdvancedSerializer.ParseWithLegacy(_currentlyOpenRomPoopForAdvancedLoaderPleaseRefactorMe); if (ioa is OpenAdvanced_LibretroNoGame) { LoadRom("", CurrentlyOpenRomArgs); @@ -961,7 +959,7 @@ namespace BizHawk.Client.EmuHawk GlobalWin.OSD.AddMessage("Screenshot (raw) saved to clipboard."); } - public void TakeScreenshotClientToClipboard() + private void TakeScreenshotClientToClipboard() { using (var bb = GlobalWin.DisplayManager.RenderOffscreen(_currentVideoProvider, Global.Config.Screenshot_CaptureOSD)) { @@ -1077,9 +1075,7 @@ namespace BizHawk.Client.EmuHawk } } - public bool IsInFullscreen => _inFullscreen; - - public void SynchChrome() + private void SynchChrome() { if (_inFullscreen) { @@ -1325,7 +1321,7 @@ namespace BizHawk.Client.EmuHawk GlobalWin.OSD.AddMessage(s.ShowBG3_1 ? "BG 3 Layer On" : "BG 3 Layer Off"); } - public void SNES_ToggleBG4(bool? setto = null) + private void SNES_ToggleBG4(bool? setto = null) { if (!(Emulator is LibsnesCore)) { @@ -1383,6 +1379,7 @@ namespace BizHawk.Client.EmuHawk { s.ShowOBJ_1 ^= true; } + AsSNES.PutSettings(s); GlobalWin.OSD.AddMessage(s.ShowOBJ_1 ? "OBJ 2 Layer On" : "OBJ 2 Layer Off"); } @@ -1469,9 +1466,9 @@ namespace BizHawk.Client.EmuHawk // AVI/WAV state private IVideoWriter _currAviWriter; - private HashSet _currAviWriterFrameList; + private readonly HashSet _currAviWriterFrameList; - private AutofireController AutofireNullControls; + private AutofireController _autofireNullControls; // Sound refator TODO: we can enforce async mode here with a property that gets/sets this but does an async check private ISoundProvider _aviSoundInputAsync; // Note: This sound provider must be in async mode! @@ -1520,15 +1517,17 @@ namespace BizHawk.Client.EmuHawk private readonly bool _chromeless; // Resources - Bitmap StatusBarDiskLightOnImage, StatusBarDiskLightOffImage; - Bitmap LinkCableOn, LinkCableOff; + private Bitmap _statusBarDiskLightOnImage; + private Bitmap _statusBarDiskLightOffImage; + private Bitmap _linkCableOn; + private Bitmap _linkCableOff; // input state which has been destined for game controller inputs are coalesced here // public static ControllerInputCoalescer ControllerInputCoalescer = new ControllerInputCoalescer(); // input state which has been destined for client hotkey consumption are colesced here - private readonly InputCoalescer HotkeyCoalescer = new InputCoalescer(); + private readonly InputCoalescer _hotkeyCoalescer = new InputCoalescer(); - public PresentationPanel PresentationPanel { get; set; } + public PresentationPanel PresentationPanel { get; } #endregion @@ -1551,8 +1550,8 @@ namespace BizHawk.Client.EmuHawk if (_inResizeLoop) { var size = PresentationPanel.NativeSize; - float AR = (float)size.Width / size.Height; - str += $"({size.Width}x{size.Height})={AR} - "; + float ar = (float)size.Width / size.Height; + str += $"({size.Width}x{size.Height})={ar} - "; } // we need to display FPS somewhere, in this case @@ -1895,8 +1894,7 @@ namespace BizHawk.Client.EmuHawk } Global.ClientControls = controls; - AutofireNullControls = new AutofireController(NullController.Instance.Definition, Emulator); - + _autofireNullControls = new AutofireController(NullController.Instance.Definition, Emulator); } private void LoadMoviesFromRecent(string path) @@ -1915,7 +1913,6 @@ namespace BizHawk.Client.EmuHawk private void LoadRomFromRecent(string rom) { - var ioa = OpenAdvancedSerializer.ParseWithLegacy(rom); var args = new LoadRomArgs @@ -2317,7 +2314,7 @@ namespace BizHawk.Client.EmuHawk Global.Config.DisplayInput ^= true; } - public static void ToggleSound() + private static void ToggleSound() { Global.Config.SoundEnabled ^= true; GlobalWin.Sound.StopSound(); @@ -2646,8 +2643,8 @@ namespace BizHawk.Client.EmuHawk } LedLightStatusLabel.Image = Emulator.AsDriveLight().DriveLightOn - ? StatusBarDiskLightOnImage - : StatusBarDiskLightOffImage; + ? _statusBarDiskLightOnImage + : _statusBarDiskLightOffImage; } else { @@ -2665,8 +2662,8 @@ namespace BizHawk.Client.EmuHawk } LinkConnectStatusBarButton.Image = Emulator.AsLinkable().LinkConnected - ? LinkCableOn - : LinkCableOff; + ? _linkCableOn + : _linkCableOff; } else { @@ -2807,8 +2804,6 @@ namespace BizHawk.Client.EmuHawk UpdateKeyPriorityIcon(); switch (Global.Config.Input_Hotkey_OverrideOptions) { - default: - break; case 0: GlobalWin.OSD.AddMessage("Key priority set to Both Hotkey and Input"); break; @@ -3009,7 +3004,7 @@ namespace BizHawk.Client.EmuHawk Global.CheatList.Pulse(); - if (!PauseAVI) + if (!PauseAvi) { AvFrameAdvance(); } @@ -3089,6 +3084,7 @@ namespace BizHawk.Client.EmuHawk { _lastFps = (_lastFps + (_framesSinceLastFpsUpdate * _fpsSmoothing)) / (1.0 + (elapsedSeconds * _fpsSmoothing)); } + _framesSinceLastFpsUpdate = 0; _timestampLastFpsUpdate = currentTimestamp; @@ -3133,7 +3129,7 @@ namespace BizHawk.Client.EmuHawk /// filename to save to private void RecordAv(string videowritername, string filename) { - _RecordAv(videowritername, filename, true); + RecordAvBase(videowritername, filename, true); } /// @@ -3141,13 +3137,13 @@ namespace BizHawk.Client.EmuHawk /// private void RecordAv() { - _RecordAv(null, null, false); + RecordAvBase(null, null, false); } /// /// start AV recording /// - private void _RecordAv(string videowritername, string filename, bool unattended) + private void RecordAvBase(string videowritername, string filename, bool unattended) { if (_currAviWriter != null) { @@ -3155,7 +3151,7 @@ namespace BizHawk.Client.EmuHawk } // select IVideoWriter to use - IVideoWriter aw = null; + IVideoWriter aw; if (string.IsNullOrEmpty(videowritername) && !string.IsNullOrEmpty(Global.Config.VideoWriter)) { @@ -3383,14 +3379,9 @@ namespace BizHawk.Client.EmuHawk Bitmap bmpin = null; try { - if (Global.Config.AVI_CaptureOSD) - { - bbin = CaptureOSD(); - } - else - { - bbin = new BitmapBuffer(_currentVideoProvider.BufferWidth, _currentVideoProvider.BufferHeight, _currentVideoProvider.GetVideoBuffer()); - } + bbin = Global.Config.AVI_CaptureOSD + ? CaptureOSD() + : new BitmapBuffer(_currentVideoProvider.BufferWidth, _currentVideoProvider.BufferHeight, _currentVideoProvider.GetVideoBuffer()); bbin.DiscardAlpha(); @@ -3439,11 +3430,11 @@ namespace BizHawk.Client.EmuHawk int nsamp; if (_dumpaudiosync) { - (_currAviWriter as VideoStretcher).DumpAV(output, _currentSoundProvider, out samp, out nsamp); + ((VideoStretcher)_currAviWriter).DumpAV(output, _currentSoundProvider, out samp, out nsamp); } else { - (_currAviWriter as AudioStretcher).DumpAV(output, _aviSoundInputAsync, out samp, out nsamp); + ((AudioStretcher)_currAviWriter).DumpAV(output, _aviSoundInputAsync, out samp, out nsamp); } disposableOutput?.Dispose(); @@ -3610,7 +3601,7 @@ namespace BizHawk.Client.EmuHawk IOpenAdvanced ioa = args.OpenAdvanced; if (ioa is IOpenAdvancedLibretro) { - var ioaretro = ioa as IOpenAdvancedLibretro; + var ioaretro = (IOpenAdvancedLibretro)ioa; // prepare a core specification // if it wasnt already specified, use the current default @@ -3659,7 +3650,7 @@ namespace BizHawk.Client.EmuHawk if (loader.LoadedEmulator is NES) { - var nes = loader.LoadedEmulator as NES; + var nes = (NES)loader.LoadedEmulator; if (!string.IsNullOrWhiteSpace(nes.GameName)) { Global.Game.Name = nes.GameName; @@ -3669,11 +3660,12 @@ namespace BizHawk.Client.EmuHawk } else if (loader.LoadedEmulator is QuickNES) { - var qns = loader.LoadedEmulator as QuickNES; + var qns = (QuickNES)loader.LoadedEmulator; if (!string.IsNullOrWhiteSpace(qns.BootGodName)) { Global.Game.Name = qns.BootGodName; } + if (qns.BootGodStatus.HasValue) { Global.Game.Status = qns.BootGodStatus.Value; @@ -3722,7 +3714,7 @@ namespace BizHawk.Client.EmuHawk } SetWindowText(); - CurrentlyOpenRomPoopForAdvancedLoaderPleaseRefactorME = loaderName; + _currentlyOpenRomPoopForAdvancedLoaderPleaseRefactorMe = loaderName; CurrentlyOpenRom = loaderName.Replace("*OpenRom*", ""); // POOP HandlePlatformMenus(); _stateSlots.Clear(); @@ -3787,7 +3779,7 @@ namespace BizHawk.Client.EmuHawk } } - private string CurrentlyOpenRomPoopForAdvancedLoaderPleaseRefactorME = ""; + private string _currentlyOpenRomPoopForAdvancedLoaderPleaseRefactorMe = ""; private void CommitCoreSettingsToConfig() { @@ -3833,7 +3825,7 @@ namespace BizHawk.Client.EmuHawk CommitCoreSettingsToConfig(); if (Global.MovieSession.Movie.IsActive) // Note: this must be called after CommitCoreSettingsToConfig() { - StopMovie(true); + StopMovie(); } Global.Rewinder.Uninitialize(); @@ -3849,13 +3841,13 @@ namespace BizHawk.Client.EmuHawk CoreFileProvider.SyncCoreCommInputSignals(coreComm); Emulator = new NullEmulator(coreComm, Global.Config.GetCoreSettings()); Global.ActiveController = new Controller(NullController.Instance.Definition); - Global.AutoFireController = AutofireNullControls; + Global.AutoFireController = _autofireNullControls; RewireSound(); RebootStatusBarIcon.Visible = false; GameIsClosing = false; } - public bool GameIsClosing { get; set; } // Lets tools make better decisions when being called by CloseGame + public bool GameIsClosing { get; private set; } // Lets tools make better decisions when being called by CloseGame public void CloseRom(bool clearSram = false) { diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs index 1bf760f96f..bea72f62b2 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs @@ -211,7 +211,7 @@ namespace BizHawk.Client.EmuHawk [LuaMethodAttributes("pause_av", "If currently capturing Audio/Video, this will suspend the record. Frames will not be captured into the AV until client.unpause_av() is called")] public static void PauseAv() { - GlobalWin.MainForm.PauseAVI = true; + GlobalWin.MainForm.PauseAvi = true; } [LuaMethodAttributes("reboot_core", "Reboots the currently loaded core")] @@ -323,7 +323,7 @@ namespace BizHawk.Client.EmuHawk [LuaMethodAttributes("unpause_av", "If currently capturing Audio/Video this resumes capturing")] public static void UnpauseAv() { - GlobalWin.MainForm.PauseAVI = false; + GlobalWin.MainForm.PauseAvi = false; } [LuaMethodAttributes("xpos", "Returns the x value of the screen position where the client currently sits")]