Atari 2600 debugger - wire up autoload and other tool options, fix up closing event and properly disable ask save

This commit is contained in:
adelikat 2014-04-20 16:19:08 +00:00
parent 39ec2ebc90
commit 6139da29cf
4 changed files with 179 additions and 27 deletions

View File

@ -527,6 +527,10 @@ namespace BizHawk.Client.Common
public BindingCollection HotkeyBindings = new BindingCollection();
// Atari 2600 Debugger
public ToolDialogSettings Atari2600DebuggerSettings = new ToolDialogSettings();
public bool Atari2600DebuggerAutoload = false;
// Analog Hotkey values
public int Analog_LargeChange = 10;
public int Analog_SmallChange = 1;

View File

@ -10,6 +10,7 @@ using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Atari.Atari2600;
using BizHawk.Emulation.Cores.Calculators;
using BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
@ -376,6 +377,11 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Tools.LoadTraceLogger();
}
if (Global.Config.Atari2600DebuggerAutoload && Global.Emulator is Atari2600)
{
GlobalWin.Tools.Load<Atari2600Debugger>();
}
if (Global.Config.DisplayStatusBar == false)
{
MainStatusBar.Visible = false;
@ -3185,7 +3191,7 @@ namespace BizHawk.Client.EmuHawk
private void Atari2600DebuggerMenuItem_Click(object sender, EventArgs e)
{
new Atari2600Debugger().Show();
GlobalWin.Tools.Load<Atari2600Debugger>();
}
}
}

View File

@ -32,6 +32,13 @@
this.DebuggerMenu = new System.Windows.Forms.MenuStrip();
this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AutoloadMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.TopmostMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.RestoreDefaultsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.StepBtn = new System.Windows.Forms.Button();
this.ScanlineAdvanceBtn = new System.Windows.Forms.Button();
this.FrameAdvButton = new System.Windows.Forms.Button();
@ -64,6 +71,8 @@
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.CoreInfoBox = new System.Windows.Forms.GroupBox();
this.VBlankCheckbox = new System.Windows.Forms.CheckBox();
this.VSyncChexkbox = new System.Windows.Forms.CheckBox();
this.ScanlineBox = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.FrameCountBox = new System.Windows.Forms.TextBox();
@ -71,8 +80,6 @@
this.TracerBox = new System.Windows.Forms.GroupBox();
this.TraceView = new BizHawk.Client.EmuHawk.VirtualListView();
this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.VSyncChexkbox = new System.Windows.Forms.CheckBox();
this.VBlankCheckbox = new System.Windows.Forms.CheckBox();
this.DebuggerMenu.SuspendLayout();
this.RegistersBox.SuspendLayout();
this.CoreInfoBox.SuspendLayout();
@ -82,7 +89,8 @@
// DebuggerMenu
//
this.DebuggerMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.FileSubMenu});
this.FileSubMenu,
this.OptionsSubMenu});
this.DebuggerMenu.Location = new System.Drawing.Point(0, 0);
this.DebuggerMenu.Name = "DebuggerMenu";
this.DebuggerMenu.Size = new System.Drawing.Size(732, 24);
@ -105,6 +113,60 @@
this.ExitMenuItem.Text = "&Close";
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
//
// OptionsSubMenu
//
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.AutoloadMenuItem,
this.SaveWindowPositionMenuItem,
this.TopmostMenuItem,
this.FloatingWindowMenuItem,
this.toolStripSeparator1,
this.RestoreDefaultsMenuItem});
this.OptionsSubMenu.Name = "OptionsSubMenu";
this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20);
this.OptionsSubMenu.Text = "&Options";
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
//
// AutoloadMenuItem
//
this.AutoloadMenuItem.Name = "AutoloadMenuItem";
this.AutoloadMenuItem.Size = new System.Drawing.Size(191, 22);
this.AutoloadMenuItem.Text = "&Autoload";
this.AutoloadMenuItem.Click += new System.EventHandler(this.AutoloadMenuItem_Click);
//
// SaveWindowPositionMenuItem
//
this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem";
this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(191, 22);
this.SaveWindowPositionMenuItem.Text = "Save Window Position";
this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
//
// TopmostMenuItem
//
this.TopmostMenuItem.Name = "TopmostMenuItem";
this.TopmostMenuItem.Size = new System.Drawing.Size(191, 22);
this.TopmostMenuItem.Text = "Always on Top";
this.TopmostMenuItem.Click += new System.EventHandler(this.TopmostMenuItem_Click);
//
// FloatingWindowMenuItem
//
this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem";
this.FloatingWindowMenuItem.Size = new System.Drawing.Size(191, 22);
this.FloatingWindowMenuItem.Text = "Floating Window";
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(188, 6);
//
// RestoreDefaultsMenuItem
//
this.RestoreDefaultsMenuItem.Name = "RestoreDefaultsMenuItem";
this.RestoreDefaultsMenuItem.Size = new System.Drawing.Size(191, 22);
this.RestoreDefaultsMenuItem.Text = "Restore Defaults";
this.RestoreDefaultsMenuItem.Click += new System.EventHandler(this.RestoreDefaultsMenuItem_Click);
//
// StepBtn
//
this.StepBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@ -438,6 +500,26 @@
this.CoreInfoBox.TabIndex = 5;
this.CoreInfoBox.TabStop = false;
//
// VBlankCheckbox
//
this.VBlankCheckbox.AutoSize = true;
this.VBlankCheckbox.Location = new System.Drawing.Point(9, 80);
this.VBlankCheckbox.Name = "VBlankCheckbox";
this.VBlankCheckbox.Size = new System.Drawing.Size(60, 17);
this.VBlankCheckbox.TabIndex = 5;
this.VBlankCheckbox.Text = "VBlank";
this.VBlankCheckbox.UseVisualStyleBackColor = true;
//
// VSyncChexkbox
//
this.VSyncChexkbox.AutoSize = true;
this.VSyncChexkbox.Location = new System.Drawing.Point(9, 63);
this.VSyncChexkbox.Name = "VSyncChexkbox";
this.VSyncChexkbox.Size = new System.Drawing.Size(57, 17);
this.VSyncChexkbox.TabIndex = 4;
this.VSyncChexkbox.Text = "VSync";
this.VSyncChexkbox.UseVisualStyleBackColor = true;
//
// ScanlineBox
//
this.ScanlineBox.Location = new System.Drawing.Point(58, 37);
@ -515,26 +597,6 @@
this.Script.Text = "Instructions";
this.Script.Width = 599;
//
// VSyncChexkbox
//
this.VSyncChexkbox.AutoSize = true;
this.VSyncChexkbox.Location = new System.Drawing.Point(9, 63);
this.VSyncChexkbox.Name = "VSyncChexkbox";
this.VSyncChexkbox.Size = new System.Drawing.Size(57, 17);
this.VSyncChexkbox.TabIndex = 4;
this.VSyncChexkbox.Text = "VSync";
this.VSyncChexkbox.UseVisualStyleBackColor = true;
//
// VBlankCheckbox
//
this.VBlankCheckbox.AutoSize = true;
this.VBlankCheckbox.Location = new System.Drawing.Point(9, 80);
this.VBlankCheckbox.Name = "VBlankCheckbox";
this.VBlankCheckbox.Size = new System.Drawing.Size(60, 17);
this.VBlankCheckbox.TabIndex = 5;
this.VBlankCheckbox.Text = "VBlank";
this.VBlankCheckbox.UseVisualStyleBackColor = true;
//
// Atari2600Debugger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -550,6 +612,7 @@
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.DebuggerMenu;
this.Name = "Atari2600Debugger";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = " Debugger";
this.Load += new System.EventHandler(this.Atari2600Debugger_Load);
this.DebuggerMenu.ResumeLayout(false);
@ -610,5 +673,12 @@
public System.Windows.Forms.ColumnHeader Script;
private System.Windows.Forms.CheckBox VBlankCheckbox;
private System.Windows.Forms.CheckBox VSyncChexkbox;
private System.Windows.Forms.ToolStripMenuItem OptionsSubMenu;
private System.Windows.Forms.ToolStripMenuItem AutoloadMenuItem;
private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem;
private System.Windows.Forms.ToolStripMenuItem TopmostMenuItem;
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem RestoreDefaultsMenuItem;
}
}

View File

@ -17,21 +17,45 @@ namespace BizHawk.Client.EmuHawk
private Atari2600 _core = Global.Emulator as Atari2600;
private readonly List<string> _instructions = new List<string>();
private int _defaultWidth;
private int _defaultHeight;
public Atari2600Debugger()
{
InitializeComponent();
TraceView.QueryItemText += TraceView_QueryItemText;
TraceView.VirtualMode = true;
TopMost = Global.Config.Atari2600DebuggerSettings.TopMost;
//TODO: add to Closing a Mainform.ResumeControl() call
Closing += (o, e) => Shutdown();
}
private void Atari2600Debugger_Load(object sender, EventArgs e)
{
_defaultWidth = Size.Width;
_defaultHeight = Size.Height;
// TODO: some kind of method like PauseAndRelinquishControl() which will set a flag preventing unpausing by the user, and then a ResumeControl() method that is done on close
GlobalWin.MainForm.PauseEmulator();
//GlobalWin.MainForm.PauseEmulator();
Global.CoreComm.Tracer.Enabled = true;
if (Global.Config.Atari2600DebuggerSettings.UseWindowPosition)
{
Location = Global.Config.Atari2600DebuggerSettings.WindowPosition;
}
if (Global.Config.Atari2600DebuggerSettings.UseWindowSize)
{
Size = Global.Config.Atari2600DebuggerSettings.WindowSize;
}
}
private void Shutdown()
{
//TODO: add a Mainform.ResumeControl() call
Global.CoreComm.Tracer.TakeContents();
Global.CoreComm.Tracer.Enabled = false;
}
public void Restart()
@ -41,7 +65,7 @@ namespace BizHawk.Client.EmuHawk
public bool AskSave()
{
return false;
return true;
}
public bool UpdateBefore
@ -139,6 +163,54 @@ namespace BizHawk.Client.EmuHawk
UpdateValues();
}
private void RefreshFloatingWindowControl()
{
Owner = Global.Config.RamSearchSettings.FloatingWindow ? null : GlobalWin.MainForm;
}
#endregion
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{
AutoloadMenuItem.Checked = Global.Config.Atari2600DebuggerAutoload;
SaveWindowPositionMenuItem.Checked = Global.Config.Atari2600DebuggerSettings.SaveWindowPosition;
TopmostMenuItem.Checked = Global.Config.Atari2600DebuggerSettings.TopMost;
FloatingWindowMenuItem.Checked = Global.Config.Atari2600DebuggerSettings.FloatingWindow;
}
private void AutoloadMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Atari2600DebuggerAutoload ^= true;
}
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Atari2600DebuggerSettings.SaveWindowPosition ^= true;
}
private void TopmostMenuItem_Click(object sender, EventArgs e)
{
TopMost = Global.Config.Atari2600DebuggerSettings.TopMost ^= true;
}
private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Atari2600DebuggerSettings.FloatingWindow ^= true;
RefreshFloatingWindowControl();
}
private void RestoreDefaultsMenuItem_Click(object sender, EventArgs e)
{
Size = new Size(_defaultWidth, _defaultHeight);
Global.Config.Atari2600DebuggerSettings = new ToolDialogSettings();
TopMost = Global.Config.Atari2600DebuggerSettings.TopMost;
RefreshFloatingWindowControl();
}
protected override void OnShown(EventArgs e)
{
RefreshFloatingWindowControl();
base.OnShown(e);
}
}
}