//Fetch all title information etc yada yada yada blalblabla private void btnTitles_Click(object sender, EventArgs e) { WorkerArguments wa=new WorkerArguments(); wa.t=Task.DownloadData; SetBusyGUI(); backgroundWorker1.RunWorkerAsync(wa); }
private void UpdateList(bool clear) { lstEntries.ClearObjects(); SetBusyGUI(); progressBar1.Visible = false; lblFileListingProgress.Visible = true; WorkerArguments wa = new WorkerArguments(); wa.t = Task.OpenDirectory; wa.args = new object[] { clear }; backgroundWorker1.RunWorkerAsync(wa); }
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { SetIdleGUI(); if (LastTask == Task.OpenDirectory) { if (!e.Cancelled) { FillListView(); } else { InfoEntryManager.Instance.Clear(); } UpdateGUI(); } else if (LastTask == Task.DownloadData && !e.Cancelled) { ShownameSearch ss = new ShownameSearch(DataGenerator.Results); if (ss.ShowDialog(Form1.Instance) == DialogResult.OK) { DataGenerator.Results = ss.Results; foreach (DataGenerator.ParsedSearch ps in DataGenerator.Results) { if (ps.SearchString != ps.Showname) { if (MessageBox.Show("Rename " + ps.Showname + " to " + ps.SearchString + "?", "Apply new Showname", MessageBoxButtons.YesNo) == DialogResult.Yes) { InfoEntryManager.Instance.RenameShow(ps.Showname, ps.SearchString); } } if (ps.Results != null && ps.Results.Count > 0) { //get rid of old relations RelationManager.Instance.RemoveRelationCollection(ps.Showname); foreach (InfoEntry ie in InfoEntryManager.Instance) { if (ie.Showname == ps.Showname && ie.ProcessingRequested) { ie.Name = ""; ie.NewFilename = ""; ie.Language = ps.provider.Language; } } } } WorkerArguments wa = new WorkerArguments(); wa.t = Task.CreateRelations; SetBusyGUI(); backgroundWorker1.RunWorkerAsync(wa); } } else if (LastTask == Task.CreateRelations && e.Cancelled) { RelationManager.Instance.Clear(); } FillListView(); }
private void BWorker_DoWork(object sender, DoWorkEventArgs e) { WorkerArguments args = e.Argument as WorkerArguments; if (args == null) { throw new InvalidOperationException("Something went wrong, this is out of design."); } var fileinfo = args.TranslationResource.GetCurrentLanguageFile(); string currentLanguage = args.TranslationResource.SelectedLanguage, currentRegion = args.TranslationResource.SelectedClientRegion, gamedata12 = Path.Combine(args.GameDirectory, "datas", "data12.v"), outputpath = args.OutputPath; // Directly read the game resource and make a copy of the .res file in the memory ??? if (!File.Exists(gamedata12)) { throw new FileNotFoundException("Can not find original data file.", gamedata12); } if (!fileinfo.Exists) { throw new TranslationFileNotFoundException("Can not find translation files.", fileinfo.FullName); } // Get the file password and make it as a pre-list TranslationDescription transDesc; System.Collections.Concurrent.ConcurrentDictionary <string, string> encryptions = new System.Collections.Concurrent.ConcurrentDictionary <string, string>(StringComparer.OrdinalIgnoreCase); // Read our derped translation files using (ZipFile translationzf = ZipFile.Read(fileinfo.FullName)) { // Password file using (Stream entryStream = translationzf["datas.ini"].OpenReader()) using (StreamReader sr = new StreamReader(entryStream)) { Leayal.Ini.IniFile afile = new Leayal.Ini.IniFile(sr); foreach (var keyValue in afile.GetAllValues("Zip Passwords")) { if (!keyValue.Value.IsComment) { encryptions.TryAdd(keyValue.Key, keyValue.Value.Value); } } afile.Close(); } // Translation Description file using (Stream entryStream = translationzf["TranslationPackData.ini"].OpenReader()) using (StreamReader sr = new StreamReader(entryStream)) { Leayal.Ini.IniFile afile = new Leayal.Ini.IniFile(sr); transDesc = new TranslationDescription(afile); afile.Close(); } using (FileStream fs = File.OpenRead(gamedata12)) // Wrap the FileStream in XorStream so we can use ZipFile class directly. using (XorStream xoredStream = new XorStream(fs, LionGameSecretByte)) using (ZipFile zf = ZipFile.Read(xoredStream)) { string[] splittedStr; DataFormatBuilder formatBuilder = new DataFormatBuilder(); zf.CompressionLevel = Ionic.Zlib.CompressionLevel.BestSpeed; if (encryptions.ContainsKey("data12")) { zf.Password = encryptions["data12"]; } System.Collections.Generic.Dictionary <string, Leayal.IO.RecyclableMemoryStream> somethingliawhglaihwg = new System.Collections.Generic.Dictionary <string, Leayal.IO.RecyclableMemoryStream>(StringComparer.OrdinalIgnoreCase); for (int i = 0; i < transDesc.Descriptions.Length; i++) { if (transDesc.Descriptions[i].TargetData.EndsWith("data12.v", StringComparison.OrdinalIgnoreCase)) // Build only for data12.v { formatBuilder.Clear(); if (this.bWorker.CancellationPending) { break; } this.OnBuildProgressChanged(new ProgressBarValueEventArgs(i + 1, transDesc.Descriptions.Length)); TranslationDescription.Description desc = transDesc.Descriptions[i]; this.OnBuildStepChanged(new StringEventArgs(Path.GetFileName(desc.PathTXT))); splittedStr = desc.ResourceFormat.Split(' '); formatBuilder.CountDataType = (DataType)Leayal.NumberHelper.Parse(splittedStr[1]); formatBuilder.IDIndex = Leayal.NumberHelper.Parse(splittedStr[0]); for (int splittedCount = 2; splittedCount < splittedStr.Length; splittedCount++) { if (!string.IsNullOrEmpty(splittedStr[splittedCount])) { formatBuilder.Append(splittedStr[splittedCount]); } } DataFormat readformat = formatBuilder.ToDataFormat(); TranslationDatabase translatedb; using (Stream transText = translationzf[desc.PathTXT].OpenReader()) using (StreamReader sr = new StreamReader(transText)) { translatedb = TranslationDatabase.From(sr, readformat); } // Read the source resource here. Ionic.Crc.CrcCalculatorStream dataStream; if (encryptions.ContainsKey("data12")) { dataStream = zf[desc.PathInsideArchieve].OpenReader(encryptions["data12"]); } else { dataStream = zf[desc.PathInsideArchieve].OpenReader(); } System.Collections.Generic.List <ResourceData[]> databuffer; using (dataStream) using (ResourceReader rr = new ResourceReader(dataStream, readformat, true)) databuffer = rr.ReadToEnd(); Leayal.IO.RecyclableMemoryStream memoryEntry = new Leayal.IO.RecyclableMemoryStream(desc.PathInsideArchieve); somethingliawhglaihwg.Add(Path.GetFileName(desc.PathInsideArchieve), memoryEntry); ResourceData[] currentnode; using (ResourceWriter sw = new ResourceWriter(memoryEntry, readformat, true)) for (int writeEntryCount = 0; writeEntryCount < databuffer.Count; writeEntryCount++) { currentnode = databuffer[writeEntryCount]; // Apply translation here currentnode = translatedb.ApplyTranslation(currentnode); sw.WriteEntry(currentnode); } zf.UpdateEntry(desc.PathInsideArchieve, new WriteDelegate((filename, writeStream) => { var memStream = somethingliawhglaihwg[Path.GetFileName(filename)]; writeStream.Write(memStream.GetBuffer(), 0, (int)memStream.Length); })); } } if (!this.bWorker.CancellationPending) { // Get client version (again) Leayal.Ini.IniFile inifile = new Leayal.Ini.IniFile(Path.Combine(args.GameDirectory, "ver.ini")); string clientVer = inifile.GetValue("Client", "ver", string.Empty); if (string.IsNullOrWhiteSpace(clientVer)) { clientVer = "Unknown"; } outputpath = Path.Combine(args.OutputPath, $"SoulWorker{args.TranslationResource.SelectedClientRegion.ToUpper()} {args.TranslationResource.SelectedLanguage} Patch for client v{clientVer}.zip"); inifile.Close(); Microsoft.VisualBasic.FileIO.FileSystem.CreateDirectory(args.OutputPath); File.Delete(outputpath); using (ZipFile outputzf = new ZipFile(outputpath, System.Text.Encoding.UTF8)) { outputzf.AddEntry($"{args.TranslationResource.SelectedLanguage}\\data12.v", new WriteDelegate((_entryName, _entryStream) => { using (XorStream writeout = new XorStream(_entryStream, LionGameSecretByte)) { zf.Save(writeout); } })); outputzf.AddFile(gamedata12, "original"); outputzf.AddEntry("version.txt", $"100% compatible with SoulWorker{args.TranslationResource.SelectedClientRegion.ToUpper()} client v{clientVer}", System.Text.Encoding.UTF8); outputzf.Save(); } } foreach (Leayal.IO.RecyclableMemoryStream memStream in somethingliawhglaihwg.Values) { memStream.Dispose(); } somethingliawhglaihwg.Clear(); } } if (this.bWorker.CancellationPending) { e.Cancel = true; } else { // Return the fullpath of output e.Result = new BuildResult(currentRegion, currentLanguage, "PatchVersion", outputpath); } }
/// <summary> /// Main Rename function /// </summary> private void Rename() { //Treat colliding files foreach (InfoEntry ie in InfoEntryManager.Instance) { if (ie.ProcessingRequested) { InfoEntry ieColliding = InfoEntryManager.Instance.GetCollidingInfoEntry(ie); while (ieColliding != null) { CollidingFiles cf = new CollidingFiles(ie, ieColliding); cf.ShowDialog(); ieColliding = InfoEntryManager.Instance.GetCollidingInfoEntry(ie); } } } SetBusyGUI(); WorkerArguments wa = new WorkerArguments(); wa.t = Task.Rename; backgroundWorker1.RunWorkerAsync(wa); }
private void startRenameTask() { WorkerArguments renameTask = new WorkerArguments(); renameTask.scheduledTask = MainTask.Rename; backgroundTaskWorker.RunWorkerAsync(renameTask); }
private void startOpenDirectoryTask(bool clear) { WorkerArguments openDirectoryTask = new WorkerArguments(); openDirectoryTask.scheduledTask = MainTask.OpenDirectory; openDirectoryTask.taskArgs = new object[] { clear }; backgroundTaskWorker.RunWorkerAsync(openDirectoryTask); }
private void startDownloadTitlesTask() { WorkerArguments downloadTitlesTask = new WorkerArguments(); downloadTitlesTask.scheduledTask = MainTask.DownloadData; setBusyGUI(); backgroundTaskWorker.RunWorkerAsync(downloadTitlesTask); }
private void startCreateTitlesTask() { WorkerArguments createRelationsTask = new WorkerArguments(); createRelationsTask.scheduledTask = MainTask.CreateRelations; setBusyGUI(); backgroundTaskWorker.RunWorkerAsync(createRelationsTask); }
internal void AddPhase(string phase, GMapTile topleft, GMapTile bottomright, string filename) { WorkerArguments arguments = new WorkerArguments(); arguments.TopLeft = topleft; arguments.BottomRight = bottomright; arguments.Filename = filename; //gkl changes - passed in phase as well arguments.Phase = phase; syncQueue.Enqueue(arguments); numPhases++; }