From 1df4408da01455e4dbece5428ea55554544dde11 Mon Sep 17 00:00:00 2001 From: yangzhi <@4F!xZpJwly&KbWq> Date: Thu, 13 Jun 2019 15:29:02 +0800 Subject: [PATCH] Modloader 1.5 1.Settings page 2.Mod compatibility improvement --- ModLoader/Activity1.cs | 58 ++-- ModLoader/ActivitySetting.cs | 50 ++++ ModLoader/Common/Constants.cs | 4 +- ModLoader/Common/MethodPatcher.cs | 25 ++ ModLoader/Common/Utils.cs | 27 ++ ModLoader/ModLoader.csproj | 11 + ModLoader/Mono/Cecil/BaseAssemblyResolver.cs | 9 +- ModLoader/MonoMod/MonoModder.cs | 4 + .../RuntimeDetour/HarmonyDetourBridge.cs | 15 +- .../Utils/DynamicMethodDefinition.Cecil.cs | 4 + .../Utils/DynamicMethodDefinition.Emit.cs | 5 +- .../MonoMod/Utils/DynamicMethodDefinition.cs | 6 + ModLoader/MonoMod/Utils/ILExt.cs | 9 +- .../MonoMod/Utils/MMReflectionImporter.cs | 4 +- .../Utils/UtilsCil/ILGeneratorShim.Proxy.cs | 15 +- ModLoader/Properties/AndroidManifest.xml | 2 +- ModLoader/Resources/Layout/layout_main.axml | 8 +- .../Resources/Layout/layout_setting.axml | 24 ++ ModLoader/Resources/Raw/ModList.json | 7 + ModLoader/Resources/Raw/SMDroidFiles.zip | Bin 787864 -> 1030500 bytes ModLoader/Resources/Resource.Designer.cs | 268 ++++++++++-------- ModLoader/Resources/Values-zh-rCN/Strings.xml | 6 + ModLoader/Resources/Values/Strings.xml | 8 +- ModLoader/SMAPI/Constants.cs | 3 +- .../ContentManagers/IContentManager.cs | 1 - .../ContentManagers/ModContentManager.cs | 93 +----- .../Framework/ModHelpers/ContentHelper.cs | 5 +- .../Framework/ModLoading/AssemblyLoader.cs | 3 +- .../Framework/ModLoading/RewriteHelper.cs | 25 +- .../Framework/RewriteFacades/FarmerMethods.cs | 6 + .../Framework/RewriteFacades/Game1Methods.cs | 5 + .../RewriteFacades/ItemGrabMenuMethods.cs | 25 ++ .../RewriteFacades/MapPageMethods.cs | 13 + .../RewriteFacades/SpriteTextMethods.cs | 30 ++ .../RewriteFacades/TextBoxMethods.cs | 17 ++ ModLoader/SMAPI/Framework/SCore.cs | 12 +- ModLoader/SMAPI/Framework/SGame.cs | 20 +- .../SMAPI/Metadata/InstructionMetadata.cs | 13 + ModLoader/SMAPI/Patches/DialogueErrorPatch.cs | 12 +- ModLoader/SMAPI/Patches/EventErrorPatch.cs | 1 - ModLoader/SMAPI/Patches/LoadContextPatch.cs | 1 - ModLoader/SMAPI/Patches/ObjectErrorPatch.cs | 4 +- 42 files changed, 587 insertions(+), 271 deletions(-) create mode 100644 ModLoader/ActivitySetting.cs create mode 100644 ModLoader/Resources/Layout/layout_setting.axml create mode 100644 ModLoader/SMAPI/Framework/RewriteFacades/ItemGrabMenuMethods.cs create mode 100644 ModLoader/SMAPI/Framework/RewriteFacades/MapPageMethods.cs create mode 100644 ModLoader/SMAPI/Framework/RewriteFacades/SpriteTextMethods.cs create mode 100644 ModLoader/SMAPI/Framework/RewriteFacades/TextBoxMethods.cs diff --git a/ModLoader/Activity1.cs b/ModLoader/Activity1.cs index edb54b31..a88a0c58 100644 --- a/ModLoader/Activity1.cs +++ b/ModLoader/Activity1.cs @@ -128,6 +128,7 @@ namespace ModLoader private readonly Mutex _working = new Mutex(false); public static Activity1 Instance { get; private set; } + private readonly HttpClient _httpClient = new HttpClient(); private static readonly Dictionary MessageHandler = new Dictionary(); @@ -150,10 +151,29 @@ namespace ModLoader protected override void OnCreate(Bundle bundle) { Instance = this; - Type[] services = { typeof(Analytics), typeof(Crashes) }; - AppCenter.Start("b8eaba94-d276-4c97-9953-0c91e7357e21", services); base.OnCreate(bundle); this.RequestWindowFeature(WindowFeatures.NoTitle); + if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.N) + { + StrictMode.SetVmPolicy(new StrictMode.VmPolicy.Builder().Build()); + } + try { + File errorLog = this.FilesDir.ListFiles().FirstOrDefault(f => f.IsDirectory && f.Name == "error")?.ListFiles().FirstOrDefault(f => f.Name.EndsWith(".dat")); + if (errorLog != null) + { + string errorLogPath = Path.Combine(this.ExternalCacheDir.AbsolutePath, "error.dat"); + StreamToFile(new FileStream(errorLog.AbsolutePath, FileMode.Open), errorLogPath); + ShowConfirmDialog(this, Resource.String.Error, Resource.String.CrashReportMessage, Resource.String.View, Resource.String.Dismiss, () => { OpenTextFile(this, errorLogPath); }); + } + Type[] services = { typeof(Analytics), typeof(Crashes) }; + AppCenter.Start("b8eaba94-d276-4c97-9953-0c91e7357e21", services); + IEnumerable errorLogs = this.FilesDir.ListFiles().FirstOrDefault(f => f.IsDirectory && f.Name == "error")?.ListFiles().ToList().FindAll(f => f.Name.EndsWith(".dat") || f.Name.EndsWith(".throwable")); + if (errorLogs != null) foreach (var file in errorLogs) file.Delete(); + } + catch (Exception) + { + // ignored + } if (Build.VERSION.SdkInt >= BuildVersionCodes.P) { this.Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges; @@ -169,13 +189,18 @@ namespace ModLoader private void OnCreatePartTwo() { - if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.N) - { - StrictMode.SetVmPolicy(new StrictMode.VmPolicy.Builder().Build()); - } - - new PgyUpdateManager.Builder().SetForced(false).SetUserCanRetry(true).SetDeleteHistroyApk(true).Register(); + if (GetConfig(this, "compatCheck", "true") == "false") + Constants.CompatCheck = false; + if (GetConfig(this, "upgradeCheck", "true") == "false") + Constants.UpgradeCheck = false; + else + new PgyUpdateManager.Builder().SetForced(false).SetUserCanRetry(true).SetDeleteHistroyApk(true).Register(); this.InitEnvironment(); + this.FindViewById