mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-10-01 20:56:36 -05:00
bugfixes
This commit is contained in:
@@ -659,7 +659,13 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||
toggleScrollAnimation.Execute = arg => AnimateScroll = !AnimateScroll;
|
||||
|
||||
resetZoom.CanExecute = CanAlwaysExecute;
|
||||
resetZoom.Execute = arg => ZoomLevel = 16;
|
||||
resetZoom.Execute = arg => {
|
||||
ZoomLevel = 16;
|
||||
foreach(var tab in this) {
|
||||
if (tab is not MapEditorViewModel mapTab) continue;
|
||||
mapTab.ResetZoom();
|
||||
}
|
||||
};
|
||||
|
||||
resetTheme.CanExecute = CanAlwaysExecute;
|
||||
resetTheme.Execute = arg => Theme.Reset();
|
||||
|
||||
@@ -919,16 +919,14 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||
var border = GetBorderThickness(layout);
|
||||
var tileX = (int)((x - LeftEdge) / SpriteScale / 16) - border.West;
|
||||
var tileY = (int)((y - TopEdge) / SpriteScale / 16) - border.North;
|
||||
IEventViewModel last = null;
|
||||
foreach (var e in GetEvents()) {
|
||||
if (e.X == tileX && e.Y == tileY) {
|
||||
if (autoSelect) SelectedEvent = e;
|
||||
pixelData = null;
|
||||
NotifyPropertyChanged(nameof(PixelData));
|
||||
return e;
|
||||
}
|
||||
if (e.X == tileX && e.Y == tileY) last = e;
|
||||
}
|
||||
if (autoSelect) SelectedEvent = null;
|
||||
return null;
|
||||
if (autoSelect) SelectedEvent = last;
|
||||
pixelData = null;
|
||||
NotifyPropertyChanged(nameof(PixelData));
|
||||
return last;
|
||||
}
|
||||
|
||||
public IPixelViewModel AutoCrop(int warpID) {
|
||||
|
||||
@@ -4,6 +4,7 @@ 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 IronPython.Runtime;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -176,19 +177,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||
public ICommand Back => StubCommand(ref backCommand, ExecuteBack, CanExecuteBack);
|
||||
public ICommand Forward => StubCommand(ref forwardCommand, ExecuteForward, CanExecuteForward);
|
||||
|
||||
private GameReferenceTables RefTable => singletons.GameReferenceTables.TryGetValue(model.GetGameCode(), out var refTable) ? refTable : null;
|
||||
public ICommand Close => StubCommand(ref close, () => {
|
||||
if (!history.IsSaved) {
|
||||
var metadata = model.ExportMetadata(RefTable, singletons.MetadataInfo);
|
||||
var result = fileSystem.TrySavePrompt(new LoadedFile(viewPort.FileName, model.RawData));
|
||||
if (result == null) return;
|
||||
if (result == true) {
|
||||
fileSystem.SaveMetadata(viewPort.FileName, metadata?.Serialize());
|
||||
history.TagAsSaved();
|
||||
}
|
||||
}
|
||||
Closed.Raise(this);
|
||||
});
|
||||
public ICommand Close => StubCommand(ref close, () => Closed.Raise(this));
|
||||
|
||||
public ICommand Diff => null;
|
||||
public ICommand DiffLeft => null;
|
||||
@@ -615,10 +604,18 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||
Tutorials.Complete(Tutorial.DoubleClick_FollowWarp);
|
||||
}
|
||||
} else if (click == PrimaryInteractionStart.DoubleClick && SelectedEvent is ObjectEventViewModel obj) {
|
||||
viewPort.Goto.Execute(obj.ScriptAddress);
|
||||
if (0 <= obj.ScriptAddress && obj.ScriptAddress < model.Count) {
|
||||
viewPort.Goto.Execute(obj.ScriptAddress);
|
||||
} else {
|
||||
OnError.Raise(this, "Not a valid script address.");
|
||||
}
|
||||
Tutorials.Complete(Tutorial.DoubleClickEvent_SeeScript);
|
||||
} else if (click == PrimaryInteractionStart.DoubleClick && SelectedEvent is ScriptEventViewModel script) {
|
||||
viewPort.Goto.Execute(script.ScriptAddress);
|
||||
if (0 <= script.ScriptAddress && script.ScriptAddress < model.Count) {
|
||||
viewPort.Goto.Execute(script.ScriptAddress);
|
||||
} else {
|
||||
OnError.Raise(this, "Not a valid script address.");
|
||||
}
|
||||
Tutorials.Complete(Tutorial.DoubleClickEvent_SeeScript);
|
||||
} else if (
|
||||
click == PrimaryInteractionStart.DoubleClick &&
|
||||
@@ -1120,6 +1117,11 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||
Tutorials.Complete(Tutorial.Wheel_ZoomMap);
|
||||
}
|
||||
|
||||
public void ResetZoom() {
|
||||
while (primaryMap.SpriteScale > 1) Zoom(0, 0, false);
|
||||
while (primaryMap.SpriteScale < 1) Zoom(0, 0, true);
|
||||
}
|
||||
|
||||
private StubCommand panCommand, zoomCommand, deleteCommand, cancelCommand;
|
||||
public ICommand PanCommand => StubCommand<MapDirection>(ref panCommand, Pan);
|
||||
public ICommand ZoomCommand => StubCommand<ZoomDirection>(ref zoomCommand, Zoom);
|
||||
|
||||
@@ -603,7 +603,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||
}
|
||||
|
||||
private void CloseExecuted(IFileSystem fileSystem) {
|
||||
if (!history.IsSaved) {
|
||||
if (!history.IsSaved && ownsHistory) {
|
||||
var metadata = Model.ExportMetadata(RefTable, Singletons.MetadataInfo);
|
||||
var result = fileSystem.TrySavePrompt(new LoadedFile(FileName, Model.RawData));
|
||||
if (result == null) return;
|
||||
@@ -877,6 +877,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||
private bool isFocused;
|
||||
public bool IsFocused { get => isFocused; set => Set(ref isFocused, value); }
|
||||
|
||||
private bool ownsHistory; // true if this tab is responsible for history ownership. False if this is a 'duplicate' tab, and another tab owns the history.
|
||||
|
||||
public ICommand Copy => copy;
|
||||
public ICommand CopyAddress => copyAddress;
|
||||
public ICommand CopyBytes => copyBytes;
|
||||
@@ -937,6 +939,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||
public ViewPort(string fileName, IDataModel model, IWorkDispatcher dispatcher, Singletons singletons = null, MapTutorialsViewModel tutorials = null, IFileSystem fs = null, PythonTool pythonTool = null, ChangeHistory<ModelDelta> changeHistory = null) {
|
||||
Singletons = singletons ?? new Singletons();
|
||||
PythonTool = pythonTool;
|
||||
ownsHistory = changeHistory == null;
|
||||
history = changeHistory ?? new ChangeHistory<ModelDelta>(RevertChanges);
|
||||
history.PropertyChanged += HistoryPropertyChanged;
|
||||
this.dispatcher = dispatcher ?? InstantDispatch.Instance;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<Decorator IsHitTestVisible="False" Width="30" Height="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="96,-60,0,0" Name="UndoButtonWidget" />
|
||||
|
||||
<!-- Blocks Panel -->
|
||||
<DockPanel Grid.Column="0" Grid.RowSpan="2" Panel.ZIndex="1" Name="BlockPanel" Background="{DynamicResource Background}">
|
||||
<DockPanel Grid.Column="0" Grid.RowSpan="2" Panel.ZIndex="1" Name="BlockPanel" Background="{DynamicResource Background}" MouseWheel="EatMouseWheel">
|
||||
<Rectangle Fill="{DynamicResource Backlight}" Width="1" DockPanel.Dock="Right" />
|
||||
<local:AngleBorder DockPanel.Dock="Top" Content="Blocks" Direction="Out" Width="100" HorizontalContentAlignment="Center" Margin="0,0,0,4" />
|
||||
<Grid Width="{Binding Blocks.ScaledWidth}" MinHeight="100" DockPanel.Dock="Top">
|
||||
@@ -836,7 +836,7 @@
|
||||
|
||||
<!-- Tile Panel -->
|
||||
<Border DataContext="{Binding PrimaryMap.BlockEditor}" Grid.Column="1" Grid.RowSpan="2" Panel.ZIndex="3" HorizontalAlignment="Left"
|
||||
BorderBrush="{DynamicResource Backlight}" BorderThickness="1"
|
||||
BorderBrush="{DynamicResource Backlight}" BorderThickness="1" MouseWheel="EatMouseWheel"
|
||||
Background="{DynamicResource Background}">
|
||||
<DockPanel Name="TilePanel" Width="400" HorizontalAlignment="Right">
|
||||
<Grid DockPanel.Dock="Top">
|
||||
@@ -921,7 +921,7 @@
|
||||
|
||||
<!-- Border Panel-->
|
||||
<Border DataContext="{Binding PrimaryMap.BorderEditor}" Grid.Column="1" Grid.RowSpan="2" Panel.ZIndex="3" HorizontalAlignment="Left"
|
||||
BorderBrush="{DynamicResource Backlight}" BorderThickness="1"
|
||||
BorderBrush="{DynamicResource Backlight}" BorderThickness="1" MouseWheel="EatMouseWheel"
|
||||
Background="{DynamicResource Background}">
|
||||
<DockPanel Width="400" HorizontalAlignment="Right">
|
||||
<Grid DockPanel.Dock="Top">
|
||||
|
||||
@@ -238,6 +238,11 @@ namespace HavenSoft.HexManiac.WPF.Controls {
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void EatMouseWheel(object sender, MouseWheelEventArgs e) {
|
||||
// we have this so that mouse-wheel over certain elements won't get taken by the Wheel method above.
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void BlocksDown(object sender, MouseButtonEventArgs e) {
|
||||
var element = (FrameworkElement)sender;
|
||||
if (element.IsMouseCaptured) return;
|
||||
|
||||
Reference in New Issue
Block a user