Ver 0.1 Release!

This commit is contained in:
secXsQuared1995 2016-10-19 07:55:23 -04:00
parent f0cecf442d
commit 5b9188506f
9 changed files with 323 additions and 19 deletions

View File

@ -10,13 +10,19 @@ EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|Any CPU.Build.0 = Debug|Any CPU {80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|x86.ActiveCfg = Debug|x86
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|x86.Build.0 = Debug|x86
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|Any CPU.ActiveCfg = Release|Any CPU {80372081-2D34-424B-93E2-89D5815BF3E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|Any CPU.Build.0 = Release|Any CPU {80372081-2D34-424B-93E2-89D5815BF3E8}.Release|Any CPU.Build.0 = Release|Any CPU
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|x86.ActiveCfg = Release|x86
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|x86.Build.0 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -7,7 +7,7 @@ namespace MHSEC_G
public class Character : INotifyPropertyChanged public class Character : INotifyPropertyChanged
{ {
private const uint OFFSETA_CHAR_NAME = 0x9DA0; private const uint OFFSETA_CHAR_NAME = 0x9DA0;
private const uint LENGTH_CHAR_NAME = 5; private const uint LENGTH_CHAR_NAME = 4;
private const uint OFFSETA_CHAR_MONEY = 0x5B404; private const uint OFFSETA_CHAR_MONEY = 0x5B404;
private const uint OFFSETA_CHAR_EXP = 0x9E68; private const uint OFFSETA_CHAR_EXP = 0x9E68;
private const uint OFFSETA_CHAR_LEVEL = 0x9E64; private const uint OFFSETA_CHAR_LEVEL = 0x9E64;
@ -70,16 +70,16 @@ namespace MHSEC_G
public string name public string name
{ {
get { return Model.read_unicode_string(_model.save_file, OFFSETA_CHAR_NAME, LENGTH_CHAR_NAME); } get { return Model.read_unicode_string(_model.save_file, OFFSETA_CHAR_NAME, 65536); }
set set
{ {
if (value.Length <= LENGTH_CHAR_NAME && value.Length > 0) if (value.Length <= LENGTH_CHAR_NAME && value.Length > 0)
{ {
Model.write_unicode_string(_model.save_file, OFFSETA_CHAR_NAME, value, LENGTH_CHAR_NAME); Model.write_unicode_string(_model.save_file, OFFSETA_CHAR_NAME, value, LENGTH_CHAR_NAME + 1);
} }
else else
{ {
MessageBox.Show("Name must be 1-6 characters.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show("Name must be 1-" + LENGTH_CHAR_NAME + " characters.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
} }
OnPropertyChanged(nameof(name)); OnPropertyChanged(nameof(name));
} }

View File

@ -1,11 +1,233 @@
using System; using System.Collections.ObjectModel;
using System.Collections.Generic; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Windows;
using MHSEC_G.Annotations;
namespace MHSEC_G namespace MHSEC_G
{ {
class EggFragment public class EggFragment : INotifyPropertyChanged
{ {
private const uint OFFSETA_EGG_FRAGMENTS = 0x9790;
private const uint OFFSETA_EGG_FRAGMENTS_END = 0x9C3F;
private const uint SIZE_EGG_FRAGMENT = 0xC;
private const uint OFFSETR_EF_SPE = 0x0;
private const uint OFFSETR_EF_POS = 0x1;
private const uint OFFSETR_EF_NEW = 0x2;
private const uint OFFSETR_EF_RAR = 0x3;
private const uint OFFSETR_EF_COL = 0x4;
private const uint OFFSETR_EF_DLC = 0x5;
private const uint OFFSETR_EF_6H = 0x6;
private const uint OFFSETR_EF_7H = 0x7;
private readonly uint _offset;
public uint offset
{
get { return _offset;}
}
private readonly Model _model;
public EggFragment(uint offset, Model model)
{
_model = model;
_offset = offset;
}
public string spe
{
get { return Model.byte_to_uint(_model.save_file[_offset + OFFSETR_EF_SPE]).ToString("X2"); }
set
{
uint parsed;
if (Model.parse_hex_string(value, out parsed) && parsed <= 0x0C)
{
Model.write_byte(_model.save_file, _offset + OFFSETR_EF_SPE, parsed);
}
else
{
MessageBox.Show("Malformed Species value - must be at most 0xC", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
OnPropertyChanged(nameof(spe));
}
}
public string pos
{
get { return Model.byte_to_uint(_model.save_file[_offset + OFFSETR_EF_POS]).ToString("X2"); }
set
{
uint parsed;
if (Model.parse_hex_string(value, out parsed) && parsed <= 0x08)
{
Model.write_byte(_model.save_file, _offset + OFFSETR_EF_POS, parsed);
}
else
{
MessageBox.Show("Malformed Position value - must be at most 0x8", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
OnPropertyChanged(nameof(pos));
}
}
public string new_flag
{
get { return Model.byte_to_uint(_model.save_file[_offset + OFFSETR_EF_NEW]).ToString("X2"); }
set
{
uint parsed;
if (Model.parse_hex_string(value, out parsed) && parsed <= 0x01)
{
Model.write_byte(_model.save_file, _offset + OFFSETR_EF_NEW, parsed);
}
else
{
MessageBox.Show("Malformed New value - must be 0 or 1", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
OnPropertyChanged(nameof(new_flag));
}
}
public string rarity
{
get { return Model.byte_to_uint(_model.save_file[_offset + OFFSETR_EF_RAR]).ToString("X2"); }
set
{
uint parsed;
if (Model.parse_hex_string(value, out parsed) && parsed <= 0x01)
{
Model.write_byte(_model.save_file, _offset + OFFSETR_EF_RAR, parsed);
}
else
{
MessageBox.Show("Malformed Rarity value - must be 0 or 1", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
OnPropertyChanged(nameof(rarity));
}
}
public string color
{
get { return Model.byte_to_uint(_model.save_file[_offset + OFFSETR_EF_COL]).ToString("X2"); }
set
{
uint parsed;
if (Model.parse_hex_string(value, out parsed) && parsed <= 0xFF)
{
Model.write_byte(_model.save_file, _offset + OFFSETR_EF_COL, parsed);
}
else
{
MessageBox.Show("Malformed Species value - must be at most 0xFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
OnPropertyChanged(nameof(color));
}
}
public string dlc
{
get { return Model.byte_to_uint(_model.save_file[_offset + OFFSETR_EF_DLC]).ToString("X2"); }
set
{
uint parsed;
if (Model.parse_hex_string(value, out parsed) && parsed <= 0xFF)
{
Model.write_byte(_model.save_file, _offset + OFFSETR_EF_DLC, parsed);
}
else
{
MessageBox.Show("Malformed DLC value - must be at most 0xFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
OnPropertyChanged(nameof(dlc));
}
}
public string unknown_6h
{
get { return Model.byte_to_uint(_model.save_file[_offset + OFFSETR_EF_6H]).ToString("X2"); }
set
{
uint parsed;
if (Model.parse_hex_string(value, out parsed) && parsed <= 0xFF)
{
Model.write_byte(_model.save_file, _offset + OFFSETR_EF_6H, parsed);
}
else
{
MessageBox.Show("Malformed Species value - must be at most 0xFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
OnPropertyChanged(nameof(unknown_6h));
}
}
public string unknown_7h
{
get { return Model.byte_to_uint(_model.save_file[_offset + OFFSETR_EF_7H]).ToString("X2"); }
set
{
uint parsed;
if (Model.parse_hex_string(value, out parsed) && parsed <= 0xFF)
{
Model.write_byte(_model.save_file, _offset + OFFSETR_EF_7H, parsed);
}
else
{
MessageBox.Show("Malformed 7h value - must be at most 0xFF", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
OnPropertyChanged(nameof(unknown_7h));
}
}
public static ObservableCollection<EggFragment> read_all_egg_fragments(Model model)
{
ObservableCollection<EggFragment> ret = new ObservableCollection<EggFragment>();
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;
}
private static EggFragment egg_frag_offset_exist(ObservableCollection<EggFragment> fragments, uint offset)
{
for (uint i = 0; i < fragments.Count; i++)
{
if(fragments.ElementAt((int)i).offset == offset)
return fragments.ElementAt((int)i);
}
return null;
}
public static void write_dlc_egg_fragment(ObservableCollection<EggFragment> fragments, Model model, uint dlc)
{
for (uint offset = OFFSETA_EGG_FRAGMENTS; offset < OFFSETA_EGG_FRAGMENTS + 9*SIZE_EGG_FRAGMENT ; offset += SIZE_EGG_FRAGMENT)
{
EggFragment each_frag = egg_frag_offset_exist(fragments, offset);
if (each_frag == null)
{
each_frag = new EggFragment(offset, model);
fragments.Insert((int)((offset - OFFSETA_EGG_FRAGMENTS) / SIZE_EGG_FRAGMENT), each_frag);
}
each_frag.new_flag = "0";
each_frag.spe = "08";
each_frag.pos = ((offset-OFFSETA_EGG_FRAGMENTS) / SIZE_EGG_FRAGMENT).ToString();
each_frag.rarity = "0";
each_frag.color = "0";
each_frag.dlc = dlc.ToString("X2");
each_frag.unknown_6h = "0";
each_frag.unknown_7h = "0";
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

View File

@ -15,7 +15,7 @@ namespace MHSEC_G
private static readonly uint OFFSETR_ITEM_COUNT = 0x2; private static readonly uint OFFSETR_ITEM_COUNT = 0x2;
private static readonly uint OFFSETA_ITEM_BOX_END = 0x2EE7; private static readonly uint OFFSETA_ITEM_BOX_END = 0x2EE7;
private static readonly string ID_MAPPING_FILE_NAME = "C:\\Users\\hyper\\Desktop\\idmap.txt"; private static readonly string ID_MAPPING_FILE_NAME = "idmap.txt";
private static readonly Dictionary<uint, uint> OFFSET_ID_MAPPING = new Dictionary<uint, uint>(); private static readonly Dictionary<uint, uint> OFFSET_ID_MAPPING = new Dictionary<uint, uint>();
private static readonly Dictionary<uint, string> OFFSET_NAME_MAPPING = new Dictionary<uint, string>(); private static readonly Dictionary<uint, string> OFFSET_NAME_MAPPING = new Dictionary<uint, string>();

View File

@ -33,6 +33,24 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />

View File

@ -25,7 +25,35 @@
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="Egg Fragments"> <TabItem Header="Egg Fragments">
<Grid Background="#FFE5E5E5"/> <Grid Background="#FFE5E5E5">
<DataGrid x:Name="egg_frag_grid" HorizontalAlignment="Left" Margin="10,35,0,0" VerticalAlignment="Top" Height="271" Width="556" CanUserAddRows="False" AutoGenerateColumns="False" ItemsSource="{Binding Path=egg_fragments}">
<DataGrid.Columns>
<DataGridTextColumn CanUserReorder ="False" CanUserResize="False" CanUserSort="False" Width ="60" Binding="{Binding spe}"
Header="Species" />
<DataGridTextColumn CanUserReorder ="False" CanUserResize="False" CanUserSort="False" Width ="60" Binding="{Binding pos}"
Header="Position" />
<DataGridTextColumn CanUserReorder ="False" CanUserResize="False" CanUserSort="False" Width ="60" Binding="{Binding new_flag}"
Header="New?" />
<DataGridTextColumn CanUserReorder ="False" CanUserResize="False" CanUserSort="False" Width ="60" Binding="{Binding rarity}"
Header="Rarity" />
<DataGridTextColumn CanUserReorder ="False" CanUserResize="False" CanUserSort="False" Width ="60" Binding="{Binding color}"
Header="Color" />
<DataGridTextColumn CanUserReorder ="False" CanUserResize="False" CanUserSort="False" Width ="60" Binding="{Binding dlc}"
Header="DLC" />
<DataGridTextColumn CanUserReorder ="False" CanUserResize="False" CanUserSort="False" Width ="60" Binding="{Binding unknown_7h}"
Header="0x6" />
<DataGridTextColumn CanUserReorder ="False" CanUserResize="False" CanUserSort="False" Width ="*" Binding="{Binding unknown_6h}"
Header="0x7" />
</DataGrid.Columns>
</DataGrid>
<Button x:Name="button_give_dino" Content="Give Dinovaldo" HorizontalAlignment="Left" Margin="584,195,0,0" VerticalAlignment="Top" Width="110" Height="30" Click="button_give_dino_Click"/>
<Button x:Name="button_give_epony" Content="Give Epony" HorizontalAlignment="Left" Margin="584,35,0,0" VerticalAlignment="Top" Width="110" Height="30" Click="button_give_epony_Click"/>
<Button x:Name="button_give_bear" Content="Give Mascot" HorizontalAlignment="Left" Margin="584,75,0,0" VerticalAlignment="Top" Width="110" Height="30" Click="button_give_bear_Click"/>
<Button x:Name="button_give_mtiggy" IsEnabled="False" Content="Give Molten Tigrex" HorizontalAlignment="Left" Margin="584,115,0,0" VerticalAlignment="Top" Width="110" Height="30" Click="button_give_mtiggy_Click"/>
<Button x:Name="button_give_okirin" IsEnabled="False" Content="Give Oroshi Kirin" HorizontalAlignment="Left" Margin="584,155,0,0" VerticalAlignment="Top" Width="110" Height="30" Click="button_give_okirin_Click"/>
<TextBlock x:Name="textblock_egg_frag" HorizontalAlignment="Left" Margin="575,241,0,0" TextWrapping="Wrap" Text="Note: You can only give yourself one DLC monster at a time." VerticalAlignment="Top" RenderTransformOrigin="-0.182,-0.531" Width="125"/>
<TextBlock x:Name="textblock_egg_frag_n" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="If interested, try giving yourself DLC eggs and modify each shard's DLC byte to 0x4 and up. You can get other DLC monsters!" VerticalAlignment="Top"/>
</Grid>
</TabItem> </TabItem>
<TabItem Header="Items"> <TabItem Header="Items">
<Grid Background="#FFE5E5E5" Margin="0,0,0,0"> <Grid Background="#FFE5E5E5" Margin="0,0,0,0">
@ -101,5 +129,6 @@
<Button x:Name="button_save" Content="Save" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="74" Click="button_save_Click"/> <Button x:Name="button_save" Content="Save" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="74" Click="button_save_Click"/>
<Button x:Name="button_load" Content="Load" HorizontalAlignment="Left" Margin="90,10,0,0" VerticalAlignment="Top" Width="74" Click="button_load_click"/> <Button x:Name="button_load" Content="Load" HorizontalAlignment="Left" Margin="90,10,0,0" VerticalAlignment="Top" Width="74" Click="button_load_click"/>
<DataGrid x:Name="dataGrid" HorizontalAlignment="Left" Height="100" Margin="1046,415,-390,-95.5" VerticalAlignment="Top" Width="100"/> <DataGrid x:Name="dataGrid" HorizontalAlignment="Left" Height="100" Margin="1046,415,-390,-95.5" VerticalAlignment="Top" Width="100"/>
<Label x:Name="label_copy" Content="By secXsQuared" HorizontalAlignment="Left" Margin="642,7,0,0" VerticalAlignment="Top"/>
</Grid> </Grid>
</Window> </Window>

View File

@ -16,6 +16,7 @@ namespace MHSEC_G
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
button_save.IsEnabled = false;
Item.read_item_mappings(); Item.read_item_mappings();
Array.Clear(dummy_data, 0, dummy_data.Length); Array.Clear(dummy_data, 0, dummy_data.Length);
this.Title = "MHSEC-G Ver" + Version; this.Title = "MHSEC-G Ver" + Version;
@ -43,6 +44,7 @@ namespace MHSEC_G
{ {
view_model = new ViewModel(buffer); view_model = new ViewModel(buffer);
DataContext = view_model; DataContext = view_model;
button_save.IsEnabled = true;
} }
} }
} }
@ -91,8 +93,33 @@ namespace MHSEC_G
private void button_save_Click(object sender, RoutedEventArgs e) private void button_save_Click(object sender, RoutedEventArgs e)
{ {
File.WriteAllBytes("C:\\Users\\hyper\\Desktop\\mhr_save0.hacked", view_model.model.save_file); File.WriteAllBytes("mhr_game0.hacked", view_model.model.save_file);
MessageBox.Show("Saved to \"mhr_save0.hacked\"","MHSEC-G",MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show("Saved to \"mhr_game0.hacked\"", "MHSEC-G",MessageBoxButton.OK, MessageBoxImage.Information);
}
private void button_give_epony_Click(object sender, RoutedEventArgs e)
{
EggFragment.write_dlc_egg_fragment(view_model.egg_fragments, view_model.model, 0x4);
}
private void button_give_bear_Click(object sender, RoutedEventArgs e)
{
EggFragment.write_dlc_egg_fragment(view_model.egg_fragments, view_model.model, 0x5);
}
private void button_give_mtiggy_Click(object sender, RoutedEventArgs e)
{
EggFragment.write_dlc_egg_fragment(view_model.egg_fragments, view_model.model, 0x10);
}
private void button_give_okirin_Click(object sender, RoutedEventArgs e)
{
EggFragment.write_dlc_egg_fragment(view_model.egg_fragments, view_model.model, 0x32);
}
private void button_give_dino_Click(object sender, RoutedEventArgs e)
{
EggFragment.write_dlc_egg_fragment(view_model.egg_fragments, view_model.model, 0x6);
} }
} }
} }

View File

@ -205,12 +205,12 @@ namespace MHSEC_G
public string name public string name
{ {
get { return Model.read_unicode_string(_model.save_file, _offset + OFFSETR_MONSTER_NAME, LIMIT_MONSTER_NAME); } get { return Model.read_unicode_string(_model.save_file, _offset + OFFSETR_MONSTER_NAME, 65536); }
set set
{ {
if (value.Length <= 10 && value.Length > 0) if (value.Length <= 10 && value.Length > 0)
{ {
Model.write_unicode_string(_model.save_file, _offset + OFFSETR_MONSTER_NAME, value, 10); Model.write_unicode_string(_model.save_file, _offset + OFFSETR_MONSTER_NAME, value, 11);
} }
else else
{ {

View File

@ -48,8 +48,12 @@ namespace MHSEC_G
get { return _items; } get { return _items; }
} }
private uint cur_egg_fragment_selection; private readonly ObservableCollection<EggFragment> _egg_fragments;
private readonly List<EggFragment> egg_fragments;
public ObservableCollection<EggFragment> egg_fragments
{
get { return _egg_fragments; }
}
public ViewModel(byte[] save) public ViewModel(byte[] save)
{ {
@ -63,9 +67,7 @@ namespace MHSEC_G
_items = Item.read_all_items(_model); _items = Item.read_all_items(_model);
_monsters = new ObservableCollection<Monster>(Monster.read_all_monsters(_model)); _monsters = new ObservableCollection<Monster>(Monster.read_all_monsters(_model));
_cur_monster_selection = _monsters.ElementAt(0); _cur_monster_selection = _monsters.ElementAt(0);
_egg_fragments = EggFragment.read_all_egg_fragments(_model);
cur_egg_fragment_selection = 0;
egg_fragments = null;
} }
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;