Skip to content

Commit

Permalink
Partial support for RSDKv5's hitboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeeynamo committed Oct 8, 2017
1 parent 8fdb121 commit 39ddd36
Show file tree
Hide file tree
Showing 13 changed files with 287 additions and 17 deletions.
8 changes: 8 additions & 0 deletions AnimationEditor/AnimationEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<Compile Include="Hitbox3Window.xaml.cs">
<DependentUpon>Hitbox3Window.xaml</DependentUpon>
</Compile>
<Compile Include="Hitbox5Window.xaml.cs">
<DependentUpon>Hitbox5Window.xaml</DependentUpon>
</Compile>
<Compile Include="TextureWindow.xaml.cs">
<DependentUpon>TextureWindow.xaml</DependentUpon>
</Compile>
Expand All @@ -68,12 +71,17 @@
<Compile Include="Services\ImageService.cs" />
<Compile Include="Services\TextureService.cs" />
<Compile Include="ViewModels\HitboxV3EditorViewModel.cs" />
<Compile Include="ViewModels\HitboxV5EditorViewModel.cs" />
<Compile Include="ViewModels\TextureViewModel.cs" />
<Compile Include="ViewModels\TextureWindowViewModel.cs" />
<Page Include="Hitbox3Window.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Hitbox5Window.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
6 changes: 3 additions & 3 deletions AnimationEditor/Hitbox3Window.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
Expand Down Expand Up @@ -73,11 +73,11 @@
<xc:NumericUpDown Grid.Column="4" Grid.Row="1"
MinimumValue="-128" MaximumValue="127"
Value="{Binding SelectedHitboxValue.Top, Mode=TwoWay}"/>
<TextBlock Grid.Column="0" Grid.Row="3" Text="Width"/>
<TextBlock Grid.Column="0" Grid.Row="3" Text="Right"/>
<xc:NumericUpDown Grid.Column="1" Grid.Row="3"
MinimumValue="-128" MaximumValue="127"
Value="{Binding SelectedHitboxValue.Right, Mode=TwoWay}"/>
<TextBlock Grid.Column="3" Grid.Row="3" Text="Height"/>
<TextBlock Grid.Column="3" Grid.Row="3" Text="Bottom"/>
<xc:NumericUpDown Grid.Column="4" Grid.Row="3"
MinimumValue="-128" MaximumValue="127"
Value="{Binding SelectedHitboxValue.Bottom, Mode=TwoWay}"/>
Expand Down
37 changes: 37 additions & 0 deletions AnimationEditor/Hitbox5Window.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Window x:Class="AnimationEditor.Hitbox5Window"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AnimationEditor"
mc:Ignorable="d"
Title="Hitbox manager" Height="300" Width="200">
<DockPanel Margin="5">
<TextBlock DockPanel.Dock="Top" Text="Selected hitbox type"/>
<TextBox DockPanel.Dock="Top" Margin="0 0 0 5"
Text="{Binding SelectedValue, Mode=TwoWay}" LostFocus="TextBox_LostFocus"/>
<Grid DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Button x:Name="ButtonAdd" Grid.Column="0" Margin="0 5 5 0" Click="ButtonAdd_Click"
IsEnabled="false">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource Add_16x}" Width="16"/>
<TextBlock Text="Add" Margin="3 0 3 0"/>
</StackPanel>
</Button>
<Button x:Name="ButtonRemove" Grid.Column="1" Margin="0 5 0 0" Click="ButtonRemove_Click"
IsEnabled="false">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource Remove_color_16x}" Width="16"/>
<TextBlock Text="Remove" Margin="3 0 3 0"/>
</StackPanel>
</Button>
</Grid>
<ListBox x:Name="List" Grid.Column="0" ItemsSource="{Binding HitboxTypeItems}"
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
SelectedValue="{Binding SelectedValue, Mode=TwoWay}"/>
</DockPanel>
</Window>
50 changes: 50 additions & 0 deletions AnimationEditor/Hitbox5Window.xaml.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Interaction logic for Hitbox5Window.xaml
/// </summary>
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);
}
}
}
}
37 changes: 36 additions & 1 deletion AnimationEditor/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,44 @@
<ComboBox ItemsSource="{Binding Textures}"
SelectedIndex="{Binding SelectedFrameTexture, Mode=TwoWay}"/>
<TextBlock Margin="0 5 0 0" Text="Hitbox"/>
<ComboBox ItemsSource="{Binding HitboxItems}"
<ComboBox ItemsSource="{Binding HitboxItems}" Visibility="{Binding HitboxV3Visibility}"
SelectedIndex="{Binding SelectedFrameHitbox, Mode=TwoWay}"/>
<ComboBox ItemsSource="{Binding HitboxTypes}" Visibility="{Binding HitboxV5Visibility}"
SelectedIndex="{Binding SelectedHitboxType, Mode=TwoWay}"/>
<Grid Margin="3" Visibility="{Binding HitboxV5Visibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="5"/>
<RowDefinition Height="20"/>
<RowDefinition Height="5"/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>

<TextBlock Grid.Column="0" Grid.Row="1" Text="Left"/>
<xc:NumericUpDown Grid.Column="1" Grid.Row="1"
MinimumValue="-32768" MaximumValue="32767"
Value="{Binding SelectedHitbox.Left, Mode=TwoWay}"/>
<TextBlock Grid.Column="3" Grid.Row="1" Text="Top"/>
<xc:NumericUpDown Grid.Column="4" Grid.Row="1"
MinimumValue="-32768" MaximumValue="32767"
Value="{Binding SelectedHitbox.Top, Mode=TwoWay}"/>
<TextBlock Grid.Column="0" Grid.Row="3" Text="Right"/>
<xc:NumericUpDown Grid.Column="1" Grid.Row="3"
MinimumValue="-32768" MaximumValue="32767"
Value="{Binding SelectedHitbox.Right, Mode=TwoWay}"/>
<TextBlock Grid.Column="3" Grid.Row="3" Text="Bottom"/>
<xc:NumericUpDown Grid.Column="4" Grid.Row="3"
MinimumValue="-32768" MaximumValue="32767"
Value="{Binding SelectedHitbox.Bottom, Mode=TwoWay}"/>
</Grid>

<TextBlock Margin="0 5 0 0" Text="Sprite property"/>
<Grid Margin="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40"/>
Expand Down
5 changes: 4 additions & 1 deletion AnimationEditor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
54 changes: 54 additions & 0 deletions AnimationEditor/ViewModels/HitboxV5EditorViewModel.cs
Original file line number Diff line number Diff line change
@@ -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<string> 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);
}
}
}
}
Loading

0 comments on commit 39ddd36

Please sign in to comment.