/// <summary> /// look for xstr in each file /// </summary> private void FetchXstr() { List <string> compatibleFiles = FilesList.Where(x => !x.Contains("-lcl.tbm") && !x.Contains("-tlc.tbm") && !x.Contains("strings.tbl")).ToList(); foreach (string file in compatibleFiles) { FileInfo fileInfo = new(file); string fileContent = File.ReadAllText(file); IEnumerable <Match> combinedResults = Utils.GetAllXstrFromFile(fileInfo, fileContent); foreach (Match match in combinedResults) { //match.Groups[0] => entire line //match.Groups[1] => text //match.Groups[2] => id if (int.TryParse(match.Groups[2].Value, out int id)) { string text = match.Groups[1].Value; // if id not existing, add a new line if (id >= 0 && !Lines.Any(x => x.Id == id)) { Lines.Add(new Xstr(id, text, fileInfo)); } // if id already existing but value is different, then put it in another list that will be treated separately else if (ManageDuplicates && (id < 0 || Lines.First(x => x.Id == id).Text != text)) { Duplicates.Add(new Xstr(id, text, fileInfo, match.Value)); } } else { throw new Exception(); } } } int maxProgress = Lines.Count + (ManageDuplicates ? FilesList.Count + Duplicates.Count : 0); Parent.SetMaxProgress(maxProgress); }