From ba49e414a2c272f0b7fd41c4a7e191d56e0c87a7 Mon Sep 17 00:00:00 2001 From: Miepee Date: Fri, 20 Jan 2023 10:58:30 +0100 Subject: [PATCH] Fix crashing when porting to Android via custom save directory Fix #6 --- AM2RPortHelperLib/RawMods.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/AM2RPortHelperLib/RawMods.cs b/AM2RPortHelperLib/RawMods.cs index 1142b67..af59248 100644 --- a/AM2RPortHelperLib/RawMods.cs +++ b/AM2RPortHelperLib/RawMods.cs @@ -244,10 +244,12 @@ public abstract class RawMods : ModsBase HelperMethods.LowercaseFolder(apkAssetsDir); // Edit apktool.yml to not compress music + SendOutput("Edit settings file to not compress OGGs..."); string yamlFile = File.ReadAllText(apkDir + "/apktool.yml"); yamlFile = yamlFile.Replace("doNotCompress:", "doNotCompress:\n- ogg"); File.WriteAllText(apkDir + "/apktool.yml", yamlFile); - + + SendOutput("Save new icons"); // Edit the icons in the apk. Wrapper always has these, so we need to overwrite these too. string resPath = apkDir + "/res"; // Icon should only be read from if its there, otherwise default frog icon should be in the assembly @@ -268,8 +270,9 @@ public abstract class RawMods : ModsBase // If a custom name was given, replace it everywhere. if (useCustomSaveDirectory) { + SendOutput("Get display name..."); string modName; - FileInfo datafile = new FileInfo(extractDirectory + "/game.ios"); + FileInfo datafile = new FileInfo(apkAssetsDir + "/game.droid"); using (FileStream fs = datafile.OpenRead()) { UndertaleData gmData = UndertaleIO.Read(fs, SendOutput, SendOutput); @@ -282,6 +285,8 @@ public abstract class RawMods : ModsBase if (!nameReg.Match(modName).Success) throw new InvalidDataException("The display name " + modName + " is invalid! The name has to start with letters (a-z), and can only contain letters, digits, space, colon and underscore!"); + SendOutput("Replace Android save directory..."); + // first in the manifest manifestFile = manifestFile.Replace("com.companyname.AM2RWrapper", $"com.companyname.{modName}"); @@ -315,6 +320,7 @@ public abstract class RawMods : ModsBase // Add internet permission, keying off the Bluetooth permission. if (usesInternet) { + SendOutput("Replace Internet permission..."); const string bluetoothPermission = ""; const string internetPermission = ""; manifestFile = manifestFile.Replace(bluetoothPermission, internetPermission + "\n " + bluetoothPermission);