Memory Viewer - fix auto highlight next value on memory poke to scroll screen if going off visible area. Hex Editor - implement Goto Address feature

This commit is contained in:
andres.delikat 2011-03-08 14:31:35 +00:00
parent 4909aa8084
commit 89981af655
2 changed files with 38 additions and 6 deletions

View File

@ -14,7 +14,6 @@ namespace BizHawk.MultiClient
{
//TODO:
//Find text box - autohighlights matches, and shows total matches
//Implement Goto address
//Users can customize background, & text colors
//Tool strip
//Double click sends all highlighted to Ram Watch not just currently pointed
@ -154,7 +153,24 @@ namespace BizHawk.MultiClient
private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e)
{
//TODO
InputPrompt i = new InputPrompt();
i.Text = "Go to Address";
i.SetMessage("Enter a hexadecimal value");
i.ShowDialog();
if (i.UserOK)
{
if (InputValidate.IsValidHexNumber(i.UserText))
{
int address = int.Parse(i.UserText, NumberStyles.HexNumber);
if (address < MemoryViewer.GetSize())
{
MemoryViewer.SetHighlighted(address);
MemoryViewer.Refresh();
}
}
}
}

View File

@ -93,12 +93,23 @@ namespace BizHawk.MultiClient
int x = int.Parse(temp, NumberStyles.HexNumber);
Domain.PokeByte(addressHighlighted, (byte)x);
ClearNibbles();
addressHighlighted++;
SetHighlighted(addressHighlighted + 1);
this.Refresh();
}
}
public void SetHighlighted(int addr)
{
if (addr < Domain.Size)
{
if (!IsVisible(addr))
{
vScrollBar1.Value = addr / 16;
}
addressHighlighted = addr;
}
}
//protected unsafe override void OnPaint(PaintEventArgs e)
private void Display(Graphics g)
@ -209,7 +220,7 @@ namespace BizHawk.MultiClient
public void SetUpScrollBar()
{
RowsVisible = this.Height / 16;
RowsVisible = ((this.Height - 8) / 16) - 2;
int totalRows = Domain.Size / 16;
int MaxRows = (totalRows - RowsVisible) + 17;
@ -337,11 +348,11 @@ namespace BizHawk.MultiClient
return -1; //Negative = no address highlighted
}
private bool IsVisible(int addr)
public bool IsVisible(int addr)
{
int row = addr / 16;
if (row >= vScrollBar1.Value && row <= (RowsVisible + vScrollBar1.Value))
if (row >= vScrollBar1.Value && row < (RowsVisible + vScrollBar1.Value))
return true;
else
return false;
@ -353,5 +364,10 @@ namespace BizHawk.MultiClient
if (addressHighlighted >= 0)
Domain.PokeByte(addressHighlighted, (byte)value);
}
public int GetSize()
{
return Domain.Size;
}
}
}