Ejemplo n.º 1
0
        private static void LoadVocalizationFiles()
        {
            _audioFileDescriptors = new Dictionary <string, IDictionary <int, Vocalization> >();

            var dir   = new DirectoryInfo(_gameDir.FullName + DataSubpath + @"audio\vocalization\vo wav files\");
            var files = new List <FileInfo>();

            RecursiveSearchAll(dir, "*.ogg", files);

            foreach (var file in files)
            {
                // skip generic voices
                if (file.Directory.Name.StartsWith("generic"))
                {
                    continue;
                }

                string conversationTag;
                int    nodeId;
                string suffix;

                if (Vocalization.TryParse(file.Name, out conversationTag, out nodeId, out suffix))
                {
                    IDictionary <int, Vocalization> nodeDescriptors;
                    if (!_audioFileDescriptors.TryGetValue(conversationTag, out nodeDescriptors))
                    {
                        nodeDescriptors = new Dictionary <int, Vocalization>();
                        _audioFileDescriptors[conversationTag] = nodeDescriptors;
                    }

                    Vocalization main;
                    if (!nodeDescriptors.TryGetValue(nodeId, out main))
                    {
                        var vocalization = new Vocalization();
                        vocalization.AddVariant(suffix, file);
                        nodeDescriptors[nodeId] = vocalization;
                    }
                    else
                    {
                        if (main.FindVariant(suffix) != null)
                        {
                            // skip duplicates

                            //Console.WriteLine("Skip duplicate '{0}' for {1} node {2} ( {3})", suffix, conversationTag, nodeId,
                            //	mainDescriptor.Files.Keys.Aggregate("", (accum, key) => accum + "'" + key + "' "));
                        }
                        else
                        {
                            //Console.WriteLine("Add variant '{0}' for {1} node {2} ( {3})", suffix, conversationTag, nodeId,
                            //	mainDescriptor.Files.Keys.Aggregate("", (accum, key) => accum + "'" + key + "' "));
                            main.AddVariant(suffix, file);
                        }
                    }
                }
                else
                {
                    //Console.WriteLine("Skip {0}", file.Name);
                }
            }
        }
        /// <summary>Save the menu information upon menu being closed.</summary>
        public override bool readyToClose()
        {
            decimal xPos = this.sliderButton.sliderInformation.xPos;

            Vocalization.config.voiceVolume = (decimal)(xPos / 100.0M);
            Vocalization.ModHelper.WriteConfig <ModConfig>(Vocalization.config);
            Vocalization.soundManager.volume = (float)Vocalization.config.voiceVolume;

            if (Vocalization.config.translationInfo.CurrentTranslation != this.getTranslationInfo())
            {
                Vocalization.config.translationInfo.CurrentTranslation = this.getTranslationInfo();
                Vocalization.soundManager.sounds.Clear();
                Vocalization.DialogueCues.Clear();
                Vocalization.loadAllVoiceFiles();
            }

            Vocalization.config.currentMode = this.getAudioMode();

            return(true);
        }