diff --git a/src/HexManiac.Core/Models/Runs/Factory/OverworldSpriteListContentStrategy.cs b/src/HexManiac.Core/Models/Runs/Factory/OverworldSpriteListContentStrategy.cs index 7a97fffa..ba32214c 100644 --- a/src/HexManiac.Core/Models/Runs/Factory/OverworldSpriteListContentStrategy.cs +++ b/src/HexManiac.Core/Models/Runs/Factory/OverworldSpriteListContentStrategy.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using HavenSoft.HexManiac.Core.ViewModels.DataFormats; +using System.Collections.Generic; namespace HavenSoft.HexManiac.Core.Models.Runs.Factory { public class OverworldSpriteListContentStrategy : RunStrategy { @@ -40,6 +41,7 @@ namespace HavenSoft.HexManiac.Core.Models.Runs.Factory { public override int LengthForNewRun(IDataModel model, int pointerAddress) { var destination = model.ReadPointer(pointerAddress); + if (destination == Pointer.NULL) return 8; if (destination < 0 || destination >= model.Count) return -1; return new OverworldSpriteListRun(model, parentTemplate, Hint, 0, destination, new SortedSpan(pointerAddress)).Length; } @@ -75,7 +77,10 @@ namespace HavenSoft.HexManiac.Core.Models.Runs.Factory { } public override IFormattedRun WriteNewRun(IDataModel owner, ModelDelta token, int source, int destination, string name, IReadOnlyList sourceSegments) { - return new OverworldSpriteListRun(owner, sourceSegments, Hint, 0, destination, new SortedSpan(source)); + var run = new OverworldSpriteListRun(owner, sourceSegments, Hint, 0, destination, new SortedSpan(source)); + owner.WritePointer(token, destination, Pointer.NULL); + owner.WriteMultiByteValue(destination + 4, 4, token, 0x100); + return run; } } } diff --git a/src/HexManiac.Core/ViewModels/Tools/ToolTray.cs b/src/HexManiac.Core/ViewModels/Tools/ToolTray.cs index cf9f6913..a69b53a6 100644 --- a/src/HexManiac.Core/ViewModels/Tools/ToolTray.cs +++ b/src/HexManiac.Core/ViewModels/Tools/ToolTray.cs @@ -25,6 +25,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Tools { using (ModelCacheScope.CreateScope(model)) { if (SelectedTool == TableTool) TableTool.DataForCurrentRunChanged(); if (SelectedTool == SpriteTool) SpriteTool.DataForCurrentRunChanged(); + if (SelectedTool == StringTool) StringTool.DataForCurrentRunChanged(); CodeTool.IsSelected = SelectedTool == CodeTool; } } diff --git a/src/HexManiac.Tests/HexManiac.Tests.csproj b/src/HexManiac.Tests/HexManiac.Tests.csproj index fa8917a7..871e215e 100644 --- a/src/HexManiac.Tests/HexManiac.Tests.csproj +++ b/src/HexManiac.Tests/HexManiac.Tests.csproj @@ -55,6 +55,10 @@ mkdir "$(TargetDir)resources" mkdir "$(TargetDir)resources\Scripts" + mkdir "$(TargetDir)resources\Scripts\Add Mechanics From Later Generations" + mkdir "$(TargetDir)resources\Scripts\internal" + mkdir "$(TargetDir)resources\Scripts\Patches" + mkdir "$(TargetDir)resources\Scripts\Update Existing Mechanics" copy "$(TargetDir)Models\Code\*.txt" "$(TargetDir)resources" del "$(TargetDir)Models\Code\*.txt" copy "$(TargetDir)Models\Code\*.toml" "$(TargetDir)resources" @@ -64,6 +68,10 @@ copy "$(TargetDir)Models\Code\*.py" "$(TargetDir)resources" del "$(TargetDir)Models\Code\*.py" copy "$(SolutionDir)src\HexManiac.WPF\Scripts\*.hma" "$(TargetDir)resources\Scripts" + copy "$(SolutionDir)src\HexManiac.WPF\Scripts\Add Mechanics From Later Generations\*.hma" "$(TargetDir)resources\Scripts\Add Mechanics From Later Generations" + copy "$(SolutionDir)src\HexManiac.WPF\Scripts\internal\*.hma" "$(TargetDir)resources\Scripts\internal" + copy "$(SolutionDir)src\HexManiac.WPF\Scripts\Patches\*.hma" "$(TargetDir)resources\Scripts\Patches" + copy "$(SolutionDir)src\HexManiac.WPF\Scripts\Update Existing Mechanics\*.hma" "$(TargetDir)resources\Scripts\Update Existing Mechanics" diff --git a/src/HexManiac.Tests/Integration/AutoSearchTests.cs b/src/HexManiac.Tests/Integration/AutoSearchTests.cs index 35caf963..4dee10bf 100644 --- a/src/HexManiac.Tests/Integration/AutoSearchTests.cs +++ b/src/HexManiac.Tests/Integration/AutoSearchTests.cs @@ -154,7 +154,7 @@ namespace HavenSoft.HexManiac.Tests { if (tileset == null) continue; var hasPalette = tileset.Format.Contains("|"); if (!hasPalette) continue; - + yield return new object[] { gameName, anchor.Name }; } gameIndex++; @@ -647,7 +647,7 @@ namespace HavenSoft.HexManiac.Tests { public void ExpandableTutorsWorks(string game) { var fileSystem = new StubFileSystem(); var model = fixture.LoadModelNoCache(game); - var editor = new New(fileSystem,fixture.Singletons).EditorViewModel(); + var editor = new New(fileSystem, fixture.Singletons).EditorViewModel(); var viewPort = NewViewPort(game, model); editor.Add(viewPort); var expandTutors = editor.QuickEditsExpansion.Single(edit => edit.Name == new MakeTutorsExpandable().Name); @@ -838,7 +838,7 @@ namespace HavenSoft.HexManiac.Tests { var errors = new List(); viewport.OnError += (sender, e) => errors.Add(e); - var fairyTypeScript = File.ReadAllBytes("resources/Scripts/AddFairyType.hma"); + var fairyTypeScript = File.ReadAllBytes("resources/Scripts/Add Mechanics From Later Generations/AnyGame_FairyType.hma"); viewport.TryImport(new("fairy.hma", fairyTypeScript), default); Assert.Empty(errors);