From efa8ab501033d4e41352c813357af9636985236f Mon Sep 17 00:00:00 2001 From: haven1433 Date: Wed, 1 Mar 2023 22:04:06 -0600 Subject: [PATCH] signpost -> goto script should set NoInfoRuns to XSERuns --- .../ViewModels/Map/IEventViewModel.cs | 8 ++++++-- src/HexManiac.Integration/MapTests.cs | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/HexManiac.Core/ViewModels/Map/IEventViewModel.cs b/src/HexManiac.Core/ViewModels/Map/IEventViewModel.cs index c8657844..e22cca17 100644 --- a/src/HexManiac.Core/ViewModels/Map/IEventViewModel.cs +++ b/src/HexManiac.Core/ViewModels/Map/IEventViewModel.cs @@ -1132,7 +1132,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map { if (!ShowPointer) return; var destinationRun = new XSERun(Pointer, SortedSpan.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 diff --git a/src/HexManiac.Integration/MapTests.cs b/src/HexManiac.Integration/MapTests.cs index 2a46b6e6..0be3d4bd 100644 --- a/src/HexManiac.Integration/MapTests.cs +++ b/src/HexManiac.Integration/MapTests.cs @@ -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); + } } }