mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-10-02 05:06:35 -05:00
fix fly logic, allow duplicate
This commit is contained in:
@@ -1262,7 +1262,9 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||
|
||||
// if there were no empty entries in the table, add a new one
|
||||
if (emptySpawn == -1) {
|
||||
var newSpawns = spawns.Run.Append(tokenFactory(), 1);
|
||||
var newSpawns = model.RelocateForExpansion(tokenFactory(), spawns.Run, spawns.Run.Length + spawns.Run.ElementLength);
|
||||
newSpawns = newSpawns.Append(tokenFactory(), 1);
|
||||
model.ObserveRunWritten(tokenFactory(), newSpawns);
|
||||
if (newSpawns.Start != spawns.Run.Start) InformRepoint(new("Fly Spawns", newSpawns.Start));
|
||||
spawns = new ModelTable(model, newSpawns, tokenFactory);
|
||||
emptySpawn = spawns.Count - 1;
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||
public ICommand Diff => null;
|
||||
public ICommand DiffLeft => null;
|
||||
public ICommand DiffRight => null;
|
||||
public bool CanDuplicate => false;
|
||||
public bool CanDuplicate => true;
|
||||
|
||||
public event EventHandler<string> OnError;
|
||||
public event EventHandler<string> OnMessage;
|
||||
@@ -202,7 +202,13 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||
public event EventHandler<CanPatchEventArgs> RequestCanCreatePatch;
|
||||
public event EventHandler<CanPatchEventArgs> RequestCreatePatch;
|
||||
|
||||
public void Duplicate() { }
|
||||
public void Duplicate() => Duplicate(PrimaryMap.MapID / 1000, PrimaryMap.MapID % 1000);
|
||||
private void Duplicate(int bank, int map) {
|
||||
var newEditor = new MapEditorViewModel(FileSystem, viewPort, singletons, Tutorials);
|
||||
newEditor.UpdatePrimaryMap(new BlockMapViewModel(FileSystem, Tutorials, viewPort, Format, bank, map));
|
||||
RequestTabChange?.Invoke(this, new(newEditor));
|
||||
}
|
||||
|
||||
public void Refresh() {
|
||||
VisibleMaps.Clear();
|
||||
primaryMap.ClearCaches();
|
||||
@@ -767,6 +773,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||
ContextItems.Add(new MenuCommand("Delete Object", DeleteCurrentEvent));
|
||||
} else if (ev is WarpEventViewModel warp) {
|
||||
ContextItems.Add(new MenuCommand("Create New Map", CreateMapForWarp));
|
||||
ContextItems.Add(new MenuCommand("Open in New Tab", () => Duplicate(warp.Bank, warp.Map)));
|
||||
ContextItems.Add(new MenuCommand("Delete Warp", DeleteCurrentEvent));
|
||||
} else if (ev is ScriptEventViewModel script) {
|
||||
ContextItems.Add(new MenuCommand("Delete Script", DeleteCurrentEvent));
|
||||
|
||||
Reference in New Issue
Block a user