slight cleanup

mac
Miepee 3 years ago
parent abd9d37986
commit b06914b3e4

@ -34,7 +34,7 @@ internal static class Program
androidOption, androidOption,
macOption, macOption,
nameOption, nameOption,
internetOption, internetOption
}; };
rootCommand.SetHandler(RootMethod, interactiveOption, fileOption, linuxOption, androidOption, rootCommand.SetHandler(RootMethod, interactiveOption, fileOption, linuxOption, androidOption,
macOption, nameOption, internetOption, verboseOption); macOption, nameOption, internetOption, verboseOption);
@ -64,16 +64,16 @@ internal static class Program
if (linuxPath is not null) if (linuxPath is not null)
{ {
RawMods.PortToLinux(inputModPath.FullName, linuxPath.FullName, beVerbose ? OutputHandlerDelegate : null); RawModsBase.PortToLinux(inputModPath.FullName, linuxPath.FullName, beVerbose ? OutputHandlerDelegate : null);
} }
if (androidPath is not null) if (androidPath is not null)
{ {
RawMods.PortToAndroid(inputModPath.FullName, androidPath.FullName, RawModsBase.PortToAndroid(inputModPath.FullName, androidPath.FullName,
useCustomSave, usesInternet, beVerbose ? OutputHandlerDelegate : null); useCustomSave, usesInternet, beVerbose ? OutputHandlerDelegate : null);
} }
if (macPath is not null) if (macPath is not null)
{ {
RawMods.PortToMac(inputModPath.FullName, macPath.FullName, beVerbose ? OutputHandlerDelegate : null); RawModsBase.PortToMac(inputModPath.FullName, macPath.FullName, beVerbose ? OutputHandlerDelegate : null);
} }
if (beVerbose) if (beVerbose)
Console.WriteLine("Done."); Console.WriteLine("Done.");
@ -142,7 +142,7 @@ internal static class Program
if (File.Exists(linuxPath)) if (File.Exists(linuxPath))
File.Delete(linuxPath); File.Delete(linuxPath);
RawMods.PortToLinux(modZipPath, linuxPath, OutputHandlerDelegate); RawModsBase.PortToLinux(modZipPath, linuxPath, OutputHandlerDelegate);
} }
if (androidSelected) if (androidSelected)
@ -181,16 +181,14 @@ internal static class Program
} }
while (customSaveSelected == null); while (customSaveSelected == null);
RawMods.PortToAndroid(modZipPath, androidPath, customSaveSelected.Value, customSaveSelected.Value, OutputHandlerDelegate); RawModsBase.PortToAndroid(modZipPath, androidPath, customSaveSelected.Value, customSaveSelected.Value, OutputHandlerDelegate);
} }
if (macSelected) if (macSelected)
{ {
if (File.Exists(macPath)) if (File.Exists(macPath))
File.Delete(macPath); File.Delete(macPath);
Console.WriteLine("Mac requires a name! Please enter one (no special characters!):"); RawModsBase.PortToMac(modZipPath, macPath, OutputHandlerDelegate);
string modName = Console.ReadLine();
RawMods.PortToMac(modZipPath, macPath, OutputHandlerDelegate);
} }
Console.WriteLine("Successfully finished!"); Console.WriteLine("Successfully finished!");
@ -199,10 +197,10 @@ internal static class Program
// We want people to also provide zips that don't end in .zip. If it turns out to not be a zip, it'll still throw later. // We want people to also provide zips that don't end in .zip. If it turns out to not be a zip, it'll still throw later.
private static bool IsValidInputZip(string path) private static bool IsValidInputZip(string path)
{ {
return path != null && (File.Exists(path)); return path != null && File.Exists(path);
} }
private static bool IsValidInputZip(FileInfo path) private static bool IsValidInputZip(FileSystemInfo path)
{ {
return IsValidInputZip(path?.FullName); return IsValidInputZip(path?.FullName);
} }

@ -40,7 +40,7 @@ public partial class MainForm : Form
mainLayout.BeginCentered(); mainLayout.BeginCentered();
mainLayout.AddRow(checkboxAndroidRequiresInternet); mainLayout.AddRow(checkboxAndroidRequiresInternet);
mainLayout.EndCentered(); mainLayout.EndCentered();
mainLayout.AddRow(new Label() { Height = 5 }); mainLayout.AddRow(new Label { Height = 5 });
mainLayout.BeginCentered(); mainLayout.BeginCentered();
mainLayout.AddRow(checkboxUseCustomSave); mainLayout.AddRow(checkboxUseCustomSave);
mainLayout.EndCentered(); mainLayout.EndCentered();
@ -101,7 +101,7 @@ public partial class MainForm : Form
if (File.Exists(linuxPath)) if (File.Exists(linuxPath))
File.Delete(linuxPath); File.Delete(linuxPath);
await Task.Run(() => RawMods.PortToLinux(modZipPath, linuxPath, OutputHandlerDelegate)); await Task.Run(() => RawModsBase.PortToLinux(modZipPath, linuxPath, OutputHandlerDelegate));
} }
if (checkboxAndroid.Checked.Value) if (checkboxAndroid.Checked.Value)
{ {
@ -110,7 +110,7 @@ public partial class MainForm : Form
bool useCustomSave = checkboxUseCustomSave.Checked.Value; bool useCustomSave = checkboxUseCustomSave.Checked.Value;
bool useInternet = checkboxAndroidRequiresInternet.Checked.Value; bool useInternet = checkboxAndroidRequiresInternet.Checked.Value;
await Task.Run(() => RawMods.PortToAndroid(modZipPath, androidPath, useCustomSave, useInternet, OutputHandlerDelegate)); await Task.Run(() => RawModsBase.PortToAndroid(modZipPath, androidPath, useCustomSave, useInternet, OutputHandlerDelegate));
} }
if (checkboxMac.Checked.Value) if (checkboxMac.Checked.Value)
{ {
@ -118,7 +118,7 @@ public partial class MainForm : Form
File.Delete(macPath); File.Delete(macPath);
string modName = checkboxUseCustomSave.Text; string modName = checkboxUseCustomSave.Text;
await Task.Run(() => RawMods.PortToMac(modZipPath, macPath, OutputHandlerDelegate)); await Task.Run(() => RawModsBase.PortToMac(modZipPath, macPath, OutputHandlerDelegate));
} }
labelProgress.Text = "Done!"; labelProgress.Text = "Done!";
@ -139,12 +139,9 @@ public partial class MainForm : Form
private void ShouldButtonPortBeEnabled(object sender, EventArgs e) private void ShouldButtonPortBeEnabled(object sender, EventArgs e)
{ {
// there needs to be a selected mod + any checkbox (if mac, then there needs to be a name) // there needs to be a selected mod + any checkbox
if ((!String.IsNullOrWhiteSpace(filePicker.FilePath) if (!String.IsNullOrWhiteSpace(filePicker.FilePath) &&
&& ((checkboxAndroid.Checked.Value && !checkboxMac.Checked.Value)) (checkboxAndroid.Checked.Value || checkboxLinux.Checked.Value || checkboxMac.Checked.Value))
|| (checkboxLinux.Checked.Value && !checkboxMac.Checked.Value)
|| (checkboxMac.Checked.Value && !String.IsNullOrWhiteSpace(checkboxUseCustomSave.Text))))
buttonPort.Enabled = true; buttonPort.Enabled = true;
else else
buttonPort.Enabled = false; buttonPort.Enabled = false;

@ -1,7 +1,20 @@
namespace AM2RPortHelperLib; namespace AM2RPortHelperLib;
public class Core public static class Core
{ {
private static string ReturnAndCreateConfigDir()
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create) + "/PortHelper/";
Console.WriteLine(path);
Directory.CreateDirectory(path);
return path;
}
/// <summary>
/// The full path to the PortHelper's place in Configuration Application Data.
/// </summary>
internal static readonly string ConfigDir = ReturnAndCreateConfigDir();
/// <summary> /// <summary>
/// The current version of <see cref="AM2RPortHelperLib"/>. /// The current version of <see cref="AM2RPortHelperLib"/>.
/// </summary> /// </summary>

@ -61,7 +61,7 @@ public static class HelperMethods
foreach (DirectoryInfo subDir in dirs) foreach (DirectoryInfo subDir in dirs)
{ {
string tempPath = Path.Combine(destDirName, subDir.Name); string tempPath = Path.Combine(destDirName, subDir.Name);
DirectoryCopy(subDir.FullName, tempPath, true); DirectoryCopy(subDir.FullName, tempPath);
} }
} }

@ -2,7 +2,7 @@
namespace AM2RPortHelperLib; namespace AM2RPortHelperLib;
public abstract class LauncherMods : IMods public abstract class LauncherModsBase : ModsBase
{ {
/// <summary> /// <summary>
/// Ports a Mod zip intended to be installed via the AM2RLauncher to other operating systems. /// Ports a Mod zip intended to be installed via the AM2RLauncher to other operating systems.
@ -17,8 +17,8 @@ public abstract class LauncherMods : IMods
/// TODO: other exceptions /// TODO: other exceptions
public static void PortLauncherMod(string inputLauncherZipPath, Core.ModOS modTarget, bool includeAndroid, string outputLauncherZipPath, string am2r11ZipPath = null, OutputHandlerDelegate outputDelegate = null) public static void PortLauncherMod(string inputLauncherZipPath, Core.ModOS modTarget, bool includeAndroid, string outputLauncherZipPath, string am2r11ZipPath = null, OutputHandlerDelegate outputDelegate = null)
{ {
outputHandler = outputDelegate; OutputHandler = outputDelegate;
string extractDirectory = tmp + "/" + Path.GetFileNameWithoutExtension(inputLauncherZipPath); string extractDirectory = TempDir + "/" + Path.GetFileNameWithoutExtension(inputLauncherZipPath);
string filesToCopyDir = extractDirectory + "/files_to_copy"; string filesToCopyDir = extractDirectory + "/files_to_copy";
// Check if temp folder exists, delete if yes, extract zip to there // Check if temp folder exists, delete if yes, extract zip to there
@ -62,7 +62,7 @@ public abstract class LauncherMods : IMods
// get proper runner // get proper runner
File.Delete(extractDirectory + "/AM2R.xdelta"); File.Delete(extractDirectory + "/AM2R.xdelta");
File.Copy(utilDir + "/windowsRunner.xdelta", extractDirectory + "/AM2R.xdelta"); File.Copy(UtilDir + "/windowsRunner.xdelta", extractDirectory + "/AM2R.xdelta");
// Windows doesn't care about capitalization and because I can't predict how it originally was, I'm going to ignore it. // Windows doesn't care about capitalization and because I can't predict how it originally was, I'm going to ignore it.
@ -91,7 +91,7 @@ public abstract class LauncherMods : IMods
// get proper runner // get proper runner
File.Delete(extractDirectory + "/AM2R.xdelta"); File.Delete(extractDirectory + "/AM2R.xdelta");
File.Copy(utilDir + "/linuxRunner.xdelta", extractDirectory + "/AM2R.xdelta"); File.Copy(UtilDir + "/linuxRunner.xdelta", extractDirectory + "/AM2R.xdelta");
// Linux needs everything lowercased. Only needed if we're coming from Windows // Linux needs everything lowercased. Only needed if we're coming from Windows
if (currentOS == "Windows") if (currentOS == "Windows")
@ -99,9 +99,9 @@ public abstract class LauncherMods : IMods
// Windows doesn't have icon/splash, so we copy them over from here // Windows doesn't have icon/splash, so we copy them over from here
if (!File.Exists(filesToCopyDir + "/icon.png")) if (!File.Exists(filesToCopyDir + "/icon.png"))
File.Copy(utilDir + "/icon.png", filesToCopyDir + "/icon.png"); File.Copy(UtilDir + "/icon.png", filesToCopyDir + "/icon.png");
if (!File.Exists(filesToCopyDir + "/splash.png")) if (!File.Exists(filesToCopyDir + "/splash.png"))
File.Copy(utilDir + "/splash.png", filesToCopyDir + "/splash.png"); File.Copy(UtilDir + "/splash.png", filesToCopyDir + "/splash.png");
// Properly set profile.xml variables // Properly set profile.xml variables
profile.OperatingSystem = "Linux"; profile.OperatingSystem = "Linux";

@ -1,28 +1,28 @@
namespace AM2RPortHelperLib; namespace AM2RPortHelperLib;
public abstract class IMods public abstract class ModsBase
{ {
public delegate void OutputHandlerDelegate(string output); public delegate void OutputHandlerDelegate(string output);
protected static OutputHandlerDelegate outputHandler; protected static OutputHandlerDelegate OutputHandler;
protected static void SendOutput(string output) protected static void SendOutput(string output)
{ {
outputHandler?.Invoke(output); OutputHandler?.Invoke(output);
} }
/// <summary> /// <summary>
/// A temporary directory /// A temporary directory
/// </summary> /// </summary>
protected static readonly string tmp = Path.GetTempPath() + "/PortHelper/"; protected static readonly string TempDir = Path.GetTempPath() + "/PortHelper/";
/// <summary> /// <summary>
/// The current directory of the AM2RPortHelper program. /// The current directory of the AM2RPortHelper program.
/// </summary> /// </summary>
protected static readonly string currentDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); protected static readonly string CurrentDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
/// <summary> /// <summary>
/// The "utils" folder that's shipped with the AM2RPortHelper. /// The "utils" folder that's shipped with the AM2RPortHelper.
/// </summary> /// </summary>
protected static readonly string utilDir = currentDir + "/utils"; protected static readonly string UtilDir = CurrentDir + "/utils";
} }

@ -9,7 +9,7 @@ using static AM2RPortHelperLib.Core;
namespace AM2RPortHelperLib; namespace AM2RPortHelperLib;
public abstract class RawMods : IMods public abstract class RawModsBase : ModsBase
{ {
// For completionist sake, it should be possible to also port raw APKs to win/lin/mac // For completionist sake, it should be possible to also port raw APKs to win/lin/mac
// But until some person actually shows up that needs this feature, I'm too lazy to implement it // But until some person actually shows up that needs this feature, I'm too lazy to implement it
@ -34,10 +34,9 @@ public abstract class RawMods : IMods
private static string GetProperPathToBuiltinIcons(string nameOfResource) private static string GetProperPathToBuiltinIcons(string nameOfResource)
{ {
string subCaseFunction(string resource) string SubCaseFunction(string resource)
{ {
// TODO: default path should be in XDG_CONFIG string origPath = ConfigDir + "/" + resource;
string origPath = utilDir + "/" + resource;
if (File.Exists(origPath)) if (File.Exists(origPath))
return origPath; return origPath;
@ -49,19 +48,19 @@ public abstract class RawMods : IMods
_ => throw new InvalidDataException("SubCaseFunction was called with an improper resource!") _ => throw new InvalidDataException("SubCaseFunction was called with an improper resource!")
}; };
Image.Load(byteArray).SaveAsPng(tmp + "/" + resource); Image.Load(byteArray).SaveAsPng(TempDir + "/" + resource);
origPath = tmp + "/" + resource; origPath = TempDir + "/" + resource;
return origPath; return origPath;
} }
switch (nameOfResource) switch (nameOfResource)
{ {
case nameof(Resources.icon): case nameof(Resources.icon):
return subCaseFunction(nameof(Resources.icon) + ".png"); return SubCaseFunction(nameof(Resources.icon) + ".png");
case nameof(Resources.splash): case nameof(Resources.splash):
return subCaseFunction(nameof(Resources.splash) + ".png"); return SubCaseFunction(nameof(Resources.splash) + ".png");
case nameof(Resources.splashAndroid): case nameof(Resources.splashAndroid):
return subCaseFunction(nameof(Resources.splashAndroid) + ".png"); return SubCaseFunction(nameof(Resources.splashAndroid) + ".png");
default: throw new InvalidDataException(nameOfResource + " is an unknown Icon!"); default: throw new InvalidDataException(nameOfResource + " is an unknown Icon!");
} }
} }
@ -84,8 +83,8 @@ public abstract class RawMods : IMods
return; return;
} }
outputHandler = outputDelegate; OutputHandler = outputDelegate;
string extractDirectory = tmp + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath); string extractDirectory = TempDir + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath);
string assetsDir = extractDirectory + "/assets"; string assetsDir = extractDirectory + "/assets";
// Check if temp folder exists, delete if yes, extract zip to there // Check if temp folder exists, delete if yes, extract zip to there
@ -116,7 +115,7 @@ public abstract class RawMods : IMods
default: throw new NotSupportedException("The OS of the mod zip is unknown and thus not supported"); default: throw new NotSupportedException("The OS of the mod zip is unknown and thus not supported");
} }
File.Copy(utilDir + "/runner", extractDirectory + "/runner"); File.Copy(UtilDir + "/runner", extractDirectory + "/runner");
if (!File.Exists(assetsDir + "/icon.png")) if (!File.Exists(assetsDir + "/icon.png"))
File.Copy(GetProperPathToBuiltinIcons(nameof(Resources.icon)), assetsDir + "/icon.png"); File.Copy(GetProperPathToBuiltinIcons(nameof(Resources.icon)), assetsDir + "/icon.png");
if (!File.Exists(assetsDir + "/splash.png")) if (!File.Exists(assetsDir + "/splash.png"))
@ -130,7 +129,7 @@ public abstract class RawMods : IMods
ZipFile.CreateFromDirectory(extractDirectory, outputRawZipPath); ZipFile.CreateFromDirectory(extractDirectory, outputRawZipPath);
// Clean up // Clean up
Directory.Delete(tmp, true); Directory.Delete(TempDir, true);
} }
public static void PortToAndroid(string inputRawZipPath, string outputRawApkPath, bool useCustomSaveDirectory = false, bool usesInternet = false, OutputHandlerDelegate outputDelegate = null) public static void PortToAndroid(string inputRawZipPath, string outputRawApkPath, bool useCustomSaveDirectory = false, bool usesInternet = false, OutputHandlerDelegate outputDelegate = null)
@ -138,14 +137,14 @@ public abstract class RawMods : IMods
ModOS currentOS = GetModOSOfRawZip(inputRawZipPath); ModOS currentOS = GetModOSOfRawZip(inputRawZipPath);
SendOutput("Zip Recognized as " + currentOS); SendOutput("Zip Recognized as " + currentOS);
outputHandler = outputDelegate; OutputHandler = outputDelegate;
string extractDirectory = tmp + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath); string extractDirectory = TempDir + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath);
string apkDir = extractDirectory + "/apk"; string apkDir = extractDirectory + "/apk";
string apkAssetsDir = apkDir + "/assets"; string apkAssetsDir = apkDir + "/assets";
string bin = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "cmd.exe" : "java"; string bin = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "cmd.exe" : "java";
string args = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "/C java -jar " : "-jar "; string args = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "/C java -jar " : "-jar ";
string apktool = currentDir + "/utils/apktool.jar"; string apktool = CurrentDir + "/utils/apktool.jar";
string signer = currentDir + "/utils/uber-apk-signer.jar"; string signer = CurrentDir + "/utils/uber-apk-signer.jar";
string finalApkBuild = extractDirectory + "/build-aligned-debugSigned.apk"; string finalApkBuild = extractDirectory + "/build-aligned-debugSigned.apk";
// Check if temp folder exists, delete if yes, extract zip to there // Check if temp folder exists, delete if yes, extract zip to there
@ -158,7 +157,7 @@ public abstract class RawMods : IMods
ProcessStartInfo pStartInfo = new ProcessStartInfo ProcessStartInfo pStartInfo = new ProcessStartInfo
{ {
FileName = bin, FileName = bin,
Arguments = args + "\"" + apktool + "\" d -f -o \"" + apkDir + "\" \"" + currentDir + "/utils/AM2RWrapper.apk" + "\"", Arguments = args + "\"" + apktool + "\" d -f -o \"" + apkDir + "\" \"" + UtilDir + "/AM2RWrapper.apk" + "\"",
CreateNoWindow = true CreateNoWindow = true
}; };
Process p = new Process { StartInfo = pStartInfo }; Process p = new Process { StartInfo = pStartInfo };
@ -244,7 +243,7 @@ public abstract class RawMods : IMods
manifestFile = manifestFile.Replace("com.companyname.AM2RWrapper", $"com.companyname.{modName}"); manifestFile = manifestFile.Replace("com.companyname.AM2RWrapper", $"com.companyname.{modName}");
// then in the rest // then in the rest
string AndroidIDReplace(string content, string name) string AndroidIdReplace(string content)
{ {
return content.Replace("com.companyname.AM2RWrapper", $"com.companyname.{modName}") return content.Replace("com.companyname.AM2RWrapper", $"com.companyname.{modName}")
.Replace("com/companyname/AM2RWrapper", $"com/companyname/{modName}") .Replace("com/companyname/AM2RWrapper", $"com/companyname/{modName}")
@ -253,20 +252,20 @@ public abstract class RawMods : IMods
foreach (var file in Directory.GetFiles($"{apkDir}/smali/com/yoyogames/runner")) foreach (var file in Directory.GetFiles($"{apkDir}/smali/com/yoyogames/runner"))
{ {
var content = File.ReadAllText(file); var content = File.ReadAllText(file);
content = AndroidIDReplace(content, modName); content = AndroidIdReplace(content);
File.WriteAllText(file, content); File.WriteAllText(file, content);
} }
var am2rWrapperDir = new DirectoryInfo($"{apkDir}/smali/com/companyname/AM2RWrapper"); var am2rWrapperDir = new DirectoryInfo($"{apkDir}/smali/com/companyname/AM2RWrapper");
foreach (var file in am2rWrapperDir.GetFiles()) foreach (var file in am2rWrapperDir.GetFiles())
{ {
var content = File.ReadAllText(file.FullName); var content = File.ReadAllText(file.FullName);
content = AndroidIDReplace(content, modName); content = AndroidIdReplace(content);
File.WriteAllText(file.FullName, content); File.WriteAllText(file.FullName, content);
} }
am2rWrapperDir.MoveTo($"{apkDir}/smali/com/companyname/{modName}"); am2rWrapperDir.MoveTo($"{apkDir}/smali/com/companyname/{modName}");
var layoutContent = File.ReadAllText($"{apkDir}/res/layout/main.xml"); var layoutContent = File.ReadAllText($"{apkDir}/res/layout/main.xml");
layoutContent = AndroidIDReplace(layoutContent, modName); layoutContent = AndroidIdReplace(layoutContent);
File.WriteAllText($"{apkDir}/res/layout/main.xml", layoutContent); File.WriteAllText($"{apkDir}/res/layout/main.xml", layoutContent);
} }
@ -308,7 +307,7 @@ public abstract class RawMods : IMods
File.Move(finalApkBuild, outputRawApkPath); File.Move(finalApkBuild, outputRawApkPath);
// Clean up // Clean up
Directory.Delete(tmp, true); Directory.Delete(TempDir, true);
} }
public static void PortToMac(string inputRawZipPath, string outputRawZipPath, OutputHandlerDelegate outputDelegate = null) public static void PortToMac(string inputRawZipPath, string outputRawZipPath, OutputHandlerDelegate outputDelegate = null)
@ -323,8 +322,8 @@ public abstract class RawMods : IMods
return; return;
} }
outputHandler = outputDelegate; OutputHandler = outputDelegate;
string baseTempDirectory = tmp + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath); string baseTempDirectory = TempDir + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath);
string extractDirectory = baseTempDirectory + "/extract"; string extractDirectory = baseTempDirectory + "/extract";
string appDirectory = baseTempDirectory + "/AM2R.app"; string appDirectory = baseTempDirectory + "/AM2R.app";
string contentsDir = baseTempDirectory + "/Contents"; string contentsDir = baseTempDirectory + "/Contents";
@ -333,9 +332,9 @@ public abstract class RawMods : IMods
// Check if temp folder exists, delete if yes, copy bare runner to there // Check if temp folder exists, delete if yes, copy bare runner to there
if (Directory.Exists(baseTempDirectory)) if (Directory.Exists(baseTempDirectory))
Directory.Delete(baseTempDirectory, true); Directory.Delete(baseTempDirectory, true);
SendOutput("Copying Runner..."); SendOutput("Copying Mac Runner...");
Directory.CreateDirectory(contentsDir); Directory.CreateDirectory(contentsDir);
HelperMethods.DirectoryCopy(utilDir + "/Contents", contentsDir, true); HelperMethods.DirectoryCopy(UtilDir + "/Contents", contentsDir);
// Extract mod to temp location // Extract mod to temp location
SendOutput("Extracting Mac..."); SendOutput("Extracting Mac...");
@ -380,15 +379,15 @@ public abstract class RawMods : IMods
// TODO: replace this via built-in lib // TODO: replace this via built-in lib
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
bin = "\"" + utilDir + "/UTMTCli/UndertaleModCli.exe\""; bin = "\"" + UtilDir + "/UTMTCli/UndertaleModCli.exe\"";
args = ""; args = "";
} }
else else
{ {
// First chmod the file, just in case // First chmod the file, just in case
Process.Start("chmod", "+x \"" + utilDir + "/UTMTCli/UndertaleModCli.dll\""); Process.Start("chmod", "+x \"" + UtilDir + "/UTMTCli/UndertaleModCli.dll\"");
bin = "dotnet"; bin = "dotnet";
args = "\"" + utilDir + "/UTMTCli/UndertaleModCli.dll\" "; args = "\"" + UtilDir + "/UTMTCli/UndertaleModCli.dll\" ";
// Also chmod the runner. Just in case. // Also chmod the runner. Just in case.
Process.Start("chmod", "+x \"" + contentsDir + "/MacOS/Mac_Runner"); Process.Start("chmod", "+x \"" + contentsDir + "/MacOS/Mac_Runner");
} }
@ -396,7 +395,7 @@ public abstract class RawMods : IMods
ProcessStartInfo pStartInfo = new ProcessStartInfo ProcessStartInfo pStartInfo = new ProcessStartInfo
{ {
FileName = bin, FileName = bin,
Arguments = args + "load \"" + extractDirectory + "/game.ios\" -s \"" + utilDir + "/bc16AndRemoveFunctions.csx\" -o \"" + extractDirectory + "/game.ios\"", Arguments = args + "load \"" + extractDirectory + "/game.ios\" -s \"" + UtilDir + "/bc16AndRemoveFunctions.csx\" -o \"" + extractDirectory + "/game.ios\"",
CreateNoWindow = false CreateNoWindow = false
}; };
Process p = new Process { StartInfo = pStartInfo }; Process p = new Process { StartInfo = pStartInfo };
@ -437,6 +436,6 @@ public abstract class RawMods : IMods
ZipFile.CreateFromDirectory(baseTempDirectory, outputRawZipPath); ZipFile.CreateFromDirectory(baseTempDirectory, outputRawZipPath);
// Clean up // Clean up
Directory.Delete(tmp, true); Directory.Delete(TempDir, true);
} }
} }

@ -26,7 +26,6 @@ public static class Serializer
memStream.Flush(); memStream.Flush();
memStream.Close(); memStream.Close();
memStream.Dispose(); memStream.Dispose();
memStream = null;
return xml; return xml;
} }

Loading…
Cancel
Save