From 7fc3d3fa6c6f99eacb299ae5684005d20862acda Mon Sep 17 00:00:00 2001 From: Christophe Huybrechts Date: Wed, 17 Jun 2020 13:23:42 +0200 Subject: [PATCH 01/16] Add KH1 Gummi Ship UI (not finished) --- KHSave.Lib1/ISaveKh1.cs | 1 + KHSave.Lib1/SaveKh1.FinalMix.cs | 2 + KHSave.SaveEditor.Kh1/MainView.xaml | 3 ++ .../ViewModels/GummiShipViewModel.cs | 28 ++++++++++++ .../ViewModels/GummiShipsViewModel.cs | 41 ++++++++++++++++++ .../ViewModels/Kh1ViewModel.cs | 1 + .../Views/GummiShipView.xaml | 21 +++++++++ .../Views/GummiShipView.xaml.cs | 28 ++++++++++++ .../Views/GummiShipsView.xaml | 43 +++++++++++++++++++ .../Views/GummiShipsView.xaml.cs | 28 ++++++++++++ 10 files changed, 196 insertions(+) create mode 100644 KHSave.SaveEditor.Kh1/ViewModels/GummiShipViewModel.cs create mode 100644 KHSave.SaveEditor.Kh1/ViewModels/GummiShipsViewModel.cs create mode 100644 KHSave.SaveEditor.Kh1/Views/GummiShipView.xaml create mode 100644 KHSave.SaveEditor.Kh1/Views/GummiShipView.xaml.cs create mode 100644 KHSave.SaveEditor.Kh1/Views/GummiShipsView.xaml create mode 100644 KHSave.SaveEditor.Kh1/Views/GummiShipsView.xaml.cs diff --git a/KHSave.Lib1/ISaveKh1.cs b/KHSave.Lib1/ISaveKh1.cs index 5b90f792..c676b0cc 100644 --- a/KHSave.Lib1/ISaveKh1.cs +++ b/KHSave.Lib1/ISaveKh1.cs @@ -22,6 +22,7 @@ public interface ISaveKh1 PlayableCharacterType CompanionCharacter3 { get; set; } byte[] InventoryCount { get; set; } Character[] Characters { get; set; } + Gummiship[] Gummiships { get; set; } void Write(Stream stream); } diff --git a/KHSave.Lib1/SaveKh1.FinalMix.cs b/KHSave.Lib1/SaveKh1.FinalMix.cs index 28148bfc..c3664f97 100644 --- a/KHSave.Lib1/SaveKh1.FinalMix.cs +++ b/KHSave.Lib1/SaveKh1.FinalMix.cs @@ -31,6 +31,8 @@ public class SaveFinalMix : ISaveKh1 [Data(0x845)] public CommandType ShortcutTriangle { get; set; } [Data(0x846)] public CommandType ShortcutSquare { get; set; } + [Data( 0x241C, Count = 10)] public Gummiship[] Gummiships { get; set; } + [Data(0x16400)] public int AutoLock { get; set; } [Data(0x16404)] public int TargetLock { get; set; } [Data(0x16408)] public int Camera { get; set; } diff --git a/KHSave.SaveEditor.Kh1/MainView.xaml b/KHSave.SaveEditor.Kh1/MainView.xaml index 3e5aecd8..e970b9a5 100644 --- a/KHSave.SaveEditor.Kh1/MainView.xaml +++ b/KHSave.SaveEditor.Kh1/MainView.xaml @@ -17,5 +17,8 @@ + + + diff --git a/KHSave.SaveEditor.Kh1/ViewModels/GummiShipViewModel.cs b/KHSave.SaveEditor.Kh1/ViewModels/GummiShipViewModel.cs new file mode 100644 index 00000000..9cda9dc3 --- /dev/null +++ b/KHSave.SaveEditor.Kh1/ViewModels/GummiShipViewModel.cs @@ -0,0 +1,28 @@ +using KHSave.Lib1; +using KHSave.Lib1.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xe.Tools.Wpf.Models; + +namespace KHSave.SaveEditor.Kh1.ViewModels +{ + public class GummiShipViewModel + { + private readonly Gummiship gummiship; + private readonly int index; + + public GummiShipViewModel(Gummiship gummiship, int index) + { + this.gummiship = gummiship; + this.index = index; + } + + + public byte[] Name { get => gummiship.ShipName; } + public byte BlocksUsed { get => gummiship.BlocksUsed; } + + } +} diff --git a/KHSave.SaveEditor.Kh1/ViewModels/GummiShipsViewModel.cs b/KHSave.SaveEditor.Kh1/ViewModels/GummiShipsViewModel.cs new file mode 100644 index 00000000..4c9420f8 --- /dev/null +++ b/KHSave.SaveEditor.Kh1/ViewModels/GummiShipsViewModel.cs @@ -0,0 +1,41 @@ +using KHSave.Lib1; +using KHSave.Lib1.Models; +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xe.Tools.Wpf.Commands; +using Xe.Tools.Wpf.Models; + +namespace KHSave.SaveEditor.Kh1.ViewModels +{ + public class GummiShipsViewModel : GenericListModel + { + public readonly ISaveKh1 save; + public RelayCommand ExportCommand { get; } + public RelayCommand ImportCommand { get; } + + public GummiShipsViewModel(ISaveKh1 save) : this(save.Gummiships) + { + this.save = save; + } + + public GummiShipsViewModel(IEnumerable list) : + this(list.Select((gummi, index) => new GummiShipViewModel(gummi, index))) + { + + } + + public GummiShipsViewModel(IEnumerable list) : base(list) + { + ExportCommand = new RelayCommand(o => ); + } + + protected override void OnSelectedItem(GummiShipViewModel item) + { + base.OnSelectedItem(item); + } + } +} diff --git a/KHSave.SaveEditor.Kh1/ViewModels/Kh1ViewModel.cs b/KHSave.SaveEditor.Kh1/ViewModels/Kh1ViewModel.cs index a28faca2..137d9c96 100644 --- a/KHSave.SaveEditor.Kh1/ViewModels/Kh1ViewModel.cs +++ b/KHSave.SaveEditor.Kh1/ViewModels/Kh1ViewModel.cs @@ -18,6 +18,7 @@ public Kh1ViewModel() public SystemViewModel System { get; private set; } public InventoryViewModel Inventory { get; private set; } public PlayersViewModel Players { get; private set; } + public GummiShipsViewModel GummiShips { get; private set; } public void RefreshUi() { diff --git a/KHSave.SaveEditor.Kh1/Views/GummiShipView.xaml b/KHSave.SaveEditor.Kh1/Views/GummiShipView.xaml new file mode 100644 index 00000000..67178522 --- /dev/null +++ b/KHSave.SaveEditor.Kh1/Views/GummiShipView.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/KHSave.SaveEditor.Kh1/Views/GummiShipView.xaml.cs b/KHSave.SaveEditor.Kh1/Views/GummiShipView.xaml.cs new file mode 100644 index 00000000..3d0b8493 --- /dev/null +++ b/KHSave.SaveEditor.Kh1/Views/GummiShipView.xaml.cs @@ -0,0 +1,28 @@ +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.Navigation; +using System.Windows.Shapes; + +namespace KHSave.SaveEditor.Kh1.Views +{ + /// + /// Interaction logic for GummiShipView.xaml + /// + public partial class GummiShipView : UserControl + { + public GummiShipView() + { + InitializeComponent(); + } + } +} diff --git a/KHSave.SaveEditor.Kh1/Views/GummiShipsView.xaml b/KHSave.SaveEditor.Kh1/Views/GummiShipsView.xaml new file mode 100644 index 00000000..e7c8c22e --- /dev/null +++ b/KHSave.SaveEditor.Kh1/Views/GummiShipsView.xaml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + +