Skip to content

Commit

Permalink
multi char support
Browse files Browse the repository at this point in the history
  • Loading branch information
turtle-insect committed Dec 31, 2020
1 parent 94b3321 commit 9781ffe
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
1 change: 1 addition & 0 deletions DQ11/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace DQ11
class Character
{
private readonly uint mAddress;
public Bag Inventory { get; set; } = new Bag();
public String Name { get; private set; }

public Character(uint address)
Expand Down
2 changes: 1 addition & 1 deletion DQ11/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public uint Count
}
}

public uint AAA
public uint Max
{
get
{
Expand Down
25 changes: 19 additions & 6 deletions DQ11/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<TabItem Header="Character">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ListBox x:Name="ListBoxParty" ItemsSource="{Binding Party}" DisplayMemberPath="Name"/>
Expand All @@ -51,7 +51,6 @@
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="Lv"/>
<TextBox Grid.Column="1" Text="{Binding ElementName=ListBoxParty, Path=SelectedItem.Lv, UpdateSourceTrigger=PropertyChanged}"/>
Expand Down Expand Up @@ -80,34 +79,48 @@
<Label Grid.Row="12" Content="Charm"/>
<TextBox Grid.Row="12" Grid.Column="1" Text="{Binding ElementName=ListBoxParty, Path=SelectedItem.Charm, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
<ListBox Grid.Column="2" ItemsSource="{Binding ElementName=ListBoxParty, Path=SelectedItem.Inventory.Items}">
<ListBox.Resources>
<local:ItemIDtoNameConverter x:Key="ItemIDtoNameConverter"/>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<!--<Button Content="..." Click="ButtonItemChoice_Click"/>-->
<Label Content="Name: "/>
<Label Content="{Binding Name, Converter={StaticResource ItemIDtoNameConverter}}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</TabItem>
<!--
<TabItem Header="Item">
<ListBox x:Name="ListBoxItem" ItemsSource="{Binding Items.Items}">
<ListBox.Resources>
<local:ItemIDtoNameConverter x:Key="ItemIDtoNameConverter"/>
</ListBox.Resources>
<ListBox.ContextMenu>
<ContextMenu>
<!--
<MenuItem Header="Append" Click="ListBoxMenuItemAppend_Click"/>
<MenuItem Header="Delete" Click="ListBoxMenuItemDelete_Click"/>
-->
</ContextMenu>
</ListBox.ContextMenu>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="Count : "/>
<TextBox Text="{Binding Count, UpdateSourceTrigger=PropertyChanged}" Width="40"/>
<Button Content="..." Click="ButtonItemChoice_Click"/>
<!--<Button Content="..." Click="ButtonItemChoice_Click"/>-->
<Label Content="Name: "/>
<Label Content="{Binding Name, Converter={StaticResource ItemIDtoNameConverter}}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</TabItem>
-->
</TabControl>
</DockPanel>
</Window>
2 changes: 0 additions & 2 deletions DQ11/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ private void ListBoxMenuItemAppend_Click(object sender, RoutedEventArgs e)

private void ListBoxMenuItemDelete_Click(object sender, RoutedEventArgs e)
{
/*
if (ListBoxItem.SelectedIndex == -1) return;
var items = (DataContext as ViewModel)?.Items;
items.Delete(ListBoxItem.SelectedIndex);
items.Update();
DataContext = new ViewModel();
*/
}

private void ButtonItemChoice_Click(object sender, RoutedEventArgs e)
Expand Down
17 changes: 15 additions & 2 deletions DQ11/SaveData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ public bool Save()
{
if (mFileName == null || mBuffer == null) return false;

/*
uint address = FindAddress("Y32_1F_01", (uint)mBuffer.Length - 100)[0];
address += 26;
DeleteBlock(address, (uint)mBuffer.Length - address);
uint mod = (uint)mBuffer.Length % 16;
if (mod > 0) mod = 16 - mod;
AppendBlock(address, mod + 16);
WriteNumber(0x2D, 4, address);
uint body = 170 + ReadNumber(0x57, 4);
WriteNumber(body, 4, address - body - 16);
WriteNumber((uint)mBuffer.Length - 16, 4, address);
*/
WriteNumber((uint)mBuffer.Length - 12, 4, CalcCheckSum());
Byte[] enc = new Byte[mBuffer.Length];
Array.Copy(mBuffer, enc, enc.Length);
Expand Down Expand Up @@ -194,7 +207,7 @@ public void WriteValue(uint address, Byte[] buffer)

public void AppendBlock(uint address, uint size)
{
if (mBuffer == null) return;
if (mBuffer == null || size == 0) return;
address = CalcAddress(address);

Byte[] tmp = new Byte[mBuffer.Length + size];
Expand All @@ -205,7 +218,7 @@ public void AppendBlock(uint address, uint size)

public void DeleteBlock(uint address, uint size)
{
if (mBuffer == null) return;
if (mBuffer == null || size == 0) return;
address = CalcAddress(address);

Byte[] tmp = new Byte[mBuffer.Length - size];
Expand Down
13 changes: 8 additions & 5 deletions DQ11/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace DQ11
class ViewModel
{
public ObservableCollection<Character> Party { get; set; } = new ObservableCollection<Character>();
public Bag Weapons { get; set; } = new Bag();
public Bag Items { get; set; } = new Bag();

public ViewModel()
Expand All @@ -22,11 +21,15 @@ public ViewModel()

var itemIndex = SaveData.Instance().FindAddress("DLC_07", 0);
if (itemIndex.Count == 0) return;
uint addresss = itemIndex[0] + 11;
addresss = Weapons.Create(addresss);
addresss += 60;
uint address = itemIndex[0] + 11;

Items.Create(addresss);
for(int i = 0; i < Party.Count; i++)
{
address = Party[i].Inventory.Create(address);
address += 4;
}

Items.Create(address);
}
}
}

0 comments on commit 9781ffe

Please sign in to comment.