Debugger: Improved scanline/cycle fields' usability

This commit is contained in:
Souryo 2017-09-29 20:54:09 -04:00
parent a04a8747ba
commit 99d1728da9
3 changed files with 57 additions and 28 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
@ -12,29 +13,15 @@ namespace Mesen.GUI.Controls
{
private NumericUpDown nud;
public event EventHandler ValueChanged
{
add { nud.ValueChanged += value; }
remove { nud.ValueChanged -= value; }
}
public event EventHandler ValueChanged { add { nud.ValueChanged += value; } remove { nud.ValueChanged -= value; } }
public new event EventHandler Validated { add { nud.Validated += value; } remove { nud.Validated -= value; } }
public new event EventHandler Click { add { nud.Click += value; } remove { nud.Click -= value; } }
public new event KeyEventHandler KeyDown { add { nud.KeyDown += value; } remove { nud.KeyDown -= value; } }
public new event KeyPressEventHandler KeyPress { add { nud.KeyPress += value; } remove { nud.KeyPress -= value; } }
public new event EventHandler Validated
{
add { nud.Validated += value; }
remove { nud.Validated -= value; }
}
public new event EventHandler Click
{
add { nud.Click += value; }
remove { nud.Click -= value; }
}
public new event KeyEventHandler KeyDown
{
add { nud.KeyDown += value; }
remove { nud.KeyDown -= value; }
}
[Browsable(true)]
[EditorBrowsable(EditorBrowsableState.Always)]
public new event EventHandler TextChanged { add { nud.TextChanged += value; } remove { nud.TextChanged -= value; } }
public decimal Value
{

View file

@ -51,9 +51,9 @@ namespace Mesen.GUI.Debugger
this.ctrlPaletteViewer = new Mesen.GUI.Debugger.Controls.ctrlPaletteViewer();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.lblShowFrameAt = new System.Windows.Forms.Label();
this.nudScanline = new MesenNumericUpDown();
this.nudScanline = new Mesen.GUI.Controls.MesenNumericUpDown();
this.lblCycle = new System.Windows.Forms.Label();
this.nudCycle = new MesenNumericUpDown();
this.nudCycle = new Mesen.GUI.Controls.MesenNumericUpDown();
this.btnReset = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
this.tabMain.SuspendLayout();
@ -241,12 +241,19 @@ namespace Mesen.GUI.Debugger
// nudScanline
//
this.nudScanline.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.nudScanline.DecimalPlaces = 0;
this.nudScanline.Increment = new decimal(new int[] {
1,
0,
0,
0});
this.nudScanline.Location = new System.Drawing.Point(275, 4);
this.nudScanline.Maximum = new decimal(new int[] {
260,
0,
0,
0});
this.nudScanline.MaximumSize = new System.Drawing.Size(10000, 20);
this.nudScanline.Minimum = new decimal(new int[] {
1,
0,
@ -261,6 +268,7 @@ namespace Mesen.GUI.Debugger
0,
0});
this.nudScanline.ValueChanged += new System.EventHandler(this.nudScanlineCycle_ValueChanged);
this.nudScanline.TextChanged += new System.EventHandler(this.nudScanlineCycle_TextChanged);
//
// lblCycle
//
@ -275,16 +283,34 @@ namespace Mesen.GUI.Debugger
// nudCycle
//
this.nudCycle.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.nudCycle.DecimalPlaces = 0;
this.nudCycle.Increment = new decimal(new int[] {
1,
0,
0,
0});
this.nudCycle.Location = new System.Drawing.Point(392, 4);
this.nudCycle.Maximum = new decimal(new int[] {
340,
0,
0,
0});
this.nudCycle.MaximumSize = new System.Drawing.Size(10000, 20);
this.nudCycle.Minimum = new decimal(new int[] {
0,
0,
0,
0});
this.nudCycle.Name = "nudCycle";
this.nudCycle.Size = new System.Drawing.Size(52, 20);
this.nudCycle.TabIndex = 6;
this.nudCycle.Value = new decimal(new int[] {
0,
0,
0,
0});
this.nudCycle.ValueChanged += new System.EventHandler(this.nudScanlineCycle_ValueChanged);
this.nudCycle.TextChanged += new System.EventHandler(this.nudScanlineCycle_TextChanged);
//
// btnReset
//

View file

@ -120,12 +120,28 @@ namespace Mesen.GUI.Debugger
ConfigManager.ApplyChanges();
}
private void SetUpdateScanlineCycle(int scanline, int cycle)
{
scanline = Math.Min(260, Math.Max(-1, scanline));
cycle = Math.Min(340, Math.Max(0, cycle));
InteropEmu.DebugSetPpuViewerScanlineCycle(scanline, cycle);
ConfigManager.Config.DebugInfo.PpuDisplayScanline = scanline;
ConfigManager.Config.DebugInfo.PpuDisplayCycle = cycle;
ConfigManager.ApplyChanges();
}
private void nudScanlineCycle_TextChanged(object sender, EventArgs e)
{
int scanline, cycle;
if(int.TryParse(this.nudScanline.Text, out scanline) && int.TryParse(this.nudCycle.Text, out cycle)) {
SetUpdateScanlineCycle(int.Parse(this.nudScanline.Text), int.Parse(this.nudCycle.Text));
}
}
private void nudScanlineCycle_ValueChanged(object sender, EventArgs e)
{
InteropEmu.DebugSetPpuViewerScanlineCycle((int)this.nudScanline.Value, (int)this.nudCycle.Value);
ConfigManager.Config.DebugInfo.PpuDisplayScanline = (int)this.nudScanline.Value;
ConfigManager.Config.DebugInfo.PpuDisplayCycle = (int)this.nudCycle.Value;
ConfigManager.ApplyChanges();
SetUpdateScanlineCycle((int)this.nudScanline.Value, (int)this.nudCycle.Value);
}
private void tabMain_SelectedIndexChanged(object sender, EventArgs e)