private static void LoadCustomEventsFromFile(int fileName, string regionPackFolder, Conversation self) { CustomWorldMod.Log("~~~LOAD CONVO " + fileName); string file = "Text_" + LocalizationTranslator.LangShort(CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage) + Path.DirectorySeparatorChar + fileName + ".txt"; string convoPath = CRExtras.BuildPath(regionPackFolder, CRExtras.CustomFolder.Text, file: file); if (!File.Exists(convoPath)) { CustomWorldMod.Log("NOT FOUND " + convoPath); return; } string text2 = File.ReadAllText(convoPath, Encoding.Default); if (text2[0] == '0') { CustomWorldMod.EncryptCustomDialogue(CRExtras.BuildPath(regionPackFolder, CRExtras.CustomFolder.Text), regionPackFolder); } else { CustomWorldMod.Log($"Decrypting file [{fileName}] at [{regionPackFolder}] in [{CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage}]"); text2 = Custom.xorEncrypt(text2, (int)(54 + fileName + (int)CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage * 7)); } string[] array = Regex.Split(text2, Environment.NewLine); if (array.Length < 2) { CustomWorldMod.Log($"Corrupted conversation [{array}]", true); } try { if (Regex.Split(array[0], "-")[1] == fileName.ToString()) { CustomWorldMod.Log($"Moon conversation... [{array[1].Substring(0, Math.Min(array[1].Length, 15))}]"); for (int j = 1; j < array.Length; j++) { string[] array3 = Regex.Split(array[j], " : "); if (array3.Length == 1 && array3[0].Length > 0) { self.events.Add(new Conversation.TextEvent(self, 0, array3[0], 0)); } } } else { CustomWorldMod.Log($"Corrupted dialogue file...[{Regex.Split(array[0], "-")[1]}]", true); } } catch { CustomWorldMod.Log("TEXT ERROR"); self.events.Add(new Conversation.TextEvent(self, 0, "TEXT ERROR", 100)); } }
private static void LoadCustomEventsFromFile(int fileName, string customRegion, Conversation self) { CustomWorldMod.Log("~~~LOAD CONVO " + fileName); char div = Path.DirectorySeparatorChar; string convoPath = Custom.RootFolderDirectory() + CustomWorldMod.resourcePath + customRegion + div + "Assets" + div + "Text" + div + "Text_" + LocalizationTranslator.LangShort(CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage) + div + fileName + ".txt"; if (!File.Exists(convoPath)) { CustomWorldMod.Log("NOT FOUND " + convoPath); return; } string text2 = File.ReadAllText(convoPath, Encoding.Default); if (text2[0] == '0') { //Debug.LogError("Tried to encrypt custom text"); //Conversation.EncryptAllDialogue(); CustomWorldMod.EncryptCustomDialogue(Custom.RootFolderDirectory() + CustomWorldMod.resourcePath + customRegion + div, customRegion); } else { CustomWorldMod.Log($"Decrypting file [{fileName}] from [{customRegion}] in [{CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage}]"); text2 = Custom.xorEncrypt(text2, (int)(54 + fileName + (int)CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage * 7)); } string[] array = Regex.Split(text2, Environment.NewLine); if (array.Length < 2) { CustomWorldMod.Log($"Corrupted conversation [{array}]", true); } try { if (Regex.Split(array[0], "-")[1] == fileName.ToString()) { CustomWorldMod.Log($"Moon conversation... [{array[1].Substring(0, Math.Min(array[1].Length, 15))}]"); for (int j = 1; j < array.Length; j++) { string[] array3 = Regex.Split(array[j], " : "); /* * if (array3.Length == 3) * { * self.events.Add(new Conversation.TextEvent(self, int.Parse(array3[0]), array3[2], int.Parse(array3[1]))); * } * else if (array3.Length == 2) * { * if (array3[0] == "SPECEVENT") * { * self.events.Add(new Conversation.SpecialEvent(self, 0, array3[1])); * } * else if (array3[0] == "PEBBLESWAIT") * { * //self.events.Add(new SSOracleBehavior.PebblesConversation.PauseAndWaitForStillEvent(self, null, int.Parse(array3[1]))); * } * } * else*/ if (array3.Length == 1 && array3[0].Length > 0) { self.events.Add(new Conversation.TextEvent(self, 0, array3[0], 0)); } /* * else * { * CustomWorldMod.Log($"Corrupted conversation [{array3[0]}]", true); * } */ } } else { CustomWorldMod.Log($"Corrupted dialogue file...[{Regex.Split(array[0], " - ")[1]}]", true); } } catch { CustomWorldMod.Log("TEXT ERROR"); self.events.Add(new Conversation.TextEvent(self, 0, "TEXT ERROR", 100)); } }
public static void EncryptAllDialogue() { Debug.Log("Encrypt all dialogue"); System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(string.Concat(new object[] { Custom.RootFolderDirectory(), "Assets", System.IO.Path.DirectorySeparatorChar, "Text", System.IO.Path.DirectorySeparatorChar, "Short_Strings", System.IO.Path.DirectorySeparatorChar })); System.IO.FileInfo[] files = directoryInfo.GetFiles(); for (int i = 0; i < files.Length; i++) { if (files[i].Name.Substring(files[i].Name.Length - 4, 4) == ".txt") { int num = int.Parse(files[i].Name.Substring(0, files[i].Name.Length - 4)); string path = string.Concat(new object[] { Custom.RootFolderDirectory(), System.IO.Path.DirectorySeparatorChar, "Assets", System.IO.Path.DirectorySeparatorChar, "Text", System.IO.Path.DirectorySeparatorChar, "Short_Strings", System.IO.Path.DirectorySeparatorChar, files[i].Name }); string text = System.IO.File.ReadAllText(path, System.Text.Encoding.Default); if (text[0] == '0') { string text2 = Custom.xorEncrypt(text, 12467 - num); text2 = '1' + text2.Remove(0, 1); Debug.Log("encrypting short string: " + num); System.IO.File.WriteAllText(path, text2); } } } for (int j = 0; j < System.Enum.GetNames(typeof(InGameTranslator.LanguageID)).Length; j++) { for (int k = 1; k <= 75; k++) { string path = string.Concat(new object[] { Custom.RootFolderDirectory(), "Assets", System.IO.Path.DirectorySeparatorChar, "Text", System.IO.Path.DirectorySeparatorChar, "Text_", LocalizationTranslator.LangShort((InGameTranslator.LanguageID)j), System.IO.Path.DirectorySeparatorChar, k, ".txt" }); if (System.IO.File.Exists(path)) { string text = System.IO.File.ReadAllText(path, System.Text.Encoding.Default); if (text[0] == '0' && Regex.Split(text, System.Environment.NewLine).Length > 1) { /* * int tempK = k; * if (k > 75) * { * tempK = k - 50; * }*/ string text3 = Custom.xorEncrypt(text, 54 + k + j * 7); text3 = '1' + text3.Remove(0, 1); System.IO.File.WriteAllText(path, text3); } } } } }