From 0bb68316e083feace5f9566e7a6dc22a13a318e8 Mon Sep 17 00:00:00 2001 From: Miepee Date: Thu, 19 Jan 2023 18:43:26 +0100 Subject: [PATCH] +- todo, add more documentation --- .../AM2RPortHelperGUI/MainForm.cs | 4 ++ AM2RPortHelperLib/RawMods.cs | 43 ++++++++----------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/AM2RPortHelperGUI/AM2RPortHelperGUI/MainForm.cs b/AM2RPortHelperGUI/AM2RPortHelperGUI/MainForm.cs index 608f557..0cbbf64 100644 --- a/AM2RPortHelperGUI/AM2RPortHelperGUI/MainForm.cs +++ b/AM2RPortHelperGUI/AM2RPortHelperGUI/MainForm.cs @@ -10,6 +10,8 @@ using Eto.Drawing; namespace AM2RPortHelperGUI; public partial class MainForm : Form + +// TODO: clean GUI { private readonly string userIconPath = Core.ConfigDir + "/icon.png"; private readonly string userSplashPath = Core.ConfigDir + "/splash.png"; @@ -114,6 +116,8 @@ public partial class MainForm : Form buttonEditIcon.Click += ButtonEditIconClick; buttonEditSplash.Click += ButtonEditSplashClick; } + + // TODO: condense these private void ButtonEditSplashClick(object sender, EventArgs e) { var dialog = new OpenFileDialog(); diff --git a/AM2RPortHelperLib/RawMods.cs b/AM2RPortHelperLib/RawMods.cs index 3e8358e..1142b67 100644 --- a/AM2RPortHelperLib/RawMods.cs +++ b/AM2RPortHelperLib/RawMods.cs @@ -11,6 +11,8 @@ using static AM2RPortHelperLib.Core; namespace AM2RPortHelperLib; +// TODO: rebrand + public abstract class RawMods : ModsBase { // For completionist sake, it should be possible to also port raw APKs to win/lin/mac @@ -39,18 +41,18 @@ public abstract class RawMods : ModsBase } /// - /// + /// Gets the file path of a PNG resource, either from the embedded assembly, or from an overwrite in a specific path. /// - /// - /// - /// - /// - public static string GetProperPathToBuiltinIcons(string nameOfResource, string userIconPath) + /// The name of a resource, without any extension. + /// A custom resource path, that should be used instead if it exists. + /// If exists, it will return that, otherwise an accessible file path to the resource. + /// does not exist as an embedded resource. + public static string GetProperPathToBuiltinIcons(string nameOfResource, string userResourcePath) { string SubCaseFunction(string resource) { - if (File.Exists(userIconPath)) - return userIconPath; + if (File.Exists(userResourcePath)) + return userResourcePath; var byteArray = resource switch { @@ -65,8 +67,8 @@ public abstract class RawMods : ModsBase if (File.Exists(resPath)) File.Delete(resPath); Image.Load(byteArray).SaveAsPng(resPath); - userIconPath = resPath; - return userIconPath; + userResourcePath = resPath; + return userResourcePath; } switch (nameOfResource) @@ -423,8 +425,7 @@ 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..."); - - // TODO: replace this via built-in lib + string modName; FileInfo datafile = new FileInfo(extractDirectory + "/game.ios"); @@ -478,6 +479,8 @@ public abstract class RawMods : ModsBase // Clean up Directory.Delete(TempDir, true); } + + // TODO: clean this private static void ChangeToByteCode16(UndertaleData Data) { if (Data is null) return; @@ -485,12 +488,10 @@ public abstract class RawMods : ModsBase 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"))) + if (!Data.FORM.Chunks.ContainsKey("AGRP")) { ScriptError("Bytecode 13 is not supported."); return; @@ -506,16 +507,8 @@ public abstract class RawMods : ModsBase 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) || (Data?.GeneralInfo.BytecodeVersion == 15)) { if (Data?.GeneralInfo.BytecodeVersion <= 14) {