예제 #1
0
        private void Evt_ExportXML(object sender, RoutedEventArgs e)
        {
            var fnameBase = CurrentLoadedExport?.ObjectName.Name;

            if (fnameBase == null && CurrentLoadedFile != null)
            {
                fnameBase = Path.GetFileNameWithoutExtension(CurrentLoadedFile);
            }
            if (fnameBase == null)
            {
                fnameBase = "TalkFile";
            }
            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                Filter   = "XML Files (*.xml)|*.xml",
                FileName = fnameBase + ".xml"
            };

            if (saveFileDialog.ShowDialog() == true)
            {
                if (CurrentLoadedExport != null)
                {
                    ME1TalkFile talkfile = new ME1TalkFile(CurrentLoadedExport);
                    talkfile.saveToFile(saveFileDialog.FileName);
                }
                else if (CurrentME2ME3TalkFile != null)
                {
                    CurrentME2ME3TalkFile.DumpToFile(saveFileDialog.FileName);
                }
            }
        }
예제 #2
0
 public static void LoadTlkData(string fileName, int index)
 {
     if (File.Exists(fileName))
     {
         IMEPackage  pcc = MEPackageHandler.OpenME1Package(fileName, forceLoadFromDisk: true); //do not cache this in the packages list.
         ME1TalkFile tlk = new ME1TalkFile(pcc, index);
         tlk.LoadTlkData();
         tlkList.Add(tlk);
     }
 }
예제 #3
0
        public override void LoadExport(ExportEntry exportEntry)
        {
            CurrentLoadedFile = null;
            var tlkFile = new ME1TalkFile(exportEntry);                                 // Setup object as TalkFile

            LoadedStrings = tlkFile.StringRefs.ToList();                                //This is not binded to so reassigning is fine
            CleanedStrings.ClearEx();                                                   //clear strings Ex does this in bulk (faster)
            CleanedStrings.AddRange(LoadedStrings.Where(x => x.StringID > 0).ToList()); //nest it remove 0 strings.
            CurrentLoadedExport = exportEntry;
            editBox.Text        = NO_STRING_SELECTED;                                   //Reset ability to save, reset edit box if export changed.
            FileModified        = false;
        }
예제 #4
0
        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);
                }
            }
        }