From b8fe3341533bf258669659d6e4f0a41aa12c6eee Mon Sep 17 00:00:00 2001 From: Flamefire Date: Tue, 23 Apr 2013 22:11:32 +0200 Subject: [PATCH] Used object initializers --- .../PartyModeChallenge/CPartyModeChallenge.cs | 17 +---- .../CPartyScreenChallengeConfig.cs | 10 +-- .../CPartyScreenChallengeMain.cs | 36 ++++------ .../CPartyModeChallengeMedley.cs | 25 ++----- .../CPartyScreenChallengeMedleyConfig.cs | 10 +-- .../CPartyScreenChallengeMedleyMain.cs | 36 ++++------ .../CPartyScreenChallengeMedleyNames.cs | 9 +-- .../PartyModeTicTacToe/CPartyModeTicTacToe.cs | 53 ++++++-------- .../CPartyScreenTicTacToeMain.cs | 3 +- .../CPartyScreenTicTacToeNames.cs | 10 +-- Vocaluxe/Base/CBackgroundMusic.cs | 5 +- Vocaluxe/Base/CCover.cs | 2 +- Vocaluxe/Base/CDataBase.cs | 71 ++++++++----------- Vocaluxe/Base/CFont.cs | 6 +- Vocaluxe/Base/CGraphics.cs | 3 +- Vocaluxe/Base/CLanguage.cs | 6 +- Vocaluxe/Base/CParty.cs | 9 +-- Vocaluxe/Base/CPlaylists.cs | 3 +- Vocaluxe/Base/CProfiles.cs | 28 +++----- Vocaluxe/Base/CSettings.cs | 11 +-- Vocaluxe/Base/CSound.cs | 13 ++-- Vocaluxe/Base/CTheme.cs | 22 ++---- Vocaluxe/Base/CUtility.cs | 5 +- Vocaluxe/Base/CVideo.cs | 3 +- Vocaluxe/Lib/Draw/CDrawWinForm.cs | 15 +--- Vocaluxe/Lib/Playlist/CPlaylistFile.cs | 14 +--- Vocaluxe/Lib/Sound/CDirectSoundRecord.cs | 20 ++---- Vocaluxe/Lib/Sound/CPortAudioPlay.cs | 12 ++-- Vocaluxe/Lib/Sound/CPortAudioRecord.cs | 23 +++--- Vocaluxe/Screens/CScreenCredits.cs | 3 +- Vocaluxe/Screens/CScreenHighscore.cs | 9 +-- Vocaluxe/Screens/CScreenNames.cs | 13 +--- Vocaluxe/Screens/CScreenOptionsRecord.cs | 3 +- Vocaluxe/Screens/CScreenSing.cs | 47 +++++------- Vocaluxe/Screens/CScreenSong.cs | 10 +-- VocaluxeLib/Menu/CButton.cs | 27 +++---- VocaluxeLib/Menu/CNameSelection.cs | 8 +-- VocaluxeLib/Menu/CObjectInteractions.cs | 6 +- VocaluxeLib/Menu/CPlaylist.cs | 64 ++++++++--------- VocaluxeLib/Menu/CSelectSlide.cs | 41 +++++------ VocaluxeLib/Menu/CStatic.cs | 9 +-- VocaluxeLib/Menu/CText.cs | 5 +- VocaluxeLib/Menu/SingNotes/CNotes.cs | 3 +- VocaluxeLib/Menu/SingNotes/CSingNotes.cs | 3 +- VocaluxeLib/Menu/SongMenu/CSong.cs | 38 +++++----- .../Menu/SongMenu/CSongMenuFramework.cs | 27 +++---- VocaluxeLib/PartyModes/CPartyMode.cs | 8 +-- 47 files changed, 289 insertions(+), 515 deletions(-) diff --git a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs index e15974b2..e94d81b3 100644 --- a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs +++ b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs @@ -178,14 +178,7 @@ namespace VocaluxeLib.PartyModes.Challenge _ToScreenNames = new SDataToScreenNames(); _ToScreenMain = new SDataToScreenMain(); - _GameData = new SData(); - _GameData.NumPlayer = 4; - _GameData.NumPlayerAtOnce = 2; - _GameData.NumRounds = 2; - _GameData.CurrentRoundNr = 1; - _GameData.ProfileIDs = new List(); - _GameData.CatSongIndices = null; - _GameData.Results = null; + _GameData = new SData {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 2, CurrentRoundNr = 1, ProfileIDs = new List(), CatSongIndices = null, Results = null}; } public override bool Init() @@ -657,15 +650,11 @@ namespace VocaluxeLib.PartyModes.Challenge List result = new List(); for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) { - SStats stat = new SStats(); - stat.ProfileID = results[i].ProfileID; - stat.SingPoints = (int)Math.Round(results[i].Points); - stat.Won = 0; - stat.GamePoints = 0; + SStats stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0}; result.Add(stat); } - result.Sort(delegate(SStats s1, SStats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); }); + result.Sort((s1, s2) => s1.SingPoints.CompareTo(s2.SingPoints)); int current = result[result.Count - 1].SingPoints; int points = result.Count; diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs index bbbd930f..7e856321 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs @@ -53,10 +53,7 @@ namespace VocaluxeLib.PartyModes.Challenge _ThemeButtons = new string[] {_ButtonNext, _ButtonBack}; _Data = new SDataFromScreen(); - SFromScreenConfig config = new SFromScreenConfig(); - config.NumPlayer = 4; - config.NumPlayerAtOnce = 2; - config.NumRounds = 12; + SFromScreenConfig config = new SFromScreenConfig {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 12}; _Data.ScreenConfig = config; } @@ -227,10 +224,7 @@ namespace VocaluxeLib.PartyModes.Challenge int res = _Data.ScreenConfig.NumPlayer / _Data.ScreenConfig.NumPlayerAtOnce; int mod = _Data.ScreenConfig.NumPlayer % _Data.ScreenConfig.NumPlayerAtOnce; - if (mod == 0) - _RoundSteps = res; - else - _RoundSteps = _Data.ScreenConfig.NumPlayer; + _RoundSteps = mod == 0 ? res : _Data.ScreenConfig.NumPlayer; } private void _Back() diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs index 87d6704a..b0cf21bd 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs @@ -98,8 +98,7 @@ namespace VocaluxeLib.PartyModes.Challenge public CPartyScreenChallengeMain() { - _Data = new SDataFromScreen(); - _Data.ScreenMain = new SFromScreenMain(); + _Data = new SDataFromScreen {ScreenMain = new SFromScreenMain()}; } public override void Init() @@ -406,9 +405,7 @@ namespace VocaluxeLib.PartyModes.Challenge _RoundsTable = new List(); for (int i = 0; i < 5; i++) { - CRoundsTableRow rtr = new CRoundsTableRow(); - rtr.TextPlayer = new List(); - rtr.TextScores = new List(); + CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List(), TextScores = new List()}; _RoundsTable.Add(rtr); } //Create statics and texts for rounds @@ -438,11 +435,8 @@ namespace VocaluxeLib.PartyModes.Challenge { _RoundsTableScrollArea = new SRectF(); - int numPlayerInOneRow = 3; - if (_GameState.NumPlayerAtOnce <= numPlayerInOneRow) - _NumRoundsVisible = 5; - else - _NumRoundsVisible = 3; + const int numPlayerInOneRow = 3; + _NumRoundsVisible = _GameState.NumPlayerAtOnce <= numPlayerInOneRow ? 5 : 3; if (_NumRoundsVisible > _GameState.Combs.Count) _NumRoundsVisible = _GameState.Combs.Count; @@ -536,10 +530,7 @@ namespace VocaluxeLib.PartyModes.Challenge private void _BuildPlayerTable() { - _PlayerTableScrollArea = new SRectF(); - _PlayerTableScrollArea.X = _Texts[_TextPosition].X; - _PlayerTableScrollArea.Y = _Texts[_TextPosition].Y; - _PlayerTableScrollArea.W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X; + _PlayerTableScrollArea = new SRectF {X = _Texts[_TextPosition].X, Y = _Texts[_TextPosition].Y, W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X}; _PlayerTable = new List(); float delta = _Texts[_TextPosition].Height * 1.2f; @@ -548,14 +539,15 @@ namespace VocaluxeLib.PartyModes.Challenge for (int i = 0; i < 10; i++) { - STableRow row = new STableRow(); - - row.Pos = GetNewText(_Texts[_TextPosition]); - row.Name = GetNewText(_Texts[_TextPlayerName]); - row.Rounds = GetNewText(_Texts[_TextNumPlayed]); - row.Won = GetNewText(_Texts[_TextWon]); - row.SingPoints = GetNewText(_Texts[_TextSingPoints]); - row.GamePoints = GetNewText(_Texts[_TextGamePoints]); + STableRow row = new STableRow + { + Pos = GetNewText(_Texts[_TextPosition]), + Name = GetNewText(_Texts[_TextPlayerName]), + Rounds = GetNewText(_Texts[_TextNumPlayed]), + Won = GetNewText(_Texts[_TextWon]), + SingPoints = GetNewText(_Texts[_TextSingPoints]), + GamePoints = GetNewText(_Texts[_TextGamePoints]) + }; row.Pos.Y += delta * (i + 1); row.Name.Y += delta * (i + 1); diff --git a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs index a9f76d23..4b549c4e 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs @@ -182,14 +182,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley _ToScreenNames = new SDataToScreenNames(); _ToScreenMain = new SDataToScreenMain(); - _GameData = new SData(); - _GameData.NumPlayer = 4; - _GameData.NumPlayerAtOnce = 2; - _GameData.NumRounds = 2; - _GameData.CurrentRoundNr = 1; - _GameData.ProfileIDs = new List(); - _GameData.CatSongIndices = null; - _GameData.Results = null; + _GameData = new SData {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 2, CurrentRoundNr = 1, ProfileIDs = new List(), CatSongIndices = null, Results = null}; } public override bool Init() @@ -637,13 +630,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley { for (int i = 0; i < _GameData.NumPlayer; i++) { - CResultTableRow row = new CResultTableRow(); - row.PlayerID = _GameData.ProfileIDs[i]; - row.NumPlayed = 0; - row.NumRounds = 0; - row.NumWon = 0; - row.NumSingPoints = 0; - row.NumGamePoints = 0; + CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumRounds = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0}; _GameData.ResultTable.Add(row); } @@ -732,15 +719,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley List result = new List(); for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) { - SStats stat = new SStats(); - stat.ProfileID = results[i].ProfileID; - stat.SingPoints = (int)Math.Round(results[i].Points); - stat.Won = 0; - stat.GamePoints = 0; + SStats stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0}; result.Add(stat); } - result.Sort(delegate(SStats s1, SStats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); }); + result.Sort((s1, s2) => s1.SingPoints.CompareTo(s2.SingPoints)); int current = result[result.Count - 1].SingPoints; int points = result.Count; diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs index 03222db4..ab99973c 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs @@ -53,10 +53,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley _ThemeButtons = new string[] {_ButtonNext, _ButtonBack}; _Data = new SDataFromScreen(); - SFromScreenConfig config = new SFromScreenConfig(); - config.NumPlayer = 4; - config.NumPlayerAtOnce = 2; - config.NumRounds = 12; + SFromScreenConfig config = new SFromScreenConfig {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 12}; _Data.ScreenConfig = config; } @@ -227,10 +224,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley int res = _Data.ScreenConfig.NumPlayer / _Data.ScreenConfig.NumPlayerAtOnce; int mod = _Data.ScreenConfig.NumPlayer % _Data.ScreenConfig.NumPlayerAtOnce; - if (mod == 0) - _RoundSteps = res; - else - _RoundSteps = _Data.ScreenConfig.NumPlayer; + _RoundSteps = mod == 0 ? res : _Data.ScreenConfig.NumPlayer; } private void _Back() diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs index 3ac5fc60..7b465fb1 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs @@ -98,8 +98,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley public CPartyScreenChallengeMedleyMain() { - _Data = new SDataFromScreen(); - _Data.ScreenMain = new SFromScreenMain(); + _Data = new SDataFromScreen {ScreenMain = new SFromScreenMain()}; } public override void Init() @@ -406,9 +405,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley _RoundsTable = new List(); for (int i = 0; i < 5; i++) { - CRoundsTableRow rtr = new CRoundsTableRow(); - rtr.TextPlayer = new List(); - rtr.TextScores = new List(); + CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List(), TextScores = new List()}; _RoundsTable.Add(rtr); } //Create statics and texts for rounds @@ -438,11 +435,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley { _RoundsTableScrollArea = new SRectF(); - int numPlayerInOneRow = 3; - if (_GameState.NumPlayerAtOnce <= numPlayerInOneRow) - _NumRoundsVisible = 5; - else - _NumRoundsVisible = 3; + const int numPlayerInOneRow = 3; + _NumRoundsVisible = _GameState.NumPlayerAtOnce <= numPlayerInOneRow ? 5 : 3; if (_NumRoundsVisible > _GameState.Combs.Count) _NumRoundsVisible = _GameState.Combs.Count; @@ -536,10 +530,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley private void _BuildPlayerTable() { - _PlayerTableScrollArea = new SRectF(); - _PlayerTableScrollArea.X = _Texts[_TextPosition].X; - _PlayerTableScrollArea.Y = _Texts[_TextPosition].Y; - _PlayerTableScrollArea.W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X; + _PlayerTableScrollArea = new SRectF {X = _Texts[_TextPosition].X, Y = _Texts[_TextPosition].Y, W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X}; _PlayerTable = new List(); float delta = _Texts[_TextPosition].Height * 1.2f; @@ -548,14 +539,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley for (int i = 0; i < 10; i++) { - STableRow row = new STableRow(); - - row.Pos = GetNewText(_Texts[_TextPosition]); - row.Name = GetNewText(_Texts[_TextPlayerName]); - row.Rounds = GetNewText(_Texts[_TextNumPlayed]); - row.Won = GetNewText(_Texts[_TextWon]); - row.SingPoints = GetNewText(_Texts[_TextSingPoints]); - row.GamePoints = GetNewText(_Texts[_TextGamePoints]); + STableRow row = new STableRow + { + Pos = GetNewText(_Texts[_TextPosition]), + Name = GetNewText(_Texts[_TextPlayerName]), + Rounds = GetNewText(_Texts[_TextNumPlayed]), + Won = GetNewText(_Texts[_TextWon]), + SingPoints = GetNewText(_Texts[_TextSingPoints]), + GamePoints = GetNewText(_Texts[_TextGamePoints]) + }; row.Pos.Y += delta * (i + 1); row.Name.Y += delta * (i + 1); diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs index 959dc7ec..9617fa42 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs @@ -88,10 +88,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _Data = new SDataFromScreen(); - SFromScreenNames names = new SFromScreenNames(); - names.FadeToConfig = false; - names.FadeToMain = false; - names.ProfileIDs = new List(); + SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, FadeToMain = false, ProfileIDs = new List()}; _Data.ScreenNames = names; } @@ -316,9 +313,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]); b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH); b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW); - CPlayerChooseButton pcb = new CPlayerChooseButton(); - pcb.Button = b; - pcb.ProfileID = -1; + CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1}; _PlayerChooseButtons.Add(pcb); column++; if (column >= _PlayerChooseButtonsNumH) diff --git a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs index 69d7c33f..750e1357 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs @@ -203,24 +203,26 @@ namespace VocaluxeLib.PartyModes.TicTacToe _ToScreenNames = new SDataToScreenNames(); _ToScreenMain = new SDataToScreenMain(); - _GameData = new SData(); - _GameData.NumFields = 9; - _GameData.NumPlayerTeam1 = 2; - _GameData.NumPlayerTeam2 = 2; - _GameData.ProfileIDsTeam1 = new List(); - _GameData.ProfileIDsTeam2 = new List(); - _GameData.PlayerTeam1 = new List(); - _GameData.PlayerTeam2 = new List(); - _GameData.CurrentRoundNr = 0; - _GameData.SingRoundNr = 0; - _GameData.SongSource = ESongSource.TR_ALLSONGS; - _GameData.PlaylistID = 0; - _GameData.CategoryID = 0; - _GameData.GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL; - _GameData.Rounds = new List(); - _GameData.Songs = new List(); - _GameData.NumJokerRandom = new int[2]; - _GameData.NumJokerRetry = new int[2]; + _GameData = new SData + { + NumFields = 9, + NumPlayerTeam1 = 2, + NumPlayerTeam2 = 2, + ProfileIDsTeam1 = new List(), + ProfileIDsTeam2 = new List(), + PlayerTeam1 = new List(), + PlayerTeam2 = new List(), + CurrentRoundNr = 0, + SingRoundNr = 0, + SongSource = ESongSource.TR_ALLSONGS, + PlaylistID = 0, + CategoryID = 0, + GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL, + Rounds = new List(), + Songs = new List(), + NumJokerRandom = new int[2], + NumJokerRetry = new int[2] + }; } public override bool Init() @@ -281,10 +283,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe _Stage = EStage.NotStarted; else { - if (CBase.Game.GetRandom(100) < 50) - _GameData.Team = 0; - else - _GameData.Team = 1; + _GameData.Team = CBase.Game.GetRandom(100) < 50 ? 0 : 1; _GameData.ProfileIDsTeam1 = dataFrom.ScreenNames.ProfileIDsTeam1; _GameData.ProfileIDsTeam2 = dataFrom.ScreenNames.ProfileIDsTeam2; _Stage = EStage.Names; @@ -377,10 +376,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe _Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen); if (screen != null) { - if (_GameData.Team == 1) - _GameData.Team = 0; - else - _GameData.Team = 1; + _GameData.Team = _GameData.Team == 1 ? 0 : 1; CBase.Songs.ResetPartySongSung(); _GameData.CurrentRoundNr = 1; _ToScreenMain.CurrentRoundNr = 1; @@ -410,10 +406,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe _Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen); if (screen != null) { - if (_GameData.Team == 1) - _GameData.Team = 0; - else - _GameData.Team = 1; + _GameData.Team = _GameData.Team == 1 ? 0 : 1; _UpdateSongList(); _UpdatePlayerList(); _ToScreenMain.CurrentRoundNr = _GameData.CurrentRoundNr; diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs index 5044030d..dd069796 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs @@ -388,8 +388,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe { for (int i = 0; i < 25; i++) { - CField f = new CField(); - f.Button = GetNewButton(_Buttons[_ButtonField]); + CField f = new CField {Button = GetNewButton(_Buttons[_ButtonField])}; f.Button.Visible = false; f.Content = new CRound(); _AddButton(f.Button); diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs index eabff2aa..2025cdf7 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs @@ -93,11 +93,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose, _ButtonPlayerChooseScrollUp, _ButtonPlayerChooseScrollDown}; _Data = new SDataFromScreen(); - SFromScreenNames names = new SFromScreenNames(); - names.FadeToConfig = false; - names.FadeToMain = false; - names.ProfileIDsTeam1 = new List(); - names.ProfileIDsTeam2 = new List(); + SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, FadeToMain = false, ProfileIDsTeam1 = new List(), ProfileIDsTeam2 = new List()}; _Data.ScreenNames = names; } @@ -378,9 +374,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]); b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH); b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW); - CPlayerChooseButton pcb = new CPlayerChooseButton(); - pcb.Button = b; - pcb.ProfileID = -1; + CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1}; _PlayerChooseButtons.Add(pcb); column++; if (column >= _PlayerChooseButtonsNumH) diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index 5c645411..de114f20 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -161,10 +161,7 @@ namespace Vocaluxe.Base else Next(); - if (!_IsBackgroundFile(_CurrentPlaylistElement)) - _CanSing = true; - else - _CanSing = false; + _CanSing = !_IsBackgroundFile(_CurrentPlaylistElement); } } } diff --git a/Vocaluxe/Base/CCover.cs b/Vocaluxe/Base/CCover.cs index d6089808..24f80d64 100644 --- a/Vocaluxe/Base/CCover.cs +++ b/Vocaluxe/Base/CCover.cs @@ -164,7 +164,7 @@ namespace Vocaluxe.Base _CoverThemes.Clear(); const string path = CSettings.FolderCover; - List files = CHelper.ListFiles(path, "*.xml", false); + List files = CHelper.ListFiles(path, "*.xml"); foreach (string file in files) { diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 9a2f899f..b130d5e4 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -73,15 +73,17 @@ namespace Vocaluxe.Base public static int AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int diff, string artist, string title, int numPlayed, string filePath) { - SPlayer player = new SPlayer(); - player.Name = playerName; - player.Points = score; - player.LineNr = lineNr; - player.DateTicks = date; - player.Medley = medley == 1; - player.Duet = duet == 1; - player.ShortSong = shortSong == 1; - player.Difficulty = (EGameDifficulty)diff; + SPlayer player = new SPlayer + { + Name = playerName, + Points = score, + LineNr = lineNr, + DateTicks = date, + Medley = medley == 1, + Duet = duet == 1, + ShortSong = shortSong == 1, + Difficulty = (EGameDifficulty)diff + }; using (SQLiteConnection connection = new SQLiteConnection()) { @@ -252,13 +254,15 @@ namespace Vocaluxe.Base { while (reader.Read()) { - SScores score = new SScores(); - score.Name = reader.GetString(0); - score.Score = reader.GetInt32(1); - score.Date = new DateTime(reader.GetInt64(2)).ToString("dd/MM/yyyy"); - score.Difficulty = (EGameDifficulty)reader.GetInt32(3); - score.LineNr = reader.GetInt32(4); - score.ID = reader.GetInt32(5); + SScores score = new SScores + { + Name = reader.GetString(0), + Score = reader.GetInt32(1), + Date = new DateTime(reader.GetInt64(2)).ToString("dd/MM/yyyy"), + Difficulty = (EGameDifficulty)reader.GetInt32(3), + LineNr = reader.GetInt32(4), + ID = reader.GetInt32(5) + }; scores.Add(score); } @@ -633,9 +637,7 @@ namespace Vocaluxe.Base { while (reader.Read()) { - SData data = new SData(); - data.Id = reader.GetInt32(0); - data.Str1 = reader.GetString(1); + SData data = new SData {Id = reader.GetInt32(0), Str1 = reader.GetString(1)}; Int64 ticks = 0; try @@ -659,10 +661,7 @@ namespace Vocaluxe.Base { while (reader.Read()) { - SData data = new SData(); - data.Id = reader.GetInt32(0); - data.Str1 = reader.GetString(1); - data.Str2 = reader.GetString(2); + SData data = new SData {Id = reader.GetInt32(0), Str1 = reader.GetString(1), Str2 = reader.GetString(2)}; songs.Add(data); } } @@ -793,21 +792,13 @@ namespace Vocaluxe.Base while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW) { - SData data = new SData(); - - data.Id = Sqlite3.sqlite3_column_int(stmt, 0); + SData data = new SData {Id = Sqlite3.sqlite3_column_int(stmt, 0)}; byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1); - if (bytes != null) - data.Str1 = utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)); - else - data.Str1 = "Someone"; + data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone"; bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 2); - if (bytes != null) - data.Str2 = utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)); - else - data.Str2 = "Someone"; + data.Str2 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone"; songs.Add(data); } @@ -831,15 +822,10 @@ namespace Vocaluxe.Base while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW) { - SData data = new SData(); - - data.Id = Sqlite3.sqlite3_column_int(stmt, 0); + SData data = new SData {Id = Sqlite3.sqlite3_column_int(stmt, 0)}; byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1); - if (bytes != null) - data.Str1 = utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)); - else - data.Str1 = "Someone"; + data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone"; if (dateExists) data.Ticks = _UnixTimeToTicks(Sqlite3.sqlite3_column_int(stmt, 2)); @@ -986,8 +972,7 @@ namespace Vocaluxe.Base if (_ConnectionCover == null) { - _ConnectionCover = new SQLiteConnection(); - _ConnectionCover.ConnectionString = "Data Source=" + _CoverFilePath; + _ConnectionCover = new SQLiteConnection {ConnectionString = "Data Source=" + _CoverFilePath}; _ConnectionCover.Open(); } diff --git a/Vocaluxe/Base/CFont.cs b/Vocaluxe/Base/CFont.cs index 10b8f7d0..f7b45b25 100644 --- a/Vocaluxe/Base/CFont.cs +++ b/Vocaluxe/Base/CFont.cs @@ -577,11 +577,7 @@ namespace Vocaluxe.Base int i = 1; while (xmlReader.GetValue("//root/Fonts/Font" + i + "/Folder", out value, value)) { - SFont sf = new SFont(); - sf.Folder = value; - sf.IsThemeFont = themeName != ""; - sf.ThemeName = themeName; - sf.PartyModeID = partyModeId; + SFont sf = new SFont {Folder = value, IsThemeFont = themeName != "", ThemeName = themeName, PartyModeID = partyModeId}; bool ok = true; diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index fb544ad4..5f9f3078 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -748,8 +748,7 @@ namespace Vocaluxe.Base if (CConfig.DebugLevel == EDebugLevel.TR_CONFIG_OFF) return; - List debugOutput = new List(); - debugOutput.Add(CTime.GetFPS().ToString("FPS: 000")); + List debugOutput = new List {CTime.GetFPS().ToString("FPS: 000")}; if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1) { diff --git a/Vocaluxe/Base/CLanguage.cs b/Vocaluxe/Base/CLanguage.cs index 1e7ec559..00b2d6e5 100644 --- a/Vocaluxe/Base/CLanguage.cs +++ b/Vocaluxe/Base/CLanguage.cs @@ -212,8 +212,7 @@ namespace Vocaluxe.Base if (nr == -1) return true; - SPartyLanguage lang = new SPartyLanguage(); - lang.PartyModeID = partyModeID; + SPartyLanguage lang = new SPartyLanguage {PartyModeID = partyModeID}; if (!_LoadLanguageEntries(xmlReader, out lang.Texts)) return false; @@ -226,8 +225,7 @@ namespace Vocaluxe.Base private static void _LoadLanguageFile(string fileName) { - SLanguage lang = new SLanguage(); - lang.LanguageFilePath = Path.Combine(CSettings.FolderLanguages, fileName); + SLanguage lang = new SLanguage {LanguageFilePath = Path.Combine(CSettings.FolderLanguages, fileName)}; CXMLReader xmlReader = CXMLReader.OpenFile(lang.LanguageFilePath); if (xmlReader == null) diff --git a/Vocaluxe/Base/CParty.cs b/Vocaluxe/Base/CParty.cs index 372046d2..9d9baee4 100644 --- a/Vocaluxe/Base/CParty.cs +++ b/Vocaluxe/Base/CParty.cs @@ -67,9 +67,7 @@ namespace Vocaluxe.Base _IDs.Enqueue(i); //add dummy normal game mode and set it as default - SPartyMode pm = new SPartyMode(); - pm.PartyMode = new CPartyModeNone(); - pm.ScreenFiles = new List(); + SPartyMode pm = new SPartyMode {PartyMode = new CPartyModeNone(), ScreenFiles = new List()}; pm.PartyMode.Initialize(); pm.PartyModeID = _IDs.Dequeue(); _NormalGameModeID = pm.PartyModeID; @@ -231,10 +229,7 @@ namespace Vocaluxe.Base private static SPartyMode _LoadPartyMode(string file) { - SPartyMode pm = new SPartyMode(); - pm.PartyModeID = _IDs.Dequeue(); - pm.ScreenFiles = new List(); - pm.NoErrors = false; + SPartyMode pm = new SPartyMode {PartyModeID = _IDs.Dequeue(), ScreenFiles = new List(), NoErrors = false}; CXMLReader xmlReader = CXMLReader.OpenFile(file); diff --git a/Vocaluxe/Base/CPlaylists.cs b/Vocaluxe/Base/CPlaylists.cs index 1b547267..9fad3f43 100644 --- a/Vocaluxe/Base/CPlaylists.cs +++ b/Vocaluxe/Base/CPlaylists.cs @@ -139,8 +139,7 @@ namespace Vocaluxe.Base public static int NewPlaylist() { - CPlaylistFile pl = new CPlaylistFile(); - pl.PlaylistName = "New Playlist"; + CPlaylistFile pl = new CPlaylistFile {PlaylistName = "New Playlist"}; _Playlists.Add(pl); return _Playlists.Count - 1; } diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs index 3538024a..76e910d8 100644 --- a/Vocaluxe/Base/CProfiles.cs +++ b/Vocaluxe/Base/CProfiles.cs @@ -69,18 +69,15 @@ namespace Vocaluxe.Base public static int NewProfile(string fileName) { - SProfile profile = new SProfile(); - - profile.PlayerName = String.Empty; - profile.Difficulty = EGameDifficulty.TR_CONFIG_EASY; - profile.Avatar = new SAvatar(-1); - profile.GuestProfile = EOffOn.TR_CONFIG_OFF; - profile.Active = EOffOn.TR_CONFIG_ON; - - if (fileName != "") - profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName); - else - profile.ProfileFile = String.Empty; + SProfile profile = new SProfile + { + PlayerName = String.Empty, + Difficulty = EGameDifficulty.TR_CONFIG_EASY, + Avatar = new SAvatar(-1), + GuestProfile = EOffOn.TR_CONFIG_OFF, + Active = EOffOn.TR_CONFIG_ON, + ProfileFile = fileName != "" ? Path.Combine(CSettings.FolderProfiles, fileName) : String.Empty + }; if (File.Exists(profile.ProfileFile)) return -1; @@ -129,9 +126,7 @@ namespace Vocaluxe.Base if (tex.Index != -1) { - SAvatar avatar = new SAvatar(); - avatar.Texture = tex; - avatar.FileName = Path.GetFileName(file); + SAvatar avatar = new SAvatar {Texture = tex, FileName = Path.GetFileName(file)}; _Avatars.Add(avatar); } } @@ -367,8 +362,7 @@ namespace Vocaluxe.Base private static void _LoadProfile(string fileName) { - SProfile profile = new SProfile(); - profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName); + SProfile profile = new SProfile {ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName)}; CXMLReader xmlReader = CXMLReader.OpenFile(profile.ProfileFile); if (xmlReader == null) diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index ee116549..cfb7c39f 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -197,16 +197,7 @@ namespace Vocaluxe.Base public static void CreateFolders() { - List folders = new List(); - - folders.Add(FolderCover); - folders.Add(FolderFonts); - folders.Add(FolderProfiles); - folders.Add(FolderSongs); - folders.Add(FolderScreenshots); - folders.Add(FolderBackgroundMusic); - folders.Add(FolderSounds); - folders.Add(FolderPlaylists); + List folders = new List {FolderCover, FolderFonts, FolderProfiles, FolderSongs, FolderScreenshots, FolderBackgroundMusic, FolderSounds, FolderPlaylists}; foreach (string folder in folders) { diff --git a/Vocaluxe/Base/CSound.cs b/Vocaluxe/Base/CSound.cs index 61a664b3..70b0e598 100644 --- a/Vocaluxe/Base/CSound.cs +++ b/Vocaluxe/Base/CSound.cs @@ -486,16 +486,19 @@ namespace Vocaluxe.Base _MaxVolume = volume; } - if (_MaxVolume >= 0.02f) - _AnalyzeByAutocorrelation(true); - else - _AnalyzeByAutocorrelation(false); + _AnalyzeByAutocorrelation(_MaxVolume >= 0.02f); } catch (Exception) {} } private void _AnalyzeByAutocorrelation(bool valid) { + if (!valid) + { + _ToneValid = false; + return; + } + const double halftoneBase = 1.05946309436; // 2^(1/12) -> HalftoneBase^12 = 2 (one octave) // prepare to analyze @@ -525,7 +528,7 @@ namespace Vocaluxe.Base weigth[toneIndex] = (float)curWeight; } - if (valid && maxWeight - minWeight > 0.01) + if (maxWeight - minWeight > 0.01) { for (int i = 0; i < weigth.Length; i++) _ToneWeigth[i] = weigth[i]; diff --git a/Vocaluxe/Base/CTheme.cs b/Vocaluxe/Base/CTheme.cs index be7fd8f9..c730d1d4 100644 --- a/Vocaluxe/Base/CTheme.cs +++ b/Vocaluxe/Base/CTheme.cs @@ -197,9 +197,7 @@ namespace Vocaluxe.Base try { xmlReader.GetValue("//root/Videos/" + _Skins[skinIndex].VideoList[i].Name, out value, String.Empty); - SSkinElement sk = new SSkinElement(); - sk.Name = _Skins[skinIndex].VideoList[i].Name; - sk.Value = value; + SSkinElement sk = new SSkinElement {Name = _Skins[skinIndex].VideoList[i].Name, Value = value}; sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[skinIndex].Path, sk.Value)); CVideo.VdSetLoop(sk.VideoIndex, true); CVideo.VdPause(sk.VideoIndex); @@ -406,7 +404,7 @@ namespace Vocaluxe.Base _Themes.Clear(); string path = Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderThemes); - List files = CHelper.ListFiles(path, "*.xml", false); + List files = CHelper.ListFiles(path, "*.xml"); foreach (string file in files) AddTheme(Path.Combine(path, file), -1); @@ -477,7 +475,7 @@ namespace Vocaluxe.Base STheme theme = _Themes[themeIndex]; string path = Path.Combine(theme.Path, theme.SkinFolder); - List files = CHelper.ListFiles(path, "*.xml", false); + List files = CHelper.ListFiles(path, "*.xml"); foreach (string file in files) { @@ -508,9 +506,7 @@ namespace Vocaluxe.Base List names = xmlReader.GetValues("Skins"); foreach (string str in names) { - SSkinElement sk = new SSkinElement(); - sk.Name = str; - sk.Value = String.Empty; + SSkinElement sk = new SSkinElement {Name = str, Value = String.Empty}; skin.SkinList[str] = sk; } @@ -518,9 +514,7 @@ namespace Vocaluxe.Base names = xmlReader.GetValues("Videos"); foreach (string str in names) { - SSkinElement sk = new SSkinElement(); - sk.Name = str; - sk.Value = String.Empty; + SSkinElement sk = new SSkinElement {Name = str, Value = String.Empty}; skin.VideoList.Add(sk); } _Skins.Add(skin); @@ -711,9 +705,8 @@ namespace Vocaluxe.Base int i = 1; while (xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/R", ref value)) { - SColorF color = new SColorF(); + SColorF color = new SColorF {R = value}; - color.R = value; xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/G", ref color.G); xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/B", ref color.B); xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/A", ref color.A); @@ -728,8 +721,7 @@ namespace Vocaluxe.Base List names = xmlReader.GetValues("ColorSchemes"); foreach (string str in names) { - SColorScheme scheme = new SColorScheme(); - scheme.Name = str; + SColorScheme scheme = new SColorScheme {Name = str}; xmlReader.TryGetFloatValue("//root/ColorSchemes/" + str + "/R", ref scheme.Color.R); xmlReader.TryGetFloatValue("//root/ColorSchemes/" + str + "/G", ref scheme.Color.G); diff --git a/Vocaluxe/Base/CUtility.cs b/Vocaluxe/Base/CUtility.cs index ce357ea9..9dbce203 100644 --- a/Vocaluxe/Base/CUtility.cs +++ b/Vocaluxe/Base/CUtility.cs @@ -158,10 +158,7 @@ namespace Vocaluxe.Base if (!_Timer.IsRunning || (_Timer.ElapsedMilliseconds > 75) || !repeat) { _Keys = e.KeyCode; - if (repeat) - _Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, _Char, _Keys); - else - _Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, Char.MinValue, _Keys); + _Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, repeat ? _Char : Char.MinValue, _Keys); } } diff --git a/Vocaluxe/Base/CVideo.cs b/Vocaluxe/Base/CVideo.cs index 9f7d9098..db7390fb 100644 --- a/Vocaluxe/Base/CVideo.cs +++ b/Vocaluxe/Base/CVideo.cs @@ -176,8 +176,7 @@ namespace Vocaluxe.Base float videoTime = _VideoTimer.ElapsedMilliseconds / 1000f; _Finished = CVideo.VdFinished(_VideoStream); - STexture tex = new STexture(-1); - tex.Height = 0f; + STexture tex = new STexture(-1) {Height = 0f}; CVideo.VdGetFrame(_VideoStream, ref tex, videoTime, out videoTime); if (tex.Height > 0) diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs index 9f0c1006..7c9b83bb 100644 --- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs +++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs @@ -359,15 +359,9 @@ namespace Vocaluxe.Lib.Draw { Bitmap bmp2 = new Bitmap(bmp); _Bitmaps.Add(bmp2); - STexture texture = new STexture(); - - texture.Index = _Bitmaps.Count - 1; - - texture.Width = bmp.Width; - texture.Height = bmp.Height; + STexture texture = new STexture {Index = _Bitmaps.Count - 1, Width = bmp.Width, Height = bmp.Height, Color = new SColorF(1f, 1f, 1f, 1f)}; // Add to Texture List - texture.Color = new SColorF(1f, 1f, 1f, 1f); texture.Rect = new SRectF(0f, 0f, texture.Width, texture.Height, 0f); texture.TexturePath = String.Empty; @@ -512,12 +506,7 @@ namespace Vocaluxe.Lib.Draw using (Graphics g = Graphics.FromImage(newBitmap)) { - ColorMatrix cm = new ColorMatrix(); - cm.Matrix33 = color.A; - cm.Matrix00 = color.R; - cm.Matrix11 = color.G; - cm.Matrix22 = color.B; - cm.Matrix44 = 1; + ColorMatrix cm = new ColorMatrix {Matrix33 = color.A, Matrix00 = color.R, Matrix11 = color.G, Matrix22 = color.B, Matrix44 = 1}; using (ImageAttributes ia = new ImageAttributes()) { diff --git a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs index 58d57c00..08593a50 100644 --- a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs +++ b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs @@ -154,8 +154,7 @@ namespace Vocaluxe.Lib.Playlist xmlReader.GetValue("//root/Songs/" + song + "/Title", out title, String.Empty); xmlReader.TryGetEnumValue("//root/Songs/" + song + "/GameMode", ref gm); - CPlaylistSong playlistSong = new CPlaylistSong(); - playlistSong.SongID = -1; + CPlaylistSong playlistSong = new CPlaylistSong {SongID = -1}; CSong[] allSongs = CSongs.AllSongs; foreach (CSong curSong in allSongs) @@ -181,21 +180,14 @@ namespace Vocaluxe.Lib.Playlist public void AddSong(int songID) { - CPlaylistSong song = new CPlaylistSong(); - song.SongID = songID; - if (CSongs.GetSong(songID).IsDuet) - song.GameMode = EGameMode.TR_GAMEMODE_DUET; - else - song.GameMode = EGameMode.TR_GAMEMODE_NORMAL; + CPlaylistSong song = new CPlaylistSong {SongID = songID, GameMode = CSongs.GetSong(songID).IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL}; Songs.Add(song); } public void AddSong(int songID, EGameMode gm) { - CPlaylistSong song = new CPlaylistSong(); - song.SongID = songID; - song.GameMode = gm; + CPlaylistSong song = new CPlaylistSong {SongID = songID, GameMode = gm}; Songs.Add(song); } diff --git a/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs b/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs index cc38e414..a26c9003 100644 --- a/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs +++ b/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs @@ -55,15 +55,9 @@ namespace Vocaluxe.Lib.Sound { using (DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid)) { - SRecordDevice device = new SRecordDevice(); - device.Driver = dev.DriverGuid.ToString(); - device.ID = id; - device.Name = dev.Description; - device.Inputs = new List(); + SRecordDevice device = new SRecordDevice {Driver = dev.DriverGuid.ToString(), ID = id, Name = dev.Description, Inputs = new List()}; - SInput inp = new SInput(); - inp.Name = "Default"; - inp.Channels = ds.Capabilities.Channels; + SInput inp = new SInput {Name = "Default", Channels = ds.Capabilities.Channels}; if (inp.Channels > 2) inp.Channels = 2; //more are not supported in vocaluxe @@ -120,8 +114,7 @@ namespace Vocaluxe.Lib.Sound { if (active[i]) { - CSoundCardSource source = new CSoundCardSource(guid[i], channels[i]); - source.SampleRateKhz = 44.1; + CSoundCardSource source = new CSoundCardSource(guid[i], channels[i]) {SampleRateKhz = 44.1}; source.SampleDataReady += _OnDataReady; source.Start(); @@ -336,9 +329,7 @@ namespace Vocaluxe.Lib.Sound for (int i = 0; i < _BufferPortionCount; i++) { - NotificationPosition notification = new NotificationPosition(); - notification.Offset = _BufferPortionCount - 1 + (_BufferPortionSize * i); - notification.Event = new AutoResetEvent(false); + NotificationPosition notification = new NotificationPosition {Offset = _BufferPortionCount - 1 + (_BufferPortionSize * i), Event = new AutoResetEvent(false)}; _Notifications.Add(notification); } @@ -348,8 +339,7 @@ namespace Vocaluxe.Lib.Sound for (int i = 0; i < _Notifications.Count; i++) _WaitHandles[i] = _Notifications[i].Event; - _CaptureThread = new Thread(_DoCapture); - _CaptureThread.IsBackground = true; + _CaptureThread = new Thread(_DoCapture) {IsBackground = true}; _Running = true; _CaptureThread.Start(); diff --git a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs index ab6ae222..54ab8263 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs @@ -603,11 +603,13 @@ namespace Vocaluxe.Lib.Sound IntPtr data = new IntPtr(0); - CPortAudio.SPaStreamParameters outputParams = new CPortAudio.SPaStreamParameters(); - outputParams.ChannelCount = format.ChannelCount; - outputParams.Device = _ApiInfo.DefaultOutputDevice; - outputParams.SampleFormat = CPortAudio.EPaSampleFormat.PaInt16; - outputParams.SuggestedLatency = _OutputDeviceInfo.DefaultLowOutputLatency; + CPortAudio.SPaStreamParameters outputParams = new CPortAudio.SPaStreamParameters + { + ChannelCount = format.ChannelCount, + Device = _ApiInfo.DefaultOutputDevice, + SampleFormat = CPortAudio.EPaSampleFormat.PaInt16, + SuggestedLatency = _OutputDeviceInfo.DefaultLowOutputLatency + }; uint bufsize = (uint)CConfig.AudioBufferSize; lock (_Mutex) diff --git a/Vocaluxe/Lib/Sound/CPortAudioRecord.cs b/Vocaluxe/Lib/Sound/CPortAudioRecord.cs index 612081a8..5508dfce 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioRecord.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioRecord.cs @@ -73,17 +73,10 @@ namespace Vocaluxe.Lib.Sound CPortAudio.SPaDeviceInfo info = CPortAudio.PaGetDeviceInfo(i); if (info.HostApi == hostAPI && info.MaxInputChannels > 0) { - SRecordDevice dev = new SRecordDevice(); + SRecordDevice dev = new SRecordDevice {ID = i, Name = info.Name, Driver = info.Name + i, Inputs = new List()}; - dev.ID = i; - dev.Name = info.Name; - dev.Driver = info.Name + i; - dev.Inputs = new List(); + SInput inp = new SInput {Name = "Default", Channels = info.MaxInputChannels}; - SInput inp = new SInput(); - inp.Name = "Default"; - - inp.Channels = info.MaxInputChannels; if (inp.Channels > 2) inp.Channels = 2; //more are not supported in vocaluxe @@ -156,11 +149,13 @@ namespace Vocaluxe.Lib.Sound { if (active[i]) { - CPortAudio.SPaStreamParameters inputParams = new CPortAudio.SPaStreamParameters(); - inputParams.ChannelCount = _DeviceConfig[i].Inputs[0].Channels; - inputParams.Device = _DeviceConfig[i].ID; - inputParams.SampleFormat = CPortAudio.EPaSampleFormat.PaInt16; - inputParams.SuggestedLatency = CPortAudio.PaGetDeviceInfo(_DeviceConfig[i].ID).DefaultLowInputLatency; + CPortAudio.SPaStreamParameters inputParams = new CPortAudio.SPaStreamParameters + { + ChannelCount = _DeviceConfig[i].Inputs[0].Channels, + Device = _DeviceConfig[i].ID, + SampleFormat = CPortAudio.EPaSampleFormat.PaInt16, + SuggestedLatency = CPortAudio.PaGetDeviceInfo(_DeviceConfig[i].ID).DefaultLowInputLatency + }; if (_ErrorCheck("OpenStream (rec)", CPortAudio.Pa_OpenStream( out _RecHandle[i], diff --git a/Vocaluxe/Screens/CScreenCredits.cs b/Vocaluxe/Screens/CScreenCredits.cs index 4ef03bbb..c9df9ec0 100644 --- a/Vocaluxe/Screens/CScreenCredits.cs +++ b/Vocaluxe/Screens/CScreenCredits.cs @@ -291,8 +291,7 @@ namespace Vocaluxe.Screens CStatic image = GetNewStatic(texture, new SColorF(1, 1, 1, 1), new SRectF(-1, -1, 400, 120, -4)); SRectF particleRect = new SRectF(-1, -1, partRectSize, partRectSize, -6); - SRectF imgDotRect = new SRectF(particleRect); - imgDotRect.Z = -5; + SRectF imgDotRect = new SRectF(particleRect) {Z = -5}; CStatic imgDot = GetNewStatic(texDot, new SColorF(1, 1, 1, 1), imgDotRect); CParticleEffect particle = _GetStarParticles(partCount, isRight, particleRect, bigParticles); diff --git a/Vocaluxe/Screens/CScreenHighscore.cs b/Vocaluxe/Screens/CScreenHighscore.cs index 95421bda..83bfe915 100644 --- a/Vocaluxe/Screens/CScreenHighscore.cs +++ b/Vocaluxe/Screens/CScreenHighscore.cs @@ -53,9 +53,7 @@ namespace Vocaluxe.Screens { base.Init(); - List texts = new List(); - texts.Add(_TextSongName); - texts.Add(_TextSongMode); + List texts = new List {_TextSongName, _TextSongMode}; _TextNumber = new string[_NumEntrys]; for (int i = 0; i < _NumEntrys; i++) @@ -176,10 +174,7 @@ namespace Vocaluxe.Screens _Texts[_TextScore[p]].Text = _Scores[_Round][_Pos + p].Score.ToString("00000"); _Texts[_TextDate[p]].Text = _Scores[_Round][_Pos + p].Date; - if (_IsNewEntry(_Scores[_Round][_Pos + p].ID)) - _ParticleEffects[_ParticleEffectNew[p]].Visible = true; - else - _ParticleEffects[_ParticleEffectNew[p]].Visible = false; + _ParticleEffects[_ParticleEffectNew[p]].Visible = _IsNewEntry(_Scores[_Round][_Pos + p].ID); } else { diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 70cfaa8d..c34fdae3 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -76,8 +76,7 @@ namespace Vocaluxe.Screens statics.Add(_StaticWarningProfiles); _ThemeStatics = statics.ToArray(); - List texts = new List(); - texts.Add(_SelectSlidePlayerNumber); + List texts = new List {_SelectSlidePlayerNumber}; texts.AddRange(_SelectSlideDuetPlayer); _ThemeSelectSlides = texts.ToArray(); @@ -597,16 +596,10 @@ namespace Vocaluxe.Screens if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) { _SelectSlides[_SelectSlideDuetPlayer[i]].Clear(); - if (i + 1 <= CGame.NumPlayer) - _SelectSlides[_SelectSlideDuetPlayer[i]].Visible = true; - else - _SelectSlides[_SelectSlideDuetPlayer[i]].Visible = false; + _SelectSlides[_SelectSlideDuetPlayer[i]].Visible = i + 1 <= CGame.NumPlayer; _SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart1); _SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart2); - if ((i + 1) % 2 == 0) - _SelectSlides[_SelectSlideDuetPlayer[i]].Selection = 1; - else - _SelectSlides[_SelectSlideDuetPlayer[i]].Selection = 0; + _SelectSlides[_SelectSlideDuetPlayer[i]].Selection = i % 2; } else _SelectSlides[_SelectSlideDuetPlayer[i]].Visible = false; diff --git a/Vocaluxe/Screens/CScreenOptionsRecord.cs b/Vocaluxe/Screens/CScreenOptionsRecord.cs index 38f12ba0..a1ced44f 100644 --- a/Vocaluxe/Screens/CScreenOptionsRecord.cs +++ b/Vocaluxe/Screens/CScreenOptionsRecord.cs @@ -75,8 +75,7 @@ namespace Vocaluxe.Screens { base.Init(); - List values = new List(); - values.Add(_StaticWarning); + List values = new List {_StaticWarning}; values.AddRange(_StaticEnergyChannel); _ThemeStatics = values.ToArray(); diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index e6434090..f8530b27 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -118,36 +118,30 @@ namespace Vocaluxe.Screens { base.Init(); - List texts = new List(); - texts.Add(_TextSongName); - texts.Add(_TextTime); - texts.Add(_TextPause); - texts.Add(_TextDuetName1); - texts.Add(_TextDuetName2); + List texts = new List {_TextSongName, _TextTime, _TextPause, _TextDuetName1, _TextDuetName2}; _BuildTextStrings(ref texts); _ThemeTexts = texts.ToArray(); - List statics = new List(); - statics.Add(_StaticSongText); - statics.Add(_StaticLyrics); - statics.Add(_StaticLyricsDuet); - statics.Add(_StaticLyricsTop); - statics.Add(_StaticTimeBar); - statics.Add(_StaticTimeLine); - statics.Add(_StaticTimeLineExpandedNormal); - statics.Add(_StaticTimeLineExpandedHighlighted); - statics.Add(_StaticTimePointer); - statics.Add(_StaticLyricHelper); - statics.Add(_StaticLyricHelperDuet); - statics.Add(_StaticLyricHelperTop); - statics.Add(_StaticPauseBG); + List statics = new List + { + _StaticSongText, + _StaticLyrics, + _StaticLyricsDuet, + _StaticLyricsTop, + _StaticTimeBar, + _StaticTimeLine, + _StaticTimeLineExpandedNormal, + _StaticTimeLineExpandedHighlighted, + _StaticTimePointer, + _StaticLyricHelper, + _StaticLyricHelperDuet, + _StaticLyricHelperTop, + _StaticPauseBG + }; _BuildStaticStrings(ref statics); _ThemeStatics = statics.ToArray(); - List buttons = new List(); - buttons.Add(_ButtonCancel); - buttons.Add(_ButtonContinue); - buttons.Add(_ButtonSkip); + List buttons = new List {_ButtonCancel, _ButtonContinue, _ButtonSkip}; _ThemeButtons = buttons.ToArray(); _ThemeLyrics = new string[] {_LyricMain, _LyricSub, _LyricMainDuet, _LyricSubDuet, _LyricMainTop, _LyricSubTop}; @@ -638,10 +632,7 @@ namespace Vocaluxe.Screens { for (int i = 0; i < CGame.NumPlayer; i++) { - if ((i % 2) == 0) - CGame.Player[i].LineNr = 1; - else - CGame.Player[i].LineNr = 0; + CGame.Player[i].LineNr = (i+1) % 2; } } else diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 9db36407..6108ade4 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -803,10 +803,7 @@ namespace Vocaluxe.Screens gm = _AvailableGameModes[_SelectSlides[_SelectSlideOptionsMode].Selection]; else { - if (CSongs.VisibleSongs[songNr].IsDuet) - gm = EGameMode.TR_GAMEMODE_DUET; - else - gm = EGameMode.TR_GAMEMODE_NORMAL; + gm = CSongs.VisibleSongs[songNr].IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL; } CGame.Reset(); @@ -823,10 +820,7 @@ namespace Vocaluxe.Screens if (CSongs.Category >= 0 && songNr >= 0 && CSongs.NumVisibleSongs > songNr) { EGameMode gm; - if (CSongs.VisibleSongs[songNr].IsDuet) - gm = EGameMode.TR_GAMEMODE_DUET; - else - gm = EGameMode.TR_GAMEMODE_NORMAL; + gm = CSongs.VisibleSongs[songNr].IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL; CGame.Reset(); CGame.ClearSongs(); diff --git a/VocaluxeLib/Menu/CButton.cs b/VocaluxeLib/Menu/CButton.cs index 8a46c185..a363dc1a 100644 --- a/VocaluxeLib/Menu/CButton.cs +++ b/VocaluxeLib/Menu/CButton.cs @@ -117,11 +117,13 @@ namespace VocaluxeLib.Menu public CButton(CButton button) { _PartyModeID = button._PartyModeID; - _Theme = new SThemeButton(); - _Theme.ColorName = button._Theme.ColorName; - _Theme.SelColorName = button._Theme.SelColorName; - _Theme.TextureName = button._Theme.TextureName; - _Theme.SelTextureName = button._Theme.SelTextureName; + _Theme = new SThemeButton + { + ColorName = button._Theme.ColorName, + SelColorName = button._Theme.SelColorName, + TextureName = button._Theme.TextureName, + SelTextureName = button._Theme.SelTextureName + }; Rect = new SRectF(button.Rect); Color = new SColorF(button.Color); @@ -303,10 +305,7 @@ namespace VocaluxeLib.Menu if (!Selected && !Pressed || !Enabled) { - if (Texture.Index != -1) - texture = Texture; - else - texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); + texture = Texture.Index != -1 ? Texture : CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); CBase.Drawing.DrawTexture(texture, Rect, Color); @@ -320,10 +319,7 @@ namespace VocaluxeLib.Menu } else if (!IsSelText) { - if (Texture.Index != -1) - texture = Texture; - else - texture = CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID); + texture = Texture.Index != -1 ? Texture : CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID); CBase.Drawing.DrawTexture(texture, Rect, SelColor); @@ -337,10 +333,7 @@ namespace VocaluxeLib.Menu } else if (IsSelText) { - if (SelTexture.Index != -1) - texture = SelTexture; - else - texture = CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID); + texture = SelTexture.Index != -1 ? SelTexture : CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID); CBase.Drawing.DrawTexture(texture, Rect, SelColor); diff --git a/VocaluxeLib/Menu/CNameSelection.cs b/VocaluxeLib/Menu/CNameSelection.cs index f3b34313..5ed4a934 100644 --- a/VocaluxeLib/Menu/CNameSelection.cs +++ b/VocaluxeLib/Menu/CNameSelection.cs @@ -106,10 +106,10 @@ namespace VocaluxeLib.Menu { _PrepareTiles(); - _PlayerSelector = new CStatic(_PartyModeID); - _PlayerSelector.Texture = _TextureTileSelected; - _PlayerSelector.Rect = new SRectF(0, 0, _TileW + 6, _TileH + 6, Rect.Z - 0.5f); - _PlayerSelector.Visible = false; + _PlayerSelector = new CStatic(_PartyModeID) { + Texture = _TextureTileSelected, + Rect = new SRectF(0, 0, _TileW + 6, _TileH + 6, Rect.Z - 0.5f), + Visible = false}; _UpdateVisibleProfiles(); diff --git a/VocaluxeLib/Menu/CObjectInteractions.cs b/VocaluxeLib/Menu/CObjectInteractions.cs index 1dd503ef..1aafbb94 100644 --- a/VocaluxeLib/Menu/CObjectInteractions.cs +++ b/VocaluxeLib/Menu/CObjectInteractions.cs @@ -320,9 +320,7 @@ namespace VocaluxeLib.Menu _Interactions[i].Type == EType.SongMenu || _Interactions[i].Type == EType.Equalizer)) { - SZSort zs = new SZSort(); - zs.ID = i; - zs.Z = _GetZValue(i); + SZSort zs = new SZSort {ID = i, Z = _GetZValue(i)}; items.Add(zs); } } @@ -331,7 +329,7 @@ namespace VocaluxeLib.Menu return; - items.Sort(delegate(SZSort s1, SZSort s2) { return s2.Z.CompareTo(s1.Z); }); + items.Sort((s1, s2) => s2.Z.CompareTo(s1.Z)); for (int i = 0; i < items.Count; i++) _DrawInteraction(items[i].ID); diff --git a/VocaluxeLib/Menu/CPlaylist.cs b/VocaluxeLib/Menu/CPlaylist.cs index 367f9ec9..73063abf 100644 --- a/VocaluxeLib/Menu/CPlaylist.cs +++ b/VocaluxeLib/Menu/CPlaylist.cs @@ -203,17 +203,19 @@ namespace VocaluxeLib.Menu public CPlaylist(int partyModeID) { _PartyModeID = partyModeID; - _Theme = new SThemePlaylist(); - _Theme.Text1 = new CText(_PartyModeID); - _Theme.StaticCover = new CStatic(_PartyModeID); - _Theme.StaticPlaylistFooter = new CStatic(_PartyModeID); - _Theme.StaticPlaylistHeader = new CStatic(_PartyModeID); - _Theme.ButtonPlaylistName = new CButton(_PartyModeID); - _Theme.ButtonPlaylistClose = new CButton(_PartyModeID); - _Theme.ButtonPlaylistDelete = new CButton(_PartyModeID); - _Theme.ButtonPlaylistSave = new CButton(_PartyModeID); - _Theme.ButtonPlaylistSing = new CButton(_PartyModeID); - _Theme.SelectSlideGameMode = new CSelectSlide(_PartyModeID); + _Theme = new SThemePlaylist + { + Text1 = new CText(_PartyModeID), + StaticCover = new CStatic(_PartyModeID), + StaticPlaylistFooter = new CStatic(_PartyModeID), + StaticPlaylistHeader = new CStatic(_PartyModeID), + ButtonPlaylistName = new CButton(_PartyModeID), + ButtonPlaylistClose = new CButton(_PartyModeID), + ButtonPlaylistDelete = new CButton(_PartyModeID), + ButtonPlaylistSave = new CButton(_PartyModeID), + ButtonPlaylistSing = new CButton(_PartyModeID), + SelectSlideGameMode = new CSelectSlide(_PartyModeID) + }; CompleteRect = new SRectF(); Rect = new SRectF(); @@ -626,8 +628,7 @@ namespace VocaluxeLib.Menu CBase.Playlist.MovePlaylistSongUp(ActivePlaylistID, CurrentPlaylistElement + Offset); UpdatePlaylist(); - SKeyEvent key = new SKeyEvent(); - key.Key = Keys.Up; + SKeyEvent key = new SKeyEvent {Key = Keys.Up}; if (CurrentPlaylistElement > scrollLimit) { @@ -656,8 +657,7 @@ namespace VocaluxeLib.Menu CBase.Playlist.MovePlaylistSongDown(ActivePlaylistID, CurrentPlaylistElement + Offset); UpdatePlaylist(); - SKeyEvent key = new SKeyEvent(); - key.Key = Keys.Down; + SKeyEvent key = new SKeyEvent {Key = Keys.Down}; if (CurrentPlaylistElement >= scrollLimit) { @@ -795,10 +795,7 @@ namespace VocaluxeLib.Menu return; int off = _PlaylistElementContents.Count - _PlaylistElements.Count; - if (off >= 0) - Offset = off; - else - Offset = 0; + Offset = off >= 0 ? off : 0; Update(); @@ -839,10 +836,7 @@ namespace VocaluxeLib.Menu return; int off = _PlaylistElementContents.Count - _PlaylistElements.Count; - if (off >= 0) - Offset = off; - else - Offset = 0; + Offset = off >= 0 ? off : 0; Update(); } @@ -1100,12 +1094,13 @@ namespace VocaluxeLib.Menu for (int i = 0; i < Math.Floor(Rect.H / _Theme.EntryHeight); i++) { - CPlaylistElement en = new CPlaylistElement(); + CPlaylistElement en = new CPlaylistElement + { + Background = new CStatic(_PartyModeID, _Theme.TextureBackgroundName, BackgroundColor, + new SRectF(Rect.X, Rect.Y + (i * _Theme.EntryHeight), Rect.W, _Theme.EntryHeight, Rect.Z)), + Cover = new CStatic(_Theme.StaticCover) + }; - en.Background = new CStatic(_PartyModeID, _Theme.TextureBackgroundName, BackgroundColor, - new SRectF(Rect.X, Rect.Y + (i * _Theme.EntryHeight), Rect.W, _Theme.EntryHeight, Rect.Z)); - - en.Cover = new CStatic(_Theme.StaticCover); en.Cover.Rect.Y += Rect.Y + (i * _Theme.EntryHeight); en.Cover.Rect.X += Rect.X; @@ -1140,10 +1135,12 @@ namespace VocaluxeLib.Menu _PlaylistElementContents.Clear(); for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(ActivePlaylistID); i++) { - CPlaylistElementContent pec = new CPlaylistElementContent(); - pec.SongID = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID; - pec.Modes = CBase.Songs.GetSongByID(CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID).AvailableGameModes; - pec.Mode = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).GameMode; + CPlaylistElementContent pec = new CPlaylistElementContent + { + SongID = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID, + Modes = CBase.Songs.GetSongByID(CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID).AvailableGameModes, + Mode = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).GameMode + }; _PlaylistElementContents.Add(pec); } Update(); @@ -1157,8 +1154,7 @@ namespace VocaluxeLib.Menu _PlaylistElementContents.Clear(); for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(ActivePlaylistID); i++) { - CPlaylistElementContent pec = new CPlaylistElementContent(); - pec.SongID = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID; + CPlaylistElementContent pec = new CPlaylistElementContent {SongID = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID}; pec.Modes = CBase.Songs.GetSongByID(pec.SongID).AvailableGameModes; pec.Mode = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).GameMode; _PlaylistElementContents.Add(pec); diff --git a/VocaluxeLib/Menu/CSelectSlide.cs b/VocaluxeLib/Menu/CSelectSlide.cs index 792fdc25..a79d9e93 100644 --- a/VocaluxeLib/Menu/CSelectSlide.cs +++ b/VocaluxeLib/Menu/CSelectSlide.cs @@ -187,29 +187,24 @@ namespace VocaluxeLib.Menu public CSelectSlide(CSelectSlide slide) { _PartyModeID = slide._PartyModeID; - _Theme = new SThemeSelectSlide(); - - _Theme.TextureArrowLeftName = slide._Theme.TextureArrowLeftName; - _Theme.TextureArrowRightName = slide._Theme.TextureArrowRightName; - - _Theme.SelTextureName = slide._Theme.SelTextureName; - _Theme.SelTextureArrowLeftName = slide._Theme.SelTextureArrowLeftName; - _Theme.SelTextureArrowRightName = slide._Theme.SelTextureArrowRightName; - - _Theme.HighlightTextureName = slide._Theme.HighlightTextureName; - - _Theme.ColorName = slide._Theme.ColorName; - _Theme.SelColorName = slide._Theme.SelColorName; - _Theme.HighlightColorName = slide._Theme.HighlightColorName; - - _Theme.ArrowColorName = slide._Theme.ArrowColorName; - _Theme.SelArrowColorName = slide._Theme.SelArrowColorName; - - _Theme.TextColorName = slide._Theme.TextColorName; - _Theme.SelTextColorName = slide._Theme.SelTextColorName; - - _Theme.TextFont = slide._Theme.TextFont; - _Theme.TextStyle = slide._Theme.TextStyle; + _Theme = new SThemeSelectSlide + { + TextureArrowLeftName = slide._Theme.TextureArrowLeftName, + TextureArrowRightName = slide._Theme.TextureArrowRightName, + SelTextureName = slide._Theme.SelTextureName, + SelTextureArrowLeftName = slide._Theme.SelTextureArrowLeftName, + SelTextureArrowRightName = slide._Theme.SelTextureArrowRightName, + HighlightTextureName = slide._Theme.HighlightTextureName, + ColorName = slide._Theme.ColorName, + SelColorName = slide._Theme.SelColorName, + HighlightColorName = slide._Theme.HighlightColorName, + ArrowColorName = slide._Theme.ArrowColorName, + SelArrowColorName = slide._Theme.SelArrowColorName, + TextColorName = slide._Theme.TextColorName, + SelTextColorName = slide._Theme.SelTextColorName, + TextFont = slide._Theme.TextFont, + TextStyle = slide._Theme.TextStyle + }; _ThemeLoaded = false; diff --git a/VocaluxeLib/Menu/CStatic.cs b/VocaluxeLib/Menu/CStatic.cs index 39ed21d7..78827930 100644 --- a/VocaluxeLib/Menu/CStatic.cs +++ b/VocaluxeLib/Menu/CStatic.cs @@ -121,8 +121,7 @@ namespace VocaluxeLib.Menu public CStatic(int partyModeID, string textureSkinName, SColorF color, SRectF rect) { _PartyModeID = partyModeID; - _Theme = new SThemeStatic(); - _Theme.TextureName = textureSkinName; + _Theme = new SThemeStatic {TextureName = textureSkinName}; _ThemeLoaded = false; _Texture = new STexture(-1); @@ -244,11 +243,7 @@ namespace VocaluxeLib.Menu public void Draw(float scale, float z, EAspect aspect, bool forceDraw) { - STexture texture; - if (_Texture.Index != -1) - texture = _Texture; - else - texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); + STexture texture = _Texture.Index != -1 ? _Texture : CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); SRectF bounds = new SRectF( Rect.X - Rect.W * (scale - 1f), diff --git a/VocaluxeLib/Menu/CText.cs b/VocaluxeLib/Menu/CText.cs index 0edc1510..bddbede2 100644 --- a/VocaluxeLib/Menu/CText.cs +++ b/VocaluxeLib/Menu/CText.cs @@ -577,10 +577,7 @@ namespace VocaluxeLib.Menu writer.WriteElementString("Font", Font); writer.WriteComment(": Nothing or translation tag"); - if (CBase.Language.TranslationExists(_Theme.Text)) - writer.WriteElementString("Text", _Theme.Text); - else - writer.WriteElementString("Text", string.Empty); + writer.WriteElementString("Text", CBase.Language.TranslationExists(_Theme.Text) ? _Theme.Text : string.Empty); if (!_ButtonText) { diff --git a/VocaluxeLib/Menu/SingNotes/CNotes.cs b/VocaluxeLib/Menu/SingNotes/CNotes.cs index f2308693..7c7413ba 100644 --- a/VocaluxeLib/Menu/SingNotes/CNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CNotes.cs @@ -678,8 +678,7 @@ namespace VocaluxeLib.Menu.SingNotes if (lineIndex < 0) { //Note is before ALL lines - CLine line = new CLine(); - line.StartBeat = note.StartBeat; + CLine line = new CLine {StartBeat = note.StartBeat}; line.AddNote(note); _Lines.Insert(0, line); } diff --git a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs index 79a8d87a..9e254aee 100644 --- a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs @@ -397,8 +397,7 @@ namespace VocaluxeLib.Menu.SingNotes if (note.EndBeat >= CBase.Game.GetCurrentBeatD() && note.Hit && note.NoteType == ENoteType.Golden) { - SRectF re = new SRectF(rect); - re.W = (CBase.Game.GetMidBeatD() - note.StartBeat) / beats * w; + SRectF re = new SRectF(rect) {W = (CBase.Game.GetMidBeatD() - note.StartBeat) / beats * w}; _AddFlare(re, n); } diff --git a/VocaluxeLib/Menu/SongMenu/CSong.cs b/VocaluxeLib/Menu/SongMenu/CSong.cs index d7931f16..f0e14732 100644 --- a/VocaluxeLib/Menu/SongMenu/CSong.cs +++ b/VocaluxeLib/Menu/SongMenu/CSong.cs @@ -217,17 +217,13 @@ namespace VocaluxeLib.Menu.SongMenu public List Language = new List(); // Notes - public CNotes Notes = new CNotes(); + public readonly CNotes Notes = new CNotes(); public EGameMode[] AvailableGameModes { get { - List gms = new List(); - if (IsDuet) - gms.Add(EGameMode.TR_GAMEMODE_DUET); - else - gms.Add(EGameMode.TR_GAMEMODE_NORMAL); + List gms = new List {IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL}; if (Medley.Source != EMedleySource.None) gms.Add(EGameMode.TR_GAMEMODE_MEDLEY); gms.Add(EGameMode.TR_GAMEMODE_SHORTSONG); @@ -250,12 +246,14 @@ namespace VocaluxeLib.Menu.SongMenu _CoverTextureSmall = song._CoverTextureSmall; _CoverTextureBig = song._CoverTextureBig; - Medley = new SMedley(); - Medley.Source = song.Medley.Source; - Medley.StartBeat = song.Medley.StartBeat; - Medley.EndBeat = song.Medley.EndBeat; - Medley.FadeInTime = song.Medley.FadeInTime; - Medley.FadeOutTime = song.Medley.FadeOutTime; + Medley = new SMedley + { + Source = song.Medley.Source, + StartBeat = song.Medley.StartBeat, + EndBeat = song.Medley.EndBeat, + FadeInTime = song.Medley.FadeInTime, + FadeOutTime = song.Medley.FadeOutTime + }; CalculateMedley = song.CalculateMedley; PreviewStart = song.PreviewStart; @@ -806,8 +804,7 @@ namespace VocaluxeLib.Menu.SongMenu private void _NewSentence(int player, int start) { CLines lines = Notes.GetLines(player); - CLine line = new CLine(); - line.StartBeat = start; + CLine line = new CLine {StartBeat = start}; lines.AddLine(line); } @@ -830,8 +827,8 @@ namespace VocaluxeLib.Menu.SongMenu { if (CoverFileName == "") { - List files = CHelper.ListFiles(Folder, "*.jpg", false); - files.AddRange(CHelper.ListFiles(Folder, "*.png", false)); + List files = CHelper.ListFiles(Folder, "*.jpg"); + files.AddRange(CHelper.ListFiles(Folder, "*.png")); foreach (String file in files) { if (Regex.IsMatch(file, @".[CO].", RegexOptions.IgnoreCase) && @@ -842,8 +839,8 @@ namespace VocaluxeLib.Menu.SongMenu if (BackgroundFileName == "") { - List files = CHelper.ListFiles(Folder, "*.jpg", false); - files.AddRange(CHelper.ListFiles(Folder, "*.png", false)); + List files = CHelper.ListFiles(Folder, "*.jpg"); + files.AddRange(CHelper.ListFiles(Folder, "*.png")); foreach (String file in files) { if (Regex.IsMatch(file, @".[BG].", RegexOptions.IgnoreCase) && @@ -885,10 +882,7 @@ namespace VocaluxeLib.Menu.SongMenu List sentences = new List(); foreach (CLine line in lines.Line) { - if (line.Points != 0) - sentences.Add(line.Lyrics); - else - sentences.Add(String.Empty); + sentences.Add(line.Points != 0 ? line.Lyrics : String.Empty); } // find equal sentences series diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index 59a22604..2fa3ed64 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -237,18 +237,21 @@ namespace VocaluxeLib.Menu.SongMenu public CSongMenuFramework(int partyModeID) { _PartyModeID = partyModeID; - _Theme = new SThemeSongMenu(); - - _Theme.SongMenuTileBoard.TextArtist = new CText(_PartyModeID); - _Theme.SongMenuTileBoard.TextTitle = new CText(_PartyModeID); - _Theme.SongMenuTileBoard.TextSongLength = new CText(_PartyModeID); - - _Theme.SongMenuTileBoard.StaticCoverBig = new CStatic(_PartyModeID); - _Theme.SongMenuTileBoard.StaticTextBG = new CStatic(_PartyModeID); - _Theme.SongMenuTileBoard.StaticDuetIcon = new CStatic(_PartyModeID); - _Theme.SongMenuTileBoard.StaticVideoIcon = new CStatic(_PartyModeID); - _Theme.SongMenuTileBoard.StaticMedleyCalcIcon = new CStatic(_PartyModeID); - _Theme.SongMenuTileBoard.StaticMedleyTagIcon = new CStatic(_PartyModeID); + _Theme = new SThemeSongMenu + { + SongMenuTileBoard = + { + TextArtist = new CText(_PartyModeID), + TextTitle = new CText(_PartyModeID), + TextSongLength = new CText(_PartyModeID), + StaticCoverBig = new CStatic(_PartyModeID), + StaticTextBG = new CStatic(_PartyModeID), + StaticDuetIcon = new CStatic(_PartyModeID), + StaticVideoIcon = new CStatic(_PartyModeID), + StaticMedleyCalcIcon = new CStatic(_PartyModeID), + StaticMedleyTagIcon = new CStatic(_PartyModeID) + } + }; _ThemeLoaded = false; } diff --git a/VocaluxeLib/PartyModes/CPartyMode.cs b/VocaluxeLib/PartyModes/CPartyMode.cs index c78b9565..de9c9b7a 100644 --- a/VocaluxeLib/PartyModes/CPartyMode.cs +++ b/VocaluxeLib/PartyModes/CPartyMode.cs @@ -26,16 +26,12 @@ namespace VocaluxeLib.PartyModes public abstract class CPartyMode : IPartyMode { protected SScreenSongOptions _ScreenSongOptions; - protected Dictionary _Screens; - protected string _Folder; + protected readonly Dictionary _Screens; public CPartyMode() { _Screens = new Dictionary(); - _Folder = String.Empty; - _ScreenSongOptions = new SScreenSongOptions(); - _ScreenSongOptions.Selection = new SSelectionOptions(); - _ScreenSongOptions.Sorting = new SSortingOptions(); + _ScreenSongOptions = new SScreenSongOptions {Selection = new SSelectionOptions(), Sorting = new SSortingOptions()}; } #region Implementation