mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-06-01 04:53:29 -05:00
allow TableStreamRun to match an ArrayRun if the format matches
This can happen if the user gives a name to a tablestreamrun with a fixed length - it becomes an ArrayRun. Allow the StreamElementViewModel to accept pointers of both streams and arrays when judging the UsageCount. Allow
This commit is contained in:
parent
0db2ce46e1
commit
5a104b3039
|
|
@ -30,7 +30,10 @@ namespace HavenSoft.HexManiac.Core.Models.Runs.Factory {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
public override bool Matches(IFormattedRun run) => run is TableStreamRun streamRun && streamRun.FormatString == Format;
|
||||
public override bool Matches(IFormattedRun run) {
|
||||
if (run == null || run.FormatString != Format) return false;
|
||||
return run is ITableRun;
|
||||
}
|
||||
public override IFormattedRun WriteNewRun(IDataModel owner, ModelDelta token, int source, int destination, string name, IReadOnlyList<ArrayRunElementSegment> sourceSegments) {
|
||||
// don't bother checking the TryParse result: we very much expect that the data originally in the run won't fit the parse.
|
||||
TableStreamRun.TryParseTableStream(owner, destination, new SortedSpan<int>(source), name, Format, sourceSegments, out var tableStream);
|
||||
|
|
|
|||
|
|
@ -148,8 +148,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Tools {
|
|||
if (destination == Pointer.NULL) {
|
||||
UsageCount = 0;
|
||||
} else {
|
||||
var run = Model.GetNextRun(destination) as IStreamRun;
|
||||
UsageCount = run?.PointerSources?.Count ?? 0;
|
||||
var run = Model.GetNextRun(destination);
|
||||
UsageCount = run is IStreamRun || run is ITableRun ? run.PointerSources?.Count ?? 0 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user