From 69bfdd58fc3e719497e1b6e1fcd956773e80e642 Mon Sep 17 00:00:00 2001 From: osdanova Date: Sun, 13 Oct 2024 19:25:48 +0200 Subject: [PATCH] Kh2ObjectEditor - Added effect VSF list to the editor --- OpenKh.Kh2/DpdVsf.cs | 2 +- .../Modules/Effects/M_EffectDpdVoice.xaml | 30 +++++++++ .../Modules/Effects/M_EffectDpdVoice.xaml.cs | 21 ++++++ .../Effects/M_EffectDpdVoiceList_Control.xaml | 30 +++++++++ .../M_EffectDpdVoiceList_Control.xaml.cs | 44 ++++++++++++ .../Modules/Effects/M_EffectDpdVoice_VM.cs | 67 +++++++++++++++++++ .../Effects/M_EffectsDpdTabs_Control.xaml | 9 ++- .../Effects/M_EffectsDpdTabs_Control.xaml.cs | 1 + 8 files changed, 200 insertions(+), 4 deletions(-) create mode 100644 OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice.xaml create mode 100644 OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice.xaml.cs create mode 100644 OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoiceList_Control.xaml create mode 100644 OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoiceList_Control.xaml.cs create mode 100644 OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice_VM.cs diff --git a/OpenKh.Kh2/DpdVsf.cs b/OpenKh.Kh2/DpdVsf.cs index d61678678..ac61d5c8c 100644 --- a/OpenKh.Kh2/DpdVsf.cs +++ b/OpenKh.Kh2/DpdVsf.cs @@ -9,7 +9,7 @@ public class DpdVsf { public int VsfNo { get; set; } public int ModelNumber { get; set; } - List Indices { get; set; } + public List Indices { get; set; } public DpdVsf(Stream vsfStream) { diff --git a/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice.xaml b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice.xaml new file mode 100644 index 000000000..f0af50116 --- /dev/null +++ b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice.xaml.cs b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice.xaml.cs new file mode 100644 index 000000000..ed7bf7a41 --- /dev/null +++ b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice.xaml.cs @@ -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(); + } + } +} diff --git a/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoiceList_Control.xaml b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoiceList_Control.xaml new file mode 100644 index 000000000..42e45e853 --- /dev/null +++ b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoiceList_Control.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoiceList_Control.xaml.cs b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoiceList_Control.xaml.cs new file mode 100644 index 000000000..85aa8f705 --- /dev/null +++ b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoiceList_Control.xaml.cs @@ -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 VsfWrappers { get; set; } + + public M_EffectDpdVoiceList_Control(Dpd loadedDpd) + { + InitializeComponent(); + + VsfWrappers = new ObservableCollection(); + 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; + } + } + } +} diff --git a/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice_VM.cs b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice_VM.cs new file mode 100644 index 000000000..de18c72a8 --- /dev/null +++ b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectDpdVoice_VM.cs @@ -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 _indices; + public ObservableCollection Indices + { + get { return _indices; } + set + { + _indices = value; + OnPropertyChanged("Indices"); + } + } + + public M_EffectDpdVoice_VM(DpdVsf vsf) + { + Voice = vsf; + _indices = new ObservableCollection(); + 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; } + } + } +} diff --git a/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectsDpdTabs_Control.xaml b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectsDpdTabs_Control.xaml index 2be607374..1c1bc5ccd 100644 --- a/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectsDpdTabs_Control.xaml +++ b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectsDpdTabs_Control.xaml @@ -18,13 +18,15 @@ - + + - + + @@ -36,7 +38,8 @@ - + + diff --git a/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectsDpdTabs_Control.xaml.cs b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectsDpdTabs_Control.xaml.cs index cacfb5510..059ed0b77 100644 --- a/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectsDpdTabs_Control.xaml.cs +++ b/OpenKh.Tools.Kh2ObjectEditor/Modules/Effects/M_EffectsDpdTabs_Control.xaml.cs @@ -19,6 +19,7 @@ public void loadTabs() return; Tab_Textures.Content = new M_EffectDpdTexture_Control(ThisDpd); + Tab_Vsf.Content = new M_EffectDpdVoiceList_Control(ThisDpd); } } }