diff --git a/src/HexManiac.Core/Models/Runs/ModelCacheScope.cs b/src/HexManiac.Core/Models/Runs/ModelCacheScope.cs
index bf20fabe..d0881a79 100644
--- a/src/HexManiac.Core/Models/Runs/ModelCacheScope.cs
+++ b/src/HexManiac.Core/Models/Runs/ModelCacheScope.cs
@@ -92,7 +92,7 @@ namespace HavenSoft.HexManiac.Core.Models.Runs {
var maps = banks[i].GetSubTable("maps");
if (maps == null) continue;
for (int j = 0; j < maps.Count; j++) {
- var mapText = "maps." + BlockMapViewModel.MapIDToText(model, i * 1000 + j);
+ var mapText = "maps." + BlockMapViewModel.MapIDToText(model, i, j);
results.Add(new(i, j, mapText));
}
}
diff --git a/src/HexManiac.Core/ViewModels/GotoControlViewModel.cs b/src/HexManiac.Core/ViewModels/GotoControlViewModel.cs
index e7f63ee1..e8817718 100644
--- a/src/HexManiac.Core/ViewModels/GotoControlViewModel.cs
+++ b/src/HexManiac.Core/ViewModels/GotoControlViewModel.cs
@@ -318,9 +318,15 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
var allMaps = model.CurrentCacheScope?.GetAllMaps();
var results = allMaps?.Where(map => map.Name.MatchesPartial(text)).ToList() ?? new();
- return //*
- new() /*/ results //*/
- ;
+ //*
+ return new();
+ /*/
+ var lower = text.ToLower();
+ foreach (var result in results) {
+ if (result.Name.ToLower() == lower) return new() { result };
+ }
+ return results;
+ //*/
}
}
diff --git a/src/HexManiac.Core/ViewModels/Tools/SpriteElementViewModel.cs b/src/HexManiac.Core/ViewModels/Tools/SpriteElementViewModel.cs
index 940ed957..7a228fff 100644
--- a/src/HexManiac.Core/ViewModels/Tools/SpriteElementViewModel.cs
+++ b/src/HexManiac.Core/ViewModels/Tools/SpriteElementViewModel.cs
@@ -1,17 +1,39 @@
using HavenSoft.HexManiac.Core.Models;
using HavenSoft.HexManiac.Core.Models.Runs;
-using HavenSoft.HexManiac.Core.Models.Runs.Factory;
using HavenSoft.HexManiac.Core.Models.Runs.Sprites;
using HavenSoft.HexManiac.Core.ViewModels.Images;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows.Input;
namespace HavenSoft.HexManiac.Core.ViewModels.Tools {
+ public class SpriteIndicatorElementViewModel : ViewModelCore, IArrayElementViewModel {
+ public IPixelViewModel Image { get; private set; }
+
+ private bool visible;
+ public bool Visible { get => visible; set => Set(ref visible, value); }
+
+ public bool IsInError => false;
+
+ public string ErrorText => string.Empty;
+
+ public int ZIndex => 1;
+
+ public event EventHandler DataChanged;
+ public event EventHandler DataSelected;
+
+ public SpriteIndicatorElementViewModel(IPixelViewModel image) => Image = image;
+
+ public bool TryCopy(IArrayElementViewModel other) {
+ if (other is not SpriteIndicatorElementViewModel indicator) return false;
+ Image = indicator.Image;
+ NotifyPropertyChanged(nameof(Image));
+ return true;
+ }
+ }
public class SpriteElementViewModel : PagedElementViewModel, IPixelViewModel {
private SpriteFormat format;
diff --git a/src/HexManiac.Core/ViewModels/Tools/StreamElementViewModel.cs b/src/HexManiac.Core/ViewModels/Tools/StreamElementViewModel.cs
index d1b979d7..63bfc123 100644
--- a/src/HexManiac.Core/ViewModels/Tools/StreamElementViewModel.cs
+++ b/src/HexManiac.Core/ViewModels/Tools/StreamElementViewModel.cs
@@ -1,6 +1,5 @@
using HavenSoft.HexManiac.Core.Models;
using HavenSoft.HexManiac.Core.Models.Runs;
-using HavenSoft.HexManiac.Core.Models.Runs.Factory;
using HavenSoft.HexManiac.Core.ViewModels.DataFormats;
using System;
using System.Collections.Generic;
diff --git a/src/HexManiac.Core/ViewModels/Tools/TableGroupViewModel.cs b/src/HexManiac.Core/ViewModels/Tools/TableGroupViewModel.cs
index f1e870ae..680c7176 100644
--- a/src/HexManiac.Core/ViewModels/Tools/TableGroupViewModel.cs
+++ b/src/HexManiac.Core/ViewModels/Tools/TableGroupViewModel.cs
@@ -1,7 +1,11 @@
using HavenSoft.HexManiac.Core.Models;
+using HavenSoft.HexManiac.Core.Models.Map;
using HavenSoft.HexManiac.Core.Models.Runs;
using HavenSoft.HexManiac.Core.Models.Runs.Sprites;
using HavenSoft.HexManiac.Core.ViewModels.DataFormats;
+using HavenSoft.HexManiac.Core.ViewModels.Images;
+using HavenSoft.HexManiac.Core.ViewModels.Map;
+using HexManiac.Core.Models.Runs.Sprites;
using System;
using System.Collections.ObjectModel;
using System.Linq;
@@ -101,6 +105,41 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Tools {
}
itemAddress += item.Length;
}
+ AddAdhocSpecialElementsToGroup(viewPort, table);
+ }
+
+ private void AddAdhocSpecialElementsToGroup(IViewPort viewPort, ITableRun table) {
+ if (table.ElementContent.Count == 14 && table.ElementCount == 1 && table.ElementContent.Select(seg => seg.Type).ToArray().SequenceEqual(new[] {
+ ElementContentType.Pointer, ElementContentType.Pointer, ElementContentType.Pointer, ElementContentType.Pointer,
+ ElementContentType.Integer, ElementContentType.Integer, ElementContentType.Integer, ElementContentType.Integer,
+ ElementContentType.Integer, ElementContentType.Integer, ElementContentType.Integer, ElementContentType.Integer,
+ ElementContentType.Integer, ElementContentType.Integer,
+ })) {
+ AddAdhocMapElementsToGroup(viewPort, table);
+ }
+ }
+
+ private void AddAdhocMapElementsToGroup(IViewPort viewPort, ITableRun table) {
+ var model = viewPort.Model;
+ if (table.PointerSources == null || table.PointerSources.Count != 1) return;
+ var addressInBankTable = table.PointerSources[0];
+ var bankTable = model.GetNextRun(addressInBankTable) as ITableRun;
+ if (bankTable == null || bankTable.PointerSources == null || bankTable.PointerSources.Count != 1) return;
+ var topTable = model.GetNextRun(bankTable.PointerSources[0]) as ITableRun;
+ if (topTable == null) return;
+ var bankOffset = topTable.ConvertByteOffsetToArrayOffset(bankTable.PointerSources[0]);
+ var mapOffset = bankTable.ConvertByteOffsetToArrayOffset(addressInBankTable);
+ var (bank, map) = (bankOffset.ElementIndex, mapOffset.ElementIndex);
+ var name = "maps." + BlockMapViewModel.MapIDToText(model, bank, map);
+ var matches = model.GetMatchingMaps(name);
+ if (matches.Count != 1) return;
+ var mapModel = new MapModel(new ModelArrayElement(model, table.Start, 0, () => viewPort.ChangeHistory.CurrentChange, table));
+ if (model.GetNextRun(mapModel.Layout.BlockMap.Start) is BlockmapRun blockmapRun) {
+ var image = (CanvasPixelViewModel)model.CurrentCacheScope.GetImage(blockmapRun);
+ image.SpriteScale = 128.0 / Math.Max(image.PixelWidth, image.PixelHeight);
+ Add(new SpriteIndicatorElementViewModel(image));
+ }
+ Add(new ButtonArrayElementViewModel("Edit Map", () => viewPort.Goto.Execute(name)));
}
private void AddChildrenFromPointerSegment(ViewPort viewPort, int itemAddress, ArrayRunElementSegment item, IArrayElementViewModel parent, int recursionLevel) {
diff --git a/src/HexManiac.WPF/Controls/TabView.xaml b/src/HexManiac.WPF/Controls/TabView.xaml
index 5721820f..f341ce5d 100644
--- a/src/HexManiac.WPF/Controls/TabView.xaml
+++ b/src/HexManiac.WPF/Controls/TabView.xaml
@@ -543,6 +543,9 @@
+
+
+