Skip to content

Commit

Permalink
- adds gen 7 trainer info editor
Browse files Browse the repository at this point in the history
  • Loading branch information
santacrab2 committed Apr 29, 2024
1 parent ea9b86a commit ce1f6b0
Show file tree
Hide file tree
Showing 24 changed files with 973 additions and 3 deletions.
21 changes: 21 additions & 0 deletions PKHeX.MAUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@
<Compile Update="SaveEditors\Save Editors.xaml.cs">
<DependentUpon>Save Editors.xaml</DependentUpon>
</Compile>
<Compile Update="SaveEditors\TrainerEditors\gen7\Trainertab7.xaml.cs">
<DependentUpon>Trainertab7.xaml</DependentUpon>
</Compile>
<Compile Update="Settings\LegalitySettings.xaml.cs">
<DependentUpon>LegalitySettings.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -311,6 +314,21 @@
<MauiXaml Update="SaveEditors\TrainerEditors\gen6\TrainerTab6.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="SaveEditors\TrainerEditors\gen7\TrainerEditor7.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="SaveEditors\TrainerEditors\gen7\TrainerEditor7BattleTree.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="SaveEditors\TrainerEditors\gen7\TrainerEditor7Map.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="SaveEditors\TrainerEditors\gen7\TrainerEditor7Misc.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="SaveEditors\TrainerEditors\gen7\TrainerEditor7Ultra.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="SaveEditors\TrainerEditors\gen8a\TrainerEditor8a.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
Expand All @@ -335,6 +353,9 @@
<MauiXaml Update="SaveEditors\TrainerEditors\gen9\TrainerTab9.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="SaveEditors\TrainerEditors\gen7\Trainertab7.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Settings\LegalitySettings.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
Expand Down
Binary file added Resources/Assets/fashion_f_sm
Binary file not shown.
Binary file added Resources/Assets/fashion_f_sm_illegal
Binary file not shown.
Binary file added Resources/Assets/fashion_f_uu
Binary file not shown.
Binary file added Resources/Assets/fashion_f_uu_illegal
Binary file not shown.
Binary file added Resources/Assets/fashion_m_sm
Binary file not shown.
Binary file added Resources/Assets/fashion_m_sm_illegal
Binary file not shown.
Binary file added Resources/Assets/fashion_m_uu
Binary file not shown.
Binary file added Resources/Assets/fashion_m_uu_illegal
Binary file not shown.
3 changes: 2 additions & 1 deletion SaveEditors/Save Editors.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private void ToggleControls()
if (!MainPage.sav.State.Exportable || MainPage.sav is BulkStorage)
return;
Button_BlockData.IsVisible = true;
if (MainPage.sav is not SAV7 or SAV8BS or SAV8SWSH)
if (MainPage.sav is not SAV8BS or SAV8SWSH)
TrainerInfoButton.IsVisible = true;
}

Expand All @@ -57,6 +57,7 @@ private void OpenTrainerEditor(object sender, EventArgs e)
case SAV4:
case SAV5: Navigation.PushModalAsync(new TrainerEditor1()); break;
case SAV6: Navigation.PushModalAsync(new TrainerTab6()); break;
case SAV7: Navigation.PushModalAsync(new TrainerTab7()); break;
case SAV8LA: Navigation.PushModalAsync(new TrainerTab8a()); break;
case SAV9SV: Navigation.PushModalAsync(new TrainerTab9()); break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<Label Text="5:" Grid.Row="7" VerticalOptions="Center"/>
<Entry x:Name="SS5" Grid.Row="7" Grid.Column="1"/>
<CheckBox x:Name="MegaEvolutionCheck" Grid.Row="8"/>
<Label Text="Mega Evolution Unlocked" Grid.Row="8" Grid.Column="1"/>
<Label Text="Mega Evolution Unlocked" Grid.Row="8" Grid.Column="1" VerticalOptions="Center"/>
<CheckBox x:Name="RayquazeMECheck" Grid.Row="9"/>
<Label Text="Mega Rayquaza Unlocked" Grid.Row="9" Grid.Column="1" x:Name="MERayquazaLabel"/>
<Label Text="Mega Rayquaza Unlocked" Grid.Row="9" Grid.Column="1" x:Name="MERayquazaLabel" VerticalOptions="Center"/>
</Grid>
</VerticalStackLayout>
</ContentPage>
2 changes: 2 additions & 0 deletions SaveEditors/TrainerEditors/gen6/TrainerTab6.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public TrainerTab6()
}
if (SAV is SAV6XY)
trainertab6.Children.Add(TEA6);
trainertab6.Children.Add(new SavePage6());
trainertab6.Children.Add(new cancelpage());
}
}
public class SavePage6 : ContentPage
Expand Down
112 changes: 112 additions & 0 deletions SaveEditors/TrainerEditors/gen7/TrainerEditor7.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="PKHeXMAUI.TrainerEditor7"
Title="Overview">
<ScrollView>
<VerticalStackLayout>
<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="Trainer Name:" VerticalOptions="Center"/>
<Entry x:Name="OTNameEntry" Grid.Column="1"/>
<Label Text="Country:" Grid.Column="2" VerticalOptions="Center" Grid.ColumnSpan="2"/>
<Picker x:Name="CountryPicker" Grid.Column="4" SelectedIndexChanged="UpdateRegion" Grid.ColumnSpan="2"/>
<Label Text="TID:" Grid.Row="1" VerticalOptions="Center"/>
<Entry x:Name="TIDEntry" Grid.Row="1" Grid.Column="1"/>
<Label Text="$:" Grid.Row="1" Grid.Column="2" VerticalOptions="Center"/>
<Entry x:Name="OTMoneyEntry" Grid.Row="1" Grid.Column="3"/>
<Button x:Name="MaxCashButton" Grid.Row="1" Grid.Column="4" Text="+" VerticalOptions="Center" HorizontalOptions="Center" Clicked="MaxCash"/>
<Label Text="Region:" Grid.Row="1" Grid.Column="5" VerticalOptions="Center"/>
<Picker x:Name="RegionPicker" Grid.Row="1" Grid.Column="6"/>
<Label Text="SID:" Grid.Row="2" VerticalOptions="Center"/>
<Entry x:Name="SIDEntry" Grid.Row="2" Grid.Column="1"/>
<Picker x:Name="GenderPicker" Grid.Row="2" Grid.Column="2"/>
<Picker x:Name="VersionPicker" Grid.Row="2" Grid.Column="3"/>
<Label Text="3DS Region:" Grid.Row="2" Grid.Column="4" VerticalOptions="Center"/>
<Picker x:Name="dsRegionPicker" Grid.Row="2" Grid.Column="5" Grid.ColumnSpan="2"/>
<Label Text="Language:" VerticalOptions="Center" Grid.Row="3" Grid.ColumnSpan="2"/>
<Picker x:Name="LanguagePicker" Grid.Row="3" Grid.Column="2"/>
<Label Text="Vivillon:" Grid.Row="3" Grid.Column="3" VerticalOptions="Center" Grid.ColumnSpan="2"/>
<Picker x:Name="VivillonPicker" Grid.Row="3" Grid.Column="4" Grid.ColumnSpan="2"/>
<Label Text="Time Offset:" Grid.Row="4" VerticalOptions="Center"/>
<Picker x:Name="TimeOffsetPicker" Grid.Row="4" Grid.Column="1"/>
</Grid>
<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="Adventure Info" Grid.ColumnSpan="2"/>
<Label Text="Hrs:" VerticalOptions="Center" Grid.Row="1"/>
<Entry x:Name="HrsPlayedEntry" Grid.Row="1" Grid.Column="1"/>
<Label Text="Min:" VerticalOptions="Center" Grid.Row="1" Grid.Column="2"/>
<Entry x:Name="MinPlayedEntry" Grid.Row="1" Grid.Column="3"/>
<Label Text="Sec:" VerticalOptions="Center" Grid.Row="1" Grid.Column="4"/>
<Entry x:Name="SecPlayedEntry" Grid.Row="1" Grid.Column="5"/>
<Label Text="Game Started:" VerticalOptions="Center" Grid.Row="2"/>
<DatePicker x:Name="GSDatePicker" Grid.Row="2" Grid.Column="1"/>
<TimePicker x:Name="GSTimePicker" Grid.Row="2" Grid.Column="2"/>
<Label Text="HoF Entered:" VerticalOptions="Center" Grid.Row="3"/>
<DatePicker x:Name="HOFDatePicker" Grid.Row="3" Grid.Column="1"/>
<TimePicker x:Name="HOFTimePicker" Grid.Row="3" Grid.Column="2"/>
<Label Text="Last Saved:" VerticalOptions="Center" Grid.Row="4" x:Name="LSLabel"/>
<DatePicker x:Name="LSDatePicker" Grid.Row="4" Grid.Column="1"/>
<TimePicker x:Name="LSTimePicker" Grid.Row="4" Grid.Column="2"/>
</Grid>
<Grid Padding="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Text="Stats" VerticalOptions="Center"/>
<Label Text="BP:" VerticalOptions="Center" Grid.Row="1"/>
<Entry x:Name="BPEntry" Grid.Row="1" Grid.Column="1"/>
<Label Text="FestaCoins:" VerticalOptions="Center" Grid.Row="2"/>
<Entry x:Name="FCEntry" Grid.Row="2" Grid.Column="1"/>
<Picker x:Name="TrainerPropPicker" Grid.Row="3" SelectedIndexChanged="GetStats"/>
<Label Text="Value:" VerticalOptions="Center" Grid.Row="4"/>
<Entry x:Name="TPEntry" Grid.Row="4" Grid.Column="1" TextChanged="ChangeStats"/>
<Label Text="Offset:" Grid.Row="5"/>
<Label x:Name="OffsetValueLabel" Grid.Row="5" Grid.Column="1"/>
</Grid>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
143 changes: 143 additions & 0 deletions SaveEditors/TrainerEditors/gen7/TrainerEditor7.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
using PKHeX.Core;

namespace PKHeXMAUI;

public partial class TrainerEditor7 : ContentPage
{
public SAV7 SAV = (SAV7)MainPage.sav;
public TrainerEditor7()
{
InitializeComponent();
OTNameEntry.Text = SAV.OT;
GenderPicker.ItemsSource = GameInfo.GenderSymbolUnicode.Take(2).ToArray();
GenderPicker.SelectedIndex = SAV.Gender;
TimeOffsetPicker.ItemsSource = GetAlolaTimeList();
TimeOffsetPicker.ItemDisplayBinding = new Binding("Text");
var timeA = SAV.GameTime.AlolaTime;
if (timeA == 0)
timeA = 24 * 60 * 60; // Patch up any bad times from previous program versions.
if (timeA == 9_999_999)
TimeOffsetPicker.IsVisible = false;
else
TimeOffsetPicker.SelectedItem = GetAlolaTimeList().FirstOrDefault(z => z.Value == (int)timeA);
if (TimeOffsetPicker.SelectedItem == null)
TimeOffsetPicker.IsVisible = false;
var recordres = RecordLists.RecordList_7;
List<string> recordlist = new();
for (int i = 0; i < ((ITrainerStatRecord)SAV).RecordCount; i++)
{
if (!recordres.TryGetValue(i, out var name))
name = $"{i:D3}";
recordlist.Add(name);
}
TrainerPropPicker.ItemsSource = recordlist;
TrainerPropPicker.SelectedIndex = recordres.First().Key;
dsRegionPicker.ItemsSource = (System.Collections.IList)GameInfo.Regions;
dsRegionPicker.ItemDisplayBinding = new Binding("Text");
LanguagePicker.ItemsSource = (System.Collections.IList)GameInfo.LanguageDataSource(SAV.Generation);
LanguagePicker.ItemDisplayBinding = new Binding("Text");
CountryPicker.ItemsSource = Util.GetCountryRegionList("countries", GameInfo.CurrentLanguage);
CountryPicker.ItemDisplayBinding = new Binding("Text");
VivillonPicker.ItemsSource = FormConverter.GetFormList((int)Species.Vivillon, GameInfo.Strings.types, GameInfo.Strings.forms, GameInfo.GenderSymbolUnicode, SAV.Context);
VersionPicker.ItemsSource = new object[] { "Sun", "Moon", "US", "UM" };
VersionPicker.SelectedIndex = (int)(SAV.Version - GameVersion.SN);
TIDEntry.Text = SAV.DisplayTID.ToString("000000");
SIDEntry.Text = SAV.DisplaySID.ToString("0000");
OTMoneyEntry.Text = SAV.Money.ToString();
CountryPicker.SelectedItem = Util.GetCountryRegionList("countries", GameInfo.CurrentLanguage).First(z => z.Value == SAV.Country);
dsRegionPicker.SelectedItem = GameInfo.Regions.First(z => z.Value == SAV.ConsoleRegion);
var index = ((ComboItem)CountryPicker.SelectedItem).Value;
RegionPicker.SelectedItem = Util.GetCountryRegionList($"sr_{index:000}", GameInfo.CurrentLanguage).First(z => z.Value == SAV.Region);
LanguagePicker.SelectedIndex = SAV.Language - 1;
BPEntry.Text = SAV.Misc.BP.ToString();
FCEntry.Text = SAV.Festa.FestaCoins.ToString();
HrsPlayedEntry.Text = SAV.PlayedHours.ToString();
MinPlayedEntry.Text = SAV.PlayedMinutes.ToString();
SecPlayedEntry.Text = SAV.PlayedSeconds.ToString();
VivillonPicker.SelectedIndex = SAV.Misc.Vivillon;
if (SAV.Played.LastSavedDate.HasValue)
{
LSDatePicker.Date = SAV.Played.LastSavedDate.Value;
LSTimePicker.Time = SAV.Played.LastSavedDate.Value.TimeOfDay;
}
else
LSLabel.IsVisible = LSDatePicker.IsVisible = LSTimePicker.IsVisible = false;
DateUtil.GetDateTime2000(SAV.SecondsToStart, out var date, out var time);
GSDatePicker.Date = date;
GSTimePicker.Time = time.TimeOfDay;
DateUtil.GetDateTime2000(SAV.SecondsToFame, out date, out time);
HOFDatePicker.Date = date;
HOFTimePicker.Time = time.TimeOfDay;

}
private static ComboItem[] GetAlolaTimeList()
{
var alolatime_list = new ComboItem[24];
for (int i = 1; i < alolatime_list.Length; i++)
alolatime_list[i] = new ComboItem($"+{i:00} Hours", i * 60 * 60);
alolatime_list[0] = new ComboItem("Sun Time", 24 * 60 * 60);
alolatime_list[12] = new ComboItem("Moon Time", 12 * 60 * 60);
return alolatime_list;
}
private void MaxCash(object sender, EventArgs e)
{
OTMoneyEntry.Text = "9,999,999";
}
private void UpdateRegion(object sender, EventArgs e)
{
var index = ((ComboItem)CountryPicker.SelectedItem).Value;
RegionPicker.ItemsSource = Util.GetCountryRegionList($"sr_{index:000}", GameInfo.CurrentLanguage);
RegionPicker.ItemDisplayBinding = new Binding("Text");
}
public bool Editing = false;
private void GetStats(object sender, EventArgs e)
{
Editing = true;
int index = TrainerPropPicker.SelectedIndex;
int val = SAV.GetRecord(index);
TPEntry.Text = val.ToString();
int offset = SAV.GetRecordOffset(index);
OffsetValueLabel.Text = $"0x{offset:X3}";
Editing = false;
}

private void ChangeStats(object sender, TextChangedEventArgs e)
{
if (Editing)
return;
int index = TrainerPropPicker.SelectedIndex;
var parsed = int.TryParse(TPEntry.Text, out var result);
if (parsed) SAV.SetRecord(index, result);
}
public void SaveTE7()
{
SAV.Version = (GameVersion)(VersionPicker.SelectedIndex + 30);
SAV.Gender = (byte)GenderPicker.SelectedIndex;
SAV.Money = Util.ToUInt32(OTMoneyEntry.Text);
SAV.Region = (byte)((ComboItem)RegionPicker.SelectedItem).Value;
SAV.Country = (byte)((ComboItem)CountryPicker.SelectedItem).Value;
SAV.ConsoleRegion = (byte)((ComboItem)dsRegionPicker.SelectedItem).Value;
SAV.Language = ((ComboItem)LanguagePicker.SelectedItem).Value;
SAV.GameTime.AlolaTime =(ulong) ((ComboItem)TimeOffsetPicker.SelectedItem).Value;
SAV.OT = OTNameEntry.Text;
var parsed = int.TryParse(TIDEntry.Text, out var result);
if (parsed) SAV.DisplayTID = (uint)result;
parsed = int.TryParse(SIDEntry.Text, out result);
if (parsed) SAV.DisplaySID = (uint)result;
parsed = int.TryParse(HrsPlayedEntry.Text, out result);
if (parsed) SAV.PlayedHours = result;
parsed = int.TryParse(MinPlayedEntry.Text, out result);
if (parsed) SAV.PlayedMinutes = result;
parsed = int.TryParse(SecPlayedEntry.Text, out result);
if (parsed) SAV.PlayedSeconds = result;
SAV.SecondsToStart = (uint)DateUtil.GetSecondsFrom2000(GSDatePicker.Date, GSDatePicker.Date.AddSeconds(GSTimePicker.Time.TotalSeconds));
SAV.SecondsToFame = (uint)DateUtil.GetSecondsFrom2000(HOFDatePicker.Date, HOFDatePicker.Date.AddSeconds(HOFTimePicker.Time.TotalSeconds));
if (SAV.Played.LastSavedDate.HasValue)
SAV.Played.LastSavedDate = LSDatePicker.Date.AddSeconds(LSTimePicker.Time.TotalSeconds);
SAV.Misc.Vivillon = VivillonPicker.SelectedIndex;
parsed = int.TryParse(BPEntry.Text, out result);
if (parsed) SAV.Misc.BP = (uint)result;
parsed = int.TryParse(FCEntry.Text, out result);
if (parsed) SAV.Festa.FestaCoins = result;
}
}
Loading

0 comments on commit ce1f6b0

Please sign in to comment.