Skip to content

Commit

Permalink
Complete refactor. Added various requested features. DO NOTE THAT THI…
Browse files Browse the repository at this point in the history
…S VERSION IS STILL FOR JPN Saves.
  • Loading branch information
quackerd committed Sep 9, 2017
1 parent 3e94d15 commit 50f3367
Show file tree
Hide file tree
Showing 24 changed files with 1,016 additions and 789 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,4 @@ ModelManifest.xml

# FAKE - F# Make
.fake/
MHSEC-G/.idea/
9 changes: 3 additions & 6 deletions MHSEC-G/MHSEC-G/Armor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace MHSEC_G
{
internal class Armor : INotifyPropertyChanged
public class Armor : INotifyPropertyChanged
{
private const uint OFFSETA_ARM = 0x55F0;
private const uint OFFSETA_ARM_END = 0x720E;
Expand All @@ -23,6 +23,7 @@ internal class Armor : INotifyPropertyChanged

private readonly uint _offset;
private readonly Model _model;
public uint index => (_offset - OFFSETA_ARM) / SIZE_ARM + 1;

public Armor(Model model, uint offset)
{
Expand Down Expand Up @@ -80,7 +81,7 @@ public string unknown_14h
uint parsed;
if (Model.parse_hex_string(value, out parsed))
{
Model.write_uint16_le(_model.save_file, _offset + OFFSETR_ARM_14h, parsed);
Model.write_uint32_le(_model.save_file, _offset + OFFSETR_ARM_14h, parsed);
}
else
{
Expand Down Expand Up @@ -141,10 +142,6 @@ public static ObservableCollection<Armor> read_all_armors(Model model)
ObservableCollection<Armor> ret = new ObservableCollection<Armor>();
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;
Expand Down
2 changes: 1 addition & 1 deletion MHSEC-G/MHSEC-G/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace MHSEC_G
{
internal class Character : INotifyPropertyChanged
public class Character : INotifyPropertyChanged
{
private const uint OFFSETA_CHAR_NAME = 0x9DA0;
private const uint LENGTH_CHAR_NAME = 6;
Expand Down
28 changes: 16 additions & 12 deletions MHSEC-G/MHSEC-G/Egg.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
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
public class Egg : INotifyPropertyChanged
{
private const int OFFSETA_EGG_START = 0x53EC0;
private const int OFFSETA_EGG_END = 0x54505;
// 200 weapons
private const int OFFSETA_EGG_END = 0x54597;
private const int OFFSETR_EGG_GENE = 0x30;
private const int SIZE_EGG_GENE = 0x2;
private const int SIZE_EGG = 0x92;

private const int OFFSETR_SPE = 0x0;
private const int OFFSETR_WGT = 0x2E;

private readonly Genes _genes;
public Genes genes => _genes;

private readonly uint _offset;
private readonly Model _model;
public uint index => (_offset - OFFSETA_EGG_START) / SIZE_EGG + 1;

public Egg(Model model, uint offset)
{
_offset = offset;
_model = model;
_genes = new Genes(model, offset + OFFSETR_EGG_GENE, SIZE_EGG_GENE);
}


public string spe
{
set
Expand Down Expand Up @@ -76,15 +77,18 @@ public static ObservableCollection<Egg> read_all_eggs(Model model)
ObservableCollection<Egg> ret = new ObservableCollection<Egg>();
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 void setByteArray(byte[] ret)
{
Array.Copy(ret, 0, _model.save_file, _offset, SIZE_EGG);
OnPropertyChanged(null);
}

public event PropertyChangedEventHandler PropertyChanged;

[NotifyPropertyChangedInvocator]
Expand Down
6 changes: 2 additions & 4 deletions MHSEC-G/MHSEC-G/EggFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace MHSEC_G
{
internal class EggFragment : INotifyPropertyChanged
public class EggFragment : INotifyPropertyChanged
{
private const uint OFFSETA_EGG_FRAGMENTS = 0x9790;
private const uint OFFSETA_EGG_FRAGMENTS_END = 0x9C3F;
Expand All @@ -21,6 +21,7 @@ internal class EggFragment : INotifyPropertyChanged
private const uint OFFSETR_EF_7H = 0x7;

private readonly uint _offset;
public uint idx => (_offset - OFFSETA_EGG_FRAGMENTS) / SIZE_EGG_FRAGMENT + 1;

public uint offset
{
Expand Down Expand Up @@ -182,8 +183,6 @@ public static ObservableCollection<EggFragment> read_all_egg_fragments(Model mod
byte[] buffer = model.save_file;
for (uint offset = OFFSETA_EGG_FRAGMENTS; offset < OFFSETA_EGG_FRAGMENTS_END; offset += SIZE_EGG_FRAGMENT)
{
if(buffer[offset] == 0)
continue;
ret.Add(new EggFragment(offset, model));
}
return ret;
Expand Down Expand Up @@ -218,7 +217,6 @@ public static void write_dlc_egg_fragment(ObservableCollection<EggFragment> frag
each_frag.dlc = dlc.ToString("X2");
each_frag.unknown_6h = "0";
each_frag.unknown_7h = "0";

}
}

Expand Down
72 changes: 72 additions & 0 deletions MHSEC-G/MHSEC-G/GeneWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<Window x:Class="MHSEC_G.GeneWindow"
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:MHSEC_G"
mc:Ignorable="d"
Title="Gene Editor" Height="306.875" Width="471.214" ResizeMode="NoResize">
<Grid Height="278" VerticalAlignment="Top">
<Grid Background="#FFE5E5E5" Height="280" VerticalAlignment="Top">
<Label x:Name="label_mgen1" Content="Gene 1 (Hex)" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="35,27,0,0" RenderTransformOrigin="0.474,0.808" />
<Label x:Name="label_mgen2" Content="Gene 2 (Hex)" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="185,27,0,0" />
<Label x:Name="label_mgen3" Content="Gene 3 (Hex)" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="336,27,0,0" RenderTransformOrigin="0.537,0.19" />
<Label x:Name="label_mgen4" Content="Gene 4 (Hex)" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="35,112,0,0" />
<Label x:Name="label_mgen5" Content="Gene 5 (Hex)" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="185,112,0,0" RenderTransformOrigin="0.524,0.439" />
<Label x:Name="label_mgen6" Content="Gene 6 (Hex)" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="336,112,0,0" />
<Label x:Name="label_mgen7" Content="Gene 7 (Hex)" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="35,189,0,0" />
<Label x:Name="label_mgen8" Content="Gene 8 (Hex)" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="185,189,0,0" RenderTransformOrigin="-3.481,0.038" />
<Label x:Name="label_mgen9" Content="Gene 9 (Hex)" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="336,189,0,0" />
<TextBox x:Name="textbox_gene1" HorizontalAlignment="Left" Height="22" TextWrapping="Wrap"
Text="{Binding genes.gene1}" VerticalAlignment="Top" Width="129"
Margin="10,58,0,0" />
<TextBox x:Name="textbox_gene2" HorizontalAlignment="Left" Height="22" TextWrapping="Wrap"
Text="{Binding genes.gene2}" VerticalAlignment="Top" Width="128"
Margin="164,58,0,0" />
<TextBox x:Name="textbox_gene3" HorizontalAlignment="Left" Height="22" TextWrapping="Wrap"
Text="{Binding genes.gene3}" VerticalAlignment="Top" Width="129"
Margin="313,58,0,0" />
<TextBox x:Name="textbox_gene4" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap"
Text="{Binding genes.gene4}" VerticalAlignment="Top" Width="127"
Margin="10,138,0,0" />
<TextBox x:Name="textbox_gene5" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap"
Text="{Binding genes.gene5}" VerticalAlignment="Top" Width="129"
Margin="164,138,0,0" />
<TextBox x:Name="textbox_gene6" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap"
Text="{Binding genes.gene6}" VerticalAlignment="Top" Width="128"
Margin="314,138,0,0" />
<TextBox x:Name="textbox_gene7" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap"
Text="{Binding genes.gene7}" VerticalAlignment="Top" Width="125"
Margin="10,214,0,0" />
<TextBox x:Name="textbox_gene8" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap"
Text="{Binding genes.gene8}" VerticalAlignment="Top" Width="129"
Margin="164,214,0,0" />
<TextBox x:Name="textbox_gene9" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap"
Text="{Binding genes.gene9}" VerticalAlignment="Top" Width="128"
Margin="314,214,0,0" RenderTransformOrigin="0.55,-0.239" />
<TextBlock x:Name="textblock_gene101" HorizontalAlignment="Left" Margin="10,10,0,0"
TextWrapping="Wrap"
Text="Do NOT use genes that start with &quot;[D]&quot; They are potentially game-crashing."
VerticalAlignment="Top" />
<ComboBox x:Name="comboBox_gene1" HorizontalAlignment="Left" Margin="10,85,0,0" VerticalAlignment="Top" Width="129" ItemsSource="{Binding genes.gene_name}" SelectedIndex="{Binding genes.gene1_selected}"/>
<ComboBox x:Name="comboBox_gene2" HorizontalAlignment="Left" Margin="164,85,0,0" VerticalAlignment="Top" Width="129" ItemsSource="{Binding genes.gene_name}" SelectedIndex="{Binding genes.gene2_selected}"/>
<ComboBox x:Name="comboBox_gene3" HorizontalAlignment="Left" Margin="313,85,0,0" VerticalAlignment="Top" Width="129" ItemsSource="{Binding genes.gene_name}" SelectedIndex="{Binding genes.gene3_selected}"/>
<ComboBox x:Name="comboBox_gene4" HorizontalAlignment="Left" Margin="10,166,0,0" VerticalAlignment="Top" Width="125" ItemsSource="{Binding genes.gene_name}" SelectedIndex="{Binding genes.gene4_selected}"/>
<ComboBox x:Name="comboBox_gene5" HorizontalAlignment="Left" Margin="164,166,0,0" VerticalAlignment="Top" Width="129" ItemsSource="{Binding genes.gene_name}" SelectedIndex="{Binding genes.gene5_selected}" RenderTransformOrigin="-1.663,0.932"/>
<ComboBox x:Name="comboBox_gene6" HorizontalAlignment="Left" Margin="314,166,0,0" VerticalAlignment="Top" Width="129" ItemsSource="{Binding genes.gene_name}" SelectedIndex="{Binding genes.gene6_selected}"/>
<ComboBox x:Name="comboBox_gene7" HorizontalAlignment="Left" Margin="10,242,0,0" VerticalAlignment="Top" Width="125" ItemsSource="{Binding genes.gene_name}" SelectedIndex="{Binding genes.gene7_selected}"/>
<ComboBox x:Name="comboBox_gene8" HorizontalAlignment="Left" Margin="164,242,0,0" VerticalAlignment="Top" Width="129" ItemsSource="{Binding genes.gene_name}" SelectedIndex="{Binding genes.gene8_selected}"/>
<ComboBox x:Name="comboBox_gene9" HorizontalAlignment="Left" Margin="313,242,0,0" VerticalAlignment="Top" Width="129" ItemsSource="{Binding genes.gene_name}" SelectedIndex="{Binding genes.gene9_selected}"/>
</Grid>

</Grid>
</Window>
41 changes: 41 additions & 0 deletions MHSEC-G/MHSEC-G/GeneWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
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;
using MHSEC_G.Annotations;

namespace MHSEC_G
{
/// <summary>
/// Interaction logic for GeneWindow.xaml
/// </summary>
public partial class GeneWindow : Window, INotifyPropertyChanged
{
private readonly Genes _genes;
public Genes genes => _genes;

public GeneWindow(Genes genes)
{
this._genes = genes;
DataContext = this;
InitializeComponent();
}

public event PropertyChangedEventHandler PropertyChanged;

[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Loading

0 comments on commit 50f3367

Please sign in to comment.