Пример #1
0
        private void Add(string path, object data, CachedFileType type, bool allowOverwrite = true)
        {
            var cachedFile = new CachedFile(path, data, allowOverwrite);

            if (data.GetType() == typeof(EffectContainerFile))
            {
                EffectContainerFile ecf = EffectContainerFile.New();
                ecf.AddEffects(((EffectContainerFile)data).Effects);
                cachedFile.backupEffectContainerFile = ecf;
            }
            else if (data.GetType() == typeof(ACB_File))
            {
                //Might be better to change this to a shallow-copy
                ACB_File acb = ACB_File.NewXv2Acb();

                foreach (var cue in ((ACB_File)data).Cues)
                {
                    acb.CopyCue((int)cue.ID, (ACB_File)data);
                }

                cachedFile.backupBgmFile = acb;
            }

            cachedFiles.Add(cachedFile);
        }
Пример #2
0
        public MusicUninstaller(Uninstall _uninstall, _File _file)
        {
            file      = _file;
            uninstall = _uninstall;
            bgmAcb    = (ACB_File)uninstall.GetParsedFile <ACB_File>(MusicInstaller.BGM_PATH, false);

            if (_file.filePath == MusicInstaller.OPTION_INSTALL_TYPE)
            {
                oblFile = (OBL_File)uninstall.GetParsedFile <OBL_File>(MusicInstaller.OBL_PATH, false);

                for (int i = 0; i < GeneralInfo.LanguageSuffix.Length; i++)
                {
                    msgFiles.Add((MSG_File)uninstall.GetParsedFile <MSG_File>($"{MusicInstaller.OPTION_MSG_PATH}{GeneralInfo.LanguageSuffix[i]}", false));
                }
            }
            else if (_file.filePath == MusicInstaller.DIRECT_INSTALL_TYPE)
            {
                if (cpkAcbFile == null)
                {
                    cpkAcbFile = (ACB_File)uninstall.GetParsedFile <ACB_File>(MusicInstaller.BGM_PATH, true);
                }
            }

            Uninstall();
        }
Пример #3
0
        private void RepairCss()
        {
            if (enCssFile.Cues.Count == jpnCssFile.Cues.Count)
            {
                return;
            }

            ACB_File main   = (enCssFile.Cues.Count > jpnCssFile.Cues.Count) ? enCssFile : jpnCssFile;
            ACB_File second = (enCssFile.Cues.Count > jpnCssFile.Cues.Count) ? jpnCssFile : enCssFile;

            while (main.Cues.Count > second.Cues.Count)
            {
                if (main.Cues.Count <= second.Cues.Count)
                {
                    break;
                }
                int     newCueId  = second.GetFreeCueId();
                ACB_Cue cueToCopy = main.GetCue(newCueId);

                if (cueToCopy != null)
                {
                    second.CopyCue(newCueId, main);
                }
                else
                {
                    break;
                }
            }
        }
Пример #4
0
        public List <IUndoRedo> PasteCues()
        {
            List <IUndoRedo> undos = new List <IUndoRedo>();

            if (!CanPasteCues())
            {
                return(undos);
            }

            ACB_File tempAcb = ACB_File.LoadFromClipboard();

            //Check if cues exist in current ACB. If they do, then generate new GUIDs for them (duplication mode)
            if (AcbFile.Cues.Any(x => tempAcb.Cues.Any(y => y.InstanceGuid == x.InstanceGuid)))
            {
                tempAcb.NewInstanceGuids();
            }

            foreach (var cue in tempAcb.Cues)
            {
                undos.AddRange(AcbFile.CopyCue((int)cue.ID, tempAcb));
            }

            Refresh();
            undos.Add(new UndoActionDelegate(this, "Refresh", true));
            return(undos);
        }
Пример #5
0
        public void SaveParsedFiles()
        {
            foreach (var file in cachedFiles)
            {
                Directory.CreateDirectory(Path.GetDirectoryName(GeneralInfo.GetPathInGameDir(file.Path)));

                if (file.FileType == CachedFileType.Parsed && file.Data.GetType() == typeof(EffectContainerFile))
                {
                    string savePath         = GeneralInfo.GetPathInGameDir(file.Path);
                    EffectContainerFile ecf = (EffectContainerFile)file.Data;
                    ecf.Directory  = Path.GetDirectoryName(savePath);
                    ecf.Name       = Path.GetFileNameWithoutExtension(savePath);
                    ecf.saveFormat = Xv2CoreLib.EffectContainer.SaveFormat.Binary;
                    ecf.Save();
                }
                else if (file.FileType == CachedFileType.Parsed && file.Data.GetType() == typeof(ACB_File))
                {
                    string   path    = GeneralInfo.GetPathInGameDir(file.Path);
                    string   acbPath = string.Format("{0}/{1}", Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path));
                    ACB_File acbFile = (ACB_File)file.Data;
                    acbFile.Save(acbPath, true);
                }
                else if (file.FileType == CachedFileType.Parsed)
                {
                    File.WriteAllBytes(GeneralInfo.GetPathInGameDir(file.Path), file.GetBytes());
                }
            }
        }
Пример #6
0
        private void LoadCssFiles()
        {
            enCssFile  = (ACB_File)install.GetParsedFile <ACB_File>(CSS_VOICE_EN_PATH, false);
            jpnCssFile = (ACB_File)install.GetParsedFile <ACB_File>(CSS_VOICE_JPN_PATH, false);

            enCssFile.CleanTablesOnSave  = false;
            jpnCssFile.CleanTablesOnSave = false;
        }
        public CreateMusicInstaller(Window parent, ACB_File musicPackage)
        {
            DataContext      = this;
            Owner            = parent;
            acbFile          = musicPackage;
            MusicPackageType = (int)acbFile.MusicPackageType;

            InitializeComponent();
        }
Пример #8
0
        public void CopyCues(IList <Cue_Wrapper> cues)
        {
            ACB_File newAcb = ACB_File.NewXv2Acb();

            foreach (var cue in cues)
            {
                newAcb.CopyCue((int)cue.CueRef.ID, AcbFile);
            }

            newAcb.SaveToClipboard();
        }
Пример #9
0
        private void CssUninstall()
        {
            acbFile = (ACB_File)uninstall.GetParsedFile <ACB_File>(file.filePath, false);
            acbFile.CleanTablesOnSave = false; //Too slow on CS_ALL

            Section section = file.GetSection(Sections.ACB_Cue);

            foreach (string id in section.IDs)
            {
                uint intId;

                if (uint.TryParse(id, out intId))
                {
                    ACB_Cue cue = acbFile.Cues.FirstOrDefault(x => x.ID == intId);

                    if (cue != null)
                    {
                        //Mark cue as free, in same manner as xv2ins
                        cue.Name = "X2_FREE";

                        var waveforms = acbFile.GetWaveformsFromCue(cue);

                        if (waveforms.Count == 1)
                        {
                            var awbEntry = acbFile.GetAfs2Entry(waveforms[0].AwbId);

                            if (awbEntry != null)
                            {
                                awbEntry.bytes = Properties.Resources.silence;
                            }
                        }
                    }
                }
            }

            /*
             * //Removed. As above, this is too slow to do on CS_ALL
             *
             * //Delete all trailing free cues
             * for (int i = acbFile.Cues.Count - 1; i >= 0; i--)
             * {
             *  if(acbFile.Cues[i].Name == "X2_FREE")
             *  {
             *      acbFile.Cues.RemoveAt(i);
             *  }
             *  else
             *  {
             *      break;
             *  }
             * }
             */
        }
Пример #10
0
        private void LoadMusicFiles()
        {
            bgmFile = (ACB_File)install.GetParsedFile <ACB_File>(BGM_PATH, false);

            if (musicPackage.MusicPackageType == MusicPackageType.BGM_NewOption)
            {
                oblFile  = (OBL_File)install.GetParsedFile <OBL_File>(OBL_PATH, false);
                msgFiles = new List <MSG_File>();

                for (int i = 0; i < GeneralInfo.LanguageSuffix.Length; i++)
                {
                    msgFiles.Add((MSG_File)install.GetParsedFile <MSG_File>($"{OPTION_MSG_PATH}{GeneralInfo.LanguageSuffix[i]}", false));
                }
            }
        }
Пример #11
0
        private async void LoadAcb(string path)
        {
            var controller = await this.ShowProgressAsync($"Loading \"{System.IO.Path.GetFileName(path)}\"...", $"", false, new MetroDialogSettings()
            {
                AnimateHide = false, AnimateShow = false, DialogTitleFontSize = 15, DialogMessageFontSize = 12
            });

            controller.SetIndeterminate();

            try
            {
                await Task.Run(() =>
                {
                    AcbFile = new ACB_Wrapper(ACB_File.Load(path));
                });

                controller.CloseAsync();
                UndoManager.Instance.Clear();

                if (AcbFile != null)
                {
                    AcbPath = path;

                    if (AcbFile.AcbFile.TableValidationFailed)
                    {
                        await this.ShowMessageAsync("Validation Failed", "This file contains unknown data that could not be loaded and was skipped. Continuing at this point may very likely result in this ACB becoming corrupt.\n\nYou've been warned!", MessageDialogStyle.Affirmative, new MetroDialogSettings()
                        {
                            AnimateShow = false, AnimateHide = false
                        });
                    }
                    if (AcbFile.AcbFile.ExternalAwbError)
                    {
                        await this.ShowMessageAsync("Validation Failed", "There should be an external AWB file with this ACB, but none was found. Because of this some tracks could not be loaded.", MessageDialogStyle.Affirmative, new MetroDialogSettings()
                        {
                            AnimateShow = false, AnimateHide = false
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                controller.CloseAsync();
                ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
            }
        }
Пример #12
0
        public MusicInstaller(Install_NEW _install, string musicPackagePath)
        {
            install      = _install;
            musicPackage = ACB_File.Load(install.zipManager.GetFileFromArchive(GeneralInfo.GetPathInZipDataDir(musicPackagePath)), null, false, true);
            bgmAcb       = (ACB_File)install.GetParsedFile <ACB_File>(BGM_PATH, false);

            if (musicPackage.MusicPackageType == MusicPackageType.NewOption)
            {
                oblFile = (OBL_File)install.GetParsedFile <OBL_File>(OBL_PATH, false);

                for (int i = 0; i < GeneralInfo.LanguageSuffix.Length; i++)
                {
                    msgFiles.Add((MSG_File)install.GetParsedFile <MSG_File>($"{OPTION_MSG_PATH}{GeneralInfo.LanguageSuffix[i]}", false));
                }
            }

            Install();
        }
Пример #13
0
        public AcbInstaller(Install _install, string musicPackagePath)
        {
            install      = _install;
            musicPackage = ACB_File.Load(install.zipManager.GetFileFromArchive(GeneralInfo.GetPathInZipDataDir(musicPackagePath)), null, false, true);

            if (musicPackage.MusicPackageType == MusicPackageType.BGM_Direct || musicPackage.MusicPackageType == MusicPackageType.BGM_NewOption)
            {
                LoadMusicFiles();
                InstallMusic();
            }
            else if (musicPackage.MusicPackageType == MusicPackageType.CSS_Voice)
            {
                LoadCssFiles();
                InstallCss();
            }
            else
            {
                throw new InvalidOperationException($"Unknown MusicPackage Type: {musicPackage.MusicPackageType}");
            }
        }
Пример #14
0
        private void LoadBgm()
        {
            acbFile = (ACB_File)uninstall.GetParsedFile <ACB_File>(AcbInstaller.BGM_PATH, false);

            if (file.filePath == AcbInstaller.OPTION_INSTALL_TYPE)
            {
                oblFile = (OBL_File)uninstall.GetParsedFile <OBL_File>(AcbInstaller.OBL_PATH, false);

                for (int i = 0; i < GeneralInfo.LanguageSuffix.Length; i++)
                {
                    msgFiles.Add((MSG_File)uninstall.GetParsedFile <MSG_File>($"{AcbInstaller.OPTION_MSG_PATH}{GeneralInfo.LanguageSuffix[i]}", false));
                }
            }
            else if (file.filePath == AcbInstaller.DIRECT_INSTALL_TYPE)
            {
                if (cpkAcbFile == null)
                {
                    cpkAcbFile = (ACB_File)uninstall.GetParsedFile <ACB_File>(AcbInstaller.BGM_PATH, true);
                }
            }
        }
Пример #15
0
        private async void LoadAcb(string path, bool forceLoad = false)
        {
            AcbFormatHelper.Instance.AcbFormatHelperMain.ForceLoad = forceLoad;

            var controller = await this.ShowProgressAsync($"Loading \"{System.IO.Path.GetFileName(path)}\"...", $"", false, DialogSettings.Default);

            controller.SetIndeterminate();

            try
            {
                await Task.Run(() =>
                {
                    AcbFile = new ACB_Wrapper(ACB_File.Load(path));
                });

                UndoManager.Instance.Clear();

                if (AcbFile != null)
                {
                    AcbPath = path;

                    if (AcbFile.AcbFile.TableValidationFailed)
                    {
                        await this.ShowMessageAsync("Validation Failed", "This file contains unknown data that could not be loaded and was skipped. Continuing at this point may very likely result in this ACB losing data or becoming corrupt.\n\nYou've been warned!", MessageDialogStyle.Affirmative, DialogSettings.Default);
                    }
                    if (AcbFile.AcbFile.ExternalAwbError)
                    {
                        await this.ShowMessageAsync("Validation Failed", "There should be an external AWB file with this ACB, but none was found. Because of this some tracks could not be loaded.", MessageDialogStyle.Affirmative, DialogSettings.Default);
                    }
                }
            }
            finally
            {
                controller.CloseAsync();
            }
        }
Пример #16
0
 public static ACB_Wrapper NewAcb(Version version)
 {
     return(new ACB_Wrapper(ACB_File.NewAcb(version)));
 }
Пример #17
0
 public static ACB_Wrapper NewXv2Acb()
 {
     return(new ACB_Wrapper(ACB_File.NewXv2Acb()));
 }
Пример #18
0
 public ACB_Wrapper(ACB_File acbFile)
 {
     AcbFile = acbFile;
     Refresh();
 }