Make Mac Conversion via builtin UMT

mac
Miepee 3 years ago
parent 771a4a88a0
commit 3d5ae1c313

@ -11,6 +11,13 @@ public abstract class ModsBase
OutputHandler?.Invoke(output);
}
// Create before accessing anything
static ModsBase()
{
Directory.CreateDirectory(TempDir);
Directory.CreateDirectory(UtilDir);
}
/// <summary>
/// A temporary directory
/// </summary>

@ -5,6 +5,8 @@ using System.Security;
using System.Text.RegularExpressions;
using SixLabors.ImageSharp;
using UndertaleModLib;
using UndertaleModLib.Decompiler;
using UndertaleModLib.Models;
using static AM2RPortHelperLib.Core;
namespace AM2RPortHelperLib;
@ -58,8 +60,12 @@ public abstract class RawMods : ModsBase
_ => throw new InvalidDataException("SubCaseFunction was called with an improper resource!")
};
Image.Load(byteArray).SaveAsPng(TempDir + "/" + resource);
userIconPath = TempDir + "/" + resource;
string resPath = TempDir + "/" + resource;
if (File.Exists(resPath))
File.Delete(resPath);
Image.Load(byteArray).SaveAsPng(resPath);
userIconPath = resPath;
return userIconPath;
}
@ -392,21 +398,21 @@ public abstract class RawMods : ModsBase
switch (currentOS)
{
case ModOS.Windows:
File.Delete(assetsDir + "/AM2R.exe");
File.Delete(assetsDir + "/D3DX9_43.dll");
File.Move(assetsDir + "/data.win", assetsDir + "/game.ios");
File.Delete(extractDirectory + "/AM2R.exe");
File.Delete(extractDirectory + "/D3DX9_43.dll");
File.Move(extractDirectory + "/data.win", extractDirectory + "/game.ios");
break;
case ModOS.Linux:
File.Delete(assetsDir + "/runner");
HelperMethods.DirectoryCopy(assetsDir + "/assets", assetsDir);
Directory.Delete(assetsDir + "/assets", true);
File.Move(assetsDir + "/game.unx", assetsDir + "/game.ios");
File.Delete(extractDirectory + "/runner");
HelperMethods.DirectoryCopy(extractDirectory + "/assets", extractDirectory);
Directory.Delete(extractDirectory + "/assets", true);
File.Move(extractDirectory + "/game.unx", extractDirectory + "/game.ios");
break;
default: throw new NotSupportedException("The OS of the mod zip is unknown and thus not supported");
}
File.Copy(GetProperPathToBuiltinIcons(nameof(Resources.icon), pathToIcon), extractDirectory + "/icon.png");
File.Copy(GetProperPathToBuiltinIcons(nameof(Resources.splash), pathToSplashScreen), extractDirectory + "/splash.png");
File.Copy(GetProperPathToBuiltinIcons(nameof(Resources.icon), pathToIcon), extractDirectory + "/icon.png", true);
File.Copy(GetProperPathToBuiltinIcons(nameof(Resources.splash), pathToSplashScreen), extractDirectory + "/splash.png", true);
// Delete fonts folder if it exists, because I need to convert bytecode version from game and newer version doesn't support font loading
if (Directory.Exists(extractDirectory + "/lang/fonts"))
@ -417,47 +423,37 @@ public abstract class RawMods : ModsBase
// Convert data.win to BC16 and get rid of not needed functions anymore
SendOutput("Editing data.win to change ByteCode version and functions...");
string bin;
string args;
// TODO: replace this via built-in lib
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
bin = "\"" + UtilDir + "/UTMTCli/UndertaleModCli.exe\"";
args = "";
}
else
string modName;
FileInfo datafile = new FileInfo(extractDirectory + "/game.ios");
// Convert data file to ByteCode 16
{
// First chmod the file, just in case
Process.Start("chmod", "+x \"" + UtilDir + "/UTMTCli/UndertaleModCli.dll\"");
bin = "dotnet";
args = "\"" + UtilDir + "/UTMTCli/UndertaleModCli.dll\" ";
// Also chmod the runner. Just in case.
Process.Start("chmod", "+x \"" + contentsDir + "/MacOS/Mac_Runner");
UndertaleData gmData;
using (FileStream fs = datafile.OpenRead())
{
gmData = UndertaleIO.Read(fs, SendOutput, SendOutput);
modName = gmData.GeneralInfo.DisplayName.Content;
ChangeToByteCode16(gmData);
}
using (FileStream fs = new FileInfo(extractDirectory + "/game.ios").OpenWrite())
{
UndertaleIO.Write(fs, gmData, SendOutput);
}
}
ProcessStartInfo pStartInfo = new ProcessStartInfo
{
FileName = bin,
Arguments = args + "load \"" + extractDirectory + "/game.ios\" -s \"" + UtilDir + "/bc16AndRemoveFunctions.csx\" -o \"" + extractDirectory + "/game.ios\"",
CreateNoWindow = false
};
Process p = new Process { StartInfo = pStartInfo };
p.Start();
p.WaitForExit();
// Also chmod the runner. Just in case.
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Process.Start("chmod", "+x \"" + contentsDir + "/MacOS/Mac_Runner");
// Copy assets to the place where they belong to
SendOutput("Copy files over...");
HelperMethods.DirectoryCopy(extractDirectory, assetsDir);
// Edit config and plist to change display name
string modName;
FileInfo datafile = new FileInfo(extractDirectory + "/game.ios");
using (FileStream fs = datafile.OpenRead())
{
UndertaleData gmData = UndertaleIO.Read(fs, SendOutput, SendOutput);
modName = gmData.GeneralInfo.DisplayName.Content;
}
// Escape invalid xml characters
modName = SecurityElement.Escape(modName);
SendOutput("Editing Runner references to AM2R...");
@ -482,4 +478,171 @@ public abstract class RawMods : ModsBase
// Clean up
Directory.Delete(TempDir, true);
}
private static void ChangeToByteCode16(UndertaleData Data)
{
if (Data is null) return;
string currentBytecodeVersion = Data?.GeneralInfo.BytecodeVersion.ToString();
string game_name = Data.GeneralInfo.Name.Content;
bool is13 = false;
void ScriptError(string s) => Console.WriteLine(s, ConsoleColor.Red);
void ScriptMessage(string s) => Console.WriteLine(s);
if (!(Data.FORM.Chunks.ContainsKey("AGRP")))
{
ScriptError("Bytecode 13 is not supported.");
return;
}
if (Data?.GeneralInfo.BytecodeVersion == 14)
{
ScriptError("Bytecode 14 is not supported.");
return;
}
if (!((Data.GMS2_3 == false) && (Data.GMS2_3_1 == false) && (Data.GMS2_3_2 == false)))
{
ScriptError(game_name + "is GMS 2.3+ and is ineligible");
return;
}
if (!(Data.FORM.Chunks.ContainsKey("AGRP")))
{
is13 = true;
ScriptMessage("Bytecode 13 type game detected. The upgrading of this game is experimental.");
currentBytecodeVersion = "13";
}
if ((Data?.GeneralInfo.BytecodeVersion == 14) || (Data?.GeneralInfo.BytecodeVersion == 15) || (is13 == true))
{
if (Data?.GeneralInfo.BytecodeVersion <= 14)
{
foreach (UndertaleCode code in Data.Code)
{
UndertaleCodeLocals locals = new UndertaleCodeLocals();
locals.Name = code.Name;
UndertaleCodeLocals.LocalVar argsLocal = new UndertaleCodeLocals.LocalVar();
argsLocal.Name = Data.Strings.MakeString("arguments");
argsLocal.Index = 0;
locals.Locals.Add(argsLocal);
code.LocalsCount = 1;
code.GenerateLocalVarDefinitions(code.FindReferencedLocalVars(), locals); // Dunno if we actually need this line, but it seems to work?
Data.CodeLocals.Add(locals);
}
}
if (!(Data.FORM.Chunks.ContainsKey("AGRP")))
{
Data.FORM.Chunks["AGRP"] = new UndertaleChunkAGRP();
var previous = -1;
var j = 0;
for (var i = -1; i < Data.Sounds.Count - 1; i++)
{
UndertaleSound sound = Data.Sounds[i + 1];
bool flagCompressed = sound.Flags.HasFlag(UndertaleSound.AudioEntryFlags.IsCompressed);
bool flagEmbedded = sound.Flags.HasFlag(UndertaleSound.AudioEntryFlags.IsEmbedded);
if (i == -1)
{
if (!flagCompressed && !flagEmbedded)
{
sound.AudioID = -1;
}
else
{
sound.AudioID = 0;
previous = 0;
j = 1;
}
}
else
{
if (!flagCompressed && !flagEmbedded)
sound.AudioID = previous;
else
{
sound.AudioID = j;
previous = j;
j++;
}
}
}
foreach (UndertaleSound sound in Data.Sounds)
{
if ((sound.AudioID >= 0) && (sound.AudioID < Data.EmbeddedAudio.Count))
{
sound.AudioFile = Data.EmbeddedAudio[sound.AudioID];
}
sound.GroupID = 0;
}
Data.GeneralInfo.Build = 1804;
var newProductID = new byte[] { 0xBA, 0x5E, 0xBA, 0x11, 0xBA, 0xDD, 0x06, 0x60, 0xBE, 0xEF, 0xED, 0xBA, 0x0B, 0xAB, 0xBA, 0xBE };
Data.FORM.EXTN.productIdData.Add(newProductID);
Data.Options.Constants.Clear();
Data.Options.Constants.Add(new UndertaleOptions.Constant() { Name = Data.Strings.MakeString("@@SleepMargin"), Value = Data.Strings.MakeString(1.ToString()) });
Data.Options.Constants.Add(new UndertaleOptions.Constant() { Name = Data.Strings.MakeString("@@DrawColour"), Value = Data.Strings.MakeString(0xFFFFFFFF.ToString()) });
}
Data.FORM.Chunks["LANG"] = new UndertaleChunkLANG();
Data.FORM.LANG.Object = new UndertaleLanguage();
Data.FORM.Chunks["GLOB"] = new UndertaleChunkGLOB();
String[] order = { "GEN8", "OPTN", "LANG", "EXTN", "SOND", "AGRP", "SPRT", "BGND", "PATH", "SCPT", "GLOB", "SHDR", "FONT", "TMLN", "OBJT", "ROOM", "DAFL", "TPAG", "CODE", "VARI", "FUNC", "STRG", "TXTR", "AUDO" };
Dictionary<string, UndertaleChunk> newChunks = new Dictionary<string, UndertaleChunk>();
foreach (String name in order)
newChunks[name] = Data.FORM.Chunks[name];
Data.FORM.Chunks = newChunks;
Data.GeneralInfo.BytecodeVersion = 16;
ScriptMessage("Upgraded from " + currentBytecodeVersion + " to 16 successfully. Save the game to apply the changes.");
ScriptMessage("Trying to remove functions \"immersion_play_effect\", \"immersion_stop\" and \"font_replace\"!");
RemoveFunctions();
}
else if (Data?.GeneralInfo.BytecodeVersion == 17)
{
ScriptMessage("Cancelled.");
return;
}
else if (Data?.GeneralInfo.BytecodeVersion == 16)
{
ScriptMessage("This is already bytecode 16.");
ScriptMessage("Trying to remove functions \"immersion_play_effect\", \"immersion_stop\" and \"font_replace\"!");
RemoveFunctions();
return;
}
else
{
string error = @"This game is not bytecode 13,
14, 15, 16, or 17, and is not made in GameMaker 2.3
or greater. Please report this game to Grossley#2869
on Discord and provide the name of the game, where
you obtained it from, and additionally send the
data.win file of the game." + @"
Current status of game '" + game_name + @"':
GMS 2.3 == " + Data.GMS2_3 + @"
GMS 2.3.1 == " + Data.GMS2_3_1 + @"
GMS 2.3.2 == " + Data.GMS2_3_2 + @"
Bytecode == " + (Data?.GeneralInfo.BytecodeVersion);
ScriptError(error);
return;
}
void RemoveFunctions()
{
List<UndertaleFunction> funcsToRemove = new List<UndertaleFunction>();
foreach (UndertaleFunction func in Data.Functions)
{
if (func.ToString() == "immersion_play_effect" || func.ToString() == "immersion_stop" || func.ToString() == "font_replace")
funcsToRemove.Add(func);
}
foreach (var func in funcsToRemove)
Data.Functions.Remove(func);
}
}
}

@ -1,3 +0,0 @@
UTMTCLI version was taken from commit "ba31a5d16eab8b0a84899064fd97f8d0648dfdd8" (tag "v0.4.0.2")
UndertaleModTool (https://github.com/krzys-h/UndertaleModTool) is licensed under GPLv3 just like this project.

@ -1,325 +0,0 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v5.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v5.0": {
"UndertaleModCli/1.0.0": {
"dependencies": {
"Microsoft.CodeAnalysis.CSharp.Scripting": "3.9.0",
"Newtonsoft.Json": "13.0.1",
"System.CommandLine": "2.0.0-beta1.21308.1",
"UndertaleModLib": "1.0.0"
},
"runtime": {
"UndertaleModCli.dll": {}
}
},
"Microsoft.CodeAnalysis.Analyzers/3.0.0": {},
"Microsoft.CodeAnalysis.Common/3.9.0": {
"dependencies": {
"Microsoft.CodeAnalysis.Analyzers": "3.0.0",
"System.Collections.Immutable": "5.0.0",
"System.Memory": "4.5.4",
"System.Reflection.Metadata": "5.0.0",
"System.Runtime.CompilerServices.Unsafe": "5.0.0",
"System.Text.Encoding.CodePages": "4.5.1",
"System.Threading.Tasks.Extensions": "4.5.4"
},
"runtime": {
"lib/netcoreapp3.1/Microsoft.CodeAnalysis.dll": {
"assemblyVersion": "3.9.0.0",
"fileVersion": "3.900.21.12420"
}
}
},
"Microsoft.CodeAnalysis.CSharp/3.9.0": {
"dependencies": {
"Microsoft.CodeAnalysis.Common": "3.9.0"
},
"runtime": {
"lib/netcoreapp3.1/Microsoft.CodeAnalysis.CSharp.dll": {
"assemblyVersion": "3.9.0.0",
"fileVersion": "3.900.21.12420"
}
}
},
"Microsoft.CodeAnalysis.CSharp.Scripting/3.9.0": {
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"Microsoft.CodeAnalysis.CSharp": "3.9.0",
"Microsoft.CodeAnalysis.Common": "3.9.0",
"Microsoft.CodeAnalysis.Scripting.Common": "3.9.0"
},
"runtime": {
"lib/netcoreapp3.1/Microsoft.CodeAnalysis.CSharp.Scripting.dll": {
"assemblyVersion": "3.9.0.0",
"fileVersion": "3.900.21.12420"
}
}
},
"Microsoft.CodeAnalysis.Scripting.Common/3.9.0": {
"dependencies": {
"Microsoft.CodeAnalysis.Common": "3.9.0"
},
"runtime": {
"lib/netcoreapp3.1/Microsoft.CodeAnalysis.Scripting.dll": {
"assemblyVersion": "3.9.0.0",
"fileVersion": "3.900.21.12420"
}
}
},
"Microsoft.CSharp/4.7.0": {},
"Microsoft.NETCore.Platforms/5.0.0": {},
"Microsoft.Win32.SystemEvents/5.0.0": {
"dependencies": {
"Microsoft.NETCore.Platforms": "5.0.0"
},
"runtime": {
"lib/netstandard2.0/Microsoft.Win32.SystemEvents.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.20.51904"
}
},
"runtimeTargets": {
"runtimes/win/lib/netcoreapp3.0/Microsoft.Win32.SystemEvents.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.20.51904"
}
}
},
"Newtonsoft.Json/13.0.1": {
"runtime": {
"lib/netstandard2.0/Newtonsoft.Json.dll": {
"assemblyVersion": "13.0.0.0",
"fileVersion": "13.0.1.25517"
}
}
},
"PropertyChanged.Fody/3.3.3": {
"runtime": {
"lib/netstandard2.1/PropertyChanged.dll": {
"assemblyVersion": "3.3.3.0",
"fileVersion": "3.3.3.0"
}
}
},
"SharpZipLib/1.3.3": {
"runtime": {
"lib/netstandard2.1/ICSharpCode.SharpZipLib.dll": {
"assemblyVersion": "1.3.3.11",
"fileVersion": "1.3.3.11"
}
}
},
"System.Collections.Immutable/5.0.0": {},
"System.CommandLine/2.0.0-beta1.21308.1": {
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Memory": "4.5.4"
},
"runtime": {
"lib/netstandard2.0/System.CommandLine.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.0.21.30801"
}
}
},
"System.Drawing.Common/5.0.2": {
"dependencies": {
"Microsoft.Win32.SystemEvents": "5.0.0"
},
"runtime": {
"lib/netcoreapp3.0/System.Drawing.Common.dll": {
"assemblyVersion": "5.0.0.2",
"fileVersion": "5.0.421.11614"
}
},
"runtimeTargets": {
"runtimes/unix/lib/netcoreapp3.0/System.Drawing.Common.dll": {
"rid": "unix",
"assetType": "runtime",
"assemblyVersion": "5.0.0.2",
"fileVersion": "5.0.421.11614"
},
"runtimes/win/lib/netcoreapp3.0/System.Drawing.Common.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "5.0.0.2",
"fileVersion": "5.0.421.11614"
}
}
},
"System.Memory/4.5.4": {},
"System.Reflection.Metadata/5.0.0": {},
"System.Runtime.CompilerServices.Unsafe/5.0.0": {},
"System.Text.Encoding.CodePages/4.5.1": {
"dependencies": {
"Microsoft.NETCore.Platforms": "5.0.0",
"System.Runtime.CompilerServices.Unsafe": "5.0.0"
}
},
"System.Threading.Tasks.Extensions/4.5.4": {},
"UndertaleModLib/1.0.0": {
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"PropertyChanged.Fody": "3.3.3",
"SharpZipLib": "1.3.3",
"System.Drawing.Common": "5.0.2"
},
"runtime": {
"UndertaleModLib.dll": {}
}
}
}
},
"libraries": {
"UndertaleModCli/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.CodeAnalysis.Analyzers/3.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-ojG5pGAhTPmjxRGTNvuszO3H8XPZqksDwr9xLd4Ae/JBjZZdl6GuoLk7uLMf+o7yl5wO0TAqoWcEKkEWqrZE5g==",
"path": "microsoft.codeanalysis.analyzers/3.0.0",
"hashPath": "microsoft.codeanalysis.analyzers.3.0.0.nupkg.sha512"
},
"Microsoft.CodeAnalysis.Common/3.9.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-HiWjF7PNIEngmFg2Xk8cZ/83lRIRkk9v+5ibbY5B7VvjNGdClGAMuWtZER9F5rGRR41VbJLco9ah73jFTh4vPw==",
"path": "microsoft.codeanalysis.common/3.9.0",
"hashPath": "microsoft.codeanalysis.common.3.9.0.nupkg.sha512"
},
"Microsoft.CodeAnalysis.CSharp/3.9.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-NTsiK3fnoZGemy4dBHrILwg9rL+jDnOJ7aixFu4EOWM1r6MZMrNCIhT2tO4AmIMdfICLPwj910uZRRLpbMnqHg==",
"path": "microsoft.codeanalysis.csharp/3.9.0",
"hashPath": "microsoft.codeanalysis.csharp.3.9.0.nupkg.sha512"
},
"Microsoft.CodeAnalysis.CSharp.Scripting/3.9.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-6Sb2z76TKmgHY/+RHEyb0kFuc0leZyWESd5xx/GePL4wGUHvGtJ+9XoYrWNGfyNJVMtJGEnyCtGr4mMS90fhGw==",
"path": "microsoft.codeanalysis.csharp.scripting/3.9.0",
"hashPath": "microsoft.codeanalysis.csharp.scripting.3.9.0.nupkg.sha512"
},
"Microsoft.CodeAnalysis.Scripting.Common/3.9.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-47scTiU65vHf0qYqNYpjyRKVIjULxXqkMaBWgG+UzRXvvXdI6EZtcllMQu1qAcyC8DU96muhiLn0shNYY+OnTg==",
"path": "microsoft.codeanalysis.scripting.common/3.9.0",
"hashPath": "microsoft.codeanalysis.scripting.common.3.9.0.nupkg.sha512"
},
"Microsoft.CSharp/4.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==",
"path": "microsoft.csharp/4.7.0",
"hashPath": "microsoft.csharp.4.7.0.nupkg.sha512"
},
"Microsoft.NETCore.Platforms/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ==",
"path": "microsoft.netcore.platforms/5.0.0",
"hashPath": "microsoft.netcore.platforms.5.0.0.nupkg.sha512"
},
"Microsoft.Win32.SystemEvents/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Bh6blKG8VAKvXiLe2L+sEsn62nc1Ij34MrNxepD2OCrS5cpCwQa9MeLyhVQPQ/R4Wlzwuy6wMK8hLb11QPDRsQ==",
"path": "microsoft.win32.systemevents/5.0.0",
"hashPath": "microsoft.win32.systemevents.5.0.0.nupkg.sha512"
},
"Newtonsoft.Json/13.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==",
"path": "newtonsoft.json/13.0.1",
"hashPath": "newtonsoft.json.13.0.1.nupkg.sha512"
},
"PropertyChanged.Fody/3.3.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-2dHoq3+Y37J2g06RRyV57zMY9uVOq9JanPienXxineL1pIACCgxn8dL/f6C9I0L1hPvhoipxtP2u9jcSlVsn6Q==",
"path": "propertychanged.fody/3.3.3",
"hashPath": "propertychanged.fody.3.3.3.nupkg.sha512"
},
"SharpZipLib/1.3.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-N8+hwhsKZm25tDJfWpBSW7EGhH/R7EMuiX+KJ4C4u+fCWVc1lJ5zg1u3S1RPPVYgTqhx/C3hxrqUpi6RwK5+Tg==",
"path": "sharpziplib/1.3.3",
"hashPath": "sharpziplib.1.3.3.nupkg.sha512"
},
"System.Collections.Immutable/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==",
"path": "system.collections.immutable/5.0.0",
"hashPath": "system.collections.immutable.5.0.0.nupkg.sha512"
},
"System.CommandLine/2.0.0-beta1.21308.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-X8qLygjyktfmcNMNFekMkumyaTblJmkH3BBbKiQlk4FvJfp613gkMKrA0CNqLUT9tEfLcm3XMzAbsiYFwM8zbQ==",
"path": "system.commandline/2.0.0-beta1.21308.1",
"hashPath": "system.commandline.2.0.0-beta1.21308.1.nupkg.sha512"
},
"System.Drawing.Common/5.0.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-rvr/M1WPf24ljpvvrVd74+NdjRUJu1bBkspkZcnzSZnmAUQWSvanlQ0k/hVHk+cHufZbZfu7vOh/vYc0q5Uu/A==",
"path": "system.drawing.common/5.0.2",
"hashPath": "system.drawing.common.5.0.2.nupkg.sha512"
},
"System.Memory/4.5.4": {
"type": "package",
"serviceable": true,
"sha512": "sha512-1MbJTHS1lZ4bS4FmsJjnuGJOu88ZzTT2rLvrhW7Ygic+pC0NWA+3hgAen0HRdsocuQXCkUTdFn9yHJJhsijDXw==",
"path": "system.memory/4.5.4",
"hashPath": "system.memory.4.5.4.nupkg.sha512"
},
"System.Reflection.Metadata/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==",
"path": "system.reflection.metadata/5.0.0",
"hashPath": "system.reflection.metadata.5.0.0.nupkg.sha512"
},
"System.Runtime.CompilerServices.Unsafe/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==",
"path": "system.runtime.compilerservices.unsafe/5.0.0",
"hashPath": "system.runtime.compilerservices.unsafe.5.0.0.nupkg.sha512"
},
"System.Text.Encoding.CodePages/4.5.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-4J2JQXbftjPMppIHJ7IC+VXQ9XfEagN92vZZNoG12i+zReYlim5dMoXFC1Zzg7tsnKDM7JPo5bYfFK4Jheq44w==",
"path": "system.text.encoding.codepages/4.5.1",
"hashPath": "system.text.encoding.codepages.4.5.1.nupkg.sha512"
},
"System.Threading.Tasks.Extensions/4.5.4": {
"type": "package",
"serviceable": true,
"sha512": "sha512-zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==",
"path": "system.threading.tasks.extensions/4.5.4",
"hashPath": "system.threading.tasks.extensions.4.5.4.nupkg.sha512"
},
"UndertaleModLib/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

@ -1,13 +0,0 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"rollForward": "LatestMajor",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0"
},
"configProperties": {
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
}
}
}

@ -1,185 +0,0 @@
//Upgrade from bytecode 13 (experimental), 14, 15, 17 to 16 - by Grossley
//13 and 14 do not work apparently due to variable issues that I don't know how to fix.
//Need to test this, once I do then I can obsolete the other two scripts
if (!((Data.GMS2_3 == false) && (Data.GMS2_3_1 == false) && (Data.GMS2_3_2 == false)))
{
bool x = RunUMTScript(Path.Combine(ExePath, "HelperScripts", "ConvertFrom17to16_for_2.3.csx"));
if (x == false)
ScriptError("ConvertFrom17to16_for_2.3.csx failed!");
return;
}
EnsureDataLoaded();
string currentBytecodeVersion = Data?.GeneralInfo.BytecodeVersion.ToString();
string game_name = Data.GeneralInfo.Name.Content;
bool is13 = false;
if (!(Data.FORM.Chunks.ContainsKey("AGRP")))
{
/* is13 = true;
ScriptMessage("Bytecode 13 type game detected. The upgrading of this game is experimental.");
currentBytecodeVersion = "13";*/
ScriptError("Bytecode 13 is not supported.");
return;
}
if (Data?.GeneralInfo.BytecodeVersion == 14)
{
ScriptError("Bytecode 14 is not supported.");
return;
}
if (!((Data.GMS2_3 == false) && (Data.GMS2_3_1 == false) && (Data.GMS2_3_2 == false)))
{
ScriptError(game_name + "is GMS 2.3+ and is ineligible", "Ineligible");
return;
}
if (!(Data.FORM.Chunks.ContainsKey("AGRP")))
{
is13 = true;
ScriptMessage("Bytecode 13 type game detected. The upgrading of this game is experimental.");
currentBytecodeVersion = "13";
}
if ((Data?.GeneralInfo.BytecodeVersion == 14) || (Data?.GeneralInfo.BytecodeVersion == 15) || (is13 == true))
{
if (Data?.GeneralInfo.BytecodeVersion <= 14)
{
foreach (UndertaleCode code in Data.Code)
{
UndertaleCodeLocals locals = new UndertaleCodeLocals();
locals.Name = code.Name;
UndertaleCodeLocals.LocalVar argsLocal = new UndertaleCodeLocals.LocalVar();
argsLocal.Name = Data.Strings.MakeString("arguments");
argsLocal.Index = 0;
locals.Locals.Add(argsLocal);
code.LocalsCount = 1;
code.GenerateLocalVarDefinitions(code.FindReferencedLocalVars(), locals); // Dunno if we actually need this line, but it seems to work?
Data.CodeLocals.Add(locals);
}
}
if (!(Data.FORM.Chunks.ContainsKey("AGRP")))
{
Data.FORM.Chunks["AGRP"] = new UndertaleChunkAGRP();
var previous = -1;
var j = 0;
for (var i = -1; i < Data.Sounds.Count - 1; i++)
{
UndertaleSound sound = Data.Sounds[i + 1];
bool flagCompressed = sound.Flags.HasFlag(UndertaleSound.AudioEntryFlags.IsCompressed);
bool flagEmbedded = sound.Flags.HasFlag(UndertaleSound.AudioEntryFlags.IsEmbedded);
if (i == -1)
{
if (!flagCompressed && !flagEmbedded)
{
sound.AudioID = -1;
}
else
{
sound.AudioID = 0;
previous = 0;
j = 1;
}
}
else
{
if (!flagCompressed && !flagEmbedded)
sound.AudioID = previous;
else
{
sound.AudioID = j;
previous = j;
j++;
}
}
}
foreach (UndertaleSound sound in Data.Sounds)
{
if ((sound.AudioID >= 0) && (sound.AudioID < Data.EmbeddedAudio.Count))
{
sound.AudioFile = Data.EmbeddedAudio[sound.AudioID];
}
sound.GroupID = 0;
}
Data.GeneralInfo.Build = 1804;
var newProductID = new byte[] { 0xBA, 0x5E, 0xBA, 0x11, 0xBA, 0xDD, 0x06, 0x60, 0xBE, 0xEF, 0xED, 0xBA, 0x0B, 0xAB, 0xBA, 0xBE };
Data.FORM.EXTN.productIdData.Add(newProductID);
Data.Options.Constants.Clear();
Data.Options.Constants.Add(new UndertaleOptions.Constant() { Name = Data.Strings.MakeString("@@SleepMargin"), Value = Data.Strings.MakeString(1.ToString()) });
Data.Options.Constants.Add(new UndertaleOptions.Constant() { Name = Data.Strings.MakeString("@@DrawColour"), Value = Data.Strings.MakeString(0xFFFFFFFF.ToString()) });
}
Data.FORM.Chunks["LANG"] = new UndertaleChunkLANG();
Data.FORM.LANG.Object = new UndertaleLanguage();
Data.FORM.Chunks["GLOB"] = new UndertaleChunkGLOB();
String[] order = { "GEN8", "OPTN", "LANG", "EXTN", "SOND", "AGRP", "SPRT", "BGND", "PATH", "SCPT", "GLOB", "SHDR", "FONT", "TMLN", "OBJT", "ROOM", "DAFL", "TPAG", "CODE", "VARI", "FUNC", "STRG", "TXTR", "AUDO" };
Dictionary<string, UndertaleChunk> newChunks = new Dictionary<string, UndertaleChunk>();
foreach (String name in order)
newChunks[name] = Data.FORM.Chunks[name];
Data.FORM.Chunks = newChunks;
Data.GeneralInfo.BytecodeVersion = 16;
ScriptMessage("Upgraded from " + currentBytecodeVersion + " to 16 successfully. Save the game to apply the changes.");
ScriptMessage("Trying to remove functions \"immersion_play_effect\", \"immersion_stop\" and \"font_replace\"!");
RemoveFunctions();
}
else if (Data?.GeneralInfo.BytecodeVersion == 17)
{
if (!ScriptQuestion("Downgrade bytecode from 17 to 16?"))
{
ScriptMessage("Cancelled.");
return;
}
Data.GeneralInfo.BytecodeVersion = 16;
if (Data.FORM.Chunks.ContainsKey("TGIN"))
Data.FORM.Chunks.Remove("TGIN");
Data.GMS2_2_2_302 = false;
ScriptMessage("Downgraded from 17 to 16 successfully. Save the game to apply the changes.");
}
else if (Data?.GeneralInfo.BytecodeVersion == 16)
{
ScriptMessage("This is already bytecode 16.");
ScriptMessage("Trying to remove functions \"immersion_play_effect\", \"immersion_stop\" and \"font_replace\"!");
RemoveFunctions();
return;
}
else
{
string error = @"This game is not bytecode 13,
14, 15, 16, or 17, and is not made in GameMaker 2.3
or greater. Please report this game to Grossley#2869
on Discord and provide the name of the game, where
you obtained it from, and additionally send the
data.win file of the game." + @"
Current status of game '" + game_name + @"':
GMS 2.3 == " + Data.GMS2_3.ToString() + @"
GMS 2.3.1 == " + Data.GMS2_3_1.ToString() + @"
GMS 2.3.2 == " + Data.GMS2_3_2.ToString() + @"
Bytecode == " + (Data?.GeneralInfo.BytecodeVersion).ToString();
ScriptError(error, "Unknown game error");
SetUMTConsoleText(error);
SetFinishedMessage(false);
return;
}
void RemoveFunctions()
{
List<UndertaleFunction> funcsToRemove = new List<UndertaleFunction>();
foreach (UndertaleFunction func in Data.Functions)
{
if(func.ToString() == "immersion_play_effect" || func.ToString() == "immersion_stop" || func.ToString() == "font_replace")
funcsToRemove.Add(func);
}
foreach(var func in funcsToRemove)
Data.Functions.Remove(func);
}
Loading…
Cancel
Save