Add optional mod name for Android

pull/5/head
Miepee 4 years ago
parent b366566d95
commit 0e629a87ee

@ -20,7 +20,7 @@ internal static class Program
var linuxOption = new Option<FileInfo>(new[] { "-l", "--linux" }, "The output file path for the Linux mod. None given equals to no Linux port."); var linuxOption = new Option<FileInfo>(new[] { "-l", "--linux" }, "The output file path for the Linux mod. None given equals to no Linux port.");
var androidOption = new Option<FileInfo>(new[] { "-a", "--android" }, "The output file path for the Android mod. None given equals to no Android port."); var androidOption = new Option<FileInfo>(new[] { "-a", "--android" }, "The output file path for the Android mod. None given equals to no Android port.");
var macOption = new Option<FileInfo>(new[] { "-m", "--mac" }, "The output file path for the Mac mod. None given equals to no Mac port."); var macOption = new Option<FileInfo>(new[] { "-m", "--mac" }, "The output file path for the Mac mod. None given equals to no Mac port.");
var nameOption = new Option<string>(new[] { "-n", "--name" }, "The name used for the Mac mod. Required for the Mac option, has no effect on anything else."); var nameOption = new Option<string>(new[] { "-n", "--name" }, "The name used for the Mac or Android mod. Required for the Mac option, and optional for the Android version. Has no effect on anything else.");
RootCommand rootCommand = new RootCommand RootCommand rootCommand = new RootCommand
{ {
@ -62,7 +62,7 @@ internal static class Program
} }
if (androidPath is not null) if (androidPath is not null)
{ {
PortHelper.PortWindowsToAndroid(inputModPath.FullName, androidPath.FullName); PortHelper.PortWindowsToAndroid(inputModPath.FullName, androidPath.FullName, string.IsNullOrWhiteSpace(modName) ? null : modName);
} }
if (macPath is not null) if (macPath is not null)
{ {
@ -73,7 +73,7 @@ internal static class Program
} }
PortHelper.PortWindowsToMac(inputModPath.FullName, macPath.FullName, modName); PortHelper.PortWindowsToMac(inputModPath.FullName, macPath.FullName, modName);
} }
Console.WriteLine("Done"); Console.WriteLine("Done.");
} }
private static void RunInteractive() private static void RunInteractive()
{ {

@ -88,7 +88,7 @@ public partial class MainForm : Form
if (checkboxLinux.Checked.Value) if (checkboxLinux.Checked.Value)
await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, OutputHandlerDelegate)); await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, OutputHandlerDelegate));
if (checkboxAndroid.Checked.Value) if (checkboxAndroid.Checked.Value)
await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, OutputHandlerDelegate)); await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, null, OutputHandlerDelegate));
if (checkboxMac.Checked.Value) if (checkboxMac.Checked.Value)
{ {
MessageBox.Show(this, "Currently the mod name is set as \"foo\", you need to manually correct that later! (Search for the files yoyorunner.config and Info.plist"); MessageBox.Show(this, "Currently the mod name is set as \"foo\", you need to manually correct that later! (Search for the files yoyorunner.config and Info.plist");

@ -199,7 +199,7 @@ public static partial class PortHelper
Directory.Delete(assetsDir, true); Directory.Delete(assetsDir, true);
} }
public static void PortWindowsToAndroid(string inputRawZipPath, string outputRawApkPath, OutputHandlerDelegate outputDelegate = null) public static void PortWindowsToAndroid(string inputRawZipPath, string outputRawApkPath, string modName = null, OutputHandlerDelegate outputDelegate = null)
{ {
outputHandler = outputDelegate; outputHandler = outputDelegate;
string extractDirectory = tmp + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath); string extractDirectory = tmp + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath);
@ -265,6 +265,15 @@ public static partial class PortHelper
SaveAndroidIcon(orig, 144, resPath + "/drawable-xxhdpi-v4/icon.png"); SaveAndroidIcon(orig, 144, resPath + "/drawable-xxhdpi-v4/icon.png");
SaveAndroidIcon(orig, 192, resPath + "/drawable-xxxhdpi-v4/icon.png"); SaveAndroidIcon(orig, 192, resPath + "/drawable-xxxhdpi-v4/icon.png");
// If a custom name was given, replace it.
//TODO: handle errors
if (modName != null)
{
string manifestFile = File.ReadAllText(apkDir + "/AndroidManifest.xml");
manifestFile = manifestFile.Replace("com.companyname.AM2RWrapper", "com.companyname." + modName);
File.WriteAllText(apkDir + "/AndroidManifest.xml", manifestFile);
}
// Run APKTOOL and build the apk // Run APKTOOL and build the apk
SendOutput("Rebuild apk..."); SendOutput("Rebuild apk...");
pStartInfo = new ProcessStartInfo pStartInfo = new ProcessStartInfo

Loading…
Cancel
Save