diff --git a/AnimationEditor/AnimationEditor.csproj b/AnimationEditor/AnimationEditor.csproj
index ad6f238..4304ee8 100644
--- a/AnimationEditor/AnimationEditor.csproj
+++ b/AnimationEditor/AnimationEditor.csproj
@@ -60,6 +60,9 @@
Hitbox3Window.xaml
+
+ Hitbox5Window.xaml
+
TextureWindow.xaml
@@ -68,12 +71,17 @@
+
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
diff --git a/AnimationEditor/Hitbox3Window.xaml b/AnimationEditor/Hitbox3Window.xaml
index 24bc0dd..0f501a6 100644
--- a/AnimationEditor/Hitbox3Window.xaml
+++ b/AnimationEditor/Hitbox3Window.xaml
@@ -6,7 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AnimationEditor"
mc:Ignorable="d"
- Title="Hitbox RSDKv3 manager" Height="300" Width="400">
+ Title="Hitbox manager" Height="300" Width="400">
@@ -73,11 +73,11 @@
-
+
-
+
diff --git a/AnimationEditor/Hitbox5Window.xaml b/AnimationEditor/Hitbox5Window.xaml
new file mode 100644
index 0000000..b629dac
--- /dev/null
+++ b/AnimationEditor/Hitbox5Window.xaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AnimationEditor/Hitbox5Window.xaml.cs b/AnimationEditor/Hitbox5Window.xaml.cs
new file mode 100644
index 0000000..4b957fd
--- /dev/null
+++ b/AnimationEditor/Hitbox5Window.xaml.cs
@@ -0,0 +1,50 @@
+using AnimationEditor.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace AnimationEditor
+{
+ ///
+ /// Interaction logic for Hitbox5Window.xaml
+ ///
+ public partial class Hitbox5Window : Window
+ {
+ public HitboxV5EditorViewModel ViewModel => DataContext as HitboxV5EditorViewModel;
+
+ public Hitbox5Window(MainViewModel vm)
+ {
+ InitializeComponent();
+ DataContext = new HitboxV5EditorViewModel(vm);
+ }
+
+ private void ButtonAdd_Click(object sender, RoutedEventArgs e)
+ {
+ ViewModel.HitboxTypeItems.Add("EMPTY");
+ }
+
+ private void ButtonRemove_Click(object sender, RoutedEventArgs e)
+ {
+ if (ViewModel.IsValueSelected)
+ ViewModel.HitboxTypeItems.RemoveAt(ViewModel.SelectedIndex);
+ }
+
+ private void TextBox_LostFocus(object sender, RoutedEventArgs e)
+ {
+ if (sender is TextBox textBox)
+ {
+ ViewModel.UpdateList(textBox.Text);
+ }
+ }
+ }
+}
diff --git a/AnimationEditor/MainWindow.xaml b/AnimationEditor/MainWindow.xaml
index 4b8ecff..f132f0c 100644
--- a/AnimationEditor/MainWindow.xaml
+++ b/AnimationEditor/MainWindow.xaml
@@ -214,9 +214,44 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AnimationEditor/MainWindow.xaml.cs b/AnimationEditor/MainWindow.xaml.cs
index 0401a7a..6b6f34b 100644
--- a/AnimationEditor/MainWindow.xaml.cs
+++ b/AnimationEditor/MainWindow.xaml.cs
@@ -122,7 +122,10 @@ private void MenuViewTexture_Click(object sender, RoutedEventArgs e)
private void MenuViewHitbox_Click(object sender, RoutedEventArgs e)
{
- new Hitbox3Window(ViewModel).Show();
+ if (ViewModel.IsHitboxV3)
+ new Hitbox3Window(ViewModel).Show();
+ else if (ViewModel.IsHitboxV5)
+ new Hitbox5Window(ViewModel).Show();
}
}
}
diff --git a/AnimationEditor/ViewModels/HitboxV5EditorViewModel.cs b/AnimationEditor/ViewModels/HitboxV5EditorViewModel.cs
new file mode 100644
index 0000000..16ad704
--- /dev/null
+++ b/AnimationEditor/ViewModels/HitboxV5EditorViewModel.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AnimationEditor.ViewModels
+{
+ public class HitboxV5EditorViewModel : Xe.Tools.Wpf.BaseNotifyPropertyChanged
+ {
+ private string _selectedValue;
+ private int _selectedIndex;
+
+ public ObservableCollection HitboxTypeItems { get; set; }
+
+ public string SelectedValue
+ {
+ get => _selectedValue;
+ set
+ {
+ _selectedValue = value;
+ OnPropertyChanged(nameof(SelectedValue));
+ }
+ }
+
+ public int SelectedIndex
+ {
+ get => _selectedIndex;
+ set
+ {
+ _selectedIndex = value;
+ OnPropertyChanged(nameof(IsValueSelected));
+ }
+ }
+
+ public bool IsValueSelected => SelectedIndex >= 0;
+
+ public HitboxV5EditorViewModel(MainViewModel vm)
+ {
+ HitboxTypeItems = vm.HitboxTypes;
+ }
+
+ public void UpdateList(string value)
+ {
+ var index = SelectedIndex;
+ if (index >= 0)
+ {
+ HitboxTypeItems.RemoveAt(index);
+ HitboxTypeItems.Insert(index, value);
+ }
+ }
+ }
+}
diff --git a/AnimationEditor/ViewModels/MainViewModel.cs b/AnimationEditor/ViewModels/MainViewModel.cs
index 80c8012..188efda 100644
--- a/AnimationEditor/ViewModels/MainViewModel.cs
+++ b/AnimationEditor/ViewModels/MainViewModel.cs
@@ -14,6 +14,18 @@ namespace AnimationEditor.ViewModels
{
public class MainViewModel : Xe.Tools.Wpf.BaseNotifyPropertyChanged
{
+ private class DummyHitbox : IHitbox
+ {
+ public int Left { get; set; }
+ public int Top { get; set; }
+ public int Right { get; set; }
+ public int Bottom { get; set; }
+
+ public void SaveChanges(BinaryWriter writer)
+ {
+ }
+ }
+
private string _pathMod;
private string _fileName;
private IAnimation _animationData;
@@ -40,8 +52,6 @@ public string FileName
public ObservableCollection Animations { get; private set; }
- public List Hitboxes { get; private set; }
-
public IAnimation AnimationData
{
get => _animationData;
@@ -53,16 +63,20 @@ public IAnimation AnimationData
Textures = new ObservableCollection(_animationData.SpriteSheets);
Animations = new ObservableCollection(_animationData.GetAnimations());
- //Hitboxes = _animationData.GetHitboxes()?.Select(x => new HitboxViewModel() { Hitbox = x.InnerFloor }).ToList() ?? new List();
- IsHitboxv3 = _animationData.HitboxTypes == null;
- IsHitboxv5 = !IsHitboxv3;
- if (IsHitboxv3)
+ IsHitboxV3 = _animationData.HitboxTypes == null;
+ IsHitboxV5 = !IsHitboxV3;
+ if (IsHitboxV3)
{
HitboxEntries = new ObservableCollection(_animationData.GetHitboxes());
HitboxItems = HitboxEntries != null ? new ObservableCollection(
HitboxEntries.Select(x => GetHitboxEntryString(x)))
: new ObservableCollection();
}
+ else if (IsHitboxV5)
+ {
+ HitboxTypes = new ObservableCollection(_animationData.HitboxTypes);
+ }
+ ValidateHitboxVisibility();
_animService = new AnimationService(_animationData);
_animService.OnFrameChanged += OnFrameChanged;
@@ -71,7 +85,6 @@ public IAnimation AnimationData
OnPropertyChanged(nameof(IsAnimationDataLoaded));
OnPropertyChanged(nameof(Textures));
OnPropertyChanged(nameof(Animations));
- OnPropertyChanged(nameof(Hitboxes));
OnPropertyChanged(nameof(HitboxEntries));
OnPropertyChanged(nameof(HitboxItems));
}
@@ -332,17 +345,62 @@ public int SelectedFramePivotY
#region Hitbox
#region Hitbox v3
- public bool IsHitboxv3 { get; private set; }
- public bool IsNotHitboxv3 => !IsHitboxv3;
+ private bool _isHitboxV3;
+ public bool IsHitboxV3
+ {
+ get => _isHitboxV3;
+ set
+ {
+ _isHitboxV3 = value;
+ ValidateHitboxVisibility();
+ }
+ }
+ public bool IsNotHitboxV3 => !IsHitboxV3;
+ public Visibility HitboxV3Visibility => IsHitboxV3 ? Visibility.Visible : Visibility.Collapsed;
public ObservableCollection HitboxEntries { get; private set; }
public ObservableCollection HitboxItems { get; private set; }
#endregion
#region Hitbox v5
- public bool IsHitboxv5 { get; private set; }
- public bool IsNotHitboxv5 => !IsHitboxv5;
+ private bool _isHitboxV5;
+ private int _selectedIndex;
+ public bool IsHitboxV5
+ {
+ get => _isHitboxV5;
+ set
+ {
+ _isHitboxV5 = value;
+ ValidateHitboxVisibility();
+ }
+ }
+ public bool IsNotHitboxV5 => !IsHitboxV5;
+ public Visibility HitboxV5Visibility => IsHitboxV5 ? Visibility.Visible : Visibility.Collapsed;
+ public ObservableCollection HitboxTypes { get; set; }
+ public int SelectedHitboxType
+ {
+ get => _selectedIndex;
+ set
+ {
+ _selectedIndex = value;
+ OnPropertyChanged(nameof(SelectedHitbox));
+ }
+ }
+ public IHitbox SelectedHitbox => SelectedFrame?.GetHitbox(SelectedHitboxType) ?? new DummyHitbox();
#endregion
+ private void ValidateHitboxVisibility()
+ {
+ OnPropertyChanged(nameof(IsHitboxV3));
+ OnPropertyChanged(nameof(IsNotHitboxV3));
+ OnPropertyChanged(nameof(HitboxV3Visibility));
+ OnPropertyChanged(nameof(HitboxEntries));
+ OnPropertyChanged(nameof(HitboxItems));
+
+ OnPropertyChanged(nameof(IsNotHitboxV5));
+ OnPropertyChanged(nameof(HitboxV5Visibility));
+ OnPropertyChanged(nameof(HitboxTypes));
+ }
+
#endregion
#region Methods
@@ -371,6 +429,7 @@ public void InvalidateFrameProperties()
OnPropertyChanged(nameof(SelectedFrameHeight));
OnPropertyChanged(nameof(SelectedFramePivotX));
OnPropertyChanged(nameof(SelectedFramePivotY));
+ OnPropertyChanged(nameof(SelectedHitbox));
}
private void OnFrameChanged(AnimationService service)
@@ -511,10 +570,14 @@ public bool ChangeCurrentAnimationName(string name)
public void SaveChanges()
{
_animationData.SetAnimations(Animations);
- if (IsHitboxv3)
+ if (IsHitboxV3)
{
_animationData.SetHitboxes(HitboxEntries);
}
+ else if (IsHitboxV5)
+ {
+ _animationData.SetHitboxTypes(HitboxTypes);
+ }
}
#endregion
}
diff --git a/RSDK/IAnimation.cs b/RSDK/IAnimation.cs
index c9e5896..08c5db7 100644
--- a/RSDK/IAnimation.cs
+++ b/RSDK/IAnimation.cs
@@ -57,6 +57,8 @@ public interface IFrame
int CenterX { get; set; }
int CenterY { get; set; }
+
+ IHitbox GetHitbox(int index);
}
public interface IAnimationEntry
@@ -98,6 +100,8 @@ public interface IAnimation
void SetHitboxes(IEnumerable hitboxes);
+ void SetHitboxTypes(IEnumerable hitboxTypes);
+
void SaveChanges(BinaryWriter writer);
}
}
diff --git a/RSDK3/Animation.Frame.cs b/RSDK3/Animation.Frame.cs
index ad8be47..f81cb9a 100644
--- a/RSDK3/Animation.Frame.cs
+++ b/RSDK3/Animation.Frame.cs
@@ -41,5 +41,10 @@ public class Frame : IFrame
public int CenterX { get; set; }
public int CenterY { get; set; }
+
+ public IHitbox GetHitbox(int index)
+ {
+ return new Hitbox();
+ }
}
}
diff --git a/RSDK3/Animation.cs b/RSDK3/Animation.cs
index df29e96..c933e65 100644
--- a/RSDK3/Animation.cs
+++ b/RSDK3/Animation.cs
@@ -85,6 +85,8 @@ public void SetHitboxes(IEnumerable hitboxes)
.Select(x => x as HitboxEntry)
.Where(x => x != null));
}
+ public void SetHitboxTypes(IEnumerable hitboxTypes)
+ { }
public void SaveChanges(BinaryWriter writer)
diff --git a/RSDK5/Animation.Frame.cs b/RSDK5/Animation.Frame.cs
index d7661c8..0818f0f 100644
--- a/RSDK5/Animation.Frame.cs
+++ b/RSDK5/Animation.Frame.cs
@@ -56,5 +56,9 @@ public Frame(int hitboxesCount = 0)
Hitboxes[i] = new Hitbox();
}
}
+ public IHitbox GetHitbox(int index)
+ {
+ return Hitboxes[index];
+ }
}
}
diff --git a/RSDK5/Animation.cs b/RSDK5/Animation.cs
index de1e447..592ad1f 100644
--- a/RSDK5/Animation.cs
+++ b/RSDK5/Animation.cs
@@ -86,6 +86,11 @@ public void SetAnimations(IEnumerable animations)
public IEnumerable GetHitboxes() { return null; }
public void SetHitboxes(IEnumerable hitboxes) { }
+ public void SetHitboxTypes(IEnumerable hitboxTypes)
+ {
+ CollisionBoxes.Clear();
+ CollisionBoxes.AddRange(hitboxTypes);
+ }
public void SaveChanges(BinaryWriter writer)