Chatterer.chatterer.load_shared_settings C# (CSharp) Method

load_shared_settings() private method

private load_shared_settings ( ConfigNode node ) : void
node ConfigNode
return void
        private void load_shared_settings(ConfigNode node)
        {
            if (debugging) Debug.Log("[CHATR] load_shared_settings() START");

            destroy_all_beep_players();
            beepsource_list.Clear();
            destroy_all_background_players();
            backgroundsource_list.Clear();
            chatter_array.Clear();

            if (node.HasValue("main_window_pos"))
            {
                string[] split = node.GetValue("main_window_pos").Split(Convert.ToChar(","));
                main_window_pos.x = Single.Parse(split[0]);
                main_window_pos.y = Single.Parse(split[1]);
            }

            if (node.HasValue("show_tooltips")) show_tooltips = Boolean.Parse(node.GetValue("show_tooltips"));
            if (node.HasValue("hide_all_windows")) hide_all_windows = Boolean.Parse(node.GetValue("hide_all_windows"));
            if (node.HasValue("skin_index")) skin_index = Int32.Parse(node.GetValue("skin_index"));
            if (node.HasValue("active_menu")) active_menu = Int32.Parse(node.GetValue("active_menu"));
            if (node.HasValue("remotetech_toggle")) remotetech_toggle = Boolean.Parse(node.GetValue("remotetech_toggle"));

            if (node.HasValue("chatter_freq"))
            {
                chatter_freq = Int32.Parse(node.GetValue("chatter_freq"));
                chatter_freq_slider = chatter_freq;
                prev_chatter_freq = chatter_freq;
            }
            if (node.HasValue("chatter_vol_slider"))
            {
                chatter_vol_slider = Single.Parse(node.GetValue("chatter_vol_slider"));
                initial_chatter.volume = chatter_vol_slider;
                response_chatter.volume = chatter_vol_slider;
                prev_chatter_vol_slider = chatter_vol_slider;
            }
            if (node.HasValue("chatter_sel_filter")) chatter_sel_filter = Int32.Parse(node.GetValue("chatter_sel_filter"));
            if (node.HasValue("show_chatter_filter_settings")) show_chatter_filter_settings = Boolean.Parse(node.GetValue("show_chatter_filter_settings"));
            if (node.HasValue("chatter_reverb_preset_index")) chatter_reverb_preset_index = Int32.Parse(node.GetValue("chatter_reverb_preset_index"));
            if (node.HasValue("chatter_filter_settings_window_pos"))
            {
                string[] split = node.GetValue("chatter_filter_settings_window_pos").Split(Convert.ToChar(","));
                chatter_filter_settings_window_pos.x = Single.Parse(split[0]);
                chatter_filter_settings_window_pos.y = Single.Parse(split[1]);
            }
            if (node.HasValue("show_sample_selector")) show_probe_sample_selector = Boolean.Parse(node.GetValue("show_sample_selector"));
            if (node.HasValue("probe_sample_selector_window_pos"))
            {
                string[] split = node.GetValue("probe_sample_selector_window_pos").Split(Convert.ToChar(","));
                probe_sample_selector_window_pos.x = Single.Parse(split[0]);
                probe_sample_selector_window_pos.y = Single.Parse(split[1]);
            }
            if (node.HasValue("quindar_toggle")) quindar_toggle = Boolean.Parse(node.GetValue("quindar_toggle"));
            if (node.HasValue("quindar_vol_slider"))
            {
                quindar_vol_slider = Single.Parse(node.GetValue("quindar_vol_slider"));
                prev_quindar_vol_slider = quindar_vol_slider;
            }
            if (node.HasValue("sstv_freq"))
            {
                sstv_freq = Int32.Parse(node.GetValue("sstv_freq"));
                sstv_freq_slider = sstv_freq;
                prev_sstv_freq = sstv_freq;
            }
            if (node.HasValue("sstv_vol_slider"))
            {
                sstv_vol_slider = Single.Parse(node.GetValue("sstv_vol_slider"));
                prev_sstv_vol_slider = sstv_vol_slider;
            }
            if (node.HasValue("sel_beep_src")) sel_beep_src = Int32.Parse(node.GetValue("sel_beep_src"));
            if (sel_beep_src < 0 || sel_beep_src > 9) sel_beep_src = 0;
            if (node.HasValue("sel_beep_page")) sel_beep_page = Int32.Parse(node.GetValue("sel_beep_page"));

            //AAE
            int i;

            if (aae_backgrounds_exist)
            {
                i = 0;

                foreach (ConfigNode _background in node.nodes)
                {
                    if (_background.name == "AAE_BACKGROUND")
                    {
                        add_new_backgroundsource();
                        if (_background.HasValue("volume")) backgroundsource_list[i].audiosource.volume = Single.Parse(_background.GetValue("volume"));
                        if (_background.HasValue("current_clip")) backgroundsource_list[i].current_clip = _background.GetValue("current_clip");

                        if (dict_background_samples.Count > 0)
                        {
                            set_background_clip(backgroundsource_list[i]);
                        }
                        i++;
                    }
                }
            }

            if (aae_soundscapes_exist)
            {
                if (node.HasValue("aae_soundscape_vol")) aae_soundscape.volume = Single.Parse(node.GetValue("aae_soundscape_vol"));
                if (node.HasValue("aae_soundscape_freq"))
                {
                    aae_soundscape_freq = Int32.Parse(node.GetValue("aae_soundscape_freq"));
                    aae_prev_soundscape_freq = aae_soundscape_freq;
                }
            }

            if (aae_breathing_exist)
            {
                if (node.HasValue("aae_breathing_vol")) aae_breathing.volume = Single.Parse(node.GetValue("aae_breathing_vol"));
            }

            if (aae_airlock_exist)
            {
                if (node.HasValue("aae_airlock_vol")) aae_airlock.volume = Single.Parse(node.GetValue("aae_airlock_vol"));
            }

            if (aae_wind_exist)
            {
                if (node.HasValue("aae_wind_vol"))
                {
                    aae_wind_vol_slider = Single.Parse(node.GetValue("aae_wind_vol"));
                    aae_wind.volume = aae_wind_vol_slider;
                }
            }

            //
            //Load audioset info
            i = 0;
            foreach (ConfigNode _set in node.nodes)
            {
                if (_set.name == "AUDIOSET")
                {
                    chatter_array.Add(new ChatterAudioList());  //create a new entry in the list for each audioset
                    if (_set.HasValue("directory")) chatter_array[i].directory = _set.GetValue("directory");
                    if (_set.HasValue("is_active")) chatter_array[i].is_active = Boolean.Parse(_set.GetValue("is_active"));
                    i++;
                }
            }
            if (debugging) Debug.Log("[CHATR] audiosets found: " + chatter_array.Count + " :: reloading chatter audio");
            load_chatter_audio();   //reload audio

            //Chatter filters
            foreach (ConfigNode _filter in node.nodes)
            {
                if (_filter.name == "CHORUS")
                {
                    if (_filter.HasValue("enabled"))
                    {
                        chatter_chorus_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                        //if (debugging) Debug.Log("[CHATR] beepsource index: " + x.ToString() + " :: chorus_enabled = " + beepsource_list[x].chorus_filter.enabled);
                    }
                    if (_filter.HasValue("dry_mix")) chatter_chorus_filter.dryMix = Single.Parse(_filter.GetValue("dry_mix"));
                    if (_filter.HasValue("wet_mix_1")) chatter_chorus_filter.wetMix1 = Single.Parse(_filter.GetValue("wet_mix_1"));
                    if (_filter.HasValue("wet_mix_2")) chatter_chorus_filter.wetMix2 = Single.Parse(_filter.GetValue("wet_mix_2"));
                    if (_filter.HasValue("wet_mix_3")) chatter_chorus_filter.wetMix3 = Single.Parse(_filter.GetValue("wet_mix_3"));
                }
                else if (_filter.name == "DISTORTION")
                {
                    if (_filter.HasValue("enabled")) chatter_distortion_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                    if (_filter.HasValue("distortion_level")) chatter_distortion_filter.distortionLevel = Single.Parse(_filter.GetValue("distortion_level"));
                }
                else if (_filter.name == "ECHO")
                {
                    if (_filter.HasValue("enabled")) chatter_echo_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                    if (_filter.HasValue("delay")) chatter_echo_filter.delay = Single.Parse(_filter.GetValue("delay"));
                    if (_filter.HasValue("decay_ratio")) chatter_echo_filter.decayRatio = Single.Parse(_filter.GetValue("decay_ratio"));
                    if (_filter.HasValue("dry_mix")) chatter_echo_filter.dryMix = Single.Parse(_filter.GetValue("dry_mix"));
                    if (_filter.HasValue("wet_mix")) chatter_echo_filter.wetMix = Single.Parse(_filter.GetValue("wet_mix"));
                }
                else if (_filter.name == "HIGHPASS")
                {
                    if (_filter.HasValue("enabled")) chatter_highpass_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                    if (_filter.HasValue("cutoff_freq")) chatter_highpass_filter.cutoffFrequency = Single.Parse(_filter.GetValue("cutoff_freq"));
                    if (_filter.HasValue("resonance_q")) chatter_highpass_filter.highpassResonaceQ = Single.Parse(_filter.GetValue("resonance_q"));
                }
                else if (_filter.name == "LOWPASS")
                {
                    if (_filter.HasValue("enabled")) chatter_lowpass_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                    if (_filter.HasValue("cutoff_freq")) chatter_lowpass_filter.cutoffFrequency = Single.Parse(_filter.GetValue("cutoff_freq"));
                    if (_filter.HasValue("resonance_q")) chatter_lowpass_filter.lowpassResonaceQ = Single.Parse(_filter.GetValue("resonance_q"));
                }
                else if (_filter.name == "REVERB")
                {
                    if (_filter.HasValue("enabled")) chatter_reverb_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                    if (_filter.HasValue("reverb_preset")) chatter_reverb_filter.reverbPreset = (AudioReverbPreset)Enum.Parse(typeof(AudioReverbPreset), _filter.GetValue("reverb_preset"));
                    if (_filter.HasValue("dry_level")) chatter_reverb_filter.dryLevel = Single.Parse(_filter.GetValue("dry_level"));
                    if (_filter.HasValue("room")) chatter_reverb_filter.room = Single.Parse(_filter.GetValue("room"));
                    if (_filter.HasValue("room_hf")) chatter_reverb_filter.roomHF = Single.Parse(_filter.GetValue("room_hf"));
                    if (_filter.HasValue("room_lf")) chatter_reverb_filter.roomLF = Single.Parse(_filter.GetValue("room_lf"));
                    if (_filter.HasValue("room_rolloff")) chatter_reverb_filter.roomRolloff = Single.Parse(_filter.GetValue("room_rolloff"));
                    if (_filter.HasValue("decay_time")) chatter_reverb_filter.decayTime = Single.Parse(_filter.GetValue("decay_time"));
                    if (_filter.HasValue("decay_hf_ratio")) chatter_reverb_filter.decayHFRatio = Single.Parse(_filter.GetValue("decay_hf_ratio"));
                    if (_filter.HasValue("reflections_level")) chatter_reverb_filter.reflectionsLevel = Single.Parse(_filter.GetValue("reflections_level"));
                    if (_filter.HasValue("reflections_delay")) chatter_reverb_filter.reflectionsDelay = Single.Parse(_filter.GetValue("reflections_delay"));
                    if (_filter.HasValue("reverb_level")) chatter_reverb_filter.reverbLevel = Single.Parse(_filter.GetValue("reverb_level"));
                    if (_filter.HasValue("reverb_delay")) chatter_reverb_filter.reverbDelay = Single.Parse(_filter.GetValue("reverb_delay"));
                    if (_filter.HasValue("diffusion")) chatter_reverb_filter.diffusion = Single.Parse(_filter.GetValue("diffusion"));
                    if (_filter.HasValue("density")) chatter_reverb_filter.density = Single.Parse(_filter.GetValue("density"));
                    if (_filter.HasValue("hf_reference")) chatter_reverb_filter.hfReference = Single.Parse(_filter.GetValue("hf_reference"));
                    if (_filter.HasValue("lf_reference")) chatter_reverb_filter.lFReference = Single.Parse(_filter.GetValue("lf_reference"));
                }
            }

            //Beepsources
            foreach (ConfigNode _source in node.nodes)
            {
                if (_source.name == "BEEPSOURCE")
                {
                    if (debugging) Debug.Log("[CHATR] loading beepsource");
                    add_new_beepsource();

                    int x = beepsource_list.Count - 1;

                    if (_source.HasValue("precise")) beepsource_list[x].precise = Boolean.Parse(_source.GetValue("precise"));
                    if (_source.HasValue("precise_freq"))
                    {
                        beepsource_list[x].precise_freq = Int32.Parse(_source.GetValue("precise_freq"));
                        beepsource_list[x].precise_freq_slider = beepsource_list[x].precise_freq;
                    }
                    if (_source.HasValue("loose_freq"))
                    {
                        beepsource_list[x].loose_freq = Int32.Parse(_source.GetValue("loose_freq"));
                        beepsource_list[x].loose_freq_slider = beepsource_list[x].loose_freq;
                    }
                    if (_source.HasValue("volume")) beepsource_list[x].audiosource.volume = Single.Parse(_source.GetValue("volume"));
                    if (_source.HasValue("pitch")) beepsource_list[x].audiosource.pitch = Single.Parse(_source.GetValue("pitch"));
                    if (_source.HasValue("current_clip")) beepsource_list[x].current_clip = _source.GetValue("current_clip");
                    if (_source.HasValue("sel_filter")) beepsource_list[x].sel_filter = Int32.Parse(_source.GetValue("sel_filter"));
                    if (_source.HasValue("show_settings_window")) beepsource_list[x].show_settings_window = Boolean.Parse(_source.GetValue("show_settings_window"));
                    if (_source.HasValue("reverb_preset_index")) beepsource_list[x].reverb_preset_index = Int32.Parse(_source.GetValue("reverb_preset_index"));
                    if (_source.HasValue("settings_window_pos_x")) beepsource_list[x].settings_window_pos.x = Single.Parse(_source.GetValue("settings_window_pos_x"));
                    if (_source.HasValue("settings_window_pos_y")) beepsource_list[x].settings_window_pos.y = Single.Parse(_source.GetValue("settings_window_pos_y"));

                    if (dict_probe_samples.Count > 0)
                    {
                        set_beep_clip(beepsource_list[x]);

                        if (beepsource_list[x].precise == false && beepsource_list[x].loose_freq > 0) new_beep_loose_timer_limit(beepsource_list[x]);
                    }

                    foreach (ConfigNode _filter in _source.nodes)
                    {
                        if (_filter.name == "CHORUS")
                        {
                            if (_filter.HasValue("enabled"))
                            {
                                beepsource_list[x].chorus_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                                //if (debugging) Debug.Log("[CHATR] beepsource index: " + x.ToString() + " :: chorus_enabled = " + beepsource_list[x].chorus_filter.enabled);
                            }
                            if (_filter.HasValue("dry_mix")) beepsource_list[x].chorus_filter.dryMix = Single.Parse(_filter.GetValue("dry_mix"));
                            if (_filter.HasValue("wet_mix_1")) beepsource_list[x].chorus_filter.wetMix1 = Single.Parse(_filter.GetValue("wet_mix_1"));
                            if (_filter.HasValue("wet_mix_2")) beepsource_list[x].chorus_filter.wetMix2 = Single.Parse(_filter.GetValue("wet_mix_2"));
                            if (_filter.HasValue("wet_mix_3")) beepsource_list[x].chorus_filter.wetMix3 = Single.Parse(_filter.GetValue("wet_mix_3"));
                        }
                        else if (_filter.name == "DISTORTION")
                        {
                            if (_filter.HasValue("enabled")) beepsource_list[x].distortion_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                            if (_filter.HasValue("distortion_level")) beepsource_list[x].distortion_filter.distortionLevel = Single.Parse(_filter.GetValue("distortion_level"));
                        }
                        else if (_filter.name == "ECHO")
                        {
                            if (_filter.HasValue("enabled")) beepsource_list[x].echo_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                            if (_filter.HasValue("delay")) beepsource_list[x].echo_filter.delay = Single.Parse(_filter.GetValue("delay"));
                            if (_filter.HasValue("decay_ratio")) beepsource_list[x].echo_filter.decayRatio = Single.Parse(_filter.GetValue("decay_ratio"));
                            if (_filter.HasValue("dry_mix")) beepsource_list[x].echo_filter.dryMix = Single.Parse(_filter.GetValue("dry_mix"));
                            if (_filter.HasValue("wet_mix")) beepsource_list[x].echo_filter.wetMix = Single.Parse(_filter.GetValue("wet_mix"));
                        }
                        else if (_filter.name == "HIGHPASS")
                        {
                            if (_filter.HasValue("enabled")) beepsource_list[x].highpass_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                            if (_filter.HasValue("cutoff_freq")) beepsource_list[x].highpass_filter.cutoffFrequency = Single.Parse(_filter.GetValue("cutoff_freq"));
                            if (_filter.HasValue("resonance_q")) beepsource_list[x].highpass_filter.highpassResonaceQ = Single.Parse(_filter.GetValue("resonance_q"));
                        }
                        else if (_filter.name == "LOWPASS")
                        {
                            if (_filter.HasValue("enabled")) beepsource_list[x].lowpass_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                            if (_filter.HasValue("cutoff_freq")) beepsource_list[x].lowpass_filter.cutoffFrequency = Single.Parse(_filter.GetValue("cutoff_freq"));
                            if (_filter.HasValue("resonance_q")) beepsource_list[x].lowpass_filter.lowpassResonaceQ = Single.Parse(_filter.GetValue("resonance_q"));
                        }
                        else if (_filter.name == "REVERB")
                        {
                            if (_filter.HasValue("enabled")) beepsource_list[x].reverb_filter.enabled = Boolean.Parse(_filter.GetValue("enabled"));
                            if (_filter.HasValue("reverb_preset")) beepsource_list[x].reverb_filter.reverbPreset = (AudioReverbPreset)Enum.Parse(typeof(AudioReverbPreset), _filter.GetValue("reverb_preset"));
                            if (_filter.HasValue("dry_level")) beepsource_list[x].reverb_filter.dryLevel = Single.Parse(_filter.GetValue("dry_level"));
                            if (_filter.HasValue("room")) beepsource_list[x].reverb_filter.room = Single.Parse(_filter.GetValue("room"));
                            if (_filter.HasValue("room_hf")) beepsource_list[x].reverb_filter.roomHF = Single.Parse(_filter.GetValue("room_hf"));
                            if (_filter.HasValue("room_lf")) beepsource_list[x].reverb_filter.roomLF = Single.Parse(_filter.GetValue("room_lf"));
                            if (_filter.HasValue("room_rolloff")) beepsource_list[x].reverb_filter.roomRolloff = Single.Parse(_filter.GetValue("room_rolloff"));
                            if (_filter.HasValue("decay_time")) beepsource_list[x].reverb_filter.decayTime = Single.Parse(_filter.GetValue("decay_time"));
                            if (_filter.HasValue("decay_hf_ratio")) beepsource_list[x].reverb_filter.decayHFRatio = Single.Parse(_filter.GetValue("decay_hf_ratio"));
                            if (_filter.HasValue("reflections_level")) beepsource_list[x].reverb_filter.reflectionsLevel = Single.Parse(_filter.GetValue("reflections_level"));
                            if (_filter.HasValue("reflections_delay")) beepsource_list[x].reverb_filter.reflectionsDelay = Single.Parse(_filter.GetValue("reflections_delay"));
                            if (_filter.HasValue("reverb_level")) beepsource_list[x].reverb_filter.reverbLevel = Single.Parse(_filter.GetValue("reverb_level"));
                            if (_filter.HasValue("reverb_delay")) beepsource_list[x].reverb_filter.reverbDelay = Single.Parse(_filter.GetValue("reverb_delay"));
                            if (_filter.HasValue("diffusion")) beepsource_list[x].reverb_filter.diffusion = Single.Parse(_filter.GetValue("diffusion"));
                            if (_filter.HasValue("density")) beepsource_list[x].reverb_filter.density = Single.Parse(_filter.GetValue("density"));
                            if (_filter.HasValue("hf_reference")) beepsource_list[x].reverb_filter.hfReference = Single.Parse(_filter.GetValue("hf_reference"));
                            if (_filter.HasValue("lf_reference")) beepsource_list[x].reverb_filter.lFReference = Single.Parse(_filter.GetValue("lf_reference"));
                        }
                    }
                }
            }
            if (debugging) Debug.Log("[CHATR] load_shared_settings() END");
        }
chatterer