From 6cdc6bfc21b98b434c0a508f67de49cde4cad5c2 Mon Sep 17 00:00:00 2001 From: secXsQuared1995 Date: Sat, 5 Nov 2016 00:13:36 -0400 Subject: [PATCH] Ver 0.22 - Weapon/Armor editing - Monster Skill Editing - Fixed Monster Name Bug - Egg Editing --- MHSEC-G/MHSEC-G/Armor.cs | 163 +++++++++++++++++ MHSEC-G/MHSEC-G/BugCheck.cs | 7 +- MHSEC-G/MHSEC-G/Character.cs | 2 +- MHSEC-G/MHSEC-G/Egg.cs | 97 ++++++++++ MHSEC-G/MHSEC-G/EggFragment.cs | 2 +- MHSEC-G/MHSEC-G/Item.cs | 2 +- MHSEC-G/MHSEC-G/MHSEC-G.csproj | 3 + MHSEC-G/MHSEC-G/MainWindow.xaml | 201 +++++++++++++-------- MHSEC-G/MHSEC-G/Model.cs | 2 +- MHSEC-G/MHSEC-G/Monster.cs | 25 ++- MHSEC-G/MHSEC-G/Properties/AssemblyInfo.cs | 4 +- MHSEC-G/MHSEC-G/Talisman.cs | 2 +- MHSEC-G/MHSEC-G/ViewModel.cs | 25 ++- MHSEC-G/MHSEC-G/Weapon.cs | 115 ++++++++++++ MHSEC-G/OffsetObject.txt | 0 15 files changed, 567 insertions(+), 83 deletions(-) create mode 100644 MHSEC-G/MHSEC-G/Armor.cs create mode 100644 MHSEC-G/MHSEC-G/Egg.cs create mode 100644 MHSEC-G/MHSEC-G/Weapon.cs create mode 100644 MHSEC-G/OffsetObject.txt diff --git a/MHSEC-G/MHSEC-G/Armor.cs b/MHSEC-G/MHSEC-G/Armor.cs new file mode 100644 index 0000000..506ab08 --- /dev/null +++ b/MHSEC-G/MHSEC-G/Armor.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Windows; +using MHSEC_G.Annotations; + +namespace MHSEC_G +{ + internal class Armor : INotifyPropertyChanged + { + private const uint OFFSETA_ARM = 0x55F0; + private const uint OFFSETA_ARM_END = 0x720E; + // 200 armors + private const uint SIZE_ARM = 0x24; + private const uint OFFSETR_ARM_ID = 0x2; + private const uint OFFSETR_ARM_LEVEL = 0x4; + private const uint OFFSETR_ARM_14h = 0x14; + private const uint OFFSETR_ARM_18h = 0x18; + private const uint OFFSETR_ARM_1C = 0x1c; + + private readonly uint _offset; + private readonly Model _model; + + public Armor(Model model, uint offset) + { + _offset = offset; + _model = model; + } + + public string id + { + set + { + uint parsed; + if (Model.parse_hex_string(value, out parsed) && parsed <= 0xFFFF) + { + Model.write_uint16_le(_model.save_file, _offset + OFFSETR_ARM_ID, parsed); + } + else + { + MessageBox.Show("Malformed int - must be at most 0xFFFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + OnPropertyChanged(nameof(id)); + } + get + { + return Model.byte_to_uint16_le(_model.save_file, _offset + OFFSETR_ARM_ID).ToString("X4"); + } + } + + public string level + { + set + { + uint parsed; + if (Model.parse_hex_string(value, out parsed) && parsed <= 0xFFFF) + { + Model.write_uint16_le(_model.save_file, _offset + OFFSETR_ARM_LEVEL, parsed); + } + else + { + MessageBox.Show("Malformed int - must be at most 0xFFFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + OnPropertyChanged(nameof(level)); + } + get + { + return Model.byte_to_uint16_le(_model.save_file, _offset + OFFSETR_ARM_LEVEL).ToString("X4"); + } + } + + + public string unknown_14h + { + set + { + uint parsed; + if (Model.parse_hex_string(value, out parsed)) + { + Model.write_uint16_le(_model.save_file, _offset + OFFSETR_ARM_14h, parsed); + } + else + { + MessageBox.Show("Malformed int - must be at most 0xFFFFFFFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + OnPropertyChanged(nameof(unknown_14h)); + } + get + { + return Model.byte_to_uint32_le(_model.save_file, _offset + OFFSETR_ARM_14h).ToString("X8"); + } + } + + public string unknown_18h + { + set + { + uint parsed; + if (Model.parse_hex_string(value, out parsed)) + { + Model.write_uint32_le(_model.save_file, _offset + OFFSETR_ARM_18h, parsed); + } + else + { + MessageBox.Show("Malformed int - must be at most 0xFFFFFFFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + OnPropertyChanged(nameof(unknown_18h)); + } + get + { + return Model.byte_to_uint32_le(_model.save_file, _offset + OFFSETR_ARM_18h).ToString("X8"); + } + } + + public string unknown_1ch + { + set + { + uint parsed; + if (Model.parse_hex_string(value, out parsed)) + { + Model.write_uint32_le(_model.save_file, _offset + OFFSETR_ARM_1C, parsed); + } + else + { + MessageBox.Show("Malformed int - must be at most 0xFFFFFFFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + OnPropertyChanged(nameof(unknown_1ch)); + } + get + { + return Model.byte_to_uint32_le(_model.save_file, _offset + OFFSETR_ARM_1C).ToString("X8"); + } + } + + public static ObservableCollection read_all_armors(Model model) + { + ObservableCollection ret = new ObservableCollection(); + for (uint i = OFFSETA_ARM; i < OFFSETA_ARM_END; i += SIZE_ARM) + { + if (Model.byte_to_uint16_le(model.save_file, i) == 0x7FFF) + { + continue; + } + ret.Add(new Armor(model, i)); + } + return ret; + } + + public event PropertyChangedEventHandler PropertyChanged; + + [NotifyPropertyChangedInvocator] + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } + + +} diff --git a/MHSEC-G/MHSEC-G/BugCheck.cs b/MHSEC-G/MHSEC-G/BugCheck.cs index 4299667..f5b6754 100644 --- a/MHSEC-G/MHSEC-G/BugCheck.cs +++ b/MHSEC-G/MHSEC-G/BugCheck.cs @@ -3,7 +3,7 @@ using System.Windows; namespace MHSEC_G { - public class BugCheck + internal class BugCheck { public enum ErrorCode { @@ -27,6 +27,11 @@ namespace MHSEC_G // Facility Monster MON_GENE_MAPPING_CORRUPTED = 0x31, MON_GENE_IDX_OVERFLOW = 0x32, + + // Factility OffsetObject + OFFSET_OBJ_MODEL_NULL = 0x41, + OFFSET_READ_OBJ_ARG_NULL = 0x42, + OFFSET_OBJ_MISMATCHED_TYPE = 0x43 } public static void bug_check(ErrorCode error_code, string error_message) { diff --git a/MHSEC-G/MHSEC-G/Character.cs b/MHSEC-G/MHSEC-G/Character.cs index aa0de25..a96cc14 100644 --- a/MHSEC-G/MHSEC-G/Character.cs +++ b/MHSEC-G/MHSEC-G/Character.cs @@ -4,7 +4,7 @@ using MHSEC_G.Annotations; namespace MHSEC_G { - public class Character : INotifyPropertyChanged + internal class Character : INotifyPropertyChanged { private const uint OFFSETA_CHAR_NAME = 0x9DA0; private const uint LENGTH_CHAR_NAME = 6; diff --git a/MHSEC-G/MHSEC-G/Egg.cs b/MHSEC-G/MHSEC-G/Egg.cs new file mode 100644 index 0000000..c5d1f44 --- /dev/null +++ b/MHSEC-G/MHSEC-G/Egg.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Windows; +using MHSEC_G.Annotations; + +namespace MHSEC_G +{ + internal class Egg : INotifyPropertyChanged + { + private const int OFFSETA_EGG_START = 0x53EC0; + private const int OFFSETA_EGG_END = 0x54505; + // 200 weapons + private const int SIZE_EGG = 0x92; + + private const int OFFSETR_SPE = 0x0; + private const int OFFSETR_WGT = 0x2E; + + private readonly uint _offset; + private readonly Model _model; + + public Egg(Model model, uint offset) + { + _offset = offset; + _model = model; + } + + + public string spe + { + set + { + uint parsed; + if (Model.parse_hex_string(value, out parsed) && parsed <= 0xFF) + { + Model.write_byte(_model.save_file, _offset + OFFSETR_SPE, parsed); + } + else + { + MessageBox.Show("Malformed int - must be at most 0xFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + OnPropertyChanged(nameof(spe)); + } + get + { + return Model.byte_to_uint(_model.save_file[_offset + OFFSETR_SPE]).ToString("X2"); + } + } + + public string wgt + { + set + { + uint parsed; + if (Model.parse_hex_string(value, out parsed) && parsed <= 0xFF) + { + Model.write_byte(_model.save_file, _offset + OFFSETR_WGT, parsed); + } + else + { + MessageBox.Show("Malformed int - must be at most 0xFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + OnPropertyChanged(nameof(wgt)); + } + get + { + return Model.byte_to_uint(_model.save_file[_offset + OFFSETR_WGT]).ToString("X2"); + } + } + + public static ObservableCollection read_all_eggs(Model model) + { + ObservableCollection ret = new ObservableCollection(); + for (uint i = OFFSETA_EGG_START; i < OFFSETA_EGG_END; i += SIZE_EGG) + { + if (Model.byte_to_uint(model.save_file[i + OFFSETR_SPE]) == 0xFF) + { + continue; + } + ret.Add(new Egg(model, i)); + } + return ret; + } + + public event PropertyChangedEventHandler PropertyChanged; + + [NotifyPropertyChangedInvocator] + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + } +} diff --git a/MHSEC-G/MHSEC-G/EggFragment.cs b/MHSEC-G/MHSEC-G/EggFragment.cs index a39a2a5..5b0b891 100644 --- a/MHSEC-G/MHSEC-G/EggFragment.cs +++ b/MHSEC-G/MHSEC-G/EggFragment.cs @@ -6,7 +6,7 @@ using MHSEC_G.Annotations; namespace MHSEC_G { - public class EggFragment : INotifyPropertyChanged + internal class EggFragment : INotifyPropertyChanged { private const uint OFFSETA_EGG_FRAGMENTS = 0x9790; private const uint OFFSETA_EGG_FRAGMENTS_END = 0x9C3F; diff --git a/MHSEC-G/MHSEC-G/Item.cs b/MHSEC-G/MHSEC-G/Item.cs index 2d7b94f..b0dc899 100644 --- a/MHSEC-G/MHSEC-G/Item.cs +++ b/MHSEC-G/MHSEC-G/Item.cs @@ -8,7 +8,7 @@ using MHSEC_G.Annotations; namespace MHSEC_G { - public class Item : INotifyPropertyChanged + internal class Item : INotifyPropertyChanged { private static readonly uint OFFSETA_ITEM_BOX = 0x10; private static readonly uint SIZE_ITEM = 0x8; diff --git a/MHSEC-G/MHSEC-G/MHSEC-G.csproj b/MHSEC-G/MHSEC-G/MHSEC-G.csproj index afb3985..2261a78 100644 --- a/MHSEC-G/MHSEC-G/MHSEC-G.csproj +++ b/MHSEC-G/MHSEC-G/MHSEC-G.csproj @@ -81,8 +81,10 @@ MSBuild:Compile Designer + + @@ -95,6 +97,7 @@ + MSBuild:Compile Designer diff --git a/MHSEC-G/MHSEC-G/MainWindow.xaml b/MHSEC-G/MHSEC-G/MainWindow.xaml index 9a4a495..0ff522b 100644 --- a/MHSEC-G/MHSEC-G/MainWindow.xaml +++ b/MHSEC-G/MHSEC-G/MainWindow.xaml @@ -10,37 +10,68 @@ - + -