private void Start() { LoadedOfficialTalkFiles = new List <TalkFile>(); MERTalkFiles = new List <TalkFile>(); // Load the basegame TLKs var bgPath = MEDirectories.GetBioGamePath(MERFileSystem.Game); // ME2 specific - ignore ME2Randomizer TLKs, we do not want to modify those var tlkFiles = Directory.GetFiles(bgPath, "*.tlk", SearchOption.AllDirectories); foreach (var tlkFile in tlkFiles) { if (tlkFile.Contains("DLC_440")) // Change if our module number changes { TalkFile tf = new TalkFile(); tf.LoadTlkData(tlkFile); MERTalkFiles.Add(tf); if (tlkFile.Contains("_INT")) { MERTalkFile = tf; } var fname = Path.GetFileNameWithoutExtension(tlkFile); loadedLanguages.Add(fname.Substring(fname.LastIndexOf("_") + 1)); } else { TalkFile tf = new TalkFile(); tf.LoadTlkData(tlkFile); LoadedOfficialTalkFiles.Add(tf); var fname = Path.GetFileNameWithoutExtension(tlkFile); loadedLanguages.Add(fname.Substring(fname.LastIndexOf("_") + 1)); } } }
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 static void LoadTlkData(string fileName) { if (File.Exists(fileName)) { TalkFile tlk = new TalkFile(); tlk.LoadTlkData(fileName); tlkList.Add(tlk); } }
public void InitTalkFile(Object editorTalkFile = null) { if (editorTalkFile == null) { var tlkPath = ME3Directory.cookedPath + "BIOGame_INT.tlk"; talkFile = new TalkFile(); talkFile.LoadTlkData(tlkPath); } else { talkFile = (TalkFile)editorTalkFile; } }
public override void LoadFile(string filepath) { //throw new NotImplementedException(); UnloadExport(); CurrentME2ME3TalkFile = new TalkFile(); CurrentME2ME3TalkFile.LoadTlkData(filepath); LoadedStrings = CurrentME2ME3TalkFile.StringRefs.ToList(); //This is not binded to so reassigning is fine CleanedStrings.ReplaceAll(LoadedStrings.Where(x => x.StringID > 0).ToList()); //remove 0 or null strings. editBox.Text = NO_STRING_SELECTED; //Reset ability to save, reset edit box if export changed. FileModified = false; }
public InterpEditor() { SText.fontcollection = LoadFont("KismetFont.ttf", 8); InitializeComponent(); timeline.Scrollbar = vScrollBar1; timeline.GroupList.ScrollbarH = hScrollBar1; timeline.GroupList.tree1 = treeView1; timeline.GroupList.tree2 = treeView2; BitConverter.IsLittleEndian = true; objects = new List<int>(); talkfile = new TalkFile(); talkfile.LoadTlkData(ME3Directory.cookedPath + "BIOGame_INT.tlk"); }
private void loadAlternateTlkToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog d = new OpenFileDialog(); d.Filter = "*.tlk|*.tlk"; if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (talkfile == null) { talkfile = new TalkFile(); } talkfile.LoadTlkData(d.FileName); timeline.GroupList.Talkfile = talkfile; MessageBox.Show("Done."); } }
public void InitInterpreter(Object editorTalkFile = null) { DynamicByteProvider db = new DynamicByteProvider(pcc.Exports[Index].Data); hb1.ByteProvider = db; memory = pcc.Exports[Index].Data; memsize = memory.Length; // Load the default TLK file into memory. if (editorTalkFile == null) { var tlkPath = ME3Directory.cookedPath + "BIOGame_INT.tlk"; talkFile = new TalkFile(); talkFile.LoadTlkData(tlkPath); } else { talkFile = (TalkFile)editorTalkFile; } }
public void InitInterpreter(Object editorTalkFile = null) { DynamicByteProvider db = new DynamicByteProvider(pcc.Exports[Index].Data); hb1.ByteProvider = db; memory = pcc.Exports[Index].Data; memsize = memory.Length; // Load the default TLK file into memory. if (editorTalkFile == null) { if (ME3Directory.cookedPath != null) { var tlkPath = ME3Directory.cookedPath + "BIOGame_INT.tlk"; talkFile = new TalkFile(); talkFile.LoadTlkData(tlkPath); } } else { talkFile = (TalkFile)editorTalkFile; } }
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); } } }