Skip to content

Commit

Permalink
support Basic param
Browse files Browse the repository at this point in the history
  • Loading branch information
turtle-insect committed May 14, 2023
1 parent a7b0560 commit b53c74c
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 9 deletions.
27 changes: 26 additions & 1 deletion ZeldaTOTK/Basic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public uint Heart
set
{
if (value < 1) value = 1;
if (value > 20) value = 20;
if (value > 40) value = 40;
SaveData.Instance().WriteNumber(0x29A44, 4, value);
}
}
Expand Down Expand Up @@ -44,6 +44,21 @@ public uint Rupee
}
}

public float Battery
{
get
{
return BitConverter.ToSingle(SaveData.Instance().ReadValue(0x34FC4, 4));
}

set
{
if (value < 3000) value = 3000;
if (value > 24000) value = 24000;
SaveData.Instance().WriteValue(0x34FC4, BitConverter.GetBytes(value));
}
}

public uint Arrow
{
get => SaveData.Instance().ReadNumber(0x47030, 4);
Expand All @@ -53,5 +68,15 @@ public uint Arrow
SaveData.Instance().WriteNumber(0x47030, 4, value);
}
}

public uint EnergyCrystal
{
get => SaveData.Instance().ReadNumber(0x4EBF4, 4);
set
{
if (value > 999) value = 999;
SaveData.Instance().WriteNumber(0x4EBF4, 4, value);
}
}
}
}
6 changes: 4 additions & 2 deletions ZeldaTOTK/HeartConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ public object Convert(object value, Type targetType, object parameter, CultureIn

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var count = (uint)(int)value * 4;
return count;
uint count = 0;
if (!uint.TryParse(value.ToString(), out count)) return 0;

return count * 4;
}
}
}
29 changes: 24 additions & 5 deletions ZeldaTOTK/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:ZeldaTOTK"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Title="MainWindow" Height="450" Width="650">
Title="Switch The Legend of Zelda Tears of the Kingdom SaveDate Editor" Height="450" Width="650">
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
Expand All @@ -28,7 +28,10 @@
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="8*"/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="6*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
Expand All @@ -40,13 +43,29 @@
<Label Content="Rupee"/>
<TextBox Grid.Column="1" Text="{Binding Basic.Rupee, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="1" Content="Heart"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Basic.Heart, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Basic.Heart, Converter={StaticResource HeartConverter}, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="2" Content="Stamina"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Basic.Stamina, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="3" Content="Arrow"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Basic.Arrow, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="3" Content="EnergyCrystal"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Basic.EnergyCrystal, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="4" Content="Battery"/>
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Basic.Battery, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="6" Content="Arrow"/>
<TextBox Grid.Row="6" Grid.Column="1" Text="{Binding Basic.Arrow, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</TabItem>
<TabItem Header="Armor">
<ListBox ItemsSource="{Binding Armors}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="ID"/>
<TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" Width="250"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</TabItem>
<TabItem Header="Bow">
<DockPanel>
<Button DockPanel.Dock="Bottom" Content="Append" Command="{Binding IncrementLimitCountCommand}"
Expand Down
12 changes: 11 additions & 1 deletion ZeldaTOTK/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal class ViewModel : INotifyPropertyChanged
{
public uint ItemCount { get; set; } = 999;
public Basic? Basic { get; private set; } = new Basic();
public ObservableCollection<Item> Armors { get; private set; } = new ObservableCollection<Item>();
public ObservableCollection<Item> Materials { get; private set; } = new ObservableCollection<Item>();
public ObservableCollection<Item> Foods { get; private set; } = new ObservableCollection<Item>();
public ObservableCollection<Item> Capsules { get; private set; } = new ObservableCollection<Item>();
Expand Down Expand Up @@ -41,10 +42,19 @@ private void LoadFile(Object? obj)
if (dlg.ShowDialog() == false) return;
SaveData.Instance().Open(dlg.FileName);

Armors.Clear();
Materials.Clear();
Foods.Clear();
Capsules.Clear();

for(uint index = 0; index < 400; index++)
for (uint index = 0; index < 400; index++)
{
Item item = new Item(0, 0x61BF8 + index * 64);
if (String.IsNullOrEmpty(item.Name)) break;
Armors.Add(item);
}

for (uint index = 0; index < 400; index++)
{
Item item = new Item(0x477E0 + index * 4, 0xAFC30 + index * 64);
if (item.Count == 0xFFFFFFFF) break;
Expand Down

0 comments on commit b53c74c

Please sign in to comment.