More WatchList comments
Finished coments on WatchList object
This commit is contained in:
parent
0f6ef723bf
commit
31cc08a954
|
@ -266,3 +266,4 @@
|
||||||
/LuaInterface/Lua/src/Release-LUAPERKS
|
/LuaInterface/Lua/src/Release-LUAPERKS
|
||||||
/LuaInterface/Release-LUAPERKS
|
/LuaInterface/Release-LUAPERKS
|
||||||
output/BizHawk.Client.ApiHawk.dll
|
output/BizHawk.Client.ApiHawk.dll
|
||||||
|
output/dll/BizHawk.Client.ApiHawk.dll
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
<OutputPath>..\output\dll\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
<OutputPath>bin\x86\Release\</OutputPath>
|
<OutputPath>..\output\dll\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
using BizHawk.Common.NumberExtensions;
|
using BizHawk.Common.NumberExtensions;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
|
@ -13,6 +14,7 @@ namespace BizHawk.Client.Common
|
||||||
/// with a specific size (8, 16 or 32bits).
|
/// with a specific size (8, 16 or 32bits).
|
||||||
/// This is an abstract class
|
/// This is an abstract class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[DebuggerDisplay("Note={Notes}, Value={ValueString}")]
|
||||||
public abstract partial class Watch
|
public abstract partial class Watch
|
||||||
: IEquatable<Watch>,
|
: IEquatable<Watch>,
|
||||||
IEquatable<Cheat>,
|
IEquatable<Cheat>,
|
||||||
|
@ -68,7 +70,7 @@ namespace BizHawk.Client.Common
|
||||||
#region Static
|
#region Static
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a <see cref="Watch"/> from a given string
|
/// Generate sa <see cref="Watch"/> from a given string
|
||||||
/// String is tab separate
|
/// String is tab separate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="line">Entire string, tab seperated for each value Order is:
|
/// <param name="line">Entire string, tab seperated for each value Order is:
|
||||||
|
@ -138,7 +140,7 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a new <see cref="Watch"/> instance
|
/// Generates a new <see cref="Watch"/> instance
|
||||||
/// Can be either <see cref="ByteWatch"/>, <see cref="WordWatch"/>, <see cref="DWordWatch"/> or <see cref="SeparatorWatch"/>
|
/// Can be either <see cref="ByteWatch"/>, <see cref="WordWatch"/>, <see cref="DWordWatch"/> or <see cref="SeparatorWatch"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="domain">The <see cref="MemoryDomain"/> where you want to watch</param>
|
/// <param name="domain">The <see cref="MemoryDomain"/> where you want to watch</param>
|
||||||
|
@ -168,7 +170,7 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a new <see cref="Watch"/> instance
|
/// Generates a new <see cref="Watch"/> instance
|
||||||
/// Can be either <see cref="ByteWatch"/>, <see cref="WordWatch"/>, <see cref="DWordWatch"/> or <see cref="SeparatorWatch"/>
|
/// Can be either <see cref="ByteWatch"/>, <see cref="WordWatch"/>, <see cref="DWordWatch"/> or <see cref="SeparatorWatch"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="domain">The <see cref="MemoryDomain"/> where you want to watch</param>
|
/// <param name="domain">The <see cref="MemoryDomain"/> where you want to watch</param>
|
||||||
|
@ -184,7 +186,7 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a new <see cref="Watch"/> instance
|
/// Generates a new <see cref="Watch"/> instance
|
||||||
/// Can be either <see cref="ByteWatch"/>, <see cref="WordWatch"/>, <see cref="DWordWatch"/> or <see cref="SeparatorWatch"/>
|
/// Can be either <see cref="ByteWatch"/>, <see cref="WordWatch"/>, <see cref="DWordWatch"/> or <see cref="SeparatorWatch"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="domain">The <see cref="MemoryDomain"/> where you want to watch</param>
|
/// <param name="domain">The <see cref="MemoryDomain"/> where you want to watch</param>
|
||||||
|
@ -310,18 +312,18 @@ namespace BizHawk.Client.Common
|
||||||
#region Abstracts
|
#region Abstracts
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a list a <see cref="DisplayType"/> that can be used for this <see cref="Watch"/>
|
/// Gets a list a <see cref="DisplayType"/> that can be used for this <see cref="Watch"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>An enumartion that contains all valid <see cref="DisplayType"/></returns>
|
/// <returns>An enumartion that contains all valid <see cref="DisplayType"/></returns>
|
||||||
public abstract IEnumerable<DisplayType> AvailableTypes();
|
public abstract IEnumerable<DisplayType> AvailableTypes();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the previous value; set it to the current one
|
/// Resets the previous value; set it to the current one
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract void ResetPrevious();
|
public abstract void ResetPrevious();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the Watch (read it from <see cref="MemoryDomain"/>
|
/// Updates the Watch (read it from <see cref="MemoryDomain"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract void Update();
|
public abstract void Update();
|
||||||
|
|
||||||
|
@ -413,7 +415,7 @@ namespace BizHawk.Client.Common
|
||||||
#endregion Protected
|
#endregion Protected
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the number of changes to 0
|
/// Sets the number of changes to 0
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearChangeCount()
|
public void ClearChangeCount()
|
||||||
{
|
{
|
||||||
|
@ -423,7 +425,7 @@ namespace BizHawk.Client.Common
|
||||||
#region IEquatable<Watch>
|
#region IEquatable<Watch>
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determine if this <see cref="Watch"/> is equals to another
|
/// Determines if this <see cref="Watch"/> is equals to another
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">The <see cref="Watch"/> to compare</param>
|
/// <param name="obj">The <see cref="Watch"/> to compare</param>
|
||||||
/// <returns>True if both object are equals; otherwise, false</returns>
|
/// <returns>True if both object are equals; otherwise, false</returns>
|
||||||
|
@ -446,7 +448,7 @@ namespace BizHawk.Client.Common
|
||||||
#region IEquatable<Cheat>
|
#region IEquatable<Cheat>
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determine if this <see cref="Watch"/> is equals to an instance of <see cref="Cheat"/>
|
/// Determines if this <see cref="Watch"/> is equals to an instance of <see cref="Cheat"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">The <see cref="Cheat"/> to compare</param>
|
/// <param name="obj">The <see cref="Cheat"/> to compare</param>
|
||||||
/// <returns>True if both object are equals; otherwise, false</returns>
|
/// <returns>True if both object are equals; otherwise, false</returns>
|
||||||
|
@ -463,7 +465,7 @@ namespace BizHawk.Client.Common
|
||||||
#region IComparable<Watch>
|
#region IComparable<Watch>
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compare two <see cref="Watch"/> together and determine wich one comes first.
|
/// Compares two <see cref="Watch"/> together and determine wich one comes first.
|
||||||
/// First we look the address and then the size
|
/// First we look the address and then the size
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="other">The other <see cref="Watch"/> to compare to</param>
|
/// <param name="other">The other <see cref="Watch"/> to compare to</param>
|
||||||
|
@ -497,7 +499,7 @@ namespace BizHawk.Client.Common
|
||||||
#endregion IComparable<Watch>
|
#endregion IComparable<Watch>
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determine if this object is Equals to another
|
/// Determines if this object is Equals to another
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">The object to compare</param>
|
/// <param name="obj">The object to compare</param>
|
||||||
/// <returns>True if both object are equals; otherwise, false</returns>
|
/// <returns>True if both object are equals; otherwise, false</returns>
|
||||||
|
@ -521,14 +523,14 @@ namespace BizHawk.Client.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hash the current watch and gets a unique value
|
/// Hash the current watch and gets a unique value
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>int that can serves as a unique representation of current Watch</returns>
|
/// <returns><see cref="int"/> that can serves as a unique representation of current Watch</returns>
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return this.Domain.GetHashCode() + (int)(this.Address);
|
return this.Domain.GetHashCode() + (int)(this.Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determine if the specified <see cref="DisplayType"/> can be
|
/// Determines if the specified <see cref="DisplayType"/> can be
|
||||||
/// used for the current <see cref="Watch"/>
|
/// used for the current <see cref="Watch"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type"><see cref="DisplayType"/> you want to check</param>
|
/// <param name="type"><see cref="DisplayType"/> you want to check</param>
|
||||||
|
@ -539,7 +541,7 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Transform the current instance into a string
|
/// Transforms the current instance into a string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A <see cref="string"/> representation of the current <see cref="Watch"/></returns>
|
/// <returns>A <see cref="string"/> representation of the current <see cref="Watch"/></returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
|
@ -85,107 +85,161 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
[Obsolete("Use the method with single parameter instead")]
|
#region ICollection<Watch>
|
||||||
public void RefreshDomains(IMemoryDomains core, MemoryDomain domain)
|
|
||||||
{
|
|
||||||
_memoryDomains = core;
|
|
||||||
_domain = domain;
|
|
||||||
|
|
||||||
_watchList.ForEach(w =>
|
/// <summary>
|
||||||
{
|
/// Adds a <see cref="Watch"/> into the current collection
|
||||||
if (w.Domain != null)
|
/// </summary>
|
||||||
{
|
/// <param name="watch"><see cref="Watch"/> to add</param>
|
||||||
w.Domain = _memoryDomains[w.Domain.Name];
|
public void Add(Watch watch)
|
||||||
}
|
{
|
||||||
});
|
_watchList.Add(watch);
|
||||||
|
Changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshDomains(IMemoryDomains core)
|
/// <summary>
|
||||||
|
/// Removes all item from the current collection
|
||||||
|
/// Clear also the file name
|
||||||
|
/// </summary>
|
||||||
|
public void Clear()
|
||||||
{
|
{
|
||||||
_memoryDomains = core;
|
_watchList.Clear();
|
||||||
Parallel.ForEach<Watch>(_watchList, watch =>
|
Changes = false;
|
||||||
|
_currentFilename = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the current <see cref="WatchList"/> contains the
|
||||||
|
/// specified <see cref="Watch"/>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="watch">The object to</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool Contains(Watch watch)
|
||||||
|
{
|
||||||
|
return _watchList.Contains(watch);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copies the elements of the current <see cref="WatchList"/>
|
||||||
|
/// into an <see cref="Array"/> starting at a particular <see cref="Array"/> index
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="array">The one-dimension <see cref="Array"/> that will serve as destination to copy</param>
|
||||||
|
/// <param name="arrayIndex">Zero-based index where the copy should starts</param>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||||
|
/// <exception cref="ArgumentException"></exception>
|
||||||
|
public void CopyTo(Watch[] array, int arrayIndex)
|
||||||
|
{
|
||||||
|
_watchList.CopyTo(array, arrayIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the first of specified <see cref="Watch"/>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="watch"><see cref="Watch"/> to remove</param>
|
||||||
|
/// <returns>True if <see cref="Watch"/> successfully removed; otherwise, false</returns>
|
||||||
|
public bool Remove(Watch watch)
|
||||||
|
{
|
||||||
|
bool result = _watchList.Remove(watch);
|
||||||
|
if (result)
|
||||||
{
|
{
|
||||||
watch.Domain = core[watch.Domain.Name];
|
Changes = true;
|
||||||
watch.ResetPrevious();
|
|
||||||
watch.Update();
|
|
||||||
watch.ClearChangeCount();
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public string AddressFormatStr // TODO: this is probably compensating for not using the ToHex string extension
|
#region IList<Watch>
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_domain != null)
|
|
||||||
{
|
|
||||||
return "{0:X" + (_domain.Size - 1).NumHexDigits() + "}";
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Empty;
|
/// <summary>
|
||||||
}
|
/// Determines the zero-base position of the specified <see cref="Watch"/>
|
||||||
|
/// into the <see cref="WatchList"/>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="watch"><see cref="Watch"/> to look for</param>
|
||||||
|
/// <returns>Zero-base position if <see cref="Watch"/> has been found; otherwise -1</returns>
|
||||||
|
public int IndexOf(Watch watch)
|
||||||
|
{
|
||||||
|
return _watchList.IndexOf(watch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count
|
/// <summary>
|
||||||
|
/// Insert a <see cref="Watch"/> at the specified index
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">The zero-base index where the <see cref="Watch"/> should be inserted</param>
|
||||||
|
/// <param name="watch"><see cref="Watch"/> to insert</param>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||||
|
public void Insert(int index, Watch watch)
|
||||||
{
|
{
|
||||||
get
|
_watchList.Insert(index, watch);
|
||||||
{
|
|
||||||
return _watchList.Count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int WatchCount
|
/// <summary>
|
||||||
|
/// Removes item at the specified index
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">Zero-based index of the <see cref="Watch"/> to remove</param>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||||
|
public void RemoveAt(int index)
|
||||||
{
|
{
|
||||||
get
|
_watchList.RemoveAt(index);
|
||||||
{
|
Changes = true;
|
||||||
return _watchList.Count<Watch>(watch => !watch.IsSeparator);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Use count property instead")]
|
#endregion IList<Watch>
|
||||||
public int ItemCount
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("Use domain from individual watch instead")]
|
#region IEnumerable<Watch>
|
||||||
public MemoryDomain Domain
|
|
||||||
{
|
|
||||||
get { return _domain; }
|
|
||||||
set { _domain = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsReadOnly { get { return false; } }
|
|
||||||
|
|
||||||
public string CurrentFileName
|
|
||||||
{
|
|
||||||
get { return _currentFilename; }
|
|
||||||
set { _currentFilename = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Changes { get; set; }
|
|
||||||
|
|
||||||
public Watch this[int index]
|
|
||||||
{
|
|
||||||
get { return _watchList[index]; }
|
|
||||||
set { _watchList[index] = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an enumerator that iterates through the collection
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An <see cref="IEnumerator{T}"/> for the current collection</returns>
|
||||||
public IEnumerator<Watch> GetEnumerator()
|
public IEnumerator<Watch> GetEnumerator()
|
||||||
{
|
{
|
||||||
return _watchList.GetEnumerator();
|
return _watchList.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an enumerator that iterates through the collection
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An <see cref="IEnumerator"/> for the current collection</returns>
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
{
|
{
|
||||||
return GetEnumerator();
|
return GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion IEnumerable<Watch>
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an existing collection of <see cref="Watch"/> into the current one
|
||||||
|
/// <see cref="Watch"/> equality will be checked to avoid doubles
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="watches"><see cref="IEnumerable{Watch}"/> of watch to merge</param>
|
||||||
|
public void AddRange(IEnumerable<Watch> watches)
|
||||||
|
{
|
||||||
|
Parallel.ForEach<Watch>(watches, watch =>
|
||||||
|
{
|
||||||
|
if (!_watchList.Contains(watch))
|
||||||
|
{
|
||||||
|
_watchList.Add(watch);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears change count of all <see cref="Watch"/> in the collection
|
||||||
|
/// </summary>
|
||||||
|
public void ClearChangeCounts()
|
||||||
|
{
|
||||||
|
Parallel.ForEach<Watch>(_watchList, watch => watch.ClearChangeCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sort the current list based on one of the constant
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="column">Value that specify sorting base</param>
|
||||||
|
/// <param name="reverse">Value that define the ordering. Ascending (true) or desceding (false)</param>
|
||||||
public void OrderWatches(string column, bool reverse)
|
public void OrderWatches(string column, bool reverse)
|
||||||
{
|
{
|
||||||
switch (column)
|
switch (column)
|
||||||
|
@ -324,13 +378,27 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear()
|
/// <summary>
|
||||||
|
/// Sets WatchList's domain list to a new one
|
||||||
|
/// <see cref="Watch"/> domain will also be refreshed
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="core">New domains</param>
|
||||||
|
public void RefreshDomains(IMemoryDomains core)
|
||||||
{
|
{
|
||||||
_watchList.Clear();
|
_memoryDomains = core;
|
||||||
Changes = false;
|
Parallel.ForEach<Watch>(_watchList, watch =>
|
||||||
_currentFilename = string.Empty;
|
{
|
||||||
|
watch.Domain = core[watch.Domain.Name];
|
||||||
|
watch.ResetPrevious();
|
||||||
|
watch.Update();
|
||||||
|
watch.ClearChangeCount();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates all <see cref="Watch"/> ine the current collection
|
||||||
|
/// </summary>
|
||||||
public void UpdateValues()
|
public void UpdateValues()
|
||||||
{
|
{
|
||||||
Parallel.ForEach<Watch>(_watchList, watch =>
|
Parallel.ForEach<Watch>(_watchList, watch =>
|
||||||
|
@ -339,66 +407,134 @@ namespace BizHawk.Client.Common
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(Watch watch)
|
public string AddressFormatStr // TODO: this is probably compensating for not using the ToHex string extension
|
||||||
{
|
{
|
||||||
_watchList.Add(watch);
|
get
|
||||||
Changes = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddRange(IList<Watch> watches)
|
|
||||||
{
|
|
||||||
_watchList.AddRange(watches);
|
|
||||||
Changes = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Remove(Watch watch)
|
|
||||||
{
|
|
||||||
var result = _watchList.Remove(watch);
|
|
||||||
if (result)
|
|
||||||
{
|
{
|
||||||
Changes = true;
|
if (_domain != null)
|
||||||
}
|
{
|
||||||
|
return "{0:X" + (_domain.Size - 1).NumHexDigits() + "}";
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return string.Empty;
|
||||||
}
|
|
||||||
|
|
||||||
public void Insert(int index, Watch watch)
|
|
||||||
{
|
|
||||||
_watchList.Insert(index, watch);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearChangeCounts()
|
|
||||||
{
|
|
||||||
foreach (var watch in _watchList)
|
|
||||||
{
|
|
||||||
watch.ClearChangeCount();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(Watch watch)
|
#endregion
|
||||||
|
|
||||||
|
#region Propeties
|
||||||
|
|
||||||
|
#region ICollection<Watch>
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of elements contained in this <see cref="WatchList"/>
|
||||||
|
/// </summary>
|
||||||
|
public int Count
|
||||||
{
|
{
|
||||||
return _watchList.Any(w =>
|
get
|
||||||
w.Size == watch.Size &&
|
{
|
||||||
w.Type == watch.Type &&
|
return _watchList.Count;
|
||||||
w.Domain == watch.Domain &&
|
}
|
||||||
w.Address == watch.Address &&
|
|
||||||
w.BigEndian == watch.BigEndian);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyTo(Watch[] array, int arrayIndex)
|
/// <summary>
|
||||||
|
/// <see cref="WatchList"/> is alsways read-write
|
||||||
|
/// so this value will be always false
|
||||||
|
/// </summary>
|
||||||
|
public bool IsReadOnly
|
||||||
{
|
{
|
||||||
_watchList.CopyTo(array, arrayIndex);
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int IndexOf(Watch watch)
|
#endregion ICollection<Watch>
|
||||||
|
|
||||||
|
#region IList<Watch>
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets element at the specified index
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">The zero based index of the element you want to get or set</param>
|
||||||
|
/// <returns><see cref="Watch"/> at the specified index</returns>
|
||||||
|
public Watch this[int index]
|
||||||
{
|
{
|
||||||
return _watchList.IndexOf(watch);
|
get
|
||||||
|
{
|
||||||
|
return _watchList[index];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_watchList[index] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveAt(int index)
|
#endregion IList<Watch>
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating if collection has changed or not
|
||||||
|
/// </summary>
|
||||||
|
public bool Changes { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets current <see cref="WatchList"/>'s filename
|
||||||
|
/// </summary>
|
||||||
|
public string CurrentFileName
|
||||||
{
|
{
|
||||||
_watchList.RemoveAt(index);
|
get
|
||||||
Changes = true;
|
{
|
||||||
|
return _currentFilename;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_currentFilename = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of <see cref="Watch"/> that are not <see cref="SeparatorWatch"/>
|
||||||
|
/// </summary>
|
||||||
|
public int WatchCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _watchList.Count<Watch>(watch => !watch.IsSeparator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
[Obsolete("Use the method with single parameter instead")]
|
||||||
|
public void RefreshDomains(IMemoryDomains core, MemoryDomain domain)
|
||||||
|
{
|
||||||
|
_memoryDomains = core;
|
||||||
|
_domain = domain;
|
||||||
|
|
||||||
|
_watchList.ForEach(w =>
|
||||||
|
{
|
||||||
|
if (w.Domain != null)
|
||||||
|
{
|
||||||
|
w.Domain = _memoryDomains[w.Domain.Name];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use count property instead")]
|
||||||
|
public int ItemCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[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
|
#region File handling logic - probably needs to be its own class
|
||||||
|
@ -608,7 +744,6 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public T Load<T>(string toolPath, bool focus = true)
|
public T Load<T>(string toolPath, bool focus = true)
|
||||||
where T : class, IToolForm
|
where T : class, IToolForm
|
||||||
{
|
{
|
||||||
if (!IsAvailable<T>())
|
if (!IsAvailable<T>() && typeof(T) != typeof(IExternalToolForm))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -566,7 +566,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
//Hard stuff as we need a proxy object that inherit from MarshalByRefObject.
|
//Hard stuff as we need a proxy object that inherit from MarshalByRefObject.
|
||||||
if (toolType == typeof(IExternalToolForm))
|
if (toolType == typeof(IExternalToolForm))
|
||||||
{
|
{
|
||||||
if (MessageBox.Show(@"Are you sure want to load this external tool?\r\nAccept ONLY if you trust the source and if you know what you're doing. In any other case, choose no."
|
if (MessageBox.Show("Are you sure want to load this external tool?\r\nAccept ONLY if you trust the source and if you know what you're doing. In any other case, choose no."
|
||||||
, "Confirmm loading", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
, "Confirmm loading", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue