Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kh2ObjectEditor - Added effect VSF list to the editor #1119

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenKh.Kh2/DpdVsf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class DpdVsf
{
public int VsfNo { get; set; }
public int ModelNumber { get; set; }
List<ushort> Indices { get; set; }
public List<ushort> Indices { get; set; }

public DpdVsf(Stream vsfStream)
{
Expand Down
30 changes: 30 additions & 0 deletions OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<UserControl x:Class="OpenKh.Tools.Kh2ObjectEditor.Modules.Effects.M_EffectDpdVoice_Control"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OpenKh.Tools.Kh2ObjectEditor.Modules.Effects"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">

<StackPanel Orientation="Vertical" Background="Black">
<StackPanel Orientation="Horizontal">
<Label Foreground="White" VerticalAlignment="Center">Number:</Label>
<TextBox MinWidth="30" Margin="10" Text="{Binding Path=VsfNo}"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Foreground="White" VerticalAlignment="Center">Model:</Label>
<TextBox MinWidth="30" Margin="10" Text="{Binding Path=ModelNumber}"></TextBox>
</StackPanel>
<Label Foreground="White" VerticalAlignment="Center">Indices</Label>
<DataGrid Name="DataTable"
AutoGenerateColumns="False"
ItemsSource="{Binding Indices}"
CanUserAddRows="True">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Index}" Header="Index" />
</DataGrid.Columns>
</DataGrid>
<Button Width="100" Click="Button_SaveIndices">Save Indices</Button>
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using OpenKh.Kh2;
using System.Windows.Controls;

namespace OpenKh.Tools.Kh2ObjectEditor.Modules.Effects
{
public partial class M_EffectDpdVoice_Control : UserControl
{
public M_EffectDpdVoice_VM ThisDpdVsf { get; set; }
public M_EffectDpdVoice_Control(DpdVsf dpdVsf)
{
InitializeComponent();
ThisDpdVsf = new M_EffectDpdVoice_VM(dpdVsf);
DataContext = ThisDpdVsf;
}

private void Button_SaveIndices(object sender, System.Windows.RoutedEventArgs e)
{
ThisDpdVsf.SaveIndices();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<UserControl x:Class="OpenKh.Tools.Kh2ObjectEditor.Modules.Effects.M_EffectDpdVoiceList_Control"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OpenKh.Tools.Kh2ObjectEditor.Modules.Effects"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>

<ContentControl Grid.Row="0" Name="Frame_Voice" />

<GridSplitter Grid.Column="1" Background="LightGray" HorizontalAlignment="Center" VerticalAlignment="Stretch" ShowsPreview="True" Width="5"/>

<ListView Grid.Column="2" x:Name="ListView_Vsf" ItemsSource="{Binding VsfWrappers}" MouseDoubleClick="ListView_Vsf_MouseDoubleClick">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Path=Name}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using OpenKh.Kh2;
using System.Collections.ObjectModel;
using System.Windows.Controls;

namespace OpenKh.Tools.Kh2ObjectEditor.Modules.Effects
{
public partial class M_EffectDpdVoiceList_Control : UserControl
{

public ObservableCollection<VsfWrapper> VsfWrappers { get; set; }

public M_EffectDpdVoiceList_Control(Dpd loadedDpd)
{
InitializeComponent();

VsfWrappers = new ObservableCollection<VsfWrapper>();
for (int i = 0; i < loadedDpd.VsfList.Count; i++)
{
VsfWrappers.Add(new VsfWrapper(i, loadedDpd.VsfList[i]));
}

DataContext = this;
}

private void ListView_Vsf_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Frame_Voice.Content = new M_EffectDpdVoice_Control(VsfWrappers[ListView_Vsf.SelectedIndex].VoiceEffect);
}

public class VsfWrapper
{
public int Index { get; set; }
public string Name { get; set; }
public DpdVsf VoiceEffect { get; set; }

public VsfWrapper(int index, DpdVsf vsf)
{
Index = index;
VoiceEffect = vsf;
Name = "Vsf " + Index;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using OpenKh.Kh2;
using OpenKh.Tools.Kh2ObjectEditor.Utils;
using System.Collections.ObjectModel;
using System.Diagnostics;

namespace OpenKh.Tools.Kh2ObjectEditor.Modules.Effects
{
public class M_EffectDpdVoice_VM : NotifyPropertyChangedBase
{
public DpdVsf Voice { get; set; }

public int VsfNo
{
get { return Voice.VsfNo; }
set
{
Voice.VsfNo = value;
OnPropertyChanged("VsfNo");
}
}
public int ModelNumber
{
get { return Voice.ModelNumber; }
set
{
Voice.ModelNumber = value;
OnPropertyChanged("ModelNumber");
}
}

private ObservableCollection<IndexWrapper> _indices;
public ObservableCollection<IndexWrapper> Indices
{
get { return _indices; }
set
{
_indices = value;
OnPropertyChanged("Indices");
}
}

public M_EffectDpdVoice_VM(DpdVsf vsf)
{
Voice = vsf;
_indices = new ObservableCollection<IndexWrapper>();
foreach (ushort value in Voice.Indices)
{
_indices.Add(new IndexWrapper { Index = value });
}
}

public void SaveIndices()
{
Voice.Indices.Clear();
foreach (IndexWrapper value in Indices)
{
Voice.Indices.Add(value.Index);
}
Debug.WriteLine("Indices saved!");
}

public class IndexWrapper
{
public ushort Index { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
<TabItem.Header>
<Label>Models</Label>
</TabItem.Header>
<ContentControl Name="Tab_Models"/>
<Label>Unimplemented</Label>
<!--<ContentControl Name="Tab_Models"/>-->
</TabItem>
<TabItem>
<TabItem.Header>
<Label>Shapes</Label>
</TabItem.Header>
<ContentControl Name="Tab_Shapes"/>
<Label>Unimplemented</Label>
<!--<ContentControl Name="Tab_Shapes"/>-->
</TabItem>
<TabItem>
<TabItem.Header>
Expand All @@ -36,7 +38,8 @@
<TabItem.Header>
<Label>Data</Label>
</TabItem.Header>
<ContentControl Name="Tab_Data"/>
<Label>Unimplemented</Label>
<!--<ContentControl Name="Tab_Data"/>-->
</TabItem>
</TabControl>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public void loadTabs()
return;

Tab_Textures.Content = new M_EffectDpdTexture_Control(ThisDpd);
Tab_Vsf.Content = new M_EffectDpdVoiceList_Control(ThisDpd);
}
}
}
Loading