Seperate into Lib and CLI

pull/5/head
Miepee 4 years ago
parent d0c3322e04
commit 18316d7fa4

@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31613.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AM2RPortHelper", "AM2RPortHelper\AM2RPortHelper.csproj", "{A630476D-8D81-4178-A742-529ADC1B3E97}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AM2RPortHelperCLI", "AM2RPortHelperCLI\AM2RPortHelperCLI.csproj", "{A630476D-8D81-4178-A742-529ADC1B3E97}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AM2RPortHelperLib", "AM2RPortHelperLib\AM2RPortHelperLib.csproj", "{FB200270-51C9-45FC-BF9C-E9006576D00A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +17,10 @@ Global
{A630476D-8D81-4178-A742-529ADC1B3E97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A630476D-8D81-4178-A742-529ADC1B3E97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A630476D-8D81-4178-A742-529ADC1B3E97}.Release|Any CPU.Build.0 = Release|Any CPU
{FB200270-51C9-45FC-BF9C-E9006576D00A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB200270-51C9-45FC-BF9C-E9006576D00A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB200270-51C9-45FC-BF9C-E9006576D00A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB200270-51C9-45FC-BF9C-E9006576D00A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<RollForward>LatestMajor</RollForward>
<LangVersion>10</LangVersion>
<RootNamespace>AM2RPortHelper</RootNamespace>
</PropertyGroup>
<ItemGroup>
@ -20,4 +21,8 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AM2RPortHelperLib\AM2RPortHelperLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,51 @@
using System;
using System.IO;
using System.Threading;
using AM2RPortHelperLib;
namespace AM2RPortHelper;
internal static class Program
{
private const string version = "1.3";
//TODO: add "-l" flag. transfer launcher mods to each other.
private static void Main(string[] args)
{
Console.WriteLine("AM2RPortHelperCLI v" + version);
if (args == null || args.Length == 0)
{
Console.WriteLine("Please drag-n-drop a Zip of your mod or provide it as an argument.");
return;
}
FileInfo modZipPath = new FileInfo(args[0]);
if (!modZipPath.Exists && modZipPath.Extension.ToLower() != "zip")
{
Console.WriteLine("Path does not point to a mod zip");
return;
}
Console.WriteLine("\n**Make sure to replace the icon.png and splash.png with custom ones if you don't want to have placeholders**\n");
Console.WriteLine("THIS ONLY WORKS FOR MODS BASED ON THE COMMUNITY UPDATES! MODS BASED ON 1.1 WILL NOT WORK!");
Console.WriteLine("To which platform do you want to port to?\n1 - Linux\n2 - Android\n3 - MacOS");
var input = Console.ReadKey().Key.ToString();
Console.WriteLine();
switch (input)
{
case "D1": PortHelper.PortWindowsToLinux(modZipPath); break;
case "D2": PortHelper.PortWindowsToAndroid(modZipPath); break;
case "D3": PortHelper.PortWindowsToMac(modZipPath); break;
default: Console.WriteLine("Unacceptable input. Aborting..."); return;
}
Console.WriteLine("Successfully finished!");
Console.WriteLine("Exiting in 3 seconds...");
Thread.Sleep(3000);
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
</ItemGroup>
</Project>

@ -1,62 +1,19 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using System;
using System.Diagnostics;
using System.IO;
using System.Diagnostics;
using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Threading;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
namespace AM2RPortHelper;
namespace AM2RPortHelperLib;
internal static class Program
public class PortHelper
{
private const string version = "1.3";
private static readonly string tmp = Path.GetTempPath();
private static readonly string currentDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
private static readonly string utilDir = currentDir + "/utils";
//TODO: add "-l" flag. transfer launcher mods to each other.
private static void Main(string[] args)
{
Console.WriteLine("AM2RPortHelper v" + version);
if (args == null || args.Length == 0)
{
Console.WriteLine("Please drag-n-drop a Zip of your mod or provide it as an argument.");
return;
}
FileInfo modZipPath = new FileInfo(args[0]);
if (!modZipPath.Exists && modZipPath.Extension.ToLower() != "zip")
{
Console.WriteLine("Path does not point to a mod zip");
return;
}
Console.WriteLine("\n**Make sure to replace the icon.png and splash.png with custom ones if you don't want to have placeholders**\n");
Console.WriteLine("THIS ONLY WORKS FOR MODS BASED ON THE COMMUNITY UPDATES! MODS BASED ON 1.1 WILL NOT WORK!");
Console.WriteLine("To which platform do you want to port to?\n1 - Linux\n2 - Android\n3 - MacOS");
var input = Console.ReadKey().Key.ToString();
Console.WriteLine();
switch (input)
{
case "D1": PortForLinux(modZipPath); break;
case "D2": PortForAndroid(modZipPath); break;
case "D3": PortForMac(modZipPath); break;
default: Console.WriteLine("Unacceptable input. Aborting..."); return;
}
Console.WriteLine("Successfully finished!");
Console.WriteLine("Exiting in 3 seconds...");
Thread.Sleep(3000);
}
private static void PortForLinux(FileInfo modZipPath)
public static void PortWindowsToLinux(FileInfo modZipPath)
{
string extractDirectory = tmp + "/" + modZipPath.Name;
string assetsDir = extractDirectory + "/assets";
@ -108,7 +65,7 @@ internal static class Program
Directory.Delete(assetsDir, true);
}
private static void PortForAndroid(FileInfo modZipPath)
public static void PortWindowsToAndroid(FileInfo modZipPath)
{
string extractDirectory = tmp + "/" + modZipPath.Name;
string unzipDir = extractDirectory + "/zip";
@ -210,7 +167,8 @@ internal static class Program
// Clean up
Directory.Delete(extractDirectory, true);
}
private static void PortForMac(FileInfo modZipPath)
public static void PortWindowsToMac(FileInfo modZipPath)
{
string baseTempDirectory = tmp + "/" + modZipPath.Name;
string extractDirectory = baseTempDirectory + "/extract";
@ -336,7 +294,7 @@ internal static class Program
LowercaseFolder(subDir.FullName);
}
}
private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
{
// Get the subdirectories for the specified directory.
@ -368,7 +326,7 @@ internal static class Program
DirectoryCopy(subDir.FullName, tempPath, true);
}
}
private static void SaveAndroidIcon(Image icon, int dimensions, string filePath)
{
Image picture = icon;

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Loading…
Cancel
Save