/// <summary> /// Saves this.Voicepack to a binary voicepack file. Makes sure any global state that might be altered during this /// operation is restored. /// </summary> /// <remarks> see remarks LoadFromFile() </remarks> public void ExportToFile(string filename) { if (!IsValidVoicepackLoaded()) { return; } var globalBackup = new VoicepackExtended(); globalBackup.GetFromGlobal(); { this.SetAsGlobal(); this.Voicepack.CreatePAKFile(filename); this.GetFromGlobal(); //make sure the global friends are copied } globalBackup.SetAsGlobal(); }
/// <summary> /// Loads the voicepack from file into this instance. Restores any global state that is altered during this operation. /// </summary> /// <remarks> /// the function achievementOptions.LoadFromPAKFile(string) will always load itself into the global instance, thats why we need /// the workaround in this function to load it in (move it in) a seperate instance. /// </remarks> public bool LoadFromFile(string filename) { var globalBackup = new VoicepackExtended(); globalBackup.GetFromGlobal(); { try { GlobalVariablesPS2.achievementOptions = new AchievementOptionsComponents(); GlobalVariablesPS2.achievementOptions.LoadFromPAKFile(filename); this.GetFromGlobal(); } catch (Exception e) { MessageBox.Show($"Failed to load:\n{filename}\n\n With error:\n{e}"); } } globalBackup.SetAsGlobal(); return(IsValidVoicepackLoaded()); }