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