refactor Watch object Generation methods
This commit is contained in:
parent
9b6738b6b5
commit
b26972a4fc
|
@ -671,23 +671,11 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 1:
|
case 1:
|
||||||
return new ByteWatch(Domain, address)
|
return new ByteWatch(Domain, address, Watch.DisplayType.Hex, BigEndian, String.Empty);
|
||||||
{
|
|
||||||
BigEndian = BigEndian,
|
|
||||||
Type = Watch.DisplayType.Hex,
|
|
||||||
};
|
|
||||||
case 2:
|
case 2:
|
||||||
return new WordWatch(Domain, address)
|
return new WordWatch(Domain, address, Watch.DisplayType.Hex, BigEndian, String.Empty);
|
||||||
{
|
|
||||||
BigEndian = BigEndian,
|
|
||||||
Type = Watch.DisplayType.Hex,
|
|
||||||
};
|
|
||||||
case 4:
|
case 4:
|
||||||
return new DWordWatch(Domain, address)
|
return new DWordWatch(Domain, address, Watch.DisplayType.Hex, BigEndian, String.Empty);
|
||||||
{
|
|
||||||
BigEndian = BigEndian,
|
|
||||||
Type = Watch.DisplayType.Hex,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,10 +719,13 @@ namespace BizHawk.MultiClient
|
||||||
var Watches = new List<Watch>();
|
var Watches = new List<Watch>();
|
||||||
foreach (var address in addresses)
|
foreach (var address in addresses)
|
||||||
{
|
{
|
||||||
Watch w = Watch.GenerateWatch(Domain, address, (Watch.WatchSize)DataSize);
|
Watches.Add(Watch.GenerateWatch(
|
||||||
w.Type = Watch.DisplayType.Hex;
|
Domain,
|
||||||
|
address,
|
||||||
Watches.Add(w);
|
(Watch.WatchSize)DataSize,
|
||||||
|
Watch.DisplayType.Hex,
|
||||||
|
String.Empty,
|
||||||
|
BigEndian));
|
||||||
}
|
}
|
||||||
|
|
||||||
poke.SetWatch(Watches);
|
poke.SetWatch(Watches);
|
||||||
|
|
|
@ -199,20 +199,19 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
public string Notes { get { return _notes; } set { _notes = value; } }
|
public string Notes { get { return _notes; } set { _notes = value; } }
|
||||||
|
|
||||||
//TODO: delete me
|
public static Watch GenerateWatch(MemoryDomain domain, int address, WatchSize size, DisplayType type, string notes, bool bigEndian)
|
||||||
public static Watch GenerateWatch(MemoryDomain domain, int address, WatchSize size)
|
|
||||||
{
|
{
|
||||||
switch (size)
|
switch (size)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case WatchSize.Separator:
|
case WatchSize.Separator:
|
||||||
return new SeparatorWatch();
|
return SeparatorWatch.Instance;
|
||||||
case WatchSize.Byte:
|
case WatchSize.Byte:
|
||||||
return new ByteWatch(domain, address);
|
return new ByteWatch(domain, address, type, bigEndian, notes);
|
||||||
case WatchSize.Word:
|
case WatchSize.Word:
|
||||||
return new WordWatch(domain, address);
|
return new WordWatch(domain, address, type, bigEndian, notes);
|
||||||
case WatchSize.DWord:
|
case WatchSize.DWord:
|
||||||
return new DWordWatch(domain, address);
|
return new DWordWatch(domain, address, type, bigEndian, notes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +221,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case WatchSize.Separator:
|
case WatchSize.Separator:
|
||||||
return new SeparatorWatch();
|
return SeparatorWatch.Instance;
|
||||||
case WatchSize.Byte:
|
case WatchSize.Byte:
|
||||||
return new ByteWatch(domain, address, type, bigendian, (byte)prev, changecount);
|
return new ByteWatch(domain, address, type, bigendian, (byte)prev, changecount);
|
||||||
case WatchSize.Word:
|
case WatchSize.Word:
|
||||||
|
@ -337,21 +336,27 @@ namespace BizHawk.MultiClient
|
||||||
private byte _previous;
|
private byte _previous;
|
||||||
private byte _value;
|
private byte _value;
|
||||||
|
|
||||||
public ByteWatch(MemoryDomain domain, int address)
|
public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes)
|
||||||
{
|
{
|
||||||
_address = address;
|
_address = address;
|
||||||
_domain = domain;
|
_domain = domain;
|
||||||
_value = _previous = GetByte();
|
_value = _previous = GetByte();
|
||||||
Notes = String.Empty;
|
if (Watch.AvailableTypes(WatchSize.Byte).Contains(type))
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
}
|
||||||
|
_bigEndian = bigEndian;
|
||||||
|
if (notes != null)
|
||||||
|
{
|
||||||
|
Notes = notes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, byte prev, int changeCount)
|
public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, byte prev, int changeCount, string notes = null)
|
||||||
: this(domain, address)
|
: this(domain, address, type, bigEndian, notes)
|
||||||
{
|
{
|
||||||
_previous = prev;
|
_previous = prev;
|
||||||
_changecount = changeCount;
|
_changecount = changeCount;
|
||||||
_type = type;
|
|
||||||
_bigEndian = bigEndian;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int? Address
|
public override int? Address
|
||||||
|
@ -534,21 +539,29 @@ namespace BizHawk.MultiClient
|
||||||
private ushort _previous;
|
private ushort _previous;
|
||||||
private ushort _value;
|
private ushort _value;
|
||||||
|
|
||||||
public WordWatch(MemoryDomain domain, int address)
|
public WordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes)
|
||||||
{
|
{
|
||||||
_domain = domain;
|
_domain = domain;
|
||||||
_address = address;
|
_address = address;
|
||||||
_value = _previous = GetWord();
|
_value = _previous = GetWord();
|
||||||
Notes = String.Empty;
|
|
||||||
|
if (Watch.AvailableTypes(WatchSize.Word).Contains(type))
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
}
|
||||||
|
_bigEndian = bigEndian;
|
||||||
|
|
||||||
|
if (notes != null)
|
||||||
|
{
|
||||||
|
Notes = notes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, ushort prev, int changeCount)
|
public WordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, ushort prev, int changeCount, string notes = null)
|
||||||
: this(domain, address)
|
: this(domain, address, type, bigEndian, notes)
|
||||||
{
|
{
|
||||||
_previous = prev;
|
_previous = prev;
|
||||||
_changecount = changeCount;
|
_changecount = changeCount;
|
||||||
_type = type;
|
|
||||||
_bigEndian = bigEndian;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int? Value
|
public override int? Value
|
||||||
|
@ -719,16 +732,26 @@ namespace BizHawk.MultiClient
|
||||||
private uint _value;
|
private uint _value;
|
||||||
private uint _previous;
|
private uint _previous;
|
||||||
|
|
||||||
public DWordWatch(MemoryDomain domain, int address)
|
public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes)
|
||||||
{
|
{
|
||||||
_domain = domain;
|
_domain = domain;
|
||||||
_address = address;
|
_address = address;
|
||||||
_value = _previous = GetDWord();
|
_value = _previous = GetDWord();
|
||||||
Notes = String.Empty;
|
|
||||||
|
if (Watch.AvailableTypes(WatchSize.DWord).Contains(type))
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
}
|
||||||
|
_bigEndian = bigEndian;
|
||||||
|
|
||||||
|
if (notes != null)
|
||||||
|
{
|
||||||
|
Notes = notes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, uint prev, int changeCount)
|
public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, uint prev, int changeCount, string notes = null)
|
||||||
: this(domain, address)
|
: this(domain, address, type, bigEndian, notes)
|
||||||
{
|
{
|
||||||
_previous = prev;
|
_previous = prev;
|
||||||
_changecount = changeCount;
|
_changecount = changeCount;
|
||||||
|
|
|
@ -224,31 +224,13 @@ namespace BizHawk.MultiClient
|
||||||
switch (SizeDropDown.SelectedIndex)
|
switch (SizeDropDown.SelectedIndex)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
_watchList.Add(new ByteWatch(domain, address)
|
_watchList.Add(new ByteWatch(domain, address, type, bigendian, notes));
|
||||||
{
|
|
||||||
Notes = notes,
|
|
||||||
Type = type,
|
|
||||||
BigEndian = bigendian,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
_watchList.Add(new WordWatch(domain, address)
|
_watchList.Add(new WordWatch(domain, address, type, bigendian, notes));
|
||||||
{
|
|
||||||
Notes = notes,
|
|
||||||
Type = type,
|
|
||||||
BigEndian = bigendian,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
_watchList.Add(new DWordWatch(domain, address)
|
_watchList.Add(new DWordWatch(domain, address, type, bigendian, notes));
|
||||||
{
|
|
||||||
Notes = notes,
|
|
||||||
Type = type,
|
|
||||||
BigEndian = bigendian,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -261,10 +243,13 @@ namespace BizHawk.MultiClient
|
||||||
_watchList.Clear();
|
_watchList.Clear();
|
||||||
foreach (var watch in tempWatchList)
|
foreach (var watch in tempWatchList)
|
||||||
{
|
{
|
||||||
var newWatch = Watch.GenerateWatch(watch.Domain, watch.Address.Value, watch.Size);
|
_watchList.Add(Watch.GenerateWatch(
|
||||||
newWatch.Type = watch.Type;
|
watch.Domain,
|
||||||
newWatch.Notes = watch.Notes;
|
watch.Address.Value,
|
||||||
_watchList.Add(watch);
|
watch.Size,
|
||||||
|
watch.Type,
|
||||||
|
watch.Notes,
|
||||||
|
watch.BigEndian));
|
||||||
}
|
}
|
||||||
DoEdit();
|
DoEdit();
|
||||||
break;
|
break;
|
||||||
|
@ -301,9 +286,11 @@ namespace BizHawk.MultiClient
|
||||||
_watchList[i] = Watch.GenerateWatch(
|
_watchList[i] = Watch.GenerateWatch(
|
||||||
_watchList[i].Domain,
|
_watchList[i].Domain,
|
||||||
_watchList.Count == 1 ? AddressBox.ToInt() : _watchList[i].Address.Value,
|
_watchList.Count == 1 ? AddressBox.ToInt() : _watchList[i].Address.Value,
|
||||||
size
|
size,
|
||||||
|
_watchList[i].Type,
|
||||||
|
_watchList[i].Notes,
|
||||||
|
_watchList[i].BigEndian
|
||||||
);
|
);
|
||||||
_watchList[i].Notes = tempNotes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_changedDisplayType)
|
if (_changedDisplayType)
|
||||||
|
|
|
@ -498,12 +498,14 @@ namespace BizHawk.MultiClient
|
||||||
startIndex = line.IndexOf('\t') + 1;
|
startIndex = line.IndexOf('\t') + 1;
|
||||||
string notes = line.Substring(startIndex, line.Length - startIndex);
|
string notes = line.Substring(startIndex, line.Length - startIndex);
|
||||||
|
|
||||||
Watch w = Watch.GenerateWatch(memDomain, addr, size);
|
_watchList.Add(
|
||||||
w.BigEndian = bigEndian;
|
Watch.GenerateWatch(
|
||||||
w.Type = type;
|
memDomain,
|
||||||
w.Notes = notes;
|
addr,
|
||||||
|
size,
|
||||||
_watchList.Add(w);
|
type,
|
||||||
|
notes,
|
||||||
|
bigEndian));
|
||||||
_domain = Global.Emulator.MemoryDomains[GetDomainPos(domain)];
|
_domain = Global.Emulator.MemoryDomains[GetDomainPos(domain)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue