This commit is contained in:
sy2zhao 2017-09-11 21:41:26 -04:00
parent 9fbf4e9794
commit e1643201e6
10 changed files with 288 additions and 108 deletions

View File

@ -125,6 +125,24 @@ namespace MHSEC_G
}
}
public string equipped
{
get { return Helper.byte_to_uint(_data[_obj_offset + Offsets.OFFSETR_ARM_EQUIPPED]).ToString("X2"); }
set
{
uint parsed;
if (Helper.parse_hex_string(value, out parsed) && parsed <= 0xFF)
{
Helper.write_byte(_data, _obj_offset + Offsets.OFFSETR_ARM_EQUIPPED, parsed);
}
else
{
MessageBox.Show("Malformed Equipped value - must be at most 0xFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
OnPropertyChanged(nameof(equipped));
}
}
public string unknown_1ch
{
set

View File

@ -88,18 +88,18 @@ namespace MHSEC_G
{
if (length < str.Length || arr.Length < offset + length)
{
BugCheck.bug_check(BugCheck.ErrorCode.MODEL_WRITE_UNICODE_OVERFLOW, "Buffer overflowed.\nBound " + arr.Length + " Offset " + offset);
BugCheck.bug_check(BugCheck.ErrorCode.MODEL_WRITE_UNICODE_OVERFLOW,
"Buffer overflowed.\nBound " + arr.Length + " Offset " + offset);
}
Array.Clear(arr, (int) offset, (int)length*2);
for (uint i = 0; i < str.Length; i ++)
Array.Clear(arr, (int) offset, (int) length * 2);
for (uint i = 0; i < str.Length; i++)
{
write_uint16_le(arr, offset + i*2, str.ElementAt((int) i));
write_uint16_le(arr, offset + i * 2, str.ElementAt((int) i));
}
return;
}
public static bool parse_hex_string(string val, out uint result)
{
result = 0;

View File

@ -76,31 +76,31 @@
VerticalAlignment="Top" Height="307" Width="417" CanUserAddRows="False"
AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Path=egg_fragments}">
<DataGrid.Columns>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="50" Binding="{Binding idx}"
Header="Index" IsReadOnly="True"/>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="50" Binding="{Binding spe}"
Header="Genus" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="60" Binding="{Binding pos}"
Header="Position" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding new_flag}"
Header="New" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding rarity}"
Header="Rarity" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding color}"
Header="Color" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding dlc}"
Header="DLC" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding unknown_7h}"
Header="0x6" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding unknown_6h}"
Header="0x7" />
</DataGrid.Columns>
@ -118,20 +118,22 @@
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding index}"
Header="Index" IsReadOnly="True"/>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding spe}"
Header="Hatched Monster Species" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding wgt}"
Header="Weight" />
</DataGrid.Columns>
</DataGrid>
<Label x:Name="label_monster_Copy" Content="Double-click an entry to edit genes. Click twice to edit the table entry." HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.184,0.019"/>
<Button x:Name="button_eggs_delete" Content="Delete" HorizontalAlignment="Left" Margin="319,29,0,0" VerticalAlignment="Top" Width="108" RenderTransformOrigin="1.601,-0.2" Click="button_eggs_delete_Click"/>
<Button x:Name="button_eggs_dummy" Content="Set Dummy Egg" HorizontalAlignment="Left" Margin="206,29,0,0" VerticalAlignment="Top" Width="108" RenderTransformOrigin="1.601,-0.2" Click="button_eggs_dummy_Click"/>
<Button x:Name="button_eggs_delete" Content="Delete" HorizontalAlignment="Left" Margin="347,29,0,0" VerticalAlignment="Top" Width="80" RenderTransformOrigin="1.601,-0.2" Click="button_eggs_delete_Click"/>
<Button x:Name="button_eggs_dummy" Content="Set Dummy" HorizontalAlignment="Left" Margin="10,29,0,0" VerticalAlignment="Top" Width="80" RenderTransformOrigin="1.601,-0.2" Click="button_eggs_dummy_Click"/>
<Button x:Name="button_eggs_export" Content="Export" HorizontalAlignment="Left" Margin="262,29,0,0" VerticalAlignment="Top" Width="80" RenderTransformOrigin="1.601,-0.2" Click="button_eggs_export_Click"/>
<Button x:Name="button_eggs_import" Content="Import" HorizontalAlignment="Left" Margin="177,29,0,0" VerticalAlignment="Top" Width="80" RenderTransformOrigin="1.601,-0.2" Click="button_eggs_import_Click"/>
</Grid>
</TabItem>
@ -146,19 +148,19 @@
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="30" Binding="{Binding box}"
Header="Box"/>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="30" Binding="{Binding slot}"
Header="Slot"/>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding uid}"
Header="UID"/>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="200" Binding="{Binding name}"
Header="Name" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding level}"
Header="Level" />
</DataGrid.Columns>
@ -173,25 +175,25 @@
VerticalAlignment="Top" Height="307" Width="417" CanUserAddRows="False"
AutoGenerateColumns="False" ItemsSource="{Binding Path=talismans}" SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding index}"
Header="Index" IsReadOnly="True" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding id}"
Header="ID" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding rarity}"
Header="Rarity" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding new_flag}"
Header="New" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="70" Binding="{Binding equipped}"
Header="Equipped" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding skill1}"
Header="Skill 1" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding skill2}"
Header="Skill 2" />
</DataGrid.Columns>
@ -204,18 +206,21 @@
VerticalAlignment="Top" Height="307" Width="417" CanUserAddRows="False"
AutoGenerateColumns="False" ItemsSource="{Binding weapons}" SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding index}"
Header="Index" IsReadOnly="True"/>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="80" Binding="{Binding clazz}"
Header="Class" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="80" Binding="{Binding id}"
Header="ID" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding level}"
Header="Level" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding equipped}"
Header="Equipped" />
</DataGrid.Columns>
</DataGrid>
</Grid>
@ -226,25 +231,28 @@
VerticalAlignment="Top" Height="307" Width="417" CanUserAddRows="False"
AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding armors}">
<DataGrid.Columns>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding index}"
Header="Index" IsReadOnly="True"/>
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding type}"
Header="Type" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding id}"
Header="ID" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="60" Binding="{Binding equipped}"
Header="Equipped" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="40" Binding="{Binding level}"
Header="Level" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding unknown_14h}"
Header="Color1 (RGB)" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
Header="Color1" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding unknown_18h}"
Header="Color2 (RGB)" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False"
Header="Color2" />
<DataGridTextColumn CanUserReorder="False" CanUserResize="False" CanUserSort="True"
Width="*" Binding="{Binding unknown_1ch}"
Header="0x1Ch" />
</DataGrid.Columns>
@ -258,7 +266,7 @@
VerticalAlignment="Top" Width="74" Click="button_load_click" />
<Button x:Name="button_about" Content="About" HorizontalAlignment="Left" Margin="379,10,0,0" VerticalAlignment="Top" Width="74" Click="button_about_Click"/>
<Label x:Name="label_save_ver_cap" Content="Save Version:" HorizontalAlignment="Left" Margin="164,7,0,0" VerticalAlignment="Top"/>
<Label x:Name="label_save_ver" Content="JPN" HorizontalAlignment="Left" Margin="235,7,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.237,0.519" FontWeight="Bold"/>
<Label x:Name="label_save_ver" Content="No save loaded" HorizontalAlignment="Left" Margin="235,7,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.237,0.519" FontWeight="Bold"/>
</Grid>
</Window>

View File

@ -29,9 +29,9 @@ namespace MHSEC_G
button_save.IsEnabled = false;
byte[] dummy = new byte[Offsets.SAVE_FILE_SIZE_JPN];
Array.Clear(dummy, 0, dummy.Length);
this.Title = "MHSEC-G Ver " + get_app_version();
Offsets.init(dummy);
init(dummy);
this.Title = "MHSEC-G Ver " + get_app_version();
DataContext = this;
}
@ -53,7 +53,8 @@ namespace MHSEC_G
}
else
{
if (buffer.Length == Offsets.SAVE_FILE_SIZE_JPN)
Offsets.init(buffer);
if (Offsets.VER == Offsets.Version.JPN)
{
label_save_ver.Content = "JPN";
}
@ -61,7 +62,6 @@ namespace MHSEC_G
{
label_save_ver.Content = "EUR/USA";
}
Offsets.init(buffer);
init(buffer);
OnPropertyChanged(null);
button_save.IsEnabled = true;
@ -238,5 +238,61 @@ namespace MHSEC_G
PartyWindow partyWnd = new PartyWindow(_model);
partyWnd.Show();
}
private void button_eggs_export_Click(object sender, RoutedEventArgs e)
{
if (this.egg_grid.SelectedItem == null)
{
MessageBox.Show("Please select an egg.", "MHSEC-G", MessageBoxButton.OK);
}
else
{
Egg theEgg = egg_grid.SelectedItem as Egg;
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "Binary files (*.bin)|*.bin|All files (*.*)|*.*";
dialog.Title = "Please select the export location.";
dialog.FileName = "egg_" + theEgg.spe + ".bin";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
byte[] binary = theEgg.toByteArray();
File.WriteAllBytes(dialog.FileName, binary);
MessageBox.Show("Exported to \"" + dialog.FileName + "\"", "MHSEC-G", MessageBoxButton.OK,
MessageBoxImage.Information);
}
}
}
private void button_eggs_import_Click(object sender, RoutedEventArgs e)
{
if (this.egg_grid.SelectedItem == null)
{
MessageBox.Show("Please select an egg.", "MHSEC-G", MessageBoxButton.OK);
}
else
{
Egg theEgg = egg_grid.SelectedItem as Egg;
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "Binary files (*.bin)|*.bin|All files (*.*)|*.*";
dialog.Title = "Please select the monster file.";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
byte[] buffer = File.ReadAllBytes(dialog.FileName);
if (buffer.Length != Offsets.SIZE_EGG)
{
System.Windows.Forms.MessageBox.Show(
"Wrong egg file size!",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
theEgg.setByteArray(buffer);
}
}
}
}
}
}

View File

@ -5,88 +5,88 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MHSEC_G"
mc:Ignorable="d"
Title="Monster Editor" Height="313.238" Width="339.947" ResizeMode="NoResize">
Title="Monster Editor" Height="313.238" Width="364.618" ResizeMode="NoResize">
<Grid Background="#FFE5E5E5">
<Label x:Name="label_mhp" Content="HP" HorizontalAlignment="Left" Margin="26,39,0,0"
<Label x:Name="label_mhp" Content="HP" HorizontalAlignment="Left" Margin="69,39,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.564,2.072" />
<Label x:Name="label_mat" Content="Atk" HorizontalAlignment="Left" Margin="23,68,0,0"
<Label x:Name="label_mat" Content="Atk" HorizontalAlignment="Left" Margin="67,68,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.564,2.072" />
<Label x:Name="label_mdf" Content="Def" HorizontalAlignment="Left" Margin="22,97,0,0"
<Label x:Name="label_mdf" Content="Def" HorizontalAlignment="Left" Margin="65,98,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.564,2.072" />
<Label x:Name="label_mhiv" Content="IV-HP" HorizontalAlignment="Left" Margin="11,125,0,0"
<Label x:Name="label_mhiv" Content="IV-HP" HorizontalAlignment="Left" Margin="55,128,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.564,2.072" />
<Label x:Name="label_mdiv" Content="IV-Atk" HorizontalAlignment="Left" Margin="8,154,0,0"
<Label x:Name="label_mdiv" Content="IV-Atk" HorizontalAlignment="Left" Margin="52,154,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.564,2.072" />
<Label x:Name="label_maiv" Content="IV-Def" HorizontalAlignment="Left" Margin="7,182,0,0"
<Label x:Name="label_maiv" Content="IV-Def" HorizontalAlignment="Left" Margin="50,183,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.564,2.072" />
<Label x:Name="label_mhpu" Content="PowerUp-HP" HorizontalAlignment="Left" Margin="157,123,0,0"
<Label x:Name="label_mhpu" Content="PowerUp-HP" HorizontalAlignment="Left" Margin="191,126,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.564,2.072" />
<Label x:Name="label_mapu" Content="PowerUp-Atk" HorizontalAlignment="Left" Margin="154,151,0,0"
<Label x:Name="label_mapu" Content="PowerUp-Atk" HorizontalAlignment="Left" Margin="188,153,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.564,2.072" />
<Label x:Name="label_mdpu" Content="PowerUp-Def" HorizontalAlignment="Left" Margin="154,179,0,0"
<Label x:Name="label_mdpu" Content="PowerUp-Def" HorizontalAlignment="Left" Margin="186,180,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.564,2.072" />
<TextBox x:Name="textbox_mhp" HorizontalAlignment="Left" Height="23" Margin="56,39,0,0"
<TextBox x:Name="textbox_mhp" HorizontalAlignment="Left" Height="23" Margin="99,39,0,0"
TextWrapping="Wrap" Text="{Binding monster.hp}" VerticalAlignment="Top"
Width="75" />
<TextBox x:Name="textbox_mat" HorizontalAlignment="Left" Height="23" Margin="56,69,0,0"
<TextBox x:Name="textbox_mat" HorizontalAlignment="Left" Height="23" Margin="99,69,0,0"
TextWrapping="Wrap" Text="{Binding monster.atk}" VerticalAlignment="Top"
Width="75" />
<TextBox x:Name="textbox_mdf" HorizontalAlignment="Left" Height="23" Margin="56,97,0,0"
<TextBox x:Name="textbox_mdf" HorizontalAlignment="Left" Height="23" Margin="99,98,0,0"
TextWrapping="Wrap" Text="{Binding monster.def}" VerticalAlignment="Top"
Width="75" />
<TextBox x:Name="textbox_mhiv" HorizontalAlignment="Left" Height="23" Margin="56,126,0,0"
<TextBox x:Name="textbox_mhiv" HorizontalAlignment="Left" Height="23" Margin="99,126,0,0"
TextWrapping="Wrap" Text="{Binding monster.hiv}" VerticalAlignment="Top"
Width="75" />
<TextBox x:Name="textbox_maiv" HorizontalAlignment="Left" Height="23" Margin="56,154,0,0"
<TextBox x:Name="textbox_maiv" HorizontalAlignment="Left" Height="23" Margin="99,154,0,0"
TextWrapping="Wrap" Text="{Binding monster.aiv}" VerticalAlignment="Top"
Width="75" />
<TextBox x:Name="textbox_mdiv" HorizontalAlignment="Left" Height="23" Margin="56,182,0,0"
Width="75" RenderTransformOrigin="1.222,0.547" />
<TextBox x:Name="textbox_mdiv" HorizontalAlignment="Left" Height="23" Margin="99,183,0,0"
TextWrapping="Wrap" Text="{Binding monster.div}" VerticalAlignment="Top"
Width="75" />
<TextBox x:Name="textbox_mhpu" HorizontalAlignment="Left" Height="23" Margin="240,126,0,0"
<TextBox x:Name="textbox_mhpu" HorizontalAlignment="Left" Height="23" Margin="273,126,0,0"
TextWrapping="Wrap" Text="{Binding monster.hpu}" VerticalAlignment="Top"
Width="75" />
<TextBox x:Name="textbox_mapu" HorizontalAlignment="Left" Height="23" Margin="240,154,0,0"
<TextBox x:Name="textbox_mapu" HorizontalAlignment="Left" Height="23" Margin="273,154,0,0"
TextWrapping="Wrap" Text="{Binding monster.apu}" VerticalAlignment="Top"
Width="75" />
<TextBox x:Name="textbox_mdpu" HorizontalAlignment="Left" Height="23" Margin="240,182,0,0"
<TextBox x:Name="textbox_mdpu" HorizontalAlignment="Left" Height="23" Margin="273,182,0,0"
TextWrapping="Wrap" Text="{Binding monster.dpu}" VerticalAlignment="Top"
Width="75" />
<Label x:Name="label_mlv" Content="Level" HorizontalAlignment="Left" Margin="198,36,0,0"
<Label x:Name="label_mlv" Content="Level" HorizontalAlignment="Left" Margin="228,37,0,0"
VerticalAlignment="Top" RenderTransformOrigin="-0.263,0.135" />
<Label x:Name="label_mex" Content="Exp" HorizontalAlignment="Left" Margin="172,69,0,0"
<Label x:Name="label_mex" Content="Exp" HorizontalAlignment="Left" Margin="200,68,0,0"
VerticalAlignment="Top" RenderTransformOrigin="-0.263,0.135" />
<Label x:Name="label_spe" Content="Species (Hex)" Margin="156,97,94,0"
<Label x:Name="label_spe" Content="Species (Hex)" Margin="188,97,82.5,0"
VerticalAlignment="Top" RenderTransformOrigin="-0.263,0.135" />
<TextBox x:Name="textbox_mlv" HorizontalAlignment="Left" Height="24" Margin="240,38,0,0"
<TextBox x:Name="textbox_mlv" HorizontalAlignment="Left" Height="24" Margin="272,38,0,0"
TextWrapping="Wrap" Text="{Binding monster.level}" VerticalAlignment="Top"
Width="75" />
<TextBox x:Name="textbox_mex" HorizontalAlignment="Left" Height="24" Margin="240,68,0,0"
<TextBox x:Name="textbox_mex" HorizontalAlignment="Left" Height="24" Margin="273,67,0,0"
TextWrapping="Wrap" Text="{Binding monster.exp}" VerticalAlignment="Top"
Width="75" />
<TextBox x:Name="textbox_spe" HorizontalAlignment="Left" Height="24" Margin="240,97,0,0"
Width="75" RenderTransformOrigin="1.06,0.436" />
<TextBox x:Name="textbox_spe" HorizontalAlignment="Left" Height="24" Margin="273,97,0,0"
TextWrapping="Wrap" Text="{Binding monster.spe, StringFormat=\{0:X2\}}" VerticalAlignment="Top"
Width="75"/>
Width="74"/>
<Label x:Name="label_mname" Content="Name" HorizontalAlignment="Left" Margin="10,10,0,0"
VerticalAlignment="Top" />
<TextBox x:Name="textbox_mname" HorizontalAlignment="Left" Height="22" Margin="56,12,0,0"
TextWrapping="Wrap" Text="{Binding monster.name}" VerticalAlignment="Top"
Width="118" />
<Button x:Name="button_mexp" Content="Max" HorizontalAlignment="Left" Margin="200,72,0,0"
VerticalAlignment="Top" Width="35" Click="button_mexp_Click" />
<Button x:Name="button_mdel" Content="Export" HorizontalAlignment="Left" Margin="7,251,0,0" VerticalAlignment="Top" Width="76" Click="button_mdel_Click" Height="24"/>
<Label x:Name="label_mon_skill" Content="Skill 1" HorizontalAlignment="Left" Margin="10,211,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="textbox_mon_skill" HorizontalAlignment="Left" Height="24" Margin="56,211,0,0"
<Button x:Name="button_mexp" Content="Max" HorizontalAlignment="Left" Margin="229,70,0,0"
VerticalAlignment="Top" Width="35" Click="button_mexp_Click" RenderTransformOrigin="1.375,0.544" />
<Button x:Name="button_mdel" Content="Export" HorizontalAlignment="Left" Margin="10,251,0,0" VerticalAlignment="Top" Width="76" Click="button_mexport_Click" Height="24"/>
<Label x:Name="label_mon_skill" Content="Skill 1 (Hex)" HorizontalAlignment="Left" Margin="23,208,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.274,0.562"/>
<TextBox x:Name="textbox_mon_skill" HorizontalAlignment="Left" Height="24" Margin="99,210,0,0"
TextWrapping="Wrap" Text="{Binding monster.skill1}" VerticalAlignment="Top"
Width="75" />
<Button x:Name="button_mdel_import" Content="Import" HorizontalAlignment="Left" Margin="88,251,0,0" VerticalAlignment="Top" Width="76" Click="button_mimport_Click" RenderTransformOrigin="0.167,-0.328" Height="24"/>
<Button x:Name="button_mdel_delete" Content="Delete" HorizontalAlignment="Left" Margin="169,251,0,0" VerticalAlignment="Top" Width="76" Click="button_mdelete_Click" Height="24" RenderTransformOrigin="-0.095,0.426"/>
<Button x:Name="button_mdel_genes" Content="Edit Genes" HorizontalAlignment="Left" Margin="250,251,0,0" VerticalAlignment="Top" Width="75" Click="button_mdel_genes_Click" Height="24" RenderTransformOrigin="0.415,0.563"/>
<Label x:Name="label_mon_uid" Content="UID (Hex)" HorizontalAlignment="Left" Margin="176,10,0,0"
<Button x:Name="button_mdel_import" Content="Import" HorizontalAlignment="Left" Margin="98,251,0,0" VerticalAlignment="Top" Width="76" Click="button_mimport_Click" RenderTransformOrigin="0.167,-0.328" Height="24"/>
<Button x:Name="button_mdel_delete" Content="Delete" HorizontalAlignment="Left" Margin="186,251,0,0" VerticalAlignment="Top" Width="76" Click="button_mdelete_Click" Height="24" RenderTransformOrigin="-0.095,0.426"/>
<Button x:Name="button_mdel_genes" Content="Edit Genes" HorizontalAlignment="Left" Margin="274,251,0,0" VerticalAlignment="Top" Width="74" Click="button_mdel_genes_Click" Height="24" RenderTransformOrigin="0.415,0.563"/>
<Label x:Name="label_mon_uid" Content="UID (Hex)" HorizontalAlignment="Left" Margin="204,10,0,0"
VerticalAlignment="Top" RenderTransformOrigin="0.564,2.072" />
<TextBox HorizontalAlignment="Left" Height="23" Margin="240,10,0,0" TextWrapping="Wrap" Text="{Binding monster.uid}" VerticalAlignment="Top" Width="75"/>
<Label x:Name="lab" Content="Skill 2" HorizontalAlignment="Left" Margin="195,211,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="textbox_mon_skill_Copy" HorizontalAlignment="Left" Height="24" Margin="240,211,0,0"
<TextBox HorizontalAlignment="Left" Height="23" Margin="272,10,0,0" TextWrapping="Wrap" Text="{Binding monster.uid}" VerticalAlignment="Top" Width="75"/>
<Label x:Name="lab" Content="Skill 2 (Hex)" HorizontalAlignment="Left" Margin="197,208,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="textbox_mon_skill_Copy" HorizontalAlignment="Left" Height="24" Margin="273,210,0,0"
TextWrapping="Wrap" Text="{Binding monster.skill2}" VerticalAlignment="Top"
Width="75" />
</Grid>

View File

@ -34,29 +34,73 @@ namespace MHSEC_G
byte[] buffer = File.ReadAllBytes(dialog.FileName);
if (buffer.Length != Offsets.SIZE_MONSTER)
{
buffer = convert_monster(buffer);
if (buffer.Length != Offsets.SIZE_MONSTER)
{
// failed again
System.Windows.Forms.MessageBox.Show(
"Wrong monster file size!",
"MHSEC-G",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
System.Windows.Forms.MessageBox.Show(
"Wrong monster file size!",
"Error",
"Detected " + (Offsets.VER == Offsets.Version.JPN ? "USA" : "JPN") + " monster export format. Automatically converted.",
"MHSEC-G",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
_monster.setByteArray(buffer);
MessageBoxIcon.Information);
}
_monster.setByteArray(buffer);
}
}
private void button_mdelete_Click(object sender, RoutedEventArgs e)
private static byte[] convert_monster(byte[] save)
{
MessageBoxResult confirm = MessageBox.Show("Are you sure you want to delete the monster?", "MHSEC-G", MessageBoxButton.YesNo);
if (confirm == MessageBoxResult.Yes)
byte[] ret = null;
if (Offsets.VER == Offsets.Version.JPN)
{
_monster.setByteArray(Offsets.MONSTER_NULL_TEMPLATE);
uint other_offset_uid = Offsets.OFFSETR_MONSTER_UID + 0x28;
// USA -> JPN
if (save.Length < other_offset_uid)
{
return ret;
}
ret = new byte[save.Length - 0x28];
// copy everything till my UID
Array.Copy(save, 0, ret, 0, Offsets.OFFSETR_MONSTER_UID);
// copy everything after it
Array.Copy(save, other_offset_uid, ret, Offsets.OFFSETR_MONSTER_UID,
save.Length - other_offset_uid);
}
else
{
uint other_offset_uid = Offsets.OFFSETR_MONSTER_UID - 0x28;
// JPN -> USA
if (save.Length < other_offset_uid)
{
return ret;
}
ret = new byte[save.Length + 0x28];
// copy everything till other uid
Array.Copy(save, 0, ret, 0, other_offset_uid);
// fill 0s
Array.Clear(ret, (int) (other_offset_uid), 0x28);
// copy everything else
Array.Copy(save, other_offset_uid, ret, Offsets.OFFSETR_MONSTER_UID,
save.Length - other_offset_uid);
}
return ret;
}
private void button_mdel_Click(object sender, RoutedEventArgs e)
private void button_mexport_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "Binary files (*.bin)|*.bin|All files (*.*)|*.*";
@ -71,6 +115,16 @@ namespace MHSEC_G
}
}
private void button_mdelete_Click(object sender, RoutedEventArgs e)
{
MessageBoxResult confirm = MessageBox.Show("Are you sure you want to delete the monster?", "MHSEC-G",
MessageBoxButton.YesNo);
if (confirm == MessageBoxResult.Yes)
{
_monster.setByteArray(Offsets.MONSTER_NULL_TEMPLATE);
}
}
private void button_mexp_Click(object sender, RoutedEventArgs e)
{
_monster.exp = Offsets.LIMIT_MONSTER_EXP;

View File

@ -9,6 +9,18 @@ namespace MHSEC_G
{
public static class Offsets
{
//
// Ver
//
public enum Version
{
JPN,
USA
};
private static Version _VER;
public static Version VER => _VER;
//
// Save
//
@ -26,6 +38,10 @@ namespace MHSEC_G
//
// Armors
//
private static uint _OFFSETR_ARM_EQUIPPED;
public static uint OFFSETR_ARM_EQUIPPED => _OFFSETR_ARM_EQUIPPED;
private static uint _OFFSETA_ARM;
public static uint OFFSETA_ARM => _OFFSETA_ARM;
@ -283,8 +299,8 @@ namespace MHSEC_G
private static uint _OFFSETR_TALI_ID;
public static uint OFFSETR_TALI_ID => _OFFSETR_TALI_ID;
private static uint _OFFSETR_EQUIPPED;
public static uint OFFSETR_EQUIPPED => _OFFSETR_EQUIPPED;
private static uint _OFFSETR_TALI_EQUIPPED;
public static uint OFFSETR_TALI_EQUIPPED => _OFFSETR_TALI_EQUIPPED;
//
@ -293,6 +309,9 @@ namespace MHSEC_G
private static uint _OFFSETA_WEAPON_START;
public static uint OFFSETA_WEAPON_START => _OFFSETA_WEAPON_START;
private static uint _OFFSETR_WEAPON_EQUIPPED;
public static uint OFFSETR_WEAPON_EQUIPPED => _OFFSETR_WEAPON_EQUIPPED;
private static uint _OFFSETA_WEAPON_END;
public static uint OFFSETA_WEAPON_END => _OFFSETA_WEAPON_END;
@ -313,6 +332,8 @@ namespace MHSEC_G
{
if (save.Length == SAVE_FILE_SIZE_JPN)
{
_VER = Version.JPN;
//
//Armors
//
@ -325,6 +346,7 @@ namespace MHSEC_G
_OFFSETR_ARM_1C = 0x1c;
_OFFSETA_ARM_END = 0x720E;
_OFFSETR_ARM_TYPE = 0x0;
_OFFSETR_ARM_EQUIPPED = 0x11;
//
//Character
@ -415,13 +437,14 @@ namespace MHSEC_G
_OFFSETR_TALI_SKILL1 = 0x28;
_OFFSETR_TALI_SKILL2 = 0x2A;
_OFFSETR_TALI_ID = 0x2;
_OFFSETR_EQUIPPED = 0x11;
_OFFSETR_TALI_EQUIPPED = 0x11;
//
//Weapons
//
_OFFSETA_WEAPON_START = 0x39D0;
_OFFSETA_WEAPON_END = 0x55EF;
_OFFSETR_WEAPON_EQUIPPED = 0x11;
_SIZE_WEAPON = 0x24;
_OFFSETR_CLASS = 0x0;
_OFFSETR_ID = 0x2;
@ -432,6 +455,7 @@ namespace MHSEC_G
}
else
{
_VER = Version.USA;
//
// Armors ok
//
@ -444,6 +468,7 @@ namespace MHSEC_G
_OFFSETR_ARM_1C = 0x1c;
_OFFSETA_ARM_END = 0x72B3;
_OFFSETR_ARM_TYPE = 0x0;
_OFFSETR_ARM_EQUIPPED = 0x11;
//
// Character ok
@ -535,13 +560,14 @@ namespace MHSEC_G
_OFFSETR_TALI_SKILL1 = 0x28;
_OFFSETR_TALI_SKILL2 = 0x2A;
_OFFSETR_TALI_ID = 0x2;
_OFFSETR_EQUIPPED = 0x11;
_OFFSETR_TALI_EQUIPPED = 0x11;
//
// Weapons ok
//
_OFFSETA_WEAPON_START = 0x3A74;
_OFFSETA_WEAPON_END = 0x5693;
_OFFSETR_WEAPON_EQUIPPED = 0x11;
_SIZE_WEAPON = 0x24;
_OFFSETR_CLASS = 0x0;
_OFFSETR_ID = 0x2;

View File

@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.2.1.0")]
[assembly: AssemblyFileVersion("1.2.1.0")]

View File

@ -106,13 +106,13 @@ namespace MHSEC_G
public string equipped
{
get { return Helper.byte_to_uint(_data[_obj_offset + Offsets.OFFSETR_EQUIPPED]).ToString("X2"); }
get { return Helper.byte_to_uint(_data[_obj_offset + Offsets.OFFSETR_TALI_EQUIPPED]).ToString("X2"); }
set
{
uint parsed;
if (Helper.parse_hex_string(value, out parsed) && parsed <= 0xFF)
{
Helper.write_byte(_data, _obj_offset + Offsets.OFFSETR_EQUIPPED, parsed);
Helper.write_byte(_data, _obj_offset + Offsets.OFFSETR_TALI_EQUIPPED, parsed);
}
else
{

View File

@ -35,6 +35,24 @@ namespace MHSEC_G
}
}
public string equipped
{
get { return Helper.byte_to_uint(_data[_obj_offset + Offsets.OFFSETR_WEAPON_EQUIPPED]).ToString("X2"); }
set
{
uint parsed;
if (Helper.parse_hex_string(value, out parsed) && parsed <= 0xFF)
{
Helper.write_byte(_data, _obj_offset + Offsets.OFFSETR_WEAPON_EQUIPPED, parsed);
}
else
{
MessageBox.Show("Malformed Equipped value - must be at most 0xFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
OnPropertyChanged(nameof(equipped));
}
}
public string id
{
set