Exemplo n.º 1
0
        public static void SetMusicSource(EBackgroundMusicSource source)
        {
            if (_MusicSource == source)
            {
                return;
            }
            _MusicSource = source;
            switch (_MusicSource)
            {
            case EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC:
                _AddBackgroundMusic();
                _RemoveOwnMusic();
                break;

            case EBackgroundMusicSource.TR_CONFIG_ONLY_OWN_MUSIC:
                _AddOwnMusic();
                _RemoveBackgroundMusic();
                break;

            case EBackgroundMusicSource.TR_CONFIG_OWN_MUSIC:
                _AddBackgroundMusic();
                _AddOwnMusic();
                break;
            }
        }
Exemplo n.º 2
0
        private void SaveConfig()
        {
            EOffOn NewOffOn = (EOffOn)SelectSlides[htSelectSlides(SelectSlideBackgroundMusic)].Selection;
            EBackgroundMusicSource NewSource = (EBackgroundMusicSource)SelectSlides[htSelectSlides(SelectSlideBackgroundMusicSource)].Selection;
            float NewVolume = SelectSlides[htSelectSlides(SelectSlideBackgroundMusicVolume)].Selection * 5;

            CBackgroundMusic.CheckAndApplyConfig(NewOffOn, NewSource, NewVolume);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Initializes the background music with values from config
        ///     Has to be called before any other method is used
        /// </summary>
        public static void Init()
        {
            if (_Initialized)
            {
                return;
            }

            List <string> soundFiles = CHelper.ListSoundFiles(CSettings.FolderNameBackgroundMusic, true, true);

            foreach (string path in soundFiles)
            {
                _BGMusicFiles.Add(new CPlaylistElement(path));
            }
            _CurPlayer = _BGPlayer;
            //Set a default to have a consistent starting point, use SetMusicSource afterwards
            _MusicSource = EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC;
            _AddBackgroundMusic();

            SetMusicSource(CConfig.Config.Sound.BackgroundMusicSource);
            _Initialized = true;
        }
Exemplo n.º 4
0
        public static void CheckAndApplyConfig(EOffOn NewOnOff, EBackgroundMusicSource NewSource, float NewVolume)
        {
            if (CConfig.BackgroundMusic != NewOnOff)
            {
                CConfig.BackgroundMusic = NewOnOff;
                if (NewOnOff == EOffOn.TR_CONFIG_ON)
                {
                    Play();
                }
                else
                {
                    Pause();
                }
            }

            if (CConfig.BackgroundMusicSource != NewSource)
            {
                CConfig.BackgroundMusicSource = NewSource;

                switch (NewSource)
                {
                case EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC:
                    if (!_BackgroundMusicAdded)
                    {
                        AddBackgroundMusic();
                    }

                    RemoveOwnMusic();
                    break;

                case EBackgroundMusicSource.TR_CONFIG_ONLY_OWN_MUSIC:
                    if (!_OwnMusicAdded)
                    {
                        AddOwnMusic();
                    }

                    RemoveBackgroundMusic();
                    break;

                case EBackgroundMusicSource.TR_CONFIG_OWN_MUSIC:
                    if (!_BackgroundMusicAdded)
                    {
                        AddBackgroundMusic();
                    }

                    if (!_OwnMusicAdded)
                    {
                        AddOwnMusic();
                    }
                    break;
                }
            }

            if (CConfig.BackgroundMusicVolume != NewVolume)
            {
                CConfig.BackgroundMusicVolume = (int)NewVolume;
                ApplyVolume();
            }

            CConfig.SaveConfig();
        }
Exemplo n.º 5
0
        public static void CheckAndApplyConfig(EOffOn NewOnOff, EBackgroundMusicSource NewSource, float NewVolume)
        {
            if (CConfig.BackgroundMusic != NewOnOff)
            {
                CConfig.BackgroundMusic = NewOnOff;
                if (NewOnOff == EOffOn.TR_CONFIG_ON)
                    Play();
                else
                    Pause();
            }

            if (CConfig.BackgroundMusicSource != NewSource)
            {
                CConfig.BackgroundMusicSource = NewSource;

                switch (NewSource)
                {
                    case EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC:
                        if (!_BackgroundMusicAdded)
                            AddBackgroundMusic();

                        RemoveOwnMusic();
                        break;

                    case EBackgroundMusicSource.TR_CONFIG_ONLY_OWN_MUSIC:
                        if (!_OwnMusicAdded)
                            AddOwnMusic();

                        RemoveBackgroundMusic();
                        break;
                    case EBackgroundMusicSource.TR_CONFIG_OWN_MUSIC:
                        if (!_BackgroundMusicAdded)
                            AddBackgroundMusic();

                        if (!_OwnMusicAdded)
                            AddOwnMusic();
                        break;
                }
            }

            if (CConfig.BackgroundMusicVolume != NewVolume)
            {
                CConfig.BackgroundMusicVolume = (int)NewVolume;
                ApplyVolume();
            }

            CConfig.SaveConfig();
        }