Watch object - add ValueToString() and PrevToString() methods and make Ram Watch use these methods and thus simplify the UpdateValues logic. Added an override for ToString() that displays notes + value in preparation for a on screen ram watch option.

This commit is contained in:
andres.delikat 2011-09-12 00:17:17 +00:00
parent 7db54e08a8
commit 73add14d28
2 changed files with 70 additions and 52 deletions

View File

@ -153,7 +153,7 @@ namespace BizHawk.MultiClient
e.Cancel = true;
base.OnClosing(e);
}
private void WatchListView_QueryItemBkColor(int index, int column, ref Color color)
{
if (column == 0)
@ -177,34 +177,7 @@ namespace BizHawk.MultiClient
}
if (column == 1) //Value
{
if (watchList[index].type == atype.SEPARATOR)
text = "";
else
{
switch (watchList[index].signed)
{
case asigned.HEX:
switch (watchList[index].type)
{
case atype.BYTE:
text = String.Format("{0:X2}", watchList[index].value);
break;
case atype.WORD:
text = String.Format("{0:X4}", watchList[index].value);
break;
case atype.DWORD:
text = String.Format("{0:X8}", watchList[index].value);
break;
}
break;
case asigned.SIGNED:
text = ((sbyte)watchList[index].value).ToString();
break;
case asigned.UNSIGNED:
text = watchList[index].value.ToString();
break;
}
}
text = watchList[index].ValueToString();
}
if (column == 2) //Prev
{
@ -222,29 +195,7 @@ namespace BizHawk.MultiClient
}
else
{
switch (watchList[index].signed)
{
case asigned.HEX:
switch (watchList[index].type)
{
case atype.BYTE:
text = String.Format("{0:X2}", watchList[index].prev);
break;
case atype.WORD:
text = String.Format("{0:X4}", watchList[index].prev);
break;
case atype.DWORD:
text = String.Format("{0:X8}", watchList[index].prev);
break;
}
break;
case asigned.SIGNED:
text = ((sbyte)watchList[index].prev).ToString();
break;
case asigned.UNSIGNED:
text = watchList[index].prev.ToString();
break;
}
text = watchList[index].PrevToString();
}
}
}

View File

@ -231,6 +231,73 @@ namespace BizHawk.MultiClient
}
}
public override string ToString()
{
if (type == atype.SEPARATOR)
return "";
StringBuilder str = new StringBuilder(notes);
str.Append(": ");
str.Append(ValueToString());
return str.ToString();
}
public string ValueToString()
{
if (type == atype.SEPARATOR)
return "";
else
{
switch (signed)
{
case asigned.HEX:
switch (type)
{
default:
case atype.BYTE:
return String.Format("{0:X2}", value);
case atype.WORD:
return String.Format("{0:X4}", value);
case atype.DWORD:
return String.Format("{0:X8}", value);
}
case asigned.SIGNED:
return ((sbyte)value).ToString();
default:
case asigned.UNSIGNED:
return value.ToString();
}
}
}
public string PrevToString()
{
if (type == atype.SEPARATOR)
return "";
else
{
switch (signed)
{
case asigned.HEX:
switch (type)
{
default:
case atype.BYTE:
return String.Format("{0:X2}", prev);
case atype.WORD:
return String.Format("{0:X4}", prev);
case atype.DWORD:
return String.Format("{0:X8}", prev);
}
case asigned.SIGNED:
return ((sbyte)prev).ToString();
default:
case asigned.UNSIGNED:
return prev.ToString();
}
}
}
private int CompareAddress(Watch Other)
{
if (this.address < Other.address)