public TabPage Create(VrfGuiContext vrfGuiContext, byte[] input) { var tab = new TabPage(); var captions = new ValveResourceFormat.ClosedCaptions.ClosedCaptions(); if (input != null) { captions.Read(vrfGuiContext.FileName, new MemoryStream(input)); } else { captions.Read(vrfGuiContext.FileName); } var control = new DataGridView { Dock = DockStyle.Fill, AutoSize = true, ReadOnly = true, AllowUserToAddRows = false, AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill, DataSource = new BindingSource(new BindingList <ClosedCaption>(captions.Captions), null), ScrollBars = ScrollBars.Both, }; tab.Controls.Add(control); return(tab); }
public static void ReplaceCaptions(CaptionModifierFile modifier, string captionFile) { var compiledCaptions = new ValveResourceFormat.ClosedCaptions.ClosedCaptions(); compiledCaptions.Read(captionFile); var captionCompiler = new ClosedCaptions(); captionCompiler.Version = compiledCaptions.Version; foreach (var caption in compiledCaptions) { captionCompiler.Add(caption.Hash, caption.Text); } Console.WriteLine($"Successfully read {captionCompiler.Captions.Count} compiled captions.\n"); var result = modifier.ModifyCaptions(captionCompiler); Console.WriteLine($"Made the following modifications:\n" + $"{result.deleteCount} deletions.\n" + $"{result.replaceCount} replacements.\n" + $"{result.additionCount} additions."); #pragma warning disable CS8604 // Possible null reference argument. //var outputPath = Path.Combine(Path.GetDirectoryName(captionFile), $"{Path.GetFileNameWithoutExtension(captionFile)}_new{Path.GetExtension(captionFile)}"); var outputPath = Path.Combine(Directory.GetCurrentDirectory(), $"closecaption_{modifier.FileName}.dat"); #pragma warning restore CS8604 // Possible null reference argument. WriteCaptionFile(captionCompiler, outputPath); }
public static void PrintClosedCaptionData(ValveResourceFormat.ClosedCaptions.ClosedCaptions captions) { Console.WriteLine("Closed Caption Data:"); Console.WriteLine($"\tVersion:\t{captions.Version}"); Console.WriteLine($"\tNumBlocks:\t{captions.NumBlocks}"); Console.WriteLine($"\tBlockSize:\t{captions.BlockSize}"); Console.WriteLine($"\tDirectorySize:\t{captions.DirectorySize}"); Console.WriteLine($"\tDataOffset:\t{captions.DataOffset}"); Console.WriteLine($"\tTotal num captions:\t{captions.Captions.Count}"); }
public static void AddTestToAll(string captionFile) { Console.WriteLine("Adding \" TEST\" to all"); var compiledCaptions = new ValveResourceFormat.ClosedCaptions.ClosedCaptions(); compiledCaptions.Read(captionFile); var captionCompiler = new ClosedCaptions(); foreach (var caption in compiledCaptions) { captionCompiler.Add(caption.Hash, caption.Text + " TEST"); } #pragma warning disable CS8604 // Possible null reference argument. var outputPath = Path.Combine(Path.GetDirectoryName(captionFile), $"{Path.GetFileNameWithoutExtension(captionFile)}_new{Path.GetExtension(captionFile)}"); #pragma warning restore CS8604 // Possible null reference argument. WriteCaptionFile(captionCompiler, outputPath); }
public static void CloneCaptionFile(string captionFile) { var compiledCaptions = new ValveResourceFormat.ClosedCaptions.ClosedCaptions(); compiledCaptions.Read(captionFile); PrintClosedCaptionData(compiledCaptions); var captionCompiler = new ClosedCaptions(); captionCompiler.Version = compiledCaptions.Version; foreach (var caption in compiledCaptions) { captionCompiler.Add(caption.Hash, caption.Text); } #pragma warning disable CS8604 // Possible null reference argument. var outputPath = Path.Combine(Path.GetDirectoryName(captionFile), $"{Path.GetFileNameWithoutExtension(captionFile)}_new{Path.GetExtension(captionFile)}"); #pragma warning restore CS8604 // Possible null reference argument. WriteCaptionFile(captionCompiler, outputPath); }