Skip to content

Commit

Permalink
fixes game start dateTime bug
Browse files Browse the repository at this point in the history
adds trainer folder and requirements for trainer folder to operate
user trainer data and trainer folder path settings added
updates automod and PKHeX dependencies
  • Loading branch information
santacrab2 committed Jul 20, 2024
1 parent dc7d1d9 commit 84f743d
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 6 deletions.
15 changes: 14 additions & 1 deletion Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
using Android.App;
using Android.Content.PM;

using Android.OS;
using Android.Content;
namespace PKHeXMAUI;

[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
if (!Android.OS.Environment.IsExternalStorageManager)
{
Intent intent = new Intent();
intent.SetAction(Android.Provider.Settings.ActionManageAppAllFilesAccessPermission);
Android.Net.Uri uri = Android.Net.Uri.FromParts("package", this.PackageName, null);
intent.SetData(uri);
StartActivity(intent);
}
base.OnCreate(savedInstanceState);
}
}
5 changes: 3 additions & 2 deletions SaveEditors/Gen1/TrainerEditor1.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,9 @@ private void SaveTE1(object sender, EventArgs e)
if (region is not null)
s.Region = region.Value;
}
SAV.SecondsToStart = (uint)DateUtil.GetSecondsFrom2000(GSDatePicker.Date, GSDatePicker.Date.AddSeconds(GSTimerPicker.Time.TotalSeconds));
SAV.SecondsToFame = (uint)DateUtil.GetSecondsFrom2000(HOFDatePicker.Date, HOFDatePicker.Date.AddSeconds(HOFTimePicker.Time.TotalSeconds));
DateTime Epoch2000 = new DateTime(2000, 1, 1);
SAV.SecondsToStart = (uint)DateUtil.GetSecondsFrom2000(GSDatePicker.Date, Epoch2000.AddSeconds(GSTimerPicker.Time.TotalSeconds % 86400));
SAV.SecondsToFame = (uint)DateUtil.GetSecondsFrom2000(HOFDatePicker.Date, Epoch2000.AddSeconds(GSTimerPicker.Time.TotalSeconds % 86400));
Navigation.PopModalAsync();
}

Expand Down
2 changes: 2 additions & 0 deletions Settings/ALMSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class PluginSettings
public static string DefaultOT { get => Preferences.Get("DefaultOT", "ALM"); }
public static string DefaultTID { get => Preferences.Get("DefaultTID", "12345"); }
public static string DefaultSID { get => Preferences.Get("DefaultSID", "54321"); }
public static bool UseTrainerData { get => Preferences.Get("UseTrainerData", false); }
public static string TrainerFolderPath { get => Preferences.Get("TrainerFolderPath", ""); }
public static bool PrioritizeGame { get => Preferences.Default.Get("PrioritizeGame", false); }
public static GameVersion PrioritizeGameVersion { get => (GameVersion)Preferences.Default.Get("PrioritizeGameVersion", 50); }
public static bool SetAllLegalRibbons { get => Preferences.Default.Get("SetAllLegalRibbons", false); }
Expand Down
11 changes: 11 additions & 0 deletions Settings/PKHeXSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Syncfusion.Maui.Core.Internals;
using System.Text.Json;
using System.Runtime.Serialization.Json;
using CommunityToolkit.Maui.Storage;

namespace PKHeXMAUI;

Expand Down Expand Up @@ -274,6 +275,16 @@ public static void GetSettingBool(object sender, EventArgs e)
_ => ""
};
ToolTipProperties.SetText(editor, description);
if(editor.Placeholder == "TrainerFolderPath")
{
var tap = new TapGestureRecognizer() { NumberOfTapsRequired = 1 };
tap.Tapped +=async (s, e) =>
{
var path = await FolderPicker.PickAsync(CancellationToken.None);
((Editor)s).Text = $"{path.Folder.Path}/";
};
editor.GestureRecognizers.Add(tap);
}
}
}
}
Expand Down
Binary file modified deps/PKHeX.Core.AutoMod.dll
Binary file not shown.
Binary file modified deps/PKHeX.Core.Injection.dll
Binary file not shown.
30 changes: 27 additions & 3 deletions pktabs/PKTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace PKHeXMAUI;

public partial class MainPage : ContentPage
{
public static string Version = "v24.06.19";
public static string Version = "v24.07.19";
public bool SkipTextChange = false;
public static int[] NoFormSpriteSpecies = [664, 665, 744, 982, 855, 854, 869,892,1012,1013];
public bool FirstLoad = true;
Expand Down Expand Up @@ -77,7 +77,8 @@ public MainPage()
public static void SetSettings()
{
APILegality.SetAllLegalRibbons = PluginSettings.SetAllLegalRibbons;
APILegality.UseTrainerData = false;
APILegality.UseTrainerData = PluginSettings.UseTrainerData;
var trainerfolder = PluginSettings.TrainerFolderPath;
APILegality.AllowTrainerOverride = true;
APILegality.SetMatchingBalls = PluginSettings.SetBallByColor;
Legalizer.EnableEasterEggs = PluginSettings.EnableMemesForIllegalSets;
Expand All @@ -97,7 +98,30 @@ public static void SetSettings()
if (IsTIDdigits)
TrainerSettings.DefaultTID16 = TID;
TrainerSettings.Clear();
TrainerSettings.Register(TrainerSettings.DefaultFallback((GameVersion)sav.Version, (LanguageID)sav.Language));
if (!APILegality.UseTrainerData)
TrainerSettings.Register(TrainerSettings.DefaultFallback((GameVersion)sav.Version, (LanguageID)sav.Language));
else
{
if (Directory.Exists(trainerfolder))
{
var files = Directory.GetFiles(trainerfolder);
foreach (var file in files)
{
if (!EntityDetection.IsSizePlausible(new FileInfo(file).Length))
{
break;
}

byte[] data = File.ReadAllBytes(file);
EntityContext contextFromExtension = EntityFileExtension.GetContextFromExtension(file);
PKM fromBytes = EntityFormat.GetFromBytes(data, contextFromExtension);
if (fromBytes != null)
{
TrainerSettings.Register(new PokeTrainerDetails(fromBytes.Clone()));
}
}
}
}
var startup = new LegalSettings();
SaveFile.SetUpdatePKM = PSettings.SetUpdatePKM ? PKMImportSetting.Update : PKMImportSetting.Skip;
ParseSettings.InitFromSaveFileData(sav);
Expand Down

0 comments on commit 84f743d

Please sign in to comment.