signpost -> goto script should set NoInfoRuns to XSERuns

This commit is contained in:
haven1433
2023-03-01 22:04:06 -06:00
parent f3d986882e
commit efa8ab5010
2 changed files with 21 additions and 2 deletions

View File

@@ -1132,7 +1132,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
if (!ShowPointer) return;
var destinationRun = new XSERun(Pointer, SortedSpan<int>.None);
var existingRun = element.Model.GetNextRun(destinationRun.Start);
if (existingRun.Start <= destinationRun.Start) return; // don't erase existing runs for this
if (existingRun.Start < destinationRun.Start) return; // don't erase existing runs for this
if (existingRun.Start == destinationRun.Start && existingRun is not NoInfoRun) return;
element.Model.ObserveRunWritten(new ModelDelta(), destinationRun); // don't track this change
}
@@ -1210,7 +1211,10 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
}
public bool CanGotoScript => 0 <= Pointer && Pointer < element.Model.Count;
public void GotoScript() => gotoAddress(Pointer);
public void GotoScript() {
SetDestinationFormat();
gotoAddress(Pointer);
}
#endregion

View File

@@ -1,6 +1,7 @@
using HavenSoft.HexManiac.Core;
using HavenSoft.HexManiac.Core.Models.Runs;
using HavenSoft.HexManiac.Core.ViewModels.Map;
using System;
using System.Linq;
using Xunit;
@@ -67,5 +68,19 @@ namespace HavenSoft.HexManiac.Integration {
var editor = firered.MapEditor;
Assert.Contains(editor.PrimaryMap, editor.VisibleMaps);
}
[SkippableFact]
public void OakLabSignpost_RepointScript_UpdateSignpostScriptField() {
var firered = LoadFireRed();
var address1 = firered.Maps[3][0].Events.Signposts[0].Arg;
firered.Goto.Execute(StartTown);
firered.MapEditor.PrimaryMap.EventGroup.Signposts[0].GotoScript();
var script = firered.Tools.CodeTool.Contents[0];
script.Content = "nop" + Environment.NewLine + script.Content; // causes repoint
var address2 = firered.Maps[3][0].Events.Signposts[0].Arg;
Assert.NotEqual(address1, address2);
}
}
}