Breakpoints - add in a notion of readonly since we are showing all callbacks in the core, even ones the debugger didn't create, and the debugger managing ones it didn't create is bad news

This commit is contained in:
adelikat 2014-12-10 23:11:04 +00:00
parent cdcb806d8c
commit ab312add39
2 changed files with 30 additions and 14 deletions

View File

@ -52,6 +52,8 @@ namespace BizHawk.Client.EmuHawk
public MemoryCallbackType Type { get; set; }
public string Name { get; set; }
public bool ReadOnly { get; private set; }
// Adds an existing callback
public Breakpoint(IDebuggable core, IMemoryCallback callback)
{
@ -61,6 +63,10 @@ namespace BizHawk.Client.EmuHawk
Address = callback.Address;
Type = callback.Type;
Name = callback.Name;
// We don't know where this callback came from so don't let the user mess with it
// Most likely it came from lua and doing so could cause some bad things to happen
ReadOnly = true;
}
public bool Active
@ -72,17 +78,20 @@ namespace BizHawk.Client.EmuHawk
set
{
if (!value)
if (!ReadOnly)
{
RemoveCallback();
}
if (!value)
{
RemoveCallback();
}
if (!_active && value) // If inactive and changing to active
{
AddCallback();
}
if (!_active && value) // If inactive and changing to active
{
AddCallback();
}
_active = value;
_active = value;
}
}
}

View File

@ -51,7 +51,9 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
private void BreakPointView_QueryItemBkColor(int index, int column, ref Color color)
{
color = Breakpoints[index].Active ? Color.LightCyan : SystemColors.Control;
color = Breakpoints[index].ReadOnly ? SystemColors.Control
: Breakpoints[index].Active ? Color.LightCyan
: Color.White;
}
private void BreakpointCallback()
@ -114,11 +116,16 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
get { return SelectedIndices.Select(index => Breakpoints[index]); }
}
private IEnumerable<Breakpoint> EditableItems
{
get { return SelectedItems.Where(item => !item.ReadOnly); }
}
private void RemoveBreakpointButton_Click(object sender, EventArgs e)
{
if (BreakpointView.SelectedIndices.Count > 0)
if (EditableItems.Any())
{
var items = SelectedItems.ToList();
var items = EditableItems.ToList();
if (items.Any())
{
foreach (var item in items)
@ -134,7 +141,7 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
private void UpdateBreakpointRemoveButton()
{
RemoveBreakpointButton.Enabled = BreakpointView.SelectedIndices.Count > 0;
RemoveBreakpointButton.Enabled = EditableItems.Any();
}
private void BreakpointView_SelectedIndexChanged(object sender, EventArgs e)
@ -144,9 +151,9 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
private void BreakpointView_ItemActivate(object sender, EventArgs e)
{
if (BreakpointView.SelectedIndices.Count > 0)
if (EditableItems.Any())
{
var items = SelectedItems.ToList();
var items = EditableItems.ToList();
if (items.Any())
{
foreach (var item in items)