diff --git a/pk3DS/Game/GARCReference.cs b/pk3DS/Game/GARCReference.cs index 93c3551..4ce3f3a 100644 --- a/pk3DS/Game/GARCReference.cs +++ b/pk3DS/Game/GARCReference.cs @@ -12,7 +12,7 @@ public class GARCReference public readonly bool LanguageVariant; public string Reference => Path.Combine("a", A.ToString(), B.ToString(), C.ToString()); - public GARCReference(int file, string name, bool lv = false) + private GARCReference(int file, string name, bool lv = false) { Name = name; FileNumber = file; diff --git a/pk3DS/Game/TextReference.cs b/pk3DS/Game/TextReference.cs index d6f413b..afd647d 100644 --- a/pk3DS/Game/TextReference.cs +++ b/pk3DS/Game/TextReference.cs @@ -4,7 +4,7 @@ public class TextReference { public readonly int Index; public readonly string Name; - public TextReference(int index, string name) + private TextReference(int index, string name) { Index = index; Name = name; diff --git a/pk3DS/Game/TextVariableCode.cs b/pk3DS/Game/TextVariableCode.cs index 30022f4..099b4e1 100644 --- a/pk3DS/Game/TextVariableCode.cs +++ b/pk3DS/Game/TextVariableCode.cs @@ -4,7 +4,7 @@ public class TextVariableCode { public readonly int Code; public readonly string Name; - public TextVariableCode(int code, string name) + private TextVariableCode(int code, string name) { Code = code; Name = name; @@ -12,15 +12,156 @@ public TextVariableCode(int code, string name) public static readonly TextVariableCode[] VariableCodes_XY = { - + new TextVariableCode(0xFF00, "COLOR"), + new TextVariableCode(0x0100, "TRNAME"), + new TextVariableCode(0x0101, "PKNAME"), + new TextVariableCode(0x0102, "PKNICK"), + new TextVariableCode(0x0103, "TYPE"), + new TextVariableCode(0x0105, "LOCATION"), + new TextVariableCode(0x0106, "ABILITY"), + new TextVariableCode(0x0107, "MOVE"), + new TextVariableCode(0x0108, "ITEM1"), + new TextVariableCode(0x0109, "ITEM2"), + new TextVariableCode(0x010A, "sTRBAG"), + new TextVariableCode(0x010B, "BOX"), + new TextVariableCode(0x010D, "EVSTAT"), + new TextVariableCode(0x0110, "OPOWER"), + new TextVariableCode(0x0127, "RIBBON"), + new TextVariableCode(0x0134, "MIINAME"), + new TextVariableCode(0x013E, "WEATHER"), + new TextVariableCode(0x0189, "TRNICK"), + new TextVariableCode(0x018A, "1stchrTR"), + new TextVariableCode(0x018B, "SHOUTOUT"), + new TextVariableCode(0x018E, "BERRY"), + new TextVariableCode(0x018F, "REMFEEL"), + new TextVariableCode(0x0190, "REMQUAL"), + new TextVariableCode(0x0191, "WEBSITE"), + new TextVariableCode(0x019C, "CHOICECOS"), + new TextVariableCode(0x01A1, "GSYNCID"), + new TextVariableCode(0x0192, "PRVIDSAY"), + new TextVariableCode(0x0193, "BTLTEST"), + new TextVariableCode(0x0195, "GENLOC"), + new TextVariableCode(0x0199, "CHOICEFOOD"), + new TextVariableCode(0x019A, "HOTELITEM"), + new TextVariableCode(0x019B, "TAXISTOP"), + new TextVariableCode(0x019F, "MAISTITLE"), + new TextVariableCode(0x1000, "ITEMPLUR0"), + new TextVariableCode(0x1001, "ITEMPLUR1"), + new TextVariableCode(0x1100, "GENDBR"), + new TextVariableCode(0x1101, "NUMBRNCH"), + new TextVariableCode(0x1302, "iCOLOR2"), + new TextVariableCode(0x1303, "iCOLOR3"), + new TextVariableCode(0x0200, "NUM1"), + new TextVariableCode(0x0201, "NUM2"), + new TextVariableCode(0x0202, "NUM3"), + new TextVariableCode(0x0203, "NUM4"), + new TextVariableCode(0x0204, "NUM5"), + new TextVariableCode(0x0205, "NUM6"), + new TextVariableCode(0x0206, "NUM7"), + new TextVariableCode(0x0207, "NUM8"), + new TextVariableCode(0x0208, "NUM9"), }; public static readonly TextVariableCode[] VariableCodes_AO = { - + new TextVariableCode(0xFF00, "COLOR"), + new TextVariableCode(0x0100, "TRNAME"), + new TextVariableCode(0x0101, "PKNAME"), + new TextVariableCode(0x0102, "PKNICK"), + new TextVariableCode(0x0103, "TYPE"), + new TextVariableCode(0x0105, "LOCATION"), + new TextVariableCode(0x0106, "ABILITY"), + new TextVariableCode(0x0107, "MOVE"), + new TextVariableCode(0x0108, "ITEM1"), + new TextVariableCode(0x0109, "ITEM2"), + new TextVariableCode(0x010A, "sTRBAG"), + new TextVariableCode(0x010B, "BOX"), + new TextVariableCode(0x010D, "EVSTAT"), + new TextVariableCode(0x0110, "OPOWER"), + new TextVariableCode(0x0127, "RIBBON"), + new TextVariableCode(0x0134, "MIINAME"), + new TextVariableCode(0x013E, "WEATHER"), + new TextVariableCode(0x0189, "TRNICK"), + new TextVariableCode(0x018A, "1stchrTR"), + new TextVariableCode(0x018B, "SHOUTOUT"), + new TextVariableCode(0x018E, "BERRY"), + new TextVariableCode(0x018F, "REMFEEL"), + new TextVariableCode(0x0190, "REMQUAL"), + new TextVariableCode(0x0191, "WEBSITE"), + new TextVariableCode(0x019C, "CHOICECOS"), + new TextVariableCode(0x01A1, "GSYNCID"), + new TextVariableCode(0x0192, "PRVIDSAY"), + new TextVariableCode(0x0193, "BTLTEST"), + new TextVariableCode(0x0195, "GENLOC"), + new TextVariableCode(0x0199, "CHOICEFOOD"), + new TextVariableCode(0x019A, "HOTELITEM"), + new TextVariableCode(0x019B, "TAXISTOP"), + new TextVariableCode(0x019F, "MAISTITLE"), + new TextVariableCode(0x1000, "ITEMPLUR0"), + new TextVariableCode(0x1001, "ITEMPLUR1"), + new TextVariableCode(0x1100, "GENDBR"), + new TextVariableCode(0x1101, "NUMBRNCH"), + new TextVariableCode(0x1302, "iCOLOR2"), + new TextVariableCode(0x1303, "iCOLOR3"), + new TextVariableCode(0x0200, "NUM1"), + new TextVariableCode(0x0201, "NUM2"), + new TextVariableCode(0x0202, "NUM3"), + new TextVariableCode(0x0203, "NUM4"), + new TextVariableCode(0x0204, "NUM5"), + new TextVariableCode(0x0205, "NUM6"), + new TextVariableCode(0x0206, "NUM7"), + new TextVariableCode(0x0207, "NUM8"), + new TextVariableCode(0x0208, "NUM9"), }; public static readonly TextVariableCode[] VariableCodes_SM = { - + new TextVariableCode(0xFF00, "COLOR"), + new TextVariableCode(0x0100, "TRNAME"), + new TextVariableCode(0x0101, "PKNAME"), + new TextVariableCode(0x0102, "PKNICK"), + new TextVariableCode(0x0103, "TYPE"), + new TextVariableCode(0x0105, "LOCATION"), + new TextVariableCode(0x0106, "ABILITY"), + new TextVariableCode(0x0107, "MOVE"), + new TextVariableCode(0x0108, "ITEM1"), + new TextVariableCode(0x0109, "ITEM2"), + new TextVariableCode(0x010A, "sTRBAG"), + new TextVariableCode(0x010B, "BOX"), + new TextVariableCode(0x010D, "EVSTAT"), + new TextVariableCode(0x0110, "OPOWER"), + new TextVariableCode(0x0127, "RIBBON"), + new TextVariableCode(0x0134, "MIINAME"), + new TextVariableCode(0x013E, "WEATHER"), + new TextVariableCode(0x0189, "TRNICK"), + new TextVariableCode(0x018A, "1stchrTR"), + new TextVariableCode(0x018B, "SHOUTOUT"), + new TextVariableCode(0x018E, "BERRY"), + new TextVariableCode(0x018F, "REMFEEL"), + new TextVariableCode(0x0190, "REMQUAL"), + new TextVariableCode(0x0191, "WEBSITE"), + new TextVariableCode(0x019C, "CHOICECOS"), + new TextVariableCode(0x01A1, "GSYNCID"), + new TextVariableCode(0x0192, "PRVIDSAY"), + new TextVariableCode(0x0193, "BTLTEST"), + new TextVariableCode(0x0195, "GENLOC"), + new TextVariableCode(0x0199, "CHOICEFOOD"), + new TextVariableCode(0x019A, "HOTELITEM"), + new TextVariableCode(0x019B, "TAXISTOP"), + new TextVariableCode(0x019F, "MAISTITLE"), + new TextVariableCode(0x1000, "ITEMPLUR0"), + new TextVariableCode(0x1001, "ITEMPLUR1"), + new TextVariableCode(0x1100, "GENDBR"), + new TextVariableCode(0x1101, "NUMBRNCH"), + new TextVariableCode(0x1302, "iCOLOR2"), + new TextVariableCode(0x1303, "iCOLOR3"), + new TextVariableCode(0x0200, "NUM1"), + new TextVariableCode(0x0201, "NUM2"), + new TextVariableCode(0x0202, "NUM3"), + new TextVariableCode(0x0203, "NUM4"), + new TextVariableCode(0x0204, "NUM5"), + new TextVariableCode(0x0205, "NUM6"), + new TextVariableCode(0x0206, "NUM7"), + new TextVariableCode(0x0207, "NUM8"), + new TextVariableCode(0x0208, "NUM9"), }; } } diff --git a/pk3DS/Main.cs b/pk3DS/Main.cs index 8b19f19..9f641e4 100644 --- a/pk3DS/Main.cs +++ b/pk3DS/Main.cs @@ -295,6 +295,7 @@ private bool checkIfRomFS(string path) RomFSPath = path; Config = cfg; + TextFile.Config = cfg; backupGARCs(false, Config.Files.Select(file => file.Name).ToArray()); backupCROs(false, RomFSPath); return true; diff --git a/pk3DS/Tools/TextFile.cs b/pk3DS/Tools/TextFile.cs index b057f92..1f1c37c 100644 --- a/pk3DS/Tools/TextFile.cs +++ b/pk3DS/Tools/TextFile.cs @@ -297,117 +297,24 @@ private static IEnumerable getVariableParameters(string text) } return vals; } + + public static GameConfig Config = new GameConfig(GameVersion.SM); private static ushort getVariableNumber(string variable) { - switch (variable) + var v = Config.getVariableCode(variable); + if (v != null) + return (ushort) v.Code; + + try { - case "COLOR": return 0xFF00; - case "TRNAME": return 0x0100; - case "PKNAME": return 0x0101; - case "PKNICK": return 0x0102; - case "TYPE": return 0x0103; - case "LOCATION": return 0x0105; - case "ABILITY": return 0x0106; - case "MOVE": return 0x0107; - case "ITEM1": return 0x0108; - case "ITEM2": return 0x0109; - case "sTRBAG": return 0x010A; - case "BOX": return 0x010B; - case "EVSTAT": return 0x010D; - case "OPOWER": return 0x0110; - case "RIBBON": return 0x0127; - case "MIINAME": return 0x0134; - case "WEATHER": return 0x013E; - case "TRNICK": return 0x0189; - case "1stchrTR": return 0x018A; - case "SHOUTOUT": return 0x018B; - case "BERRY": return 0x018E; - case "REMFEEL": return 0x018F; - case "REMQUAL": return 0x0190; - case "WEBSITE": return 0x0191; - case "CHOICECOS": return 0x019C; - case "GSYNCID": return 0x01A1; - case "PRVIDSAY": return 0x0192; - case "BTLTEST": return 0x0193; - case "GENLOC": return 0x0195; - case "CHOICEFOOD": return 0x0199; - case "HOTELITEM": return 0x019A; - case "TAXISTOP": return 0x019B; - case "MAISTITLE": return 0x019F; - case "ITEMPLUR0": return 0x1000; - case "ITEMPLUR1": return 0x1001; - case "GENDBR": return 0x1100; - case "NUMBRNCH": return 0x1101; - case "iCOLOR2": return 0x1302; - case "iCOLOR3": return 0x1303; - case "NUM1": return 0x0200; - case "NUM2": return 0x0201; - case "NUM3": return 0x0202; - case "NUM4": return 0x0203; - case "NUM5": return 0x0204; - case "NUM6": return 0x0205; - case "NUM7": return 0x0206; - case "NUM8": return 0x0207; - case "NUM9": return 0x0208; - default: - try { return Convert.ToUInt16(variable, 16); } - catch { throw new ArgumentException($"Variable \"{variable}\" parse error."); } + return Convert.ToUInt16(variable, 16); } + catch { throw new ArgumentException($"Variable \"{variable}\" parse error."); } } private static string getVariableString(ushort variable) { - switch (variable) - { - case 0xFF00: return "COLOR"; // Change text line color (0 = white, 1 = red, 2 = blue...) - case 0x0100: return "TRNAME"; - case 0x0101: return "PKNAME"; - case 0x0102: return "PKNICK"; - case 0x0103: return "TYPE"; - case 0x0105: return "LOCATION"; - case 0x0106: return "ABILITY"; - case 0x0107: return "MOVE"; - case 0x0108: return "ITEM1"; - case 0x0109: return "ITEM2"; - case 0x010A: return "sTRBAG"; - case 0x010B: return "BOX"; - case 0x010D: return "EVSTAT"; - case 0x0110: return "OPOWER"; - case 0x0127: return "RIBBON"; - case 0x0134: return "MIINAME"; - case 0x013E: return "WEATHER"; - case 0x0189: return "TRNICK"; - case 0x018A: return "1stchrTR"; - case 0x018B: return "SHOUTOUT"; - case 0x018E: return "BERRY"; - case 0x018F: return "REMFEEL"; - case 0x0190: return "REMQUAL"; - case 0x0191: return "WEBSITE"; - case 0x019C: return "CHOICECOS"; - case 0x01A1: return "GSYNCID"; - case 0x0192: return "PRVIDSAY"; - case 0x0193: return "BTLTEST"; - case 0x0195: return "GENLOC"; - case 0x0199: return "CHOICEFOOD"; - case 0x019A: return "HOTELITEM"; - case 0x019B: return "TAXISTOP"; - case 0x019F: return "MAISTITLE"; - case 0x1000: return "ITEMPLUR0"; - case 0x1001: return "ITEMPLUR1"; - case 0x1100: return "GENDBR"; - case 0x1101: return "NUMBRNCH"; - case 0x1302: return "iCOLOR2"; - case 0x1303: return "iCOLOR3"; - case 0x0200: return "NUM1"; - case 0x0201: return "NUM2"; - case 0x0202: return "NUM3"; - case 0x0203: return "NUM4"; - case 0x0204: return "NUM5"; - case 0x0205: return "NUM6"; - case 0x0206: return "NUM7"; - case 0x0207: return "NUM8"; - case 0x0208: return "NUM9"; - default: return variable.ToString("X4"); - } + var v = Config.getVariableName(variable); + return v == null ? variable.ToString("X4") : v.Name; } // Exposed Methods