Add display type column (resolves #683)
This commit is contained in:
parent
11b6bb6e2f
commit
f983c91eb0
|
@ -268,6 +268,7 @@
|
||||||
<Compile Include="tools\Watch\SeparatorWatch.cs" />
|
<Compile Include="tools\Watch\SeparatorWatch.cs" />
|
||||||
<Compile Include="tools\Watch\Watch.cs" />
|
<Compile Include="tools\Watch\Watch.cs" />
|
||||||
<Compile Include="tools\Watch\WatchList\WatchChangeCountComparer.cs" />
|
<Compile Include="tools\Watch\WatchList\WatchChangeCountComparer.cs" />
|
||||||
|
<Compile Include="tools\Watch\WatchList\WatchDisplayTypeComparer.cs" />
|
||||||
<Compile Include="tools\Watch\WatchList\WatchEqualityComparer.cs" />
|
<Compile Include="tools\Watch\WatchList\WatchEqualityComparer.cs" />
|
||||||
<Compile Include="tools\Watch\WatchList\WatchDomainComparer.cs" />
|
<Compile Include="tools\Watch\WatchList\WatchDomainComparer.cs" />
|
||||||
<Compile Include="tools\Watch\WatchList\WatchAddressComparer.cs" />
|
<Compile Include="tools\Watch\WatchList\WatchAddressComparer.cs" />
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BizHawk.Client.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class hold a collection <see cref="Watch"/>
|
||||||
|
/// </summary>
|
||||||
|
public sealed partial class WatchList
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Nested private class that defines how to compare two <see cref="Watch"/>es based on their full display type
|
||||||
|
/// </summary>
|
||||||
|
private sealed class WatchFullDisplayTypeComparer
|
||||||
|
: WatchEqualityComparer, IComparer<Watch>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Compares two <see cref="Watch"/>es and determines which has greater size.
|
||||||
|
/// If they are equal, comparison will done on the display type and then on endianness
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">First <see cref="Watch"/></param>
|
||||||
|
/// <param name="y">Second <see cref="Watch"/></param>
|
||||||
|
/// <returns>0 for equality, 1 if x comes first; -1 if y comes first</returns>
|
||||||
|
public int Compare(Watch x, Watch y)
|
||||||
|
{
|
||||||
|
if (Equals(x, y))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x.Size.Equals(y.Size))
|
||||||
|
{
|
||||||
|
if (x.Type.Equals(y.Type))
|
||||||
|
{
|
||||||
|
return x.BigEndian.CompareTo(y.BigEndian);
|
||||||
|
}
|
||||||
|
|
||||||
|
return x.Type.CompareTo(y.Type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return x.Size.CompareTo(y.Size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,11 +26,13 @@ namespace BizHawk.Client.Common
|
||||||
public const string PREV = "PrevColumn";
|
public const string PREV = "PrevColumn";
|
||||||
public const string CHANGES = "ChangesColumn";
|
public const string CHANGES = "ChangesColumn";
|
||||||
public const string DIFF = "DiffColumn";
|
public const string DIFF = "DiffColumn";
|
||||||
|
public const string TYPE = "TypeColumn";
|
||||||
public const string DOMAIN = "DomainColumn";
|
public const string DOMAIN = "DomainColumn";
|
||||||
public const string NOTES = "NotesColumn";
|
public const string NOTES = "NotesColumn";
|
||||||
|
|
||||||
private static readonly WatchDomainComparer DomainComparer = new WatchDomainComparer();
|
private static readonly WatchDomainComparer DomainComparer = new WatchDomainComparer();
|
||||||
private static readonly WatchAddressComparer AddressComparer = new WatchAddressComparer();
|
private static readonly WatchAddressComparer AddressComparer = new WatchAddressComparer();
|
||||||
|
private static readonly WatchFullDisplayTypeComparer DisplayTypeComparer = new WatchFullDisplayTypeComparer();
|
||||||
private static readonly WatchValueComparer ValueComparer = new WatchValueComparer();
|
private static readonly WatchValueComparer ValueComparer = new WatchValueComparer();
|
||||||
private static readonly WatchPreviousValueComparer PreviousValueComparer = new WatchPreviousValueComparer();
|
private static readonly WatchPreviousValueComparer PreviousValueComparer = new WatchPreviousValueComparer();
|
||||||
private static readonly WatchValueDifferenceComparer ValueDifferenceComparer = new WatchValueDifferenceComparer();
|
private static readonly WatchValueDifferenceComparer ValueDifferenceComparer = new WatchValueDifferenceComparer();
|
||||||
|
@ -297,6 +299,19 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TYPE:
|
||||||
|
if (reverse)
|
||||||
|
{
|
||||||
|
_watchList.Sort(DisplayTypeComparer);
|
||||||
|
_watchList.Reverse();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_watchList.Sort(DisplayTypeComparer);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case NOTES:
|
case NOTES:
|
||||||
if (reverse)
|
if (reverse)
|
||||||
{
|
{
|
||||||
|
|
|
@ -114,6 +114,7 @@
|
||||||
this.PrevColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.PrevColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.ChangesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.ChangesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.DiffColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.DiffColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
|
this.TypeColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.DomainColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.DomainColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.NotesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.NotesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.ListViewContextMenu.SuspendLayout();
|
this.ListViewContextMenu.SuspendLayout();
|
||||||
|
@ -850,6 +851,7 @@
|
||||||
this.PrevColumn,
|
this.PrevColumn,
|
||||||
this.ChangesColumn,
|
this.ChangesColumn,
|
||||||
this.DiffColumn,
|
this.DiffColumn,
|
||||||
|
this.TypeColumn,
|
||||||
this.DomainColumn,
|
this.DomainColumn,
|
||||||
this.NotesColumn});
|
this.NotesColumn});
|
||||||
this.WatchListView.ContextMenuStrip = this.ListViewContextMenu;
|
this.WatchListView.ContextMenuStrip = this.ListViewContextMenu;
|
||||||
|
@ -907,6 +909,12 @@
|
||||||
this.DiffColumn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
this.DiffColumn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||||
this.DiffColumn.Width = 59;
|
this.DiffColumn.Width = 59;
|
||||||
//
|
//
|
||||||
|
// TypeColumn
|
||||||
|
//
|
||||||
|
this.TypeColumn.Name = "TypeColumn";
|
||||||
|
this.TypeColumn.Text = "Type";
|
||||||
|
this.TypeColumn.Width = 55;
|
||||||
|
//
|
||||||
// DomainColumn
|
// DomainColumn
|
||||||
//
|
//
|
||||||
this.DomainColumn.Name = "DomainColumn";
|
this.DomainColumn.Name = "DomainColumn";
|
||||||
|
@ -959,6 +967,7 @@
|
||||||
private System.Windows.Forms.ColumnHeader PrevColumn;
|
private System.Windows.Forms.ColumnHeader PrevColumn;
|
||||||
private System.Windows.Forms.ColumnHeader ChangesColumn;
|
private System.Windows.Forms.ColumnHeader ChangesColumn;
|
||||||
private System.Windows.Forms.ColumnHeader DiffColumn;
|
private System.Windows.Forms.ColumnHeader DiffColumn;
|
||||||
|
private System.Windows.Forms.ColumnHeader TypeColumn;
|
||||||
private System.Windows.Forms.ColumnHeader DomainColumn;
|
private System.Windows.Forms.ColumnHeader DomainColumn;
|
||||||
private System.Windows.Forms.ColumnHeader NotesColumn;
|
private System.Windows.Forms.ColumnHeader NotesColumn;
|
||||||
private MenuStripEx RamWatchMenu;
|
private MenuStripEx RamWatchMenu;
|
||||||
|
|
|
@ -73,8 +73,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
new Column { Name = WatchList.PREV, Visible = false, Index = 2, Width = 59 },
|
new Column { Name = WatchList.PREV, Visible = false, Index = 2, Width = 59 },
|
||||||
new Column { Name = WatchList.CHANGES, Visible = true, Index = 3, Width = 55 },
|
new Column { Name = WatchList.CHANGES, Visible = true, Index = 3, Width = 55 },
|
||||||
new Column { Name = WatchList.DIFF, Visible = false, Index = 4, Width = 59 },
|
new Column { Name = WatchList.DIFF, Visible = false, Index = 4, Width = 59 },
|
||||||
new Column { Name = WatchList.DOMAIN, Visible = true, Index = 5, Width = 55 },
|
new Column { Name = WatchList.TYPE, Visible = false, Index = 5, Width = 55 },
|
||||||
new Column { Name = WatchList.NOTES, Visible = true, Index = 6, Width = 128 },
|
new Column { Name = WatchList.DOMAIN, Visible = true, Index = 6, Width = 55 },
|
||||||
|
new Column { Name = WatchList.NOTES, Visible = true, Index = 7, Width = 128 },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,6 +429,39 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string ComputeDisplayType(Watch w)
|
||||||
|
{
|
||||||
|
String s = w.Size == WatchSize.Byte ? "1" : (w.Size == WatchSize.Word ? "2" : "4");
|
||||||
|
switch (w.Type)
|
||||||
|
{
|
||||||
|
case Common.DisplayType.Binary:
|
||||||
|
s += "b";
|
||||||
|
break;
|
||||||
|
case Common.DisplayType.FixedPoint_12_4:
|
||||||
|
s += "F";
|
||||||
|
break;
|
||||||
|
case Common.DisplayType.FixedPoint_16_16:
|
||||||
|
s += "F6";
|
||||||
|
break;
|
||||||
|
case Common.DisplayType.FixedPoint_20_12:
|
||||||
|
s += "F2";
|
||||||
|
break;
|
||||||
|
case Common.DisplayType.Float:
|
||||||
|
s += "f";
|
||||||
|
break;
|
||||||
|
case Common.DisplayType.Hex:
|
||||||
|
s += "h";
|
||||||
|
break;
|
||||||
|
case Common.DisplayType.Signed:
|
||||||
|
s += "s";
|
||||||
|
break;
|
||||||
|
case Common.DisplayType.Unsigned:
|
||||||
|
s += "u";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return s + (w.BigEndian ? "B" : "L");
|
||||||
|
}
|
||||||
|
|
||||||
private string GetColumnValue(string name, int index)
|
private string GetColumnValue(string name, int index)
|
||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
|
@ -444,6 +478,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return _watches[index].ChangeCount.ToString();
|
return _watches[index].ChangeCount.ToString();
|
||||||
case WatchList.DIFF:
|
case WatchList.DIFF:
|
||||||
return _watches[index].Diff;
|
return _watches[index].Diff;
|
||||||
|
case WatchList.TYPE:
|
||||||
|
return ComputeDisplayType(_watches[index]);
|
||||||
case WatchList.DOMAIN:
|
case WatchList.DOMAIN:
|
||||||
return _watches[index].Domain.Name;
|
return _watches[index].Domain.Name;
|
||||||
case WatchList.NOTES:
|
case WatchList.NOTES:
|
||||||
|
@ -619,6 +655,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
case WatchList.DIFF:
|
case WatchList.DIFF:
|
||||||
text = _watches[index].Diff;
|
text = _watches[index].Diff;
|
||||||
break;
|
break;
|
||||||
|
case WatchList.TYPE:
|
||||||
|
text = ComputeDisplayType(_watches[index]);
|
||||||
|
break;
|
||||||
case WatchList.DOMAIN:
|
case WatchList.DOMAIN:
|
||||||
text = _watches[index].Domain.Name;
|
text = _watches[index].Domain.Name;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue