From 44c78fad1922ba41d169265b971ae7ecbefb1ab8 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Thu, 22 Aug 2013 00:05:01 +0200 Subject: [PATCH 1/2] Split Notes, Lines and Voices into separate files/classes --- .../PartyModeChallenge/CPartyModeChallenge.cs | 11 +- .../CPartyScreenChallengeMain.cs | 9 +- .../CPartyScreenChallengeNames.cs | 17 +- .../CPartyScreenChallengeMedleyMain.cs | 9 +- .../CPartyScreenChallengeMedleyNames.cs | 23 +- .../PartyModeTicTacToe/CPartyModeTicTacToe.cs | 25 +- .../CPartyScreenTicTacToeMain.cs | 14 +- .../CPartyScreenTicTacToeNames.cs | 24 +- Vocaluxe/Base/CDataBase.cs | 2 +- Vocaluxe/Base/CGame.cs | 157 +++-- Vocaluxe/Base/Server/CCommands.cs | 27 +- Vocaluxe/Base/Server/CVocaluxeServer.cs | 10 +- Vocaluxe/Base/Server/VocaluxeStructs.cs | 4 +- Vocaluxe/Screens/CScreenNames.cs | 19 +- Vocaluxe/Screens/CScreenScore.cs | 4 +- Vocaluxe/Screens/CScreenSing.cs | 62 +- VocaluxeLib/Game/CPoints.cs | 4 +- VocaluxeLib/Menu/CLyric.cs | 4 +- VocaluxeLib/Menu/CNameSelection.cs | 16 +- VocaluxeLib/Menu/CStatic.cs | 10 +- VocaluxeLib/Menu/SingNotes/CSingNotes.cs | 109 ++- VocaluxeLib/Songs/CBaseNote.cs | 63 ++ VocaluxeLib/Songs/CLineBase.cs | 135 ++++ VocaluxeLib/Songs/CNotes.cs | 627 ------------------ VocaluxeLib/Songs/CSong.cs | 6 +- VocaluxeLib/Songs/CSongLine.cs | 86 +++ VocaluxeLib/Songs/CSongNote.cs | 52 ++ VocaluxeLib/Songs/CSungLine.cs | 18 + VocaluxeLib/Songs/CSungNote.cs | 63 ++ VocaluxeLib/Songs/CVoice.cs | 194 ++++++ VocaluxeLib/Structs.cs | 4 +- VocaluxeLib/VocaluxeLib.csproj | 7 + 32 files changed, 889 insertions(+), 926 deletions(-) create mode 100644 VocaluxeLib/Songs/CBaseNote.cs create mode 100644 VocaluxeLib/Songs/CLineBase.cs create mode 100644 VocaluxeLib/Songs/CSongLine.cs create mode 100644 VocaluxeLib/Songs/CSongNote.cs create mode 100644 VocaluxeLib/Songs/CSungLine.cs create mode 100644 VocaluxeLib/Songs/CSungNote.cs create mode 100644 VocaluxeLib/Songs/CVoice.cs diff --git a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs index 1c6fa0d8..b6de22a0 100644 --- a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs +++ b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using VocaluxeLib.Menu; -using VocaluxeLib.Profile; [assembly: ComVisible(false)] @@ -65,7 +64,7 @@ namespace VocaluxeLib.PartyModes.Challenge public int CompareTo(object obj) { - CResultTableRow row = obj as CResultTableRow; + var row = obj as CResultTableRow; if (row != null) { int res = row.NumGamePoints.CompareTo(NumGamePoints); @@ -545,9 +544,7 @@ namespace VocaluxeLib.PartyModes.Challenge for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) { if (c != null) - { _ScreenSongOptions.Selection.TeamNames[i] = CBase.Profiles.GetPlayerName(_GameData.ProfileIDs[c.Player[i]]); - } else _ScreenSongOptions.Selection.TeamNames[i] = "foobar"; } @@ -559,7 +556,7 @@ namespace VocaluxeLib.PartyModes.Challenge { for (int i = 0; i < _GameData.NumPlayer; i++) { - CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0}; + var row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0}; _GameData.ResultTable.Add(row); } @@ -627,10 +624,10 @@ namespace VocaluxeLib.PartyModes.Challenge private List _GetPointsForPlayer(SPlayer[] results) { - List result = new List(); + var result = new List(); for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) { - SStats stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0}; + var stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0}; result.Add(stat); } diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs index 60a8bd86..a34e308b 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; using System.Windows.Forms; using VocaluxeLib.Menu; -using VocaluxeLib.Profile; namespace VocaluxeLib.PartyModes.Challenge { @@ -143,7 +142,7 @@ namespace VocaluxeLib.PartyModes.Challenge { try { - SDataToScreenMain data = (SDataToScreenMain)receivedData; + var data = (SDataToScreenMain)receivedData; _GameState = data; } catch (Exception e) @@ -405,7 +404,7 @@ namespace VocaluxeLib.PartyModes.Challenge _RoundsTable = new List(); for (int i = 0; i < 5; i++) { - CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List(), TextScores = new List()}; + var rtr = new CRoundsTableRow {TextPlayer = new List(), TextScores = new List()}; _RoundsTable.Add(rtr); } //Create statics and texts for rounds @@ -457,7 +456,7 @@ namespace VocaluxeLib.PartyModes.Challenge //Round-number roundRow.Number.X = numberX; roundRow.Number.Y = numberY; - int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow)); + var numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow)); for (int row = 0; row < numInnerRows; row++) { int num = (row + 1) * numPlayerInOneRow; @@ -541,7 +540,7 @@ namespace VocaluxeLib.PartyModes.Challenge for (int i = 0; i < 10; i++) { - STableRow row = new STableRow + var row = new STableRow { Pos = GetNewText(_Texts[_TextPosition]), Name = GetNewText(_Texts[_TextPlayerName]), diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs index 289f7a6d..c3662253 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using VocaluxeLib.Menu; +using VocaluxeLib.Profile; namespace VocaluxeLib.PartyModes.Challenge { @@ -88,7 +89,7 @@ namespace VocaluxeLib.PartyModes.Challenge _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _Data = new SDataFromScreen(); - SFromScreenNames names = new SFromScreenNames {FadeBack = false, ProfileIDs = new List()}; + var names = new SFromScreenNames {FadeBack = false, ProfileIDs = new List()}; _Data.ScreenNames = names; } @@ -96,7 +97,7 @@ namespace VocaluxeLib.PartyModes.Challenge { try { - SDataToScreenNames config = (SDataToScreenNames)receivedData; + var config = (SDataToScreenNames)receivedData; _Data.ScreenNames.ProfileIDs = config.ProfileIDs ?? new List(); _NumPlayer = config.NumPlayer; @@ -247,7 +248,7 @@ namespace VocaluxeLib.PartyModes.Challenge 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 {Button = b, ProfileID = -1}; + var pcb = new CPlayerChooseButton {Button = b, ProfileID = -1}; _PlayerChooseButtons.Add(pcb); column++; if (column >= _PlayerChooseButtonsNumH) @@ -309,15 +310,15 @@ namespace VocaluxeLib.PartyModes.Challenge private void _UpdateVisibleProfiles() { _PlayerChooseButtonsVisibleProfiles.Clear(); - Profile.CProfile[] profiles = CBase.Profiles.GetProfiles(); - for (int i = 0; i < profiles.Length; i++) + CProfile[] profiles = CBase.Profiles.GetProfiles(); + foreach (CProfile profile in profiles) { bool visible = false; //Show profile only if active - if (profiles[i].Active == EOffOn.TR_CONFIG_ON) - visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profiles[i].ID); + if (profile.Active == EOffOn.TR_CONFIG_ON) + visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profile.ID); if (visible) - _PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID); + _PlayerChooseButtonsVisibleProfiles.Add(profile.ID); } } diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs index 47d7ff93..a1db4bd2 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; using System.Windows.Forms; using VocaluxeLib.Menu; -using VocaluxeLib.Profile; namespace VocaluxeLib.PartyModes.ChallengeMedley { @@ -143,7 +142,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley { try { - SDataToScreenMain data = (SDataToScreenMain)receivedData; + var data = (SDataToScreenMain)receivedData; _GameState = data; } catch (Exception e) @@ -405,7 +404,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley _RoundsTable = new List(); for (int i = 0; i < 5; i++) { - CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List(), TextScores = new List()}; + var rtr = new CRoundsTableRow {TextPlayer = new List(), TextScores = new List()}; _RoundsTable.Add(rtr); } //Create statics and texts for rounds @@ -457,7 +456,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley //Round-number roundRow.Number.X = numberX; roundRow.Number.Y = numberY; - int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow)); + var numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow)); for (int row = 0; row < numInnerRows; row++) { int num = (row + 1) * numPlayerInOneRow; @@ -541,7 +540,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley for (int i = 0; i < 10; i++) { - STableRow row = new STableRow + var row = new STableRow { Pos = GetNewText(_Texts[_TextPosition]), Name = GetNewText(_Texts[_TextPlayerName]), diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs index 7346fccf..dff34fdd 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using VocaluxeLib.Menu; +using VocaluxeLib.Profile; namespace VocaluxeLib.PartyModes.ChallengeMedley { @@ -85,10 +86,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley _Data.ScreenNames.ProfileIDs = new List(); - _ThemeButtons = new string[] { _ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose }; + _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _Data = new SDataFromScreen(); - SFromScreenNames names = new SFromScreenNames { FadeToConfig = false, ProfileIDs = new List() }; + var names = new SFromScreenNames {FadeToConfig = false, ProfileIDs = new List()}; _Data.ScreenNames = names; } @@ -96,7 +97,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley { try { - SDataToScreenNames config = (SDataToScreenNames)receivedData; + var config = (SDataToScreenNames)receivedData; _Data.ScreenNames.ProfileIDs = config.ProfileIDs ?? new List(); _NumPlayer = config.NumPlayer; @@ -114,7 +115,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley { base.HandleInput(keyEvent); - if (keyEvent.KeyPressed) { } + if (keyEvent.KeyPressed) {} else { switch (keyEvent.Key) @@ -156,7 +157,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley _OldMouseX = mouseEvent.X; _OldMouseY = mouseEvent.Y; } - // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar + // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar else if (_SelectingMouseActive) { //Reset variables @@ -247,7 +248,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 { Button = b, ProfileID = -1 }; + var pcb = new CPlayerChooseButton {Button = b, ProfileID = -1}; _PlayerChooseButtons.Add(pcb); column++; if (column >= _PlayerChooseButtonsNumH) @@ -309,15 +310,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley private void _UpdateVisibleProfiles() { _PlayerChooseButtonsVisibleProfiles.Clear(); - Profile.CProfile[] profiles = CBase.Profiles.GetProfiles(); - for (int i = 0; i < profiles.Length; i++) + CProfile[] profiles = CBase.Profiles.GetProfiles(); + foreach (CProfile profile in profiles) { bool visible = false; //Show profile only if active - if (profiles[i].Active == EOffOn.TR_CONFIG_ON) - visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profiles[i].ID); + if (profile.Active == EOffOn.TR_CONFIG_ON) + visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profile.ID); if (visible) - _PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID); + _PlayerChooseButtonsVisibleProfiles.Add(profile.ID); } } diff --git a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs index d7730f65..c7ebe356 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using VocaluxeLib.Menu; -using VocaluxeLib.Profile; [assembly: ComVisible(false)] @@ -248,7 +247,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe public override void DataFromScreen(string screenName, Object data) { - SDataFromScreen dataFrom = new SDataFromScreen(); + var dataFrom = new SDataFromScreen(); switch (screenName) { case "PartyScreenTicTacToeConfig": @@ -492,7 +491,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe public override void SongSelected(int songID) { - EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; + var gm = EGameMode.TR_GAMEMODE_NORMAL; switch (_GameData.GameMode) { @@ -525,7 +524,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe _GameData.Rounds = new List(); for (int i = 0; i < _GameData.NumFields; i++) { - CRound r = new CRound(); + var r = new CRound(); _GameData.Rounds.Add(r); } } @@ -540,11 +539,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe _GameData.PlayerTeam2 = new List(); //Prepare Player-IDs - List ids1 = new List(); - List ids2 = new List(); + var ids1 = new List(); + var ids2 = new List(); //Add IDs to team-list while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && - _GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] ) + _GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1]) { if (ids1.Count == 0) { @@ -579,7 +578,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe case 1: { //Prepare Player-IDs - List ids = new List(); + var ids = new List(); //Add IDs to team-list while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && ids.Count == 0) { @@ -602,7 +601,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe case 2: { //Prepare Player-IDs - List ids = new List(); + var ids = new List(); //Add IDs to team-list while (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && ids.Count == 0) { @@ -627,7 +626,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe private void _PrepareSongList() { - EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; + var gm = EGameMode.TR_GAMEMODE_NORMAL; switch (_GameData.GameMode) { @@ -646,7 +645,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe while (_GameData.Songs.Count < (_GameData.NumFields + _GameData.NumJokerRandom[0] + _GameData.NumJokerRandom[1])) { - List songs = new List(); + var songs = new List(); switch (_GameData.SongSource) { case ESongSource.TR_PLAYLIST: @@ -741,11 +740,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe { players[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1]; if (isDuet) - players[0].LineNr = 0; + players[0].VoiceNr = 0; players[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2]; if (isDuet) - players[1].LineNr = 1; + players[1].VoiceNr = 1; SongSelected(r.SongID); } diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs index 46887b31..71976a20 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs @@ -22,7 +22,6 @@ using System.Collections.Generic; using System.Windows.Forms; using VocaluxeLib.Menu; using VocaluxeLib.Songs; -using VocaluxeLib.Profile; namespace VocaluxeLib.PartyModes.TicTacToe { @@ -104,7 +103,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe _ThemeStatics = new string[] {_StaticPopupBG, _StaticAvatarT1, _StaticAvatarT2}; _Data = new SDataFromScreen(); - SFromScreenMain config = new SFromScreenMain(); + var config = new SFromScreenMain(); _GameData = new SDataToScreenMain(); config.SingRoundNr = 1; config.Rounds = new List(); @@ -130,7 +129,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe { try { - SDataToScreenMain config = (SDataToScreenMain)receivedData; + var config = (SDataToScreenMain)receivedData; _GameData = config; } catch (Exception e) @@ -389,7 +388,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe { for (int i = 0; i < 25; i++) { - CField f = new CField {Button = GetNewButton(_Buttons[_ButtonField])}; + var f = new CField {Button = GetNewButton(_Buttons[_ButtonField])}; f.Button.Visible = false; f.Content = new CRound(); _AddButton(f.Button); @@ -399,7 +398,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe private void _UpdateFields() { - int numOneRow = (int)Math.Sqrt(_GameData.NumFields); + var numOneRow = (int)Math.Sqrt(_GameData.NumFields); float fieldSizeY = ((float)CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow; float fieldSizeX = ((float)CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow; _FieldSize = Math.Min(fieldSizeX, fieldSizeY); @@ -495,7 +494,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe _GameData.Rounds[_SelectedField].SingerTeam2 = singerTeam2; _UpdatePlayerInformation(); - } int songID = 0; if (_GameData.Songs.Count > 0) @@ -672,7 +670,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe private int _BuildWinnerPossibilities() { - int numOneRow = (int)Math.Sqrt(_GameData.NumFields); + var numOneRow = (int)Math.Sqrt(_GameData.NumFields); _Possibilities = new int[(numOneRow * 2) + 2,numOneRow]; for (int i = 0; i < _Possibilities.GetLength(0); i++) { @@ -704,7 +702,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe { for (int i = 0; i < _Possibilities.GetLength(0); i++) { - List check = new List(); + var check = new List(); for (int j = 0; j < _Possibilities.GetLength(1); j++) { if (_Fields[_Possibilities[i, j]].Content.Winner > 0) diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs index f1c3c144..49443eb1 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using VocaluxeLib.Menu; +using VocaluxeLib.Profile; namespace VocaluxeLib.PartyModes.TicTacToe { @@ -93,7 +94,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose, _ButtonPlayerChooseScrollUp, _ButtonPlayerChooseScrollDown}; _Data = new SDataFromScreen(); - SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, ProfileIDsTeam1 = new List(), ProfileIDsTeam2 = new List()}; + var names = new SFromScreenNames {FadeToConfig = false, ProfileIDsTeam1 = new List(), ProfileIDsTeam2 = new List()}; _Data.ScreenNames = names; } @@ -101,7 +102,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe { try { - SDataToScreenNames config = (SDataToScreenNames)receivedData; + var config = (SDataToScreenNames)receivedData; _Data.ScreenNames.ProfileIDsTeam1 = config.ProfileIDsTeam1; _Data.ScreenNames.ProfileIDsTeam2 = config.ProfileIDsTeam2; if (_Data.ScreenNames.ProfileIDsTeam1 == null) @@ -375,7 +376,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 {Button = b, ProfileID = -1}; + var pcb = new CPlayerChooseButton {Button = b, ProfileID = -1}; _PlayerChooseButtons.Add(pcb); column++; if (column >= _PlayerChooseButtonsNumH) @@ -418,7 +419,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe _PlayerChooseButtons[i].ProfileID = id; _PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetPlayerName(id); _PlayerChooseButtons[i].Button.Texture = CBase.Profiles.GetAvatar(id); - _PlayerChooseButtons[i].Button.SelTexture = CBase.Profiles.GetAvatar(id); + _PlayerChooseButtons[i].Button.SelTexture = CBase.Profiles.GetAvatar(id); _PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f); _PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1); _PlayerChooseButtons[i].Button.Enabled = true; @@ -440,15 +441,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe private void _UpdateVisibleProfiles() { _PlayerChooseButtonsVisibleProfiles.Clear(); - Profile.CProfile[] profiles = CBase.Profiles.GetProfiles(); - for (int i = 0; i < profiles.Length; i++) + CProfile[] profiles = CBase.Profiles.GetProfiles(); + foreach (CProfile profile in profiles) { bool visible = false; //Show profile only if active - if (profiles[i].Active == EOffOn.TR_CONFIG_ON) - visible = _Data.ScreenNames.ProfileIDsTeam1.All(profileID => profileID != profiles[i].ID) && _Data.ScreenNames.ProfileIDsTeam2.All(profileID => profileID != profiles[i].ID); + if (profile.Active == EOffOn.TR_CONFIG_ON) + visible = _Data.ScreenNames.ProfileIDsTeam1.All(profileID => profileID != profile.ID) && + _Data.ScreenNames.ProfileIDsTeam2.All(profileID => profileID != profile.ID); if (visible) - _PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID); + _PlayerChooseButtonsVisibleProfiles.Add(profile.ID); } } @@ -486,7 +488,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe { if (_Data.ScreenNames.ProfileIDsTeam1[i] != -1) { - int id = _Data.ScreenNames.ProfileIDsTeam1[i]; + int id = _Data.ScreenNames.ProfileIDsTeam1[i]; _PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[i].Texture = CBase.Profiles.GetAvatar(id); @@ -511,7 +513,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe { if (_Data.ScreenNames.ProfileIDsTeam2[i] != -1) { - int id = _Data.ScreenNames.ProfileIDsTeam2[i]; + int id = _Data.ScreenNames.ProfileIDsTeam2[i]; _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[i].Texture = CBase.Profiles.GetAvatar(id); diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 2e9c4b65..d9f56b01 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -114,7 +114,7 @@ namespace Vocaluxe.Base using (SQLiteCommand command = new SQLiteCommand(connection)) { int dataBaseSongID = _GetDataBaseSongID(player, command); - return _AddScore(CProfiles.GetPlayerName(player.ProfileID), (int)Math.Round(player.Points), player.LineNr, player.DateTicks, player.Medley ? 1 : 0, + return _AddScore(CProfiles.GetPlayerName(player.ProfileID), (int)Math.Round(player.Points), player.VoiceNr, player.DateTicks, player.Medley ? 1 : 0, player.Duet ? 1 : 0, player.ShortSong ? 1 : 0, (int)CProfiles.GetDifficulty(player.ProfileID), dataBaseSongID, command); } } diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index 40942314..9acd1881 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -172,9 +172,9 @@ namespace Vocaluxe.Base Players[i].Points = 0f; Players[i].PointsLineBonus = 0f; Players[i].PointsGoldenNotes = 0f; - Players[i].LineNr = 0; + Players[i].VoiceNr = 0; Players[i].NoteDiff = 0; - Players[i].SingLine = new List(); + Players[i].SungLines = new List(); Players[i].CurrentLine = -1; Players[i].CurrentNote = -1; Players[i].SongID = -1; @@ -221,7 +221,7 @@ namespace Vocaluxe.Base (_SongQueue.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat)) Players[p].SongFinished = true; - CLine[] lines = song.Notes.GetVoice(Players[p].LineNr).Lines; + CSongLine[] lines = song.Notes.GetVoice(Players[p].VoiceNr).Lines; int line = -1; for (int j = 0; j < lines.Length; j++) @@ -240,103 +240,102 @@ namespace Vocaluxe.Base Players[p].CurrentLine = line; - while (Players[p].SingLine.Count <= line) - Players[p].SingLine.Add(new CLine()); + while (Players[p].SungLines.Count <= line) + Players[p].SungLines.Add(new CSungLine()); - CNote[] notes = lines[line].Notes; + CSongNote[] notes = lines[line].Notes; int note = lines[line].FindPreviousNote(beat); if (note >= 0 && notes[note].EndBeat < beat) note = -1; - if (note >= 0) + if (note < 0) + continue; + Players[p].CurrentNote = note; + + if (line == lines.Length - 1) { - Players[p].CurrentNote = note; - - if (line == lines.Length - 1) + if (note == lines[line].NoteCount - 1) { - if (note == lines[line].NoteCount - 1) - { - if (notes[note].EndBeat == beat) - Players[p].SongFinished = true; - } + if (notes[note].EndBeat == beat) + Players[p].SongFinished = true; } + } - if (notes[note].PointsForBeat > 0 && CSound.RecordToneValid(p)) + if (notes[note].PointsForBeat > 0 && CSound.RecordToneValid(p)) + { + int tone = notes[note].Tone; + int tonePlayer = CSound.RecordGetTone(p); + + while (tonePlayer - tone > 6) + tonePlayer -= 12; + + while (tonePlayer - tone < -6) + tonePlayer += 12; + + Players[p].NoteDiff = Math.Abs(tone - tonePlayer); + bool hit = Players[p].NoteDiff <= (2 - (int)CProfiles.GetDifficulty(Players[p].ProfileID)); + if (hit) { - int tone = notes[note].Tone; - int tonePlayer = CSound.RecordGetTone(p); + // valid + //CSound.RecordSetTone(p, Tone); + double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat / + song.Notes.GetVoice(Players[p].VoiceNr).Points; + if (notes[note].NoteType == ENoteType.Golden) + Players[p].PointsGoldenNotes += points; - while (tonePlayer - tone > 6) - tonePlayer -= 12; + Players[p].Points += points; - while (tonePlayer - tone < -6) - tonePlayer += 12; - - Players[p].NoteDiff = Math.Abs(tone - tonePlayer); - bool hit = Players[p].NoteDiff <= (2 - (int)CProfiles.GetDifficulty(Players[p].ProfileID)); - if (hit) + // update player notes (sung notes) + if (Players[p].SungLines[line].NoteCount > 0) { - // valid - //CSound.RecordSetTone(p, Tone); - double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat / - song.Notes.GetVoice(Players[p].LineNr).Points; - if (notes[note].NoteType == ENoteType.Golden) - Players[p].PointsGoldenNotes += points; - - Players[p].Points += points; - - // update player notes (sung notes) - if (Players[p].SingLine[line].NoteCount > 0) - { - CNote lastNote = Players[p].SingLine[line].LastNote; - if (notes[note].StartBeat == beat || lastNote.EndBeat + 1 != beat || lastNote.Tone != tone || !lastNote.Hit) - Players[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType)); - else - Players[p].SingLine[line].IncLastNoteLength(); - } + CSungNote lastNote = Players[p].SungLines[line].LastNote; + if (notes[note].StartBeat == beat || lastNote.EndBeat + 1 != beat || lastNote.Tone != tone || !lastNote.Hit) + Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tone, notes[note])); else - Players[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType)); - - Players[p].SingLine[line].LastNote.IsPerfect(notes[note]); - Players[p].SingLine[line].IsPerfect(lines[line]); + Players[p].SungLines[line].IncLastNoteLength(); } else - { - if (Players[p].SingLine[line].NoteCount > 0) - { - CNote lastNote = Players[p].SingLine[line].LastNote; - if (lastNote.Tone == tonePlayer && lastNote.EndBeat + 1 == beat && !lastNote.Hit) - Players[p].SingLine[line].IncLastNoteLength(); - else - Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle)); - } - else - Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle)); - } + Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tone, notes[note])); + + Players[p].SungLines[line].LastNote.CheckPerfect(); + Players[p].SungLines[line].IsPerfect(lines[line]); } - - // Line Bonus - int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(Players[p].LineNr); - if (note == lines[line].NoteCount - 1 && numLinesWithPoints > 0) + else { - if (notes[note].EndBeat == beat && lines[line].Points > 0f) + if (Players[p].SungLines[line].NoteCount > 0) { - double factor = Players[p].SingLine[line].Points / (double)lines[line].Points; - if (factor < 0.4) - factor = 0.0; - else if (factor > 0.9) - factor = 1.0; + CSungNote lastNote = Players[p].SungLines[line].LastNote; + if (lastNote.Tone != tonePlayer || lastNote.EndBeat + 1 != beat || lastNote.Hit) + Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tonePlayer)); else - { - factor -= 0.4; - factor *= 2; - factor *= factor; - } - - double points = CSettings.LinebonusScore * factor * 1f / numLinesWithPoints; - Players[p].Points += points; - Players[p].PointsLineBonus += points; + Players[p].SungLines[line].IncLastNoteLength(); } + else + Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tonePlayer)); + } + } + + // Line Bonus + int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(Players[p].VoiceNr); + if (note == lines[line].NoteCount - 1 && numLinesWithPoints > 0) + { + if (notes[note].EndBeat == beat && lines[line].Points > 0f) + { + double factor = Players[p].SungLines[line].Points / (double)lines[line].Points; + if (factor < 0.4) + factor = 0.0; + else if (factor > 0.9) + factor = 1.0; + else + { + factor -= 0.4; + factor *= 2; + factor *= factor; + } + + double points = CSettings.LinebonusScore * factor * 1f / numLinesWithPoints; + Players[p].Points += points; + Players[p].PointsLineBonus += points; } } } diff --git a/Vocaluxe/Base/Server/CCommands.cs b/Vocaluxe/Base/Server/CCommands.cs index ecfa087e..aa99c89b 100644 --- a/Vocaluxe/Base/Server/CCommands.cs +++ b/Vocaluxe/Base/Server/CCommands.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.IO; using System.Text; using System.Security.Cryptography; - using Newtonsoft.Json; namespace Vocaluxe.Base.Server @@ -25,7 +22,6 @@ namespace Vocaluxe.Base.Server public const int ResponseLoginFailed = 22; public const int ResponseLoginOK = 23; - public const int CommandSendKeyStroke = 100; public const int CommandSendKeyUp = 110; public const int CommandSendKeyDown = 111; @@ -45,7 +41,6 @@ namespace Vocaluxe.Base.Server public const int CommandSendAvatarPictureJpg = 501; public const int CommandSendProfile = 510; - #endregion Commands #region General @@ -58,7 +53,7 @@ namespace Vocaluxe.Base.Server #region Login public static byte[] CreateCommandLogin(string Password) { - SLoginData data = new SLoginData(); + var data = new SLoginData(); data.SHA256 = SHA256.ComputeHash(Encoding.UTF8.GetBytes(Password)); return Serialize(CommandLogin, data); @@ -71,13 +66,12 @@ namespace Vocaluxe.Base.Server #endregion Login #region Keyboard - #endregion Keyboard #region Profiles public static byte[] CreateCommandSendAvatarPicture(int Width, int Height, byte[] data) { - SAvatarPicture ap = new SAvatarPicture(); + var ap = new SAvatarPicture(); ap.Height = Height; ap.Width = Width; ap.data = new byte[data.Length]; @@ -93,7 +87,7 @@ namespace Vocaluxe.Base.Server public static byte[] CreateCommandSendAvatarPictureJpg(byte[] AvatarJpgData) { - SAvatarPicture ap = new SAvatarPicture(); + var ap = new SAvatarPicture(); ap.Height = 0; ap.Width = 0; ap.data = new byte[AvatarJpgData.Length]; @@ -104,13 +98,13 @@ namespace Vocaluxe.Base.Server public static byte[] CreateCommandSendProfile(byte[] AvatarJpgData, string PlayerName, int Difficulty) { - SAvatarPicture ap = new SAvatarPicture(); + var ap = new SAvatarPicture(); ap.Height = 0; ap.Width = 0; ap.data = new byte[AvatarJpgData.Length]; Array.Copy(AvatarJpgData, ap.data, AvatarJpgData.Length); - SProfile profile = new SProfile(); + var profile = new SProfile(); profile.Avatar = ap; profile.PlayerName = PlayerName; profile.Difficulty = Difficulty; @@ -122,7 +116,6 @@ namespace Vocaluxe.Base.Server { return TryDeserialize(Message, out Profile); } - #endregion Profiles #region Serializing @@ -130,11 +123,11 @@ namespace Vocaluxe.Base.Server { byte[] command = BitConverter.GetBytes(Command); - MemoryStream stream = new MemoryStream(); + var stream = new MemoryStream(); stream.Write(command, 0, command.Length); byte[] data; - using (MemoryStream ms = new MemoryStream()) + using (var ms = new MemoryStream()) { string json = JsonConvert.SerializeObject(obj); data = encoder.GetBytes(json); @@ -153,9 +146,9 @@ namespace Vocaluxe.Base.Server if (message.Length < 5) return false; - byte[] data = new byte[message.Length - 4]; + var data = new byte[message.Length - 4]; Array.Copy(message, 4, data, 0, data.Length); - using (MemoryStream ms = new MemoryStream(data)) + using (var ms = new MemoryStream(data)) { try { @@ -170,4 +163,4 @@ namespace Vocaluxe.Base.Server } #endregion Serializing } -} +} \ No newline at end of file diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index fb8e1f83..2b70775c 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -22,9 +22,7 @@ using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; -using System.Linq; using System.IO; -using System.Text; using System.Windows.Forms; using ClientServerLib; using Vocaluxe.Lib.Input; @@ -84,7 +82,7 @@ namespace Vocaluxe.Base.Server { if (!_Clients.ContainsKey(connectionID)) { - CClientHandler client = new CClientHandler(connectionID); + var client = new CClientHandler(connectionID); _Clients.Add(connectionID, client); } @@ -120,7 +118,7 @@ namespace Vocaluxe.Base.Server SAvatarPicture avatarPicture; if (CCommands.DecodeCommandSendAvatarPicture(message, out avatarPicture)) { - using (Bitmap bmp = new Bitmap(avatarPicture.Width, avatarPicture.Height)) + using (var bmp = new Bitmap(avatarPicture.Width, avatarPicture.Height)) { BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); Marshal.Copy(avatarPicture.data, 0, bmpData.Scan0, avatarPicture.data.Length); @@ -156,7 +154,7 @@ namespace Vocaluxe.Base.Server string avatarFilename = _AddAvatar(profile.Avatar.data); if (avatarFilename != String.Empty) { - CProfile p = new CProfile + var p = new CProfile { Active = EOffOn.TR_CONFIG_ON, AvatarFileName = avatarFilename, @@ -193,7 +191,7 @@ namespace Vocaluxe.Base.Server fs.Flush(); fs.Close(); - CAvatar avatar = new CAvatar(-1); + var avatar = new CAvatar(-1); if (avatar.LoadFromFile(filename)) { CProfiles.AddAvatar(avatar); diff --git a/Vocaluxe/Base/Server/VocaluxeStructs.cs b/Vocaluxe/Base/Server/VocaluxeStructs.cs index 99b917d2..faf0dfa6 100644 --- a/Vocaluxe/Base/Server/VocaluxeStructs.cs +++ b/Vocaluxe/Base/Server/VocaluxeStructs.cs @@ -1,6 +1,4 @@ -using System; - -namespace Vocaluxe.Base.Server +namespace Vocaluxe.Base.Server { public struct SLoginData { diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index eed8851b..4cc13fdb 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -24,7 +24,6 @@ using Vocaluxe.Base; using VocaluxeLib; using VocaluxeLib.Draw; using VocaluxeLib.Menu; -using VocaluxeLib.Profile; namespace Vocaluxe.Screens { @@ -71,14 +70,14 @@ namespace Vocaluxe.Screens { base.Init(); - List statics = new List(); + var statics = new List(); statics.AddRange(_StaticPlayerAvatar); statics.AddRange(_StaticPlayer); statics.Add(_StaticWarningMics); statics.Add(_StaticWarningProfiles); _ThemeStatics = statics.ToArray(); - List texts = new List {_SelectSlidePlayerNumber}; + var texts = new List {_SelectSlidePlayerNumber}; texts.AddRange(_SelectSlideDuetPlayer); _ThemeSelectSlides = texts.ToArray(); @@ -411,13 +410,9 @@ namespace Vocaluxe.Screens if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) { if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID > -1) - { _UpdateSelectedProfile(_SelectingSwitchNr, CGame.Players[i].ProfileID); - } else if (_SelectingSwitchNr > -1) - { _ResetPlayerSelection(_SelectingSwitchNr); - } if (!CProfiles.IsProfileIDValid(_SelectedProfileID)) return true; @@ -427,9 +422,7 @@ namespace Vocaluxe.Screens } //Selected player is dropped out of area if (_SelectingSwitchNr > -1) - { _ResetPlayerSelection(_SelectingSwitchNr); - } } _SelectingSwitchNr = -1; _SelectedProfileID = -1; @@ -449,7 +442,7 @@ namespace Vocaluxe.Screens return true; _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedProfileID); - + _SelectingFastPlayerNr++; if (_SelectingFastPlayerNr <= CGame.NumPlayer) _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); @@ -633,7 +626,7 @@ namespace Vocaluxe.Screens for (int i = 0; i < CGame.NumPlayer; i++) { if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) - CGame.Players[i].LineNr = _SelectSlides[_SelectSlideDuetPlayer[i]].Selection; + CGame.Players[i].VoiceNr = _SelectSlides[_SelectSlideDuetPlayer[i]].Selection; } CGraphics.FadeTo(EScreens.ScreenSing); @@ -726,7 +719,7 @@ namespace Vocaluxe.Screens private void _CheckMics() { - List playerWithoutMicro = new List(); + var playerWithoutMicro = new List(); for (int player = 0; player < CConfig.NumPlayer; player++) { if (!CConfig.IsMicConfig(player + 1)) @@ -764,7 +757,7 @@ namespace Vocaluxe.Screens private void _CheckPlayers() { - List playerWithoutProfile = new List(); + var playerWithoutProfile = new List(); for (int player = 0; player < CConfig.NumPlayer; player++) { if (CGame.Players[player].ProfileID < 0) diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index 94838312..759a70f9 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -296,9 +296,9 @@ namespace Vocaluxe.Screens string name = CProfiles.GetPlayerName(players[p].ProfileID, p); if (song != null && song.IsDuet) { - if (players[p].LineNr == 0 && song.DuetPart1 != "Part 1") + if (players[p].VoiceNr == 0 && song.DuetPart1 != "Part 1") name += " (" + song.DuetPart1 + ")"; - else if (players[p].LineNr == 1 && song.DuetPart2 != "Part 2") + else if (players[p].VoiceNr == 1 && song.DuetPart2 != "Part 2") name += " (" + song.DuetPart2 + ")"; } _Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = name; diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 9e9d4ebd..94dfa613 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -125,11 +125,11 @@ namespace Vocaluxe.Screens { base.Init(); - List texts = new List {_TextSongName, _TextTime, _TextPause, _TextDuetName1, _TextDuetName2, _TextMedleyCountdown}; + var texts = new List {_TextSongName, _TextTime, _TextPause, _TextDuetName1, _TextDuetName2, _TextMedleyCountdown}; _BuildTextStrings(texts); _ThemeTexts = texts.ToArray(); - List statics = new List + var statics = new List { _StaticSongText, _StaticLyrics, @@ -148,7 +148,7 @@ namespace Vocaluxe.Screens _BuildStaticStrings(ref statics); _ThemeStatics = statics.ToArray(); - List buttons = new List {_ButtonCancel, _ButtonContinue, _ButtonSkip}; + var buttons = new List {_ButtonCancel, _ButtonContinue, _ButtonSkip}; _ThemeButtons = buttons.ToArray(); _ThemeLyrics = new string[] {_LyricMain, _LyricSub, _LyricMainDuet, _LyricSubDuet, _LyricMainTop, _LyricSubTop}; @@ -202,7 +202,7 @@ namespace Vocaluxe.Screens break; case Keys.T: - int mode = (int)CConfig.TimerMode; + var mode = (int)CConfig.TimerMode; mode++; if (mode > Enum.GetNames(typeof(ETimerMode)).Length - 1) @@ -355,18 +355,18 @@ namespace Vocaluxe.Screens for (int p = 0; p < CGame.NumPlayer; p++) { - _SingNotes[_SingBars].SetAlpha(_NoteLines[p], alpha[CGame.Players[p].LineNr * 2]); + _SingNotes[_SingBars].SetAlpha(_NoteLines[p], alpha[CGame.Players[p].VoiceNr * 2]); if (CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_INFO || CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_ALL) { - _Statics[_StaticAvatars[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; - _Texts[_TextNames[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; + _Statics[_StaticAvatars[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; + _Texts[_TextNames[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; } if (CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_ALL) { - _Statics[_StaticScores[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; - _Statics[_StaticAvatars[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; - _Texts[_TextNames[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; - _Texts[_TextScores[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; + _Statics[_StaticScores[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; + _Statics[_StaticAvatars[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; + _Texts[_TextNames[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; + _Texts[_TextScores[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; } } @@ -459,7 +459,7 @@ namespace Vocaluxe.Screens if (_Active) { CTexture background; - EAspect aspect = EAspect.Crop; + var aspect = EAspect.Crop; if (_CurrentVideo != -1 && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam) { background = _CurrentVideoTexture; @@ -474,7 +474,7 @@ namespace Vocaluxe.Screens background = _Background; if (background != null) { - RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH); + var bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH); RectangleF rect; CHelper.SetRect(bounds, out rect, background.OrigAspect, aspect); CDraw.DrawTexture(background, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f), @@ -512,7 +512,7 @@ namespace Vocaluxe.Screens for (int i = 0; i < CGame.NumPlayer; i++) - _SingNotes[_SingBars].Draw(_NoteLines[i], CGame.Players[i].SingLine, i); + _SingNotes[_SingBars].Draw(_NoteLines[i], CGame.Players[i].SungLines, i); _DrawLyricHelper(); @@ -607,12 +607,12 @@ namespace Vocaluxe.Screens _FinishTime = song.Finish; _TimeToFirstNote = 0f; _TimeToFirstNoteDuet = 0f; - int[] duetPlayer = new int[CGame.NumPlayer]; + var duetPlayer = new int[CGame.NumPlayer]; if (song.IsDuet) { //Save duet-assignment before resetting for (int i = 0; i < duetPlayer.Length; i++) - duetPlayer[i] = CGame.Players[i].LineNr; + duetPlayer[i] = CGame.Players[i].VoiceNr; } CGame.ResetPlayer(); @@ -641,12 +641,12 @@ namespace Vocaluxe.Screens if (CGame.GetNumSongs() > 1) { for (int i = 0; i < CGame.NumPlayer; i++) - CGame.Players[i].LineNr = (i + 1) % 2; + CGame.Players[i].VoiceNr = (i + 1) % 2; } else { for (int i = 0; i < CGame.NumPlayer; i++) - CGame.Players[i].LineNr = duetPlayer[i]; + CGame.Players[i].VoiceNr = duetPlayer[i]; } } @@ -745,7 +745,7 @@ namespace Vocaluxe.Screens CWebcam.Close(); } - private int _FindCurrentLine(CVoice voice, CLine[] lines, CSong song) + private int _FindCurrentLine(CVoice voice, CSongLine[] lines, CSong song) { float currentTime = _CurrentTime - song.Gap; //We are only interested in the last matching line, so either do not check further after line[j].StartBeat > _CurrentBeat or go backwards! @@ -787,7 +787,7 @@ namespace Vocaluxe.Screens break; // for later CVoice voice = song.Notes.GetVoice(i); - CLine[] lines = voice.Lines; + CSongLine[] lines = voice.Lines; // find current line int nr = _FindCurrentLine(voice, lines, song); @@ -796,7 +796,7 @@ namespace Vocaluxe.Screens { for (int j = 0; j < CGame.NumPlayer; j++) { - if (CGame.Players[j].LineNr == i) + if (CGame.Players[j].VoiceNr == i) _SingNotes[_SingBars].SetLines(_NoteLines[j], lines, nr); } @@ -980,7 +980,7 @@ namespace Vocaluxe.Screens if (_CurrentTime < timeToFirstMedleyNote) { float timeDiff = timeToFirstMedleyNote - _CurrentTime + 1; - float fullSeconds = (float)Math.Truncate(timeDiff); + var fullSeconds = (float)Math.Truncate(timeDiff); float partSeconds = timeDiff - fullSeconds; _Texts[_TextMedleyCountdown].Visible = true; _Texts[_TextMedleyCountdown].Text = fullSeconds.ToString(); @@ -1025,7 +1025,7 @@ namespace Vocaluxe.Screens if (_Statics[_StaticLyrics].Visible) { SRectF rect = _Statics[_StaticLyricHelper].Rect; - SColorF color = new SColorF( + var color = new SColorF( _Statics[_StaticLyricHelper].Color.R, _Statics[_StaticLyricHelper].Color.G, _Statics[_StaticLyricHelper].Color.B, @@ -1039,7 +1039,7 @@ namespace Vocaluxe.Screens if (_Statics[_StaticLyricsTop].Visible) { SRectF rect = _Statics[_StaticLyricHelperTop].Rect; - SColorF color = new SColorF( + var color = new SColorF( _Statics[_StaticLyricHelperTop].Color.R, _Statics[_StaticLyricHelperTop].Color.G, _Statics[_StaticLyricHelperTop].Color.B, @@ -1066,7 +1066,7 @@ namespace Vocaluxe.Screens SRectF rect = _Statics[_StaticLyricHelperDuet].Rect; - SColorF color = new SColorF( + var color = new SColorF( _Statics[_StaticLyricHelperDuet].Color.R, _Statics[_StaticLyricHelperDuet].Color.G, _Statics[_StaticLyricHelperDuet].Color.B, @@ -1089,13 +1089,13 @@ namespace Vocaluxe.Screens if (song == null || !song.NotesLoaded) return null; - float[] alpha = new float[song.Notes.Voices.Length * 2]; + var alpha = new float[song.Notes.Voices.Length * 2]; float currentTime = _CurrentTime - song.Gap; for (int i = 0; i < song.Notes.LinesCount; i++) { CVoice voice = song.Notes.GetVoice(i); - CLine[] lines = voice.Lines; + CSongLine[] lines = voice.Lines; // find current line for lyric sub fading int currentLineSub = _FindCurrentLine(voice, lines, song); @@ -1292,8 +1292,8 @@ namespace Vocaluxe.Screens switch (CConfig.TimerMode) { case ETimerMode.TR_CONFIG_TIMERMODE_CURRENT: - int min = (int)Math.Floor(currentTime / 60f); - int sec = (int)(currentTime - min * 60f); + var min = (int)Math.Floor(currentTime / 60f); + var sec = (int)(currentTime - min * 60f); _Texts[_TextTime].Text = min.ToString("00") + ":" + sec.ToString("00"); break; @@ -1368,9 +1368,9 @@ namespace Vocaluxe.Screens foreach (CVoice voice in song.Notes.Voices) { - foreach (CLine line in voice.Lines.Where(line => line.VisibleInTimeLine)) + foreach (CSongLine line in voice.Lines.Where(line => line.VisibleInTimeLine)) { - STimeRect trect = new STimeRect {StartBeat = line.FirstNoteBeat, EndBeat = line.EndBeat}; + var trect = new STimeRect {StartBeat = line.FirstNoteBeat, EndBeat = line.EndBeat}; trect.Rect = GetNewStatic(null, new SColorF(1f, 1f, 1f, 1f), new SRectF( diff --git a/VocaluxeLib/Game/CPoints.cs b/VocaluxeLib/Game/CPoints.cs index a0f82b90..31afe16c 100644 --- a/VocaluxeLib/Game/CPoints.cs +++ b/VocaluxeLib/Game/CPoints.cs @@ -51,7 +51,7 @@ namespace VocaluxeLib.Game for (int player = 0; player < players.Length; player++) { _Rounds[round, player].SongID = songID; - _Rounds[round, player].LineNr = players[player].LineNr; + _Rounds[round, player].VoiceNr = players[player].VoiceNr; _Rounds[round, player].Points = players[player].Points; _Rounds[round, player].PointsGoldenNotes = players[player].PointsGoldenNotes; _Rounds[round, player].PointsLineBonus = players[player].PointsLineBonus; @@ -88,7 +88,7 @@ namespace VocaluxeLib.Game players[p].PointsGoldenNotes = _Rounds[round, p].PointsGoldenNotes; players[p].PointsLineBonus = _Rounds[round, p].PointsLineBonus; players[p].SongID = _Rounds[round, p].SongID; - players[p].LineNr = _Rounds[round, p].LineNr; + players[p].VoiceNr = _Rounds[round, p].VoiceNr; players[p].Medley = _Rounds[round, p].Medley; players[p].Duet = _Rounds[round, p].Duet; players[p].ShortSong = _Rounds[round, p].ShortSong; diff --git a/VocaluxeLib/Menu/CLyric.cs b/VocaluxeLib/Menu/CLyric.cs index a57b5f6a..cdd1b1a8 100644 --- a/VocaluxeLib/Menu/CLyric.cs +++ b/VocaluxeLib/Menu/CLyric.cs @@ -201,12 +201,12 @@ namespace VocaluxeLib.Menu return false; } - public void SetLine(CLine line) + public void SetLine(CSongLine line) { _Notes.Clear(); _Width = 0f; - foreach (CNote note in line.Notes) + foreach (CSongNote note in line.Notes) { SNote n = new SNote {Text = note.Text, StartBeat = note.StartBeat, EndBeat = note.EndBeat, Duration = note.Duration, Type = note.NoteType}; diff --git a/VocaluxeLib/Menu/CNameSelection.cs b/VocaluxeLib/Menu/CNameSelection.cs index b2238b53..e7a4c908 100644 --- a/VocaluxeLib/Menu/CNameSelection.cs +++ b/VocaluxeLib/Menu/CNameSelection.cs @@ -487,10 +487,10 @@ namespace VocaluxeLib.Menu { for (int j = 0; j < _NumW; j++) { - SRectF rect = new SRectF(Rect.X + j * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, Rect.Z); - CStatic tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, ColorEmptyTile, rect) {Aspect = EAspect.Crop}; - CText tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.NameSpace, rect.Z, _Theme.NameHeight, rect.W, EAlignment.Center, _Theme.NameStyle, - _Theme.NameFont, _Theme.NameColor, ""); + var rect = new SRectF(Rect.X + j * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, Rect.Z); + var tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, ColorEmptyTile, rect) {Aspect = EAspect.Crop}; + var tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.NameSpace, rect.Z, _Theme.NameHeight, rect.W, EAlignment.Center, _Theme.NameStyle, + _Theme.NameFont, _Theme.NameColor, ""); _Tiles.Add(new CTile(tileStatic, tileText, -1)); } } @@ -501,21 +501,21 @@ namespace VocaluxeLib.Menu _VisibleProfiles.Clear(); CProfile[] profiles = CBase.Profiles.GetProfiles(); - for (int i = 0; i < profiles.Length; i++) + foreach (CProfile profile in profiles) { - bool visible = profiles[i].Active == EOffOn.TR_CONFIG_ON; + bool visible = profile.Active == EOffOn.TR_CONFIG_ON; if (visible) { //Show profile only if active for (int p = 0; p < CBase.Game.GetNumPlayer(); p++) { //Don't show profile if is selected, but if selected and guest - if (CBase.Game.GetPlayers()[p].ProfileID == profiles[i].ID && profiles[i].GuestProfile == EOffOn.TR_CONFIG_OFF) + if (CBase.Game.GetPlayers()[p].ProfileID == profile.ID && profile.GuestProfile == EOffOn.TR_CONFIG_OFF) visible = false; } } if (visible) - _VisibleProfiles.Add(profiles[i].ID); + _VisibleProfiles.Add(profile.ID); } } diff --git a/VocaluxeLib/Menu/CStatic.cs b/VocaluxeLib/Menu/CStatic.cs index 3d0678be..b40d4f99 100644 --- a/VocaluxeLib/Menu/CStatic.cs +++ b/VocaluxeLib/Menu/CStatic.cs @@ -205,11 +205,9 @@ namespace VocaluxeLib.Menu public void Draw(float scale, float z, EAspect aspect, bool forceDraw = false) { - CTexture texture = Texture; - if (texture == null) - texture = new CTexture((int)Rect.W, (int)Rect.H); + CTexture texture = Texture ?? new CTexture((int)Rect.W, (int)Rect.H); - SRectF bounds = new SRectF( + var bounds = new SRectF( Rect.X - Rect.W * (scale - 1f), Rect.Y - Rect.H * (scale - 1f), Rect.W + 2 * Rect.W * (scale - 1f), @@ -220,7 +218,7 @@ namespace VocaluxeLib.Menu if (aspect != EAspect.Stretch) { - RectangleF bounds2 = new RectangleF(bounds.X, bounds.Y, bounds.W, bounds.H); + var bounds2 = new RectangleF(bounds.X, bounds.Y, bounds.W, bounds.H); RectangleF rect2; CHelper.SetRect(bounds2, out rect2, texture.OrigAspect, aspect); @@ -230,7 +228,7 @@ namespace VocaluxeLib.Menu rect.H = rect2.Height; } - SColorF color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha); + var color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha); if (Visible || forceDraw || (CBase.Settings.GetGameState() == EGameState.EditTheme)) { CBase.Drawing.DrawTexture(texture, rect, color, bounds); diff --git a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs index 01846d46..b0331890 100644 --- a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs @@ -33,7 +33,7 @@ namespace VocaluxeLib.Menu.SingNotes public SRectF Rect; public SColorF Color; public float Alpha; - public CLine[] Lines; + public CSongLine[] Lines; public int LineNr; public Stopwatch Timer; public List GoldenStars; @@ -205,7 +205,7 @@ namespace VocaluxeLib.Menu.SingNotes public int AddPlayer(SRectF rect, SColorF color, int playerNr) { - SPlayerNotes notes = new SPlayerNotes + var notes = new SPlayerNotes { Rect = rect, Color = color, @@ -226,7 +226,7 @@ namespace VocaluxeLib.Menu.SingNotes return notes.ID; } - public void SetLines(int id, CLine[] lines, int lineNr) + public void SetLines(int id, CSongLine[] lines, int lineNr) { if (lines == null) return; @@ -278,7 +278,7 @@ namespace VocaluxeLib.Menu.SingNotes Draw(id, null, player); } - public void Draw(int id, List singLines, int player) + public void Draw(int id, List sungLines, int player) { int n = _FindPlayerNotes(id); if (n == -1) @@ -293,7 +293,7 @@ namespace VocaluxeLib.Menu.SingNotes if (_PlayerNotes[n].Lines.Length <= _PlayerNotes[n].LineNr) return; - CLine line = _PlayerNotes[n].Lines[_PlayerNotes[n].LineNr]; + CSongLine line = _PlayerNotes[n].Lines[_PlayerNotes[n].LineNr]; if (CBase.Config.GetDrawNoteLines() == EOffOn.TR_CONFIG_ON) _DrawNoteLines(_PlayerNotes[n].Rect, new SColorF(0.5f, 0.5f, 0.5f, 0.5f * _PlayerNotes[n].Alpha)); @@ -311,7 +311,7 @@ namespace VocaluxeLib.Menu.SingNotes if (beats < 1) return; - SColorF color = new SColorF( + var color = new SColorF( _PlayerNotes[n].Color.R, _PlayerNotes[n].Color.G, _PlayerNotes[n].Color.B, @@ -319,13 +319,13 @@ namespace VocaluxeLib.Menu.SingNotes float baseLine = line.BaseLine; int nr = 1; - foreach (CNote note in line.Notes) + foreach (CSongNote note in line.Notes) { if (note.NoteType != ENoteType.Freestyle) { float width = note.Duration / beats * w; - SRectF rect = new SRectF( + var rect = new SRectF( _PlayerNotes[n].Rect.X + (note.StartBeat - line.FirstNoteBeat) / beats * w, _PlayerNotes[n].Rect.Y + (CBase.Settings.GetNumNoteLines() - 1 - (note.Tone - baseLine) / 2) / CBase.Settings.GetNumNoteLines() * h - dh, width, @@ -359,7 +359,7 @@ namespace VocaluxeLib.Menu.SingNotes foreach (CParticleEffect perfline in _PlayerNotes[n].PerfectLineTwinkle) perfline.Draw(); - if (singLines == null || singLines.Count == 0 || CBase.Game.GetPlayers()[player].CurrentLine == -1 || singLines.Count <= CBase.Game.GetPlayers()[player].CurrentLine) + if (sungLines == null || sungLines.Count == 0 || CBase.Game.GetPlayers()[player].CurrentLine == -1 || sungLines.Count <= CBase.Game.GetPlayers()[player].CurrentLine) { foreach (CParticleEffect stars in _PlayerNotes[n].GoldenStars) { @@ -369,48 +369,45 @@ namespace VocaluxeLib.Menu.SingNotes return; } - foreach (CNote note in singLines[CBase.Game.GetPlayers()[player].CurrentLine].Notes) + foreach (CSungNote note in sungLines[CBase.Game.GetPlayers()[player].CurrentLine].Notes) { - if (note.StartBeat >= line.FirstNoteBeat && note.EndBeat <= line.LastNoteBeat) + float width = note.Duration / beats * w; + + if (note.EndBeat == CBase.Game.GetCurrentBeatD()) + width -= (1 - (CBase.Game.GetMidBeatD() - CBase.Game.GetCurrentBeatD())) / beats * w; + + var rect = new SRectF( + _PlayerNotes[n].Rect.X + (note.StartBeat - line.FirstNoteBeat) / beats * w, + _PlayerNotes[n].Rect.Y + (CBase.Settings.GetNumNoteLines() - 1 - (note.Tone - baseLine) / 2) / CBase.Settings.GetNumNoteLines() * h - dh, + width, + h / CBase.Settings.GetNumNoteLines() + 2 * dh, + _PlayerNotes[n].Rect.Z + ); + + float f = (note.Hit) ? 0.7f : 0.4f; + + _DrawNote(rect, color, f); + + if (note.EndBeat >= CBase.Game.GetCurrentBeatD() && note.Hit && note.HitNote.NoteType == ENoteType.Golden) { - float width = note.Duration / beats * w; + var re = new SRectF(rect) {W = (CBase.Game.GetMidBeatD() - note.StartBeat) / beats * w}; + _AddFlare(re, n); + } - if (note.EndBeat == CBase.Game.GetCurrentBeatD()) - width -= (1 - (CBase.Game.GetMidBeatD() - CBase.Game.GetCurrentBeatD())) / beats * w; - - SRectF rect = new SRectF( - _PlayerNotes[n].Rect.X + (note.StartBeat - line.FirstNoteBeat) / beats * w, - _PlayerNotes[n].Rect.Y + (CBase.Settings.GetNumNoteLines() - 1 - (note.Tone - baseLine) / 2) / CBase.Settings.GetNumNoteLines() * h - dh, - width, - h / CBase.Settings.GetNumNoteLines() + 2 * dh, - _PlayerNotes[n].Rect.Z - ); - - float f = (note.Hit) ? 0.7f : 0.4f; - - _DrawNote(rect, color, f); - - if (note.EndBeat >= CBase.Game.GetCurrentBeatD() && note.Hit && note.NoteType == ENoteType.Golden) - { - SRectF re = new SRectF(rect) {W = (CBase.Game.GetMidBeatD() - note.StartBeat) / beats * w}; - _AddFlare(re, n); - } - - if (note.Perfect && note.EndBeat < CBase.Game.GetCurrentBeatD()) - { - _AddPerfectNote(rect, n); - note.Perfect = false; - } + if (note.Perfect && note.EndBeat < CBase.Game.GetCurrentBeatD()) + { + _AddPerfectNote(rect, n); + note.Perfect = false; } } - int currentLine = CBase.Game.GetPlayers()[player].SingLine.Count - 1; + int currentLine = CBase.Game.GetPlayers()[player].SungLines.Count - 1; if (currentLine > 0) { - if (CBase.Game.GetPlayers()[player].SingLine[currentLine - 1].PerfectLine) + if (CBase.Game.GetPlayers()[player].SungLines[currentLine - 1].PerfectLine) { _AddPerfectLine(n); - CBase.Game.GetPlayers()[player].SingLine[currentLine - 1].PerfectLine = false; + CBase.Game.GetPlayers()[player].SungLines[currentLine - 1].PerfectLine = false; } } @@ -475,7 +472,7 @@ namespace VocaluxeLib.Menu.SingNotes float dh = (1f - factor) * rect.H / 2; float dw = Math.Min(dh, rect.W / 2); - SRectF noteRect = new SRectF(rect.X + dw, rect.Y + dh, rect.W - 2 * dw, rect.H - 2 * dh, rect.Z); + var noteRect = new SRectF(rect.X + dw, rect.Y + dh, rect.W - 2 * dw, rect.H - 2 * dh, rect.Z); CTexture noteBegin = CBase.Theme.GetSkinTexture(_Theme.SkinLeftName, _PartyModeID); CTexture noteMiddle = CBase.Theme.GetSkinTexture(_Theme.SkinMiddleName, _PartyModeID); @@ -487,7 +484,7 @@ namespace VocaluxeLib.Menu.SingNotes CBase.Drawing.DrawTexture(noteBegin, new SRectF(noteRect.X, noteRect.Y, endsW, noteRect.H, noteRect.Z), color); - SRectF middleRect = new SRectF(noteRect.X + endsW, noteRect.Y, noteRect.W - 2 * endsW, noteRect.H, noteRect.Z); + var middleRect = new SRectF(noteRect.X + endsW, noteRect.Y, noteRect.W - 2 * endsW, noteRect.H, noteRect.Z); if (noteRect.W >= 4 * endsW) CBase.Drawing.DrawTexture(noteMiddle, middleRect, color); else @@ -516,7 +513,7 @@ namespace VocaluxeLib.Menu.SingNotes if (2 * dw > rect.W) dw = rect.W / 2; - SRectF r = new SRectF( + var r = new SRectF( rect.X + dw + spacing, rect.Y + d + spacing, rect.W - 2 * dw - 2 * spacing, @@ -532,7 +529,7 @@ namespace VocaluxeLib.Menu.SingNotes if (2 * dx > r.W) dx = r.W / 2; - SColorF col = new SColorF(color.R, color.G, color.B, color.A * alpha); + var col = new SColorF(color.R, color.G, color.B, color.A * alpha); CBase.Drawing.DrawTexture(noteBackgroundBegin, new SRectF(r.X, r.Y, dx, r.H, r.Z), col); @@ -565,7 +562,7 @@ namespace VocaluxeLib.Menu.SingNotes if (2 * dw > rect.W) dw = rect.W / 2; - SRectF r = new SRectF( + var r = new SRectF( rect.X + dw + spacing, rect.Y + d + spacing, rect.W - 2 * dw - 2 * spacing, @@ -573,8 +570,8 @@ namespace VocaluxeLib.Menu.SingNotes rect.Z ); - int numstars = (int)(r.W * 0.25f); - CParticleEffect stars = new CParticleEffect(_PartyModeID, numstars, new SColorF(1f, 1f, 0f, 1f), r, _Theme.SkinGoldenStarName, 20, EParticleType.Star); + var numstars = (int)(r.W * 0.25f); + var stars = new CParticleEffect(_PartyModeID, numstars, new SColorF(1f, 1f, 0f, 1f), r, _Theme.SkinGoldenStarName, 20, EParticleType.Star); _PlayerNotes[n].GoldenStars.Add(stars); } } @@ -589,7 +586,7 @@ namespace VocaluxeLib.Menu.SingNotes if (2 * dw > rect.W) dw = rect.W / 2; - SRectF r = new SRectF( + var r = new SRectF( rect.X + dw + spacing + rect.W - 2 * dw - 2 * spacing, rect.Y + d + spacing, 0f, @@ -597,7 +594,7 @@ namespace VocaluxeLib.Menu.SingNotes rect.Z ); - CParticleEffect flares = new CParticleEffect(_PartyModeID, 15, new SColorF(1f, 1f, 1f, 1f), r, _Theme.SkinGoldenStarName, 20, EParticleType.Flare); + var flares = new CParticleEffect(_PartyModeID, 15, new SColorF(1f, 1f, 1f, 1f), r, _Theme.SkinGoldenStarName, 20, EParticleType.Flare); _PlayerNotes[n].Flares.Add(flares); } @@ -611,7 +608,7 @@ namespace VocaluxeLib.Menu.SingNotes if (2 * dw > rect.W) dw = rect.W / 2; - SRectF r = new SRectF( + var r = new SRectF( rect.X + dw + spacing, rect.Y + d + spacing, rect.W - 2 * dw - 2 * spacing, @@ -632,14 +629,14 @@ namespace VocaluxeLib.Menu.SingNotes rect.Z ); - CParticleEffect stars = new CParticleEffect(_PartyModeID, CBase.Game.GetRandom(2) + 1, new SColorF(1f, 1f, 1f, 1f), r, _Theme.SkinPerfectNoteStarName, 35, - EParticleType.PerfNoteStar); + var stars = new CParticleEffect(_PartyModeID, CBase.Game.GetRandom(2) + 1, new SColorF(1f, 1f, 1f, 1f), r, _Theme.SkinPerfectNoteStarName, 35, + EParticleType.PerfNoteStar); _PlayerNotes[n].PerfectNoteEffect.Add(stars); } private void _AddPerfectLine(int n) { - CParticleEffect twinkle = new CParticleEffect(_PartyModeID, 200, _PlayerNotes[n].Color, _PlayerNotes[n].Rect, _Theme.SkinGoldenStarName, 25, EParticleType.Twinkle); + var twinkle = new CParticleEffect(_PartyModeID, 200, _PlayerNotes[n].Color, _PlayerNotes[n].Rect, _Theme.SkinGoldenStarName, 25, EParticleType.Twinkle); _PlayerNotes[n].PerfectLineTwinkle.Add(twinkle); } @@ -662,7 +659,7 @@ namespace VocaluxeLib.Menu.SingNotes offsetX = noteBounds.W; float dy = noteBounds.H / CBase.Settings.GetNumNoteLines(); - SRectF drawRect = new SRectF( + var drawRect = new SRectF( noteBounds.X - dy + offsetX, noteBounds.Y + dy * (CBase.Settings.GetNumNoteLines() - 1 - (tonePlayer - baseLine) / 2f), dy, @@ -670,7 +667,7 @@ namespace VocaluxeLib.Menu.SingNotes noteBounds.Z ); - SColorF color = new SColorF( + var color = new SColorF( _PlayerNotes[n].Color.R, _PlayerNotes[n].Color.G, _PlayerNotes[n].Color.B, diff --git a/VocaluxeLib/Songs/CBaseNote.cs b/VocaluxeLib/Songs/CBaseNote.cs new file mode 100644 index 00000000..a3a5691f --- /dev/null +++ b/VocaluxeLib/Songs/CBaseNote.cs @@ -0,0 +1,63 @@ +namespace VocaluxeLib.Songs +{ + /// + /// Base class for all note types + /// + public abstract class CBaseNote + { + private int _Duration = 1; + private int _Tone; + + #region Contructors + protected CBaseNote(CBaseNote note) + { + StartBeat = note.StartBeat; + _Duration = note._Duration; + _Tone = note._Tone; + } + + protected CBaseNote(int startBeat, int duration, int tone) + { + StartBeat = startBeat; + Duration = duration; + Tone = tone; + } + #endregion Constructors + + #region Properties + public int StartBeat { get; set; } + + public int EndBeat + { + get { return StartBeat + _Duration - 1; } + } + + public int Duration + { + get { return _Duration; } + set + { + if (value > 0) + _Duration = value; + } + } + + public int Tone + { + get { return _Tone; } + set + { + if ((value >= CBase.Settings.GetToneMin()) && (value <= CBase.Settings.GetToneMax())) + _Tone = value; + } + } + + public int Points + { + get { return PointsForBeat * Duration; } + } + + public abstract int PointsForBeat { get; } + #endregion Properties + } +} \ No newline at end of file diff --git a/VocaluxeLib/Songs/CLineBase.cs b/VocaluxeLib/Songs/CLineBase.cs new file mode 100644 index 00000000..f2d700fe --- /dev/null +++ b/VocaluxeLib/Songs/CLineBase.cs @@ -0,0 +1,135 @@ +using System.Collections.Generic; +using System.Linq; + +namespace VocaluxeLib.Songs +{ + public class CLineBase where T : CBaseNote + { + protected readonly List _Notes = new List(); + + #region Properties + public int FirstNoteBeat + { + get { return (_Notes.Count == 0) ? int.MaxValue : _Notes[0].StartBeat; } + } + + public int LastNoteBeat + { + get { return (_Notes.Count == 0) ? int.MinValue : _Notes[_Notes.Count - 1].EndBeat; } + } + + public int NoteCount + { + get { return _Notes.Count; } + } + + public T[] Notes + { + get { return _Notes.ToArray(); } + } + + public T FirstNote + { + get { return _Notes.Count > 0 ? _Notes[0] : null; } + } + + public T LastNote + { + get { return _Notes.Count > 0 ? _Notes[_Notes.Count - 1] : null; } + } + + public int Points + { + get { return _Notes.Sum(note => note.Points); } + } + public int BaseLine + { + get + { + int min = int.MaxValue; + int max = int.MinValue; + foreach (T note in _Notes) + { + if (note.Tone < min) + min = note.Tone; + if (note.Tone > max) + max = note.Tone; + } + + return min - (max - min) / 4; + } + } + #endregion Properties + + #region Methods + //Find last note with StartBeat<=Beat + public int FindPreviousNote(int beat) + { + //If no notes -> No previous note + if (_Notes.Count == 0) + return -1; + int start = 0; + int end = _Notes.Count - 1; + //Ensure that start.StartBeat<=Beat && end.StartBeat>Beat + if (_Notes[0].StartBeat > beat) + return -1; + if (_Notes[end].StartBeat <= beat) + return end; + //Binary search + while (end - start > 1) + { + int mid = (start + end) / 2; + if (_Notes[mid].StartBeat <= beat) + start = mid; + else + end = mid; + } + return start; + } + + public virtual bool AddNote(T note) + { + if (_Notes.Count == 0) + _Notes.Add(note); + else + { + int insPos = FindPreviousNote(note.StartBeat); + _Notes.Insert(insPos + 1, note); + } + return true; + } + + public bool DeleteNote(int index) + { + if (_Notes.Count > index) + { + _Notes.RemoveAt(index); + return true; + } + return false; + } + + public bool ReplaceNote(int index, T note) + { + if (_Notes.Count > index) + { + _Notes.RemoveAt(index); + return AddNote(note); + } + return false; + } + + public bool IncLastNoteLength() + { + if (_Notes.Count > 0) + _Notes[_Notes.Count - 1].Duration++; + return false; + } + + public void DeleteAllNotes() + { + _Notes.Clear(); + } + #endregion Methods + } +} \ No newline at end of file diff --git a/VocaluxeLib/Songs/CNotes.cs b/VocaluxeLib/Songs/CNotes.cs index 4f6fc017..709c2715 100644 --- a/VocaluxeLib/Songs/CNotes.cs +++ b/VocaluxeLib/Songs/CNotes.cs @@ -17,9 +17,7 @@ // */ #endregion -using System; using System.Collections.Generic; -using System.Linq; namespace VocaluxeLib.Songs { @@ -94,629 +92,4 @@ namespace VocaluxeLib.Songs voice.SetMedley(startBeat, endBeat); } } - - public class CNote - { - private int _StartBeat; - private int _Duration; - private int _Tone; - private ENoteType _NoteType; - private string _Text; - private bool _Hit; // for drawing player notes - private bool _Perfect; // for drawing perfect note effect - - #region Contructors - public CNote() - { - StartBeat = 0; - Duration = 1; - Tone = 0; - NoteType = ENoteType.Normal; - Text = String.Empty; - _Hit = false; - _Perfect = false; - } - - public CNote(CNote note) - { - _StartBeat = note._StartBeat; - _Duration = note._Duration; - _Tone = note._Tone; - _NoteType = note._NoteType; - _Text = note._Text; - _Hit = note._Hit; - _Perfect = note._Perfect; - } - - public CNote(int startBeat, int duration, int tone, string text) - : this() - { - StartBeat = startBeat; - Duration = duration; - Tone = tone; - NoteType = ENoteType.Normal; - Text = text; - } - - public CNote(int startBeat, int duration, int tone, string text, bool hit) - : this() - { - StartBeat = startBeat; - Duration = duration; - Tone = tone; - NoteType = ENoteType.Normal; - Text = text; - Hit = hit; - } - - public CNote(int startBeat, int duration, int tone, string text, ENoteType noteType) - : this(startBeat, duration, tone, text) - { - NoteType = noteType; - } - - public CNote(int startBeat, int duration, int tone, string text, bool hit, ENoteType noteType) - : this(startBeat, duration, tone, text) - { - NoteType = noteType; - Hit = hit; - } - #endregion Constructors - - #region Properties - public bool Hit - { - get { return _Hit; } - set { _Hit = value; } - } - - public bool Perfect - { - get { return _Perfect; } - set { _Perfect = value; } - } - - public int StartBeat - { - get { return _StartBeat; } - set { _StartBeat = value; } - } - - public int EndBeat - { - get { return _StartBeat + _Duration - 1; } - } - - public int Duration - { - get { return _Duration; } - set - { - if (value > 0) - _Duration = value; - } - } - - public int Tone - { - get { return _Tone; } - set - { - if ((value >= CBase.Settings.GetToneMin()) && (value <= CBase.Settings.GetToneMax())) - _Tone = value; - } - } - - public ENoteType NoteType - { - get { return _NoteType; } - set { _NoteType = value; } - } - - public string Text - { - get { return _Text; } - set { _Text = value; } - } - - public int Points - { - get - { - switch (_NoteType) - { - case ENoteType.Normal: - return _Duration; - case ENoteType.Golden: - return _Duration * 2; - case ENoteType.Freestyle: - return 0; - default: - return 0; - } - } - } - - public int PointsForBeat - { - get - { - switch (_NoteType) - { - case ENoteType.Normal: - return 1; - case ENoteType.Golden: - return 2; - case ENoteType.Freestyle: - return 0; - default: - return 0; - } - } - } - #endregion Properties - - #region Methods - public bool IsPerfect(CNote compareNote) - { - bool result = Hit; - - if (StartBeat != compareNote.StartBeat) - result = false; - - if (EndBeat != compareNote.EndBeat) - result = false; - - if (Tone != compareNote.Tone) - result = false; - - Perfect = result; - return result; - } - #endregion Methods - } - - public class CLine - { - private int _StartBeat = int.MinValue; - private int _EndBeat = int.MinValue; - private bool _PerfectLine; // for drawing perfect line effect - private bool _VisibleInTimeLine = true; - - private int _MinBeat = int.MaxValue; - private int _MaxBeat = int.MinValue; - private readonly List _Notes = new List(); - - #region Constructors - public CLine() {} - - public CLine(CLine line) - { - foreach (CNote note in line._Notes) - _Notes.Add(new CNote(note)); - _StartBeat = line._StartBeat; - _EndBeat = line._EndBeat; - _PerfectLine = line._PerfectLine; - _MinBeat = line._MinBeat; - _MaxBeat = line._MaxBeat; - _VisibleInTimeLine = line._VisibleInTimeLine; - } - #endregion Constructors - - #region Properties - public bool VisibleInTimeLine - { - get { return _VisibleInTimeLine; } - set { _VisibleInTimeLine = value; } - } - - public int StartBeat - { - get { return _StartBeat; } - set - { - if (value <= _MinBeat) - _StartBeat = value; - } - } - - public int EndBeat - { - get { return _EndBeat; } - set - { - if (value >= _MaxBeat) - _EndBeat = value; - } - } - - public bool PerfectLine - { - get { return _PerfectLine; } - set { _PerfectLine = value; } - } - - public int FirstNoteBeat - { - get { return _MinBeat; } - } - - public int LastNoteBeat - { - get { return _MaxBeat; } - } - - public string Lyrics - { - get { return _Notes.Aggregate(String.Empty, (current, note) => current + note.Text); } - } - - public int NoteCount - { - get { return _Notes.Count; } - } - - public int Points - { - get { return _Notes.Sum(note => note.Points); } - } - - public CNote[] Notes - { - get { return _Notes.ToArray(); } - } - - public CNote FirstNote - { - get { return _Notes.Count > 0 ? _Notes[0] : null; } - } - - public CNote LastNote - { - get { return _Notes.Count > 0 ? _Notes[_Notes.Count - 1] : null; } - } - - public int BaseLine - { - get - { - int min = int.MaxValue; - int max = int.MinValue; - foreach (CNote note in _Notes) - { - if (note.Tone < min) - min = note.Tone; - if (note.Tone > max) - max = note.Tone; - } - - return min - (max - min) / 4; - } - } - #endregion Properties - - #region Methods - public bool IsPerfect(CLine compareLine) - { - if (_Notes.Count == 0) - return false; - - if (_Notes.Count != compareLine.NoteCount) - return false; - - if (compareLine.Points == 0) - return false; - - _PerfectLine = Points == compareLine.Points; - return _PerfectLine; - } - - //Find last note with StartBeat<=Beat - public int FindPreviousNote(int beat) - { - //If no notes -> No previous note - if (_Notes.Count == 0) - return -1; - int start = 0; - int end = _Notes.Count - 1; - //Ensure that start.StartBeat<=Beat && end.StartBeat>Beat - if (_Notes[0].StartBeat > beat) - return -1; - if (_Notes[end].StartBeat <= beat) - return end; - //Binary search - while (end - start > 1) - { - int mid = (start + end) / 2; - if (_Notes[mid].StartBeat <= beat) - start = mid; - else - end = mid; - } - return start; - } - - public bool AddNote(CNote note) - { - if (_Notes.Count == 0) - _Notes.Add(note); - else - { - int insPos = FindPreviousNote(note.StartBeat); - //Flamefire: May be a performance hit as notes are also used for sung notes - //But for song loading this might be very helpful! - //Check for overlapping notes - /*if (insPos >= 0 && _Notes[insPos].EndBeat > Note.StartBeat) - return false; - if (insPos < _Notes.Count - 1 && _Notes[insPos+1].StartBeat > Note.EndBeat) - return false; - * */ - _Notes.Insert(insPos + 1, note); - } - _UpdateMinMaxBeat(note); - return true; - } - - public bool DeleteNote(int index) - { - if (_Notes.Count > index) - { - _Notes.RemoveAt(index); - if (index == 0 || index == _Notes.Count - 1) - _UpdateMinMaxBeat(); - return true; - } - return false; - } - - public bool ReplaceNote(int index, CNote note) - { - if (_Notes.Count > index) - { - _Notes.RemoveAt(index); - return AddNote(note); - } - return false; - } - - public bool IncLastNoteLength() - { - if (_Notes.Count > 0) - { - _Notes[_Notes.Count - 1].Duration++; - _MaxBeat++; - } - return false; - } - - public void DeleteAllNotes() - { - _Notes.Clear(); - _UpdateMinMaxBeat(); - } - - public void SetMedley(int startBeat, int endBeat) - { - foreach (CNote note in _Notes) - { - if (note.StartBeat < startBeat || note.EndBeat > endBeat) - note.NoteType = ENoteType.Freestyle; - } - - _VisibleInTimeLine = _MinBeat >= startBeat && _MaxBeat <= endBeat; - } - - private void _UpdateMinMaxBeat(CNote note) - { - if (note.StartBeat < _MinBeat) - _MinBeat = note.StartBeat; - - if (note.EndBeat > _MaxBeat) - _MaxBeat = note.EndBeat; - } - - private void _UpdateMinMaxBeat() - { - if (_Notes.Count > 0) - { - _MinBeat = _Notes[0].StartBeat; - _MaxBeat = _Notes[_Notes.Count - 1].EndBeat; - } - else - { - _MinBeat = int.MaxValue; - _MaxBeat = int.MinValue; - } - } - #endregion Methods - } - - public class CVoice - { - private readonly List _Lines = new List(); - - public CVoice() {} - - public CVoice(CVoice voice) - { - foreach (CLine line in voice._Lines) - _Lines.Add(new CLine(line)); - } - - public CLine[] Lines - { - get { return _Lines.ToArray(); } - } - public int NumLines - { - get { return _Lines.Count; } - } - - /// - /// Total song length in beats - /// - public int Length - { - get - { - if (_Lines.Count == 0) - return 0; - - int startbeat = _Lines.Max(line => line.FirstNoteBeat); - int endbeat = _Lines.Min(line => line.LastNoteBeat); - - int result = endbeat - startbeat; - return result > 0 ? result : 0; - } - } - - public int Points - { - get { return _Lines.Sum(line => line.Points); } - } - - public int NumLinesWithPoints - { - get { return _Lines.Count(line => line.Points > 0f); } - } - - #region Methods - //Find last line with StartBeat<=Beat - public int FindPreviousLine(int beat) - { - //If no line -> No previous line - if (_Lines.Count == 0) - return -1; - int start = 0; - int end = _Lines.Count - 1; - //Ensure that start.StartBeat<=Beat && end.StartBeat>Beat - if (_Lines[0].StartBeat > beat) - return -1; - if (_Lines[end].StartBeat <= beat) - return end; - //Binary search - while (end - start > 1) - { - int mid = (start + end) / 2; - if (_Lines[mid].StartBeat <= beat) - start = mid; - else - end = mid; - } - return start; - } - - public void AddLine(CLine line) - { - if (_Lines.Count == 0) - _Lines.Add(line); - else - { - int insPos = FindPreviousLine(line.StartBeat); - _Lines.Insert(insPos + 1, line); - } - } - - public bool DeleteLine(int index) - { - if (_Lines.Count > index) - { - _Lines.RemoveAt(index); - UpdateTimings(); - return true; - } - return false; - } - - public void DeleteAllLines() - { - _Lines.Clear(); - } - - public bool AddNote(CNote note, bool updateTimings = false) - { - int lineIndex = FindPreviousLine(note.StartBeat); - if (lineIndex < 0) - { - //Note is before ALL lines - CLine line = new CLine {StartBeat = note.StartBeat}; - line.AddNote(note); - _Lines.Insert(0, line); - } - else - { - if (!_Lines[lineIndex].AddNote(note)) - return false; - } - if (updateTimings) - UpdateTimings(); - return true; - } - - public bool InsertNote(CNote note, int lineIndex, bool updateTimings = false) - { - if (_Lines.Count > lineIndex && _Lines[lineIndex].StartBeat <= note.StartBeat) - { - _Lines[lineIndex].AddNote(note); - if (updateTimings) - UpdateTimings(); - return true; - } - return false; - } - - public void UpdateTimings() - { - CNote lastNote; - - if (_Lines.Count > 0) - _Lines[0].StartBeat = -10000; - - for (int i = 1; i < _Lines.Count; i++) - { - lastNote = _Lines[i - 1].LastNote; - CNote firstNote = _Lines[i].FirstNote; - - if ((lastNote != null) && (firstNote != null)) - { - int min = lastNote.EndBeat; - int max = firstNote.StartBeat; - - int s; - switch (max - min) - { - case 0: - s = max; - break; - case 1: - s = max; - break; - case 2: - s = max - 1; - break; - case 3: - s = max - 2; - break; - default: - s = min + 2; - break; - } - - _Lines[i].StartBeat = s; - _Lines[i - 1].EndBeat = min; - } - } - - lastNote = _Lines[_Lines.Count - 1].LastNote; - if (lastNote != null) - _Lines[_Lines.Count - 1].EndBeat = lastNote.EndBeat; - } - - public void SetMedley(int startBeat, int endBeat) - { - foreach (CLine line in _Lines) - line.SetMedley(startBeat, endBeat); - } - #endregion Methods - } } \ No newline at end of file diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index adf7f34d..7b76f94b 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -725,7 +725,7 @@ namespace VocaluxeLib.Songs private bool _ParseNote(int player, ENoteType noteType, int start, int length, int tone, string text) { - CNote note = new CNote(start, length, tone, text, noteType); + CSongNote note = new CSongNote(start, length, tone, text, noteType); CVoice voice = Notes.GetVoice(player); return voice.AddNote(note); } @@ -733,7 +733,7 @@ namespace VocaluxeLib.Songs private void _NewSentence(int player, int start) { CVoice voice = Notes.GetVoice(player); - CLine line = new CLine {StartBeat = start}; + CSongLine line = new CSongLine {StartBeat = start}; voice.AddLine(line); } @@ -933,7 +933,7 @@ namespace VocaluxeLib.Songs } //Check if stop is in line - foreach (CLine line in voice.Lines) + foreach (CSongLine line in voice.Lines) { if (line.FirstNoteBeat < stop && line.LastNoteBeat > stop) { diff --git a/VocaluxeLib/Songs/CSongLine.cs b/VocaluxeLib/Songs/CSongLine.cs new file mode 100644 index 00000000..54f713d9 --- /dev/null +++ b/VocaluxeLib/Songs/CSongLine.cs @@ -0,0 +1,86 @@ +using System; +using System.Linq; + +namespace VocaluxeLib.Songs +{ + public class CSongLine : CLineBase + { + private int _StartBeat = int.MinValue; + private int _EndBeat = int.MinValue; + + #region Constructors + public CSongLine() + { + VisibleInTimeLine = true; + } + + public CSongLine(CSongLine line) + { + foreach (CSongNote note in line._Notes) + _Notes.Add(new CSongNote(note)); + _StartBeat = line._StartBeat; + _EndBeat = line._EndBeat; + VisibleInTimeLine = line.VisibleInTimeLine; + } + #endregion Constructors + + #region Properties + public bool VisibleInTimeLine { get; set; } + + public int StartBeat + { + get { return _StartBeat; } + set + { + if (value <= FirstNoteBeat) + _StartBeat = value; + } + } + + public int EndBeat + { + get { return _EndBeat; } + set + { + if (value >= LastNoteBeat) + _EndBeat = value; + } + } + + public string Lyrics + { + get { return _Notes.Aggregate(String.Empty, (current, note) => current + note.Text); } + } + #endregion Properties + + #region Methods + public override bool AddNote(CSongNote note) + { + if (_Notes.Count == 0) + _Notes.Add(note); + else + { + int insPos = FindPreviousNote(note.StartBeat); + //Check for overlapping notes + if (insPos >= 0 && _Notes[insPos].EndBeat > note.StartBeat) + return false; + if (insPos < _Notes.Count - 1 && _Notes[insPos + 1].StartBeat > note.EndBeat) + return false; + _Notes.Insert(insPos + 1, note); + } + return true; + } + + public void SetMedley(int startBeat, int endBeat) + { + foreach (CSongNote note in _Notes) + { + if (note.StartBeat < startBeat || note.EndBeat > endBeat) + note.NoteType = ENoteType.Freestyle; + } + + VisibleInTimeLine = FirstNoteBeat >= startBeat && LastNoteBeat <= endBeat; + } + #endregion Methods + } +} \ No newline at end of file diff --git a/VocaluxeLib/Songs/CSongNote.cs b/VocaluxeLib/Songs/CSongNote.cs new file mode 100644 index 00000000..7619cbfd --- /dev/null +++ b/VocaluxeLib/Songs/CSongNote.cs @@ -0,0 +1,52 @@ +namespace VocaluxeLib.Songs +{ + /// + /// Class to represent a note in a song + /// + public class CSongNote : CBaseNote + { + #region Contructors + public CSongNote(CSongNote note) : base(note) + { + NoteType = note.NoteType; + Text = note.Text; + } + + public CSongNote(int startBeat, int duration, int tone, string text) : base(startBeat, duration, tone) + { + NoteType = ENoteType.Normal; + Text = text; + } + + public CSongNote(int startBeat, int duration, int tone, string text, ENoteType noteType) + : this(startBeat, duration, tone, text) + { + NoteType = noteType; + } + #endregion Constructors + + #region Properties + public ENoteType NoteType { get; set; } + + public string Text { get; set; } + + public override int PointsForBeat + { + get + { + switch (NoteType) + { + case ENoteType.Normal: + return 1; + case ENoteType.Golden: + return 2; + case ENoteType.Freestyle: + return 0; + default: + return 0; + } + } + } + #endregion Properties + } +} \ No newline at end of file diff --git a/VocaluxeLib/Songs/CSungLine.cs b/VocaluxeLib/Songs/CSungLine.cs new file mode 100644 index 00000000..bb06c393 --- /dev/null +++ b/VocaluxeLib/Songs/CSungLine.cs @@ -0,0 +1,18 @@ +using System.Linq; + +namespace VocaluxeLib.Songs +{ + public class CSungLine : CLineBase + { + // for drawing perfect line effect + public bool PerfectLine { get; set; } + + public bool IsPerfect(CSongLine compareLine) + { + PerfectLine = _Notes.Count > 0; + PerfectLine &= _Notes.Count == compareLine.NoteCount; + PerfectLine &= _Notes.All(note => note.Perfect); + return PerfectLine; + } + } +} \ No newline at end of file diff --git a/VocaluxeLib/Songs/CSungNote.cs b/VocaluxeLib/Songs/CSungNote.cs new file mode 100644 index 00000000..976910bd --- /dev/null +++ b/VocaluxeLib/Songs/CSungNote.cs @@ -0,0 +1,63 @@ +namespace VocaluxeLib.Songs +{ + /// + /// Note that was sung by a player + /// + public class CSungNote : CBaseNote + { + /// + /// Constructor for a sung note that was not hit + /// + /// + /// + /// + public CSungNote(int startBeat, int duration, int tone) : base(startBeat, duration, tone) + { + Perfect = false; + HitNote = null; + } + + /// + /// Constructor for a sung note that hit the given note + /// + /// + /// + /// + /// + public CSungNote(int startBeat, int duration, int tone, CSongNote hitNote) : this(startBeat, duration, tone) + { + HitNote = hitNote; + } + + #region Properties + // for drawing player notes + public bool Hit + { + get { return HitNote != null; } + } + public CSongNote HitNote { get; set; } + // for drawing perfect note effect + public bool Perfect { get; set; } + #endregion + + #region Methods + public void CheckPerfect() + { + bool result = HitNote != null; + if (result) + { + result = (StartBeat == HitNote.StartBeat); + result &= (EndBeat == HitNote.EndBeat); + result &= (Tone == HitNote.Tone); + } + + Perfect = result; + } + #endregion Methods + + public override int PointsForBeat + { + get { return (HitNote == null) ? 0 : HitNote.PointsForBeat; } + } + } +} \ No newline at end of file diff --git a/VocaluxeLib/Songs/CVoice.cs b/VocaluxeLib/Songs/CVoice.cs new file mode 100644 index 00000000..c833d679 --- /dev/null +++ b/VocaluxeLib/Songs/CVoice.cs @@ -0,0 +1,194 @@ +using System.Collections.Generic; +using System.Linq; + +namespace VocaluxeLib.Songs +{ + public class CVoice + { + private readonly List _Lines = new List(); + + public CVoice() {} + + public CVoice(CVoice voice) + { + foreach (CSongLine line in voice._Lines) + _Lines.Add(new CSongLine(line)); + } + + public CSongLine[] Lines + { + get { return _Lines.ToArray(); } + } + public int NumLines + { + get { return _Lines.Count; } + } + + /// + /// Total song length in beats + /// + public int Length + { + get + { + if (_Lines.Count == 0) + return 0; + + int startbeat = _Lines.Max(line => line.FirstNoteBeat); + int endbeat = _Lines.Min(line => line.LastNoteBeat); + + int result = endbeat - startbeat; + return result > 0 ? result : 0; + } + } + + public int Points + { + get { return _Lines.Sum(line => line.Points); } + } + + public int NumLinesWithPoints + { + get { return _Lines.Count(line => line.Points > 0f); } + } + + #region Methods + //Find last line with StartBeat<=Beat + public int FindPreviousLine(int beat) + { + //If no line -> No previous line + if (_Lines.Count == 0) + return -1; + int start = 0; + int end = _Lines.Count - 1; + //Ensure that start.StartBeat<=Beat && end.StartBeat>Beat + if (_Lines[0].StartBeat > beat) + return -1; + if (_Lines[end].StartBeat <= beat) + return end; + //Binary search + while (end - start > 1) + { + int mid = (start + end) / 2; + if (_Lines[mid].StartBeat <= beat) + start = mid; + else + end = mid; + } + return start; + } + + public void AddLine(CSongLine line) + { + if (_Lines.Count == 0) + _Lines.Add(line); + else + { + int insPos = FindPreviousLine(line.StartBeat); + _Lines.Insert(insPos + 1, line); + } + } + + public bool DeleteLine(int index) + { + if (_Lines.Count > index) + { + _Lines.RemoveAt(index); + UpdateTimings(); + return true; + } + return false; + } + + public void DeleteAllLines() + { + _Lines.Clear(); + } + + public bool AddNote(CSongNote note, bool updateTimings = false) + { + int lineIndex = FindPreviousLine(note.StartBeat); + if (lineIndex < 0) + { + //Note is before ALL lines + CSongLine line = new CSongLine {StartBeat = note.StartBeat}; + line.AddNote(note); + _Lines.Insert(0, line); + } + else + { + if (!_Lines[lineIndex].AddNote(note)) + return false; + } + if (updateTimings) + UpdateTimings(); + return true; + } + + public bool InsertNote(CSongNote note, int lineIndex, bool updateTimings = false) + { + if (_Lines.Count > lineIndex && _Lines[lineIndex].StartBeat <= note.StartBeat) + { + _Lines[lineIndex].AddNote(note); + if (updateTimings) + UpdateTimings(); + return true; + } + return false; + } + + public void UpdateTimings() + { + CSongNote lastNote; + + if (_Lines.Count > 0) + _Lines[0].StartBeat = -10000; + + for (int i = 1; i < _Lines.Count; i++) + { + lastNote = _Lines[i - 1].LastNote; + CSongNote firstNote = _Lines[i].FirstNote; + + if ((lastNote != null) && (firstNote != null)) + { + int min = lastNote.EndBeat; + int max = firstNote.StartBeat; + + int s; + switch (max - min) + { + case 0: + s = max; + break; + case 1: + s = max; + break; + case 2: + s = max - 1; + break; + case 3: + s = max - 2; + break; + default: + s = min + 2; + break; + } + + _Lines[i].StartBeat = s; + _Lines[i - 1].EndBeat = min; + } + } + + lastNote = _Lines[_Lines.Count - 1].LastNote; + if (lastNote != null) + _Lines[_Lines.Count - 1].EndBeat = lastNote.EndBeat; + } + + public void SetMedley(int startBeat, int endBeat) + { + foreach (CSongLine line in _Lines) + line.SetMedley(startBeat, endBeat); + } + #endregion Methods + } +} \ No newline at end of file diff --git a/VocaluxeLib/Structs.cs b/VocaluxeLib/Structs.cs index e94c3359..88dd1f7b 100644 --- a/VocaluxeLib/Structs.cs +++ b/VocaluxeLib/Structs.cs @@ -186,8 +186,8 @@ namespace VocaluxeLib public double PointsLineBonus; public double PointsGoldenNotes; public int NoteDiff; - public int LineNr; - public List SingLine; + public int VoiceNr; + public List SungLines; public int CurrentLine; public int CurrentNote; diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj index 25869d1a..c078d90d 100644 --- a/VocaluxeLib/VocaluxeLib.csproj +++ b/VocaluxeLib/VocaluxeLib.csproj @@ -138,6 +138,10 @@ + + + + @@ -150,6 +154,9 @@ + + + From 762d2c80d2b8058b7bf5274de8a0112f61cfe215 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Thu, 22 Aug 2013 00:56:58 +0200 Subject: [PATCH 2/2] Code cleanup Added license stuff --- Vocaluxe/Base/CConfig.cs | 4 +- Vocaluxe/Base/CController.cs | 4 +- Vocaluxe/Base/CDataBase.cs | 138 ++++++++---------- Vocaluxe/Base/CDraw.cs | 2 +- Vocaluxe/Base/CGraphics.cs | 20 +-- Vocaluxe/Base/CLanguage.cs | 10 +- Vocaluxe/Base/CParty.cs | 2 +- Vocaluxe/Base/CProfiles.cs | 40 ++--- Vocaluxe/Base/CSettings.cs | 4 +- Vocaluxe/Base/CSongSorter.cs | 4 +- Vocaluxe/Base/CSongs.cs | 4 +- Vocaluxe/Base/CSound.cs | 8 +- Vocaluxe/Base/CVideo.cs | 2 +- Vocaluxe/Base/Fonts/CFonts.cs | 8 +- Vocaluxe/Base/Server/CCommands.cs | 21 ++- Vocaluxe/Base/Server/VocaluxeStructs.cs | 21 ++- Vocaluxe/GameModes/CGameModes.cs | 4 +- Vocaluxe/Lib/Draw/CDirect3D.cs | 26 ++-- Vocaluxe/Lib/Draw/CDrawWinForm.cs | 14 +- Vocaluxe/Lib/Draw/COpenGL.cs | 10 +- Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs | 10 +- Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs | 4 +- Vocaluxe/Lib/Playlist/CPlaylistFile.cs | 12 +- Vocaluxe/Lib/Sound/CDirectSoundRecord.cs | 20 +-- Vocaluxe/Lib/Sound/CGstreamerAudio.cs | 4 +- Vocaluxe/Lib/Sound/COpenALPlay.cs | 10 +- Vocaluxe/Lib/Sound/CPortAudioPlay.cs | 16 +- Vocaluxe/Lib/Sound/CPortAudioRecord.cs | 12 +- .../Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs | 6 +- Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs | 10 +- Vocaluxe/Lib/Video/Acinerella/CDecoder.cs | 19 +++ Vocaluxe/Lib/Video/Acinerella/CFramebuffer.cs | 21 ++- Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs | 2 +- Vocaluxe/Lib/Webcam/CAForgeNet.cs | 8 +- Vocaluxe/Program.cs | 2 +- Vocaluxe/Screens/CPopupScreenPlayerControl.cs | 2 +- Vocaluxe/Screens/CScreenCredits.cs | 10 +- Vocaluxe/Screens/CScreenHighscore.cs | 2 +- Vocaluxe/Screens/CScreenOptionsRecord.cs | 14 +- Vocaluxe/Screens/CScreenOptionsSound.cs | 4 +- Vocaluxe/Screens/CScreenScore.cs | 12 +- Vocaluxe/Screens/CScreenSing.cs | 4 +- Vocaluxe/Screens/CScreenSong.cs | 26 ++-- Vocaluxe/Screens/CScreenTest.cs | 4 +- VocaluxeLib/CHelper.cs | 8 +- VocaluxeLib/CXMLReader.cs | 6 +- VocaluxeLib/Game/CPoints.cs | 2 +- VocaluxeLib/Menu/CBackground.cs | 8 +- VocaluxeLib/Menu/CEqualizer.cs | 2 +- VocaluxeLib/Menu/CLyric.cs | 2 +- VocaluxeLib/Menu/CMenu.cs | 42 +++--- VocaluxeLib/Menu/CObjectInteractions.cs | 30 ++-- VocaluxeLib/Menu/CParticle.cs | 6 +- VocaluxeLib/Menu/CPlaylist.cs | 12 +- VocaluxeLib/Menu/CSelectSlide.cs | 8 +- VocaluxeLib/Menu/CText.cs | 4 +- .../Menu/SongMenu/CSongMenuFramework.cs | 5 +- .../Menu/SongMenu/CSongMenuTileBoard.cs | 22 +-- VocaluxeLib/Songs/CBaseNote.cs | 23 ++- VocaluxeLib/Songs/CLineBase.cs | 21 ++- VocaluxeLib/Songs/CSong.cs | 16 +- VocaluxeLib/Songs/CSongLine.cs | 21 ++- VocaluxeLib/Songs/CSongNote.cs | 23 ++- VocaluxeLib/Songs/CSungLine.cs | 21 ++- VocaluxeLib/Songs/CSungNote.cs | 27 +++- VocaluxeLib/Songs/CVoice.cs | 21 ++- 66 files changed, 553 insertions(+), 357 deletions(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index f3dbbdbf..64fd0aed 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -697,7 +697,7 @@ namespace Vocaluxe.Base /// Parameters public static void LoadCommandLineParams(string[] args) { - Regex spliterParam = new Regex(@"-{1,2}|\/", RegexOptions.IgnoreCase); + var spliterParam = new Regex(@"-{1,2}|\/", RegexOptions.IgnoreCase); //Complete argument string string arguments = args.Aggregate(string.Empty, (current, arg) => current + (arg + " ")); @@ -706,7 +706,7 @@ namespace Vocaluxe.Base foreach (string text in args) { - Regex spliterVal = new Regex(@"\s", RegexOptions.IgnoreCase); + var spliterVal = new Regex(@"\s", RegexOptions.IgnoreCase); //split arg with Spilter-Regex and save in parts string[] parts = spliterVal.Split(text, 2); diff --git a/Vocaluxe/Base/CController.cs b/Vocaluxe/Base/CController.cs index e28bb2ee..babc1ca0 100644 --- a/Vocaluxe/Base/CController.cs +++ b/Vocaluxe/Base/CController.cs @@ -77,11 +77,11 @@ namespace Vocaluxe.Base { controller.Update(); - SKeyEvent ke = new SKeyEvent(); + var ke = new SKeyEvent(); while (controller.PollKeyEvent(ref ke)) _KeysPool.Add(ke); - SMouseEvent me = new SMouseEvent(); + var me = new SMouseEvent(); while (controller.PollMouseEvent(ref me)) _MousePool.Add(me); } diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index ffe314cf..c9e0ebdb 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -71,13 +71,12 @@ namespace Vocaluxe.Base } #region Highscores - public static bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded, out int highscoreID) { - string sArtist = string.Empty; - string sTitle = string.Empty; - int songID = -1; - using (SQLiteConnection connection = new SQLiteConnection()) + string sArtist; + string sTitle; + int songID; + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _HighscoreFilePath; @@ -85,11 +84,9 @@ namespace Vocaluxe.Base { connection.Open(); } - catch (Exception) - { - } + catch (Exception) {} - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { songID = _GetDataBaseSongID(artist, title, 0, command); highscoreID = songID; @@ -100,7 +97,7 @@ namespace Vocaluxe.Base public static void IncreaseSongCounter(SPlayer player) { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _HighscoreFilePath; @@ -108,11 +105,9 @@ namespace Vocaluxe.Base { connection.Open(); } - catch (Exception) - { - } + catch (Exception) {} - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { int dataBaseSongID = _GetDataBaseSongID(player, command); _IncreaseSongCounter(dataBaseSongID, command); @@ -122,7 +117,7 @@ namespace Vocaluxe.Base public static void IncreaseSongCounter(int dataBaseSongID) { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _HighscoreFilePath; @@ -130,21 +125,17 @@ namespace Vocaluxe.Base { connection.Open(); } - catch (Exception) - { - } + catch (Exception) {} - using (SQLiteCommand command = new SQLiteCommand(connection)) - { + using (var command = new SQLiteCommand(connection)) _IncreaseSongCounter(dataBaseSongID, command); - } } } public static int AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int difficulty, string artist, string title, int numPlayed, string filePath) { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + filePath; @@ -157,7 +148,7 @@ namespace Vocaluxe.Base return -1; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { int dataBaseSongID = _GetDataBaseSongID(artist, title, numPlayed, command); int result = _AddScore(playerName, score, lineNr, date, medley, duet, shortSong, difficulty, dataBaseSongID, command); @@ -168,7 +159,7 @@ namespace Vocaluxe.Base public static int AddScore(SPlayer player) { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _HighscoreFilePath; @@ -181,7 +172,7 @@ namespace Vocaluxe.Base return -1; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { int dataBaseSongID = CSongs.GetSong(player.SongID).DataBaseSongID; return _AddScore(CProfiles.GetPlayerName(player.ProfileID), (int)Math.Round(player.Points), player.VoiceNr, player.DateTicks, player.Medley ? 1 : 0, @@ -256,7 +247,7 @@ namespace Vocaluxe.Base public static void LoadScore(out List scores, SPlayer player) { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _HighscoreFilePath; @@ -271,7 +262,7 @@ namespace Vocaluxe.Base return; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { int medley = 0; if (player.Medley) @@ -301,7 +292,7 @@ namespace Vocaluxe.Base { while (reader.Read()) { - SScores score = new SScores + var score = new SScores { Name = reader.GetString(0), Score = reader.GetInt32(1), @@ -361,7 +352,7 @@ namespace Vocaluxe.Base 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.Parameters.Add("@dateadded", System.Data.DbType.Int64, 0).Value = DateTime.Now.Ticks; + command.Parameters.Add("@dateadded", DbType.Int64, 0).Value = DateTime.Now.Ticks; command.ExecuteNonQuery(); command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist"; @@ -388,7 +379,7 @@ namespace Vocaluxe.Base numPlayed = 0; dateAdded = String.Empty; - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + filePath; @@ -401,7 +392,7 @@ namespace Vocaluxe.Base return false; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { command.CommandText = "SELECT Artist, Title, NumPlayed, DateAdded FROM Songs WHERE [id] = @id"; command.Parameters.Add("@id", DbType.String, 0).Value = songID; @@ -460,7 +451,7 @@ namespace Vocaluxe.Base private static void _CreateHighscoreDB(string filePath) { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + filePath; @@ -473,7 +464,7 @@ namespace Vocaluxe.Base return; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);"; command.ExecuteNonQuery(); @@ -496,7 +487,7 @@ namespace Vocaluxe.Base private static void _CreateHighscoreDBV1(string filePath) { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + filePath; @@ -509,7 +500,7 @@ namespace Vocaluxe.Base return; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);"; command.ExecuteNonQuery(); @@ -536,7 +527,7 @@ namespace Vocaluxe.Base /// private static bool _CreateOrConvert(string filePath) { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + filePath; @@ -549,7 +540,7 @@ namespace Vocaluxe.Base return false; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { command.CommandText = "PRAGMA user_version"; SQLiteDataReader reader = command.ExecuteReader(); @@ -646,7 +637,7 @@ namespace Vocaluxe.Base /// True if succeeded private static bool _ConvertFrom110(string filePath) { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + filePath; @@ -659,7 +650,7 @@ namespace Vocaluxe.Base return false; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { //The USDX database has no column for LineNr, Medley and Duet so just fill 0 in there command.CommandText = @@ -669,8 +660,8 @@ namespace Vocaluxe.Base command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs"; command.ExecuteNonQuery(); - List scores = new List(); - List songs = new List(); + var scores = new List(); + var songs = new List(); command.CommandText = "SELECT id, PlayerName, Date FROM Scores"; SQLiteDataReader reader = command.ExecuteReader(); @@ -679,7 +670,7 @@ namespace Vocaluxe.Base { while (reader.Read()) { - SData data = new SData {Id = reader.GetInt32(0), Str1 = reader.GetString(1)}; + var data = new SData {Id = reader.GetInt32(0), Str1 = reader.GetString(1)}; Int64 ticks = 0; try @@ -703,7 +694,7 @@ namespace Vocaluxe.Base { while (reader.Read()) { - SData data = new SData {Id = reader.GetInt32(0), Str1 = reader.GetString(1), Str2 = reader.GetString(2)}; + var data = new SData {Id = reader.GetInt32(0), Str1 = reader.GetString(1), Str2 = reader.GetString(2)}; songs.Add(data); } } @@ -759,7 +750,7 @@ namespace Vocaluxe.Base /// True if succeeded private static bool _ConvertFrom101(string filePath) { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + filePath; @@ -772,7 +763,7 @@ namespace Vocaluxe.Base return false; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { command.CommandText = "PRAGMA table_info(US_Scores);"; bool dateExists = false; @@ -803,8 +794,8 @@ namespace Vocaluxe.Base command.ExecuteNonQuery(); // convert from CP1252 to UTF8 - List scores = new List(); - List songs = new List(); + var scores = new List(); + var songs = new List(); Sqlite3.sqlite3 oldDB; int res = Sqlite3.sqlite3_open(filePath, out oldDB); @@ -813,7 +804,7 @@ namespace Vocaluxe.Base CLog.LogError("Error opening Database: " + filePath + " (" + Sqlite3.sqlite3_errmsg(oldDB) + ")"); else { - Sqlite3.Vdbe stmt = new Sqlite3.Vdbe(); + var stmt = new Sqlite3.Vdbe(); res = Sqlite3.sqlite3_prepare_v2(oldDB, "SELECT id, Artist, Title FROM Songs", -1, ref stmt, 0); if (res != Sqlite3.SQLITE_OK) @@ -826,7 +817,7 @@ namespace Vocaluxe.Base while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW) { - SData data = new SData {Id = Sqlite3.sqlite3_column_int(stmt, 0)}; + var data = new SData {Id = Sqlite3.sqlite3_column_int(stmt, 0)}; byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1); data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone"; @@ -858,7 +849,7 @@ namespace Vocaluxe.Base while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW) { - SData data = new SData {Id = Sqlite3.sqlite3_column_int(stmt, 0)}; + var data = new SData {Id = Sqlite3.sqlite3_column_int(stmt, 0)}; byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1); data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone"; @@ -918,20 +909,16 @@ namespace Vocaluxe.Base bool updated = true; if (currentVersion < 2) - { updated &= _ConvertV1toV2(connection); - } if (currentVersion < 3) - { updated &= _ConvertV2toV3(connection); - } return updated; } private static bool _ConvertV1toV2(SQLiteConnection connection) { - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { command.CommandText = "ALTER TABLE Scores ADD ShortSong INTEGER"; command.ExecuteNonQuery(); @@ -948,17 +935,14 @@ namespace Vocaluxe.Base private static bool _ConvertV2toV3(SQLiteConnection connection) { - SQLiteCommand command; + var command = new SQLiteCommand(connection) {CommandText = "ALTER TABLE Songs ADD DateAdded BIGINT"}; - command = new SQLiteCommand(connection); - - command.CommandText = "ALTER TABLE Songs ADD DateAdded BIGINT"; command.ExecuteNonQuery(); command.CommandText = "UPDATE Songs SET [DateAdded] = @DateAdded"; - command.Parameters.Add("@DateAdded",System.Data.DbType.Int64, 0).Value = DateTime.Now.Ticks; + command.Parameters.Add("@DateAdded", DbType.Int64, 0).Value = DateTime.Now.Ticks; command.ExecuteNonQuery(); command.CommandText = "UPDATE Version SET [Value] = @version"; - command.Parameters.Add("@version", System.Data.DbType.Int32, 0).Value = 3; + command.Parameters.Add("@version", DbType.Int32, 0).Value = 3; command.ExecuteNonQuery(); command.Dispose(); @@ -968,7 +952,7 @@ namespace Vocaluxe.Base private static bool _ImportData(string sourceDBPath) { #region open db - using (SQLiteConnection connSource = new SQLiteConnection()) + using (var connSource = new SQLiteConnection()) { connSource.ConnectionString = "Data Source=" + sourceDBPath; @@ -983,7 +967,7 @@ namespace Vocaluxe.Base } #endregion open db - using (SQLiteCommand cmdSource = new SQLiteCommand(connSource)) + using (var cmdSource = new SQLiteCommand(connSource)) { #region import table scores cmdSource.CommandText = "SELECT SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty FROM Scores"; @@ -1039,7 +1023,7 @@ namespace Vocaluxe.Base _ConnectionCover.Open(); } - using (SQLiteCommand command = new SQLiteCommand(_ConnectionCover)) + using (var command = new SQLiteCommand(_ConnectionCover)) { command.CommandText = "SELECT id, width, height FROM Cover WHERE [Path] = @path"; command.Parameters.Add("@path", DbType.String, 0).Value = coverPath; @@ -1097,7 +1081,7 @@ namespace Vocaluxe.Base else if (origin.Height > origin.Width && origin.Height > h) w = (int)Math.Round((float)h / origin.Height * origin.Width); - using (Bitmap bmp = new Bitmap(w, h)) + using (var bmp = new Bitmap(w, h)) { using (Graphics g = Graphics.FromImage(bmp)) g.DrawImage(origin, new Rectangle(0, 0, w, h)); @@ -1166,7 +1150,7 @@ namespace Vocaluxe.Base private static bool _InitCoverDB() { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _CoverFilePath; @@ -1179,7 +1163,7 @@ namespace Vocaluxe.Base return false; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { command.CommandText = "SELECT Value FROM Version"; @@ -1219,7 +1203,7 @@ namespace Vocaluxe.Base private static void _CreateCoverDB() { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _CoverFilePath; @@ -1232,7 +1216,7 @@ namespace Vocaluxe.Base return; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);"; command.ExecuteNonQuery(); @@ -1258,7 +1242,7 @@ namespace Vocaluxe.Base { bool result = false; - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _CreditsRessourcesFilePath; try @@ -1269,7 +1253,7 @@ namespace Vocaluxe.Base { return false; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { command.CommandText = "SELECT id, width, height FROM Images WHERE [Path] = @path"; command.Parameters.Add("@path", DbType.String, 0).Value = fileName; @@ -1391,7 +1375,7 @@ namespace Vocaluxe.Base private static bool _InitCreditsRessourcesDB() { - using (SQLiteConnection connection = new SQLiteConnection()) + using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _CreditsRessourcesFilePath; @@ -1404,7 +1388,7 @@ namespace Vocaluxe.Base return false; } - using (SQLiteCommand command = new SQLiteCommand(connection)) + using (var command = new SQLiteCommand(connection)) { command.CommandText = "SELECT Value FROM Version"; @@ -1484,14 +1468,14 @@ namespace Vocaluxe.Base private static byte[] _GetBytes(SQLiteDataReader reader) { const int chunkSize = 2 * 1024; - byte[] buffer = new byte[chunkSize]; + var buffer = new byte[chunkSize]; long fieldOffset = 0; - using (MemoryStream stream = new MemoryStream()) + using (var stream = new MemoryStream()) { long bytesRead; while ((bytesRead = reader.GetBytes(0, fieldOffset, buffer, 0, buffer.Length)) > 0) { - byte[] actualRead = new byte[bytesRead]; + var actualRead = new byte[bytesRead]; Buffer.BlockCopy(buffer, 0, actualRead, 0, (int)bytesRead); stream.Write(actualRead, 0, actualRead.Length); fieldOffset += bytesRead; @@ -1502,7 +1486,7 @@ namespace Vocaluxe.Base private static long _UnixTimeToTicks(int unixTime) { - DateTime t70 = new DateTime(1970, 1, 1, 0, 0, 0, 0); + var t70 = new DateTime(1970, 1, 1, 0, 0, 0, 0); t70 = t70.AddSeconds(unixTime); return t70.Ticks; } diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs index 3969658a..cf945004 100644 --- a/Vocaluxe/Base/CDraw.cs +++ b/Vocaluxe/Base/CDraw.cs @@ -206,7 +206,7 @@ namespace Vocaluxe.Base if (texture == null) return; - RectangleF bounds = new RectangleF(staticBounds.Rect.X, staticBounds.Rect.Y, staticBounds.Rect.W, staticBounds.Rect.H); + var bounds = new RectangleF(staticBounds.Rect.X, staticBounds.Rect.Y, staticBounds.Rect.W, staticBounds.Rect.H); RectangleF rect; CHelper.SetRect(bounds, out rect, texture.OrigAspect, aspect); diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index f531a3c7..87164ab1 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -218,7 +218,7 @@ namespace Vocaluxe.Base if (_Fading) { - long fadeTime = (long)(CConfig.FadeTime * 1000); + var fadeTime = (long)(CConfig.FadeTime * 1000); if ((_FadingTimer.ElapsedMilliseconds < fadeTime) && (CConfig.FadeTime > 0)) { @@ -349,10 +349,10 @@ namespace Vocaluxe.Base #region private stuff private static bool _HandleInputs(CKeys keys, CMouse mouse) { - SKeyEvent keyEvent = new SKeyEvent(); - SMouseEvent mouseEvent = new SMouseEvent(); - SKeyEvent inputKeyEvent = new SKeyEvent(); - SMouseEvent inputMouseEvent = new SMouseEvent(); + var keyEvent = new SKeyEvent(); + var mouseEvent = new SMouseEvent(); + var inputKeyEvent = new SKeyEvent(); + var inputMouseEvent = new SMouseEvent(); bool popupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing && (_CurrentScreen != EScreens.ScreenSong || @@ -541,8 +541,8 @@ namespace Vocaluxe.Base private static bool _HandleInputThemeEditor(CKeys keys, CMouse mouse) { - SKeyEvent keyEvent = new SKeyEvent(); - SMouseEvent mouseEvent = new SMouseEvent(); + var keyEvent = new SKeyEvent(); + var mouseEvent = new SMouseEvent(); while (keys.PollEvent(ref keyEvent)) { @@ -598,7 +598,7 @@ namespace Vocaluxe.Base if (CConfig.DebugLevel == EDebugLevel.TR_CONFIG_OFF) return; - List debugOutput = new List {CTime.GetFPS().ToString("FPS: 000")}; + var debugOutput = new List {CTime.GetFPS().ToString("FPS: 000")}; if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1) { @@ -627,11 +627,11 @@ namespace Vocaluxe.Base CFonts.Style = EStyle.Normal; CFonts.SetFont("Normal"); CFonts.Height = 25; - SColorF gray = new SColorF(1f, 1f, 1f, 0.5f); + var gray = new SColorF(1f, 1f, 1f, 0.5f); float y = 0; foreach (string txt in debugOutput) { - RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), y, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt)); + var rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), y, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt)); CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear)); CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear); y += rect.Height; diff --git a/Vocaluxe/Base/CLanguage.cs b/Vocaluxe/Base/CLanguage.cs index ede9e021..d0a1dd9b 100644 --- a/Vocaluxe/Base/CLanguage.cs +++ b/Vocaluxe/Base/CLanguage.cs @@ -66,7 +66,7 @@ namespace Vocaluxe.Base public static IEnumerable GetLanguageNames() { - string[] languages = new string[_Languages.Count]; + var languages = new string[_Languages.Count]; for (int i = 0; i < _Languages.Count; i++) languages[i] = _Languages[i].Name; @@ -81,7 +81,7 @@ namespace Vocaluxe.Base _Settings.Encoding = Encoding.UTF8; _Settings.ConformanceLevel = ConformanceLevel.Document; - List files = new List(); + var files = new List(); files.AddRange(CHelper.ListFiles(CSettings.FolderLanguages, "*.xml", true, true)); foreach (string file in files) @@ -166,7 +166,7 @@ namespace Vocaluxe.Base public static bool LoadPartyLanguageFiles(int partyModeID, string path) { - List files = new List(); + var files = new List(); files.AddRange(CHelper.ListFiles(path, "*.xml", true, true)); return files.All(file => _LoadPartyLanguageFile(partyModeID, file)); @@ -208,7 +208,7 @@ namespace Vocaluxe.Base if (nr == -1) return true; - SPartyLanguage lang = new SPartyLanguage {PartyModeID = partyModeID}; + var lang = new SPartyLanguage {PartyModeID = partyModeID}; if (!_LoadLanguageEntries(xmlReader, out lang.Texts)) return false; @@ -221,7 +221,7 @@ namespace Vocaluxe.Base private static void _LoadLanguageFile(string fileName) { - SLanguage lang = new SLanguage {LanguageFilePath = Path.Combine(CSettings.FolderLanguages, fileName)}; + var 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 32b283c8..45f0cec9 100644 --- a/Vocaluxe/Base/CParty.cs +++ b/Vocaluxe/Base/CParty.cs @@ -304,7 +304,7 @@ namespace Vocaluxe.Base pm.PartyMode.Initialize(); pm.PartyMode.SetFolder(Path.Combine(Directory.GetCurrentDirectory(), Path.Combine(CSettings.FolderPartyModes, pm.Folder))); - if (!CTheme.AddTheme(Path.Combine(pm.PartyMode.GetFolder(), "Theme.xml"),pm.PartyModeID)) + if (!CTheme.AddTheme(Path.Combine(pm.PartyMode.GetFolder(), "Theme.xml"), pm.PartyModeID)) return pm; int themeIndex = CTheme.GetThemeIndex(pm.PartyModeID); diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs index 005eefe3..91474e96 100644 --- a/Vocaluxe/Base/CProfiles.cs +++ b/Vocaluxe/Base/CProfiles.cs @@ -179,7 +179,7 @@ namespace Vocaluxe.Base if (_ProfileChangedCallbacks.Count == 0) return; - EProfileChangedFlags flags = EProfileChangedFlags.None; + var flags = EProfileChangedFlags.None; if (_AvatarsChanged) flags = EProfileChangedFlags.Avatar; @@ -214,7 +214,7 @@ namespace Vocaluxe.Base public static void LoadProfiles() { - SChange change = new SChange {Action = EAction.LoadProfiles}; + var change = new SChange {Action = EAction.LoadProfiles}; lock (_QueueMutex) { @@ -224,7 +224,7 @@ namespace Vocaluxe.Base public static void LoadAvatars() { - SChange change = new SChange {Action = EAction.LoadAvatars}; + var change = new SChange {Action = EAction.LoadAvatars}; lock (_QueueMutex) { @@ -237,7 +237,7 @@ namespace Vocaluxe.Base if (newProfile == null) return; - SChange change = new SChange {Action = EAction.AddProfile, Profile = newProfile}; + var change = new SChange {Action = EAction.AddProfile, Profile = newProfile}; lock (_QueueMutex) { @@ -250,7 +250,7 @@ namespace Vocaluxe.Base if (editProfile == null) return; - SChange change = new SChange {Action = EAction.EditProfile, Profile = editProfile}; + var change = new SChange {Action = EAction.EditProfile, Profile = editProfile}; lock (_QueueMutex) { @@ -263,7 +263,7 @@ namespace Vocaluxe.Base if (!IsProfileIDValid(profileID)) return; - SChange change = new SChange {Action = EAction.DeleteProfile, ProfileID = profileID}; + var change = new SChange {Action = EAction.DeleteProfile, ProfileID = profileID}; lock (_QueueMutex) { @@ -276,7 +276,7 @@ namespace Vocaluxe.Base if (newAvatar == null) return; - SChange change = new SChange {Action = EAction.AddAvatar, Avatar = newAvatar}; + var change = new SChange {Action = EAction.AddAvatar, Avatar = newAvatar}; lock (_QueueMutex) { @@ -289,7 +289,7 @@ namespace Vocaluxe.Base if (editAvatar == null) return; - SChange change = new SChange {Action = EAction.EditAvatar, Avatar = editAvatar}; + var change = new SChange {Action = EAction.EditAvatar, Avatar = editAvatar}; lock (_QueueMutex) { @@ -302,7 +302,7 @@ namespace Vocaluxe.Base if (_Profiles.Count == 0) return null; - List list = new List(_Profiles.Values); + var list = new List(_Profiles.Values); list.Sort(_CompareByPlayerName); return list.ToArray(); } @@ -312,7 +312,7 @@ namespace Vocaluxe.Base if (_Avatars.Count == 0) return null; - CAvatar[] result = new CAvatar[_Avatars.Count]; + var result = new CAvatar[_Avatars.Count]; _Avatars.Values.CopyTo(result, 0); return result; @@ -320,7 +320,7 @@ namespace Vocaluxe.Base public static int NewProfile(string fileName = "") { - CProfile profile = new CProfile + var profile = new CProfile { FileName = fileName != "" ? Path.Combine(CSettings.FolderProfiles, fileName) : String.Empty }; @@ -336,7 +336,7 @@ namespace Vocaluxe.Base public static int NewAvatar(string fileName) { - CAvatar avatar = new CAvatar(-1); + var avatar = new CAvatar(-1); if (!avatar.LoadFromFile(fileName)) return -1; @@ -511,10 +511,10 @@ namespace Vocaluxe.Base { _LoadAvatars(); - List knownFiles = new List(); + var knownFiles = new List(); if (_Profiles.Count > 0) { - int[] ids = new int[_Profiles.Keys.Count]; + var ids = new int[_Profiles.Keys.Count]; _Profiles.Keys.CopyTo(ids, 0); foreach (int id in ids) { @@ -528,7 +528,7 @@ namespace Vocaluxe.Base } } - List files = new List(); + var files = new List(); files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.xml", true, true)); foreach (string file in files) @@ -536,7 +536,7 @@ namespace Vocaluxe.Base if (knownFiles.Contains(Path.GetFileName(file))) continue; - CProfile profile = new CProfile + var profile = new CProfile { FileName = Path.Combine(CSettings.FolderProfiles, file) }; @@ -553,10 +553,10 @@ namespace Vocaluxe.Base private static void _LoadAvatars() { - List knownFiles = new List(); + var knownFiles = new List(); if (_Avatars.Count > 0) { - int[] ids = new int[_Avatars.Keys.Count]; + var ids = new int[_Avatars.Keys.Count]; _Avatars.Keys.CopyTo(ids, 0); foreach (int id in ids) { @@ -567,7 +567,7 @@ namespace Vocaluxe.Base } } - List files = new List(); + var files = new List(); files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.png", true, true)); files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.jpg", true, true)); files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.jpeg", true, true)); @@ -578,7 +578,7 @@ namespace Vocaluxe.Base if (knownFiles.Contains(Path.GetFileName(file))) continue; - CAvatar avatar = new CAvatar(-1); + var avatar = new CAvatar(-1); if (avatar.LoadFromFile(file)) { avatar.ID = _AvatarIDs.Dequeue(); diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 71cfd196..c4cb68c6 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -209,7 +209,7 @@ namespace Vocaluxe.Base public static void CreateFolders() { - List folders = new List {FolderCover, FolderFonts, FolderProfiles, FolderSongs, FolderScreenshots, FolderBackgroundMusic, FolderSounds, FolderPlaylists}; + var folders = new List {FolderCover, FolderFonts, FolderProfiles, FolderSongs, FolderScreenshots, FolderBackgroundMusic, FolderSounds, FolderPlaylists}; foreach (string folder in folders) { @@ -224,4 +224,4 @@ namespace Vocaluxe.Base Directory.CreateDirectory(path); } } -} +} \ No newline at end of file diff --git a/Vocaluxe/Base/CSongSorter.cs b/Vocaluxe/Base/CSongSorter.cs index 1c427fcf..f9921bdd 100644 --- a/Vocaluxe/Base/CSongSorter.cs +++ b/Vocaluxe/Base/CSongSorter.cs @@ -114,7 +114,7 @@ namespace Vocaluxe.Base private List _CreateSortList(string fieldName) { - List sortList = new List(); + var sortList = new List(); if (fieldName == "") CSongs.Filter.FilteredSongs.ForEach(song => sortList.Add(new CSongPointer(song.ID, ""))); else @@ -135,7 +135,7 @@ namespace Vocaluxe.Base sortList.Add(new CSongPointer(song.ID, (String)value)); else { - List values = (List)value; + var values = (List)value; if (values.Count == 0) sortList.Add(new CSongPointer(song.ID, "")); else diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 05f7ac31..280fcb7d 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -251,7 +251,7 @@ namespace Vocaluxe.Base { get { - List songs = new List(); + var songs = new List(); if (_IsCatIndexValid(_CatIndex)) { // ReSharper disable LoopCanBeConvertedToQuery @@ -298,7 +298,7 @@ namespace Vocaluxe.Base _Songs.Clear(); CLog.StartBenchmark(2, "List Songs"); - List files = new List(); + var files = new List(); foreach (string p in CConfig.SongFolder) { string path = p; diff --git a/Vocaluxe/Base/CSound.cs b/Vocaluxe/Base/CSound.cs index a4dc3e5b..97558342 100644 --- a/Vocaluxe/Base/CSound.cs +++ b/Vocaluxe/Base/CSound.cs @@ -450,11 +450,11 @@ namespace Vocaluxe.Base int len = _AnalysisBuffer.Length * 2; if (_Stream.Length >= len) { - byte[] buf = new byte[len]; + var buf = new byte[len]; _Stream.Position -= len; _Stream.Read(buf, 0, len); - byte[] b = new byte[2]; + var b = new byte[2]; for (int i = 0; i < _AnalysisBuffer.Length; i++) { b[0] = buf[i * 2]; @@ -496,7 +496,7 @@ namespace Vocaluxe.Base double maxWeight = -1.0; double minWeight = 1.0; int maxTone = -1; - float[] weigth = new float[_NumHalfTones]; + var weigth = new float[_NumHalfTones]; // analyze halftones // Note: at the lowest tone (~65Hz) and a buffer-size of 4096 @@ -535,7 +535,7 @@ namespace Vocaluxe.Base private double _AnalyzeAutocorrelationFreq(double freq) { int sampleIndex = 0; // index of sample to analyze - int samplesPerPeriod = (int)Math.Round(44100.0 / freq); // samples in one period + var samplesPerPeriod = (int)Math.Round(44100.0 / freq); // samples in one period int correlatingSampleIndex = sampleIndex + samplesPerPeriod; // index of sample one period ahead double accumDist = 0.0; // accumulated distances diff --git a/Vocaluxe/Base/CVideo.cs b/Vocaluxe/Base/CVideo.cs index 031bc6b6..24104123 100644 --- a/Vocaluxe/Base/CVideo.cs +++ b/Vocaluxe/Base/CVideo.cs @@ -168,7 +168,7 @@ namespace Vocaluxe.Base } if (_VideoTexture == null) return; - RectangleF bounds = new RectangleF(0f, 0f, CSettings.RenderW, CSettings.RenderH); + var bounds = new RectangleF(0f, 0f, CSettings.RenderW, CSettings.RenderH); RectangleF rect; CHelper.SetRect(bounds, out rect, _VideoTexture.OrigAspect, EAspect.Crop); diff --git a/Vocaluxe/Base/Fonts/CFonts.cs b/Vocaluxe/Base/Fonts/CFonts.cs index 1de2f929..18b1d61c 100644 --- a/Vocaluxe/Base/Fonts/CFonts.cs +++ b/Vocaluxe/Base/Fonts/CFonts.cs @@ -258,8 +258,8 @@ namespace Vocaluxe.Base.Fonts Height = height; SetFont(text.Font); Style = text.Style; - RectangleF result = new RectangleF(text.X, text.Y, GetTextWidth(CLanguage.Translate(text.Text, text.TranslationID)), - GetTextHeight(CLanguage.Translate(text.Text, text.TranslationID))); + var result = new RectangleF(text.X, text.Y, GetTextWidth(CLanguage.Translate(text.Text, text.TranslationID)), + GetTextHeight(CLanguage.Translate(text.Text, text.TranslationID))); //restore old values Height = oldHeight; _CurrentFont = oldFont; @@ -286,7 +286,7 @@ namespace Vocaluxe.Base.Fonts int i = 1; while (xmlReader.GetValue("//root/Fonts/Font" + i + "/Folder", out value, value)) { - SFont sf = new SFont {Folder = value, IsThemeFont = themeName != "", ThemeName = themeName, PartyModeID = partyModeId}; + var sf = new SFont {Folder = value, IsThemeFont = themeName != "", ThemeName = themeName, PartyModeID = partyModeId}; bool ok = true; @@ -297,7 +297,7 @@ namespace Vocaluxe.Base.Fonts ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/FileNormal", out value, value); sf.FileNormal = value; value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value)); - CFont f = new CFont(value); + var f = new CFont(value); sf.Normal = f; ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/FileItalic", out value, value); diff --git a/Vocaluxe/Base/Server/CCommands.cs b/Vocaluxe/Base/Server/CCommands.cs index 6c04e92c..162b4a76 100644 --- a/Vocaluxe/Base/Server/CCommands.cs +++ b/Vocaluxe/Base/Server/CCommands.cs @@ -1,4 +1,23 @@ -using System; +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + +using System; using System.IO; using System.Text; using System.Security.Cryptography; diff --git a/Vocaluxe/Base/Server/VocaluxeStructs.cs b/Vocaluxe/Base/Server/VocaluxeStructs.cs index ae5fd5cf..90a294a9 100644 --- a/Vocaluxe/Base/Server/VocaluxeStructs.cs +++ b/Vocaluxe/Base/Server/VocaluxeStructs.cs @@ -1,4 +1,23 @@ -namespace Vocaluxe.Base.Server +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + +namespace Vocaluxe.Base.Server { public struct SLoginData { diff --git a/Vocaluxe/GameModes/CGameModes.cs b/Vocaluxe/GameModes/CGameModes.cs index 5090ff44..4dfc2585 100644 --- a/Vocaluxe/GameModes/CGameModes.cs +++ b/Vocaluxe/GameModes/CGameModes.cs @@ -70,7 +70,7 @@ namespace Vocaluxe.GameModes { protected override CSong _PrepareSong(CSong song) { - CSong newSong = new CSong(song) {Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap}; + var newSong = new CSong(song) {Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap}; // set lines to short mode newSong.Notes.SetMedley(song.Notes.GetVoice(0).Lines[0].FirstNoteBeat, song.ShortEnd); @@ -82,7 +82,7 @@ namespace Vocaluxe.GameModes { protected override CSong _PrepareSong(CSong song) { - CSong newSong = new CSong(song) {Start = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) - song.Medley.FadeInTime + song.Gap}; + var newSong = new CSong(song) {Start = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) - song.Medley.FadeInTime + song.Gap}; if (newSong.Start < 0f) newSong.Start = 0f; diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 0e104ee1..6ab00e27 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -448,7 +448,7 @@ namespace Vocaluxe.Lib.Draw if (_Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate).IsFailure) CLog.LogError("Failed to set alpha operation"); - Int16[] indices = new Int16[6]; + var indices = new Int16[6]; indices[0] = 0; indices[1] = 1; indices[2] = 2; @@ -465,7 +465,7 @@ namespace Vocaluxe.Lib.Draw //This creates a new white texture and adds it to the texture pool //This texture is used for the DrawRect method - using (Bitmap blankMap = new Bitmap(1, 1)) + using (var blankMap = new Bitmap(1, 1)) { Graphics g = Graphics.FromImage(blankMap); g.Clear(Color.White); @@ -674,7 +674,7 @@ namespace Vocaluxe.Lib.Draw CTexture texture = _GetNewTexture(_W, _H); Surface backbufferSurface = _Device.GetBackBuffer(0, 0); - Texture tex = new Texture(_Device, texture.W2, texture.H2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed); + var tex = new Texture(_Device, texture.W2, texture.H2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed); Surface textureSurface = tex.GetSurfaceLevel(0); Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0, new Rectangle(0, 0, _W, _H), new Rectangle(0, 0, _W, _H)); backbufferSurface.Dispose(); @@ -722,7 +722,7 @@ namespace Vocaluxe.Lib.Draw //create a surface of the frame using (Surface surface = _Device.GetBackBuffer(0, 0)) { - Bitmap screen = new Bitmap(Surface.ToStream(surface, ImageFileFormat.Bmp)); + var screen = new Bitmap(Surface.ToStream(surface, ImageFileFormat.Bmp)); screen.Save(Path.Combine(path, file + i.ToString("00000") + ".bmp"), ImageFormat.Bmp); screen.Dispose(); } @@ -742,8 +742,8 @@ namespace Vocaluxe.Lib.Draw /// The end y-value public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2) { - Vector2[] lineVector = new Vector2[] {new Vector2(x1, y1), new Vector2(x2, y2)}; - using (Line line = new Line(_Device)) + var lineVector = new Vector2[] {new Vector2(x1, y1), new Vector2(x2, y2)}; + using (var line = new Line(_Device)) { line.Antialias = true; line.Begin(); @@ -850,7 +850,7 @@ namespace Vocaluxe.Lib.Draw w = _CheckForNextPowerOf2(w); h = _CheckForNextPowerOf2(h); - CTexture texture = new CTexture(bmp.Width, bmp.Height, w, h, true); + var texture = new CTexture(bmp.Width, bmp.Height, w, h, true); Bitmap bmp2 = null; byte[] data; @@ -907,7 +907,7 @@ namespace Vocaluxe.Lib.Draw { //Create a new texture in the managed pool, which does not need to be recreated on a lost device //because a copy of the texture is hold in the Ram - Texture t = new Texture(_Device, textureW, textureH, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed); + var t = new Texture(_Device, textureW, textureH, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed); _WriteDataToTexture(t, w, data); return t; } @@ -939,7 +939,7 @@ namespace Vocaluxe.Lib.Draw { texture.ID = _IDs.Dequeue(); _D3DTextures.Add(texture.ID, null); - STextureQueue queue = new STextureQueue(texture.ID, texture.W2, texture.H2, w, h, data); + var queue = new STextureQueue(texture.ID, texture.W2, texture.H2, w, h, data); _TexturesToLoad.Enqueue(queue); } return texture; @@ -1122,7 +1122,7 @@ namespace Vocaluxe.Lib.Draw if (!mirrored) { - STexturedColoredVertex[] vert = new STexturedColoredVertex[4]; + var vert = new STexturedColoredVertex[4]; vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb()); vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb()); vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb()); @@ -1131,7 +1131,7 @@ namespace Vocaluxe.Lib.Draw } else { - STexturedColoredVertex[] vert = new STexturedColoredVertex[4]; + var vert = new STexturedColoredVertex[4]; vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y1), c.ToArgb()); vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y2), c.ToArgb()); vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y2), c.ToArgb()); @@ -1175,7 +1175,7 @@ namespace Vocaluxe.Lib.Draw Color c = color.AsColor(); - STexturedColoredVertex[] vert = new STexturedColoredVertex[4]; + var vert = new STexturedColoredVertex[4]; vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb()); vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb()); vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb()); @@ -1258,7 +1258,7 @@ namespace Vocaluxe.Lib.Draw color.A = 0; Color transparent = color.AsColor(); - STexturedColoredVertex[] vert = new STexturedColoredVertex[4]; + var vert = new STexturedColoredVertex[4]; vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb()); vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), transparent.ToArgb()); vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), transparent.ToArgb()); diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs index 0c0c9ac1..c913faf7 100644 --- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs +++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs @@ -289,7 +289,7 @@ namespace Vocaluxe.Lib.Draw public CTexture CopyScreen() { - Bitmap bmp = new Bitmap(_Backbuffer); + var bmp = new Bitmap(_Backbuffer); _Bitmaps.Add(bmp); CTexture texture = _GetNewTexture(bmp.Width, bmp.Height); @@ -333,7 +333,7 @@ namespace Vocaluxe.Lib.Draw public CTexture AddTexture(Bitmap bmp) { - Bitmap bmp2 = new Bitmap(bmp); + var bmp2 = new Bitmap(bmp); _Bitmaps.Add(bmp2); CTexture texture = _GetNewTexture(bmp.Width, bmp.Height); @@ -357,7 +357,7 @@ namespace Vocaluxe.Lib.Draw if (tex.TexturePath == texturePath) return tex; } - using (Bitmap bmp = new Bitmap(texturePath)) + using (var bmp = new Bitmap(texturePath)) { CTexture texture = AddTexture(bmp); texture.TexturePath = texturePath; @@ -389,7 +389,7 @@ namespace Vocaluxe.Lib.Draw public CTexture AddTexture(int w, int h, byte[] data) { - using (Bitmap bmp = new Bitmap(w, h)) + using (var bmp = new Bitmap(w, h)) { BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); Marshal.Copy(data, 0, bmpData.Scan0, data.Length); @@ -459,13 +459,13 @@ namespace Vocaluxe.Lib.Draw private static Bitmap _ColorizeBitmap(Bitmap original, SColorF color) { - Bitmap newBitmap = new Bitmap(original.Width, original.Height); + var newBitmap = new Bitmap(original.Width, original.Height); using (Graphics g = Graphics.FromImage(newBitmap)) { - ColorMatrix cm = new ColorMatrix {Matrix33 = color.A, Matrix00 = color.R, Matrix11 = color.G, Matrix22 = color.B, Matrix44 = 1}; + var cm = new ColorMatrix {Matrix33 = color.A, Matrix00 = color.R, Matrix11 = color.G, Matrix22 = color.B, Matrix44 = 1}; - using (ImageAttributes ia = new ImageAttributes()) + using (var ia = new ImageAttributes()) { ia.SetColorMatrix(cm); diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index e2cc99d8..737b9ceb 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -124,7 +124,7 @@ namespace Vocaluxe.Lib.Draw bool ok = false; try { - GraphicsMode gm = new GraphicsMode(32, 24, 0, (int)CConfig.AAMode); + var gm = new GraphicsMode(32, 24, 0, (int)CConfig.AAMode); _Control = new GLControl(gm, 2, 1, GraphicsContextFlags.Default); if (_Control.GraphicsMode != null) ok = true; @@ -473,7 +473,7 @@ namespace Vocaluxe.Lib.Draw Close(); } catch {} - CTexture[] textures = new CTexture[_Textures.Count]; + var textures = new CTexture[_Textures.Count]; _Textures.Values.CopyTo(textures, 0); for (int i = 0; i < _Textures.Count; i++) RemoveTexture(ref textures[i]); @@ -552,7 +552,7 @@ namespace Vocaluxe.Lib.Draw int width = GetScreenWidth(); int height = GetScreenHeight(); - using (Bitmap screen = new Bitmap(width, height)) + using (var screen = new Bitmap(width, height)) { BitmapData bmpData = screen.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); @@ -707,7 +707,7 @@ namespace Vocaluxe.Lib.Draw w = MathHelper.NextPowerOfTwo(w); h = MathHelper.NextPowerOfTwo(h); - CTexture texture = new CTexture(bmp.Width, bmp.Height, w, h, true) {Name = GL.GenTexture()}; + var texture = new CTexture(bmp.Width, bmp.Height, w, h, true) {Name = GL.GenTexture()}; GL.BindTexture(TextureTarget.Texture2D, texture.Name); Bitmap bmp2 = null; @@ -813,7 +813,7 @@ namespace Vocaluxe.Lib.Draw lock (_MutexTexture) { texture.ID = _IDs.Dequeue(); - STextureQueue queue = new STextureQueue(texture.ID, texture.W2, texture.H2, w, h, data); + var queue = new STextureQueue(texture.ID, texture.W2, texture.H2, w, h, data); _TexturesToLoad.Enqueue(queue); _Textures[texture.ID] = texture; } diff --git a/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs b/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs index 6fffb49c..2961172c 100644 --- a/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs +++ b/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs @@ -204,7 +204,7 @@ namespace Vocaluxe.Lib.Input.WiiMote bool lb = false; bool rb = gesture == EGesture.Back; - Keys key = Keys.None; + var key = Keys.None; if (ws.ButtonState.A && !_ButtonStates[0]) lb = true; @@ -246,7 +246,7 @@ namespace Vocaluxe.Lib.Input.WiiMote if (key != Keys.None) { - SKeyEvent pool = new SKeyEvent(ESender.WiiMote, false, false, false, false, char.MinValue, key); + var pool = new SKeyEvent(ESender.WiiMote, false, false, false, false, char.MinValue, key); lock (_KeyCopyLock) { @@ -260,8 +260,8 @@ namespace Vocaluxe.Lib.Input.WiiMote float rx = ((p.X / 1024f) - reducing) * factor; float ry = ((p.Y / 768f) - reducing) * factor; - int x = (int)(rx * CSettings.RenderW); - int y = (int)(ry * CSettings.RenderH); + var x = (int)(rx * CSettings.RenderW); + var y = (int)(ry * CSettings.RenderH); bool lbh = !lb && ws.ButtonState.A; @@ -272,7 +272,7 @@ namespace Vocaluxe.Lib.Input.WiiMote if (gesture == EGesture.ScrollDown) wheel = 1; - SMouseEvent mpool = new SMouseEvent(); + var mpool = new SMouseEvent(); bool trigger = false; if (!lb && !rb && (p.X != _OldPosition.X || p.Y != _OldPosition.Y)) diff --git a/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs b/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs index b4e234c9..be556efd 100644 --- a/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs +++ b/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs @@ -320,7 +320,7 @@ namespace Vocaluxe.Lib.Input.WiiMote if (_Handle != IntPtr.Zero && Connected) { - byte[] buff = new byte[_ReportLength]; + var buff = new byte[_ReportLength]; try { @@ -348,7 +348,7 @@ namespace Vocaluxe.Lib.Input.WiiMote return false; } - EInputReport type = (EInputReport)buff[0]; + var type = (EInputReport)buff[0]; switch (type) { diff --git a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs index ddf4849e..e1def3bc 100644 --- a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs +++ b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs @@ -147,7 +147,7 @@ namespace Vocaluxe.Lib.Playlist Songs = new List(); List songs = xmlReader.GetValues("Songs"); - EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; + var gm = EGameMode.TR_GAMEMODE_NORMAL; foreach (string song in songs) { @@ -157,7 +157,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 {SongID = -1}; + var playlistSong = new CPlaylistSong {SongID = -1}; foreach (CSong curSong in CSongs.AllSongs) { @@ -182,14 +182,14 @@ namespace Vocaluxe.Lib.Playlist public void AddSong(int songID) { - CPlaylistSong song = new CPlaylistSong {SongID = songID, GameMode = CSongs.GetSong(songID).IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL}; + var 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 {SongID = songID, GameMode = gm}; + var song = new CPlaylistSong {SongID = songID, GameMode = gm}; Songs.Add(song); } @@ -216,7 +216,7 @@ namespace Vocaluxe.Lib.Playlist if (sourceNr < 0 || destNr < 0 || sourceNr == destNr || sourceNr > Songs.Count - 1 || destNr > Songs.Count - 1) return; - CPlaylistSong ps = new CPlaylistSong(Songs[sourceNr]); + var ps = new CPlaylistSong(Songs[sourceNr]); Songs.RemoveAt(sourceNr); Songs.Insert(destNr, ps); } @@ -226,7 +226,7 @@ namespace Vocaluxe.Lib.Playlist if (destNr < 0 || destNr > Songs.Count - 1) return; - CPlaylistSong ps = new CPlaylistSong(songID, gm); + var ps = new CPlaylistSong(songID, gm); Songs.Insert(destNr, ps); } } diff --git a/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs b/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs index fad206a4..49dccd09 100644 --- a/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs +++ b/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs @@ -53,9 +53,9 @@ namespace Vocaluxe.Lib.Sound int id = 0; foreach (DeviceInformation dev in devices) { - using (DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid)) + using (var ds = new DirectSoundCapture(dev.DriverGuid)) { - CRecordDevice device = new CRecordDevice {Driver = dev.DriverGuid.ToString(), ID = id, Name = dev.Description, Channels = ds.Capabilities.Channels}; + var device = new CRecordDevice {Driver = dev.DriverGuid.ToString(), ID = id, Name = dev.Description, Channels = ds.Capabilities.Channels}; if (device.Channels > 2) device.Channels = 2; //more are not supported in vocaluxe @@ -89,9 +89,9 @@ namespace Vocaluxe.Lib.Sound foreach (CBuffer buffer in _Buffer) buffer.Reset(); - bool[] active = new bool[_Devices.Count]; - Guid[] guid = new Guid[_Devices.Count]; - short[] channels = new short[_Devices.Count]; + var active = new bool[_Devices.Count]; + var guid = new Guid[_Devices.Count]; + var channels = new short[_Devices.Count]; for (int dev = 0; dev < _Devices.Count; dev++) { active[dev] = false; @@ -105,7 +105,7 @@ namespace Vocaluxe.Lib.Sound { if (active[i]) { - CSoundCardSource source = new CSoundCardSource(guid[i], channels[i]) {SampleRateKhz = 44.1}; + var source = new CSoundCardSource(guid[i], channels[i]) {SampleRateKhz = 44.1}; source.SampleDataReady += _OnDataReady; source.Start(); @@ -209,8 +209,8 @@ namespace Vocaluxe.Lib.Sound { if (_Initialized) { - byte[] leftBuffer = new byte[e.Data.Length / 2]; - byte[] rightBuffer = new byte[e.Data.Length / 2]; + var leftBuffer = new byte[e.Data.Length / 2]; + var rightBuffer = new byte[e.Data.Length / 2]; //[]: Sample, L: Left channel R: Right channel //[LR][LR][LR][LR][LR][LR] @@ -318,7 +318,7 @@ namespace Vocaluxe.Lib.Sound for (int i = 0; i < _BufferPortionCount; i++) { - NotificationPosition notification = new NotificationPosition {Offset = _BufferPortionCount - 1 + (_BufferPortionSize * i), Event = new AutoResetEvent(false)}; + var notification = new NotificationPosition {Offset = _BufferPortionCount - 1 + (_BufferPortionSize * i), Event = new AutoResetEvent(false)}; _Notifications.Add(notification); } @@ -371,7 +371,7 @@ namespace Vocaluxe.Lib.Sound int bufferPortionSamples = _BufferPortionSize / sizeof(byte); // Buffer type must match this.waveFormat.FormatTag and this.waveFormat.BitsPerSample - byte[] bufferPortion = new byte[bufferPortionSamples]; + var bufferPortion = new byte[bufferPortionSamples]; _CaptureBuffer.Start(true); diff --git a/Vocaluxe/Lib/Sound/CGstreamerAudio.cs b/Vocaluxe/Lib/Sound/CGstreamerAudio.cs index 998bdbde..cdc53b45 100644 --- a/Vocaluxe/Lib/Sound/CGstreamerAudio.cs +++ b/Vocaluxe/Lib/Sound/CGstreamerAudio.cs @@ -65,14 +65,14 @@ namespace Vocaluxe.Lib.Sound public int Load(string media) { - Uri u = new Uri(media); + var u = new Uri(media); int i = CGstreamerAudioWrapper.Load(u.AbsoluteUri); return i; } public int Load(string media, bool prescan) { - Uri u = new Uri(media); + var u = new Uri(media); int i = CGstreamerAudioWrapper.Load(u.AbsoluteUri, prescan); return i; } diff --git a/Vocaluxe/Lib/Sound/COpenALPlay.cs b/Vocaluxe/Lib/Sound/COpenALPlay.cs index 36017220..849a484a 100644 --- a/Vocaluxe/Lib/Sound/COpenALPlay.cs +++ b/Vocaluxe/Lib/Sound/COpenALPlay.cs @@ -106,8 +106,8 @@ namespace Vocaluxe.Lib.Sound public int Load(string media, bool prescan) { - SAudioStreams stream = new SAudioStreams(0); - COpenAlStream decoder = new COpenAlStream(); + var stream = new SAudioStreams(0); + var decoder = new COpenAlStream(); if (decoder.Open(media) > -1) { @@ -595,7 +595,7 @@ namespace Vocaluxe.Lib.Sound _CurrentTime = 0f; _Timer.Reset(); - SAudioStreams stream = new SAudioStreams(0) {Handle = _Buffers[0]}; + var stream = new SAudioStreams(0) {Handle = _Buffers[0]}; if (stream.Handle != 0) { @@ -782,7 +782,7 @@ namespace Vocaluxe.Lib.Sound return; } - byte[] buf = new byte[_BufferSize]; + var buf = new byte[_BufferSize]; lock (_MutexData) { @@ -793,7 +793,7 @@ namespace Vocaluxe.Lib.Sound _Data.Read(buf); - byte[] b = new byte[2]; + var b = new byte[2]; for (int i = 0; i < buf.Length; i += _ByteCount) { b[0] = buf[i]; diff --git a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs index 9c195495..7cf0c4f0 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs @@ -91,8 +91,8 @@ namespace Vocaluxe.Lib.Sound public int Load(string media, bool prescan) { - SAudioStreams stream = new SAudioStreams(0); - CPortAudioStream decoder = new CPortAudioStream(); + var stream = new SAudioStreams(0); + var decoder = new CPortAudioStream(); if (decoder.Open(media) > -1) { @@ -599,11 +599,11 @@ namespace Vocaluxe.Lib.Sound _CurrentTime = 0f; _SyncTimer.Time = _CurrentTime; - SAudioStreams stream = new SAudioStreams(0); + var stream = new SAudioStreams(0); - IntPtr data = new IntPtr(0); + var data = new IntPtr(0); - CPortAudio.SPaStreamParameters outputParams = new CPortAudio.SPaStreamParameters + var outputParams = new CPortAudio.SPaStreamParameters { ChannelCount = format.ChannelCount, Device = _ApiInfo.DefaultOutputDevice, @@ -611,7 +611,7 @@ namespace Vocaluxe.Lib.Sound SuggestedLatency = _OutputDeviceInfo.DefaultLowOutputLatency }; - uint bufsize = (uint)CConfig.AudioBufferSize; + var bufsize = (uint)CConfig.AudioBufferSize; lock (_Mutex) { _ErrorCheck("OpenDefaultStream (playback)", CPortAudio.Pa_OpenStream( @@ -797,7 +797,7 @@ namespace Vocaluxe.Lib.Sound CPortAudio.EPaStreamCallbackFlags statusFlags, IntPtr userData) { - byte[] buf = new byte[frameCount * _ByteCount]; + var buf = new byte[frameCount * _ByteCount]; if (_Paused) { @@ -818,7 +818,7 @@ namespace Vocaluxe.Lib.Sound { _Data.Read(buf); - byte[] b = new byte[2]; + var b = new byte[2]; for (int i = 0; i < buf.Length; i += _ByteCount) { b[0] = buf[i]; diff --git a/Vocaluxe/Lib/Sound/CPortAudioRecord.cs b/Vocaluxe/Lib/Sound/CPortAudioRecord.cs index 0f51fa31..a4ae35c4 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioRecord.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioRecord.cs @@ -73,7 +73,7 @@ namespace Vocaluxe.Lib.Sound CPortAudio.SPaDeviceInfo info = CPortAudio.PaGetDeviceInfo(i); if (info.HostApi == hostAPI && info.MaxInputChannels > 0) { - CRecordDevice dev = new CRecordDevice {ID = i, Name = info.Name, Driver = info.Name + i, Channels = info.MaxInputChannels}; + var dev = new CRecordDevice {ID = i, Name = info.Name, Driver = info.Name + i, Channels = info.MaxInputChannels}; if (dev.Channels > 2) dev.Channels = 2; //more are not supported in vocaluxe @@ -123,7 +123,7 @@ namespace Vocaluxe.Lib.Sound for (int i = 0; i < _RecHandle.Length; i++) _RecHandle[i] = IntPtr.Zero; - bool[] active = new bool[_Devices.Count]; + var active = new bool[_Devices.Count]; for (int dev = 0; dev < _Devices.Count; dev++) { active[dev] = false; @@ -135,7 +135,7 @@ namespace Vocaluxe.Lib.Sound { if (active[i]) { - CPortAudio.SPaStreamParameters inputParams = new CPortAudio.SPaStreamParameters + var inputParams = new CPortAudio.SPaStreamParameters { ChannelCount = _Devices[i].Channels, Device = _Devices[i].ID, @@ -283,9 +283,9 @@ namespace Vocaluxe.Lib.Sound frameCount *= 4; if (frameCount > 0 && input != IntPtr.Zero) { - byte[] recbuffer = new byte[frameCount]; - byte[] leftBuffer = new byte[frameCount / 2]; - byte[] rightBuffer = new byte[frameCount / 2]; + var recbuffer = new byte[frameCount]; + var leftBuffer = new byte[frameCount / 2]; + var rightBuffer = new byte[frameCount / 2]; // copy from managed to unmanaged memory Marshal.Copy(input, recbuffer, 0, (int)frameCount); diff --git a/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs b/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs index 15e06b56..a536a35e 100644 --- a/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs +++ b/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs @@ -124,7 +124,7 @@ namespace Vocaluxe.Lib.Sound.Decoder public float GetLength() { - return _FileOpened ? _Instance.Info.Duration / 1000f:0; + return _FileOpened ? _Instance.Info.Duration / 1000f : 0; } public void SetPosition(float time) @@ -134,7 +134,7 @@ namespace Vocaluxe.Lib.Sound.Decoder try { - CAcinerella.AcSeek(_Audiodecoder, (time>_CurrentTime)?0:-1, (Int64)(time * 1000f)); + CAcinerella.AcSeek(_Audiodecoder, (time > _CurrentTime) ? 0 : -1, (Int64)(time * 1000f)); } catch (Exception) { @@ -161,7 +161,7 @@ namespace Vocaluxe.Lib.Sound.Decoder if (frameFinished) { - SACDecoder decoder = (SACDecoder)Marshal.PtrToStructure(_Audiodecoder, typeof(SACDecoder)); + var decoder = (SACDecoder)Marshal.PtrToStructure(_Audiodecoder, typeof(SACDecoder)); timeStamp = (float)decoder.Timecode; _CurrentTime = timeStamp; diff --git a/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs b/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs index bfc814c9..5da15ff1 100644 --- a/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs +++ b/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs @@ -363,7 +363,7 @@ namespace Vocaluxe.Lib.Video.Acinerella { lock (_Lock) { - return _ac_decode_package(pAcPackage, pAcDecoder)!=0; + return _ac_decode_package(pAcPackage, pAcDecoder) != 0; } } @@ -374,7 +374,7 @@ namespace Vocaluxe.Lib.Video.Acinerella { lock (_Lock) { - return _ac_get_audio_frame(pAcInstance, pAcDecoder)!=0; + return _ac_get_audio_frame(pAcInstance, pAcDecoder) != 0; } } @@ -385,7 +385,7 @@ namespace Vocaluxe.Lib.Video.Acinerella { lock (_Lock) { - return _ac_get_frame(pAcInstance, pAcDecoder)!=0; + return _ac_get_frame(pAcInstance, pAcDecoder) != 0; } } @@ -396,7 +396,7 @@ namespace Vocaluxe.Lib.Video.Acinerella { lock (_Lock) { - return _ac_skip_frames(pAcInstance, pAcDecoder, num)!=0; + return _ac_skip_frames(pAcInstance, pAcDecoder, num) != 0; } } @@ -412,7 +412,7 @@ namespace Vocaluxe.Lib.Video.Acinerella { lock (_Lock) { - return _ac_seek(pAcDecoder, dir, targetPos)!=0; + return _ac_seek(pAcDecoder, dir, targetPos) != 0; } } diff --git a/Vocaluxe/Lib/Video/Acinerella/CDecoder.cs b/Vocaluxe/Lib/Video/Acinerella/CDecoder.cs index 5ba37c91..56509684 100644 --- a/Vocaluxe/Lib/Video/Acinerella/CDecoder.cs +++ b/Vocaluxe/Lib/Video/Acinerella/CDecoder.cs @@ -1,3 +1,22 @@ +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + using System; using System.Diagnostics; using System.IO; diff --git a/Vocaluxe/Lib/Video/Acinerella/CFramebuffer.cs b/Vocaluxe/Lib/Video/Acinerella/CFramebuffer.cs index 8aaa6287..aea38207 100644 --- a/Vocaluxe/Lib/Video/Acinerella/CFramebuffer.cs +++ b/Vocaluxe/Lib/Video/Acinerella/CFramebuffer.cs @@ -1,4 +1,23 @@ -using System; +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + +using System; using System.Runtime.InteropServices; namespace Vocaluxe.Lib.Video.Acinerella diff --git a/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs b/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs index f37b0dc8..53d88c4e 100644 --- a/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs +++ b/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs @@ -55,7 +55,7 @@ namespace Vocaluxe.Lib.Video int i = -1; try { - Uri u = new Uri(videoFileName); + var u = new Uri(videoFileName); i = CGstreamerVideoWrapper.LoadVideo(u.AbsoluteUri); return i; } diff --git a/Vocaluxe/Lib/Webcam/CAForgeNet.cs b/Vocaluxe/Lib/Webcam/CAForgeNet.cs index 2fb2ff6e..f7e400c7 100644 --- a/Vocaluxe/Lib/Webcam/CAForgeNet.cs +++ b/Vocaluxe/Lib/Webcam/CAForgeNet.cs @@ -65,7 +65,7 @@ namespace Vocaluxe.Lib.Webcam { lock (_MutexData) { - Bitmap bmp = new Bitmap(_Width, _Height); + var bmp = new Bitmap(_Width, _Height); BitmapData bitmapdata = bmp.LockBits(new Rectangle(0, 0, _Width, _Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); Marshal.Copy(_Data, 0, bitmapdata.Scan0, _Data.Length); bmp.UnlockBits(bitmapdata); @@ -80,17 +80,17 @@ namespace Vocaluxe.Lib.Webcam _WebcamDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); foreach (FilterInfo info in _WebcamDevices) { - SWebcamDevice device = new SWebcamDevice + var device = new SWebcamDevice { Name = info.Name, MonikerString = info.MonikerString, Capabilities = new List() }; - VideoCaptureDevice tmpdev = new VideoCaptureDevice(info.MonikerString); + var tmpdev = new VideoCaptureDevice(info.MonikerString); foreach (VideoCapabilities capabilities in tmpdev.VideoCapabilities) { - SCapabilities item = new SCapabilities + var item = new SCapabilities { Framerate = capabilities.FrameRate, Height = capabilities.FrameSize.Height, diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 63758783..77c4dafc 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -253,7 +253,7 @@ namespace Vocaluxe [HandleProcessCorruptedStateExceptions] private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) { - Exception e = (Exception)args.ExceptionObject; + var e = (Exception)args.ExceptionObject; string stackTrace = ""; try { diff --git a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs index 1856b90d..c3ba6ece 100644 --- a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs +++ b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs @@ -201,7 +201,7 @@ namespace Vocaluxe.Screens CGame.Reset(); CGame.ClearSongs(); - EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; + var gm = EGameMode.TR_GAMEMODE_NORMAL; if (CSongs.AllSongs[songNr].IsDuet) gm = EGameMode.TR_GAMEMODE_DUET; diff --git a/Vocaluxe/Screens/CScreenCredits.cs b/Vocaluxe/Screens/CScreenCredits.cs index c73a5df1..c2958750 100644 --- a/Vocaluxe/Screens/CScreenCredits.cs +++ b/Vocaluxe/Screens/CScreenCredits.cs @@ -293,12 +293,12 @@ 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) {Z = -5}; + var particleRect = new SRectF(-1, -1, partRectSize, partRectSize, -6); + var imgDotRect = new SRectF(particleRect) {Z = -5}; CStatic imgDot = GetNewStatic(texDot, new SColorF(1, 1, 1, 1), imgDotRect); CParticleEffect particle = _GetStarParticles(partCount, isRight, particleRect, bigParticles); - CCreditName credit = new CCreditName(image, imgDot, particle, particleOffsetX, particleOffsetY); + var credit = new CCreditName(image, imgDot, particle, particleOffsetX, particleOffsetY); if (isRight) { @@ -323,8 +323,8 @@ namespace Vocaluxe.Screens new SRectF((float)(CSettings.RenderW - _TexLogo.OrigSize.Width) / 2, -270, _TexLogo.OrigSize.Width, _TexLogo.OrigSize.Height, -2)); //Little stars for logo - int numstars = (int)(_Logo.Rect.W * 0.25f / 2f); - SRectF partRect = new SRectF(_Logo.Rect.X, _Logo.Rect.Y, _Logo.Rect.W, _Logo.Rect.H, -1); + var numstars = (int)(_Logo.Rect.W * 0.25f / 2f); + var partRect = new SRectF(_Logo.Rect.X, _Logo.Rect.Y, _Logo.Rect.W, _Logo.Rect.H, -1); _StarsRed = _GetStarParticles(numstars, true, partRect, true); _StarsBlue = _GetStarParticles(numstars, false, partRect, true); diff --git a/Vocaluxe/Screens/CScreenHighscore.cs b/Vocaluxe/Screens/CScreenHighscore.cs index 56e70ecf..b6b379c3 100644 --- a/Vocaluxe/Screens/CScreenHighscore.cs +++ b/Vocaluxe/Screens/CScreenHighscore.cs @@ -56,7 +56,7 @@ namespace Vocaluxe.Screens { base.Init(); - List texts = new List {_TextSongName, _TextSongMode}; + var texts = new List {_TextSongName, _TextSongMode}; _TextNumber = new string[_NumEntrys]; for (int i = 0; i < _NumEntrys; i++) diff --git a/Vocaluxe/Screens/CScreenOptionsRecord.cs b/Vocaluxe/Screens/CScreenOptionsRecord.cs index 36a7f66d..5bacee52 100644 --- a/Vocaluxe/Screens/CScreenOptionsRecord.cs +++ b/Vocaluxe/Screens/CScreenOptionsRecord.cs @@ -75,7 +75,7 @@ namespace Vocaluxe.Screens { base.Init(); - List values = new List {_StaticWarning}; + var values = new List {_StaticWarning}; values.AddRange(_StaticEnergyChannel); _ThemeStatics = values.ToArray(); @@ -369,11 +369,11 @@ namespace Vocaluxe.Screens { if (_ChannelEnergy[i] > 0f) { - SRectF rect = new SRectF(_Statics[_StaticEnergyChannel[i]].Rect.X, - _Statics[_StaticEnergyChannel[i]].Rect.Y, - _Statics[_StaticEnergyChannel[i]].Rect.W * _ChannelEnergy[i], - _Statics[_StaticEnergyChannel[i]].Rect.H, - _Statics[_StaticEnergyChannel[i]].Rect.Z); + var rect = new SRectF(_Statics[_StaticEnergyChannel[i]].Rect.X, + _Statics[_StaticEnergyChannel[i]].Rect.Y, + _Statics[_StaticEnergyChannel[i]].Rect.W * _ChannelEnergy[i], + _Statics[_StaticEnergyChannel[i]].Rect.H, + _Statics[_StaticEnergyChannel[i]].Rect.Z); CDraw.DrawTexture(_Statics[_StaticEnergyChannel[i]].Texture, _Statics[_StaticEnergyChannel[i]].Rect, new SColorF(1f, 1f, 1f, 1f), rect); @@ -465,7 +465,7 @@ namespace Vocaluxe.Screens private bool _CheckMicConfig() { - bool[] isSet = new bool[CSettings.MaxNumPlayer]; + var isSet = new bool[CSettings.MaxNumPlayer]; for (int i = 0; i < CSettings.MaxNumPlayer; i++) isSet[i] = false; diff --git a/Vocaluxe/Screens/CScreenOptionsSound.cs b/Vocaluxe/Screens/CScreenOptionsSound.cs index ef809fbb..9eb19060 100644 --- a/Vocaluxe/Screens/CScreenOptionsSound.cs +++ b/Vocaluxe/Screens/CScreenOptionsSound.cs @@ -154,8 +154,8 @@ namespace Vocaluxe.Screens CConfig.PreviewMusicVolume = _SelectSlides[_SelectSlidePreviewMusicVolume].Selection * 5; CConfig.SaveConfig(); - EOffOn newOffOn = (EOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection; - EBackgroundMusicSource newSource = (EBackgroundMusicSource)_SelectSlides[_SelectSlideBackgroundMusicSource].Selection; + var newOffOn = (EOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection; + var newSource = (EBackgroundMusicSource)_SelectSlides[_SelectSlideBackgroundMusicSource].Selection; float newVolume = _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection * 5; CBackgroundMusic.CheckAndApplyConfig(newOffOn, newSource, newVolume); diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index c697207d..aece36cf 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -60,13 +60,13 @@ namespace Vocaluxe.Screens { base.Init(); - List texts = new List {_TextSong}; + var texts = new List {_TextSong}; _BuildTextStrings(ref texts); _ThemeTexts = texts.ToArray(); - List statics = new List(); + var statics = new List(); _BuildStaticStrings(ref statics); _ThemeStatics = statics.ToArray(); @@ -131,7 +131,7 @@ namespace Vocaluxe.Screens public override bool UpdateGame() { - SPlayer[] players = new SPlayer[CGame.NumPlayer]; + var players = new SPlayer[CGame.NumPlayer]; if (_Round != 0) players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); else @@ -156,7 +156,7 @@ namespace Vocaluxe.Screens if (_StaticPointsBarDrawnPoints[p] > players[p].Points) _StaticPointsBarDrawnPoints[p] = players[p].Points; - string direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue(); + var direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue(); if (direction.ToLower() == "vertical") { _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.W = ((float)_StaticPointsBarDrawnPoints[p]) * @@ -264,7 +264,7 @@ namespace Vocaluxe.Screens private void _UpdateRatings() { CSong song = null; - SPlayer[] players = new SPlayer[CGame.NumPlayer]; + var players = new SPlayer[CGame.NumPlayer]; if (_Round != 0) { song = CGame.GetSong(_Round); @@ -325,7 +325,7 @@ namespace Vocaluxe.Screens _Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points))); _StaticPointsBarDrawnPoints[p] = 0.0; - string direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue(); + var direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue(); if (direction.ToLower() == "vertical") _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.W = 0; else diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index fcd8d78c..a77c8a6c 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -546,13 +546,13 @@ namespace Vocaluxe.Screens public override void ApplyVolume() { - if(_CurrentStream > -1) + if (_CurrentStream > -1) CSound.SetStreamVolumeMax(_CurrentStream, CConfig.GameMusicVolume); } private void _CloseSong() { - if(_CurrentStream > -1) + if (_CurrentStream > -1) CSound.FadeAndStop(_CurrentStream, 0f, 0.5f); CSound.RecordStop(); if (_CurrentVideo != -1) diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 1a614ba0..81568658 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -105,7 +105,7 @@ namespace Vocaluxe.Screens _ButtonsJoker.Clear(); for (int i = 0; i < CSettings.MaxNumPlayer; i++) _ButtonsJoker.Add("ButtonJoker" + (i + 1)); - List blist = new List(); + var blist = new List(); blist.AddRange(_ButtonsJoker); blist.Add(_ButtonOptionsClose); blist.Add(_ButtonOptionsPlaylist); @@ -123,7 +123,7 @@ namespace Vocaluxe.Screens _TextsPlayer.Clear(); for (int i = 0; i < CSettings.MaxNumPlayer; i++) _TextsPlayer.Add("TextPlayer" + (i + 1)); - List tlist = new List(); + var tlist = new List(); tlist.AddRange(_TextsPlayer); tlist.Add(_TextCategory); tlist.Add(_TextSelection); @@ -172,7 +172,7 @@ namespace Vocaluxe.Screens { if (_SearchActive) _ApplyNewSearchFilter(_SearchText + keyEvent.Unicode); - else if(!_Sso.Selection.PartyMode) + else if (!_Sso.Selection.PartyMode) { _JumpTo(keyEvent.Unicode); return true; @@ -862,7 +862,7 @@ namespace Vocaluxe.Screens CGame.Reset(); CGame.ClearSongs(); - List ids = new List(); + var ids = new List(); for (int i = 0; i < CSongs.AllSongs.Count; i++) ids.Add(i); @@ -870,7 +870,7 @@ namespace Vocaluxe.Screens { int songNr = ids[CGame.Rand.Next(ids.Count)]; - EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; + var gm = EGameMode.TR_GAMEMODE_NORMAL; if (CSongs.AllSongs[songNr].IsDuet) gm = EGameMode.TR_GAMEMODE_DUET; @@ -894,7 +894,7 @@ namespace Vocaluxe.Screens { int songNr = ids[CGame.Rand.Next(ids.Count)]; - EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; + var gm = EGameMode.TR_GAMEMODE_NORMAL; if (CSongs.AllSongs[songNr].IsDuet) gm = EGameMode.TR_GAMEMODE_DUET; @@ -1009,10 +1009,10 @@ namespace Vocaluxe.Screens int curSelected = _SongMenus[_SongMenu].GetActualSelection(); bool firstLevel = CConfig.Tabs == EOffOn.TR_CONFIG_OFF && CSongs.IsInCategory; bool secondSort = CConfig.Tabs == EOffOn.TR_CONFIG_ON && - (CConfig.SongSorting == ESongSorting.TR_CONFIG_ARTIST || - CConfig.SongSorting == ESongSorting.TR_CONFIG_ARTIST_LETTER || - CConfig.SongSorting == ESongSorting.TR_CONFIG_FOLDER || - CConfig.SongSorting == ESongSorting.TR_CONFIG_TITLE_LETTER); + (CConfig.SongSorting == ESongSorting.TR_CONFIG_ARTIST || + CConfig.SongSorting == ESongSorting.TR_CONFIG_ARTIST_LETTER || + CConfig.SongSorting == ESongSorting.TR_CONFIG_FOLDER || + CConfig.SongSorting == ESongSorting.TR_CONFIG_TITLE_LETTER); if (firstLevel && !secondSort) { //TODO: What's to do with multiple tags? @@ -1029,7 +1029,7 @@ namespace Vocaluxe.Screens visibleID = _FindIndex(songs, start, element => element.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); break; - //TODO: Does this make sense? Maybe we should deactivate this for years? You could only jump between 1 and 2 + //TODO: Does this make sense? Maybe we should deactivate this for years? You could only jump between 1 and 2 case ESongSorting.TR_CONFIG_YEAR: case ESongSorting.TR_CONFIG_DECADE: if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Year.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)) @@ -1076,7 +1076,7 @@ namespace Vocaluxe.Screens if (visibleID > -1) _SongMenus[_SongMenu].SetSelectedSong(visibleID); } - else if(!CSongs.IsInCategory) + else if (!CSongs.IsInCategory) { ReadOnlyCollection categories = CSongs.Categories; int ct = categories.Count; @@ -1166,7 +1166,7 @@ namespace Vocaluxe.Screens private void _ShowSongOptionsSong() { - EGameMode lastMode = EGameMode.TR_GAMEMODE_NORMAL; + var lastMode = EGameMode.TR_GAMEMODE_NORMAL; if (_AvailableGameModes.Count > 0) lastMode = _AvailableGameModes[_SelectSlides[_SelectSlideOptionsMode].Selection]; _AvailableGameModes.Clear(); diff --git a/Vocaluxe/Screens/CScreenTest.cs b/Vocaluxe/Screens/CScreenTest.cs index 52a6ed1f..15249fc3 100644 --- a/Vocaluxe/Screens/CScreenTest.cs +++ b/Vocaluxe/Screens/CScreenTest.cs @@ -41,8 +41,8 @@ namespace Vocaluxe.Screens { base.Init(); const string test = "Ö ÄÜabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890"; - SColorF color = new SColorF(1, 0, 0, 1); - CText text = new CText(10, 50, 1, 32, 0, EAlignment.Left, EStyle.Normal, "Normal", color, "jÄNormal Text" + test, -1, 26, 1); + var color = new SColorF(1, 0, 0, 1); + var text = new CText(10, 50, 1, 32, 0, EAlignment.Left, EStyle.Normal, "Normal", color, "jÄNormal Text" + test, -1, 26, 1); _AddText(text); text = new CText(10, 90, 1, 32, 0, EAlignment.Left, EStyle.Bold, "Normal", color, "jÄBold Text" + test, -1, 26, 1); _AddText(text); diff --git a/VocaluxeLib/CHelper.cs b/VocaluxeLib/CHelper.cs index af49179f..5fd2947b 100644 --- a/VocaluxeLib/CHelper.cs +++ b/VocaluxeLib/CHelper.cs @@ -69,7 +69,7 @@ namespace VocaluxeLib public static int TryReadInt(StreamReader sr) { string value = String.Empty; - + try { int tmp = sr.Peek(); @@ -79,7 +79,7 @@ namespace VocaluxeLib if (sr.EndOfStream) break; - char chr = (char)sr.Read(); + var chr = (char)sr.Read(); value += chr.ToString(); tmp = sr.Peek(); } @@ -141,8 +141,8 @@ namespace VocaluxeLib public static List ListFiles(string path, string cast, bool recursive = false, bool fullpath = false) { - List files = new List(); - DirectoryInfo dir = new DirectoryInfo(path); + var files = new List(); + var dir = new DirectoryInfo(path); try { diff --git a/VocaluxeLib/CXMLReader.cs b/VocaluxeLib/CXMLReader.cs index 5b295bcb..383db367 100644 --- a/VocaluxeLib/CXMLReader.cs +++ b/VocaluxeLib/CXMLReader.cs @@ -37,7 +37,7 @@ namespace VocaluxeLib private CXMLReader(string uri) { _FileName = uri; - XPathDocument xmlDoc = new XPathDocument(uri); + var xmlDoc = new XPathDocument(uri); _Navigator = xmlDoc.CreateNavigator(); } @@ -123,7 +123,7 @@ namespace VocaluxeLib public List GetValues(string cast) { - List values = new List(); + var values = new List(); _Navigator.MoveToRoot(); _Navigator.MoveToFirstChild(); @@ -143,7 +143,7 @@ namespace VocaluxeLib public IEnumerable GetAttributes(string cast, string attribute) { - List values = new List(); + var values = new List(); _Navigator.MoveToRoot(); _Navigator.MoveToFirstChild(); diff --git a/VocaluxeLib/Game/CPoints.cs b/VocaluxeLib/Game/CPoints.cs index 31afe16c..6837e356 100644 --- a/VocaluxeLib/Game/CPoints.cs +++ b/VocaluxeLib/Game/CPoints.cs @@ -80,7 +80,7 @@ namespace VocaluxeLib.Game if (round >= NumRounds) return new SPlayer[1]; - SPlayer[] players = new SPlayer[numPlayer]; + var players = new SPlayer[numPlayer]; for (int p = 0; p < players.Length; p++) { diff --git a/VocaluxeLib/Menu/CBackground.cs b/VocaluxeLib/Menu/CBackground.cs index 068ea9fc..0027536a 100644 --- a/VocaluxeLib/Menu/CBackground.cs +++ b/VocaluxeLib/Menu/CBackground.cs @@ -196,7 +196,7 @@ namespace VocaluxeLib.Menu #region internal private void _DrawColor() { - SRectF bounds = new SRectF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), CBase.Settings.GetZFar() / 4); + var bounds = new SRectF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), CBase.Settings.GetZFar() / 4); CBase.Drawing.DrawColor(Color, bounds); } @@ -206,7 +206,7 @@ namespace VocaluxeLib.Menu CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); if (texture != null) { - RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); + var bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); RectangleF rect; CHelper.SetRect(bounds, out rect, texture.OrigAspect, EAspect.Crop); @@ -221,7 +221,7 @@ namespace VocaluxeLib.Menu CTexture videoTexture = CBase.Theme.GetSkinVideoTexture(_Theme.VideoName, _PartyModeID); if (videoTexture != null) { - RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); + var bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); RectangleF rect; CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop); @@ -236,7 +236,7 @@ namespace VocaluxeLib.Menu CTexture videoTexture = CBase.BackgroundMusic.GetVideoTexture(); if (videoTexture != null) { - RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); + var bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); RectangleF rect; CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop); diff --git a/VocaluxeLib/Menu/CEqualizer.cs b/VocaluxeLib/Menu/CEqualizer.cs index c65b42c0..94df7eba 100644 --- a/VocaluxeLib/Menu/CEqualizer.cs +++ b/VocaluxeLib/Menu/CEqualizer.cs @@ -258,7 +258,7 @@ namespace VocaluxeLib.Menu for (int i = 0; i < _Bars.Length; i++) { - SRectF bar = new SRectF(Rect.X + dx * i, Rect.Y + Rect.H - _Bars[i] * Rect.H, dx - Space, _Bars[i] * Rect.H, Rect.Z); + var bar = new SRectF(Rect.X + dx * i, Rect.Y + Rect.H - _Bars[i] * Rect.H, dx - Space, _Bars[i] * Rect.H, Rect.Z); SColorF color = Color; if (i == max) color = MaxColor; diff --git a/VocaluxeLib/Menu/CLyric.cs b/VocaluxeLib/Menu/CLyric.cs index cdd1b1a8..a5f2af2a 100644 --- a/VocaluxeLib/Menu/CLyric.cs +++ b/VocaluxeLib/Menu/CLyric.cs @@ -208,7 +208,7 @@ namespace VocaluxeLib.Menu _Width = 0f; foreach (CSongNote note in line.Notes) { - SNote n = new SNote {Text = note.Text, StartBeat = note.StartBeat, EndBeat = note.EndBeat, Duration = note.Duration, Type = note.NoteType}; + var n = new SNote {Text = note.Text, StartBeat = note.StartBeat, EndBeat = note.EndBeat, Duration = note.Duration, Type = note.NoteType}; _Text.Text = note.Text; _Text.Style = EStyle.Bold; diff --git a/VocaluxeLib/Menu/CMenu.cs b/VocaluxeLib/Menu/CMenu.cs index 4a3021b9..29e887ab 100644 --- a/VocaluxeLib/Menu/CMenu.cs +++ b/VocaluxeLib/Menu/CMenu.cs @@ -151,7 +151,7 @@ namespace VocaluxeLib.Menu { foreach (string elName in elements) { - T element = (T)Activator.CreateInstance(typeof(T), _PartyModeID); + var element = (T)Activator.CreateInstance(typeof(T), _PartyModeID); if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader, skinIndex)) addElementHandler(element, elName); else @@ -198,7 +198,7 @@ namespace VocaluxeLib.Menu if (_ThemePath == "") return; - XmlWriterSettings settings = new XmlWriterSettings {Indent = true, Encoding = Encoding.UTF8, ConformanceLevel = ConformanceLevel.Document}; + var settings = new XmlWriterSettings {Indent = true, Encoding = Encoding.UTF8, ConformanceLevel = ConformanceLevel.Document}; string file = Path.Combine(_ThemePath, ThemeName + ".xml"); using (XmlWriter writer = XmlWriter.Create(file, settings)) @@ -770,7 +770,7 @@ namespace VocaluxeLib.Menu if (_Interactions.Count <= 0) return; - List items = new List(); + var items = new List(); for (int i = 0; i < _Interactions.Count; i++) { @@ -779,7 +779,7 @@ namespace VocaluxeLib.Menu _Interactions[i].Type != EType.NameSelection && _Interactions[i].Type != EType.Text && _Interactions[i].Type != EType.SongMenu && _Interactions[i].Type != EType.Equalizer && _Interactions[i].Type != EType.Playlist && _Interactions[i].Type != EType.ParticleEffect)) continue; - SZSort zs = new SZSort {ID = i, Z = _GetZValue(i)}; + var zs = new SZSort {ID = i, Z = _GetZValue(i)}; items.Add(zs); } @@ -1105,10 +1105,10 @@ namespace VocaluxeLib.Menu /// private bool _NextInteraction(SKeyEvent key) { - SKeyEvent[] directions = new SKeyEvent[4]; - float[] distances = new float[4]; - int[] stages = new int[4]; - int[] elements = new int[4]; + var directions = new SKeyEvent[4]; + var distances = new float[4]; + var stages = new int[4]; + var elements = new int[4]; for (int i = 0; i < 4; i++) directions[i] = new SKeyEvent(); @@ -1248,11 +1248,11 @@ namespace VocaluxeLib.Menu private float _GetDistanceDirect(SKeyEvent key, SRectF actualRect, SRectF targetRect) { - PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); - PointF dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f); + var source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); + var dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f); - PointF vector = new PointF(dest.X - source.X, dest.Y - source.Y); - float distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); + var vector = new PointF(dest.X - source.X, dest.Y - source.Y); + var distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); bool inDirection = false; switch (key.Key) { @@ -1281,11 +1281,11 @@ namespace VocaluxeLib.Menu private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect) { - PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); - PointF dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f); + var source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); + var dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f); - PointF vector = new PointF(dest.X - source.X, dest.Y - source.Y); - float distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); + var vector = new PointF(dest.X - source.X, dest.Y - source.Y); + var distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); bool inDirection = false; switch (key.Key) { @@ -1584,7 +1584,7 @@ namespace VocaluxeLib.Menu private SRectF _GetRect(CInteraction interaction) { - SRectF result = new SRectF(); + var result = new SRectF(); switch (interaction.Type) { case EType.Button: @@ -1808,7 +1808,7 @@ namespace VocaluxeLib.Menu private void _LoadThemeBasics(CXMLReader xmlReader, int skinIndex) { // Backgrounds - CBackground background = new CBackground(_PartyModeID); + var background = new CBackground(_PartyModeID); int i = 1; while (background.LoadTheme("//root/" + ThemeName, "Background" + i, xmlReader, skinIndex)) { @@ -1818,7 +1818,7 @@ namespace VocaluxeLib.Menu } // Statics - CStatic stat = new CStatic(_PartyModeID); + var stat = new CStatic(_PartyModeID); i = 1; while (stat.LoadTheme("//root/" + ThemeName, "Static" + i, xmlReader, skinIndex)) { @@ -1828,7 +1828,7 @@ namespace VocaluxeLib.Menu } // Texts - CText text = new CText(_PartyModeID); + var text = new CText(_PartyModeID); i = 1; while (text.LoadTheme("//root/" + ThemeName, "Text" + i, xmlReader, skinIndex)) { @@ -1838,7 +1838,7 @@ namespace VocaluxeLib.Menu } // ParticleEffects - CParticleEffect partef = new CParticleEffect(_PartyModeID); + var partef = new CParticleEffect(_PartyModeID); i = 1; while (partef.LoadTheme("//root/" + ThemeName, "ParticleEffect" + i, xmlReader, skinIndex)) { diff --git a/VocaluxeLib/Menu/CObjectInteractions.cs b/VocaluxeLib/Menu/CObjectInteractions.cs index 1aafbb94..fb041cff 100644 --- a/VocaluxeLib/Menu/CObjectInteractions.cs +++ b/VocaluxeLib/Menu/CObjectInteractions.cs @@ -307,7 +307,7 @@ namespace VocaluxeLib.Menu if (_Interactions.Count <= 0) return; - List items = new List(); + var items = new List(); for (int i = 0; i < _Interactions.Count; i++) { @@ -320,7 +320,7 @@ namespace VocaluxeLib.Menu _Interactions[i].Type == EType.SongMenu || _Interactions[i].Type == EType.Equalizer)) { - SZSort zs = new SZSort {ID = i, Z = _GetZValue(i)}; + var zs = new SZSort {ID = i, Z = _GetZValue(i)}; items.Add(zs); } } @@ -613,10 +613,10 @@ namespace VocaluxeLib.Menu /// private bool _NextInteraction(SKeyEvent key) { - SKeyEvent[] directions = new SKeyEvent[4]; - float[] distances = new float[4]; - int[] stages = new int[4]; - int[] elements = new int[4]; + var directions = new SKeyEvent[4]; + var distances = new float[4]; + var stages = new int[4]; + var elements = new int[4]; for (int i = 0; i < 4; i++) directions[i] = new SKeyEvent(); @@ -756,11 +756,11 @@ namespace VocaluxeLib.Menu private float _GetDistanceDirect(SKeyEvent key, SRectF actualRect, SRectF targetRect) { - PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); - PointF dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f); + var source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); + var dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f); - PointF vector = new PointF(dest.X - source.X, dest.Y - source.Y); - float distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); + var vector = new PointF(dest.X - source.X, dest.Y - source.Y); + var distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); bool inDirection = false; switch (key.Key) { @@ -789,11 +789,11 @@ namespace VocaluxeLib.Menu private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect) { - PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); - PointF dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f); + var source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); + var dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f); - PointF vector = new PointF(dest.X - source.X, dest.Y - source.Y); - float distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); + var vector = new PointF(dest.X - source.X, dest.Y - source.Y); + var distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); bool inDirection = false; switch (key.Key) { @@ -1002,7 +1002,7 @@ namespace VocaluxeLib.Menu private SRectF _GetRect(int interaction) { - SRectF result = new SRectF(); + var result = new SRectF(); switch (_Interactions[interaction].Type) { case EType.Button: diff --git a/VocaluxeLib/Menu/CParticle.cs b/VocaluxeLib/Menu/CParticle.cs index 3e49902b..d6b58aaf 100644 --- a/VocaluxeLib/Menu/CParticle.cs +++ b/VocaluxeLib/Menu/CParticle.cs @@ -203,7 +203,7 @@ namespace VocaluxeLib.Menu break; case EParticleType.Snow: - int maxy = (int)Math.Round(CBase.Settings.GetRenderH() - _Size * 0.4f); + var maxy = (int)Math.Round(CBase.Settings.GetRenderH() - _Size * 0.4f); if (Math.Round(Y) < maxy) { @@ -525,8 +525,8 @@ namespace VocaluxeLib.Menu break; } - int w = (int)(Rect.W - size / 4f); - int h = (int)(Rect.H - size / 4f); + var w = (int)(Rect.W - size / 4f); + var h = (int)(Rect.H - size / 4f); if (w < 0) w = 0; diff --git a/VocaluxeLib/Menu/CPlaylist.cs b/VocaluxeLib/Menu/CPlaylist.cs index 33af9c65..efa54b11 100644 --- a/VocaluxeLib/Menu/CPlaylist.cs +++ b/VocaluxeLib/Menu/CPlaylist.cs @@ -631,7 +631,7 @@ namespace VocaluxeLib.Menu CBase.Playlist.MovePlaylistSongUp(ActivePlaylistID, CurrentPlaylistElement + Offset); UpdatePlaylist(); - SKeyEvent key = new SKeyEvent {Key = Keys.Up}; + var key = new SKeyEvent {Key = Keys.Up}; if (CurrentPlaylistElement > scrollLimit) { @@ -660,7 +660,7 @@ namespace VocaluxeLib.Menu CBase.Playlist.MovePlaylistSongDown(ActivePlaylistID, CurrentPlaylistElement + Offset); UpdatePlaylist(); - SKeyEvent key = new SKeyEvent {Key = Keys.Down}; + var key = new SKeyEvent {Key = Keys.Down}; if (CurrentPlaylistElement >= scrollLimit) { @@ -973,7 +973,7 @@ namespace VocaluxeLib.Menu if (!mouseEvent.LBH && DragAndDropSongID != -1) { - EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; + var gm = EGameMode.TR_GAMEMODE_NORMAL; CSong song = CBase.Songs.GetSongByID(DragAndDropSongID); if (song != null) @@ -1102,7 +1102,7 @@ namespace VocaluxeLib.Menu for (int i = 0; i < Math.Floor(Rect.H / _Theme.EntryHeight); i++) { - CPlaylistElement en = new CPlaylistElement + var 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)), @@ -1143,7 +1143,7 @@ namespace VocaluxeLib.Menu _PlaylistElementContents.Clear(); for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(ActivePlaylistID); i++) { - CPlaylistElementContent pec = new CPlaylistElementContent + var pec = new CPlaylistElementContent { SongID = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID, Modes = CBase.Songs.GetSongByID(CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID).AvailableGameModes, @@ -1162,7 +1162,7 @@ namespace VocaluxeLib.Menu _PlaylistElementContents.Clear(); for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(ActivePlaylistID); i++) { - CPlaylistElementContent pec = new CPlaylistElementContent {SongID = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID}; + var 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 b7f62571..0f6e5d69 100644 --- a/VocaluxeLib/Menu/CSelectSlide.cs +++ b/VocaluxeLib/Menu/CSelectSlide.cs @@ -750,10 +750,10 @@ namespace VocaluxeLib.Menu _ValueBounds.Clear(); for (int i = 0; i < numvis; i++) { - CText text = new CText(0, 0, 0, TextH, MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, TextColor, _ValueNames[i + offset], - _ValuePartyModeIDs[i + offset]); + var text = new CText(0, 0, 0, TextH, MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, TextColor, _ValueNames[i + offset], + _ValuePartyModeIDs[i + offset]); - SColorF alpha = new SColorF(1f, 1f, 1f, 0.35f); + var alpha = new SColorF(1f, 1f, 1f, 0.35f); if (i + offset == _Selection) { text.Color = SelTextColor; @@ -774,7 +774,7 @@ namespace VocaluxeLib.Menu if (WithTextures) { float dh = text.Y - Rect.Y - Rect.H * 0.1f; - SRectF rect = new SRectF(text.X - dh / 2, Rect.Y + Rect.H * 0.05f, dh, dh, Rect.Z); + var rect = new SRectF(text.X - dh / 2, Rect.Y + Rect.H * 0.05f, dh, dh, Rect.Z); CBase.Drawing.DrawTexture(_Textures[i + offset], rect, alpha); _ValueBounds.Add(rect); } diff --git a/VocaluxeLib/Menu/CText.cs b/VocaluxeLib/Menu/CText.cs index e326d5d8..a0c1e096 100644 --- a/VocaluxeLib/Menu/CText.cs +++ b/VocaluxeLib/Menu/CText.cs @@ -469,7 +469,7 @@ namespace VocaluxeLib.Menu CBase.Fonts.SetStyle(Style); SColorF currentColor = (Selected) ? SelColor : Color; - SColorF color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha); + var color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha); CBase.Fonts.DrawText(_Text, Rect.H, Rect.X, Rect.Y, Z, color); @@ -486,7 +486,7 @@ namespace VocaluxeLib.Menu CBase.Fonts.SetStyle(Style); SColorF currentColor = (Selected) ? SelColor : Color; - SColorF color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha); + var color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha); CBase.Fonts.DrawText(Text, Rect.H, Rect.X, Rect.Y, Z, color, begin, end); diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index be9dd224..f637bc1f 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -518,7 +518,10 @@ namespace VocaluxeLib.Menu.SongMenu _Active = active; } - public virtual bool IsMouseOverActualSelection(SMouseEvent mEvent) { return false; } + public virtual bool IsMouseOverActualSelection(SMouseEvent mEvent) + { + return false; + } public virtual int GetSelectedSong() { diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index d263fe92..55d0e2e3 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -92,9 +92,9 @@ namespace VocaluxeLib.Menu.SongMenu { for (int j = 0; j < _NumW; j++) { - SRectF rect = new SRectF(_Theme.SongMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW), - _Theme.SongMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); - CStatic tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect); + var rect = new SRectF(_Theme.SongMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW), + _Theme.SongMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); + var tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect); _Tiles.Add(tile); } } @@ -423,8 +423,8 @@ namespace VocaluxeLib.Menu.SongMenu time = song.Finish; time -= song.Start; - int min = (int)Math.Floor(time / 60f); - int sec = (int)(time - min * 60f); + var min = (int)Math.Floor(time / 60f); + var sec = (int)(time - min * 60f); _SongLength.Text = min.ToString("00") + ":" + sec.ToString("00"); } } @@ -458,11 +458,11 @@ namespace VocaluxeLib.Menu.SongMenu { if (_Vidtex.Color.A < 1) _CoverBig.Draw(1f, EAspect.Crop); - RectangleF bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H); + var bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H); RectangleF rect; CHelper.SetRect(bounds, out rect, _Vidtex.OrigAspect, EAspect.Crop); - SRectF vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z); - SRectF vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f); + var vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z); + var vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f); CBase.Drawing.DrawTexture(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds); CBase.Drawing.DrawTextureReflection(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); @@ -490,7 +490,7 @@ namespace VocaluxeLib.Menu.SongMenu CStatic selCov = GetSelectedSongCover(); if (selCov.Texture == null) return false; - SRectF rect = new SRectF(selCov.Rect.X - selCov.Rect.W*0.2f, selCov.Rect.Y - selCov.Rect.H*0.2f, selCov.Rect.W*1.2f, selCov.Rect.H*1.2f, selCov.Rect.Z); + var rect = new SRectF(selCov.Rect.X - selCov.Rect.W * 0.2f, selCov.Rect.Y - selCov.Rect.H * 0.2f, selCov.Rect.W * 1.2f, selCov.Rect.H * 1.2f, selCov.Rect.Z); return CHelper.IsInBounds(rect, mEvent); } @@ -679,8 +679,8 @@ namespace VocaluxeLib.Menu.SongMenu { for (int j = 0; j < _NumW; j++) { - SRectF rect = new SRectF(_Rect.X + j * (_TileW + _SpaceW), _Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); - CStatic tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect); + var rect = new SRectF(_Rect.X + j * (_TileW + _SpaceW), _Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); + var tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect); _Tiles.Add(tile); } } diff --git a/VocaluxeLib/Songs/CBaseNote.cs b/VocaluxeLib/Songs/CBaseNote.cs index a3a5691f..424eba86 100644 --- a/VocaluxeLib/Songs/CBaseNote.cs +++ b/VocaluxeLib/Songs/CBaseNote.cs @@ -1,7 +1,26 @@ -namespace VocaluxeLib.Songs +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + +namespace VocaluxeLib.Songs { /// - /// Base class for all note types + /// Base class for all note types /// public abstract class CBaseNote { diff --git a/VocaluxeLib/Songs/CLineBase.cs b/VocaluxeLib/Songs/CLineBase.cs index f2d700fe..ea6e14b7 100644 --- a/VocaluxeLib/Songs/CLineBase.cs +++ b/VocaluxeLib/Songs/CLineBase.cs @@ -1,4 +1,23 @@ -using System.Collections.Generic; +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + +using System.Collections.Generic; using System.Linq; namespace VocaluxeLib.Songs diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index 9da713e4..93ba8b78 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -149,7 +149,7 @@ namespace VocaluxeLib.Songs public int DataBaseSongID = -1; public string DateAdded = ""; - public int NumPlayed = 0; + public int NumPlayed; // Notes public readonly CNotes Notes = new CNotes(); @@ -158,7 +158,7 @@ namespace VocaluxeLib.Songs { get { - List gms = new List {IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL}; + var 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); @@ -172,7 +172,7 @@ namespace VocaluxeLib.Songs public static CSong LoadSong(string filePath) { - CSong song = new CSong(); + var song = new CSong(); return song.ReadHeader(filePath) ? song : null; } @@ -289,7 +289,7 @@ namespace VocaluxeLib.Songs FileName = Path.GetFileName(filePath); - EHeaderFlags headerFlags = new EHeaderFlags(); + var headerFlags = new EHeaderFlags(); StreamReader sr = null; try { @@ -737,7 +737,7 @@ namespace VocaluxeLib.Songs private bool _ParseNote(int player, ENoteType noteType, int start, int length, int tone, string text) { - CSongNote note = new CSongNote(start, length, tone, text, noteType); + var note = new CSongNote(start, length, tone, text, noteType); CVoice voice = Notes.GetVoice(player); return voice.AddNote(note); } @@ -745,7 +745,7 @@ namespace VocaluxeLib.Songs private void _NewSentence(int player, int start) { CVoice voice = Notes.GetVoice(player); - CSongLine line = new CSongLine {StartBeat = start}; + var line = new CSongLine {StartBeat = start}; voice.AddLine(line); } @@ -821,14 +821,14 @@ namespace VocaluxeLib.Songs List sentences = voice.Lines.Select(line => line.Points != 0 ? line.Lyrics : String.Empty).ToList(); // find equal sentences series - List series = new List(); + var series = new List(); for (int i = 0; i < voice.NumLines - 1; i++) { for (int j = i + 1; j < voice.NumLines; j++) { if (sentences[i] != sentences[j] || sentences[i] == "") continue; - SSeries tempSeries = new SSeries {Start = i, End = i}; + var tempSeries = new SSeries {Start = i, End = i}; int max; if (j + j - i > voice.NumLines) diff --git a/VocaluxeLib/Songs/CSongLine.cs b/VocaluxeLib/Songs/CSongLine.cs index 54f713d9..8617a7b8 100644 --- a/VocaluxeLib/Songs/CSongLine.cs +++ b/VocaluxeLib/Songs/CSongLine.cs @@ -1,4 +1,23 @@ -using System; +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + +using System; using System.Linq; namespace VocaluxeLib.Songs diff --git a/VocaluxeLib/Songs/CSongNote.cs b/VocaluxeLib/Songs/CSongNote.cs index d62dfeec..7e26cd54 100644 --- a/VocaluxeLib/Songs/CSongNote.cs +++ b/VocaluxeLib/Songs/CSongNote.cs @@ -1,7 +1,26 @@ -namespace VocaluxeLib.Songs +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + +namespace VocaluxeLib.Songs { /// - /// Class to represent a note in a song + /// Class to represent a note in a song /// public class CSongNote : CBaseNote { diff --git a/VocaluxeLib/Songs/CSungLine.cs b/VocaluxeLib/Songs/CSungLine.cs index bb06c393..1f53c719 100644 --- a/VocaluxeLib/Songs/CSungLine.cs +++ b/VocaluxeLib/Songs/CSungLine.cs @@ -1,4 +1,23 @@ -using System.Linq; +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + +using System.Linq; namespace VocaluxeLib.Songs { diff --git a/VocaluxeLib/Songs/CSungNote.cs b/VocaluxeLib/Songs/CSungNote.cs index eb0aa49a..40fbef2e 100644 --- a/VocaluxeLib/Songs/CSungNote.cs +++ b/VocaluxeLib/Songs/CSungNote.cs @@ -1,12 +1,31 @@ -namespace VocaluxeLib.Songs +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + +namespace VocaluxeLib.Songs { /// - /// Note that was sung by a player + /// Note that was sung by a player /// public class CSungNote : CBaseNote { /// - /// Constructor for a sung note that was not hit + /// Constructor for a sung note that was not hit /// /// /// @@ -18,7 +37,7 @@ } /// - /// Constructor for a sung note that hit the given note + /// Constructor for a sung note that hit the given note /// /// /// diff --git a/VocaluxeLib/Songs/CVoice.cs b/VocaluxeLib/Songs/CVoice.cs index 2b8ae897..72071b24 100644 --- a/VocaluxeLib/Songs/CVoice.cs +++ b/VocaluxeLib/Songs/CVoice.cs @@ -1,4 +1,23 @@ -using System.Collections.Generic; +#region license +// /* +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +// */ +#endregion + +using System.Collections.Generic; using System.Linq; namespace VocaluxeLib.Songs