Properly check that linux->linux/mac->mac ports have correct icon/splashes

mac
Miepee 3 years ago
parent b2eff24918
commit 87760abe49

@ -172,22 +172,29 @@ public abstract class RawMods : ModsBase
ModOS currentOS = GetModOSOfRawZip(inputRawZipPath); ModOS currentOS = GetModOSOfRawZip(inputRawZipPath);
outputDelegate.SendOutput("Zip Recognized as " + currentOS); outputDelegate.SendOutput("Zip Recognized as " + currentOS);
if (currentOS == ModOS.Linux)
{
outputDelegate.SendOutput("Zip is already a raw Linux zip. Copying to output directory...");
File.Copy(inputRawZipPath, outputRawZipPath, true);
return;
}
string extractDirectory = TempDir + "/" + 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
if (Directory.Exists(extractDirectory)) if (Directory.Exists(extractDirectory))
Directory.Delete(extractDirectory, true); Directory.Delete(extractDirectory, true);
outputDelegate.SendOutput("Extracting for Raw Linux..."); outputDelegate.SendOutput("Extracting for Raw Linux...");
Directory.CreateDirectory(assetsDir); Directory.CreateDirectory(assetsDir);
if (currentOS == ModOS.Linux)
{
ZipFile.ExtractToDirectory(inputRawZipPath, extractDirectory);
outputDelegate.SendOutput("Zip is already a raw Linux zip. Checking and replacing icons and splashes...");
File.Copy(GetProperPathToBuiltinIcons(nameof(Resources.icon), pathToIcon), assetsDir + "/icon.png", true);
File.Copy(GetProperPathToBuiltinIcons(nameof(Resources.splash), pathToSplashScreen), assetsDir + "/splash.png", true);
outputDelegate.SendOutput("Creating raw Linux zip...");
ZipFile.CreateFromDirectory(extractDirectory, outputRawZipPath);
Directory.Delete(TempDir, true);
return;
}
ZipFile.ExtractToDirectory(inputRawZipPath, assetsDir); ZipFile.ExtractToDirectory(inputRawZipPath, assetsDir);
// Delete unnecessary files, rename data.win, move in the new runner // Delete unnecessary files, rename data.win, move in the new runner
@ -448,13 +455,6 @@ public abstract class RawMods : ModsBase
ModOS currentOS = GetModOSOfRawZip(inputRawZipPath); ModOS currentOS = GetModOSOfRawZip(inputRawZipPath);
outputDelegate.SendOutput("Zip Recognized as " + currentOS); outputDelegate.SendOutput("Zip Recognized as " + currentOS);
if (currentOS == ModOS.Mac)
{
outputDelegate.SendOutput("Zip is already a raw Mac zip. Copying to output dir...");
File.Copy(inputRawZipPath, outputRawZipPath, true);
return;
}
string baseTempDirectory = TempDir + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath); string baseTempDirectory = TempDir + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath);
string extractDirectory = baseTempDirectory + "/extract"; string extractDirectory = baseTempDirectory + "/extract";
@ -471,6 +471,19 @@ public abstract class RawMods : ModsBase
// Extract mod to temp location // Extract mod to temp location
outputDelegate.SendOutput("Extracting Mac..."); outputDelegate.SendOutput("Extracting Mac...");
if (currentOS == ModOS.Mac)
{
ZipFile.ExtractToDirectory(inputRawZipPath, extractDirectory);
outputDelegate.SendOutput("Zip is already a raw Mac zip. Checking and replacing icons and splashes...");
File.Copy(GetProperPathToBuiltinIcons(nameof(Resources.icon), pathToIcon), assetsDir + "/icon.png", true);
File.Copy(GetProperPathToBuiltinIcons(nameof(Resources.splash), pathToSplashScreen), assetsDir + "/splash.png", true);
outputDelegate.SendOutput("Creating raw Mac zip...");
ZipFile.CreateFromDirectory(extractDirectory, outputRawZipPath);
Directory.Delete(TempDir, true);
return;
}
ZipFile.ExtractToDirectory(inputRawZipPath, extractDirectory); ZipFile.ExtractToDirectory(inputRawZipPath, extractDirectory);
// Delete unnecessary files, rename data.win, move in the new runner // Delete unnecessary files, rename data.win, move in the new runner

@ -266,6 +266,36 @@ public class RawModsTests
//Otherwise there should be our stuff //Otherwise there should be our stuff
Assert.True(File.Exists(newExtract + "/assets/" + deepSuffix.ToLower() + origInput.ToLower())); Assert.True(File.Exists(newExtract + "/assets/" + deepSuffix.ToLower() + origInput.ToLower()));
} }
[Theory]
[InlineData("./GameWin.zip")]
[InlineData("./GameLin.zip")]
public void CheckThatLinuxPortHasProperIcons(string inputZip)
{
var outputZip = testTempDir + Guid.NewGuid();
var newExtract = testTempDir + Guid.NewGuid() + "/";
// With default icons
void CheckIconsWithPath(string? path)
{
File.Delete(outputZip);
RawMods.PortToLinux(inputZip, outputZip, path, path);
if (Directory.Exists(newExtract))
Directory.Delete(newExtract, true);
ZipFile.ExtractToDirectory(outputZip, newExtract);
var newIcon = File.ReadAllBytes(newExtract + "/assets/icon.png");
var newSplash = File.ReadAllBytes(newExtract + "/assets/splash.png");
Directory.CreateDirectory(libTempDir);
var oldIcon = File.ReadAllBytes(RawMods.GetProperPathToBuiltinIcons(nameof(Resources.icon), path));
var oldSplash = File.ReadAllBytes(RawMods.GetProperPathToBuiltinIcons(nameof(Resources.splash), path));
Assert.True(newIcon.SequenceEqual(oldIcon));
Assert.True(newSplash.SequenceEqual(oldSplash));
}
CheckIconsWithPath(null);
CheckIconsWithPath(inputZip);
}
#endregion #endregion
@ -372,6 +402,36 @@ public class RawModsTests
Assert.True(File.Exists(newExtract + "/" + appDir.Name + "/Contents/Resources/" + deepSuffix.ToLower() + origInput.ToLower())); Assert.True(File.Exists(newExtract + "/" + appDir.Name + "/Contents/Resources/" + deepSuffix.ToLower() + origInput.ToLower()));
} }
[Theory]
[InlineData("./GameWin.zip")]
[InlineData("./GameLin.zip")]
public void CheckThatMacPortHasProperIcons(string inputZip)
{
var outputZip = testTempDir + Guid.NewGuid();
var newExtract = testTempDir + Guid.NewGuid() + "/";
// With default icons
void CheckIconsWithPath(string? path)
{
File.Delete(outputZip);
RawMods.PortToMac(inputZip, outputZip, path, path);
if (Directory.Exists(newExtract))
Directory.Delete(newExtract, true);
ZipFile.ExtractToDirectory(outputZip, newExtract);
var newIcon = File.ReadAllBytes(newExtract + "/AM2R.app/Contents/Resources/icon.png");
var newSplash = File.ReadAllBytes(newExtract + "/AM2R.app/Contents/Resources/splash.png");
Directory.CreateDirectory(libTempDir);
var oldIcon = File.ReadAllBytes(RawMods.GetProperPathToBuiltinIcons(nameof(Resources.icon), path));
var oldSplash = File.ReadAllBytes(RawMods.GetProperPathToBuiltinIcons(nameof(Resources.splash), path));
Assert.True(newIcon.SequenceEqual(oldIcon));
Assert.True(newSplash.SequenceEqual(oldSplash));
}
CheckIconsWithPath(null);
CheckIconsWithPath(inputZip);
}
#endregion #endregion
#region PortInvalidZips #region PortInvalidZips

Loading…
Cancel
Save