diff --git a/balatro-mobile-maker/Constants.cs b/balatro-mobile-maker/Constants.cs index 09f0052..a6e1edd 100644 --- a/balatro-mobile-maker/Constants.cs +++ b/balatro-mobile-maker/Constants.cs @@ -44,20 +44,4 @@ internal static class Constants public const string SevenzipOSXLink = "https://www.7-zip.org/a/7z2403-mac.tar.xz"; - //Python Links - //Win (Embedded) - public const string PythonWinX64Link = "https://www.python.org/ftp/python/3.12.3/python-3.12.3-embed-amd64.zip"; - public const string PythonWinX86Link = "https://www.python.org/ftp/python/3.12.3/python-3.12.3-embed-win32.zip"; - public const string PythonWinArm64Link = "https://www.python.org/ftp/python/3.12.3/python-3.12.3-embed-arm64.zip"; - //TODO: Multiplatform Python - - - public const string PythonScript = -@"import zipfile -existing_zip = zipfile.ZipFile('balatro-base.zip', 'a') -new_file_path = 'game.love' -existing_zip.write(new_file_path, arcname='Payload/Balatro.app/game.love') -existing_zip.close()"; - - } \ No newline at end of file diff --git a/balatro-mobile-maker/Platform.cs b/balatro-mobile-maker/Platform.cs index 63bd05d..2170cf6 100644 --- a/balatro-mobile-maker/Platform.cs +++ b/balatro-mobile-maker/Platform.cs @@ -48,17 +48,23 @@ public static void useSevenZip(string args) if (isOSX) { if (!fileExists("7zz")) + { RunCommand("tar", "-xf 7zip.tar.xz"); + RunCommand("chmod", "+x 7zz"); + } - RunCommand("7zz", args); + RunCommand("./7zz", args); } if (isLinux) { if (!fileExists("7zzs")) + { RunCommand("tar", "-xf 7zip.tar.xz"); + RunCommand("chmod", "+x 7zzs"); + } - RunCommand("7zzs", args); + RunCommand("./7zzs", args); } } @@ -146,19 +152,6 @@ public static void useOpenJDK(string args) } } - //Uses Python with args - public static void usePython(string args) - { - if (isWindows) - RunCommand("python\\python.exe", args); - - //TODO: Don't assume python is already installed and in the system path!!! - if (isOSX) - RunCommand("python", args); - - if (isLinux) - RunCommand("python", args); - } public static string getOpenJDKDownloadLink() { if (isWindows) @@ -192,25 +185,6 @@ public static string getOpenJDKDownloadLink() return ""; } - public static string getPythonDownloadLink() - { - if (isWindows) - { - if (isX64) - return Constants.PythonWinX64Link; - if (isX86) //May not be supported, but included for now - return Constants.PythonWinX86Link; - if (isArm64) - return Constants.PythonWinArm64Link; - } - - //TODO: Download Python!!! At the moment, we're assuming OSX and Linux users already have Python installed, and in their path. - if (isOSX) { /*...*/ } - - if (isLinux) { /*...*/ } - - return ""; - } public static string getGameSaveLocation() { @@ -219,11 +193,11 @@ public static string getGameSaveLocation() //TODO: Test Linux location if (isLinux) - return "~/.local/share/Steam/steamapps/compatdata/2379780/pfx/drive_c/users/steamuser/AppData/Roaming/Balatro"; + return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/.local/share/Steam/steamapps/compatdata/2379780/pfx/drive_c/users/steamuser/AppData/Roaming/Balatro"; //TODO: Implement - //if (isOSX) - // return "uhhh"; + if (isOSX) + return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/Library/Application Support/Balatro"; return "."; } @@ -268,10 +242,10 @@ public static bool tryLocateGame() //TODO: Test OSX and Linux locations!!! if (isOSX) - location = "~/Library/Application Support/Steam/steamapps/common/Balatro/Balatro.app/Contents/Resources/Balatro.love"; + location = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/Library/Application Support/Steam/steamapps/common/Balatro/Balatro.app/Contents/Resources/Balatro.love"; if (isLinux) - location = "~/.local/share/Steam/steamapps/common/Balatro/Balatro.exe"; + location = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/.local/share/Steam/steamapps/common/Balatro/Balatro.exe"; //Attempt to copy Balatro from Steam directory diff --git a/balatro-mobile-maker/Tools.cs b/balatro-mobile-maker/Tools.cs index a51d8a7..1a7b224 100644 --- a/balatro-mobile-maker/Tools.cs +++ b/balatro-mobile-maker/Tools.cs @@ -7,6 +7,7 @@ using System.Net; using static balatro_mobile_maker.Program; using System.Diagnostics; +using System.IO.Compression; namespace balatro_mobile_maker; internal class Tools @@ -16,7 +17,6 @@ public enum ProcessTools SevenZip, ADB, Java, - Python } public static void useTool(ProcessTools tool, string args) @@ -26,9 +26,6 @@ public static void useTool(ProcessTools tool, string args) case ProcessTools.ADB: Platform.useADB(args); break; - case ProcessTools.Python: - Platform.usePython(args); - break; case ProcessTools.Java: Platform.useOpenJDK(args); break; @@ -227,4 +224,16 @@ public static bool AskQuestion(string question) return input == "y"; } + + public static void ModifyZip() + { + string existingZipFile = "balatro-base.zip"; + string newFilePath = "game.love"; + string arcname = "Payload/Balatro.app/game.love"; + + using (ZipArchive archive = ZipFile.Open(existingZipFile, ZipArchiveMode.Update)) + { + archive.CreateEntryFromFile(newFilePath, arcname); + } + } } diff --git a/balatro-mobile-maker/View.cs b/balatro-mobile-maker/View.cs index 846cc88..4a22376 100644 --- a/balatro-mobile-maker/View.cs +++ b/balatro-mobile-maker/View.cs @@ -73,10 +73,7 @@ public void Begin() //Downloading tools. Handled in threads to allow simultaneous downloads Thread[] downloadThreads = [ - //TODO: Platform specific file downloads for Python!! This will download the Windows X64 version on all platforms! Moving forward without correcting this assumes Python is installed and in the Path for OSX and Linux!!! new Thread(() => { Platform.download7Zip(); }), - new Thread(() => { TryDownloadFile("Python", PythonWinX64Link, "python.zip"); }), - new Thread(() => { TryDownloadFile("iOS Base", IosBaseLink, "balatro-base.ipa"); }) ]; @@ -250,14 +247,9 @@ public void Begin() if (_iosBuild) { #region Packing IPA - Log("Extracting Python"); - tryDelete("python"); - useTool(ProcessTools.SevenZip, "x python.zip -opython"); - + Log("Repacking iOS app..."); - tryDelete("ios.py"); - System.IO.File.WriteAllText("ios.py", Constants.PythonScript); - useTool(ProcessTools.Python, "ios.py"); + ModifyZip(); fileMove("balatro-base.zip", "balatro.ipa"); #endregion @@ -382,7 +374,6 @@ public static void Cleanup() tryDelete("balatro-aligned-debugSigned.apk.idsig"); tryDelete("balatro-unsigned.apk"); tryDelete("platform-tools.zip"); - tryDelete("python.zip"); tryDelete("ios.py"); tryDelete("balatro.zip"); tryDelete("game.love"); @@ -399,7 +390,6 @@ public static void Cleanup() tryDelete("platform-tools"); tryDelete("jdk-21.0.3+9"); - tryDelete("python"); tryDelete("Balatro-APK-Patch");//TODO: remove when Android build changes //tryDelete("icons");//TODO: enable when Android build changes tryDelete("Balatro");