public TreeNode ToTree(int MyIndex, TalkFile talk, PCCObject pcc) { string s = ""; if (Text.Length != 0) { s = Text.Substring(0, Text.Length - 1); } TreeNode res = new TreeNode(MyIndex + " : " + s + " " + talk.findDataById(refText)); TreeNode t = new TreeNode("Reply List"); for (int i = 0; i < ReplyList.Count; i++) { EntryListReplyListStruct e = ReplyList[i]; string par = e.Paraphrase; if (par.Length != 0 && par[par.Length - 1] == '\0') { par = par.Substring(0, par.Length - 1); } t.Nodes.Add(i + " : " + par + " " + e.refParaphrase + " " + talk.findDataById(e.refParaphrase) + " " + e.Index + " " + pcc.getNameEntry(e.CategoryType) + " " + pcc.getNameEntry(e.CategoryValue)); } res.Nodes.Add(t); TreeNode t2 = new TreeNode("Speaker List"); for (int i = 0; i < SpeakerList.Count; i++) { t2.Nodes.Add(i + " : " + SpeakerList[i]); } res.Nodes.Add(t2); res.Nodes.Add("SpeakerIndex : " + SpeakerIndex); res.Nodes.Add("ListenerIndex : " + ListenerIndex); res.Nodes.Add("ConditionalFunc : " + ConditionalFunc); res.Nodes.Add("ConditionalParam : " + ConditionalParam); res.Nodes.Add("StateTransition : " + StateTransition); res.Nodes.Add("StateTransitionParam : " + StateTransitionParam); res.Nodes.Add("ExportID : " + ExportID); res.Nodes.Add("ScriptIndex : " + ScriptIndex); res.Nodes.Add("CameraIntimacy : " + CameraIntimacy); res.Nodes.Add("Skippable : " + Skippable); res.Nodes.Add("FireConditional : " + FireConditional); res.Nodes.Add("Ambient : " + Ambient); res.Nodes.Add("NonTextline : " + NonTextline); res.Nodes.Add("IgnoreBodyGestures : " + IgnoreBodyGestures); res.Nodes.Add("AlwaysHideSubtitle : " + AlwaysHideSubtitle); res.Nodes.Add("Text : " + Text); res.Nodes.Add("refText : " + refText + " " + talk.findDataById(refText)); res.Nodes.Add("GUIStyle : (" + pcc.getNameEntry(GUIStyleType) + ") " + pcc.getNameEntry(GUIStyleValue)); return(res); }
public TreeNode ToTree(int MyIndex, TalkFile talk, PCCObject pcc) { string s = ""; if (Text.Length != 0) s = Text.Substring(0, Text.Length - 1); TreeNode res = new TreeNode(MyIndex + " : " + s + " " + talk.findDataById(refText)); TreeNode t = new TreeNode("Reply List"); for (int i = 0; i < ReplyList.Count; i++) { EntryListReplyListStruct e = ReplyList[i]; string par = e.Paraphrase; if (par.Length != 0 && par[par.Length - 1] == '\0') par = par.Substring(0, par.Length - 1); t.Nodes.Add(i + " : " + par + " " + e.refParaphrase + " " + talk.findDataById(e.refParaphrase) + " " + e.Index + " " + pcc.getNameEntry(e.CategoryType) + " " + pcc.getNameEntry(e.CategoryValue)); } res.Nodes.Add(t); TreeNode t2 = new TreeNode("Speaker List"); for (int i = 0; i < SpeakerList.Count; i++) t2.Nodes.Add(i + " : " + SpeakerList[i]); res.Nodes.Add(t2); res.Nodes.Add("SpeakerIndex : " + SpeakerIndex); res.Nodes.Add("ListenerIndex : " + ListenerIndex); res.Nodes.Add("ConditionalFunc : " + ConditionalFunc); res.Nodes.Add("ConditionalParam : " + ConditionalParam); res.Nodes.Add("StateTransition : " + StateTransition); res.Nodes.Add("StateTransitionParam : " + StateTransitionParam); res.Nodes.Add("ExportID : " + ExportID); res.Nodes.Add("ScriptIndex : " + ScriptIndex); res.Nodes.Add("CameraIntimacy : " + CameraIntimacy); res.Nodes.Add("Skippable : " + Skippable); res.Nodes.Add("FireConditional : " + FireConditional); res.Nodes.Add("Ambient : " + Ambient); res.Nodes.Add("NonTextline : " + NonTextline); res.Nodes.Add("IgnoreBodyGestures : " + IgnoreBodyGestures); res.Nodes.Add("AlwaysHideSubtitle : " + AlwaysHideSubtitle); res.Nodes.Add("Text : " + Text); res.Nodes.Add("refText : " + refText + " " + talk.findDataById(refText)); res.Nodes.Add("GUIStyle : (" + pcc.getNameEntry(GUIStyleType) + ") " + pcc.getNameEntry(GUIStyleValue)); return res; }
public void TestTLKs() { GlobalTest.Init(); Console.WriteLine(@"Testing TLK operations"); var tlksDir = Path.Combine(GlobalTest.FindDirectoryInParentDirectories(GlobalTest.TESTDATA_FOLDER_NAME), "tlk", "me3"); var tlksToTestOn = Directory.GetFiles(tlksDir, "*.tlk", SearchOption.AllDirectories); foreach (var tlk in tlksToTestOn) { TalkFile talkFileMe2 = new TalkFile(); talkFileMe2.LoadTlkData(tlk); var tlkStream = ME3ExplorerCore.TLK.ME2ME3.HuffmanCompression.SaveToTlkStream(talkFileMe2.StringRefs); var reloadedTlk = new TalkFile(); tlkStream.Position = 0; reloadedTlk.LoadTlkDataFromStream(tlkStream); foreach (var v in talkFileMe2.StringRefs) { var fd = reloadedTlk.findDataById(v.StringID); if (fd == "\"Male\"") { continue; //Male/Female, we don't have way to distinguish these } Assert.AreEqual($"\"{v.Data}\"", fd); } } }
public TreeNode ToTree(int MyIndex, TalkFile talk, PCCObject pcc) { string s = ""; if (Text.Length != 0) { s = Text.Substring(0, Text.Length - 1); } TreeNode res = new TreeNode(MyIndex + " : " + s + " " + talk.findDataById(refText)); TreeNode t = new TreeNode("Entry List"); for (int i = 0; i < EntryList.Count; i++) { t.Nodes.Add(i + " : " + EntryList[i]); } res.Nodes.Add(t); res.Nodes.Add("Listener Index : " + ListenerIndex); res.Nodes.Add("Unskippable : " + Unskippable); res.Nodes.Add("IsDefaultAction : " + IsDefaultAction); res.Nodes.Add("IsMajorDecision : " + IsMajorDecision); res.Nodes.Add("ReplyType : (" + pcc.getNameEntry(ReplyTypeType) + ") " + pcc.getNameEntry(ReplyTypeValue)); res.Nodes.Add("Text : " + Text); res.Nodes.Add("refText : " + refText + " " + talk.findDataById(refText)); res.Nodes.Add("ConditionalFunc : " + ConditionalFunc); res.Nodes.Add("ConditionalParam : " + ConditionalParam); res.Nodes.Add("StateTransition : " + StateTransition); res.Nodes.Add("StateTransitionParam : " + StateTransitionParam); res.Nodes.Add("ExportID : " + ExportID); res.Nodes.Add("ScriptIndex : " + ScriptIndex); res.Nodes.Add("CameraIntimacy : " + CameraIntimacy); res.Nodes.Add("FireConditional : " + FireConditional); res.Nodes.Add("Ambient : " + Ambient); res.Nodes.Add("NonTextline : " + NonTextLine); res.Nodes.Add("IgnoreBodyGestures : " + IgnoreBodyGestures); res.Nodes.Add("AlwaysHideSubtitle : " + AlwaysHideSubtitle); res.Nodes.Add("GUIStyle : (" + pcc.getNameEntry(GUIStyleType) + ") " + pcc.getNameEntry(GUIStyleValue)); return(res); }
public TreeNode GenerateNode(PropHeader p) { string s = p.offset.ToString("X4") + " : "; s += "Name: \"" + pcc.getNameEntry(p.name) + "\" "; s += "Type: \"" + pcc.getNameEntry(p.type) + "\" "; s += "Size: " + p.size.ToString() + " Value: "; int propertyType = getType(pcc.getNameEntry(p.type)); switch (propertyType) { case INT_PROPERTY: case OBJECT_PROPERTY: int idx = BitConverter.ToInt32(memory, p.offset + 24); s += idx.ToString(); break; case STRING_PROPERTY: int count = BitConverter.ToInt32(memory, p.offset + 24); s += "\""; for (int i = 0; i < count * -1 - 1; i++) { s += (char)memory[p.offset + 28 + i * 2]; } s += "\""; break; case BOOL_PROPERTY: byte val = memory[p.offset + 24]; s += (val == 1).ToString(); break; case FLOAT_PROPERTY: float f = BitConverter.ToSingle(memory, p.offset + 24); s += f.ToString() + "f"; break; case STRUCT_PROPERTY: case NAME_PROPERTY: idx = BitConverter.ToInt32(memory, p.offset + 24); s += "\"" + pcc.getNameEntry(idx) + "\""; break; case BYTE_PROPERTY: idx = BitConverter.ToInt32(memory, p.offset + 24); int idx2 = BitConverter.ToInt32(memory, p.offset + 32); s += "\"" + pcc.getNameEntry(idx) + "\",\"" + pcc.getNameEntry(idx2) + "\""; break; case ARRAY_PROPERTY: idx = BitConverter.ToInt32(memory, p.offset + 24); s += idx.ToString() + "(count)"; break; case STRINGREF_PROPERTY: idx = BitConverter.ToInt32(memory, p.offset + 24); s += "#" + idx.ToString() + ": "; s += talkFile == null ? "(.tlk not loaded)" : talkFile.findDataById(idx); break; } TreeNode ret = new TreeNode(s); ret.Tag = propertyType; ret.Name = p.offset.ToString(); return(ret); }
public void ScanBasefolder() { string dir = ME3Directory.cookedPath; string[] files = Directory.GetFiles(dir, "*.pcc"); pbar1.Maximum = files.Length - 1; int count = 0; foreach (string file in files) { DebugOutput.PrintLn("Scan file #" + count + " : " + file, count % 10 == 0); try { PCCObject pcc = new PCCObject(file); for (int i = 0; i < pcc.Exports.Count; i++) { if (pcc.Exports[i].ClassName == "BioConversation") { DebugOutput.PrintLn("Found dialog \"" + pcc.Exports[i].ObjectName + "\"", false); BioConversation Dialog = new BioConversation(pcc, i); foreach (BioConversation.EntryListStuct e in Dialog.EntryList) { string text = talkFile.findDataById(e.refText); if (text.Length != 7 && text != "No Data") { EntryStruct t = new EntryStruct(); t.inDLC = false; t.text = text; t.ID = e.refText; t.indexpcc = i; t.pathafc = "";//Todo t.pathdlc = ""; t.pathpcc = file; t.convname = pcc.Exports[i].ObjectName; if (e.SpeakerIndex >= 0 && e.SpeakerIndex < Dialog.SpeakerList.Count) { t.speaker = pcc.getNameEntry(Dialog.SpeakerList[e.SpeakerIndex]); } else { t.speaker = "unknown"; } if (t.speaker == null || t.speaker == "") { t.speaker = "unknown"; } Entries.Add(t); DebugOutput.PrintLn("Requ.: (" + t.speaker + ") " + t.text, false); } } foreach (BioConversation.ReplyListStruct e in Dialog.ReplyList) { string text = talkFile.findDataById(e.refText); if (text.Length != 7 && text != "No Data") { EntryStruct t = new EntryStruct(); t.inDLC = false; t.text = text; t.ID = e.refText; t.indexpcc = i; t.pathafc = "";//Todo t.pathdlc = ""; t.pathpcc = file; t.convname = pcc.Exports[i].ObjectName; Entries.Add(t); DebugOutput.PrintLn("Reply: " + t.text, false); } } } } if (count % 10 == 0) { Application.DoEvents(); pbar1.Value = count; } count++; } catch (Exception ex) { DebugOutput.PrintLn("=====ERROR=====\n" + ex.ToString() + "\n=====ERROR====="); } } }
public TreeNode ToTree(int MyIndex, TalkFile talk, PCCObject pcc) { string s = ""; if (Text.Length != 0) s = Text.Substring(0, Text.Length - 1); TreeNode res = new TreeNode(MyIndex + " : " + s + " " + talk.findDataById(refText)); TreeNode t = new TreeNode("Entry List"); for (int i = 0; i < EntryList.Count; i++) t.Nodes.Add(i + " : " + EntryList[i]); res.Nodes.Add(t); res.Nodes.Add("Listener Index : " + ListenerIndex); res.Nodes.Add("Unskippable : " + Unskippable); res.Nodes.Add("IsDefaultAction : " + IsDefaultAction); res.Nodes.Add("IsMajorDecision : " + IsMajorDecision); res.Nodes.Add("ReplyType : (" + pcc.getNameEntry(ReplyTypeType) + ") " + pcc.getNameEntry(ReplyTypeValue)); res.Nodes.Add("Text : " + Text); res.Nodes.Add("refText : " + refText + " " + talk.findDataById(refText)); res.Nodes.Add("ConditionalFunc : " + ConditionalFunc); res.Nodes.Add("ConditionalParam : " + ConditionalParam); res.Nodes.Add("StateTransition : " + StateTransition); res.Nodes.Add("StateTransitionParam : " + StateTransitionParam); res.Nodes.Add("ExportID : " + ExportID); res.Nodes.Add("ScriptIndex : " + ScriptIndex); res.Nodes.Add("CameraIntimacy : " + CameraIntimacy); res.Nodes.Add("FireConditional : " + FireConditional); res.Nodes.Add("Ambient : " + Ambient); res.Nodes.Add("NonTextline : " + NonTextLine); res.Nodes.Add("IgnoreBodyGestures : " + IgnoreBodyGestures); res.Nodes.Add("AlwaysHideSubtitle : " + AlwaysHideSubtitle); res.Nodes.Add("GUIStyle : (" + pcc.getNameEntry(GUIStyleType) + ") " + pcc.getNameEntry(GUIStyleValue)); return res; }
public TreeNode ToTree(int index, float time, TalkFile tlk) { TreeNode root = new TreeNode(index + ": " + time); root.Nodes.Add("pConversation : " + pConversation); root.Nodes.Add("nLineStrRef : " + tlk.findDataById(nLineStrRef) + " (" + nLineStrRef + ")"); root.Nodes.Add("srActorNameOverride : " + srActorNameOverride); root.Nodes.Add("bForceHideSubtitles : " + bForceHideSubtitles); root.Nodes.Add("bPlaySoundOnly : " + bPlaySoundOnly); root.Nodes.Add("bDisableDelayUntilPreload : " + bDisableDelayUntilPreload); root.Nodes.Add("bAllowInConversation : " + bAllowInConversation); root.Nodes.Add("bSubtitleHasPriority : " + bSubtitleHasPriority); return root; }
public TreeNode ToTree(int index, float time, PCCObject pcc, TalkFile tlk) { TreeNode root = new TreeNode(index + ": " + time); root.Nodes.Add("nStrRefID : " + tlk.findDataById(nStrRefID) + " (" + nStrRefID + ")"); root.Nodes.Add("fLength : " + fLength); root.Nodes.Add("bShowAtTop : " + bShowAtTop); root.Nodes.Add("bUseOnlyAsReplyWheelHint : " + bUseOnlyAsReplyWheelHint); return root; }
public TreeNode GenerateNode(PropHeader p) { string s = p.offset.ToString("X4") + " : "; s += "Name: \"" + pcc.getNameEntry(p.name) + "\" "; s += "Type: \"" + pcc.getNameEntry(p.type) + "\" "; s += "Size: " + p.size.ToString() + " Value: "; int idx = -1; switch (isType(pcc.getNameEntry(p.type))) { case 3: idx = BitConverter.ToInt32(memory, p.offset + 24); s += idx.ToString() + " "; if (idx == 0) { s += "None"; } else { s += pcc.GetClass(idx); } break; case 1: idx = BitConverter.ToInt32(memory, p.offset + 24); s += idx.ToString(); break; case 8: int count = BitConverter.ToInt32(memory, p.offset + 24); s += "\""; if (GameVersion == 1) { for (int i = 0; i < count - 1; i++) { s += (char)memory[p.offset + 28 + i]; } } else { for (int i = 0; i < count * -1 - 1; i++) { s += (char)memory[p.offset + 28 + i * 2]; } } s += "\""; break; case 5: byte val = memory[p.offset + 24]; s += (val == 1).ToString(); break; case 2: float f = BitConverter.ToSingle(memory, p.offset + 24); s += f.ToString() + "f"; break; case 0: case 4: idx = BitConverter.ToInt32(memory, p.offset + 24); s += "\"" + pcc.getNameEntry(idx) + "\""; break; case 6: idx = BitConverter.ToInt32(memory, p.offset + 24); if (GameVersion == 3) { int idx2 = BitConverter.ToInt32(memory, p.offset + 32); s += "\"" + pcc.getNameEntry(idx) + "\",\"" + pcc.getNameEntry(idx2) + "\""; } else if (GameVersion == 2) { s += "\"" + pcc.GetName(idx) + "\""; } break; case 7: idx = BitConverter.ToInt32(memory, p.offset + 24); s += idx.ToString() + "(count)"; break; case 9: idx = BitConverter.ToInt32(memory, p.offset + 24); if (GameVersion == 3) { s += "#" + idx.ToString() + ": "; s += talkFile.findDataById(idx); } else if (GameVersion == 2) { s += "#" + idx.ToString(); } break; } TreeNode ret = new TreeNode(s); ret.Name = p.offset.ToString(); return(ret); }
public void TestTLKs() { GlobalTest.Init(); // Loads compressed packages and attempts to enumerate every object's properties. var tlkDataPath = GlobalTest.GetTestTLKDirectory(); //ME1 var packages = Directory.GetFiles(tlkDataPath, "*.*", SearchOption.AllDirectories) .Where(x => x.RepresentsPackageFilePath()); foreach (var p in packages) { Console.WriteLine($"Opening package {p}"); (MEGame expectedGame, MEPackage.GamePlatform expectedPlatform) = GlobalTest.GetExpectedTypes(p); var package = MEPackageHandler.OpenMEPackage(p, forceLoadFromDisk: true); foreach (var export in package.Exports.Where(x => x.ClassName == "BioTlkFile")) { ME1TalkFile me1Tf = new ME1TalkFile(export); foreach (var stringId in me1Tf.StringRefs) { var expected = stringId.Data; var found = me1Tf.findDataById(stringId.StringID); // Strip single pair of quotes off. Trim() does multiple so if string ends with " it ruins it if (found.StartsWith('\"')) { found = found.Substring(1); } if (found.EndsWith('\"')) { found = found.Substring(0, found.Length - 1); } Assert.AreEqual(string.IsNullOrEmpty(expected) ? "" : expected, found); } } } // ME2/ME3 var tlks = Directory.GetFiles(tlkDataPath, "*.tlk", SearchOption.AllDirectories); foreach (var tlkFilePath in tlks) { // Do not use package caching in tests Debug.WriteLine($"Opening TLK file {tlkFilePath}"); (MEGame expectedGame, MEPackage.GamePlatform expectedPlatform) = GlobalTest.GetExpectedTypes(tlkFilePath); TalkFile tf = new TalkFile(); tf.LoadTlkData(tlkFilePath); foreach (var stringId in tf.StringRefs) { var expected = stringId.Data; var found = tf.findDataById(stringId.StringID); var testcache = found; // Strip single pair of quotes off. Trim() does multiple so if string ends with " it ruins it if (found.StartsWith('\"')) { found = found.Substring(1); } if (found.EndsWith('\"')) { found = found.Substring(0, found.Length - 1); } if (expected == "Female") { continue; //It seems we don't have a way to query female strings. } Assert.AreEqual(string.IsNullOrEmpty(expected) ? "" : expected, found); } } }