/// <summary>
 /// Memory cleanup when this control is unloaded
 /// </summary>
 public override void Dispose()
 {
     CurrentLoadedExport   = null;
     CurrentME2ME3TalkFile = null;
     LoadedStrings?.Clear();
     CleanedStrings?.ClearEx();
 }
Пример #2
0
        public void InitTlkManager(PCCObject pcc, BioTlkFileSet tlkSet, TalkFiles tlks = null)
        {
            packages     = new List <PCCObject>();
            tlkFileSets  = new List <BioTlkFileSet>();
            selectedTlks = tlks ?? new TalkFiles();

            packages.Add(pcc);
            refreshFileBox();
            fileBox.SelectedIndex = 0;
            Application.DoEvents();
            for (int i = 0; i < tlkFileSets.Count; i++)
            {
                if (tlkFileSets[i].index == tlkSet.index)
                {
                    bioTlkSetBox.SelectedIndex = i;
                    Application.DoEvents();
                    tlkFileBox.SelectedIndex = tlkSet.selectedTLK;
                    break;
                }
            }
            TalkFile tlk = tlkSet.talkFiles[tlkSet.selectedTLK];

            if (!selectedTlks.tlkList.Contains(tlk))
            {
                selectedTlks.tlkList.Add(tlk);
            }
            foreach (TalkFile tlkFile in selectedTlks.tlkList)
            {
                selectedTlkFilesBox.Items.Add(Path.GetFileName(pcc.fullname) + " -> " + tlkFile.BioTlkSetName + tlkFile.Name);
            }
        }
Пример #3
0
        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);
                }
            }
        }
Пример #4
0
            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);
            }
Пример #5
0
        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));
                }
            }
        }
Пример #6
0
        private void replaceWithFileButton_Click(object sender, EventArgs e)
        {
            int n = tlkFileBox.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            TalkFile           tlk        = tlkFileSets[bioTlkSetBox.SelectedIndex].talkFiles[n];
            HuffmanCompression compressor = new HuffmanCompression();

            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.xml|*.xml";
            if (d.ShowDialog() == DialogResult.OK)
            {
                compressor.LoadInputData(d.FileName);
                compressor.replaceTlkwithFile(tlk.pcc, tlk.index);
                MessageBox.Show("Done");
            }
            n = packages.FindIndex(x => tlk.pcc.pccFileName == x.pccFileName);
            packages.RemoveAt(n);
            packages.Insert(n, new PCCObject(tlk.pcc.pccFileName));
            refreshFileBox();
        }
Пример #7
0
 public static void LoadTlkData(string fileName)
 {
     if (File.Exists(fileName))
     {
         TalkFile tlk = new TalkFile();
         tlk.LoadTlkData(fileName);
         tlkList.Add(tlk);
     }
 }
Пример #8
0
        private static void RandomizeVowelsInternal(TalkFile tf, List <int> skipIDs, Dictionary <char, char> translationMap, bool isMERTlk, RandomizationOption option)
        {
            var tfName   = Path.GetFileNameWithoutExtension(tf.path);
            var langCode = tfName.Substring(tfName.LastIndexOf("_", StringComparison.InvariantCultureIgnoreCase) + 1);

            foreach (var sref in tf.StringRefs.Where(x => x.StringID > 0 && !string.IsNullOrWhiteSpace(x.Data)).ToList())
            {
                option.IncrementProgressValue();

                if (sref.Data.Contains("DLC_"))
                {
                    continue;                             // Don't modify
                }
                if (!isMERTlk && skipIDs.Contains(sref.StringID))
                {
                    continue; // Do not randomize this version of the string as it's in the DLC version specifically
                }
                // See if strref has CUSTOMTOKEN or a control symbol
                List <int> skipRanges = new List <int>();
                FindSkipRanges(sref, skipRanges);

                var newStr = sref.Data.ToArray();
                for (int i = 0; i < sref.Data.Length; i++) // For every letter
                {
                    // Skip any items we should not skip.
                    if (skipRanges.Any() && skipRanges[0] == i)
                    {
                        i = skipRanges[1] - 1;  // We subtract one as the next iteration of the loop will +1 it again, which then will make it read the 'next' character
                        skipRanges.RemoveAt(0); // remove first 2
                        skipRanges.RemoveAt(0); // remove first 2

                        if (i >= sref.Data.Length - 1)
                        {
                            break;
                        }
                        continue;
                    }

                    if (translationMap.ContainsKey(newStr[i]))
                    {
                        // Remap the letter
                        newStr[i] = translationMap[newStr[i]];
                    }
                    else
                    {
                        // Do not change the letter. It might be something like <.
                    }

                    TLKHandler.ReplaceString(sref.StringID, new string(newStr), langCode);
                }
            }
        }
        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;
        }
Пример #10
0
 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");
 }
Пример #11
0
 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;
     }
 }
Пример #12
0
 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;
     }
 }
Пример #13
0
 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;
 }
Пример #14
0
        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.");
            }
        }
Пример #15
0
        private void addToSelectedTlks()
        {
            int n = tlkFileBox.SelectedIndex;

            if (n == -1 || editor)
            {
                return;
            }
            TalkFile tlk = tlkFileSets[bioTlkSetBox.SelectedIndex].talkFiles[n];

            if (!selectedTlks.tlkList.Contains(tlk))
            {
                selectedTlks.tlkList.Add(tlk);
                selectedTlkFilesBox.Items.Add(Path.GetFileName(tlk.pcc.fullname) + " -> " + tlkFileSets[bioTlkSetBox.SelectedIndex].Name + tlk.Name);
            }
        }
Пример #16
0
        private void Commit()
        {
            // Write out the TLKs
            Parallel.ForEach(MERTalkFiles, tf =>
            {
                if (tf.IsModified)
                {
                    HuffmanCompression hc = new HuffmanCompression();
                    hc.LoadInputData(tf.StringRefs);
                    hc.SaveToFile(tf.path);
                }
            });

            // Free memory
            MERTalkFile             = null;
            MERTalkFiles            = null;
            LoadedOfficialTalkFiles = null;
        }
Пример #17
0
        private void downButton_Click(object sender, EventArgs e)
        {
            int n = selectedTlkFilesBox.SelectedIndex;

            if (n == -1 || n >= selectedTlkFilesBox.Items.Count - 1)
            {
                return;
            }
            TalkFile tlk     = selectedTlks.tlkList[n];
            string   tlkPath = selectedTlkFilesBox.Items[n] as string;

            selectedTlks.tlkList.RemoveAt(n);
            selectedTlks.tlkList.Insert(n + 1, tlk);

            selectedTlkFilesBox.Items.RemoveAt(n);
            selectedTlkFilesBox.Items.Insert(n + 1, tlkPath);
            selectedTlkFilesBox.SelectedIndex = n + 1;
        }
Пример #18
0
        private void upButton_Click(object sender, EventArgs e)
        {
            int n = selectedTlkFilesBox.SelectedIndex;

            if (n <= 0)
            {
                return;
            }
            TalkFile tlk     = selectedTlks.tlkList[n];
            string   tlkPath = selectedTlkFilesBox.Items[n] as string;

            selectedTlks.tlkList.RemoveAt(n);
            selectedTlks.tlkList.Insert(n - 1, tlk);

            selectedTlkFilesBox.Items.RemoveAt(n);
            selectedTlkFilesBox.Items.Insert(n - 1, tlkPath);
            selectedTlkFilesBox.SelectedIndex = n - 1;
        }
Пример #19
0
        private void saveToFile()
        {
            int n = tlkFileBox.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            TalkFile tlk = tlkFileSets[bioTlkSetBox.SelectedIndex].talkFiles[n];

            SaveFileDialog d = new SaveFileDialog();

            d.Filter = "*.xml|*.xml";
            if (d.ShowDialog() == DialogResult.OK)
            {
                tlk.saveToFile(d.FileName);
                MessageBox.Show("Done");
            }
        }
Пример #20
0
        private void fileBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            bioTlkSetBox.Items.Clear();
            tlkFileBox.Items.Clear();
            int n = fileBox.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            ME1Package pcc = packages[n];

            tlkFileSets.Clear();
            IReadOnlyList <IExportEntry> Exports = pcc.Exports;

            for (int i = 0; i < Exports.Count; i++)
            {
                if (Exports[i].ClassName == "BioTlkFileSet")
                {
                    BioTlkFileSet b = new BioTlkFileSet(pcc, i);
                    tlkFileSets.Add(b);
                    bioTlkSetBox.Items.Add(b.Name);
                }
            }
            //No BioTlkSets, look for loose BioTlkFiles
            if (tlkFileSets.Count == 0)
            {
                BioTlkFileSet tlkSet = new BioTlkFileSet(pcc);
                for (int i = 0; i < Exports.Count; i++)
                {
                    if (Exports[i].ClassName == "BioTlkFile")
                    {
                        TalkFile tlk = new TalkFile(pcc, i);
                        tlkSet.talkFiles.Add(tlk);
                    }
                }
                if (tlkSet.talkFiles.Count != 0)
                {
                    tlkFileSets.Add(tlkSet);
                    bioTlkSetBox.Items.Add("Misc TlkFiles");
                }
            }
        }
Пример #21
0
 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;
     }
 }
Пример #22
0
            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);
            }
Пример #23
0
        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;
            }
        }
Пример #24
0
 private void fileBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     bioTlkSetBox.Items.Clear();
     tlkFileBox.Items.Clear();
     int n = fileBox.SelectedIndex;
     if (n == -1)
     {
         return;
     }
     ME1Package pcc = packages[n];
     tlkFileSets.Clear();
     IReadOnlyList<IExportEntry> Exports = pcc.Exports;
     for (int i = 0; i < Exports.Count; i++)
     {
         if(Exports[i].ClassName == "BioTlkFileSet")
         {
             BioTlkFileSet b = new BioTlkFileSet(pcc, i);
             tlkFileSets.Add(b);
             bioTlkSetBox.Items.Add(b.Name);
         }
     }
     //No BioTlkSets, look for loose BioTlkFiles
     if(tlkFileSets.Count == 0)
     {
         BioTlkFileSet tlkSet = new BioTlkFileSet(pcc);
         for (int i = 0; i < Exports.Count; i++)
         {
             if (Exports[i].ClassName == "BioTlkFile")
             {
                 TalkFile tlk = new TalkFile(pcc, i);
                 tlkSet.talkFiles.Add(tlk);
             }
         }
         if (tlkSet.talkFiles.Count != 0)
         {
             tlkFileSets.Add(tlkSet);
             bioTlkSetBox.Items.Add("Misc TlkFiles");
         }
     }
 }
Пример #25
0
        private static void UwuifyTalkFile(TalkFile tf, bool keepCasing, bool addReactions, List <int> skipIDs, bool isMERTlk, RandomizationOption option)
        {
            var tfName   = Path.GetFileNameWithoutExtension(tf.path);
            var langCode = tfName.Substring(tfName.LastIndexOf("_", StringComparison.InvariantCultureIgnoreCase) + 1);

            if (langCode != "INT")
            {
                return;
            }
            foreach (var sref in tf.StringRefs.Where(x => x.StringID > 0 && !string.IsNullOrWhiteSpace(x.Data)))
            {
                option.IncrementProgressValue();

                var strData = sref.Data;

                //strData = "New Game";
                if (strData.Contains("DLC_"))
                {
                    continue;                           // Don't modify
                }
                if (!isMERTlk && skipIDs.Contains(sref.StringID))
                {
                    continue; // Do not randomize this version of the string as it's in the DLC version specifically
                }

                //if (sref.StringID != 325648)
                //    continue;
                // See if strref has CUSTOMTOKEN or a control symbol
                List <int> skipRanges = new List <int>();
                FindSkipRanges(sref, skipRanges);
                // uwuify it
                StringBuilder sb           = new StringBuilder();
                char          previousChar = (char)0x00;
                char          currentChar;
                for (int i = 0; i < strData.Length; i++)
                {
                    if (skipRanges.Any() && skipRanges[0] == i)
                    {
                        sb.Append(strData.Substring(skipRanges[0], skipRanges[1] - skipRanges[0]));
                        previousChar = (char)0x00;
                        i            = skipRanges[1] - 1; // We subtract one as the next iteration of the loop will +1 it again, which then will make it read the 'next' character
                        skipRanges.RemoveAt(0);           // remove first 2
                        skipRanges.RemoveAt(0);           // remove first 2

                        if (i >= strData.Length - 1)
                        {
                            break;
                        }
                        continue;
                    }

                    currentChar = strData[i];
                    if (currentChar == 'L' || currentChar == 'R')
                    {
                        sb.Append(keepCasing ? 'W' : 'w');
                    }
                    else if (currentChar == 'l' || currentChar == 'r')
                    {
                        sb.Append('w');
                        if (ThreadSafeRandom.Next(5) == 0)
                        {
                            sb.Append('w'); // append another w 20% of the time
                            if (ThreadSafeRandom.Next(8) == 0)
                            {
                                sb.Append('w'); // append another w 20% of the time
                            }
                        }
                    }
                    else if (currentChar == 'N' && (previousChar == 0x00 || previousChar == ' '))
                    {
                        sb.Append(keepCasing ? "Nyaa" : "nyaa");
                    }
                    else if (currentChar == 'O' || currentChar == 'o')
                    {
                        if (previousChar == 'N' || previousChar == 'n' ||
                            previousChar == 'M' || previousChar == 'm')
                        {
                            sb.Append("yo");
                        }
                        else
                        {
                            sb.Append(keepCasing ? strData[i] : char.ToLower(strData[i]));
                        }
                    }
                    else if (currentChar == '!' && !addReactions)
                    {
                        sb.Append(currentChar);
                        if (ThreadSafeRandom.Next(2) == 0)
                        {
                            sb.Append(currentChar); // append another ! 50% of the time
                        }
                    }
                    else
                    {
                        sb.Append(keepCasing ? strData[i] : char.ToLower(strData[i]));
                    }

                    previousChar = currentChar;
                }

                var str = sb.ToString();

                if (addReactions)
                {
                    str = AddReactionToLine(strData, str, keepCasing);
                }
                else
                {
                    str = str.Replace("f**k", keepCasing ? "UwU" : "uwu", StringComparison.InvariantCultureIgnoreCase);
                }

                TLKHandler.ReplaceString(sref.StringID, str, langCode);
            }
        }
Пример #26
0
 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;
 }
Пример #27
0
 private void loadDifferentTLKToolStripMenuItem_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);
         MessageBox.Show("Done.");
     }
 }
Пример #28
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);
                }
            }
        }
Пример #29
0
 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;
 }
Пример #30
0
 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;
 }