Skip to content

Commit

Permalink
add edit param
Browse files Browse the repository at this point in the history
  • Loading branch information
turtle-insect committed Jul 6, 2021
1 parent 0af5357 commit 5b4e8ac
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 1 deletion.
39 changes: 39 additions & 0 deletions MonsterHunterStories2/Character.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;

namespace MonsterHunterStories2
{
class Character : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

private readonly uint mAddress;

public Character(uint address)
{
mAddress = address;
}

public String Name
{
get { return SaveData.Instance().ReadText(mAddress, 18); }
set
{
SaveData.Instance().WriteText(mAddress, 18, value);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Name)));
}
}

public uint Lv
{
get { return SaveData.Instance().ReadNumber(mAddress + 234, 1); }
set { Util.WriteNumber(mAddress + 234, 1, value, 1, 0xFF); }
}


}
}
72 changes: 71 additions & 1 deletion MonsterHunterStories2/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,76 @@
<TextBox Grid.Column="1" Text="{Binding Money, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</TabItem>
<TabItem Header="Character">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ListBox x:Name="ListBoxCharacter" ItemsSource="{Binding Characters}" DisplayMemberPath="Name"/>
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="11*"/>
</Grid.RowDefinitions>
<Label Content="Lv"/>
<TextBox Grid.Column="1" Text="{Binding ElementName=ListBoxCharacter, Path=SelectedItem.Lv, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="1" Content="Name"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding ElementName=ListBoxCharacter, Path=SelectedItem.Name, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</Grid>
</TabItem>
<TabItem Header="Monster">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ListBox x:Name="ListBoxMonster" ItemsSource="{Binding Monsters}" DisplayMemberPath="Name"/>
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<Label Content="Type"/>
<TextBox Grid.Column="1" Text="{Binding ElementName=ListBoxMonster, Path=SelectedItem.ID, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="1" Content="Lv"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding ElementName=ListBoxMonster, Path=SelectedItem.Lv, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="2" Content="Name"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding ElementName=ListBoxMonster, Path=SelectedItem.Name, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</Grid>
</TabItem>
<TabItem Header="Weapon">
<DockPanel>
<ListBox x:Name="ListBoxWeapon" ItemsSource="{Binding Weapons}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="Lv:"/>
<TextBox Text="{Binding Lv, UpdateSourceTrigger=PropertyChanged}" Width="60"/>
<Label Content=" ID:"/>
<TextBox Text="{Binding ID, UpdateSourceTrigger=PropertyChanged}" Width="60"/>
<Label Content=" ID=32767 is None" Foreground="Gray"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</TabItem>
<TabItem Header="Item">
<DockPanel>
<Button DockPanel.Dock="Bottom" Content="Append/Search Item" Click="ButtonItemAppend_Click"/>
Expand All @@ -49,7 +119,7 @@
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="Count:"/>
<TextBox Text="{Binding Count, UpdateSourceTrigger=PropertyChanged}" Width="50"/>
<TextBox Text="{Binding Count, UpdateSourceTrigger=PropertyChanged}" Width="60"/>
<Label Content=" Name:"/>
<Label Content="{Binding ID, Converter={StaticResource ItemID2NameConverter}}"/>
</StackPanel>
Expand Down
47 changes: 47 additions & 0 deletions MonsterHunterStories2/Monster.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MonsterHunterStories2
{
class Monster : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

private readonly uint mAddress;

public Monster(uint address)
{
mAddress = address;
}

public String Name
{
get { return SaveData.Instance().ReadText(mAddress, 18); }
set
{
SaveData.Instance().WriteText(mAddress, 18, value);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Name)));
}
}

public uint ID
{
get { return SaveData.Instance().ReadNumber(mAddress + 48, 4); }
set
{
SaveData.Instance().WriteNumber(mAddress + 48, 4, value);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ID)));
}
}

public uint Lv
{
get { return SaveData.Instance().ReadNumber(mAddress + 86, 1); }
set { Util.WriteNumber(mAddress + 86, 1, value, 1, 0xFF); }
}
}
}
3 changes: 3 additions & 0 deletions MonsterHunterStories2/MonsterHunterStories2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,20 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Character.cs" />
<Compile Include="ChoiceWindow.xaml.cs">
<DependentUpon>ChoiceWindow.xaml</DependentUpon>
</Compile>
<Compile Include="ILineAnalysis.cs" />
<Compile Include="Info.cs" />
<Compile Include="Item.cs" />
<Compile Include="ItemID2NameConverter.cs" />
<Compile Include="Monster.cs" />
<Compile Include="NameValueInfo.cs" />
<Compile Include="SaveData.cs" />
<Compile Include="Util.cs" />
<Compile Include="ViewModel.cs" />
<Compile Include="Weapon.cs" />
<Page Include="ChoiceWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
12 changes: 12 additions & 0 deletions MonsterHunterStories2/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ namespace MonsterHunterStories2
{
class Util
{
public const uint CHARACTER_ADDRESS = 0x2D2A98;
public const uint CHARACTER_COUNT = 31;
public const uint CHARACTER_SIZE = 596;

public const uint MONSTER_ADDRESS = 0x2D72C8;
public const uint MONSTER_COUNT = 50;
public const uint MONSTER_SIZE = 412;

public const uint WEAPON_ADDRESS = 0x3ECC;
public const uint WEAPON_COUNT = 1099;
public const uint WEAPON_SIZE = 36;

public static void WriteNumber(uint address, uint size, uint value, uint min, uint max)
{
if (value < min) value = min;
Expand Down
28 changes: 28 additions & 0 deletions MonsterHunterStories2/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace MonsterHunterStories2
class ViewModel
{
public ObservableCollection<Item> Items { get; set; } = new ObservableCollection<Item>();
public ObservableCollection<Weapon> Weapons { get; set; } = new ObservableCollection<Weapon>();
public ObservableCollection<Character> Characters { get; set; } = new ObservableCollection<Character>();
public ObservableCollection<Monster> Monsters { get; set; } = new ObservableCollection<Monster>();
public ViewModel()
{
foreach(var itemInfo in Info.Instance().Item)
Expand All @@ -21,6 +24,31 @@ public ViewModel()

Items.Add(item);
}

for (uint i = 0; i < Util.WEAPON_COUNT; i++)
{
uint address = Util.WEAPON_ADDRESS + Util.WEAPON_SIZE * i;
Weapon weapon = new Weapon(address);
Weapons.Add(weapon);
}

for (uint i = 0; i < Util.CHARACTER_COUNT; i++)
{
uint address = Util.CHARACTER_ADDRESS + Util.CHARACTER_SIZE * i;
Character chara = new Character(address);
if (String.IsNullOrEmpty(chara.Name)) continue;

Characters.Add(chara);
}

for (uint i = 0; i < Util.MONSTER_COUNT; i++)
{
uint address = Util.MONSTER_ADDRESS + Util.MONSTER_SIZE * i;
Monster monster = new Monster(address);
if (String.IsNullOrEmpty(monster.Name)) continue;

Monsters.Add(monster);
}
}

public uint Money
Expand Down
37 changes: 37 additions & 0 deletions MonsterHunterStories2/Weapon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MonsterHunterStories2
{
class Weapon : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

private readonly uint mAddress;

public Weapon(uint address)
{
mAddress = address;
}

public uint ID
{
get { return SaveData.Instance().ReadNumber(mAddress, 4); }
set
{
SaveData.Instance().WriteNumber(mAddress, 4, value);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Type)));
}
}

public uint Lv
{
get { return SaveData.Instance().ReadNumber(mAddress + 4, 2); }
set { Util.WriteNumber(mAddress + 4, 2, value, 1, 0xFFFF); }
}
}
}

0 comments on commit 5b4e8ac

Please sign in to comment.