New Ram Watch - implement Separator object, finish file loading (only 1 byte supported currently)
This commit is contained in:
parent
ca579745de
commit
1254b8b03e
|
@ -109,7 +109,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
if (result)
|
||||
{
|
||||
Watches.Load(file.FullName, false);
|
||||
Watches.Load(file.FullName, details: true, append: false);
|
||||
DisplayWatches();
|
||||
MessageLabel.Text = Path.GetFileNameWithoutExtension(Watches.CurrentFileName);
|
||||
UpdateWatchCount();
|
||||
|
|
|
@ -912,10 +912,13 @@ namespace BizHawk.MultiClient
|
|||
public readonly DisplayType Type;
|
||||
public bool BigEndian = false;
|
||||
|
||||
public bool IsSeparator()
|
||||
public virtual bool IsSeparator
|
||||
{
|
||||
get
|
||||
{
|
||||
return Size == WatchSize.Separator;
|
||||
}
|
||||
}
|
||||
|
||||
public static WatchSize SizeFromChar(char c) //b = byte, w = word, d = dword
|
||||
{
|
||||
|
@ -946,6 +949,30 @@ namespace BizHawk.MultiClient
|
|||
return DisplayType.Hex;
|
||||
}
|
||||
}
|
||||
|
||||
public static WatchEntryBase GenerateWatch(MemoryDomain domain, int address, WatchSize size, DisplayType type, bool details)
|
||||
{
|
||||
switch (size)
|
||||
{
|
||||
default:
|
||||
case WatchSize.Separator:
|
||||
return new SeparatorWatch();
|
||||
case WatchSize.Byte:
|
||||
if (details)
|
||||
{
|
||||
return new DetailedByteWatch(domain, address);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ByteWatch(domain, address);
|
||||
}
|
||||
break;
|
||||
case WatchSize.Word:
|
||||
throw new NotImplementedException();
|
||||
case WatchSize.DWord:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface iWatchEntryDetails
|
||||
|
@ -959,6 +986,48 @@ namespace BizHawk.MultiClient
|
|||
string Notes { get; set; }
|
||||
}
|
||||
|
||||
public class SeparatorWatch : WatchEntryBase
|
||||
{
|
||||
public SeparatorWatch()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override int? Address
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public override int? Value
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public override string AddressString
|
||||
{
|
||||
get { return ""; }
|
||||
}
|
||||
|
||||
public override string ValueString
|
||||
{
|
||||
get { return ""; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
default:
|
||||
return Value.ToString(); //TODO
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsSeparator
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
public class ByteWatch : WatchEntryBase
|
||||
{
|
||||
protected int? _address;
|
||||
|
@ -1010,7 +1079,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
switch(Type)
|
||||
switch (Type)
|
||||
{
|
||||
default:
|
||||
return Value.ToString(); //TODO
|
||||
|
@ -1038,6 +1107,8 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public class WatchList : IEnumerable
|
||||
{
|
||||
private string _currentFilename = "";
|
||||
|
||||
public enum WatchPrevDef { LastSearch, Original, LastFrame, LastChange };
|
||||
|
||||
private List<WatchEntryBase> _watchList = new List<WatchEntryBase>();
|
||||
|
@ -1067,7 +1138,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
get
|
||||
{
|
||||
return _watchList.Count(w => !w.IsSeparator());
|
||||
return _watchList.Count(w => !w.IsSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1174,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
#region File handling logic - probably needs to be its own class
|
||||
|
||||
public string CurrentFileName { get; set; }
|
||||
public string CurrentFileName { get { return _currentFilename; } set { _currentFilename = value; } }
|
||||
public bool Changes { get; set; }
|
||||
|
||||
public void Save()
|
||||
|
@ -1118,9 +1189,9 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public void Load(string path, bool append)
|
||||
public void Load(string path, bool details, bool append)
|
||||
{
|
||||
bool result = LoadFile(path, append);
|
||||
bool result = LoadFile(path, append, details);
|
||||
|
||||
if (result)
|
||||
{
|
||||
|
@ -1147,7 +1218,7 @@ namespace BizHawk.MultiClient
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private bool LoadFile(string path, bool append)
|
||||
private bool LoadFile(string path, bool details, bool append)
|
||||
{
|
||||
string domain = "";
|
||||
var file = new FileInfo(path);
|
||||
|
@ -1211,7 +1282,6 @@ namespace BizHawk.MultiClient
|
|||
|
||||
|
||||
//Temporary, rename if kept
|
||||
Watch w = new Watch();
|
||||
int THEADDRESS_ = 0;
|
||||
WatchEntryBase.WatchSize THESIZE = WatchEntryBase.WatchSize.Separator;
|
||||
WatchEntryBase.DisplayType THEDISPLAYTYPE = WatchEntryBase.DisplayType.Unsigned;
|
||||
|
@ -1268,7 +1338,16 @@ namespace BizHawk.MultiClient
|
|||
startIndex = line.IndexOf('\t') + 1;
|
||||
THENOTES = line.Substring(startIndex, line.Length - startIndex); //User notes
|
||||
|
||||
//_watchList.Add(w); //TODO: we need a widget factory or something, to manage the logic of what object to use!
|
||||
WatchEntryBase w = WatchEntryBase.GenerateWatch(
|
||||
THEDOMAIN,
|
||||
THEADDRESS_,
|
||||
THESIZE,
|
||||
THEDISPLAYTYPE,
|
||||
details
|
||||
);
|
||||
w.BigEndian = BIGENDIAN;
|
||||
_watchList.Add(w);
|
||||
_domain = Global.Emulator.MemoryDomains[GetDomainPos(domain)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue