diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs index 6d1065ed..5044030d 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs @@ -711,14 +711,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe if (_Fields[_Possibilities[i, j]].Content.Winner > 0) check.Add(_Fields[_Possibilities[i, j]].Content.Winner); } - if (check.Count == _Possibilities.GetLength(1)) - { - //Check for winner - if (check.Contains(1) && !check.Contains(2)) - return 1; - else if (check.Contains(2) && !check.Contains(1)) - return 2; - } + if (check.Count != _Possibilities.GetLength(1)) + continue; + //Check for winner + if (check.Contains(1) && !check.Contains(2)) + return 1; + if (check.Contains(2) && !check.Contains(1)) + return 2; } return 0; } diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs index c8e79710..fb355443 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using VocaluxeLib.Menu; @@ -209,8 +210,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe return true; } - // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar - else if (_SelectingMouseActive) + // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar + if (_SelectingMouseActive) { //Check if really a player was selected if (_SelectedPlayerNr != -1) @@ -571,44 +572,41 @@ namespace VocaluxeLib.PartyModes.TicTacToe private bool _OnAdd() { - for (int i = 0; i < _PlayerChooseButtons.Count; i++) + foreach (CPlayerChooseButton chooseButton in _PlayerChooseButtons.Where(chooseButton => chooseButton.Button.Selected && chooseButton.ProfileID != -1)) { - if (_PlayerChooseButtons[i].Button.Selected && _PlayerChooseButtons[i].ProfileID != -1) + if (_Data.ScreenNames.ProfileIDsTeam1.Count < _NumPlayerTeam1) { - if (_Data.ScreenNames.ProfileIDsTeam1.Count < _NumPlayerTeam1) - { - _Data.ScreenNames.ProfileIDsTeam1.Add(_PlayerChooseButtons[i].ProfileID); - int added = _Data.ScreenNames.ProfileIDsTeam1.Count - 1; - _UpdateButtonNext(); - //Update texture and name - _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); - _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); - _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; - _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; - _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName; - _PlayerDestinationButtons[added].Enabled = true; - //Update Tiles-List - _UpdateButtonPlayerChoose(); - _CheckInteraction(); - return true; - } - else if (_Data.ScreenNames.ProfileIDsTeam2.Count < _NumPlayerTeam2) - { - _Data.ScreenNames.ProfileIDsTeam2.Add(_PlayerChooseButtons[i].ProfileID); - int added = (_Data.ScreenNames.ProfileIDsTeam2.Count - 1) + _PlayerDestinationButtonsNumH; - _UpdateButtonNext(); - //Update texture and name - _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); - _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); - _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; - _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; - _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName; - _PlayerDestinationButtons[added].Enabled = true; - //Update Tiles-List - _UpdateButtonPlayerChoose(); - _CheckInteraction(); - return true; - } + _Data.ScreenNames.ProfileIDsTeam1.Add(chooseButton.ProfileID); + int added = _Data.ScreenNames.ProfileIDsTeam1.Count - 1; + _UpdateButtonNext(); + //Update texture and name + _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); + _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); + _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; + _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; + _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName; + _PlayerDestinationButtons[added].Enabled = true; + //Update Tiles-List + _UpdateButtonPlayerChoose(); + _CheckInteraction(); + return true; + } + if (_Data.ScreenNames.ProfileIDsTeam2.Count < _NumPlayerTeam2) + { + _Data.ScreenNames.ProfileIDsTeam2.Add(chooseButton.ProfileID); + int added = (_Data.ScreenNames.ProfileIDsTeam2.Count - 1) + _PlayerDestinationButtonsNumH; + _UpdateButtonNext(); + //Update texture and name + _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); + _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); + _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; + _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; + _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName; + _PlayerDestinationButtons[added].Enabled = true; + //Update Tiles-List + _UpdateButtonPlayerChoose(); + _CheckInteraction(); + return true; } } return false; diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index 5f81b346..bfd73230 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -45,7 +45,6 @@ namespace Vocaluxe.Base private static bool _OwnMusicAdded; private static bool _BackgroundMusicAdded; - private static bool _Playing; private static bool _Disabled; private static bool _CanSing; private static bool _RepeatSong; @@ -107,10 +106,7 @@ namespace Vocaluxe.Base get { return File.Exists(_CurrentPlaylistElement.VideoFilePath); } } - public static bool Playing - { - get { return _Playing; } - } + public static bool Playing { get; private set; } public static string ArtistAndTitle { @@ -118,8 +114,7 @@ namespace Vocaluxe.Base { if (_CurrentPlaylistElement.Artist != "" && _CurrentPlaylistElement.Title != "") return _CurrentPlaylistElement.Artist + " - " + _CurrentPlaylistElement.Title; - else - return Path.GetFileNameWithoutExtension(_CurrentPlaylistElement.MusicFilePath); + return Path.GetFileNameWithoutExtension(_CurrentPlaylistElement.MusicFilePath); } } @@ -143,12 +138,12 @@ namespace Vocaluxe.Base if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON) _VideoEnabled = true; - _Playing = false; + Playing = false; } public static void Play() { - if (_Playing) + if (Playing) return; if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON) @@ -161,7 +156,7 @@ namespace Vocaluxe.Base CSound.Play(_CurrentMusicStream); if (_VideoEnabled && _Video != -1) CVideo.VdResume(_Video); - _Playing = true; + Playing = true; } else Next(); @@ -176,7 +171,7 @@ namespace Vocaluxe.Base public static void Stop() { - if (!_Playing) + if (!Playing) return; if (_VideoEnabled && _Video != -1) @@ -189,12 +184,12 @@ namespace Vocaluxe.Base _CurrentMusicStream = -1; _CurrentPlaylistElement = new CPlaylistElement(); - _Playing = false; + Playing = false; } public static void Pause() { - if (!_Playing) + if (!Playing) return; if (_VideoEnabled && _Video != -1) @@ -203,7 +198,7 @@ namespace Vocaluxe.Base CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap); } CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime); - _Playing = false; + Playing = false; } public static void Update() @@ -217,7 +212,7 @@ namespace Vocaluxe.Base timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream); bool finished = CSound.IsFinished(_CurrentMusicStream); - if (_Playing && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished)) + if (Playing && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished)) { if (_RepeatSong) { @@ -228,7 +223,7 @@ namespace Vocaluxe.Base CSound.SetPosition(_CurrentMusicStream, 0); if (_VideoEnabled && _Video != -1) { - if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) + if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); else CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); @@ -269,7 +264,7 @@ namespace Vocaluxe.Base CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume); //Seek to #Start-Tag, if found - if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) + if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start); if (_VideoEnabled) @@ -289,13 +284,13 @@ namespace Vocaluxe.Base if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f) { //Seek to #Start-Tag, if found - if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) + if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start); else CSound.SetPosition(_CurrentMusicStream, 0); if (_VideoEnabled && _Video != -1) { - if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) + if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); else CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); @@ -321,7 +316,7 @@ namespace Vocaluxe.Base else if (_CurrentMusicStream != -1) { //Seek to #Start-Tag, if found - if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) + if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start); else CSound.SetPosition(_CurrentMusicStream, 0); @@ -499,7 +494,7 @@ namespace Vocaluxe.Base if (_Video == -1) { _Video = CVideo.VdLoad(_CurrentPlaylistElement.VideoFilePath); - if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) + if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); else CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 6a41e5fb..fa0ee5cf 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -314,31 +314,28 @@ namespace Vocaluxe.Base reader.Dispose(); return id; } - else + if (reader != null) + reader.Close(); + + command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " + + "VALUES (@title, @artist, @numplayed)"; + command.Parameters.Add("@title", DbType.String, 0).Value = title; + command.Parameters.Add("@artist", DbType.String, 0).Value = artist; + command.Parameters.Add("@numplayed", DbType.Int32, 0).Value = defNumPlayed; + command.ExecuteNonQuery(); + + command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist"; + command.Parameters.Add("@title", DbType.String, 0).Value = title; + command.Parameters.Add("@artist", DbType.String, 0).Value = artist; + + reader = command.ExecuteReader(); + + if (reader != null) { - if (reader != null) - reader.Close(); - - command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " + - "VALUES (@title, @artist, @numplayed)"; - command.Parameters.Add("@title", DbType.String, 0).Value = title; - command.Parameters.Add("@artist", DbType.String, 0).Value = artist; - command.Parameters.Add("@numplayed", DbType.Int32, 0).Value = defNumPlayed; - command.ExecuteNonQuery(); - - command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist"; - command.Parameters.Add("@title", DbType.String, 0).Value = title; - command.Parameters.Add("@artist", DbType.String, 0).Value = artist; - - reader = command.ExecuteReader(); - - if (reader != null) - { - reader.Read(); - int id = reader.GetInt32(0); - reader.Dispose(); - return id; - } + reader.Read(); + int id = reader.GetInt32(0); + reader.Dispose(); + return id; } return -1; diff --git a/Vocaluxe/Base/CLanguage.cs b/Vocaluxe/Base/CLanguage.cs index 21fa3796..9b7da582 100644 --- a/Vocaluxe/Base/CLanguage.cs +++ b/Vocaluxe/Base/CLanguage.cs @@ -225,11 +225,8 @@ namespace Vocaluxe.Base _Languages[nr].PartyModeTexts.Add(lang); return true; } - else - { - CLog.LogError("Error reading Party Language File " + file); - return false; - } + CLog.LogError("Error reading Party Language File " + file); + return false; } private static void _LoadLanguageFile(string fileName) diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index f69c922b..ee116549 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -160,7 +160,9 @@ namespace Vocaluxe.Base { string version = ProgramName; + // ReSharper disable ConditionIsAlwaysTrueOrFalse if (ProgramCodeName != "") + // ReSharper restore ConditionIsAlwaysTrueOrFalse version += " \"" + ProgramCodeName + "\""; return version + " " + GetVersionText(); diff --git a/Vocaluxe/Base/CSongSorter.cs b/Vocaluxe/Base/CSongSorter.cs index 7e589b2a..96e39b3d 100644 --- a/Vocaluxe/Base/CSongSorter.cs +++ b/Vocaluxe/Base/CSongSorter.cs @@ -50,11 +50,10 @@ namespace Vocaluxe.Base get { return _IgnoreArticles; } set { - if (value != _IgnoreArticles) - { - _IgnoreArticles = value; - _SetChanged(); - } + if (value == _IgnoreArticles) + return; + _IgnoreArticles = value; + _SetChanged(); } } @@ -63,11 +62,10 @@ namespace Vocaluxe.Base get { return _SongSorting; } set { - if (value != _SongSorting) - { - _SongSorting = value; - _SetChanged(); - } + if (value == _SongSorting) + return; + _SongSorting = value; + _SetChanged(); } } @@ -88,36 +86,28 @@ namespace Vocaluxe.Base private int _SortByFieldArtistTitle(SSongPointer s1, SSongPointer s2) { - int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); + int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase); if (res == 0) { if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) { - res = CSongs.Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].ArtistSorting.ToUpper()); - if (res == 0) - return CSongs.Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].TitleSorting.ToUpper()); - return res; - } - else - { - res = CSongs.Songs[s1.SongID].Artist.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Artist.ToUpper()); - if (res == 0) - return CSongs.Songs[s1.SongID].Title.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Title.ToUpper()); - return res; + res = String.Compare(CSongs.Songs[s1.SongID].ArtistSorting, CSongs.Songs[s2.SongID].ArtistSorting, StringComparison.OrdinalIgnoreCase); + return res != 0 ? res: String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.OrdinalIgnoreCase); } + res = String.Compare(CSongs.Songs[s1.SongID].Artist, CSongs.Songs[s2.SongID].Artist, StringComparison.OrdinalIgnoreCase); + return res != 0 ? res : String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.OrdinalIgnoreCase); } return res; } private int _SortByFieldTitle(SSongPointer s1, SSongPointer s2) { - int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); + int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase); if (res == 0) { - if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) - return CSongs.Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].TitleSorting.ToUpper()); - else - return CSongs.Songs[s1.SongID].Title.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Title.ToUpper()); + return _IgnoreArticles == EOffOn.TR_CONFIG_ON + ? String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.OrdinalIgnoreCase) : + String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.OrdinalIgnoreCase); } return res; } @@ -177,16 +167,10 @@ namespace Vocaluxe.Base break; case ESongSorting.TR_CONFIG_ARTIST_LETTER: case ESongSorting.TR_CONFIG_ARTIST: - if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) - fieldName = "ArtistSorting"; - else - fieldName = "Artist"; + fieldName = _IgnoreArticles == EOffOn.TR_CONFIG_ON ? "ArtistSorting" : "Artist"; break; case ESongSorting.TR_CONFIG_TITLE_LETTER: - if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) - fieldName = "TitleSorting"; - else - fieldName = "Title"; + fieldName = _IgnoreArticles == EOffOn.TR_CONFIG_ON ? "TitleSorting" : "Title"; break; case ESongSorting.TR_CONFIG_YEAR: case ESongSorting.TR_CONFIG_DECADE: diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 68f46f4c..6a2ecea7 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -205,8 +205,7 @@ namespace Vocaluxe.Base { if ((Categorizer.Categories.Count > 0) && (_CatIndex >= 0) && (Categorizer.Categories.Count > _CatIndex)) return Categorizer.Categories[_CatIndex].Name; - else - return String.Empty; + return String.Empty; } public static CSong GetSong(int songID) diff --git a/Vocaluxe/Base/CTheme.cs b/Vocaluxe/Base/CTheme.cs index c61499f3..be7fd8f9 100644 --- a/Vocaluxe/Base/CTheme.cs +++ b/Vocaluxe/Base/CTheme.cs @@ -548,7 +548,7 @@ namespace Vocaluxe.Base { if (partyModeID != -1 && _Skins[i].PartyModeID == partyModeID) return i; - else if (partyModeID == -1 && _Skins[i].Name == CConfig.Skin) + if (partyModeID == -1 && _Skins[i].Name == CConfig.Skin) return i; } @@ -561,7 +561,7 @@ namespace Vocaluxe.Base { if (partyModeID != -1 && _Themes[i].PartyModeID == partyModeID) return i; - else if (partyModeID == -1 && _Themes[i].Name == CConfig.Theme) + if (partyModeID == -1 && _Themes[i].Name == CConfig.Theme) return i; } @@ -597,22 +597,12 @@ namespace Vocaluxe.Base return _GetSkinFileName(skinName, GetSkinIndex(partyModeID), true); } - private static string _GetSkinFileName(string skinName, int skinIndex) - { - return _GetSkinFileName(skinName, skinIndex, false); - } - - private static string _GetSkinFileName(string skinName, int skinIndex, bool returnPath) + private static string _GetSkinFileName(string skinName, int skinIndex, bool returnPath = false) { foreach (SSkinElement sk in _Skins[skinIndex].SkinList.Values) { if (sk.Name == skinName) - { - if (!returnPath) - return sk.Value; - else - return Path.Combine(_Skins[skinIndex].Path, sk.Value); - } + return !returnPath ? sk.Value : Path.Combine(_Skins[skinIndex].Path, sk.Value); } CLog.LogError("Can't find Skin Element \"" + skinName); @@ -695,22 +685,12 @@ namespace Vocaluxe.Base return _GetVideoFileName(videoName, GetSkinIndex(partyModeID), true); } - private static string _GetVideoFileName(string videoName, int skinIndex) - { - return _GetVideoFileName(videoName, skinIndex, false); - } - - private static string _GetVideoFileName(string videoName, int skinIndex, bool returnPath) + private static string _GetVideoFileName(string videoName, int skinIndex, bool returnPath = false) { foreach (SSkinElement sk in _Skins[skinIndex].VideoList) { if (sk.Name == videoName) - { - if (!returnPath) - return sk.Value; - else - return Path.Combine(_Skins[skinIndex].Path, sk.Value); - } + return !returnPath ? sk.Value : Path.Combine(_Skins[skinIndex].Path, sk.Value); } CLog.LogError("Can't find Video Element \"" + videoName); diff --git a/Vocaluxe/Base/CUtility.cs b/Vocaluxe/Base/CUtility.cs index 8ff7f225..ce357ea9 100644 --- a/Vocaluxe/Base/CUtility.cs +++ b/Vocaluxe/Base/CUtility.cs @@ -59,11 +59,9 @@ namespace Vocaluxe.Base long ticks = _Stopwatch.ElapsedTicks; if (Stopwatch.IsHighResolution && ticks != 0) return (float)((_NanosecPerTick * ticks) / (1000.0 * 1000.0)); - else - return _Stopwatch.ElapsedMilliseconds; + return _Stopwatch.ElapsedMilliseconds; } - else - return 0f; + return 0f; } public static float CalculateFPS() @@ -190,8 +188,7 @@ namespace Vocaluxe.Base _Del(0); return true; } - else - return false; + return false; } public void CopyEvents() diff --git a/Vocaluxe/Lib/Sound/IPlayback.cs b/Vocaluxe/Lib/Sound/IPlayback.cs index 69058546..d6f6d563 100644 --- a/Vocaluxe/Lib/Sound/IPlayback.cs +++ b/Vocaluxe/Lib/Sound/IPlayback.cs @@ -17,8 +17,6 @@ // */ #endregion -using System; - namespace Vocaluxe.Lib.Sound { struct SAudioStreams diff --git a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs index 6aae01ae..135d3129 100644 --- a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs +++ b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs @@ -661,7 +661,7 @@ namespace Vocaluxe.Lib.Video if (num >= 0) { - if (frame.Index == -1 || _Width != (int) frame.Width || _Height != (int) frame.Height) + if (frame.Index == -1 || _Width != (int)frame.Width || _Height != (int)frame.Height) { CDraw.RemoveTexture(ref frame); frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].Data); diff --git a/Vocaluxe/Lib/Video/IVideoDecoder.cs b/Vocaluxe/Lib/Video/IVideoDecoder.cs index da0db810..4dc3905a 100644 --- a/Vocaluxe/Lib/Video/IVideoDecoder.cs +++ b/Vocaluxe/Lib/Video/IVideoDecoder.cs @@ -17,7 +17,6 @@ // */ #endregion -using System; using VocaluxeLib.Menu; namespace Vocaluxe.Lib.Video diff --git a/Vocaluxe/Lib/Webcam/CAForgeNet.cs b/Vocaluxe/Lib/Webcam/CAForgeNet.cs index 6ba3577f..446cf681 100644 --- a/Vocaluxe/Lib/Webcam/CAForgeNet.cs +++ b/Vocaluxe/Lib/Webcam/CAForgeNet.cs @@ -17,7 +17,6 @@ // */ #endregion -using System; using AForge.Video; using AForge.Video.DirectShow; using System.Collections.Generic; @@ -57,7 +56,7 @@ namespace Vocaluxe.Lib.Webcam { lock (_MutexData) { - if (frame.Index == -1 || _Width != (int) frame.Width || _Height != (int)frame.Height) + if (frame.Index == -1 || _Width != (int)frame.Width || _Height != (int)frame.Height) { CDraw.RemoveTexture(ref frame); frame = CDraw.AddTexture(_Width, _Height, ref _Data); diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 62b9dbdf..361c5f6d 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -317,7 +317,7 @@ namespace Vocaluxe.Screens { _CurrentTime = CSound.GetPosition(_CurrentStream); - if (_FinishTime >0.001 && _CurrentTime >= _FinishTime) + if (_FinishTime > 0.001 && _CurrentTime >= _FinishTime) finish = true; } else @@ -1038,13 +1038,11 @@ namespace Vocaluxe.Screens private float[] _CalcFadingAlpha() { - float dt = 4f; - float rt = dt * 0.8f; + const float dt = 4f; + const float rt = dt * 0.8f; CSong song = CGame.GetSong(); - if (song == null) - return null; - else if (!song.NotesLoaded) + if (song == null || !song.NotesLoaded) return null; float[] alpha = new float[song.Notes.Lines.Length * 2]; diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 8e9dcde9..9db36407 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -463,24 +463,24 @@ namespace Vocaluxe.Screens _ToggleSongOptions(ESongOptionsView.General); return true; } - else if (_Buttons[_ButtonOptionsClose].Selected) + if (_Buttons[_ButtonOptionsClose].Selected) { _ToggleSongOptions(ESongOptionsView.None); return true; } - else if (_Buttons[_ButtonOptionsSing].Selected) + if (_Buttons[_ButtonOptionsSing].Selected) { _ToggleSongOptions(ESongOptionsView.None); _StartSong(_SongMenus[_SongMenu].GetSelectedSong()); return true; } - else if (_Buttons[_ButtonOptionsPlaylist].Selected) + if (_Buttons[_ButtonOptionsPlaylist].Selected) { _ToggleSongOptions(ESongOptionsView.None); _OpenAndAddPlaylistAction(); return true; } - else if (_Buttons[_ButtonOptionsRandom].Selected) + if (_Buttons[_ButtonOptionsRandom].Selected) { if (CSongs.IsInCategory) { @@ -558,11 +558,8 @@ namespace Vocaluxe.Screens _ToggleSongOptions(ESongOptionsView.Song); return true; } - else - { - _ToggleSongOptions(ESongOptionsView.None); - return true; - } + _ToggleSongOptions(ESongOptionsView.None); + return true; } } diff --git a/VocaluxeLib/Menu/CLyric.cs b/VocaluxeLib/Menu/CLyric.cs index 6e928c4a..2d18e6ec 100644 --- a/VocaluxeLib/Menu/CLyric.cs +++ b/VocaluxeLib/Menu/CLyric.cs @@ -503,7 +503,7 @@ namespace VocaluxeLib.Menu if (diff <= 0) diff = 1; - float p = 1f-(currentBeat - _Notes[jumpNote].StartBeat) / diff; + float p = 1f - (currentBeat - _Notes[jumpNote].StartBeat) / diff; if (Math.Abs(p) < float.Epsilon) _Text.Draw(); diff --git a/VocaluxeLib/Menu/CObjectInteractions.cs b/VocaluxeLib/Menu/CObjectInteractions.cs index 5f7d6044..1dd503ef 100644 --- a/VocaluxeLib/Menu/CObjectInteractions.cs +++ b/VocaluxeLib/Menu/CObjectInteractions.cs @@ -500,10 +500,7 @@ namespace VocaluxeLib.Menu if (_Selection >= _Interactions.Count || _Selection < 0) return false; - if (_Interactions.Count > 0) - return _IsMouseOver(x, y, _Interactions[_Selection]); - else - return false; + return _Interactions.Count > 0 && _IsMouseOver(x, y, _Interactions[_Selection]); } private bool _IsMouseOver(int x, int y, CInteraction interact) @@ -789,10 +786,7 @@ namespace VocaluxeLib.Menu inDirection = true; break; } - if (!inDirection) - return float.MaxValue; - else - return distance; + return !inDirection ? float.MaxValue : distance; } private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect) @@ -825,10 +819,7 @@ namespace VocaluxeLib.Menu inDirection = true; break; } - if (!inDirection) - return float.MaxValue; - else - return distance; + return !inDirection ? float.MaxValue : distance; } /// diff --git a/VocaluxeLib/Menu/CPlaylist.cs b/VocaluxeLib/Menu/CPlaylist.cs index b748048d..ed2bff99 100644 --- a/VocaluxeLib/Menu/CPlaylist.cs +++ b/VocaluxeLib/Menu/CPlaylist.cs @@ -873,7 +873,7 @@ namespace VocaluxeLib.Menu } return true; } - else if (mouseEvent.Wheel < 0) + if (mouseEvent.Wheel < 0) { if (Offset + mouseEvent.Wheel >= 0) { @@ -925,23 +925,23 @@ namespace VocaluxeLib.Menu ClosePlaylist(); return true; } - else if (_Theme.ButtonPlaylistSing.Selected) + if (_Theme.ButtonPlaylistSing.Selected) { _StartPlaylistSongs(); return true; } - else if (_Theme.ButtonPlaylistSave.Selected) + if (_Theme.ButtonPlaylistSave.Selected) { CBase.Playlist.SavePlaylist(ActivePlaylistID); return true; } - else if (_Theme.ButtonPlaylistDelete.Selected) + if (_Theme.ButtonPlaylistDelete.Selected) { CBase.Playlist.DeletePlaylist(ActivePlaylistID); ClosePlaylist(); return true; } - else if (_Theme.ButtonPlaylistName.Selected) + if (_Theme.ButtonPlaylistName.Selected) { EditMode = EEditMode.PlaylistName; _Theme.ButtonPlaylistName.EditMode = true; @@ -1159,8 +1159,7 @@ namespace VocaluxeLib.Menu Update(); return true; } - else - return false; + return false; } public void UpdatePlaylist() diff --git a/VocaluxeLib/Menu/CSelectSlide.cs b/VocaluxeLib/Menu/CSelectSlide.cs index 4886658a..792fdc25 100644 --- a/VocaluxeLib/Menu/CSelectSlide.cs +++ b/VocaluxeLib/Menu/CSelectSlide.cs @@ -134,8 +134,7 @@ namespace VocaluxeLib.Menu { if (_Selection >= 0 && _ValueIndexes.Count > _Selection) return _ValueIndexes[_Selection]; - else - return -1; + return -1; } } diff --git a/VocaluxeLib/Menu/CStatic.cs b/VocaluxeLib/Menu/CStatic.cs index 50bf7278..39ed21d7 100644 --- a/VocaluxeLib/Menu/CStatic.cs +++ b/VocaluxeLib/Menu/CStatic.cs @@ -45,13 +45,7 @@ namespace VocaluxeLib.Menu private STexture _Texture; public STexture Texture { - get - { - if (_Texture.Index != -1) - return _Texture; - else - return CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); - } + get { return _Texture.Index != -1 ? _Texture : CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); } set { _Texture = value; } } diff --git a/VocaluxeLib/Menu/CText.cs b/VocaluxeLib/Menu/CText.cs index c193ed8d..e148d062 100644 --- a/VocaluxeLib/Menu/CText.cs +++ b/VocaluxeLib/Menu/CText.cs @@ -143,7 +143,8 @@ namespace VocaluxeLib.Menu get { return _Bounds; } set { - if (Math.Abs(_Bounds.X - value.X) > 0.01 || Math.Abs(_Bounds.Y - value.Y) > 0.01 || Math.Abs(_Bounds.W - value.W) > 0.01 || Math.Abs(_Bounds.H - value.H) > 0.01 || Math.Abs(_Bounds.Z - value.Z) > 0.01) + if (Math.Abs(_Bounds.X - value.X) > 0.01 || Math.Abs(_Bounds.Y - value.Y) > 0.01 || Math.Abs(_Bounds.W - value.W) > 0.01 || Math.Abs(_Bounds.H - value.H) > 0.01 || + Math.Abs(_Bounds.Z - value.Z) > 0.01) { _Bounds = value; _PositionNeedsUpdate = true; diff --git a/VocaluxeLib/Menu/SingNotes/CNotes.cs b/VocaluxeLib/Menu/SingNotes/CNotes.cs index 21377ab5..f2308693 100644 --- a/VocaluxeLib/Menu/SingNotes/CNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CNotes.cs @@ -379,24 +379,12 @@ namespace VocaluxeLib.Menu.SingNotes public CNote FirstNote { - get - { - if (_Notes.Count > 0) - return _Notes[0]; - else - return null; - } + get { return _Notes.Count > 0 ? _Notes[0] : null; } } public CNote LastNote { - get - { - if (_Notes.Count > 0) - return _Notes[_Notes.Count - 1]; - else - return null; - } + get { return _Notes.Count > 0 ? _Notes[_Notes.Count - 1] : null; } } public int BaseLine diff --git a/VocaluxeLib/Menu/SongMenu/CSong.cs b/VocaluxeLib/Menu/SongMenu/CSong.cs index c77e46da..38f5dc4a 100644 --- a/VocaluxeLib/Menu/SongMenu/CSong.cs +++ b/VocaluxeLib/Menu/SongMenu/CSong.cs @@ -66,13 +66,7 @@ namespace VocaluxeLib.Menu.SongMenu public STexture CoverTextureBig { - get - { - if (_CoverBigLoaded) - return _CoverTextureBig; - else - return _CoverTextureSmall; - } + get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; } set { if (value.Index != -1) @@ -1016,11 +1010,8 @@ namespace VocaluxeLib.Menu.SongMenu ShortEnd = lines.Line[series[i].Start - 1].LastNote.EndBeat; return; } - else - { - ShortEnd = lines.Line[series[i].End].LastNote.EndBeat; - return; - } + ShortEnd = lines.Line[series[i].End].LastNote.EndBeat; + return; } } diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index 56ee0519..7ed861c6 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -367,7 +367,7 @@ namespace VocaluxeLib.Menu.SongMenu mouseEvent.Handled = true; return; } - else if (mouseEvent.RB && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && !songOptions.Selection.PartyMode) + if (mouseEvent.RB && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && !songOptions.Selection.PartyMode) CBase.Graphics.FadeTo(EScreens.ScreenMain); else if (_PreviewSelected != -1 && mouseEvent.LB && CBase.Songs.GetCurrentCategoryIndex() != -1 && !songOptions.Selection.PartyMode) {