示例#1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (mpupThread != null)
            {
                if (mpupThread.IsAlive)
                {
                    updateLogs();
                }
                else
                {
                    updateLogs();
                    mpup       = null;
                    mpupThread = null;
                }
            }

            if (spupThread != null)
            {
                if (spupThread.IsAlive)
                {
                    updateLogs();
                }
                else
                {
                    updateLogs();
                    spup       = null;
                    spupThread = null;
                }
            }
        }
示例#2
0
 private void RepackSounds()
 {
     spup       = new SPUP();
     spupThread = new Thread(() => spup.Repack(gameDirectory + "\\TextSoundRando\\Temp\\Sound", threadCount, gameDirectory));
     spupThread.Start();
     spupThread.Join();
 }
示例#3
0
        private void FixMainSoundFile()
        {
            LogMessage("Checking main sound file");

            bool   isValid             = false;
            string mainSoundFileFolder = gameDirectory + "\\TextSoundRando\\Temp\\Sound\\frpg_main.fsb";

            if (File.Exists(gameDirectory + "\\TextSoundRando\\Output\\Sound\\frpg_main.fsb"))
            {
                long mainFileSize = new FileInfo(gameDirectory + "\\TextSoundRando\\Output\\sound\\frpg_main.fsb").Length;
                if (File.Exists(mainSoundFileFolder + "\\frpg_main.fsb") && mainFileSize > minMainSoundFileSize && mainFileSize < maxMainSoundFileSize)
                {
                    isValid = true;
                }
            }

            while (!isValid)
            {
                LogMessage("Main sound file is invalid, retrying.");

                Directory.CreateDirectory(mainSoundFileFolder);

                //clear main sound temp folder
                foreach (var file in Directory.GetFiles(mainSoundFileFolder))
                {
                    File.Delete(file);
                }

                List <string> smallSoundFiles, mediumSoundFiles, largeSoundFiles;

                GetSoundsToSwap(out smallSoundFiles, out mediumSoundFiles, out largeSoundFiles);

                //cant use seed for fixing main file or itll just give the same files over
                Random r = new Random();

                foreach (string file in Directory.GetFiles(gameDirectory + "\\TextSoundRando\\Unpack\\Sound\\frpg_main.fsb"))
                {
                    if (CheckIsValidSoundForSwapping(file))
                    {
                        long fileSize = new FileInfo(file).Length;

                        //sound files must be replaced by a similar-ish sized or else the game might not load
                        if (fileSize < soundSmallFileThreshold)
                        {
                            int rando = r.Next(smallSoundFiles.Count);
                            File.Copy(smallSoundFiles[rando], mainSoundFileFolder + "\\" + Path.GetFileName(file), true);

                            if (!onlyCustomSounds)
                            {
                                smallSoundFiles.RemoveAt(rando);
                            }
                        }
                        else if (fileSize < soundMediumFileThreshold)
                        {
                            int rando = r.Next(mediumSoundFiles.Count);
                            File.Copy(mediumSoundFiles[rando], mainSoundFileFolder + "\\" + Path.GetFileName(file), true);

                            if (!onlyCustomSounds)
                            {
                                mediumSoundFiles.RemoveAt(rando);
                            }
                        }
                        else
                        {
                            int rando = r.Next(largeSoundFiles.Count);
                            File.Copy(largeSoundFiles[rando], mainSoundFileFolder + "\\" + Path.GetFileName(file), true);

                            if (!onlyCustomSounds)
                            {
                                largeSoundFiles.RemoveAt(rando);
                            }
                        }
                    }
                    else
                    {
                        //not a sound file - copy it to directory as is
                        File.Copy(file, mainSoundFileFolder + "\\" + Path.GetFileName(file), true);
                    }
                }

                spup       = new SPUP();
                spupThread = new Thread(() => spup.Repack(gameDirectory + "\\TextSoundRando\\Temp\\Sound\\frpg_main.fsb", 1, gameDirectory));
                spupThread.Start();
                spupThread.Join();

                if (File.Exists(mainSoundFileFolder + "\\frpg_main.fsb"))
                {
                    long mainFileSize = new FileInfo(mainSoundFileFolder + "\\frpg_main.fsb").Length;
                    if (mainFileSize > minMainSoundFileSize && mainFileSize < maxMainSoundFileSize)
                    {
                        isValid = true;
                    }
                }
            }

            File.Copy(mainSoundFileFolder + "\\frpg_main.fsb", gameDirectory + "\\sound\\frpg_main.fsb", true);

            LogMessage("Main sound file is valid!");
        }