+- todo, add more documentation

mac
Miepee 3 years ago
parent 3d5ae1c313
commit 0bb68316e0

@ -10,6 +10,8 @@ using Eto.Drawing;
namespace AM2RPortHelperGUI; namespace AM2RPortHelperGUI;
public partial class MainForm : Form public partial class MainForm : Form
// TODO: clean GUI
{ {
private readonly string userIconPath = Core.ConfigDir + "/icon.png"; private readonly string userIconPath = Core.ConfigDir + "/icon.png";
private readonly string userSplashPath = Core.ConfigDir + "/splash.png"; private readonly string userSplashPath = Core.ConfigDir + "/splash.png";
@ -114,6 +116,8 @@ public partial class MainForm : Form
buttonEditIcon.Click += ButtonEditIconClick; buttonEditIcon.Click += ButtonEditIconClick;
buttonEditSplash.Click += ButtonEditSplashClick; buttonEditSplash.Click += ButtonEditSplashClick;
} }
// TODO: condense these
private void ButtonEditSplashClick(object sender, EventArgs e) private void ButtonEditSplashClick(object sender, EventArgs e)
{ {
var dialog = new OpenFileDialog(); var dialog = new OpenFileDialog();

@ -11,6 +11,8 @@ using static AM2RPortHelperLib.Core;
namespace AM2RPortHelperLib; namespace AM2RPortHelperLib;
// TODO: rebrand
public abstract class RawMods : ModsBase public abstract class RawMods : ModsBase
{ {
// For completionist sake, it should be possible to also port raw APKs to win/lin/mac // 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
} }
/// <summary> /// <summary>
/// /// Gets the file path of a PNG resource, either from the embedded assembly, or from an overwrite in a specific path.
/// </summary> /// </summary>
/// <param name="nameOfResource"></param> /// <param name="nameOfResource">The name of a resource, without any extension.</param>
/// <param name="userIconPath"></param> /// <param name="userResourcePath">A custom resource path, that should be used instead if it exists.</param>
/// <returns></returns> /// <returns>If <paramref name="userResourcePath"/>exists, it will return that, otherwise an accessible file path to the resource.</returns>
/// <exception cref="InvalidDataException"></exception> /// <exception cref="InvalidDataException"><paramref name="nameOfResource"/> does not exist as an embedded resource.</exception>
public static string GetProperPathToBuiltinIcons(string nameOfResource, string userIconPath) public static string GetProperPathToBuiltinIcons(string nameOfResource, string userResourcePath)
{ {
string SubCaseFunction(string resource) string SubCaseFunction(string resource)
{ {
if (File.Exists(userIconPath)) if (File.Exists(userResourcePath))
return userIconPath; return userResourcePath;
var byteArray = resource switch var byteArray = resource switch
{ {
@ -65,8 +67,8 @@ public abstract class RawMods : ModsBase
if (File.Exists(resPath)) if (File.Exists(resPath))
File.Delete(resPath); File.Delete(resPath);
Image.Load(byteArray).SaveAsPng(resPath); Image.Load(byteArray).SaveAsPng(resPath);
userIconPath = resPath; userResourcePath = resPath;
return userIconPath; return userResourcePath;
} }
switch (nameOfResource) switch (nameOfResource)
@ -424,7 +426,6 @@ public abstract class RawMods : ModsBase
// Convert data.win to BC16 and get rid of not needed functions anymore // Convert data.win to BC16 and get rid of not needed functions anymore
SendOutput("Editing data.win to change ByteCode version and functions..."); SendOutput("Editing data.win to change ByteCode version and functions...");
// TODO: replace this via built-in lib
string modName; string modName;
FileInfo datafile = new FileInfo(extractDirectory + "/game.ios"); FileInfo datafile = new FileInfo(extractDirectory + "/game.ios");
@ -478,6 +479,8 @@ public abstract class RawMods : ModsBase
// Clean up // Clean up
Directory.Delete(TempDir, true); Directory.Delete(TempDir, true);
} }
// TODO: clean this
private static void ChangeToByteCode16(UndertaleData Data) private static void ChangeToByteCode16(UndertaleData Data)
{ {
if (Data is null) return; if (Data is null) return;
@ -485,12 +488,10 @@ public abstract class RawMods : ModsBase
string currentBytecodeVersion = Data?.GeneralInfo.BytecodeVersion.ToString(); string currentBytecodeVersion = Data?.GeneralInfo.BytecodeVersion.ToString();
string game_name = Data.GeneralInfo.Name.Content; string game_name = Data.GeneralInfo.Name.Content;
bool is13 = false;
void ScriptError(string s) => Console.WriteLine(s, ConsoleColor.Red); void ScriptError(string s) => Console.WriteLine(s, ConsoleColor.Red);
void ScriptMessage(string s) => Console.WriteLine(s); 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."); ScriptError("Bytecode 13 is not supported.");
return; return;
@ -507,15 +508,7 @@ public abstract class RawMods : ModsBase
return; return;
} }
if (!(Data.FORM.Chunks.ContainsKey("AGRP"))) if ((Data?.GeneralInfo.BytecodeVersion == 14) || (Data?.GeneralInfo.BytecodeVersion == 15))
{
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) if (Data?.GeneralInfo.BytecodeVersion <= 14)
{ {

Loading…
Cancel
Save