diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index de114f20..d4679b96 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -106,7 +106,7 @@ namespace Vocaluxe.Base get { return File.Exists(_CurrentPlaylistElement.VideoFilePath); } } - public static bool Playing { get; private set; } + public static bool IsPlaying { get; private set; } public static string ArtistAndTitle { @@ -138,12 +138,12 @@ namespace Vocaluxe.Base if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON) _VideoEnabled = true; - Playing = false; + IsPlaying = false; } public static void Play() { - if (Playing) + if (IsPlaying) return; if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON) @@ -156,7 +156,7 @@ namespace Vocaluxe.Base CSound.Play(_CurrentMusicStream); if (_VideoEnabled && _Video != -1) CVideo.VdResume(_Video); - Playing = true; + IsPlaying = true; } else Next(); @@ -168,7 +168,7 @@ namespace Vocaluxe.Base public static void Stop() { - if (!Playing) + if (!IsPlaying) return; if (_VideoEnabled && _Video != -1) @@ -181,12 +181,12 @@ namespace Vocaluxe.Base _CurrentMusicStream = -1; _CurrentPlaylistElement = new CPlaylistElement(); - Playing = false; + IsPlaying = false; } public static void Pause() { - if (!Playing) + if (!IsPlaying) return; if (_VideoEnabled && _Video != -1) @@ -195,7 +195,7 @@ namespace Vocaluxe.Base CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap); } CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime); - Playing = false; + IsPlaying = false; } public static void Update() @@ -209,7 +209,7 @@ namespace Vocaluxe.Base timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream); bool finished = CSound.IsFinished(_CurrentMusicStream); - if (Playing && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished)) + if (IsPlaying && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished)) { if (_RepeatSong) { @@ -355,7 +355,7 @@ namespace Vocaluxe.Base _NotPlayedFileNames.AddRange(_BGMusicFileNames); } - if (Playing && !_IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0) + if (IsPlaying && !_IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0) Next(); _OwnMusicAdded = false; @@ -380,7 +380,7 @@ namespace Vocaluxe.Base AddOwnMusic(); _BackgroundMusicAdded = false; - if (Playing && _IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0) + if (IsPlaying && _IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0) Next(); } } diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index ed3287be..32f00ea8 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -77,7 +77,7 @@ namespace Vocaluxe.Base public static ERecordLib RecordLib = ERecordLib.PortAudio; public static EBufferSize AudioBufferSize = EBufferSize.B2048; public static int AudioLatency; - public static int BackgroundMusicVolume = 30; + private static int _BackgroundMusicVolume = 30; public static EOffOn BackgroundMusic = EOffOn.TR_CONFIG_ON; public static EBackgroundMusicSource BackgroundMusicSource = EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC; public static EOffOn BackgroundMusicUseStart = EOffOn.TR_CONFIG_ON; @@ -118,6 +118,19 @@ namespace Vocaluxe.Base //Variables to save old values for commandline-parameters private static readonly List _SongFolderOld = new List(); + public static int BackgroundMusicVolume + { + get { return _BackgroundMusicVolume; } + set { + if (value < 0) + _BackgroundMusicVolume = 0; + else if (value > 100) + _BackgroundMusicVolume = 100; + else + _BackgroundMusicVolume = value; + SaveConfig(); + } + } public static void Init() { @@ -180,7 +193,7 @@ namespace Vocaluxe.Base xmlReader.TryGetIntValueRange("//root/Sound/AudioLatency", ref AudioLatency, -500, 500); xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusic", ref BackgroundMusic); - xmlReader.TryGetIntValueRange("//root/Sound/BackgroundMusicVolume", ref BackgroundMusicVolume); + xmlReader.TryGetIntValueRange("//root/Sound/BackgroundMusicVolume", ref _BackgroundMusicVolume); xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicSource", ref BackgroundMusicSource); xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicUseStart", ref BackgroundMusicUseStart); xmlReader.TryGetIntValueRange("//root/Sound/PreviewMusicVolume", ref PreviewMusicVolume); @@ -591,6 +604,19 @@ namespace Vocaluxe.Base return false; } + public static int GetMaxNumMics() + { + int max = 0; + for (int i = 0; i < CSettings.MaxNumPlayer; i++) + { + if (IsMicConfig(i + 1)) + max = i + 1; + else + break; + } + return max; + } + /// /// Try to assign automatically player 1 and 2 to usb-mics. /// diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index eff9e0c4..84f51c5a 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -411,7 +411,7 @@ namespace Vocaluxe.Base GC.Collect(); _CurrentScreen = _NextScreen; _NextScreen = EScreens.ScreenNull; - if (CBackgroundMusic.Playing) + if (CBackgroundMusic.IsPlaying) CBackgroundMusic.Play(); _Screens[(int)_CurrentScreen].OnShowFinish(); _Screens[(int)_CurrentScreen].ProcessMouseMove(_Cursor.X, _Cursor.Y); @@ -542,15 +542,15 @@ namespace Vocaluxe.Base if (popupPlayerControlAllowed && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON) { if (keyEvent.Key == Keys.MediaNextTrack) - CMain.BackgroundMusic.Next(); + CBackgroundMusic.Next(); else if (keyEvent.Key == Keys.MediaPreviousTrack) - CMain.BackgroundMusic.Previous(); + CBackgroundMusic.Previous(); else if (keyEvent.Key == Keys.MediaPlayPause) { - if (CMain.BackgroundMusic.IsPlaying()) - CMain.BackgroundMusic.Pause(); + if (CBackgroundMusic.IsPlaying) + CBackgroundMusic.Pause(); else - CMain.BackgroundMusic.Play(); + CBackgroundMusic.Play(); } } @@ -600,7 +600,7 @@ namespace Vocaluxe.Base _VolumePopupTimer.Start(); } - CMain.BackgroundMusic.ApplyVolume(); + CBackgroundMusic.ApplyVolume(); } if (keyEvent.ModShift && (keyEvent.Key == Keys.F1)) diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 64cbbb9c..59e7d962 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -27,30 +27,30 @@ namespace Vocaluxe.Base { static class CMain { - public static readonly IConfig Config = new CBconfig(); - public static readonly ISettings Settings = new CBsettings(); - public static readonly ITheme Theme = new CBtheme(); - public static readonly IBackgroundMusic BackgroundMusic = new CBbackgroundMusic(); - public static readonly IDrawing Draw = new CBdraw(); - public static IGraphics Graphics = new CBGraphics(); - public static ILog Log = new CBlog(); - public static IFonts Fonts = new CBfonts(); - public static ILanguage Language = new CBlanguage(); - public static IGame Game = new CBGame(); - public static IProfiles Profiles = new CBprofiles(); - public static IRecording Record = new CBrecord(); - public static ISongs Songs = new CBsongs(); - public static IVideo Video = new CBvideo(); - public static ISound Sound = new CBsound(); - public static ICover Cover = new CBcover(); - public static IDataBase DataBase = new CBdataBase(); - public static IInputs Input = new CBinputs(); - public static IPlaylist Playlist = new CBplaylist(); + private static readonly IConfig _Config = new CBconfig(); + private static readonly ISettings _Settings = new CBsettings(); + private static readonly ITheme _Theme = new CBtheme(); + private static readonly IBackgroundMusic _BackgroundMusic = new CBbackgroundMusic(); + private static readonly IDrawing _Draw = new CBdraw(); + private static readonly IGraphics _Graphics = new CBGraphics(); + private static readonly ILog _Log = new CBlog(); + private static readonly IFonts _Fonts = new CBfonts(); + private static readonly ILanguage _Language = new CBlanguage(); + private static readonly IGame _Game = new CBGame(); + private static readonly IProfiles _Profiles = new CBprofiles(); + private static readonly IRecording _Record = new CBrecord(); + private static readonly ISongs _Songs = new CBsongs(); + private static readonly IVideo _Video = new CBvideo(); + private static readonly ISound _Sound = new CBsound(); + private static readonly ICover _Cover = new CBcover(); + private static readonly IDataBase _DataBase = new CBdataBase(); + private static readonly IInputs _Input = new CBinputs(); + private static readonly IPlaylist _Playlist = new CBplaylist(); public static void Init() { - CBase.Assign(Config, Settings, Theme, Log, BackgroundMusic, Draw, Graphics, Fonts, Language, - Game, Profiles, Record, Songs, Video, Sound, Cover, DataBase, Input, Playlist); + CBase.Assign(_Config, _Settings, _Theme, _Log, _BackgroundMusic, _Draw, _Graphics, _Fonts, _Language, + _Game, _Profiles, _Record, _Songs, _Video, _Sound, _Cover, _DataBase, _Input, _Playlist); } } @@ -58,14 +58,7 @@ namespace Vocaluxe.Base { public void SetBackgroundMusicVolume(int newVolume) { - if (newVolume < 0) - CConfig.BackgroundMusicVolume = 0; - else if (newVolume > 100) - CConfig.BackgroundMusicVolume = 100; - else - CConfig.BackgroundMusicVolume = newVolume; - - CConfig.SaveConfig(); + CConfig.BackgroundMusicVolume = newVolume; } public int GetBackgroundMusicVolume() @@ -140,15 +133,7 @@ namespace Vocaluxe.Base public int GetMaxNumMics() { - int max = 0; - for (int i = 0; i < CSettings.MaxNumPlayer; i++) - { - if (CConfig.IsMicConfig(i + 1)) - max = i + 1; - else - break; - } - return max; + return CConfig.GetMaxNumMics(); } } @@ -302,7 +287,7 @@ namespace Vocaluxe.Base public bool IsPlaying() { - return CBackgroundMusic.Playing; + return CBackgroundMusic.IsPlaying; } public bool SongHasVideo() diff --git a/Vocaluxe/Base/CPlaylists.cs b/Vocaluxe/Base/CPlaylists.cs index d71bcda5..7611d242 100644 --- a/Vocaluxe/Base/CPlaylists.cs +++ b/Vocaluxe/Base/CPlaylists.cs @@ -227,7 +227,7 @@ namespace Vocaluxe.Base private static int _CompareByPlaylistName(CPlaylistFile a, CPlaylistFile b) { - return System.String.CompareOrdinal(a.PlaylistName, b.PlaylistName); + return String.CompareOrdinal(a.PlaylistName, b.PlaylistName); } private static CPlaylistFile _ConvertUSDXPlaylist(string file) diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs index d69effda..655cf08c 100644 --- a/Vocaluxe/Base/CProfiles.cs +++ b/Vocaluxe/Base/CProfiles.cs @@ -282,7 +282,7 @@ namespace Vocaluxe.Base private static int _CompareByPlayerName(SProfile a, SProfile b) { - return System.String.CompareOrdinal(a.PlayerName, b.PlayerName); + return String.CompareOrdinal(a.PlayerName, b.PlayerName); } #region private methods diff --git a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs index fd38ee1a..023ee4e2 100644 --- a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs +++ b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs @@ -189,8 +189,8 @@ namespace Vocaluxe.Screens _Statics[_StaticCover].Texture = CBackgroundMusic.Cover; if (CBackgroundMusic.VideoEnabled && _VideoPreview && CBackgroundMusic.SongHasVideo) CDraw.DrawTexture(_Statics[_StaticCover], CBackgroundMusic.GetVideoTexture(), EAspect.Crop); - _Buttons[_ButtonPause].Visible = CBackgroundMusic.Playing; - _Buttons[_ButtonPlay].Visible = !CBackgroundMusic.Playing; + _Buttons[_ButtonPause].Visible = CBackgroundMusic.IsPlaying; + _Buttons[_ButtonPlay].Visible = !CBackgroundMusic.IsPlaying; _Texts[_TextCurrentSong].Text = CBackgroundMusic.ArtistAndTitle; return base.Draw(); diff --git a/Vocaluxe/Screens/CScreenLoad.cs b/Vocaluxe/Screens/CScreenLoad.cs index 4d7dec77..1f25f6d1 100644 --- a/Vocaluxe/Screens/CScreenLoad.cs +++ b/Vocaluxe/Screens/CScreenLoad.cs @@ -141,7 +141,7 @@ namespace Vocaluxe.Screens { CBackgroundMusic.AddOwnMusic(); - if (!CBackgroundMusic.Playing) + if (!CBackgroundMusic.IsPlaying) CBackgroundMusic.Next(); _BGMusicStartet = true; @@ -177,7 +177,7 @@ namespace Vocaluxe.Screens { CBackgroundMusic.AddOwnMusic(); - if (!CBackgroundMusic.Playing) + if (!CBackgroundMusic.IsPlaying) CBackgroundMusic.Next(); _BGMusicStartet = true; diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs index b5f58a2d..46df559b 100644 --- a/Vocaluxe/Screens/CScreenParty.cs +++ b/Vocaluxe/Screens/CScreenParty.cs @@ -195,7 +195,7 @@ namespace Vocaluxe.Screens if (index >= _PartyModeInfos.Count) return; - if (CMain.Config.GetMaxNumMics() == 0) + if (CConfig.GetMaxNumMics() == 0) return; //TODO: Add message! if (_PartyModeInfos[index].Playable) diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 85551067..f9b69d1d 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -100,7 +100,7 @@ namespace Vocaluxe.Screens base.Init(); _ButtonsJoker.Clear(); - for (int i = 0; i < CMain.Settings.GetMaxNumPlayer(); i++) + for (int i = 0; i < CSettings.MaxNumPlayer; i++) _ButtonsJoker.Add("ButtonJoker" + (i + 1)); List blist = new List(); blist.AddRange(_ButtonsJoker); @@ -118,7 +118,7 @@ namespace Vocaluxe.Screens blist.Add(_ButtonOptionsStartMedley); _TextsPlayer.Clear(); - for (int i = 0; i < CMain.Settings.GetMaxNumPlayer(); i++) + for (int i = 0; i < CSettings.MaxNumPlayer; i++) _TextsPlayer.Add("TextPlayer" + (i + 1)); List tlist = new List(); tlist.AddRange(_TextsPlayer); @@ -751,7 +751,7 @@ namespace Vocaluxe.Screens if (!_SongMenus[_SongMenu].IsSmallView()) _SongMenus[_SongMenu].SetSmallView(true); - for (int i = 0; i < CMain.Settings.GetMaxNumPlayer(); i++) + for (int i = 0; i < CSettings.MaxNumPlayer; i++) { if (i < _Sso.Selection.NumJokers.Length) { @@ -784,7 +784,7 @@ namespace Vocaluxe.Screens if (_Sso.Selection.PartyMode && _SongMenus[_SongMenu].IsSmallView()) _SongMenus[_SongMenu].SetSmallView(false); - for (int i = 0; i < CMain.Settings.GetMaxNumPlayer(); i++) + for (int i = 0; i < CSettings.MaxNumPlayer; i++) { _Buttons[_ButtonsJoker[i]].Visible = false; _Texts[_TextsPlayer[i]].Visible = false;