From 67ec75f644cc5000f9ec117a9e90383a19ef4502 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 1 Feb 2020 15:43:06 -0600 Subject: [PATCH] Basic Bot - don't display messages while botting, recalculate Start enable on max value change, add checkbox to wire to mainform's invisible emulation for faster botting (possibly) --- .../tools/BasicBot/BasicBot.Designer.cs | 14 +++++++++ .../tools/BasicBot/BasicBot.cs | 31 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.Designer.cs b/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.Designer.cs index fd851af9b3..b44a2c0e0f 100644 --- a/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.Designer.cs @@ -115,6 +115,7 @@ this.label8 = new System.Windows.Forms.Label(); this.StartFromSlotBox = new System.Windows.Forms.ComboBox(); this.ControlGroupBox = new System.Windows.Forms.GroupBox(); + this.InvisibleEmulationCheckBox = new System.Windows.Forms.CheckBox(); this.panel2 = new System.Windows.Forms.Panel(); this.StatsContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.ClearStatsContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -1099,6 +1100,7 @@ // ControlGroupBox // this.ControlGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.ControlGroupBox.Controls.Add(this.InvisibleEmulationCheckBox); this.ControlGroupBox.Controls.Add(this.panel2); this.ControlGroupBox.Controls.Add(this.StopBtn); this.ControlGroupBox.Controls.Add(this.RunBtn); @@ -1111,6 +1113,17 @@ this.ControlGroupBox.TabStop = false; this.ControlGroupBox.Text = "Control"; // + // InvisibleEmulationCheckBox + // + this.InvisibleEmulationCheckBox.AutoSize = true; + this.InvisibleEmulationCheckBox.Location = new System.Drawing.Point(88, 60); + this.InvisibleEmulationCheckBox.Name = "InvisibleEmulationCheckBox"; + this.InvisibleEmulationCheckBox.Size = new System.Drawing.Size(127, 17); + this.InvisibleEmulationCheckBox.TabIndex = 2004; + this.InvisibleEmulationCheckBox.Text = "Turn Off Audio/Video"; + this.InvisibleEmulationCheckBox.UseVisualStyleBackColor = true; + this.InvisibleEmulationCheckBox.CheckedChanged += new System.EventHandler(this.InvisibleEmulationCheckBox_CheckedChanged); + // // panel2 // this.panel2.ContextMenuStrip = this.StatsContextMenu; @@ -1288,5 +1301,6 @@ private System.Windows.Forms.Button btnCopyBestInput; private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; + private System.Windows.Forms.CheckBox InvisibleEmulationCheckBox; } } diff --git a/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs b/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs index e5a4c3120c..7af7034ff5 100644 --- a/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs +++ b/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs @@ -55,6 +55,9 @@ namespace BizHawk.Client.EmuHawk private Dictionary _cachedControlProbabilities; private ILogEntryGenerator _logGenerator; + private bool _previousDisplayMessage; + private bool _previousInvisibleEmulation; + #region Services and Settings [RequiredService] @@ -74,6 +77,7 @@ namespace BizHawk.Client.EmuHawk { public RecentFiles RecentBotFiles { get; set; } = new RecentFiles(); public bool TurboWhenBotting { get; set; } = true; + public bool InvisibleEmulation { get; set; } } #endregion @@ -88,6 +92,12 @@ namespace BizHawk.Client.EmuHawk MainOperator.SelectedItem = ">="; } + private void BasicBot_Load(object sender, EventArgs e) + { + _previousInvisibleEmulation = InvisibleEmulationCheckBox.Checked = Settings.InvisibleEmulation; + _previousDisplayMessage = Config.DisplayMessages; + } + #region UI Bindings private Dictionary ControlProbabilities => @@ -960,12 +970,21 @@ namespace BizHawk.Client.EmuHawk _targetFrame = Emulator.Frame + (int)FrameLengthNumeric.Value; + _previousDisplayMessage = Config.DisplayMessages; + Config.DisplayMessages = false; + MainForm.UnpauseEmulator(); if (Settings.TurboWhenBotting) { SetMaxSpeed(); } + if (InvisibleEmulationCheckBox.Checked) + { + _previousInvisibleEmulation = MainForm.InvisibleEmulation; + MainForm.InvisibleEmulation = true; + } + UpdateBotStatusIcon(); MessageLabel.Text = "Running..."; _cachedControlProbabilities = ControlProbabilities; @@ -1010,6 +1029,8 @@ namespace BizHawk.Client.EmuHawk Global.MovieSession.Movie.IsCountingRerecords = _oldCountingSetting; } + Config.DisplayMessages = _previousDisplayMessage; + MainForm.InvisibleEmulation = _previousInvisibleEmulation; MainForm.PauseEmulator(); SetNormalSpeed(); UpdateBotStatusIcon(); @@ -1210,5 +1231,15 @@ namespace BizHawk.Client.EmuHawk { Process.Start("http://tasvideos.org/Bizhawk/BasicBot.html"); } + + private void InvisibleEmulationCheckBox_CheckedChanged(object sender, EventArgs e) + { + Settings.InvisibleEmulation ^= true; + } + + private void MaximizeAddressBox_TextChanged(object sender, EventArgs e) + { + AssessRunButtonStatus(); + } } }