Final stuff to WatchList
Now fully use comparer class. That saves memory and offer extensibility ItemCount property obsolete => Moved to Count property (which did the same thing) Moved ConfigPersistAttribute.cs, IToolForm.cs, IToolFormAutoConfig.cs back to common
This commit is contained in:
parent
8a6ddfbf3f
commit
708bb4fa93
|
@ -59,10 +59,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Attributes\ConfigPersistAttribute.cs" />
|
||||
<Compile Include="Interfaces\IToolFormAutoConfig.cs" />
|
||||
<Compile Include="Interfaces\IExternalToolForm.cs" />
|
||||
<Compile Include="Interfaces\IToolForm.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -80,6 +77,7 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Attributes\" />
|
||||
<Folder Include="Classes\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1" MembersFormat="FullSignature">
|
||||
<Class Name="BizHawk.Client.EmuHawk.ConfigPersistAttribute">
|
||||
<Position X="11.5" Y="0.75" Width="1.75" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Attributes\ConfigPersistAttribute.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="BizHawk.Client.Common.Watch">
|
||||
<Position X="17" Y="0.75" Width="8.75" />
|
||||
<Compartments>
|
||||
|
@ -36,14 +29,13 @@
|
|||
<Compartments>
|
||||
<Compartment Name="Nested Types" Collapsed="false" />
|
||||
</Compartments>
|
||||
<NestedTypes>
|
||||
<Enum Name="BizHawk.Client.Common.WatchList.WatchPrevDef">
|
||||
<TypeIdentifier />
|
||||
</Enum>
|
||||
</NestedTypes>
|
||||
<TypeIdentifier />
|
||||
<Lollipop Orientation="Right" Position="0.1" />
|
||||
</Class>
|
||||
<Class Name="BizHawk.Client.EmuHawk.ConfigPersistAttribute">
|
||||
<Position X="11.5" Y="0.75" Width="2" />
|
||||
<TypeIdentifier />
|
||||
</Class>
|
||||
<Interface Name="BizHawk.Client.EmuHawk.IExternalToolForm">
|
||||
<Position X="4.5" Y="4.5" Width="2.75" />
|
||||
<TypeIdentifier>
|
||||
|
@ -53,17 +45,11 @@
|
|||
</Interface>
|
||||
<Interface Name="BizHawk.Client.EmuHawk.IToolForm">
|
||||
<Position X="6" Y="0.75" Width="2.25" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>ECAAAAAAAABACAAgAAEAABAAAAAEAAAAAAAAAACAQAA=</HashCode>
|
||||
<FileName>Interfaces\IToolForm.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<TypeIdentifier />
|
||||
</Interface>
|
||||
<Interface Name="BizHawk.Client.EmuHawk.IToolFormAutoConfig">
|
||||
<Position X="8" Y="4.5" Width="1.75" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Interfaces\IToolFormAutoConfig.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<TypeIdentifier />
|
||||
</Interface>
|
||||
<Enum Name="BizHawk.Client.Common.WatchSize">
|
||||
<Position X="26.5" Y="3.75" Width="1.5" />
|
||||
|
|
|
@ -105,6 +105,7 @@
|
|||
<Compile Include="BitmapBufferVideoProvider.cs" />
|
||||
<Compile Include="config\Binding.cs" />
|
||||
<Compile Include="config\Config.cs" />
|
||||
<Compile Include="config\ConfigPersistAttribute.cs" />
|
||||
<Compile Include="config\ConfigService.cs" />
|
||||
<Compile Include="config\PathEntry.cs" />
|
||||
<Compile Include="config\ToolDialogSettings.cs" />
|
||||
|
@ -232,6 +233,8 @@
|
|||
<Compile Include="SystemInfo.cs" />
|
||||
<Compile Include="tools\Cheat.cs" />
|
||||
<Compile Include="tools\CheatList.cs" />
|
||||
<Compile Include="tools\Interfaces\IToolForm.cs" />
|
||||
<Compile Include="tools\Interfaces\IToolFormAutoConfig.cs" />
|
||||
<Compile Include="tools\Watch\ByteWatch.cs" />
|
||||
<Compile Include="tools\Watch\DisplayType.cs" />
|
||||
<Compile Include="tools\Watch\DWordWatch.cs" />
|
||||
|
@ -239,9 +242,15 @@
|
|||
<Compile Include="tools\RamSearchEngine.cs" />
|
||||
<Compile Include="tools\Watch\SeparatorWatch.cs" />
|
||||
<Compile Include="tools\Watch\Watch.cs" />
|
||||
<Compile Include="tools\Watch\WatchList\WatchChangeCountComparer.cs" />
|
||||
<Compile Include="tools\Watch\WatchList\WatchEqualityComparer.cs" />
|
||||
<Compile Include="tools\Watch\WatchList\WatchDomainComparer.cs" />
|
||||
<Compile Include="tools\Watch\WatchList\WatchAddressComparer.cs" />
|
||||
<Compile Include="tools\Watch\WatchList\WatchList.cs" />
|
||||
<Compile Include="tools\Watch\WatchList\WatchNoteComparer.cs" />
|
||||
<Compile Include="tools\Watch\WatchList\WatchPreviousValueComparer.cs" />
|
||||
<Compile Include="tools\Watch\WatchList\WatchValueComparer.cs" />
|
||||
<Compile Include="tools\Watch\WatchList\WatchValueDifferenceComparer.cs" />
|
||||
<Compile Include="tools\Watch\WatchSize.cs" />
|
||||
<Compile Include="tools\Watch\WordWatch.cs" />
|
||||
<Compile Include="XmlGame.cs" />
|
||||
|
|
|
@ -232,7 +232,18 @@ namespace BizHawk.Client.Common
|
|||
/// <returns>True if they are equals; otherwise, false</returns>
|
||||
public static bool operator ==(Watch a, Cheat b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
if (object.ReferenceEquals(a, null) || object.ReferenceEquals(b, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (object.ReferenceEquals(a, b))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -12,83 +12,40 @@ namespace BizHawk.Client.Common
|
|||
/// Netsed private class that define how to compare two <see cref="Watch"/>
|
||||
/// based on their address
|
||||
/// </summary>
|
||||
private struct WatchAddressComparer
|
||||
: IEqualityComparer<Watch>,
|
||||
private sealed class WatchAddressComparer
|
||||
: WatchEqualityComparer,
|
||||
IComparer<Watch>
|
||||
{
|
||||
/// <summary>
|
||||
/// Compare two <see cref="Watch"/> between them
|
||||
/// and determine wich one comes first.
|
||||
/// Compares two <see cref="Watch"/> between them
|
||||
/// and determines wich one comes first.
|
||||
/// If they are equals, comapraison will done one the domain and next on size
|
||||
/// </summary>
|
||||
/// <param name="x">First <see cref="Watch"/></param>
|
||||
/// <returns>True if <see cref="Watch"/> are equal; otherwise, false</returns>
|
||||
/// <returns></returns>
|
||||
/// <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;
|
||||
}
|
||||
else if (x.Address.Equals(y.Address))
|
||||
{
|
||||
if (x.Domain.Name.Equals(y.Domain.Name))
|
||||
if (Equals(x, y))
|
||||
{
|
||||
return x.Size.CompareTo(y.Size);
|
||||
return 0;
|
||||
}
|
||||
else if (x.Address.Equals(y.Address))
|
||||
{
|
||||
if (x.Domain.Name.Equals(y.Domain.Name))
|
||||
{
|
||||
return x.Size.CompareTo(y.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Domain.Name.CompareTo(y.Domain.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Domain.Name.CompareTo(y.Domain.Name);
|
||||
return x.Address.CompareTo(y.Address);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Address.CompareTo(y.Address);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if two <see cref="Watch"/> are equals
|
||||
/// </summary>
|
||||
/// <param name="x">First <see cref="Watch"/></param>
|
||||
/// <param name="y">Second <see cref="Watch"/></param>
|
||||
/// <returns>True if <see cref="Watch"/> are equal; otherwise, false</returns>
|
||||
public bool Equals(Watch x, Watch y)
|
||||
{
|
||||
if (object.ReferenceEquals(x, null))
|
||||
{
|
||||
if (object.ReferenceEquals(y, null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (object.ReferenceEquals(y, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (object.ReferenceEquals(x, y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Address.Equals(y.Address);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the hash value of specified <see cref="Watch"/>
|
||||
/// </summary>
|
||||
/// <param name="obj">Watch to get hash</param>
|
||||
/// <returns>int that can serves as a unique representation of current Watch</returns>
|
||||
public int GetHashCode(Watch obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// This class hold a collection <see cref="Watch"/>
|
||||
/// Different memory domain can be mixed
|
||||
/// </summary>
|
||||
public sealed partial class WatchList
|
||||
{
|
||||
/// <summary>
|
||||
/// Netsed private class that define how to compare two <see cref="Watch"/>
|
||||
/// based on the number of changes
|
||||
/// </summary>
|
||||
private sealed class WatchChangeCountComparer
|
||||
:WatchEqualityComparer
|
||||
,IComparer<Watch>
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Watch"/> between them
|
||||
/// and determines wich one comes first.
|
||||
/// If they are equals, comapraison will done one the address and next on size
|
||||
/// </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;
|
||||
}
|
||||
else if (x.ChangeCount.Equals(y.ChangeCount))
|
||||
{
|
||||
if (x.Address.Equals(y.Address))
|
||||
{
|
||||
return x.Size.CompareTo(y.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Address.CompareTo(y.Address);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.ChangeCount.CompareTo(y.ChangeCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,25 +12,25 @@ namespace BizHawk.Client.Common
|
|||
/// Netsed private class that define how to compare two <see cref="Watch"/>
|
||||
/// based on their domain
|
||||
/// </summary>
|
||||
private struct WatchDomainComparer
|
||||
: IEqualityComparer<Watch>,
|
||||
private sealed class WatchDomainComparer
|
||||
: WatchEqualityComparer,
|
||||
IComparer<Watch>
|
||||
{
|
||||
/// <summary>
|
||||
/// Compare two <see cref="Watch"/> between them
|
||||
/// and determine wich one comes first.
|
||||
/// Compares two <see cref="Watch"/> between them
|
||||
/// and determines wich one comes first.
|
||||
/// If they are equals, comapraison will done one the address and next on size
|
||||
/// </summary>
|
||||
/// <param name="x">First <see cref="Watch"/></param>
|
||||
/// <returns>True if <see cref="Watch"/> are equal; otherwise, false</returns>
|
||||
/// <returns></returns>
|
||||
///<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))
|
||||
if (Equals(x, y))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if(x.Domain.Name.Equals(y.Domain.Name))
|
||||
else if (x.Domain.Name.Equals(y.Domain.Name))
|
||||
{
|
||||
if (x.Address.Equals(y.Address))
|
||||
{
|
||||
|
@ -46,49 +46,6 @@ namespace BizHawk.Client.Common
|
|||
return x.Domain.Name.CompareTo(y.Domain.Name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if two <see cref="Watch"/> are equals
|
||||
/// </summary>
|
||||
/// <param name="x">First <see cref="Watch"/></param>
|
||||
/// <param name="y">Second <see cref="Watch"/></param>
|
||||
/// <returns>True if <see cref="Watch"/> are equal; otherwise, false</returns>
|
||||
public bool Equals(Watch x, Watch y)
|
||||
{
|
||||
if(object.ReferenceEquals(x, null))
|
||||
{
|
||||
if(object.ReferenceEquals(y, null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(object.ReferenceEquals(y, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(object.ReferenceEquals(x,y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Domain.Name.Equals(y.Domain.Name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the hash value of specified <see cref="Watch"/>
|
||||
/// </summary>
|
||||
/// <param name="obj">Watch to get hash</param>
|
||||
/// <returns>int that can serves as a unique representation of current Watch</returns>
|
||||
public int GetHashCode(Watch obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// This class hold a collection <see cref="Watch"/>
|
||||
/// Different memory domain can be mixed
|
||||
/// </summary>
|
||||
public sealed partial class WatchList
|
||||
{
|
||||
private class WatchEqualityComparer
|
||||
: IEqualityComparer<Watch>
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines if two <see cref="Watch"/> are equals
|
||||
/// </summary>
|
||||
/// <param name="x">First <see cref="Watch"/></param>
|
||||
/// <param name="y">Second <see cref="Watch"/></param>
|
||||
/// <returns>True if <see cref="Watch"/> are equal; otherwise, false</returns>
|
||||
public bool Equals(Watch x, Watch y)
|
||||
{
|
||||
if (ReferenceEquals(x, null))
|
||||
{
|
||||
if (ReferenceEquals(y, null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (ReferenceEquals(y, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (ReferenceEquals(x, y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash value of specified <see cref="Watch"/>
|
||||
/// </summary>
|
||||
/// <param name="obj">Watch to get hash</param>
|
||||
/// <returns>int that can serves as a unique representation of current Watch</returns>
|
||||
public int GetHashCode(Watch obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,6 +33,11 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private static readonly WatchDomainComparer domainComparer = new WatchDomainComparer();
|
||||
private static readonly WatchAddressComparer addressComparer = new WatchAddressComparer();
|
||||
private static readonly WatchValueComparer valueComparer = new WatchValueComparer();
|
||||
private static readonly WatchPreviousValueComparer previousValueComparer = new WatchPreviousValueComparer();
|
||||
private static readonly WatchValueDifferenceComparer valueDifferenceComparer = new WatchValueDifferenceComparer();
|
||||
private static readonly WatchChangeCountComparer changeCountComparer = new WatchChangeCountComparer();
|
||||
private static readonly WatchNoteComparer noteComparer = new WatchNoteComparer();
|
||||
|
||||
private static IMemoryDomains _memoryDomains;
|
||||
|
||||
|
@ -256,92 +261,58 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
|
||||
case VALUE:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => x.Value)
|
||||
.ThenBy(x => x.Address)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ThenBy(x => x.BigEndian)
|
||||
.ToList();
|
||||
_watchList.Sort(valueComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => x.Value)
|
||||
.ThenBy(x => x.Address)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ThenBy(x => x.BigEndian)
|
||||
.ToList();
|
||||
_watchList.Sort(valueComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
case PREV: // Note: these only work if all entries are detailed objects!
|
||||
|
||||
case PREV:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => x.PreviousStr)
|
||||
.ThenBy(x => x.Address)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
_watchList.Sort(previousValueComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => x.PreviousStr)
|
||||
.ThenBy(x => x.Address)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
_watchList.Sort(previousValueComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DIFF:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => x.Diff)
|
||||
.ThenBy(x => x.Address)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
_watchList.Sort(valueDifferenceComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => x.Diff)
|
||||
.ThenBy(x => x.Address)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
_watchList.Sort(valueDifferenceComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CHANGES:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => x.ChangeCount)
|
||||
.ThenBy(x => x.Address)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
_watchList.Sort(changeCountComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => x.ChangeCount)
|
||||
.ThenBy(x => x.Address)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
_watchList.Sort(changeCountComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DOMAIN:
|
||||
if (reverse)
|
||||
{
|
||||
|
@ -354,24 +325,16 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
|
||||
case NOTES:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => x.Notes)
|
||||
.ThenBy(x => x.Address)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
_watchList.Sort(noteComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => x.Notes)
|
||||
.ThenBy(x => x.Address)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
_watchList.Sort(noteComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -521,7 +484,14 @@ namespace BizHawk.Client.Common
|
|||
});
|
||||
}
|
||||
|
||||
[Obsolete("Use count property instead")]
|
||||
[Obsolete("Use domain from individual watch instead")]
|
||||
public MemoryDomain Domain
|
||||
{
|
||||
get { return _domain; }
|
||||
set { _domain = value; }
|
||||
}
|
||||
|
||||
[Obsolete("Use count property instead", true)]
|
||||
public int ItemCount
|
||||
{
|
||||
get
|
||||
|
@ -530,13 +500,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
[Obsolete("Use domain from individual watch instead")]
|
||||
public MemoryDomain Domain
|
||||
{
|
||||
get { return _domain; }
|
||||
set { _domain = value; }
|
||||
}
|
||||
|
||||
#region File handling logic - probably needs to be its own class
|
||||
|
||||
public bool Load(string path, bool append)
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// This class hold a collection <see cref="Watch"/>
|
||||
/// Different memory domain can be mixed
|
||||
/// </summary>
|
||||
public sealed partial class WatchList
|
||||
{
|
||||
/// <summary>
|
||||
/// Netsed private class that define how to compare two <see cref="Watch"/>
|
||||
/// based on their note
|
||||
/// </summary>
|
||||
private sealed class WatchNoteComparer
|
||||
:WatchEqualityComparer,
|
||||
IComparer<Watch>
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Watch"/> between them
|
||||
/// and determines wich one comes first.
|
||||
/// If they are equals, comapraison will done one the address and next on size
|
||||
/// </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;
|
||||
}
|
||||
else if (string.Compare(x.Notes, y.Notes, true) == 0)
|
||||
{
|
||||
if (x.Address.Equals(y.Address))
|
||||
{
|
||||
return x.Size.CompareTo(y.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Address.CompareTo(y.Address);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Compare(x.Notes, y.Notes, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// This class hold a collection <see cref="Watch"/>
|
||||
/// Different memory domain can be mixed
|
||||
/// </summary>
|
||||
public sealed partial class WatchList
|
||||
{
|
||||
/// <summary>
|
||||
/// Netsed private class that define how to compare two <see cref="Watch"/>
|
||||
/// based on their previous value
|
||||
/// </summary>
|
||||
private sealed class WatchPreviousValueComparer
|
||||
: WatchEqualityComparer,
|
||||
IComparer<Watch>
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Watch"/> between them
|
||||
/// and determines wich one comes first.
|
||||
/// If they are equals, comapraison will done one the address and next on size
|
||||
/// </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;
|
||||
}
|
||||
else if (x.Previous.Equals(y.Previous))
|
||||
{
|
||||
if (x.Address.Equals(y.Address))
|
||||
{
|
||||
return x.Size.CompareTo(y.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Address.CompareTo(y.Address);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Previous.CompareTo(y.Previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// This class hold a collection <see cref="Watch"/>
|
||||
/// Different memory domain can be mixed
|
||||
/// </summary>
|
||||
public sealed partial class WatchList
|
||||
{
|
||||
/// <summary>
|
||||
/// Netsed private class that define how to compare two <see cref="Watch"/>
|
||||
/// based on their values
|
||||
/// </summary>
|
||||
private sealed class WatchValueComparer
|
||||
: WatchEqualityComparer,
|
||||
IComparer<Watch>
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Watch"/> between them
|
||||
/// and determines wich one comes first.
|
||||
/// If they are equals, comapraison will done one the address and next on size
|
||||
/// </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)
|
||||
{
|
||||
int xValue;
|
||||
int yValue;
|
||||
|
||||
if (x.Type == DisplayType.Signed)
|
||||
{
|
||||
int.TryParse(x.ValueString, out xValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
xValue = x.Value;
|
||||
}
|
||||
|
||||
if (y.Type == DisplayType.Signed)
|
||||
{
|
||||
int.TryParse(y.ValueString, out yValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
yValue = y.Value;
|
||||
}
|
||||
|
||||
if (Equals(x, y))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (xValue.Equals(yValue))
|
||||
{
|
||||
if (x.Address.Equals(y.Address))
|
||||
{
|
||||
return x.Size.CompareTo(y.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Address.CompareTo(y.Address);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return xValue.CompareTo(yValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// This class hold a collection <see cref="Watch"/>
|
||||
/// Different memory domain can be mixed
|
||||
/// </summary>
|
||||
public sealed partial class WatchList
|
||||
{
|
||||
/// <summary>
|
||||
/// Netsed private class that define how to compare two <see cref="Watch"/>
|
||||
/// based on the diffence between current and previous value
|
||||
/// </summary>
|
||||
private sealed class WatchValueDifferenceComparer
|
||||
: WatchEqualityComparer
|
||||
, IComparer<Watch>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Watch"/> between them
|
||||
/// and determines wich one comes first.
|
||||
/// If they are equals, comapraison will done one the address and next on size
|
||||
/// </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;
|
||||
}
|
||||
else if (x.Diff.Equals(y.Diff))
|
||||
{
|
||||
if (x.Address.Equals(y.Address))
|
||||
{
|
||||
return x.Size.CompareTo(y.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Address.CompareTo(y.Address);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.Diff.CompareTo(y.Diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -119,7 +119,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void AddWatch(Watch watch)
|
||||
{
|
||||
_watches.Add(watch);
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
UpdateValues();
|
||||
UpdateWatchCount();
|
||||
Changes();
|
||||
|
@ -176,7 +176,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
else
|
||||
{
|
||||
Global.Config.RecentWatches.Add(path);
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
UpdateWatchCount();
|
||||
UpdateStatusBar();
|
||||
_watches.Changes = false;
|
||||
|
@ -197,7 +197,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (result)
|
||||
{
|
||||
_watches.Load(file.FullName, append);
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
UpdateWatchCount();
|
||||
Global.Config.RecentWatches.Add(_watches.CurrentFileName);
|
||||
SetMemoryDomain(_watches.Domain.ToString());
|
||||
|
@ -386,7 +386,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void FullyUpdateWatchList()
|
||||
{
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
UpdateWatchCount();
|
||||
UpdateStatusBar();
|
||||
UpdateValues();
|
||||
|
@ -417,7 +417,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (duplicate)
|
||||
{
|
||||
_watches.AddRange(we.Watches);
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -499,7 +499,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (result || suppressAsk)
|
||||
{
|
||||
_watches.Clear();
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
UpdateWatchCount();
|
||||
UpdateStatusBar();
|
||||
_sortReverse = false;
|
||||
|
@ -598,7 +598,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void WatchListView_QueryItemBkColor(int index, int column, ref Color color)
|
||||
{
|
||||
if (index >= _watches.ItemCount)
|
||||
if (index >= _watches.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -624,7 +624,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
text = string.Empty;
|
||||
|
||||
if (index >= _watches.ItemCount || _watches[index].IsSeparator)
|
||||
if (index >= _watches.Count || _watches[index].IsSeparator)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_watches.Add(we.Watches[0]);
|
||||
Changes();
|
||||
UpdateWatchCount();
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
UpdateValues();
|
||||
}
|
||||
}
|
||||
|
@ -784,7 +784,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_watches.Remove(item);
|
||||
}
|
||||
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
UpdateValues();
|
||||
UpdateWatchCount();
|
||||
}
|
||||
|
@ -838,7 +838,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_watches.Add(SeparatorWatch.Instance);
|
||||
}
|
||||
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
Changes();
|
||||
UpdateWatchCount();
|
||||
}
|
||||
|
@ -873,7 +873,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
WatchListView.SelectItem(t, true);
|
||||
}
|
||||
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
}
|
||||
|
||||
private void MoveDownMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -900,7 +900,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
Changes();
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
}
|
||||
|
||||
private void SelectAllMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -1037,8 +1037,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
_watches.Load(filePaths[0], append: false);
|
||||
Global.Config.RecentWatches.Add(_watches.CurrentFileName);
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
}
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
}
|
||||
}
|
||||
|
||||
private void NewRamWatch_Enter(object sender, EventArgs e)
|
||||
|
@ -1205,7 +1205,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_watches.Remove(item);
|
||||
}
|
||||
|
||||
WatchListView.ItemCount = _watches.ItemCount;
|
||||
WatchListView.ItemCount = _watches.Count;
|
||||
UpdateValues();
|
||||
UpdateWatchCount();
|
||||
UpdateStatusBar();
|
||||
|
|
18
BizHawk.sln
18
BizHawk.sln
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Version", "Version\Version.csproj", "{0CE8B337-08E3-4602-BF10-C4D4C75D2F13}"
|
||||
EndProject
|
||||
|
@ -250,18 +250,18 @@ Global
|
|||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Win32.Build.0 = Debug|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Win32.ActiveCfg = Debug|x86
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Win32.Build.0 = Debug|x86
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|x86.Build.0 = Debug|x86
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Win32.Build.0 = Release|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|x86.Build.0 = Release|Any CPU
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Win32.ActiveCfg = Release|x86
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Win32.Build.0 = Release|x86
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|x86.ActiveCfg = Release|x86
|
||||
{8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Loading…
Reference in New Issue