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)

This commit is contained in:
adelikat 2020-02-01 15:43:06 -06:00
parent 1836ad86b6
commit 67ec75f644
2 changed files with 45 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -55,6 +55,9 @@ namespace BizHawk.Client.EmuHawk
private Dictionary<string, double> _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<string, double> 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();
}
}
}