Beispiel #1
0
 public void AddAllToClosedCaptions(ClosedCaptions captions)
 {
     foreach (var rule in Rules)
     {
         captions.Add(rule.Caption);
     }
 }
        void Save(string language, string addOn)
        {
            string captionFile =
                System.IO.Path.Combine(Steam.SteamData.GetHLAInstallFolder(), Steam.SteamData.HLAWIPAddonGamePath,
                                       addOn, Steam.SteamData.CaptionFolder, string.Format(Steam.SteamData.CaptionFormat, language + "_custom"));

            ClosedCaptions captionsList  = new ClosedCaptions();
            ClosedCaptions workingCCList = new ClosedCaptions();
            //First load in all the game captions for the selected language.


            string gameCaptionFile = System.IO.Path.Combine(Steam.SteamData.GetHLAInstallFolder(), @"game\hlvr",
                                                            Steam.SteamData.CaptionFolder, string.Format(Steam.SteamData.CaptionFormat, language));

            using (var stream = new FileStream(gameCaptionFile, FileMode.Open, FileAccess.Read))
            {
                captionsList.Read(stream);
            }

            foreach (var caption in Captions)
            {
                workingCCList.Add(caption.Caption);
                captionsList.Add(caption.Caption);
            }
            captionsList.Write(captionFile);
            string workingCaptionFile = System.IO.Path.Combine(Steam.SteamData.GetHLAInstallFolder(), Steam.SteamData.HLAWIPAddonGamePath,
                                                               addOn, Steam.SteamData.CaptionFolder, string.Format(workingCCFileFormat, language + "_custom"));

            workingCCList.Write(workingCaptionFile);

            MessageBox.Show("Captions saved as: " + captionFile + "\r\nWorking caption file: " + workingCaptionFile);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }