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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }