Merge branch 'develop' of github.com:Flamefire/Vocaluxe into develop

Conflicts:
	Vocaluxe/Base/CPlaylists.cs
	Vocaluxe/Base/CProfiles.cs
	Vocaluxe/Base/CSettings.cs
This commit is contained in:
Florian Küpper committed 2013-09-15 15:15:10 +02:00
commit 0400a02bc1
89 files changed
+1396 -1250

No files matched your search

@@ -21,7 +21,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@@ -65,7 +64,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public int CompareTo(object obj) public int CompareTo(object obj)
{ {
CResultTableRow row = obj as CResultTableRow; var row = obj as CResultTableRow;
if (row != null) if (row != null)
{ {
int res = row.NumGamePoints.CompareTo(NumGamePoints); int res = row.NumGamePoints.CompareTo(NumGamePoints);
@@ -545,9 +544,7 @@ namespace VocaluxeLib.PartyModes.Challenge
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
{ {
if (c != null) if (c != null)
{
_ScreenSongOptions.Selection.TeamNames[i] = CBase.Profiles.GetPlayerName(_GameData.ProfileIDs[c.Player[i]]); _ScreenSongOptions.Selection.TeamNames[i] = CBase.Profiles.GetPlayerName(_GameData.ProfileIDs[c.Player[i]]);
}
else else
_ScreenSongOptions.Selection.TeamNames[i] = "foobar"; _ScreenSongOptions.Selection.TeamNames[i] = "foobar";
} }
@@ -559,7 +556,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
for (int i = 0; i < _GameData.NumPlayer; i++) 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); _GameData.ResultTable.Add(row);
} }
@@ -627,10 +624,10 @@ namespace VocaluxeLib.PartyModes.Challenge
private List<SStats> _GetPointsForPlayer(SPlayer[] results) private List<SStats> _GetPointsForPlayer(SPlayer[] results)
{ {
List<SStats> result = new List<SStats>(); var result = new List<SStats>();
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) 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); result.Add(stat);
} }
@@ -21,7 +21,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
namespace VocaluxeLib.PartyModes.Challenge namespace VocaluxeLib.PartyModes.Challenge
{ {
@@ -143,7 +142,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
try try
{ {
SDataToScreenMain data = (SDataToScreenMain)receivedData; var data = (SDataToScreenMain)receivedData;
_GameState = data; _GameState = data;
} }
catch (Exception e) catch (Exception e)
@@ -405,7 +404,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_RoundsTable = new List<CRoundsTableRow>(); _RoundsTable = new List<CRoundsTableRow>();
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()}; var rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()};
_RoundsTable.Add(rtr); _RoundsTable.Add(rtr);
} }
//Create statics and texts for rounds //Create statics and texts for rounds
@@ -457,7 +456,7 @@ namespace VocaluxeLib.PartyModes.Challenge
//Round-number //Round-number
roundRow.Number.X = numberX; roundRow.Number.X = numberX;
roundRow.Number.Y = numberY; 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++) for (int row = 0; row < numInnerRows; row++)
{ {
int num = (row + 1) * numPlayerInOneRow; int num = (row + 1) * numPlayerInOneRow;
@@ -541,7 +540,7 @@ namespace VocaluxeLib.PartyModes.Challenge
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
STableRow row = new STableRow var row = new STableRow
{ {
Pos = GetNewText(_Texts[_TextPosition]), Pos = GetNewText(_Texts[_TextPosition]),
Name = GetNewText(_Texts[_TextPlayerName]), Name = GetNewText(_Texts[_TextPlayerName]),
@@ -22,6 +22,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
namespace VocaluxeLib.PartyModes.Challenge namespace VocaluxeLib.PartyModes.Challenge
{ {
@@ -88,7 +89,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames {FadeBack = false, ProfileIDs = new List<int>()}; var names = new SFromScreenNames {FadeBack = false, ProfileIDs = new List<int>()};
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
@@ -96,7 +97,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
try try
{ {
SDataToScreenNames config = (SDataToScreenNames)receivedData; var config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDs = config.ProfileIDs ?? new List<int>(); _Data.ScreenNames.ProfileIDs = config.ProfileIDs ?? new List<int>();
_NumPlayer = config.NumPlayer; _NumPlayer = config.NumPlayer;
@@ -247,7 +248,7 @@ namespace VocaluxeLib.PartyModes.Challenge
CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]); CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]);
b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH); b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH);
b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW); 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); _PlayerChooseButtons.Add(pcb);
column++; column++;
if (column >= _PlayerChooseButtonsNumH) if (column >= _PlayerChooseButtonsNumH)
@@ -309,15 +310,15 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdateVisibleProfiles() private void _UpdateVisibleProfiles()
{ {
_PlayerChooseButtonsVisibleProfiles.Clear(); _PlayerChooseButtonsVisibleProfiles.Clear();
Profile.CProfile[] profiles = CBase.Profiles.GetProfiles(); CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < profiles.Length; i++) foreach (CProfile profile in profiles)
{ {
bool visible = false; bool visible = false;
//Show profile only if active //Show profile only if active
if (profiles[i].Active == EOffOn.TR_CONFIG_ON) if (profile.Active == EOffOn.TR_CONFIG_ON)
visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profiles[i].ID); visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profile.ID);
if (visible) if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID); _PlayerChooseButtonsVisibleProfiles.Add(profile.ID);
} }
} }
@@ -21,7 +21,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
namespace VocaluxeLib.PartyModes.ChallengeMedley namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
@@ -143,7 +142,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
try try
{ {
SDataToScreenMain data = (SDataToScreenMain)receivedData; var data = (SDataToScreenMain)receivedData;
_GameState = data; _GameState = data;
} }
catch (Exception e) catch (Exception e)
@@ -405,7 +404,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_RoundsTable = new List<CRoundsTableRow>(); _RoundsTable = new List<CRoundsTableRow>();
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()}; var rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()};
_RoundsTable.Add(rtr); _RoundsTable.Add(rtr);
} }
//Create statics and texts for rounds //Create statics and texts for rounds
@@ -457,7 +456,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
//Round-number //Round-number
roundRow.Number.X = numberX; roundRow.Number.X = numberX;
roundRow.Number.Y = numberY; 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++) for (int row = 0; row < numInnerRows; row++)
{ {
int num = (row + 1) * numPlayerInOneRow; int num = (row + 1) * numPlayerInOneRow;
@@ -541,7 +540,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
STableRow row = new STableRow var row = new STableRow
{ {
Pos = GetNewText(_Texts[_TextPosition]), Pos = GetNewText(_Texts[_TextPosition]),
Name = GetNewText(_Texts[_TextPlayerName]), Name = GetNewText(_Texts[_TextPlayerName]),
@@ -22,6 +22,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
namespace VocaluxeLib.PartyModes.ChallengeMedley namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
@@ -85,10 +86,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_Data.ScreenNames.ProfileIDs = new List<int>(); _Data.ScreenNames.ProfileIDs = new List<int>();
_ThemeButtons = new string[] { _ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose }; _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames { FadeToConfig = false, ProfileIDs = new List<int>() }; var names = new SFromScreenNames {FadeToConfig = false, ProfileIDs = new List<int>()};
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
@@ -96,7 +97,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
try try
{ {
SDataToScreenNames config = (SDataToScreenNames)receivedData; var config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDs = config.ProfileIDs ?? new List<int>(); _Data.ScreenNames.ProfileIDs = config.ProfileIDs ?? new List<int>();
_NumPlayer = config.NumPlayer; _NumPlayer = config.NumPlayer;
@@ -114,7 +115,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
base.HandleInput(keyEvent); base.HandleInput(keyEvent);
if (keyEvent.KeyPressed) { } if (keyEvent.KeyPressed) {}
else else
{ {
switch (keyEvent.Key) switch (keyEvent.Key)
@@ -247,7 +248,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]); CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]);
b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH); b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH);
b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW); 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); _PlayerChooseButtons.Add(pcb);
column++; column++;
if (column >= _PlayerChooseButtonsNumH) if (column >= _PlayerChooseButtonsNumH)
@@ -309,15 +310,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateVisibleProfiles() private void _UpdateVisibleProfiles()
{ {
_PlayerChooseButtonsVisibleProfiles.Clear(); _PlayerChooseButtonsVisibleProfiles.Clear();
Profile.CProfile[] profiles = CBase.Profiles.GetProfiles(); CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < profiles.Length; i++) foreach (CProfile profile in profiles)
{ {
bool visible = false; bool visible = false;
//Show profile only if active //Show profile only if active
if (profiles[i].Active == EOffOn.TR_CONFIG_ON) if (profile.Active == EOffOn.TR_CONFIG_ON)
visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profiles[i].ID); visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profile.ID);
if (visible) if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID); _PlayerChooseButtonsVisibleProfiles.Add(profile.ID);
} }
} }
@@ -21,7 +21,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@@ -248,7 +247,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public override void DataFromScreen(string screenName, Object data) public override void DataFromScreen(string screenName, Object data)
{ {
SDataFromScreen dataFrom = new SDataFromScreen(); var dataFrom = new SDataFromScreen();
switch (screenName) switch (screenName)
{ {
case "PartyScreenTicTacToeConfig": case "PartyScreenTicTacToeConfig":
@@ -492,7 +491,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public override void SongSelected(int songID) public override void SongSelected(int songID)
{ {
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; var gm = EGameMode.TR_GAMEMODE_NORMAL;
switch (_GameData.GameMode) switch (_GameData.GameMode)
{ {
@@ -525,7 +524,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_GameData.Rounds = new List<CRound>(); _GameData.Rounds = new List<CRound>();
for (int i = 0; i < _GameData.NumFields; i++) for (int i = 0; i < _GameData.NumFields; i++)
{ {
CRound r = new CRound(); var r = new CRound();
_GameData.Rounds.Add(r); _GameData.Rounds.Add(r);
} }
} }
@@ -540,11 +539,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_GameData.PlayerTeam2 = new List<int>(); _GameData.PlayerTeam2 = new List<int>();
//Prepare Player-IDs //Prepare Player-IDs
List<int> ids1 = new List<int>(); var ids1 = new List<int>();
List<int> ids2 = new List<int>(); var ids2 = new List<int>();
//Add IDs to team-list //Add IDs to team-list
while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && 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) if (ids1.Count == 0)
{ {
@@ -579,7 +578,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case 1: case 1:
{ {
//Prepare Player-IDs //Prepare Player-IDs
List<int> ids = new List<int>(); var ids = new List<int>();
//Add IDs to team-list //Add IDs to team-list
while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && ids.Count == 0) while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && ids.Count == 0)
{ {
@@ -602,7 +601,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case 2: case 2:
{ {
//Prepare Player-IDs //Prepare Player-IDs
List<int> ids = new List<int>(); var ids = new List<int>();
//Add IDs to team-list //Add IDs to team-list
while (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && ids.Count == 0) while (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && ids.Count == 0)
{ {
@@ -627,7 +626,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _PrepareSongList() private void _PrepareSongList()
{ {
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; var gm = EGameMode.TR_GAMEMODE_NORMAL;
switch (_GameData.GameMode) switch (_GameData.GameMode)
{ {
@@ -646,7 +645,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
while (_GameData.Songs.Count < (_GameData.NumFields + _GameData.NumJokerRandom[0] + _GameData.NumJokerRandom[1])) while (_GameData.Songs.Count < (_GameData.NumFields + _GameData.NumJokerRandom[0] + _GameData.NumJokerRandom[1]))
{ {
List<int> songs = new List<int>(); var songs = new List<int>();
switch (_GameData.SongSource) switch (_GameData.SongSource)
{ {
case ESongSource.TR_PLAYLIST: case ESongSource.TR_PLAYLIST:
@@ -741,11 +740,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
players[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1]; players[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1];
if (isDuet) if (isDuet)
players[0].LineNr = 0; players[0].VoiceNr = 0;
players[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2]; players[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2];
if (isDuet) if (isDuet)
players[1].LineNr = 1; players[1].VoiceNr = 1;
SongSelected(r.SongID); SongSelected(r.SongID);
} }
@@ -22,7 +22,6 @@ using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Songs; using VocaluxeLib.Songs;
using VocaluxeLib.Profile;
namespace VocaluxeLib.PartyModes.TicTacToe namespace VocaluxeLib.PartyModes.TicTacToe
{ {
@@ -104,7 +103,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ThemeStatics = new string[] {_StaticPopupBG, _StaticAvatarT1, _StaticAvatarT2}; _ThemeStatics = new string[] {_StaticPopupBG, _StaticAvatarT1, _StaticAvatarT2};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenMain config = new SFromScreenMain(); var config = new SFromScreenMain();
_GameData = new SDataToScreenMain(); _GameData = new SDataToScreenMain();
config.SingRoundNr = 1; config.SingRoundNr = 1;
config.Rounds = new List<CRound>(); config.Rounds = new List<CRound>();
@@ -130,7 +129,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
try try
{ {
SDataToScreenMain config = (SDataToScreenMain)receivedData; var config = (SDataToScreenMain)receivedData;
_GameData = config; _GameData = config;
} }
catch (Exception e) catch (Exception e)
@@ -389,7 +388,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
for (int i = 0; i < 25; i++) 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.Button.Visible = false;
f.Content = new CRound(); f.Content = new CRound();
_AddButton(f.Button); _AddButton(f.Button);
@@ -399,7 +398,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateFields() 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 fieldSizeY = ((float)CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow;
float fieldSizeX = ((float)CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow; float fieldSizeX = ((float)CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow;
_FieldSize = Math.Min(fieldSizeX, fieldSizeY); _FieldSize = Math.Min(fieldSizeX, fieldSizeY);
@@ -495,7 +494,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_GameData.Rounds[_SelectedField].SingerTeam2 = singerTeam2; _GameData.Rounds[_SelectedField].SingerTeam2 = singerTeam2;
_UpdatePlayerInformation(); _UpdatePlayerInformation();
} }
int songID = 0; int songID = 0;
if (_GameData.Songs.Count > 0) if (_GameData.Songs.Count > 0)
@@ -672,7 +670,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private int _BuildWinnerPossibilities() private int _BuildWinnerPossibilities()
{ {
int numOneRow = (int)Math.Sqrt(_GameData.NumFields); var numOneRow = (int)Math.Sqrt(_GameData.NumFields);
_Possibilities = new int[(numOneRow * 2) + 2,numOneRow]; _Possibilities = new int[(numOneRow * 2) + 2,numOneRow];
for (int i = 0; i < _Possibilities.GetLength(0); i++) 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++) for (int i = 0; i < _Possibilities.GetLength(0); i++)
{ {
List<int> check = new List<int>(); var check = new List<int>();
for (int j = 0; j < _Possibilities.GetLength(1); j++) for (int j = 0; j < _Possibilities.GetLength(1); j++)
{ {
if (_Fields[_Possibilities[i, j]].Content.Winner > 0) if (_Fields[_Possibilities[i, j]].Content.Winner > 0)
@@ -22,6 +22,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
namespace VocaluxeLib.PartyModes.TicTacToe namespace VocaluxeLib.PartyModes.TicTacToe
{ {
@@ -93,7 +94,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose, _ButtonPlayerChooseScrollUp, _ButtonPlayerChooseScrollDown}; _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose, _ButtonPlayerChooseScrollUp, _ButtonPlayerChooseScrollDown};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, ProfileIDsTeam1 = new List<int>(), ProfileIDsTeam2 = new List<int>()}; var names = new SFromScreenNames {FadeToConfig = false, ProfileIDsTeam1 = new List<int>(), ProfileIDsTeam2 = new List<int>()};
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
@@ -101,7 +102,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
try try
{ {
SDataToScreenNames config = (SDataToScreenNames)receivedData; var config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDsTeam1 = config.ProfileIDsTeam1; _Data.ScreenNames.ProfileIDsTeam1 = config.ProfileIDsTeam1;
_Data.ScreenNames.ProfileIDsTeam2 = config.ProfileIDsTeam2; _Data.ScreenNames.ProfileIDsTeam2 = config.ProfileIDsTeam2;
if (_Data.ScreenNames.ProfileIDsTeam1 == null) if (_Data.ScreenNames.ProfileIDsTeam1 == null)
@@ -375,7 +376,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]); CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]);
b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH); b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH);
b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW); 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); _PlayerChooseButtons.Add(pcb);
column++; column++;
if (column >= _PlayerChooseButtonsNumH) if (column >= _PlayerChooseButtonsNumH)
@@ -440,15 +441,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateVisibleProfiles() private void _UpdateVisibleProfiles()
{ {
_PlayerChooseButtonsVisibleProfiles.Clear(); _PlayerChooseButtonsVisibleProfiles.Clear();
Profile.CProfile[] profiles = CBase.Profiles.GetProfiles(); CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < profiles.Length; i++) foreach (CProfile profile in profiles)
{ {
bool visible = false; bool visible = false;
//Show profile only if active //Show profile only if active
if (profiles[i].Active == EOffOn.TR_CONFIG_ON) if (profile.Active == EOffOn.TR_CONFIG_ON)
visible = _Data.ScreenNames.ProfileIDsTeam1.All(profileID => profileID != profiles[i].ID) && _Data.ScreenNames.ProfileIDsTeam2.All(profileID => profileID != profiles[i].ID); visible = _Data.ScreenNames.ProfileIDsTeam1.All(profileID => profileID != profile.ID) &&
_Data.ScreenNames.ProfileIDsTeam2.All(profileID => profileID != profile.ID);
if (visible) if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID); _PlayerChooseButtonsVisibleProfiles.Add(profile.ID);
} }
} }
+2 -2
View File
@@ -704,7 +704,7 @@ namespace Vocaluxe.Base
/// <param name="args">Parameters</param> /// <param name="args">Parameters</param>
public static void LoadCommandLineParams(string[] args) 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 //Complete argument string
string arguments = args.Aggregate(string.Empty, (current, arg) => current + (arg + " ")); string arguments = args.Aggregate(string.Empty, (current, arg) => current + (arg + " "));
@@ -713,7 +713,7 @@ namespace Vocaluxe.Base
foreach (string text in args) 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 //split arg with Spilter-Regex and save in parts
string[] parts = spliterVal.Split(text, 2); string[] parts = spliterVal.Split(text, 2);
+2 -2
View File
@@ -77,11 +77,11 @@ namespace Vocaluxe.Base
{ {
controller.Update(); controller.Update();
SKeyEvent ke = new SKeyEvent(); var ke = new SKeyEvent();
while (controller.PollKeyEvent(ref ke)) while (controller.PollKeyEvent(ref ke))
_KeysPool.Add(ke); _KeysPool.Add(ke);
SMouseEvent me = new SMouseEvent(); var me = new SMouseEvent();
while (controller.PollMouseEvent(ref me)) while (controller.PollMouseEvent(ref me))
_MousePool.Add(me); _MousePool.Add(me);
} }
+10 -12
View File
@@ -62,7 +62,7 @@ namespace Vocaluxe.Base
{ {
get get
{ {
List<string> coverThemes = new List<string>(); var coverThemes = new List<string>();
for (int i = 0; i < _CoverThemes.Count; i++) for (int i = 0; i < _CoverThemes.Count; i++)
coverThemes.Add(_CoverThemes[i].Name); coverThemes.Add(_CoverThemes[i].Name);
@@ -154,7 +154,7 @@ namespace Vocaluxe.Base
if (xmlReader != null) if (xmlReader != null)
{ {
SCoverTheme coverTheme = new SCoverTheme(); var coverTheme = new SCoverTheme();
xmlReader.GetValue("//root/Info/Name", out coverTheme.Name, String.Empty); xmlReader.GetValue("//root/Info/Name", out coverTheme.Name, String.Empty);
xmlReader.GetValue("//root/Info/Folder", out coverTheme.Folder, String.Empty); xmlReader.GetValue("//root/Info/Folder", out coverTheme.Folder, String.Empty);
@@ -179,7 +179,7 @@ namespace Vocaluxe.Base
if (String.IsNullOrEmpty(coverTheme.Name)) if (String.IsNullOrEmpty(coverTheme.Name))
return; return;
List<string> ignoreList = new List<string>(); var ignoreList = new List<string>();
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderCover, coverTheme.File)); CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderCover, coverTheme.File));
if (xmlReader != null) if (xmlReader != null)
{ {
@@ -206,7 +206,7 @@ namespace Vocaluxe.Base
} }
} }
List<string> files = new List<string>(); var files = new List<string>();
string coverPath = Path.Combine(CSettings.FolderCover, coverTheme.Folder); string coverPath = Path.Combine(CSettings.FolderCover, coverTheme.Folder);
files.AddRange(CHelper.ListFiles(coverPath, "*.png", true, true)); files.AddRange(CHelper.ListFiles(coverPath, "*.png", true, true));
@@ -222,19 +222,17 @@ namespace Vocaluxe.Base
} }
} }
private static void _AddCover(string Name, string File) private static void _AddCover(string name, string file)
{ {
CTexture texture = CDraw.AddTexture(File); CTexture texture = CDraw.AddTexture(file);
if (!_CoverExists(Name)) if (!_CoverExists(name))
{ _Cover.Add(name, texture);
_Cover.Add(Name, texture);
}
else else
{ {
CTexture tex = _Cover[Name]; CTexture tex = _Cover[name];
CDraw.RemoveTexture(ref tex); CDraw.RemoveTexture(ref tex);
_Cover[Name] = texture; _Cover[name] = texture;
} }
} }
} }
+62 -78
View File
@@ -71,13 +71,12 @@ namespace Vocaluxe.Base
} }
#region Highscores #region Highscores
public static bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded, out int highscoreID) public static bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded, out int highscoreID)
{ {
string sArtist = string.Empty; string sArtist;
string sTitle = string.Empty; string sTitle;
int songID = -1; int songID;
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + _HighscoreFilePath; connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
@@ -85,11 +84,9 @@ namespace Vocaluxe.Base
{ {
connection.Open(); connection.Open();
} }
catch (Exception) catch (Exception) {}
{
}
using (SQLiteCommand command = new SQLiteCommand(connection)) using (var command = new SQLiteCommand(connection))
{ {
songID = _GetDataBaseSongID(artist, title, 0, command); songID = _GetDataBaseSongID(artist, title, 0, command);
highscoreID = songID; highscoreID = songID;
@@ -100,7 +97,7 @@ namespace Vocaluxe.Base
public static void IncreaseSongCounter(SPlayer player) public static void IncreaseSongCounter(SPlayer player)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + _HighscoreFilePath; connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
@@ -108,11 +105,9 @@ namespace Vocaluxe.Base
{ {
connection.Open(); connection.Open();
} }
catch (Exception) catch (Exception) {}
{
}
using (SQLiteCommand command = new SQLiteCommand(connection)) using (var command = new SQLiteCommand(connection))
{ {
int dataBaseSongID = _GetDataBaseSongID(player, command); int dataBaseSongID = _GetDataBaseSongID(player, command);
_IncreaseSongCounter(dataBaseSongID, command); _IncreaseSongCounter(dataBaseSongID, command);
@@ -122,7 +117,7 @@ namespace Vocaluxe.Base
public static void IncreaseSongCounter(int dataBaseSongID) public static void IncreaseSongCounter(int dataBaseSongID)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + _HighscoreFilePath; connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
@@ -130,21 +125,17 @@ namespace Vocaluxe.Base
{ {
connection.Open(); connection.Open();
} }
catch (Exception) catch (Exception) {}
{
}
using (SQLiteCommand command = new SQLiteCommand(connection)) using (var command = new SQLiteCommand(connection))
{
_IncreaseSongCounter(dataBaseSongID, command); _IncreaseSongCounter(dataBaseSongID, command);
} }
} }
}
public static int AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int difficulty, 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) string artist, string title, int numPlayed, string filePath)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + filePath; connection.ConnectionString = "Data Source=" + filePath;
@@ -157,7 +148,7 @@ namespace Vocaluxe.Base
return -1; return -1;
} }
using (SQLiteCommand command = new SQLiteCommand(connection)) using (var command = new SQLiteCommand(connection))
{ {
int dataBaseSongID = _GetDataBaseSongID(artist, title, numPlayed, command); int dataBaseSongID = _GetDataBaseSongID(artist, title, numPlayed, command);
int result = _AddScore(playerName, score, lineNr, date, medley, duet, shortSong, difficulty, dataBaseSongID, 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) public static int AddScore(SPlayer player)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + _HighscoreFilePath; connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
@@ -181,10 +172,10 @@ namespace Vocaluxe.Base
return -1; return -1;
} }
using (SQLiteCommand command = new SQLiteCommand(connection)) using (var command = new SQLiteCommand(connection))
{ {
int dataBaseSongID = CSongs.GetSong(player.SongID).DataBaseSongID; int dataBaseSongID = CSongs.GetSong(player.SongID).DataBaseSongID;
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); player.Duet ? 1 : 0, player.ShortSong ? 1 : 0, (int)CProfiles.GetDifficulty(player.ProfileID), dataBaseSongID, command);
} }
} }
@@ -256,7 +247,7 @@ namespace Vocaluxe.Base
public static void LoadScore(out List<SScores> scores, SPlayer player) public static void LoadScore(out List<SScores> scores, SPlayer player)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + _HighscoreFilePath; connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
@@ -271,7 +262,7 @@ namespace Vocaluxe.Base
return; return;
} }
using (SQLiteCommand command = new SQLiteCommand(connection)) using (var command = new SQLiteCommand(connection))
{ {
int medley = 0; int medley = 0;
if (player.Medley) if (player.Medley)
@@ -301,7 +292,7 @@ namespace Vocaluxe.Base
{ {
while (reader.Read()) while (reader.Read())
{ {
SScores score = new SScores var score = new SScores
{ {
Name = reader.GetString(0), Name = reader.GetString(0),
Score = reader.GetInt32(1), Score = reader.GetInt32(1),
@@ -361,7 +352,7 @@ namespace Vocaluxe.Base
command.Parameters.Add("@title", DbType.String, 0).Value = title; command.Parameters.Add("@title", DbType.String, 0).Value = title;
command.Parameters.Add("@artist", DbType.String, 0).Value = artist; command.Parameters.Add("@artist", DbType.String, 0).Value = artist;
command.Parameters.Add("@numplayed", DbType.Int32, 0).Value = defNumPlayed; 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.ExecuteNonQuery();
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist"; command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
@@ -388,7 +379,7 @@ namespace Vocaluxe.Base
numPlayed = 0; numPlayed = 0;
dateAdded = String.Empty; dateAdded = String.Empty;
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + filePath; connection.ConnectionString = "Data Source=" + filePath;
@@ -401,7 +392,7 @@ namespace Vocaluxe.Base
return false; 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.CommandText = "SELECT Artist, Title, NumPlayed, DateAdded FROM Songs WHERE [id] = @id";
command.Parameters.Add("@id", DbType.String, 0).Value = songID; command.Parameters.Add("@id", DbType.String, 0).Value = songID;
@@ -460,7 +451,7 @@ namespace Vocaluxe.Base
private static void _CreateHighscoreDB(string filePath) private static void _CreateHighscoreDB(string filePath)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + filePath; connection.ConnectionString = "Data Source=" + filePath;
@@ -473,7 +464,7 @@ namespace Vocaluxe.Base
return; 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.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
@@ -496,7 +487,7 @@ namespace Vocaluxe.Base
private static void _CreateHighscoreDBV1(string filePath) private static void _CreateHighscoreDBV1(string filePath)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + filePath; connection.ConnectionString = "Data Source=" + filePath;
@@ -509,7 +500,7 @@ namespace Vocaluxe.Base
return; 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.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
@@ -536,7 +527,7 @@ namespace Vocaluxe.Base
/// <returns></returns> /// <returns></returns>
private static bool _CreateOrConvert(string filePath) private static bool _CreateOrConvert(string filePath)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + filePath; connection.ConnectionString = "Data Source=" + filePath;
@@ -549,7 +540,7 @@ namespace Vocaluxe.Base
return false; return false;
} }
using (SQLiteCommand command = new SQLiteCommand(connection)) using (var command = new SQLiteCommand(connection))
{ {
command.CommandText = "PRAGMA user_version"; command.CommandText = "PRAGMA user_version";
SQLiteDataReader reader = command.ExecuteReader(); SQLiteDataReader reader = command.ExecuteReader();
@@ -646,7 +637,7 @@ namespace Vocaluxe.Base
/// <returns>True if succeeded</returns> /// <returns>True if succeeded</returns>
private static bool _ConvertFrom110(string filePath) private static bool _ConvertFrom110(string filePath)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + filePath; connection.ConnectionString = "Data Source=" + filePath;
@@ -659,7 +650,7 @@ namespace Vocaluxe.Base
return false; 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 //The USDX database has no column for LineNr, Medley and Duet so just fill 0 in there
command.CommandText = command.CommandText =
@@ -669,8 +660,8 @@ namespace Vocaluxe.Base
command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs"; command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
List<SData> scores = new List<SData>(); var scores = new List<SData>();
List<SData> songs = new List<SData>(); var songs = new List<SData>();
command.CommandText = "SELECT id, PlayerName, Date FROM Scores"; command.CommandText = "SELECT id, PlayerName, Date FROM Scores";
SQLiteDataReader reader = command.ExecuteReader(); SQLiteDataReader reader = command.ExecuteReader();
@@ -679,7 +670,7 @@ namespace Vocaluxe.Base
{ {
while (reader.Read()) 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; Int64 ticks = 0;
try try
@@ -703,7 +694,7 @@ namespace Vocaluxe.Base
{ {
while (reader.Read()) 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); songs.Add(data);
} }
} }
@@ -759,7 +750,7 @@ namespace Vocaluxe.Base
/// <returns>True if succeeded</returns> /// <returns>True if succeeded</returns>
private static bool _ConvertFrom101(string filePath) private static bool _ConvertFrom101(string filePath)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + filePath; connection.ConnectionString = "Data Source=" + filePath;
@@ -772,7 +763,7 @@ namespace Vocaluxe.Base
return false; return false;
} }
using (SQLiteCommand command = new SQLiteCommand(connection)) using (var command = new SQLiteCommand(connection))
{ {
command.CommandText = "PRAGMA table_info(US_Scores);"; command.CommandText = "PRAGMA table_info(US_Scores);";
bool dateExists = false; bool dateExists = false;
@@ -803,8 +794,8 @@ namespace Vocaluxe.Base
command.ExecuteNonQuery(); command.ExecuteNonQuery();
// convert from CP1252 to UTF8 // convert from CP1252 to UTF8
List<SData> scores = new List<SData>(); var scores = new List<SData>();
List<SData> songs = new List<SData>(); var songs = new List<SData>();
Sqlite3.sqlite3 oldDB; Sqlite3.sqlite3 oldDB;
int res = Sqlite3.sqlite3_open(filePath, out 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) + ")"); CLog.LogError("Error opening Database: " + filePath + " (" + Sqlite3.sqlite3_errmsg(oldDB) + ")");
else 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); res = Sqlite3.sqlite3_prepare_v2(oldDB, "SELECT id, Artist, Title FROM Songs", -1, ref stmt, 0);
if (res != Sqlite3.SQLITE_OK) if (res != Sqlite3.SQLITE_OK)
@@ -826,7 +817,7 @@ namespace Vocaluxe.Base
while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW) 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); byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1);
data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone"; 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) 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); byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1);
data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone"; data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone";
@@ -918,20 +909,16 @@ namespace Vocaluxe.Base
bool updated = true; bool updated = true;
if (currentVersion < 2) if (currentVersion < 2)
{
updated &= _ConvertV1toV2(connection); updated &= _ConvertV1toV2(connection);
}
if (currentVersion < 3) if (currentVersion < 3)
{
updated &= _ConvertV2toV3(connection); updated &= _ConvertV2toV3(connection);
}
return updated; return updated;
} }
private static bool _ConvertV1toV2(SQLiteConnection connection) 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.CommandText = "ALTER TABLE Scores ADD ShortSong INTEGER";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
@@ -948,17 +935,14 @@ namespace Vocaluxe.Base
private static bool _ConvertV2toV3(SQLiteConnection connection) 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.ExecuteNonQuery();
command.CommandText = "UPDATE Songs SET [DateAdded] = @DateAdded"; 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.ExecuteNonQuery();
command.CommandText = "UPDATE Version SET [Value] = @version"; 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.ExecuteNonQuery();
//Read NumPlayed from Scores and save to Songs //Read NumPlayed from Scores and save to Songs
@@ -1003,7 +987,7 @@ namespace Vocaluxe.Base
private static bool _ImportData(string sourceDBPath) private static bool _ImportData(string sourceDBPath)
{ {
#region open db #region open db
using (SQLiteConnection connSource = new SQLiteConnection()) using (var connSource = new SQLiteConnection())
{ {
connSource.ConnectionString = "Data Source=" + sourceDBPath; connSource.ConnectionString = "Data Source=" + sourceDBPath;
@@ -1018,7 +1002,7 @@ namespace Vocaluxe.Base
} }
#endregion open db #endregion open db
using (SQLiteCommand cmdSource = new SQLiteCommand(connSource)) using (var cmdSource = new SQLiteCommand(connSource))
{ {
#region import table scores #region import table scores
cmdSource.CommandText = "SELECT SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty FROM Scores"; cmdSource.CommandText = "SELECT SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty FROM Scores";
@@ -1074,7 +1058,7 @@ namespace Vocaluxe.Base
_ConnectionCover.Open(); _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.CommandText = "SELECT id, width, height FROM Cover WHERE [Path] = @path";
command.Parameters.Add("@path", DbType.String, 0).Value = coverPath; command.Parameters.Add("@path", DbType.String, 0).Value = coverPath;
@@ -1132,7 +1116,7 @@ namespace Vocaluxe.Base
else if (origin.Height > origin.Width && origin.Height > h) else if (origin.Height > origin.Width && origin.Height > h)
w = (int)Math.Round((float)h / origin.Height * origin.Width); 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)) using (Graphics g = Graphics.FromImage(bmp))
g.DrawImage(origin, new Rectangle(0, 0, w, h)); g.DrawImage(origin, new Rectangle(0, 0, w, h));
@@ -1201,7 +1185,7 @@ namespace Vocaluxe.Base
private static bool _InitCoverDB() private static bool _InitCoverDB()
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + _CoverFilePath; connection.ConnectionString = "Data Source=" + _CoverFilePath;
@@ -1214,7 +1198,7 @@ namespace Vocaluxe.Base
return false; return false;
} }
using (SQLiteCommand command = new SQLiteCommand(connection)) using (var command = new SQLiteCommand(connection))
{ {
command.CommandText = "SELECT Value FROM Version"; command.CommandText = "SELECT Value FROM Version";
@@ -1254,7 +1238,7 @@ namespace Vocaluxe.Base
private static void _CreateCoverDB() private static void _CreateCoverDB()
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + _CoverFilePath; connection.ConnectionString = "Data Source=" + _CoverFilePath;
@@ -1267,7 +1251,7 @@ namespace Vocaluxe.Base
return; 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.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
@@ -1293,7 +1277,7 @@ namespace Vocaluxe.Base
{ {
bool result = false; bool result = false;
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + _CreditsRessourcesFilePath; connection.ConnectionString = "Data Source=" + _CreditsRessourcesFilePath;
try try
@@ -1304,7 +1288,7 @@ namespace Vocaluxe.Base
{ {
return false; 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.CommandText = "SELECT id, width, height FROM Images WHERE [Path] = @path";
command.Parameters.Add("@path", DbType.String, 0).Value = fileName; command.Parameters.Add("@path", DbType.String, 0).Value = fileName;
@@ -1426,7 +1410,7 @@ namespace Vocaluxe.Base
private static bool _InitCreditsRessourcesDB() private static bool _InitCreditsRessourcesDB()
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (var connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + _CreditsRessourcesFilePath; connection.ConnectionString = "Data Source=" + _CreditsRessourcesFilePath;
@@ -1439,7 +1423,7 @@ namespace Vocaluxe.Base
return false; return false;
} }
using (SQLiteCommand command = new SQLiteCommand(connection)) using (var command = new SQLiteCommand(connection))
{ {
command.CommandText = "SELECT Value FROM Version"; command.CommandText = "SELECT Value FROM Version";
@@ -1519,14 +1503,14 @@ namespace Vocaluxe.Base
private static byte[] _GetBytes(SQLiteDataReader reader) private static byte[] _GetBytes(SQLiteDataReader reader)
{ {
const int chunkSize = 2 * 1024; const int chunkSize = 2 * 1024;
byte[] buffer = new byte[chunkSize]; var buffer = new byte[chunkSize];
long fieldOffset = 0; long fieldOffset = 0;
using (MemoryStream stream = new MemoryStream()) using (var stream = new MemoryStream())
{ {
long bytesRead; long bytesRead;
while ((bytesRead = reader.GetBytes(0, fieldOffset, buffer, 0, buffer.Length)) > 0) 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); Buffer.BlockCopy(buffer, 0, actualRead, 0, (int)bytesRead);
stream.Write(actualRead, 0, actualRead.Length); stream.Write(actualRead, 0, actualRead.Length);
fieldOffset += bytesRead; fieldOffset += bytesRead;
@@ -1537,7 +1521,7 @@ namespace Vocaluxe.Base
private static long _UnixTimeToTicks(int unixTime) 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); t70 = t70.AddSeconds(unixTime);
return t70.Ticks; return t70.Ticks;
} }
+1 -1
View File
@@ -206,7 +206,7 @@ namespace Vocaluxe.Base
if (texture == null) if (texture == null)
return; 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; RectangleF rect;
CHelper.SetRect(bounds, out rect, texture.OrigAspect, aspect); CHelper.SetRect(bounds, out rect, texture.OrigAspect, aspect);
+24 -25
View File
@@ -172,9 +172,9 @@ namespace Vocaluxe.Base
Players[i].Points = 0f; Players[i].Points = 0f;
Players[i].PointsLineBonus = 0f; Players[i].PointsLineBonus = 0f;
Players[i].PointsGoldenNotes = 0f; Players[i].PointsGoldenNotes = 0f;
Players[i].LineNr = 0; Players[i].VoiceNr = 0;
Players[i].NoteDiff = 0; Players[i].NoteDiff = 0;
Players[i].SingLine = new List<CLine>(); Players[i].SungLines = new List<CSungLine>();
Players[i].CurrentLine = -1; Players[i].CurrentLine = -1;
Players[i].CurrentNote = -1; Players[i].CurrentNote = -1;
Players[i].SongID = -1; Players[i].SongID = -1;
@@ -221,7 +221,7 @@ namespace Vocaluxe.Base
(_SongQueue.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat)) (_SongQueue.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat))
Players[p].SongFinished = true; 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; int line = -1;
for (int j = 0; j < lines.Length; j++) for (int j = 0; j < lines.Length; j++)
@@ -240,16 +240,16 @@ namespace Vocaluxe.Base
Players[p].CurrentLine = line; Players[p].CurrentLine = line;
while (Players[p].SingLine.Count <= line) while (Players[p].SungLines.Count <= line)
Players[p].SingLine.Add(new CLine()); Players[p].SungLines.Add(new CSungLine());
CNote[] notes = lines[line].Notes; CSongNote[] notes = lines[line].Notes;
int note = lines[line].FindPreviousNote(beat); int note = lines[line].FindPreviousNote(beat);
if (note >= 0 && notes[note].EndBeat < beat) if (note >= 0 && notes[note].EndBeat < beat)
note = -1; note = -1;
if (note >= 0) if (note < 0)
{ continue;
Players[p].CurrentNote = note; Players[p].CurrentNote = note;
if (line == lines.Length - 1) if (line == lines.Length - 1)
@@ -279,49 +279,49 @@ namespace Vocaluxe.Base
// valid // valid
//CSound.RecordSetTone(p, Tone); //CSound.RecordSetTone(p, Tone);
double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat / double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat /
song.Notes.GetVoice(Players[p].LineNr).Points; song.Notes.GetVoice(Players[p].VoiceNr).Points;
if (notes[note].NoteType == ENoteType.Golden) if (notes[note].NoteType == ENoteType.Golden)
Players[p].PointsGoldenNotes += points; Players[p].PointsGoldenNotes += points;
Players[p].Points += points; Players[p].Points += points;
// update player notes (sung notes) // update player notes (sung notes)
if (Players[p].SingLine[line].NoteCount > 0) if (Players[p].SungLines[line].NoteCount > 0)
{ {
CNote lastNote = Players[p].SingLine[line].LastNote; CSungNote lastNote = Players[p].SungLines[line].LastNote;
if (notes[note].StartBeat == beat || lastNote.EndBeat + 1 != beat || lastNote.Tone != tone || !lastNote.Hit) 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)); Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tone, notes[note]));
else else
Players[p].SingLine[line].IncLastNoteLength(); Players[p].SungLines[line].IncLastNoteLength();
} }
else else
Players[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType)); Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tone, notes[note]));
Players[p].SingLine[line].LastNote.IsPerfect(notes[note]); Players[p].SungLines[line].LastNote.CheckPerfect();
Players[p].SingLine[line].IsPerfect(lines[line]); Players[p].SungLines[line].IsPerfect(lines[line]);
} }
else else
{ {
if (Players[p].SingLine[line].NoteCount > 0) if (Players[p].SungLines[line].NoteCount > 0)
{ {
CNote lastNote = Players[p].SingLine[line].LastNote; CSungNote lastNote = Players[p].SungLines[line].LastNote;
if (lastNote.Tone == tonePlayer && lastNote.EndBeat + 1 == beat && !lastNote.Hit) if (lastNote.Tone != tonePlayer || lastNote.EndBeat + 1 != beat || lastNote.Hit)
Players[p].SingLine[line].IncLastNoteLength(); Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tonePlayer));
else else
Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle)); Players[p].SungLines[line].IncLastNoteLength();
} }
else 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, tonePlayer));
} }
} }
// Line Bonus // Line Bonus
int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(Players[p].LineNr); int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(Players[p].VoiceNr);
if (note == lines[line].NoteCount - 1 && numLinesWithPoints > 0) if (note == lines[line].NoteCount - 1 && numLinesWithPoints > 0)
{ {
if (notes[note].EndBeat == beat && lines[line].Points > 0f) if (notes[note].EndBeat == beat && lines[line].Points > 0f)
{ {
double factor = Players[p].SingLine[line].Points / (double)lines[line].Points; double factor = Players[p].SungLines[line].Points / (double)lines[line].Points;
if (factor < 0.4) if (factor < 0.4)
factor = 0.0; factor = 0.0;
else if (factor > 0.9) else if (factor > 0.9)
@@ -340,7 +340,6 @@ namespace Vocaluxe.Base
} }
} }
} }
}
_OldBeatD = ActBeatD; _OldBeatD = ActBeatD;
} }
} }
+10 -10
View File
@@ -218,7 +218,7 @@ namespace Vocaluxe.Base
if (_Fading) if (_Fading)
{ {
long fadeTime = (long)(CConfig.FadeTime * 1000); var fadeTime = (long)(CConfig.FadeTime * 1000);
if ((_FadingTimer.ElapsedMilliseconds < fadeTime) && (CConfig.FadeTime > 0)) if ((_FadingTimer.ElapsedMilliseconds < fadeTime) && (CConfig.FadeTime > 0))
{ {
@@ -349,10 +349,10 @@ namespace Vocaluxe.Base
#region private stuff #region private stuff
private static bool _HandleInputs(CKeys keys, CMouse mouse) private static bool _HandleInputs(CKeys keys, CMouse mouse)
{ {
SKeyEvent keyEvent = new SKeyEvent(); var keyEvent = new SKeyEvent();
SMouseEvent mouseEvent = new SMouseEvent(); var mouseEvent = new SMouseEvent();
SKeyEvent inputKeyEvent = new SKeyEvent(); var inputKeyEvent = new SKeyEvent();
SMouseEvent inputMouseEvent = new SMouseEvent(); var inputMouseEvent = new SMouseEvent();
bool popupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing && bool popupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing &&
(_CurrentScreen != EScreens.ScreenSong || (_CurrentScreen != EScreens.ScreenSong ||
@@ -541,8 +541,8 @@ namespace Vocaluxe.Base
private static bool _HandleInputThemeEditor(CKeys keys, CMouse mouse) private static bool _HandleInputThemeEditor(CKeys keys, CMouse mouse)
{ {
SKeyEvent keyEvent = new SKeyEvent(); var keyEvent = new SKeyEvent();
SMouseEvent mouseEvent = new SMouseEvent(); var mouseEvent = new SMouseEvent();
while (keys.PollEvent(ref keyEvent)) while (keys.PollEvent(ref keyEvent))
{ {
@@ -598,7 +598,7 @@ namespace Vocaluxe.Base
if (CConfig.DebugLevel == EDebugLevel.TR_CONFIG_OFF) if (CConfig.DebugLevel == EDebugLevel.TR_CONFIG_OFF)
return; return;
List<String> debugOutput = new List<string> {CTime.GetFPS().ToString("FPS: 000")}; var debugOutput = new List<string> {CTime.GetFPS().ToString("FPS: 000")};
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1) if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
{ {
@@ -627,11 +627,11 @@ namespace Vocaluxe.Base
CFonts.Style = EStyle.Normal; CFonts.Style = EStyle.Normal;
CFonts.SetFont("Normal"); CFonts.SetFont("Normal");
CFonts.Height = 25; CFonts.Height = 25;
SColorF gray = new SColorF(1f, 1f, 1f, 0.5f); var gray = new SColorF(1f, 1f, 1f, 0.5f);
float y = 0; float y = 0;
foreach (string txt in debugOutput) 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)); CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear); CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
y += rect.Height; y += rect.Height;
+5 -5
View File
@@ -66,7 +66,7 @@ namespace Vocaluxe.Base
public static IEnumerable<string> GetLanguageNames() public static IEnumerable<string> GetLanguageNames()
{ {
string[] languages = new string[_Languages.Count]; var languages = new string[_Languages.Count];
for (int i = 0; i < _Languages.Count; i++) for (int i = 0; i < _Languages.Count; i++)
languages[i] = _Languages[i].Name; languages[i] = _Languages[i].Name;
@@ -81,7 +81,7 @@ namespace Vocaluxe.Base
_Settings.Encoding = Encoding.UTF8; _Settings.Encoding = Encoding.UTF8;
_Settings.ConformanceLevel = ConformanceLevel.Document; _Settings.ConformanceLevel = ConformanceLevel.Document;
List<string> files = new List<string>(); var files = new List<string>();
files.AddRange(CHelper.ListFiles(CSettings.FolderLanguages, "*.xml", true, true)); files.AddRange(CHelper.ListFiles(CSettings.FolderLanguages, "*.xml", true, true));
foreach (string file in files) foreach (string file in files)
@@ -166,7 +166,7 @@ namespace Vocaluxe.Base
public static bool LoadPartyLanguageFiles(int partyModeID, string path) public static bool LoadPartyLanguageFiles(int partyModeID, string path)
{ {
List<string> files = new List<string>(); var files = new List<string>();
files.AddRange(CHelper.ListFiles(path, "*.xml", true, true)); files.AddRange(CHelper.ListFiles(path, "*.xml", true, true));
return files.All(file => _LoadPartyLanguageFile(partyModeID, file)); return files.All(file => _LoadPartyLanguageFile(partyModeID, file));
@@ -208,7 +208,7 @@ namespace Vocaluxe.Base
if (nr == -1) if (nr == -1)
return true; return true;
SPartyLanguage lang = new SPartyLanguage {PartyModeID = partyModeID}; var lang = new SPartyLanguage {PartyModeID = partyModeID};
if (!_LoadLanguageEntries(xmlReader, out lang.Texts)) if (!_LoadLanguageEntries(xmlReader, out lang.Texts))
return false; return false;
@@ -221,7 +221,7 @@ namespace Vocaluxe.Base
private static void _LoadLanguageFile(string fileName) 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); CXMLReader xmlReader = CXMLReader.OpenFile(lang.LanguageFilePath);
if (xmlReader == null) if (xmlReader == null)
+1 -1
View File
@@ -304,7 +304,7 @@ namespace Vocaluxe.Base
pm.PartyMode.Initialize(); pm.PartyMode.Initialize();
pm.PartyMode.SetFolder(Path.Combine(Directory.GetCurrentDirectory(), Path.Combine(CSettings.FolderPartyModes, pm.Folder))); 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; return pm;
int themeIndex = CTheme.GetThemeIndex(pm.PartyModeID); int themeIndex = CTheme.GetThemeIndex(pm.PartyModeID);
+8 -7
View File
@@ -52,14 +52,14 @@ namespace Vocaluxe.Base
public static void Init() public static void Init()
{ {
LoadPlaylists(); LoadPlaylists();
ConvertUSDXPlaylists(); _ConvertUSDXPlaylists();
_SortPlaylistsByName(); _SortPlaylistsByName();
} }
public static void ConvertUSDXPlaylists() private static void _ConvertUSDXPlaylists()
{ {
List<string> files = new List<string>(); var files = new List<string>();
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataPath,CSettings.FolderPlaylists), "*.upl", true, true)); files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataPath,CSettings.FolderPlaylists), "*.upl", true, true));
foreach (string file in files) foreach (string file in files)
@@ -73,12 +73,13 @@ namespace Vocaluxe.Base
public static void LoadPlaylists() public static void LoadPlaylists()
{ {
_Playlists = new List<CPlaylistFile>(); _Playlists = new List<CPlaylistFile>();
List<string> files = new List<string>();
var files = new List<string>();
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataPath, CSettings.FolderPlaylists), "*.xml", true, true)); files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataPath, CSettings.FolderPlaylists), "*.xml", true, true));
foreach (string file in files) foreach (string file in files)
{ {
CPlaylistFile playlist = new CPlaylistFile(file); var playlist = new CPlaylistFile(file);
_Playlists.Add(playlist); _Playlists.Add(playlist);
} }
} }
@@ -126,7 +127,7 @@ namespace Vocaluxe.Base
public static int NewPlaylist() public static int NewPlaylist()
{ {
CPlaylistFile pl = new CPlaylistFile {PlaylistName = "New Playlist"}; var pl = new CPlaylistFile {PlaylistName = "New Playlist"};
_Playlists.Add(pl); _Playlists.Add(pl);
return _Playlists.Count - 1; return _Playlists.Count - 1;
} }
@@ -219,7 +220,7 @@ namespace Vocaluxe.Base
private static CPlaylistFile _ConvertUSDXPlaylist(string file) private static CPlaylistFile _ConvertUSDXPlaylist(string file)
{ {
CPlaylistFile pl = new CPlaylistFile(); var pl = new CPlaylistFile();
ReadOnlyCollection<CSong> allSongs = CSongs.AllSongs; ReadOnlyCollection<CSong> allSongs = CSongs.AllSongs;
if (!File.Exists(file)) if (!File.Exists(file))
+21 -20
View File
@@ -179,7 +179,7 @@ namespace Vocaluxe.Base
if (_ProfileChangedCallbacks.Count == 0) if (_ProfileChangedCallbacks.Count == 0)
return; return;
EProfileChangedFlags flags = EProfileChangedFlags.None; var flags = EProfileChangedFlags.None;
if (_AvatarsChanged) if (_AvatarsChanged)
flags = EProfileChangedFlags.Avatar; flags = EProfileChangedFlags.Avatar;
@@ -214,7 +214,7 @@ namespace Vocaluxe.Base
public static void LoadProfiles() public static void LoadProfiles()
{ {
SChange change = new SChange {Action = EAction.LoadProfiles}; var change = new SChange {Action = EAction.LoadProfiles};
lock (_QueueMutex) lock (_QueueMutex)
{ {
@@ -224,7 +224,7 @@ namespace Vocaluxe.Base
public static void LoadAvatars() public static void LoadAvatars()
{ {
SChange change = new SChange {Action = EAction.LoadAvatars}; var change = new SChange {Action = EAction.LoadAvatars};
lock (_QueueMutex) lock (_QueueMutex)
{ {
@@ -237,7 +237,7 @@ namespace Vocaluxe.Base
if (newProfile == null) if (newProfile == null)
return; return;
SChange change = new SChange {Action = EAction.AddProfile, Profile = newProfile}; var change = new SChange {Action = EAction.AddProfile, Profile = newProfile};
lock (_QueueMutex) lock (_QueueMutex)
{ {
@@ -250,7 +250,7 @@ namespace Vocaluxe.Base
if (editProfile == null) if (editProfile == null)
return; return;
SChange change = new SChange {Action = EAction.EditProfile, Profile = editProfile}; var change = new SChange {Action = EAction.EditProfile, Profile = editProfile};
lock (_QueueMutex) lock (_QueueMutex)
{ {
@@ -263,7 +263,7 @@ namespace Vocaluxe.Base
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return; return;
SChange change = new SChange {Action = EAction.DeleteProfile, ProfileID = profileID}; var change = new SChange {Action = EAction.DeleteProfile, ProfileID = profileID};
lock (_QueueMutex) lock (_QueueMutex)
{ {
@@ -276,7 +276,7 @@ namespace Vocaluxe.Base
if (newAvatar == null) if (newAvatar == null)
return; return;
SChange change = new SChange {Action = EAction.AddAvatar, Avatar = newAvatar}; var change = new SChange {Action = EAction.AddAvatar, Avatar = newAvatar};
lock (_QueueMutex) lock (_QueueMutex)
{ {
@@ -289,7 +289,7 @@ namespace Vocaluxe.Base
if (editAvatar == null) if (editAvatar == null)
return; return;
SChange change = new SChange {Action = EAction.EditAvatar, Avatar = editAvatar}; var change = new SChange {Action = EAction.EditAvatar, Avatar = editAvatar};
lock (_QueueMutex) lock (_QueueMutex)
{ {
@@ -302,7 +302,7 @@ namespace Vocaluxe.Base
if (_Profiles.Count == 0) if (_Profiles.Count == 0)
return null; return null;
List<CProfile> list = new List<CProfile>(_Profiles.Values); var list = new List<CProfile>(_Profiles.Values);
list.Sort(_CompareByPlayerName); list.Sort(_CompareByPlayerName);
return list.ToArray(); return list.ToArray();
} }
@@ -312,7 +312,7 @@ namespace Vocaluxe.Base
if (_Avatars.Count == 0) if (_Avatars.Count == 0)
return null; return null;
CAvatar[] result = new CAvatar[_Avatars.Count]; var result = new CAvatar[_Avatars.Count];
_Avatars.Values.CopyTo(result, 0); _Avatars.Values.CopyTo(result, 0);
return result; return result;
@@ -320,7 +320,7 @@ namespace Vocaluxe.Base
public static int NewProfile(string fileName = "") public static int NewProfile(string fileName = "")
{ {
CProfile profile = new CProfile var profile = new CProfile
{ {
FileName = fileName != "" ? Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, fileName) : String.Empty FileName = fileName != "" ? Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, fileName) : String.Empty
}; };
@@ -336,7 +336,7 @@ namespace Vocaluxe.Base
public static int NewAvatar(string fileName) public static int NewAvatar(string fileName)
{ {
CAvatar avatar = new CAvatar(-1); var avatar = new CAvatar(-1);
if (!avatar.LoadFromFile(fileName)) if (!avatar.LoadFromFile(fileName))
return -1; return -1;
@@ -511,10 +511,10 @@ namespace Vocaluxe.Base
{ {
_LoadAvatars(); _LoadAvatars();
List<string> knownFiles = new List<string>(); var knownFiles = new List<string>();
if (_Profiles.Count > 0) if (_Profiles.Count > 0)
{ {
int[] ids = new int[_Profiles.Keys.Count]; var ids = new int[_Profiles.Keys.Count];
_Profiles.Keys.CopyTo(ids, 0); _Profiles.Keys.CopyTo(ids, 0);
foreach (int id in ids) foreach (int id in ids)
{ {
@@ -528,7 +528,8 @@ namespace Vocaluxe.Base
} }
} }
List<string> files = new List<string>();
var files = new List<string>();
foreach(string path in CSettings.FoldersProfiles) foreach(string path in CSettings.FoldersProfiles)
files.AddRange(CHelper.ListFiles(path, "*.xml", true, true)); files.AddRange(CHelper.ListFiles(path, "*.xml", true, true));
@@ -537,7 +538,7 @@ namespace Vocaluxe.Base
if (knownFiles.Contains(Path.GetFileName(file))) if (knownFiles.Contains(Path.GetFileName(file)))
continue; continue;
CProfile profile = new CProfile var profile = new CProfile
{ {
FileName = Path.GetFileName(file), FileName = Path.GetFileName(file),
FilePath = Path.GetDirectoryName(file) FilePath = Path.GetDirectoryName(file)
@@ -555,10 +556,10 @@ namespace Vocaluxe.Base
private static void _LoadAvatars() private static void _LoadAvatars()
{ {
List<string> knownFiles = new List<string>(); var knownFiles = new List<string>();
if (_Avatars.Count > 0) if (_Avatars.Count > 0)
{ {
int[] ids = new int[_Avatars.Keys.Count]; var ids = new int[_Avatars.Keys.Count];
_Avatars.Keys.CopyTo(ids, 0); _Avatars.Keys.CopyTo(ids, 0);
foreach (int id in ids) foreach (int id in ids)
{ {
@@ -569,7 +570,7 @@ namespace Vocaluxe.Base
} }
} }
List<string> files = new List<string>(); var files = new List<string>();
foreach (string path in CSettings.FoldersProfiles) foreach (string path in CSettings.FoldersProfiles)
{ {
files.AddRange(CHelper.ListFiles(path, "*.png", true, true)); files.AddRange(CHelper.ListFiles(path, "*.png", true, true));
@@ -583,7 +584,7 @@ namespace Vocaluxe.Base
if (knownFiles.Contains(Path.GetFileName(file))) if (knownFiles.Contains(Path.GetFileName(file)))
continue; continue;
CAvatar avatar = new CAvatar(-1); var avatar = new CAvatar(-1);
if (avatar.LoadFromFile(file)) if (avatar.LoadFromFile(file))
{ {
avatar.ID = _AvatarIDs.Dequeue(); avatar.ID = _AvatarIDs.Dequeue();
+1 -1
View File
@@ -222,7 +222,7 @@ namespace Vocaluxe.Base
public static void CreateFolders() public static void CreateFolders()
{ {
List<string> folders = new List<string> {FolderCover, FolderFonts, Path.Combine(DataPath,FolderScreenshots), FolderBackgroundMusic, FolderSounds, Path.Combine(DataPath,FolderPlaylists)}; var folders = new List<string> {FolderCover, FolderFonts, Path.Combine(DataPath,FolderScreenshots), FolderBackgroundMusic, FolderSounds, Path.Combine(DataPath,FolderPlaylists)};
folders.AddRange(FoldersProfiles); folders.AddRange(FoldersProfiles);
foreach (string folder in folders) foreach (string folder in folders)
+2 -2
View File
@@ -114,7 +114,7 @@ namespace Vocaluxe.Base
private List<CSongPointer> _CreateSortList(string fieldName) private List<CSongPointer> _CreateSortList(string fieldName)
{ {
List<CSongPointer> sortList = new List<CSongPointer>(); var sortList = new List<CSongPointer>();
if (fieldName == "") if (fieldName == "")
CSongs.Filter.FilteredSongs.ForEach(song => sortList.Add(new CSongPointer(song.ID, ""))); CSongs.Filter.FilteredSongs.ForEach(song => sortList.Add(new CSongPointer(song.ID, "")));
else else
@@ -135,7 +135,7 @@ namespace Vocaluxe.Base
sortList.Add(new CSongPointer(song.ID, (String)value)); sortList.Add(new CSongPointer(song.ID, (String)value));
else else
{ {
List<String> values = (List<String>)value; var values = (List<String>)value;
if (values.Count == 0) if (values.Count == 0)
sortList.Add(new CSongPointer(song.ID, "")); sortList.Add(new CSongPointer(song.ID, ""));
else else
+2 -2
View File
@@ -251,7 +251,7 @@ namespace Vocaluxe.Base
{ {
get get
{ {
List<CSong> songs = new List<CSong>(); var songs = new List<CSong>();
if (_IsCatIndexValid(_CatIndex)) if (_IsCatIndexValid(_CatIndex))
{ {
// ReSharper disable LoopCanBeConvertedToQuery // ReSharper disable LoopCanBeConvertedToQuery
@@ -298,7 +298,7 @@ namespace Vocaluxe.Base
_Songs.Clear(); _Songs.Clear();
CLog.StartBenchmark(2, "List Songs"); CLog.StartBenchmark(2, "List Songs");
List<string> files = new List<string>(); var files = new List<string>();
foreach (string p in CConfig.SongFolder) foreach (string p in CConfig.SongFolder)
{ {
string path = p; string path = p;
+4 -4
View File
@@ -450,11 +450,11 @@ namespace Vocaluxe.Base
int len = _AnalysisBuffer.Length * 2; int len = _AnalysisBuffer.Length * 2;
if (_Stream.Length >= len) if (_Stream.Length >= len)
{ {
byte[] buf = new byte[len]; var buf = new byte[len];
_Stream.Position -= len; _Stream.Position -= len;
_Stream.Read(buf, 0, len); _Stream.Read(buf, 0, len);
byte[] b = new byte[2]; var b = new byte[2];
for (int i = 0; i < _AnalysisBuffer.Length; i++) for (int i = 0; i < _AnalysisBuffer.Length; i++)
{ {
b[0] = buf[i * 2]; b[0] = buf[i * 2];
@@ -496,7 +496,7 @@ namespace Vocaluxe.Base
double maxWeight = -1.0; double maxWeight = -1.0;
double minWeight = 1.0; double minWeight = 1.0;
int maxTone = -1; int maxTone = -1;
float[] weigth = new float[_NumHalfTones]; var weigth = new float[_NumHalfTones];
// analyze halftones // analyze halftones
// Note: at the lowest tone (~65Hz) and a buffer-size of 4096 // Note: at the lowest tone (~65Hz) and a buffer-size of 4096
@@ -535,7 +535,7 @@ namespace Vocaluxe.Base
private double _AnalyzeAutocorrelationFreq(double freq) private double _AnalyzeAutocorrelationFreq(double freq)
{ {
int sampleIndex = 0; // index of sample to analyze 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 int correlatingSampleIndex = sampleIndex + samplesPerPeriod; // index of sample one period ahead
double accumDist = 0.0; // accumulated distances double accumDist = 0.0; // accumulated distances
+6 -2
View File
@@ -31,12 +31,16 @@ namespace Vocaluxe.Base
private static float _Fps; private static float _Fps;
private static readonly double _NanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency; private static readonly double _NanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
// ReSharper disable MemberCanBePrivate.Global
public static void Reset() public static void Reset()
// ReSharper restore MemberCanBePrivate.Global
{ {
_Stopwatch.Reset(); _Stopwatch.Reset();
} }
// ReSharper disable MemberCanBePrivate.Global
public static void Start() public static void Start()
// ReSharper restore MemberCanBePrivate.Global
{ {
_Stopwatch.Start(); _Stopwatch.Start();
} }
@@ -117,7 +121,7 @@ namespace Vocaluxe.Base
if (!_Timer.IsRunning || (_Timer.ElapsedMilliseconds > 75) || !keyRepeat) if (!_Timer.IsRunning || (_Timer.ElapsedMilliseconds > 75) || !keyRepeat)
{ {
SKeyEvent pool = new SKeyEvent(ESender.Keyboard, alt, shift, ctrl, pressed && (unicode != Char.MinValue), unicode, key); var pool = new SKeyEvent(ESender.Keyboard, alt, shift, ctrl, pressed && (unicode != Char.MinValue), unicode, key);
lock (_CopyLock) lock (_CopyLock)
{ {
@@ -226,7 +230,7 @@ namespace Vocaluxe.Base
x = (int)(x * (float)CSettings.RenderW / CDraw.GetScreenWidth()); x = (int)(x * (float)CSettings.RenderW / CDraw.GetScreenWidth());
y = (int)(y * (float)CSettings.RenderH / CDraw.GetScreenHeight()); y = (int)(y * (float)CSettings.RenderH / CDraw.GetScreenHeight());
SMouseEvent pool = new SMouseEvent(ESender.Mouse, _Mod, x, y, lb, ld, rb, -wheel / 120, lbh, rbh, mb, mbh); var pool = new SMouseEvent(ESender.Mouse, _Mod, x, y, lb, ld, rb, -wheel / 120, lbh, rbh, mb, mbh);
lock (_CopyLock) lock (_CopyLock)
{ {
+1 -1
View File
@@ -168,7 +168,7 @@ namespace Vocaluxe.Base
} }
if (_VideoTexture == null) if (_VideoTexture == null)
return; return;
RectangleF bounds = new RectangleF(0f, 0f, CSettings.RenderW, CSettings.RenderH); var bounds = new RectangleF(0f, 0f, CSettings.RenderW, CSettings.RenderH);
RectangleF rect; RectangleF rect;
CHelper.SetRect(bounds, out rect, _VideoTexture.OrigAspect, EAspect.Crop); CHelper.SetRect(bounds, out rect, _VideoTexture.OrigAspect, EAspect.Crop);
+3 -3
View File
@@ -258,7 +258,7 @@ namespace Vocaluxe.Base.Fonts
Height = height; Height = height;
SetFont(text.Font); SetFont(text.Font);
Style = text.Style; Style = text.Style;
RectangleF result = new RectangleF(text.X, text.Y, GetTextWidth(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))); GetTextHeight(CLanguage.Translate(text.Text, text.TranslationID)));
//restore old values //restore old values
Height = oldHeight; Height = oldHeight;
@@ -286,7 +286,7 @@ namespace Vocaluxe.Base.Fonts
int i = 1; int i = 1;
while (xmlReader.GetValue("//root/Fonts/Font" + i + "/Folder", out value, value)) 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; bool ok = true;
@@ -297,7 +297,7 @@ namespace Vocaluxe.Base.Fonts
ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/FileNormal", out value, value); ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/FileNormal", out value, value);
sf.FileNormal = value; sf.FileNormal = value;
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value)); value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
CFont f = new CFont(value); var f = new CFont(value);
sf.Normal = f; sf.Normal = f;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/FileItalic", out value, value); ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/FileItalic", out value, value);
+7 -5
View File
@@ -80,7 +80,7 @@ namespace Vocaluxe.Base.Fonts
bmpSize = new Size(1, 1); bmpSize = new Size(1, 1);
} }
} }
using (Bitmap bmp = new Bitmap(bmpSize.Width, bmpSize.Height, PixelFormat.Format32bppArgb)) using (var bmp = new Bitmap(bmpSize.Width, bmpSize.Height, PixelFormat.Format32bppArgb))
using (Graphics g = Graphics.FromImage(bmp)) using (Graphics g = Graphics.FromImage(bmp))
{ {
g.Clear(Color.Transparent); g.Clear(Color.Transparent);
@@ -96,15 +96,15 @@ namespace Vocaluxe.Base.Fonts
g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
PointF point = new PointF(outlineSize / 2, outlineSize / 4); var point = new PointF(outlineSize / 2, outlineSize / 4);
using (GraphicsPath path = new GraphicsPath()) using (var path = new GraphicsPath())
{ {
//Have to use size in em not pixels! //Have to use size in em not pixels!
float emSize = fo.Size * fo.FontFamily.GetCellAscent(fo.Style) / fo.FontFamily.GetEmHeight(fo.Style); float emSize = fo.Size * fo.FontFamily.GetCellAscent(fo.Style) / fo.FontFamily.GetEmHeight(fo.Style);
path.AddString(chrString, fo.FontFamily, (int)fo.Style, emSize, point, new StringFormat()); path.AddString(chrString, fo.FontFamily, (int)fo.Style, emSize, point, new StringFormat());
using (Pen pen = new Pen(CFonts.OutlineColor.AsColor(), outlineSize)) using (var pen = new Pen(CFonts.OutlineColor.AsColor(), outlineSize))
{ {
pen.LineJoin = LineJoin.Round; pen.LineJoin = LineJoin.Round;
g.DrawPath(pen, path); g.DrawPath(pen, path);
@@ -123,6 +123,7 @@ namespace Vocaluxe.Base.Fonts
_DrawBounding.Height = _Texture.Height;*/ _DrawBounding.Height = _Texture.Height;*/
#pragma warning disable 162 #pragma warning disable 162
// ReSharper disable HeuristicUnreachableCode // ReSharper disable HeuristicUnreachableCode
// ReSharper disable ConditionIsAlwaysTrueOrFalse
if (false && Char.IsLetterOrDigit(chr)) if (false && Char.IsLetterOrDigit(chr))
{ {
if (outline > 0) if (outline > 0)
@@ -130,6 +131,7 @@ namespace Vocaluxe.Base.Fonts
else else
bmpCropped.Save("font_" + chr + CFonts.Style + "2.png", ImageFormat.Png); bmpCropped.Save("font_" + chr + CFonts.Style + "2.png", ImageFormat.Png);
} }
// ReSharper restore ConditionIsAlwaysTrueOrFalse
// ReSharper restore HeuristicUnreachableCode // ReSharper restore HeuristicUnreachableCode
#pragma warning restore 162 #pragma warning restore 162
} }
@@ -164,7 +166,7 @@ namespace Vocaluxe.Base.Fonts
int minX = 0, maxX = bmp.Width - 1, minY = 0; int minX = 0, maxX = bmp.Width - 1, minY = 0;
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
int values = bmpData.Width * bmp.Height; int values = bmpData.Width * bmp.Height;
Int32[] rgbValues = new Int32[values]; var rgbValues = new Int32[values];
Marshal.Copy(bmpData.Scan0, rgbValues, 0, values); Marshal.Copy(bmpData.Scan0, rgbValues, 0, values);
int index = 0; int index = 0;
bool found = false; bool found = false;
+2 -2
View File
@@ -21,12 +21,12 @@ namespace Vocaluxe.Base.Server
{ {
class CClientHandler class CClientHandler
{ {
public int ConnectionID; private int _ConnectionID;
public bool LoggedIn; public bool LoggedIn;
public CClientHandler(int connectionID) public CClientHandler(int connectionID)
{ {
ConnectionID = connectionID; _ConnectionID = connectionID;
LoggedIn = false; LoggedIn = false;
} }
} }
+61 -61
View File
@@ -1,22 +1,39 @@
using System; #region license
using System.Collections.Generic; // /*
using System.Linq; // 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 <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Security.Cryptography; using System.Security.Cryptography;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Vocaluxe.Base.Server namespace Vocaluxe.Base.Server
{ {
public static class CCommands public static class CCommands
{ {
private static UTF8Encoding encoder = new UTF8Encoding(); private static readonly UTF8Encoding _Encoder = new UTF8Encoding();
public static SHA256Managed SHA256 = new SHA256Managed(); private static readonly SHA256Managed _Sha256 = new SHA256Managed();
public const string BroadcastKeyword = "I am a Vocaluxe Server"; public const string BroadcastKeyword = "I am a Vocaluxe Server";
#region Commands #region Commands
// ReSharper disable UnusedMember.Global
public const int ResponseOK = 1; public const int ResponseOK = 1;
public const int ResponseNOK = 2; public const int ResponseNOK = 2;
@@ -25,7 +42,6 @@ namespace Vocaluxe.Base.Server
public const int ResponseLoginFailed = 22; public const int ResponseLoginFailed = 22;
public const int ResponseLoginOK = 23; public const int ResponseLoginOK = 23;
public const int CommandSendKeyStroke = 100; public const int CommandSendKeyStroke = 100;
public const int CommandSendKeyUp = 110; public const int CommandSendKeyUp = 110;
public const int CommandSendKeyDown = 111; public const int CommandSendKeyDown = 111;
@@ -45,105 +61,92 @@ namespace Vocaluxe.Base.Server
public const int CommandSendAvatarPictureJpg = 501; public const int CommandSendAvatarPictureJpg = 501;
public const int CommandSendProfile = 510; public const int CommandSendProfile = 510;
// ReSharper restore UnusedMember.Global
#endregion Commands #endregion Commands
#region General #region General
public static byte[] CreateCommandWithoutParams(int Command) public static byte[] CreateCommandWithoutParams(int command)
{ {
return BitConverter.GetBytes(Command); return BitConverter.GetBytes(command);
} }
#endregion General #endregion General
#region Login #region Login
public static byte[] CreateCommandLogin(string Password) public static byte[] CreateCommandLogin(string password)
{ {
SLoginData data = new SLoginData(); var data = new SLoginData {Sha256 = _Sha256.ComputeHash(Encoding.UTF8.GetBytes(password))};
data.SHA256 = SHA256.ComputeHash(Encoding.UTF8.GetBytes(Password));
return Serialize<SLoginData>(CommandLogin, data); return _Serialize(CommandLogin, data);
} }
public static bool DecodeCommandLogin(byte[] Message, out SLoginData LoginData) public static bool DecodeCommandLogin(byte[] message, out SLoginData loginData)
{ {
return TryDeserialize<SLoginData>(Message, out LoginData); return _TryDeserialize(message, out loginData);
} }
#endregion Login #endregion Login
#region Keyboard #region Keyboard
#endregion Keyboard #endregion Keyboard
#region Profiles #region Profiles
public static byte[] CreateCommandSendAvatarPicture(int Width, int Height, byte[] data) public static byte[] CreateCommandSendAvatarPicture(int width, int height, byte[] data)
{ {
SAvatarPicture ap = new SAvatarPicture(); var ap = new SAvatarPicture {Height = height, Width = width, Data = new byte[data.Length]};
ap.Height = Height; Array.Copy(data, ap.Data, data.Length);
ap.Width = Width;
ap.data = new byte[data.Length];
Array.Copy(data, ap.data, data.Length);
return Serialize<SAvatarPicture>(CommandSendAvatarPicture, ap); return _Serialize(CommandSendAvatarPicture, ap);
} }
public static bool DecodeCommandSendAvatarPicture(byte[] Message, out SAvatarPicture AvatarPicture) public static bool DecodeCommandSendAvatarPicture(byte[] message, out SAvatarPicture avatarPicture)
{ {
return TryDeserialize<SAvatarPicture>(Message, out AvatarPicture); return _TryDeserialize(message, out avatarPicture);
} }
public static byte[] CreateCommandSendAvatarPictureJpg(byte[] AvatarJpgData) public static byte[] CreateCommandSendAvatarPictureJpg(byte[] avatarJpgData)
{ {
SAvatarPicture ap = new SAvatarPicture(); var ap = new SAvatarPicture {Height = 0, Width = 0, Data = new byte[avatarJpgData.Length]};
ap.Height = 0; Array.Copy(avatarJpgData, ap.Data, avatarJpgData.Length);
ap.Width = 0;
ap.data = new byte[AvatarJpgData.Length];
Array.Copy(AvatarJpgData, ap.data, AvatarJpgData.Length);
return Serialize<SAvatarPicture>(CommandSendAvatarPictureJpg, ap); return _Serialize(CommandSendAvatarPictureJpg, ap);
} }
public static byte[] CreateCommandSendProfile(byte[] AvatarJpgData, string PlayerName, int Difficulty) public static byte[] CreateCommandSendProfile(byte[] avatarJpgData, string playerName, int difficulty)
{ {
SAvatarPicture ap = new SAvatarPicture(); var ap = new SAvatarPicture {Height = 0, Width = 0, Data = new byte[avatarJpgData.Length]};
ap.Height = 0; Array.Copy(avatarJpgData, ap.Data, avatarJpgData.Length);
ap.Width = 0;
ap.data = new byte[AvatarJpgData.Length];
Array.Copy(AvatarJpgData, ap.data, AvatarJpgData.Length);
SProfile profile = new SProfile(); var profile = new SProfile {Avatar = ap, PlayerName = playerName, Difficulty = difficulty};
profile.Avatar = ap;
profile.PlayerName = PlayerName;
profile.Difficulty = Difficulty;
return Serialize<SProfile>(CommandSendProfile, profile); return _Serialize(CommandSendProfile, profile);
} }
public static bool DecodeCommandSendProfile(byte[] Message, out SProfile Profile) public static bool DecodeCommandSendProfile(byte[] message, out SProfile profile)
{ {
return TryDeserialize<SProfile>(Message, out Profile); return _TryDeserialize(message, out profile);
} }
#endregion Profiles #endregion Profiles
#region Serializing #region Serializing
private static byte[] Serialize<T>(int Command, T obj) private static byte[] _Serialize<T>(T obj)
{ {
byte[] command = BitConverter.GetBytes(Command); return _Serialize(0, obj);
}
MemoryStream stream = new MemoryStream(); private static byte[] _Serialize<T>(int command, T obj)
stream.Write(command, 0, command.Length); {
byte[] cmd = BitConverter.GetBytes(command);
var stream = new MemoryStream();
stream.Write(cmd, 0, cmd.Length);
byte[] data; byte[] data;
using (MemoryStream ms = new MemoryStream())
{
string json = JsonConvert.SerializeObject(obj); string json = JsonConvert.SerializeObject(obj);
data = encoder.GetBytes(json); data = _Encoder.GetBytes(json);
}
stream.Write(data, 0, data.Length); stream.Write(data, 0, data.Length);
return stream.ToArray(); return stream.ToArray();
} }
private static bool TryDeserialize<T>(byte[] message, out T obj) private static bool _TryDeserialize<T>(byte[] message, out T obj)
{ {
obj = default(T); obj = default(T);
@@ -153,13 +156,11 @@ namespace Vocaluxe.Base.Server
if (message.Length < 5) if (message.Length < 5)
return false; return false;
byte[] data = new byte[message.Length - 4]; var data = new byte[message.Length - 4];
Array.Copy(message, 4, data, 0, data.Length); Array.Copy(message, 4, data, 0, data.Length);
using (MemoryStream ms = new MemoryStream(data))
{
try try
{ {
obj = JsonConvert.DeserializeObject<T>(encoder.GetString(data)); obj = JsonConvert.DeserializeObject<T>(_Encoder.GetString(data));
return true; return true;
} }
catch catch
@@ -167,7 +168,6 @@ namespace Vocaluxe.Base.Server
return false; return false;
} }
} }
}
#endregion Serializing #endregion Serializing
} }
} }
+12 -13
View File
@@ -22,9 +22,7 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Linq;
using System.IO; using System.IO;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using ClientServerLib; using ClientServerLib;
using Vocaluxe.Lib.Input; using Vocaluxe.Lib.Input;
@@ -44,10 +42,8 @@ namespace Vocaluxe.Base.Server
public static void Init() public static void Init()
{ {
_Clients = new Dictionary<int, CClientHandler>(); _Clients = new Dictionary<int, CClientHandler>();
if (CConfig.ServerEncryption == EOffOn.TR_CONFIG_ON) String pw = (CConfig.ServerEncryption == EOffOn.TR_CONFIG_ON) ? CConfig.ServerPassword : String.Empty;
_Server = new CServer(RequestHandler, CConfig.ServerPort, CConfig.ServerPassword); _Server = new CServer(RequestHandler, CConfig.ServerPort, pw);
else
_Server = new CServer(RequestHandler, CConfig.ServerPort, String.Empty);
_Discover = new CDiscover(CConfig.ServerPort, CCommands.BroadcastKeyword); _Discover = new CDiscover(CConfig.ServerPort, CCommands.BroadcastKeyword);
Controller.Init(); Controller.Init();
@@ -84,13 +80,16 @@ namespace Vocaluxe.Base.Server
{ {
if (!_Clients.ContainsKey(connectionID)) if (!_Clients.ContainsKey(connectionID))
{ {
CClientHandler client = new CClientHandler(connectionID); var client = new CClientHandler(connectionID);
_Clients.Add(connectionID, client); _Clients.Add(connectionID, client);
} }
loggedIn = _Clients[connectionID].LoggedIn; loggedIn = _Clients[connectionID].LoggedIn;
} }
if (!loggedIn)
return CCommands.CreateCommandWithoutParams(CCommands.ResponseNOK);
int command = BitConverter.ToInt32(message, 0); int command = BitConverter.ToInt32(message, 0);
switch (command) switch (command)
@@ -120,10 +119,10 @@ namespace Vocaluxe.Base.Server
SAvatarPicture avatarPicture; SAvatarPicture avatarPicture;
if (CCommands.DecodeCommandSendAvatarPicture(message, out 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); 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); Marshal.Copy(avatarPicture.Data, 0, bmpData.Scan0, avatarPicture.Data.Length);
bmp.UnlockBits(bmpData); bmp.UnlockBits(bmpData);
const string filename = "snapshot"; const string filename = "snapshot";
@@ -142,7 +141,7 @@ namespace Vocaluxe.Base.Server
SAvatarPicture avatarPictureJpg; SAvatarPicture avatarPictureJpg;
if (CCommands.DecodeCommandSendAvatarPicture(message, out avatarPictureJpg)) if (CCommands.DecodeCommandSendAvatarPicture(message, out avatarPictureJpg))
{ {
if (_AddAvatar(avatarPictureJpg.data) != String.Empty) if (_AddAvatar(avatarPictureJpg.Data) != String.Empty)
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK); answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
} }
break; break;
@@ -153,10 +152,10 @@ namespace Vocaluxe.Base.Server
{ {
try try
{ {
string avatarFilename = _AddAvatar(profile.Avatar.data); string avatarFilename = _AddAvatar(profile.Avatar.Data);
if (avatarFilename != String.Empty) if (avatarFilename != String.Empty)
{ {
CProfile p = new CProfile var p = new CProfile
{ {
Active = EOffOn.TR_CONFIG_ON, Active = EOffOn.TR_CONFIG_ON,
AvatarFileName = avatarFilename, AvatarFileName = avatarFilename,
@@ -193,7 +192,7 @@ namespace Vocaluxe.Base.Server
fs.Flush(); fs.Flush();
fs.Close(); fs.Close();
CAvatar avatar = new CAvatar(-1); var avatar = new CAvatar(-1);
if (avatar.LoadFromFile(filename)) if (avatar.LoadFromFile(filename))
{ {
CProfiles.AddAvatar(avatar); CProfiles.AddAvatar(avatar);
+20 -3
View File
@@ -1,17 +1,34 @@
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 <http://www.gnu.org/licenses/>.
// */
#endregion
namespace Vocaluxe.Base.Server namespace Vocaluxe.Base.Server
{ {
public struct SLoginData public struct SLoginData
{ {
public byte[] SHA256; public byte[] Sha256;
} }
public struct SAvatarPicture public struct SAvatarPicture
{ {
public int Width; public int Width;
public int Height; public int Height;
public byte[] data; public byte[] Data;
} }
public struct SProfile public struct SProfile
+2 -2
View File
@@ -70,7 +70,7 @@ namespace Vocaluxe.GameModes
{ {
protected override CSong _PrepareSong(CSong song) 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 // set lines to short mode
newSong.Notes.SetMedley(song.Notes.GetVoice(0).Lines[0].FirstNoteBeat, song.ShortEnd); 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) 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) if (newSong.Start < 0f)
newSong.Start = 0f; newSong.Start = 0f;
+13 -13
View File
@@ -448,7 +448,7 @@ namespace Vocaluxe.Lib.Draw
if (_Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate).IsFailure) if (_Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate).IsFailure)
CLog.LogError("Failed to set alpha operation"); CLog.LogError("Failed to set alpha operation");
Int16[] indices = new Int16[6]; var indices = new Int16[6];
indices[0] = 0; indices[0] = 0;
indices[1] = 1; indices[1] = 1;
indices[2] = 2; 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 creates a new white texture and adds it to the texture pool
//This texture is used for the DrawRect method //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); Graphics g = Graphics.FromImage(blankMap);
g.Clear(Color.White); g.Clear(Color.White);
@@ -674,7 +674,7 @@ namespace Vocaluxe.Lib.Draw
CTexture texture = _GetNewTexture(_W, _H); CTexture texture = _GetNewTexture(_W, _H);
Surface backbufferSurface = _Device.GetBackBuffer(0, 0); 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 textureSurface = tex.GetSurfaceLevel(0);
Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0, new Rectangle(0, 0, _W, _H), new Rectangle(0, 0, _W, _H)); Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0, new Rectangle(0, 0, _W, _H), new Rectangle(0, 0, _W, _H));
backbufferSurface.Dispose(); backbufferSurface.Dispose();
@@ -722,7 +722,7 @@ namespace Vocaluxe.Lib.Draw
//create a surface of the frame //create a surface of the frame
using (Surface surface = _Device.GetBackBuffer(0, 0)) 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.Save(Path.Combine(path, file + i.ToString("00000") + ".bmp"), ImageFormat.Bmp);
screen.Dispose(); screen.Dispose();
} }
@@ -742,8 +742,8 @@ namespace Vocaluxe.Lib.Draw
/// <param name="y2">The end y-value</param> /// <param name="y2">The end y-value</param>
public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2) 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)}; var lineVector = new Vector2[] {new Vector2(x1, y1), new Vector2(x2, y2)};
using (Line line = new Line(_Device)) using (var line = new Line(_Device))
{ {
line.Antialias = true; line.Antialias = true;
line.Begin(); line.Begin();
@@ -850,7 +850,7 @@ namespace Vocaluxe.Lib.Draw
w = _CheckForNextPowerOf2(w); w = _CheckForNextPowerOf2(w);
h = _CheckForNextPowerOf2(h); 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; Bitmap bmp2 = null;
byte[] data; 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 //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 //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); _WriteDataToTexture(t, w, data);
return t; return t;
} }
@@ -939,7 +939,7 @@ namespace Vocaluxe.Lib.Draw
{ {
texture.ID = _IDs.Dequeue(); texture.ID = _IDs.Dequeue();
_D3DTextures.Add(texture.ID, null); _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); _TexturesToLoad.Enqueue(queue);
} }
return texture; return texture;
@@ -1122,7 +1122,7 @@ namespace Vocaluxe.Lib.Draw
if (!mirrored) 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[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[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()); 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 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[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[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()); 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(); 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[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[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()); 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.A = 0;
Color transparent = color.AsColor(); 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[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[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()); vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), transparent.ToArgb());
+7 -7
View File
@@ -289,7 +289,7 @@ namespace Vocaluxe.Lib.Draw
public CTexture CopyScreen() public CTexture CopyScreen()
{ {
Bitmap bmp = new Bitmap(_Backbuffer); var bmp = new Bitmap(_Backbuffer);
_Bitmaps.Add(bmp); _Bitmaps.Add(bmp);
CTexture texture = _GetNewTexture(bmp.Width, bmp.Height); CTexture texture = _GetNewTexture(bmp.Width, bmp.Height);
@@ -333,7 +333,7 @@ namespace Vocaluxe.Lib.Draw
public CTexture AddTexture(Bitmap bmp) public CTexture AddTexture(Bitmap bmp)
{ {
Bitmap bmp2 = new Bitmap(bmp); var bmp2 = new Bitmap(bmp);
_Bitmaps.Add(bmp2); _Bitmaps.Add(bmp2);
CTexture texture = _GetNewTexture(bmp.Width, bmp.Height); CTexture texture = _GetNewTexture(bmp.Width, bmp.Height);
@@ -357,7 +357,7 @@ namespace Vocaluxe.Lib.Draw
if (tex.TexturePath == texturePath) if (tex.TexturePath == texturePath)
return tex; return tex;
} }
using (Bitmap bmp = new Bitmap(texturePath)) using (var bmp = new Bitmap(texturePath))
{ {
CTexture texture = AddTexture(bmp); CTexture texture = AddTexture(bmp);
texture.TexturePath = texturePath; texture.TexturePath = texturePath;
@@ -389,7 +389,7 @@ namespace Vocaluxe.Lib.Draw
public CTexture AddTexture(int w, int h, byte[] data) 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); BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
Marshal.Copy(data, 0, bmpData.Scan0, data.Length); Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
@@ -459,13 +459,13 @@ namespace Vocaluxe.Lib.Draw
private static Bitmap _ColorizeBitmap(Bitmap original, SColorF color) 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)) 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); ia.SetColorMatrix(cm);
+5 -5
View File
@@ -124,7 +124,7 @@ namespace Vocaluxe.Lib.Draw
bool ok = false; bool ok = false;
try 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); _Control = new GLControl(gm, 2, 1, GraphicsContextFlags.Default);
if (_Control.GraphicsMode != null) if (_Control.GraphicsMode != null)
ok = true; ok = true;
@@ -473,7 +473,7 @@ namespace Vocaluxe.Lib.Draw
Close(); Close();
} }
catch {} catch {}
CTexture[] textures = new CTexture[_Textures.Count]; var textures = new CTexture[_Textures.Count];
_Textures.Values.CopyTo(textures, 0); _Textures.Values.CopyTo(textures, 0);
for (int i = 0; i < _Textures.Count; i++) for (int i = 0; i < _Textures.Count; i++)
RemoveTexture(ref textures[i]); RemoveTexture(ref textures[i]);
@@ -552,7 +552,7 @@ namespace Vocaluxe.Lib.Draw
int width = GetScreenWidth(); int width = GetScreenWidth();
int height = GetScreenHeight(); 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); 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); w = MathHelper.NextPowerOfTwo(w);
h = MathHelper.NextPowerOfTwo(h); 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); GL.BindTexture(TextureTarget.Texture2D, texture.Name);
Bitmap bmp2 = null; Bitmap bmp2 = null;
@@ -813,7 +813,7 @@ namespace Vocaluxe.Lib.Draw
lock (_MutexTexture) lock (_MutexTexture)
{ {
texture.ID = _IDs.Dequeue(); 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); _TexturesToLoad.Enqueue(queue);
_Textures[texture.ID] = texture; _Textures[texture.ID] = texture;
} }
+5 -5
View File
@@ -205,7 +205,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
bool lb = false; bool lb = false;
bool rb = gesture == EGesture.Back; bool rb = gesture == EGesture.Back;
Keys key = Keys.None; var key = Keys.None;
if (ws.ButtonState.A && !_ButtonStates[0]) if (ws.ButtonState.A && !_ButtonStates[0])
lb = true; lb = true;
@@ -247,7 +247,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
if (key != Keys.None) 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) lock (_KeyCopyLock)
{ {
@@ -261,8 +261,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
float rx = ((p.X / 1024f) - reducing) * factor; float rx = ((p.X / 1024f) - reducing) * factor;
float ry = ((p.Y / 768f) - reducing) * factor; float ry = ((p.Y / 768f) - reducing) * factor;
int x = (int)(rx * CSettings.RenderW); var x = (int)(rx * CSettings.RenderW);
int y = (int)(ry * CSettings.RenderH); var y = (int)(ry * CSettings.RenderH);
bool lbh = !lb && ws.ButtonState.A; bool lbh = !lb && ws.ButtonState.A;
@@ -273,7 +273,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
if (gesture == EGesture.ScrollDown) if (gesture == EGesture.ScrollDown)
wheel = 1; wheel = 1;
SMouseEvent mpool = new SMouseEvent(); var mpool = new SMouseEvent();
bool trigger = false; bool trigger = false;
if (!lb && !rb && (p.X != _OldPosition.X || p.Y != _OldPosition.Y)) if (!lb && !rb && (p.X != _OldPosition.X || p.Y != _OldPosition.Y))
+2 -2
View File
@@ -336,7 +336,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
if (_Handle != IntPtr.Zero && Connected) if (_Handle != IntPtr.Zero && Connected)
{ {
byte[] buff = new byte[_ReportLength]; var buff = new byte[_ReportLength];
try try
{ {
@@ -364,7 +364,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
return false; return false;
} }
EInputReport type = (EInputReport)buff[0]; var type = (EInputReport)buff[0];
switch (type) switch (type)
{ {
+6 -6
View File
@@ -147,7 +147,7 @@ namespace Vocaluxe.Lib.Playlist
Songs = new List<CPlaylistSong>(); Songs = new List<CPlaylistSong>();
List<string> songs = xmlReader.GetValues("Songs"); List<string> songs = xmlReader.GetValues("Songs");
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; var gm = EGameMode.TR_GAMEMODE_NORMAL;
foreach (string song in songs) foreach (string song in songs)
{ {
@@ -157,7 +157,7 @@ namespace Vocaluxe.Lib.Playlist
xmlReader.GetValue("//root/Songs/" + song + "/Title", out title, String.Empty); xmlReader.GetValue("//root/Songs/" + song + "/Title", out title, String.Empty);
xmlReader.TryGetEnumValue("//root/Songs/" + song + "/GameMode", ref gm); 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) foreach (CSong curSong in CSongs.AllSongs)
{ {
@@ -182,14 +182,14 @@ namespace Vocaluxe.Lib.Playlist
public void AddSong(int songID) 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); Songs.Add(song);
} }
public void AddSong(int songID, EGameMode gm) 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); 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) if (sourceNr < 0 || destNr < 0 || sourceNr == destNr || sourceNr > Songs.Count - 1 || destNr > Songs.Count - 1)
return; return;
CPlaylistSong ps = new CPlaylistSong(Songs[sourceNr]); var ps = new CPlaylistSong(Songs[sourceNr]);
Songs.RemoveAt(sourceNr); Songs.RemoveAt(sourceNr);
Songs.Insert(destNr, ps); Songs.Insert(destNr, ps);
} }
@@ -226,7 +226,7 @@ namespace Vocaluxe.Lib.Playlist
if (destNr < 0 || destNr > Songs.Count - 1) if (destNr < 0 || destNr > Songs.Count - 1)
return; return;
CPlaylistSong ps = new CPlaylistSong(songID, gm); var ps = new CPlaylistSong(songID, gm);
Songs.Insert(destNr, ps); Songs.Insert(destNr, ps);
} }
} }
+10 -10
View File
@@ -53,9 +53,9 @@ namespace Vocaluxe.Lib.Sound
int id = 0; int id = 0;
foreach (DeviceInformation dev in devices) 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) if (device.Channels > 2)
device.Channels = 2; //more are not supported in vocaluxe device.Channels = 2; //more are not supported in vocaluxe
@@ -89,9 +89,9 @@ namespace Vocaluxe.Lib.Sound
foreach (CBuffer buffer in _Buffer) foreach (CBuffer buffer in _Buffer)
buffer.Reset(); buffer.Reset();
bool[] active = new bool[_Devices.Count]; var active = new bool[_Devices.Count];
Guid[] guid = new Guid[_Devices.Count]; var guid = new Guid[_Devices.Count];
short[] channels = new short[_Devices.Count]; var channels = new short[_Devices.Count];
for (int dev = 0; dev < _Devices.Count; dev++) for (int dev = 0; dev < _Devices.Count; dev++)
{ {
active[dev] = false; active[dev] = false;
@@ -105,7 +105,7 @@ namespace Vocaluxe.Lib.Sound
{ {
if (active[i]) 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.SampleDataReady += _OnDataReady;
source.Start(); source.Start();
@@ -209,8 +209,8 @@ namespace Vocaluxe.Lib.Sound
{ {
if (_Initialized) if (_Initialized)
{ {
byte[] leftBuffer = new byte[e.Data.Length / 2]; var leftBuffer = new byte[e.Data.Length / 2];
byte[] rightBuffer = new byte[e.Data.Length / 2]; var rightBuffer = new byte[e.Data.Length / 2];
//[]: Sample, L: Left channel R: Right channel //[]: Sample, L: Left channel R: Right channel
//[LR][LR][LR][LR][LR][LR] //[LR][LR][LR][LR][LR][LR]
@@ -318,7 +318,7 @@ namespace Vocaluxe.Lib.Sound
for (int i = 0; i < _BufferPortionCount; i++) 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); _Notifications.Add(notification);
} }
@@ -371,7 +371,7 @@ namespace Vocaluxe.Lib.Sound
int bufferPortionSamples = _BufferPortionSize / sizeof(byte); int bufferPortionSamples = _BufferPortionSize / sizeof(byte);
// Buffer type must match this.waveFormat.FormatTag and this.waveFormat.BitsPerSample // Buffer type must match this.waveFormat.FormatTag and this.waveFormat.BitsPerSample
byte[] bufferPortion = new byte[bufferPortionSamples]; var bufferPortion = new byte[bufferPortionSamples];
_CaptureBuffer.Start(true); _CaptureBuffer.Start(true);
+2 -2
View File
@@ -65,14 +65,14 @@ namespace Vocaluxe.Lib.Sound
public int Load(string media) public int Load(string media)
{ {
Uri u = new Uri(media); var u = new Uri(media);
int i = CGstreamerAudioWrapper.Load(u.AbsoluteUri); int i = CGstreamerAudioWrapper.Load(u.AbsoluteUri);
return i; return i;
} }
public int Load(string media, bool prescan) public int Load(string media, bool prescan)
{ {
Uri u = new Uri(media); var u = new Uri(media);
int i = CGstreamerAudioWrapper.Load(u.AbsoluteUri, prescan); int i = CGstreamerAudioWrapper.Load(u.AbsoluteUri, prescan);
return i; return i;
} }
+5 -5
View File
@@ -106,8 +106,8 @@ namespace Vocaluxe.Lib.Sound
public int Load(string media, bool prescan) public int Load(string media, bool prescan)
{ {
SAudioStreams stream = new SAudioStreams(0); var stream = new SAudioStreams(0);
COpenAlStream decoder = new COpenAlStream(); var decoder = new COpenAlStream();
if (decoder.Open(media) > -1) if (decoder.Open(media) > -1)
{ {
@@ -595,7 +595,7 @@ namespace Vocaluxe.Lib.Sound
_CurrentTime = 0f; _CurrentTime = 0f;
_Timer.Reset(); _Timer.Reset();
SAudioStreams stream = new SAudioStreams(0) {Handle = _Buffers[0]}; var stream = new SAudioStreams(0) {Handle = _Buffers[0]};
if (stream.Handle != 0) if (stream.Handle != 0)
{ {
@@ -782,7 +782,7 @@ namespace Vocaluxe.Lib.Sound
return; return;
} }
byte[] buf = new byte[_BufferSize]; var buf = new byte[_BufferSize];
lock (_MutexData) lock (_MutexData)
{ {
@@ -793,7 +793,7 @@ namespace Vocaluxe.Lib.Sound
_Data.Read(buf); _Data.Read(buf);
byte[] b = new byte[2]; var b = new byte[2];
for (int i = 0; i < buf.Length; i += _ByteCount) for (int i = 0; i < buf.Length; i += _ByteCount)
{ {
b[0] = buf[i]; b[0] = buf[i];
+8 -8
View File
@@ -91,8 +91,8 @@ namespace Vocaluxe.Lib.Sound
public int Load(string media, bool prescan) public int Load(string media, bool prescan)
{ {
SAudioStreams stream = new SAudioStreams(0); var stream = new SAudioStreams(0);
CPortAudioStream decoder = new CPortAudioStream(); var decoder = new CPortAudioStream();
if (decoder.Open(media) > -1) if (decoder.Open(media) > -1)
{ {
@@ -599,11 +599,11 @@ namespace Vocaluxe.Lib.Sound
_CurrentTime = 0f; _CurrentTime = 0f;
_SyncTimer.Time = _CurrentTime; _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, ChannelCount = format.ChannelCount,
Device = _ApiInfo.DefaultOutputDevice, Device = _ApiInfo.DefaultOutputDevice,
@@ -611,7 +611,7 @@ namespace Vocaluxe.Lib.Sound
SuggestedLatency = _OutputDeviceInfo.DefaultLowOutputLatency SuggestedLatency = _OutputDeviceInfo.DefaultLowOutputLatency
}; };
uint bufsize = (uint)CConfig.AudioBufferSize; var bufsize = (uint)CConfig.AudioBufferSize;
lock (_Mutex) lock (_Mutex)
{ {
_ErrorCheck("OpenDefaultStream (playback)", CPortAudio.Pa_OpenStream( _ErrorCheck("OpenDefaultStream (playback)", CPortAudio.Pa_OpenStream(
@@ -797,7 +797,7 @@ namespace Vocaluxe.Lib.Sound
CPortAudio.EPaStreamCallbackFlags statusFlags, CPortAudio.EPaStreamCallbackFlags statusFlags,
IntPtr userData) IntPtr userData)
{ {
byte[] buf = new byte[frameCount * _ByteCount]; var buf = new byte[frameCount * _ByteCount];
if (_Paused) if (_Paused)
{ {
@@ -818,7 +818,7 @@ namespace Vocaluxe.Lib.Sound
{ {
_Data.Read(buf); _Data.Read(buf);
byte[] b = new byte[2]; var b = new byte[2];
for (int i = 0; i < buf.Length; i += _ByteCount) for (int i = 0; i < buf.Length; i += _ByteCount)
{ {
b[0] = buf[i]; b[0] = buf[i];
+6 -6
View File
@@ -73,7 +73,7 @@ namespace Vocaluxe.Lib.Sound
CPortAudio.SPaDeviceInfo info = CPortAudio.PaGetDeviceInfo(i); CPortAudio.SPaDeviceInfo info = CPortAudio.PaGetDeviceInfo(i);
if (info.HostApi == hostAPI && info.MaxInputChannels > 0) 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) if (dev.Channels > 2)
dev.Channels = 2; //more are not supported in vocaluxe 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++) for (int i = 0; i < _RecHandle.Length; i++)
_RecHandle[i] = IntPtr.Zero; _RecHandle[i] = IntPtr.Zero;
bool[] active = new bool[_Devices.Count]; var active = new bool[_Devices.Count];
for (int dev = 0; dev < _Devices.Count; dev++) for (int dev = 0; dev < _Devices.Count; dev++)
{ {
active[dev] = false; active[dev] = false;
@@ -135,7 +135,7 @@ namespace Vocaluxe.Lib.Sound
{ {
if (active[i]) if (active[i])
{ {
CPortAudio.SPaStreamParameters inputParams = new CPortAudio.SPaStreamParameters var inputParams = new CPortAudio.SPaStreamParameters
{ {
ChannelCount = _Devices[i].Channels, ChannelCount = _Devices[i].Channels,
Device = _Devices[i].ID, Device = _Devices[i].ID,
@@ -283,9 +283,9 @@ namespace Vocaluxe.Lib.Sound
frameCount *= 4; frameCount *= 4;
if (frameCount > 0 && input != IntPtr.Zero) if (frameCount > 0 && input != IntPtr.Zero)
{ {
byte[] recbuffer = new byte[frameCount]; var recbuffer = new byte[frameCount];
byte[] leftBuffer = new byte[frameCount / 2]; var leftBuffer = new byte[frameCount / 2];
byte[] rightBuffer = new byte[frameCount / 2]; var rightBuffer = new byte[frameCount / 2];
// copy from managed to unmanaged memory // copy from managed to unmanaged memory
Marshal.Copy(input, recbuffer, 0, (int)frameCount); Marshal.Copy(input, recbuffer, 0, (int)frameCount);
@@ -124,7 +124,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
public float GetLength() public float GetLength()
{ {
return _FileOpened ? _Instance.Info.Duration / 1000f:0; return _FileOpened ? _Instance.Info.Duration / 1000f : 0;
} }
public void SetPosition(float time) public void SetPosition(float time)
@@ -134,7 +134,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
try try
{ {
CAcinerella.AcSeek(_Audiodecoder, (time>_CurrentTime)?0:-1, (Int64)(time * 1000f)); CAcinerella.AcSeek(_Audiodecoder, (time > _CurrentTime) ? 0 : -1, (Int64)(time * 1000f));
} }
catch (Exception) catch (Exception)
{ {
@@ -161,7 +161,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
if (frameFinished) if (frameFinished)
{ {
SACDecoder decoder = (SACDecoder)Marshal.PtrToStructure(_Audiodecoder, typeof(SACDecoder)); var decoder = (SACDecoder)Marshal.PtrToStructure(_Audiodecoder, typeof(SACDecoder));
timeStamp = (float)decoder.Timecode; timeStamp = (float)decoder.Timecode;
_CurrentTime = timeStamp; _CurrentTime = timeStamp;
+5 -5
View File
@@ -363,7 +363,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
{ {
lock (_Lock) 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) 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) 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) 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) lock (_Lock)
{ {
return _ac_seek(pAcDecoder, dir, targetPos)!=0; return _ac_seek(pAcDecoder, dir, targetPos) != 0;
} }
} }
+19
View File
@@ -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 <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
+20 -1
View File
@@ -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 <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Vocaluxe.Lib.Video.Acinerella namespace Vocaluxe.Lib.Video.Acinerella
+1 -1
View File
@@ -55,7 +55,7 @@ namespace Vocaluxe.Lib.Video
int i = -1; int i = -1;
try try
{ {
Uri u = new Uri(videoFileName); var u = new Uri(videoFileName);
i = CGstreamerVideoWrapper.LoadVideo(u.AbsoluteUri); i = CGstreamerVideoWrapper.LoadVideo(u.AbsoluteUri);
return i; return i;
} }
+4 -4
View File
@@ -65,7 +65,7 @@ namespace Vocaluxe.Lib.Webcam
{ {
lock (_MutexData) 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); BitmapData bitmapdata = bmp.LockBits(new Rectangle(0, 0, _Width, _Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Marshal.Copy(_Data, 0, bitmapdata.Scan0, _Data.Length); Marshal.Copy(_Data, 0, bitmapdata.Scan0, _Data.Length);
bmp.UnlockBits(bitmapdata); bmp.UnlockBits(bitmapdata);
@@ -80,17 +80,17 @@ namespace Vocaluxe.Lib.Webcam
_WebcamDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); _WebcamDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo info in _WebcamDevices) foreach (FilterInfo info in _WebcamDevices)
{ {
SWebcamDevice device = new SWebcamDevice var device = new SWebcamDevice
{ {
Name = info.Name, Name = info.Name,
MonikerString = info.MonikerString, MonikerString = info.MonikerString,
Capabilities = new List<SCapabilities>() Capabilities = new List<SCapabilities>()
}; };
VideoCaptureDevice tmpdev = new VideoCaptureDevice(info.MonikerString); var tmpdev = new VideoCaptureDevice(info.MonikerString);
foreach (VideoCapabilities capabilities in tmpdev.VideoCapabilities) foreach (VideoCapabilities capabilities in tmpdev.VideoCapabilities)
{ {
SCapabilities item = new SCapabilities var item = new SCapabilities
{ {
Framerate = capabilities.FrameRate, Framerate = capabilities.FrameRate,
Height = capabilities.FrameSize.Height, Height = capabilities.FrameSize.Height,
+1 -1
View File
@@ -253,7 +253,7 @@ namespace Vocaluxe
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args)
{ {
Exception e = (Exception)args.ExceptionObject; var e = (Exception)args.ExceptionObject;
string stackTrace = ""; string stackTrace = "";
try try
{ {
@@ -201,7 +201,7 @@ namespace Vocaluxe.Screens
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; var gm = EGameMode.TR_GAMEMODE_NORMAL;
if (CSongs.AllSongs[songNr].IsDuet) if (CSongs.AllSongs[songNr].IsDuet)
gm = EGameMode.TR_GAMEMODE_DUET; gm = EGameMode.TR_GAMEMODE_DUET;
+5 -5
View File
@@ -293,12 +293,12 @@ namespace Vocaluxe.Screens
CStatic image = GetNewStatic(texture, new SColorF(1, 1, 1, 1), new SRectF(-1, -1, 400, 120, -4)); 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); var particleRect = new SRectF(-1, -1, partRectSize, partRectSize, -6);
SRectF imgDotRect = new SRectF(particleRect) {Z = -5}; var imgDotRect = new SRectF(particleRect) {Z = -5};
CStatic imgDot = GetNewStatic(texDot, new SColorF(1, 1, 1, 1), imgDotRect); CStatic imgDot = GetNewStatic(texDot, new SColorF(1, 1, 1, 1), imgDotRect);
CParticleEffect particle = _GetStarParticles(partCount, isRight, particleRect, bigParticles); 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) 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)); new SRectF((float)(CSettings.RenderW - _TexLogo.OrigSize.Width) / 2, -270, _TexLogo.OrigSize.Width, _TexLogo.OrigSize.Height, -2));
//Little stars for logo //Little stars for logo
int numstars = (int)(_Logo.Rect.W * 0.25f / 2f); var 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 partRect = new SRectF(_Logo.Rect.X, _Logo.Rect.Y, _Logo.Rect.W, _Logo.Rect.H, -1);
_StarsRed = _GetStarParticles(numstars, true, partRect, true); _StarsRed = _GetStarParticles(numstars, true, partRect, true);
_StarsBlue = _GetStarParticles(numstars, false, partRect, true); _StarsBlue = _GetStarParticles(numstars, false, partRect, true);
+1 -1
View File
@@ -56,7 +56,7 @@ namespace Vocaluxe.Screens
{ {
base.Init(); base.Init();
List<string> texts = new List<string> {_TextSongName, _TextSongMode}; var texts = new List<string> {_TextSongName, _TextSongMode};
_TextNumber = new string[_NumEntrys]; _TextNumber = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++) for (int i = 0; i < _NumEntrys; i++)
+5 -12
View File
@@ -24,7 +24,6 @@ using Vocaluxe.Base;
using VocaluxeLib; using VocaluxeLib;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
namespace Vocaluxe.Screens namespace Vocaluxe.Screens
{ {
@@ -71,14 +70,14 @@ namespace Vocaluxe.Screens
{ {
base.Init(); base.Init();
List<string> statics = new List<string>(); var statics = new List<string>();
statics.AddRange(_StaticPlayerAvatar); statics.AddRange(_StaticPlayerAvatar);
statics.AddRange(_StaticPlayer); statics.AddRange(_StaticPlayer);
statics.Add(_StaticWarningMics); statics.Add(_StaticWarningMics);
statics.Add(_StaticWarningProfiles); statics.Add(_StaticWarningProfiles);
_ThemeStatics = statics.ToArray(); _ThemeStatics = statics.ToArray();
List<string> texts = new List<string> {_SelectSlidePlayerNumber}; var texts = new List<string> {_SelectSlidePlayerNumber};
texts.AddRange(_SelectSlideDuetPlayer); texts.AddRange(_SelectSlideDuetPlayer);
_ThemeSelectSlides = texts.ToArray(); _ThemeSelectSlides = texts.ToArray();
@@ -411,13 +410,9 @@ namespace Vocaluxe.Screens
if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent))
{ {
if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID > -1) if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID > -1)
{
_UpdateSelectedProfile(_SelectingSwitchNr, CGame.Players[i].ProfileID); _UpdateSelectedProfile(_SelectingSwitchNr, CGame.Players[i].ProfileID);
}
else if (_SelectingSwitchNr > -1) else if (_SelectingSwitchNr > -1)
{
_ResetPlayerSelection(_SelectingSwitchNr); _ResetPlayerSelection(_SelectingSwitchNr);
}
if (!CProfiles.IsProfileIDValid(_SelectedProfileID)) if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
@@ -427,10 +422,8 @@ namespace Vocaluxe.Screens
} }
//Selected player is dropped out of area //Selected player is dropped out of area
if (_SelectingSwitchNr > -1) if (_SelectingSwitchNr > -1)
{
_ResetPlayerSelection(_SelectingSwitchNr); _ResetPlayerSelection(_SelectingSwitchNr);
} }
}
_SelectingSwitchNr = -1; _SelectingSwitchNr = -1;
_SelectedProfileID = -1; _SelectedProfileID = -1;
//Reset variables //Reset variables
@@ -633,7 +626,7 @@ namespace Vocaluxe.Screens
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
{ {
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) 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); CGraphics.FadeTo(EScreens.ScreenSing);
@@ -726,7 +719,7 @@ namespace Vocaluxe.Screens
private void _CheckMics() private void _CheckMics()
{ {
List<int> playerWithoutMicro = new List<int>(); var playerWithoutMicro = new List<int>();
for (int player = 0; player < CConfig.NumPlayer; player++) for (int player = 0; player < CConfig.NumPlayer; player++)
{ {
if (!CConfig.IsMicConfig(player + 1)) if (!CConfig.IsMicConfig(player + 1))
@@ -764,7 +757,7 @@ namespace Vocaluxe.Screens
private void _CheckPlayers() private void _CheckPlayers()
{ {
List<int> playerWithoutProfile = new List<int>(); var playerWithoutProfile = new List<int>();
for (int player = 0; player < CConfig.NumPlayer; player++) for (int player = 0; player < CConfig.NumPlayer; player++)
{ {
if (CGame.Players[player].ProfileID < 0) if (CGame.Players[player].ProfileID < 0)
+3 -3
View File
@@ -75,7 +75,7 @@ namespace Vocaluxe.Screens
{ {
base.Init(); base.Init();
List<string> values = new List<string> {_StaticWarning}; var values = new List<string> {_StaticWarning};
values.AddRange(_StaticEnergyChannel); values.AddRange(_StaticEnergyChannel);
_ThemeStatics = values.ToArray(); _ThemeStatics = values.ToArray();
@@ -369,7 +369,7 @@ namespace Vocaluxe.Screens
{ {
if (_ChannelEnergy[i] > 0f) if (_ChannelEnergy[i] > 0f)
{ {
SRectF rect = new SRectF(_Statics[_StaticEnergyChannel[i]].Rect.X, var rect = new SRectF(_Statics[_StaticEnergyChannel[i]].Rect.X,
_Statics[_StaticEnergyChannel[i]].Rect.Y, _Statics[_StaticEnergyChannel[i]].Rect.Y,
_Statics[_StaticEnergyChannel[i]].Rect.W * _ChannelEnergy[i], _Statics[_StaticEnergyChannel[i]].Rect.W * _ChannelEnergy[i],
_Statics[_StaticEnergyChannel[i]].Rect.H, _Statics[_StaticEnergyChannel[i]].Rect.H,
@@ -465,7 +465,7 @@ namespace Vocaluxe.Screens
private bool _CheckMicConfig() private bool _CheckMicConfig()
{ {
bool[] isSet = new bool[CSettings.MaxNumPlayer]; var isSet = new bool[CSettings.MaxNumPlayer];
for (int i = 0; i < CSettings.MaxNumPlayer; i++) for (int i = 0; i < CSettings.MaxNumPlayer; i++)
isSet[i] = false; isSet[i] = false;
+2 -2
View File
@@ -154,8 +154,8 @@ namespace Vocaluxe.Screens
CConfig.PreviewMusicVolume = _SelectSlides[_SelectSlidePreviewMusicVolume].Selection * 5; CConfig.PreviewMusicVolume = _SelectSlides[_SelectSlidePreviewMusicVolume].Selection * 5;
CConfig.SaveConfig(); CConfig.SaveConfig();
EOffOn newOffOn = (EOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection; var newOffOn = (EOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection;
EBackgroundMusicSource newSource = (EBackgroundMusicSource)_SelectSlides[_SelectSlideBackgroundMusicSource].Selection; var newSource = (EBackgroundMusicSource)_SelectSlides[_SelectSlideBackgroundMusicSource].Selection;
float newVolume = _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection * 5; float newVolume = _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection * 5;
CBackgroundMusic.CheckAndApplyConfig(newOffOn, newSource, newVolume); CBackgroundMusic.CheckAndApplyConfig(newOffOn, newSource, newVolume);
+8 -8
View File
@@ -60,13 +60,13 @@ namespace Vocaluxe.Screens
{ {
base.Init(); base.Init();
List<string> texts = new List<string> {_TextSong}; var texts = new List<string> {_TextSong};
_BuildTextStrings(ref texts); _BuildTextStrings(ref texts);
_ThemeTexts = texts.ToArray(); _ThemeTexts = texts.ToArray();
List<string> statics = new List<string>(); var statics = new List<string>();
_BuildStaticStrings(ref statics); _BuildStaticStrings(ref statics);
_ThemeStatics = statics.ToArray(); _ThemeStatics = statics.ToArray();
@@ -131,7 +131,7 @@ namespace Vocaluxe.Screens
public override bool UpdateGame() public override bool UpdateGame()
{ {
SPlayer[] players = new SPlayer[CGame.NumPlayer]; var players = new SPlayer[CGame.NumPlayer];
if (_Round != 0) if (_Round != 0)
players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer);
else else
@@ -156,7 +156,7 @@ namespace Vocaluxe.Screens
if (_StaticPointsBarDrawnPoints[p] > players[p].Points) if (_StaticPointsBarDrawnPoints[p] > players[p].Points)
_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") if (direction.ToLower() == "vertical")
{ {
_Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.W = ((float)_StaticPointsBarDrawnPoints[p]) * _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.W = ((float)_StaticPointsBarDrawnPoints[p]) *
@@ -264,7 +264,7 @@ namespace Vocaluxe.Screens
private void _UpdateRatings() private void _UpdateRatings()
{ {
CSong song = null; CSong song = null;
SPlayer[] players = new SPlayer[CGame.NumPlayer]; var players = new SPlayer[CGame.NumPlayer];
if (_Round != 0) if (_Round != 0)
{ {
song = CGame.GetSong(_Round); song = CGame.GetSong(_Round);
@@ -298,9 +298,9 @@ namespace Vocaluxe.Screens
string name = CProfiles.GetPlayerName(players[p].ProfileID, p); string name = CProfiles.GetPlayerName(players[p].ProfileID, p);
if (song != null && song.IsDuet) 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 + ")"; 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 + ")"; name += " (" + song.DuetPart2 + ")";
} }
_Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = name; _Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = name;
@@ -325,7 +325,7 @@ namespace Vocaluxe.Screens
_Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points))); _Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points)));
_StaticPointsBarDrawnPoints[p] = 0.0; _StaticPointsBarDrawnPoints[p] = 0.0;
string direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue(); var direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue();
if (direction.ToLower() == "vertical") if (direction.ToLower() == "vertical")
_Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.W = 0; _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.W = 0;
else else
+33 -33
View File
@@ -125,11 +125,11 @@ namespace Vocaluxe.Screens
{ {
base.Init(); base.Init();
List<string> texts = new List<string> {_TextSongName, _TextTime, _TextPause, _TextDuetName1, _TextDuetName2, _TextMedleyCountdown}; var texts = new List<string> {_TextSongName, _TextTime, _TextPause, _TextDuetName1, _TextDuetName2, _TextMedleyCountdown};
_BuildTextStrings(texts); _BuildTextStrings(texts);
_ThemeTexts = texts.ToArray(); _ThemeTexts = texts.ToArray();
List<string> statics = new List<string> var statics = new List<string>
{ {
_StaticSongText, _StaticSongText,
_StaticLyrics, _StaticLyrics,
@@ -148,7 +148,7 @@ namespace Vocaluxe.Screens
_BuildStaticStrings(ref statics); _BuildStaticStrings(ref statics);
_ThemeStatics = statics.ToArray(); _ThemeStatics = statics.ToArray();
List<string> buttons = new List<string> {_ButtonCancel, _ButtonContinue, _ButtonSkip}; var buttons = new List<string> {_ButtonCancel, _ButtonContinue, _ButtonSkip};
_ThemeButtons = buttons.ToArray(); _ThemeButtons = buttons.ToArray();
_ThemeLyrics = new string[] {_LyricMain, _LyricSub, _LyricMainDuet, _LyricSubDuet, _LyricMainTop, _LyricSubTop}; _ThemeLyrics = new string[] {_LyricMain, _LyricSub, _LyricMainDuet, _LyricSubDuet, _LyricMainTop, _LyricSubTop};
@@ -202,7 +202,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.T: case Keys.T:
int mode = (int)CConfig.TimerMode; var mode = (int)CConfig.TimerMode;
mode++; mode++;
if (mode > Enum.GetNames(typeof(ETimerMode)).Length - 1) if (mode > Enum.GetNames(typeof(ETimerMode)).Length - 1)
@@ -355,18 +355,18 @@ namespace Vocaluxe.Screens
for (int p = 0; p < CGame.NumPlayer; p++) 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) 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]; _Statics[_StaticAvatars[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2];
_Texts[_TextNames[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; _Texts[_TextNames[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2];
} }
if (CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_ALL) if (CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_ALL)
{ {
_Statics[_StaticScores[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].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].LineNr * 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].LineNr * 2]; _Texts[_TextScores[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2];
} }
} }
@@ -459,7 +459,7 @@ namespace Vocaluxe.Screens
if (_Active) if (_Active)
{ {
CTexture background; CTexture background;
EAspect aspect = EAspect.Crop; var aspect = EAspect.Crop;
if (_CurrentVideo != -1 && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam) if (_CurrentVideo != -1 && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam)
{ {
background = _CurrentVideoTexture; background = _CurrentVideoTexture;
@@ -474,7 +474,7 @@ namespace Vocaluxe.Screens
background = _Background; background = _Background;
if (background != null) 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; RectangleF rect;
CHelper.SetRect(bounds, out rect, background.OrigAspect, aspect); CHelper.SetRect(bounds, out rect, background.OrigAspect, aspect);
CDraw.DrawTexture(background, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f), 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++) 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(); _DrawLyricHelper();
@@ -546,13 +546,13 @@ namespace Vocaluxe.Screens
public override void ApplyVolume() public override void ApplyVolume()
{ {
if(_CurrentStream > -1) if (_CurrentStream > -1)
CSound.SetStreamVolumeMax(_CurrentStream, CConfig.GameMusicVolume); CSound.SetStreamVolumeMax(_CurrentStream, CConfig.GameMusicVolume);
} }
private void _CloseSong() private void _CloseSong()
{ {
if(_CurrentStream > -1) if (_CurrentStream > -1)
CSound.FadeAndStop(_CurrentStream, 0f, 0.5f); CSound.FadeAndStop(_CurrentStream, 0f, 0.5f);
CSound.RecordStop(); CSound.RecordStop();
if (_CurrentVideo != -1) if (_CurrentVideo != -1)
@@ -609,12 +609,12 @@ namespace Vocaluxe.Screens
_FinishTime = song.Finish; _FinishTime = song.Finish;
_TimeToFirstNote = 0f; _TimeToFirstNote = 0f;
_TimeToFirstNoteDuet = 0f; _TimeToFirstNoteDuet = 0f;
int[] duetPlayer = new int[CGame.NumPlayer]; var duetPlayer = new int[CGame.NumPlayer];
if (song.IsDuet) if (song.IsDuet)
{ {
//Save duet-assignment before resetting //Save duet-assignment before resetting
for (int i = 0; i < duetPlayer.Length; i++) for (int i = 0; i < duetPlayer.Length; i++)
duetPlayer[i] = CGame.Players[i].LineNr; duetPlayer[i] = CGame.Players[i].VoiceNr;
} }
CGame.ResetPlayer(); CGame.ResetPlayer();
@@ -643,12 +643,12 @@ namespace Vocaluxe.Screens
if (CGame.GetNumSongs() > 1) if (CGame.GetNumSongs() > 1)
{ {
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
CGame.Players[i].LineNr = (i + 1) % 2; CGame.Players[i].VoiceNr = (i + 1) % 2;
} }
else else
{ {
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
CGame.Players[i].LineNr = duetPlayer[i]; CGame.Players[i].VoiceNr = duetPlayer[i];
} }
} }
@@ -747,7 +747,7 @@ namespace Vocaluxe.Screens
CWebcam.Close(); 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; 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! //We are only interested in the last matching line, so either do not check further after line[j].StartBeat > _CurrentBeat or go backwards!
@@ -789,7 +789,7 @@ namespace Vocaluxe.Screens
break; // for later break; // for later
CVoice voice = song.Notes.GetVoice(i); CVoice voice = song.Notes.GetVoice(i);
CLine[] lines = voice.Lines; CSongLine[] lines = voice.Lines;
// find current line // find current line
int nr = _FindCurrentLine(voice, lines, song); int nr = _FindCurrentLine(voice, lines, song);
@@ -798,7 +798,7 @@ namespace Vocaluxe.Screens
{ {
for (int j = 0; j < CGame.NumPlayer; j++) 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); _SingNotes[_SingBars].SetLines(_NoteLines[j], lines, nr);
} }
@@ -982,7 +982,7 @@ namespace Vocaluxe.Screens
if (_CurrentTime < timeToFirstMedleyNote) if (_CurrentTime < timeToFirstMedleyNote)
{ {
float timeDiff = timeToFirstMedleyNote - _CurrentTime + 1; float timeDiff = timeToFirstMedleyNote - _CurrentTime + 1;
float fullSeconds = (float)Math.Truncate(timeDiff); var fullSeconds = (float)Math.Truncate(timeDiff);
float partSeconds = timeDiff - fullSeconds; float partSeconds = timeDiff - fullSeconds;
_Texts[_TextMedleyCountdown].Visible = true; _Texts[_TextMedleyCountdown].Visible = true;
_Texts[_TextMedleyCountdown].Text = fullSeconds.ToString(); _Texts[_TextMedleyCountdown].Text = fullSeconds.ToString();
@@ -1027,7 +1027,7 @@ namespace Vocaluxe.Screens
if (_Statics[_StaticLyrics].Visible) if (_Statics[_StaticLyrics].Visible)
{ {
SRectF rect = _Statics[_StaticLyricHelper].Rect; SRectF rect = _Statics[_StaticLyricHelper].Rect;
SColorF color = new SColorF( var color = new SColorF(
_Statics[_StaticLyricHelper].Color.R, _Statics[_StaticLyricHelper].Color.R,
_Statics[_StaticLyricHelper].Color.G, _Statics[_StaticLyricHelper].Color.G,
_Statics[_StaticLyricHelper].Color.B, _Statics[_StaticLyricHelper].Color.B,
@@ -1041,7 +1041,7 @@ namespace Vocaluxe.Screens
if (_Statics[_StaticLyricsTop].Visible) if (_Statics[_StaticLyricsTop].Visible)
{ {
SRectF rect = _Statics[_StaticLyricHelperTop].Rect; SRectF rect = _Statics[_StaticLyricHelperTop].Rect;
SColorF color = new SColorF( var color = new SColorF(
_Statics[_StaticLyricHelperTop].Color.R, _Statics[_StaticLyricHelperTop].Color.R,
_Statics[_StaticLyricHelperTop].Color.G, _Statics[_StaticLyricHelperTop].Color.G,
_Statics[_StaticLyricHelperTop].Color.B, _Statics[_StaticLyricHelperTop].Color.B,
@@ -1068,7 +1068,7 @@ namespace Vocaluxe.Screens
SRectF rect = _Statics[_StaticLyricHelperDuet].Rect; SRectF rect = _Statics[_StaticLyricHelperDuet].Rect;
SColorF color = new SColorF( var color = new SColorF(
_Statics[_StaticLyricHelperDuet].Color.R, _Statics[_StaticLyricHelperDuet].Color.R,
_Statics[_StaticLyricHelperDuet].Color.G, _Statics[_StaticLyricHelperDuet].Color.G,
_Statics[_StaticLyricHelperDuet].Color.B, _Statics[_StaticLyricHelperDuet].Color.B,
@@ -1091,13 +1091,13 @@ namespace Vocaluxe.Screens
if (song == null || !song.NotesLoaded) if (song == null || !song.NotesLoaded)
return null; 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; float currentTime = _CurrentTime - song.Gap;
for (int i = 0; i < song.Notes.LinesCount; i++) for (int i = 0; i < song.Notes.LinesCount; i++)
{ {
CVoice voice = song.Notes.GetVoice(i); CVoice voice = song.Notes.GetVoice(i);
CLine[] lines = voice.Lines; CSongLine[] lines = voice.Lines;
// find current line for lyric sub fading // find current line for lyric sub fading
int currentLineSub = _FindCurrentLine(voice, lines, song); int currentLineSub = _FindCurrentLine(voice, lines, song);
@@ -1294,8 +1294,8 @@ namespace Vocaluxe.Screens
switch (CConfig.TimerMode) switch (CConfig.TimerMode)
{ {
case ETimerMode.TR_CONFIG_TIMERMODE_CURRENT: case ETimerMode.TR_CONFIG_TIMERMODE_CURRENT:
int min = (int)Math.Floor(currentTime / 60f); var min = (int)Math.Floor(currentTime / 60f);
int sec = (int)(currentTime - min * 60f); var sec = (int)(currentTime - min * 60f);
_Texts[_TextTime].Text = min.ToString("00") + ":" + sec.ToString("00"); _Texts[_TextTime].Text = min.ToString("00") + ":" + sec.ToString("00");
break; break;
@@ -1370,9 +1370,9 @@ namespace Vocaluxe.Screens
foreach (CVoice voice in song.Notes.Voices) 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, trect.Rect = GetNewStatic(null,
new SColorF(1f, 1f, 1f, 1f), new SColorF(1f, 1f, 1f, 1f),
new SRectF( new SRectF(
+8 -8
View File
@@ -105,7 +105,7 @@ namespace Vocaluxe.Screens
_ButtonsJoker.Clear(); _ButtonsJoker.Clear();
for (int i = 0; i < CSettings.MaxNumPlayer; i++) for (int i = 0; i < CSettings.MaxNumPlayer; i++)
_ButtonsJoker.Add("ButtonJoker" + (i + 1)); _ButtonsJoker.Add("ButtonJoker" + (i + 1));
List<string> blist = new List<string>(); var blist = new List<string>();
blist.AddRange(_ButtonsJoker); blist.AddRange(_ButtonsJoker);
blist.Add(_ButtonOptionsClose); blist.Add(_ButtonOptionsClose);
blist.Add(_ButtonOptionsPlaylist); blist.Add(_ButtonOptionsPlaylist);
@@ -123,7 +123,7 @@ namespace Vocaluxe.Screens
_TextsPlayer.Clear(); _TextsPlayer.Clear();
for (int i = 0; i < CSettings.MaxNumPlayer; i++) for (int i = 0; i < CSettings.MaxNumPlayer; i++)
_TextsPlayer.Add("TextPlayer" + (i + 1)); _TextsPlayer.Add("TextPlayer" + (i + 1));
List<string> tlist = new List<string>(); var tlist = new List<string>();
tlist.AddRange(_TextsPlayer); tlist.AddRange(_TextsPlayer);
tlist.Add(_TextCategory); tlist.Add(_TextCategory);
tlist.Add(_TextSelection); tlist.Add(_TextSelection);
@@ -172,7 +172,7 @@ namespace Vocaluxe.Screens
{ {
if (_SearchActive) if (_SearchActive)
_ApplyNewSearchFilter(_SearchText + keyEvent.Unicode); _ApplyNewSearchFilter(_SearchText + keyEvent.Unicode);
else if(!_Sso.Selection.PartyMode) else if (!_Sso.Selection.PartyMode)
{ {
_JumpTo(keyEvent.Unicode); _JumpTo(keyEvent.Unicode);
return true; return true;
@@ -862,7 +862,7 @@ namespace Vocaluxe.Screens
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
List<int> ids = new List<int>(); var ids = new List<int>();
for (int i = 0; i < CSongs.AllSongs.Count; i++) for (int i = 0; i < CSongs.AllSongs.Count; i++)
ids.Add(i); ids.Add(i);
@@ -870,7 +870,7 @@ namespace Vocaluxe.Screens
{ {
int songNr = ids[CGame.Rand.Next(ids.Count)]; 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) if (CSongs.AllSongs[songNr].IsDuet)
gm = EGameMode.TR_GAMEMODE_DUET; gm = EGameMode.TR_GAMEMODE_DUET;
@@ -894,7 +894,7 @@ namespace Vocaluxe.Screens
{ {
int songNr = ids[CGame.Rand.Next(ids.Count)]; 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) if (CSongs.AllSongs[songNr].IsDuet)
gm = EGameMode.TR_GAMEMODE_DUET; gm = EGameMode.TR_GAMEMODE_DUET;
@@ -1076,7 +1076,7 @@ namespace Vocaluxe.Screens
if (visibleID > -1) if (visibleID > -1)
_SongMenus[_SongMenu].SetSelectedSong(visibleID); _SongMenus[_SongMenu].SetSelectedSong(visibleID);
} }
else if(!CSongs.IsInCategory) else if (!CSongs.IsInCategory)
{ {
ReadOnlyCollection<CCategory> categories = CSongs.Categories; ReadOnlyCollection<CCategory> categories = CSongs.Categories;
int ct = categories.Count; int ct = categories.Count;
@@ -1170,7 +1170,7 @@ namespace Vocaluxe.Screens
private void _ShowSongOptionsSong() private void _ShowSongOptionsSong()
{ {
EGameMode lastMode = EGameMode.TR_GAMEMODE_NORMAL; var lastMode = EGameMode.TR_GAMEMODE_NORMAL;
if (_AvailableGameModes.Count > 0) if (_AvailableGameModes.Count > 0)
lastMode = _AvailableGameModes[_SelectSlides[_SelectSlideOptionsMode].Selection]; lastMode = _AvailableGameModes[_SelectSlides[_SelectSlideOptionsMode].Selection];
_AvailableGameModes.Clear(); _AvailableGameModes.Clear();
+2 -2
View File
@@ -41,8 +41,8 @@ namespace Vocaluxe.Screens
{ {
base.Init(); base.Init();
const string test = "Ö ÄÜabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890"; const string test = "Ö ÄÜabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890";
SColorF color = new SColorF(1, 0, 0, 1); var 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 text = new CText(10, 50, 1, 32, 0, EAlignment.Left, EStyle.Normal, "Normal", color, "jÄNormal Text" + test, -1, 26, 1);
_AddText(text); _AddText(text);
text = new CText(10, 90, 1, 32, 0, EAlignment.Left, EStyle.Bold, "Normal", color, "jÄBold Text" + test, -1, 26, 1); text = new CText(10, 90, 1, 32, 0, EAlignment.Left, EStyle.Bold, "Normal", color, "jÄBold Text" + test, -1, 26, 1);
_AddText(text); _AddText(text);
+3 -3
View File
@@ -79,7 +79,7 @@ namespace VocaluxeLib
if (sr.EndOfStream) if (sr.EndOfStream)
break; break;
char chr = (char)sr.Read(); var chr = (char)sr.Read();
value += chr.ToString(); value += chr.ToString();
tmp = sr.Peek(); tmp = sr.Peek();
} }
@@ -141,8 +141,8 @@ namespace VocaluxeLib
public static List<string> ListFiles(string path, string cast, bool recursive = false, bool fullpath = false) public static List<string> ListFiles(string path, string cast, bool recursive = false, bool fullpath = false)
{ {
List<string> files = new List<string>(); var files = new List<string>();
DirectoryInfo dir = new DirectoryInfo(path); var dir = new DirectoryInfo(path);
try try
{ {
+3 -3
View File
@@ -37,7 +37,7 @@ namespace VocaluxeLib
private CXMLReader(string uri) private CXMLReader(string uri)
{ {
_FileName = uri; _FileName = uri;
XPathDocument xmlDoc = new XPathDocument(uri); var xmlDoc = new XPathDocument(uri);
_Navigator = xmlDoc.CreateNavigator(); _Navigator = xmlDoc.CreateNavigator();
} }
@@ -123,7 +123,7 @@ namespace VocaluxeLib
public List<string> GetValues(string cast) public List<string> GetValues(string cast)
{ {
List<string> values = new List<string>(); var values = new List<string>();
_Navigator.MoveToRoot(); _Navigator.MoveToRoot();
_Navigator.MoveToFirstChild(); _Navigator.MoveToFirstChild();
@@ -143,7 +143,7 @@ namespace VocaluxeLib
public IEnumerable<string> GetAttributes(string cast, string attribute) public IEnumerable<string> GetAttributes(string cast, string attribute)
{ {
List<string> values = new List<string>(); var values = new List<string>();
_Navigator.MoveToRoot(); _Navigator.MoveToRoot();
_Navigator.MoveToFirstChild(); _Navigator.MoveToFirstChild();
+3 -3
View File
@@ -51,7 +51,7 @@ namespace VocaluxeLib.Game
for (int player = 0; player < players.Length; player++) for (int player = 0; player < players.Length; player++)
{ {
_Rounds[round, player].SongID = songID; _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].Points = players[player].Points;
_Rounds[round, player].PointsGoldenNotes = players[player].PointsGoldenNotes; _Rounds[round, player].PointsGoldenNotes = players[player].PointsGoldenNotes;
_Rounds[round, player].PointsLineBonus = players[player].PointsLineBonus; _Rounds[round, player].PointsLineBonus = players[player].PointsLineBonus;
@@ -80,7 +80,7 @@ namespace VocaluxeLib.Game
if (round >= NumRounds) if (round >= NumRounds)
return new SPlayer[1]; return new SPlayer[1];
SPlayer[] players = new SPlayer[numPlayer]; var players = new SPlayer[numPlayer];
for (int p = 0; p < players.Length; p++) for (int p = 0; p < players.Length; p++)
{ {
@@ -88,7 +88,7 @@ namespace VocaluxeLib.Game
players[p].PointsGoldenNotes = _Rounds[round, p].PointsGoldenNotes; players[p].PointsGoldenNotes = _Rounds[round, p].PointsGoldenNotes;
players[p].PointsLineBonus = _Rounds[round, p].PointsLineBonus; players[p].PointsLineBonus = _Rounds[round, p].PointsLineBonus;
players[p].SongID = _Rounds[round, p].SongID; 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].Medley = _Rounds[round, p].Medley;
players[p].Duet = _Rounds[round, p].Duet; players[p].Duet = _Rounds[round, p].Duet;
players[p].ShortSong = _Rounds[round, p].ShortSong; players[p].ShortSong = _Rounds[round, p].ShortSong;
+4 -4
View File
@@ -196,7 +196,7 @@ namespace VocaluxeLib.Menu
#region internal #region internal
private void _DrawColor() 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); CBase.Drawing.DrawColor(Color, bounds);
} }
@@ -206,7 +206,7 @@ namespace VocaluxeLib.Menu
CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
if (texture != null) 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; RectangleF rect;
CHelper.SetRect(bounds, out rect, texture.OrigAspect, EAspect.Crop); CHelper.SetRect(bounds, out rect, texture.OrigAspect, EAspect.Crop);
@@ -221,7 +221,7 @@ namespace VocaluxeLib.Menu
CTexture videoTexture = CBase.Theme.GetSkinVideoTexture(_Theme.VideoName, _PartyModeID); CTexture videoTexture = CBase.Theme.GetSkinVideoTexture(_Theme.VideoName, _PartyModeID);
if (videoTexture != null) 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; RectangleF rect;
CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop); CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop);
@@ -236,7 +236,7 @@ namespace VocaluxeLib.Menu
CTexture videoTexture = CBase.BackgroundMusic.GetVideoTexture(); CTexture videoTexture = CBase.BackgroundMusic.GetVideoTexture();
if (videoTexture != null) 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; RectangleF rect;
CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop); CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop);
+1 -1
View File
@@ -258,7 +258,7 @@ namespace VocaluxeLib.Menu
for (int i = 0; i < _Bars.Length; i++) 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; SColorF color = Color;
if (i == max) if (i == max)
color = MaxColor; color = MaxColor;
+3 -3
View File
@@ -201,14 +201,14 @@ namespace VocaluxeLib.Menu
return false; return false;
} }
public void SetLine(CLine line) public void SetLine(CSongLine line)
{ {
_Notes.Clear(); _Notes.Clear();
_Width = 0f; _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}; var n = new SNote {Text = note.Text, StartBeat = note.StartBeat, EndBeat = note.EndBeat, Duration = note.Duration, Type = note.NoteType};
_Text.Text = note.Text; _Text.Text = note.Text;
_Text.Style = EStyle.Bold; _Text.Style = EStyle.Bold;
+21 -21
View File
@@ -151,7 +151,7 @@ namespace VocaluxeLib.Menu
{ {
foreach (string elName in elements) 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)) if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader, skinIndex))
addElementHandler(element, elName); addElementHandler(element, elName);
else else
@@ -198,7 +198,7 @@ namespace VocaluxeLib.Menu
if (_ThemePath == "") if (_ThemePath == "")
return; 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"); string file = Path.Combine(_ThemePath, ThemeName + ".xml");
using (XmlWriter writer = XmlWriter.Create(file, settings)) using (XmlWriter writer = XmlWriter.Create(file, settings))
@@ -770,7 +770,7 @@ namespace VocaluxeLib.Menu
if (_Interactions.Count <= 0) if (_Interactions.Count <= 0)
return; return;
List<SZSort> items = new List<SZSort>(); var items = new List<SZSort>();
for (int i = 0; i < _Interactions.Count; i++) 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.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)) _Interactions[i].Type != EType.Equalizer && _Interactions[i].Type != EType.Playlist && _Interactions[i].Type != EType.ParticleEffect))
continue; continue;
SZSort zs = new SZSort {ID = i, Z = _GetZValue(i)}; var zs = new SZSort {ID = i, Z = _GetZValue(i)};
items.Add(zs); items.Add(zs);
} }
@@ -1105,10 +1105,10 @@ namespace VocaluxeLib.Menu
/// <returns></returns> /// <returns></returns>
private bool _NextInteraction(SKeyEvent key) private bool _NextInteraction(SKeyEvent key)
{ {
SKeyEvent[] directions = new SKeyEvent[4]; var directions = new SKeyEvent[4];
float[] distances = new float[4]; var distances = new float[4];
int[] stages = new int[4]; var stages = new int[4];
int[] elements = new int[4]; var elements = new int[4];
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
directions[i] = new SKeyEvent(); directions[i] = new SKeyEvent();
@@ -1248,11 +1248,11 @@ namespace VocaluxeLib.Menu
private float _GetDistanceDirect(SKeyEvent key, SRectF actualRect, SRectF targetRect) private float _GetDistanceDirect(SKeyEvent key, SRectF actualRect, SRectF targetRect)
{ {
PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); var 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 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); var 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 distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
bool inDirection = false; bool inDirection = false;
switch (key.Key) switch (key.Key)
{ {
@@ -1281,11 +1281,11 @@ namespace VocaluxeLib.Menu
private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect) private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect)
{ {
PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); var 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 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); var 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 distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
bool inDirection = false; bool inDirection = false;
switch (key.Key) switch (key.Key)
{ {
@@ -1584,7 +1584,7 @@ namespace VocaluxeLib.Menu
private SRectF _GetRect(CInteraction interaction) private SRectF _GetRect(CInteraction interaction)
{ {
SRectF result = new SRectF(); var result = new SRectF();
switch (interaction.Type) switch (interaction.Type)
{ {
case EType.Button: case EType.Button:
@@ -1808,7 +1808,7 @@ namespace VocaluxeLib.Menu
private void _LoadThemeBasics(CXMLReader xmlReader, int skinIndex) private void _LoadThemeBasics(CXMLReader xmlReader, int skinIndex)
{ {
// Backgrounds // Backgrounds
CBackground background = new CBackground(_PartyModeID); var background = new CBackground(_PartyModeID);
int i = 1; int i = 1;
while (background.LoadTheme("//root/" + ThemeName, "Background" + i, xmlReader, skinIndex)) while (background.LoadTheme("//root/" + ThemeName, "Background" + i, xmlReader, skinIndex))
{ {
@@ -1818,7 +1818,7 @@ namespace VocaluxeLib.Menu
} }
// Statics // Statics
CStatic stat = new CStatic(_PartyModeID); var stat = new CStatic(_PartyModeID);
i = 1; i = 1;
while (stat.LoadTheme("//root/" + ThemeName, "Static" + i, xmlReader, skinIndex)) while (stat.LoadTheme("//root/" + ThemeName, "Static" + i, xmlReader, skinIndex))
{ {
@@ -1828,7 +1828,7 @@ namespace VocaluxeLib.Menu
} }
// Texts // Texts
CText text = new CText(_PartyModeID); var text = new CText(_PartyModeID);
i = 1; i = 1;
while (text.LoadTheme("//root/" + ThemeName, "Text" + i, xmlReader, skinIndex)) while (text.LoadTheme("//root/" + ThemeName, "Text" + i, xmlReader, skinIndex))
{ {
@@ -1838,7 +1838,7 @@ namespace VocaluxeLib.Menu
} }
// ParticleEffects // ParticleEffects
CParticleEffect partef = new CParticleEffect(_PartyModeID); var partef = new CParticleEffect(_PartyModeID);
i = 1; i = 1;
while (partef.LoadTheme("//root/" + ThemeName, "ParticleEffect" + i, xmlReader, skinIndex)) while (partef.LoadTheme("//root/" + ThemeName, "ParticleEffect" + i, xmlReader, skinIndex))
{ {
+7 -7
View File
@@ -487,9 +487,9 @@ namespace VocaluxeLib.Menu
{ {
for (int j = 0; j < _NumW; j++) 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); var 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}; var 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, 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, ""); _Theme.NameFont, _Theme.NameColor, "");
_Tiles.Add(new CTile(tileStatic, tileText, -1)); _Tiles.Add(new CTile(tileStatic, tileText, -1));
} }
@@ -501,21 +501,21 @@ namespace VocaluxeLib.Menu
_VisibleProfiles.Clear(); _VisibleProfiles.Clear();
CProfile[] profiles = CBase.Profiles.GetProfiles(); 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) if (visible)
{ {
//Show profile only if active //Show profile only if active
for (int p = 0; p < CBase.Game.GetNumPlayer(); p++) for (int p = 0; p < CBase.Game.GetNumPlayer(); p++)
{ {
//Don't show profile if is selected, but if selected and guest //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; visible = false;
} }
} }
if (visible) if (visible)
_VisibleProfiles.Add(profiles[i].ID); _VisibleProfiles.Add(profile.ID);
} }
} }
+15 -15
View File
@@ -307,7 +307,7 @@ namespace VocaluxeLib.Menu
if (_Interactions.Count <= 0) if (_Interactions.Count <= 0)
return; return;
List<SZSort> items = new List<SZSort>(); var items = new List<SZSort>();
for (int i = 0; i < _Interactions.Count; i++) for (int i = 0; i < _Interactions.Count; i++)
{ {
@@ -320,7 +320,7 @@ namespace VocaluxeLib.Menu
_Interactions[i].Type == EType.SongMenu || _Interactions[i].Type == EType.SongMenu ||
_Interactions[i].Type == EType.Equalizer)) _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); items.Add(zs);
} }
} }
@@ -613,10 +613,10 @@ namespace VocaluxeLib.Menu
/// <returns></returns> /// <returns></returns>
private bool _NextInteraction(SKeyEvent key) private bool _NextInteraction(SKeyEvent key)
{ {
SKeyEvent[] directions = new SKeyEvent[4]; var directions = new SKeyEvent[4];
float[] distances = new float[4]; var distances = new float[4];
int[] stages = new int[4]; var stages = new int[4];
int[] elements = new int[4]; var elements = new int[4];
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
directions[i] = new SKeyEvent(); directions[i] = new SKeyEvent();
@@ -756,11 +756,11 @@ namespace VocaluxeLib.Menu
private float _GetDistanceDirect(SKeyEvent key, SRectF actualRect, SRectF targetRect) private float _GetDistanceDirect(SKeyEvent key, SRectF actualRect, SRectF targetRect)
{ {
PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); var 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 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); var 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 distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
bool inDirection = false; bool inDirection = false;
switch (key.Key) switch (key.Key)
{ {
@@ -789,11 +789,11 @@ namespace VocaluxeLib.Menu
private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect) private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect)
{ {
PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); var 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 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); var 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 distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
bool inDirection = false; bool inDirection = false;
switch (key.Key) switch (key.Key)
{ {
@@ -1002,7 +1002,7 @@ namespace VocaluxeLib.Menu
private SRectF _GetRect(int interaction) private SRectF _GetRect(int interaction)
{ {
SRectF result = new SRectF(); var result = new SRectF();
switch (_Interactions[interaction].Type) switch (_Interactions[interaction].Type)
{ {
case EType.Button: case EType.Button:
+3 -3
View File
@@ -203,7 +203,7 @@ namespace VocaluxeLib.Menu
break; break;
case EParticleType.Snow: 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) if (Math.Round(Y) < maxy)
{ {
@@ -525,8 +525,8 @@ namespace VocaluxeLib.Menu
break; break;
} }
int w = (int)(Rect.W - size / 4f); var w = (int)(Rect.W - size / 4f);
int h = (int)(Rect.H - size / 4f); var h = (int)(Rect.H - size / 4f);
if (w < 0) if (w < 0)
w = 0; w = 0;
+6 -6
View File
@@ -631,7 +631,7 @@ namespace VocaluxeLib.Menu
CBase.Playlist.MovePlaylistSongUp(ActivePlaylistID, CurrentPlaylistElement + Offset); CBase.Playlist.MovePlaylistSongUp(ActivePlaylistID, CurrentPlaylistElement + Offset);
UpdatePlaylist(); UpdatePlaylist();
SKeyEvent key = new SKeyEvent {Key = Keys.Up}; var key = new SKeyEvent {Key = Keys.Up};
if (CurrentPlaylistElement > scrollLimit) if (CurrentPlaylistElement > scrollLimit)
{ {
@@ -660,7 +660,7 @@ namespace VocaluxeLib.Menu
CBase.Playlist.MovePlaylistSongDown(ActivePlaylistID, CurrentPlaylistElement + Offset); CBase.Playlist.MovePlaylistSongDown(ActivePlaylistID, CurrentPlaylistElement + Offset);
UpdatePlaylist(); UpdatePlaylist();
SKeyEvent key = new SKeyEvent {Key = Keys.Down}; var key = new SKeyEvent {Key = Keys.Down};
if (CurrentPlaylistElement >= scrollLimit) if (CurrentPlaylistElement >= scrollLimit)
{ {
@@ -973,7 +973,7 @@ namespace VocaluxeLib.Menu
if (!mouseEvent.LBH && DragAndDropSongID != -1) if (!mouseEvent.LBH && DragAndDropSongID != -1)
{ {
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; var gm = EGameMode.TR_GAMEMODE_NORMAL;
CSong song = CBase.Songs.GetSongByID(DragAndDropSongID); CSong song = CBase.Songs.GetSongByID(DragAndDropSongID);
if (song != null) if (song != null)
@@ -1102,7 +1102,7 @@ namespace VocaluxeLib.Menu
for (int i = 0; i < Math.Floor(Rect.H / _Theme.EntryHeight); i++) 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, Background = new CStatic(_PartyModeID, _Theme.TextureBackgroundName, BackgroundColor,
new SRectF(Rect.X, Rect.Y + (i * _Theme.EntryHeight), Rect.W, _Theme.EntryHeight, Rect.Z)), new SRectF(Rect.X, Rect.Y + (i * _Theme.EntryHeight), Rect.W, _Theme.EntryHeight, Rect.Z)),
@@ -1143,7 +1143,7 @@ namespace VocaluxeLib.Menu
_PlaylistElementContents.Clear(); _PlaylistElementContents.Clear();
for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(ActivePlaylistID); i++) 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, SongID = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID,
Modes = CBase.Songs.GetSongByID(CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID).AvailableGameModes, Modes = CBase.Songs.GetSongByID(CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID).AvailableGameModes,
@@ -1162,7 +1162,7 @@ namespace VocaluxeLib.Menu
_PlaylistElementContents.Clear(); _PlaylistElementContents.Clear();
for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(ActivePlaylistID); i++) 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.Modes = CBase.Songs.GetSongByID(pec.SongID).AvailableGameModes;
pec.Mode = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).GameMode; pec.Mode = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).GameMode;
_PlaylistElementContents.Add(pec); _PlaylistElementContents.Add(pec);
+3 -3
View File
@@ -750,10 +750,10 @@ namespace VocaluxeLib.Menu
_ValueBounds.Clear(); _ValueBounds.Clear();
for (int i = 0; i < numvis; i++) 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], var text = new CText(0, 0, 0, TextH, MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, TextColor, _ValueNames[i + offset],
_ValuePartyModeIDs[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) if (i + offset == _Selection)
{ {
text.Color = SelTextColor; text.Color = SelTextColor;
@@ -774,7 +774,7 @@ namespace VocaluxeLib.Menu
if (WithTextures) if (WithTextures)
{ {
float dh = text.Y - Rect.Y - Rect.H * 0.1f; 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); CBase.Drawing.DrawTexture(_Textures[i + offset], rect, alpha);
_ValueBounds.Add(rect); _ValueBounds.Add(rect);
} }
+4 -6
View File
@@ -205,11 +205,9 @@ namespace VocaluxeLib.Menu
public void Draw(float scale, float z, EAspect aspect, bool forceDraw = false) public void Draw(float scale, float z, EAspect aspect, bool forceDraw = false)
{ {
CTexture texture = Texture; CTexture texture = Texture ?? new CTexture((int)Rect.W, (int)Rect.H);
if (texture == null)
texture = new CTexture((int)Rect.W, (int)Rect.H);
SRectF bounds = new SRectF( var bounds = new SRectF(
Rect.X - Rect.W * (scale - 1f), Rect.X - Rect.W * (scale - 1f),
Rect.Y - Rect.H * (scale - 1f), Rect.Y - Rect.H * (scale - 1f),
Rect.W + 2 * Rect.W * (scale - 1f), Rect.W + 2 * Rect.W * (scale - 1f),
@@ -220,7 +218,7 @@ namespace VocaluxeLib.Menu
if (aspect != EAspect.Stretch) 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; RectangleF rect2;
CHelper.SetRect(bounds2, out rect2, texture.OrigAspect, aspect); CHelper.SetRect(bounds2, out rect2, texture.OrigAspect, aspect);
@@ -230,7 +228,7 @@ namespace VocaluxeLib.Menu
rect.H = rect2.Height; 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)) if (Visible || forceDraw || (CBase.Settings.GetGameState() == EGameState.EditTheme))
{ {
CBase.Drawing.DrawTexture(texture, rect, color, bounds); CBase.Drawing.DrawTexture(texture, rect, color, bounds);
+2 -2
View File
@@ -469,7 +469,7 @@ namespace VocaluxeLib.Menu
CBase.Fonts.SetStyle(Style); CBase.Fonts.SetStyle(Style);
SColorF currentColor = (Selected) ? SelColor : Color; 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); CBase.Fonts.DrawText(_Text, Rect.H, Rect.X, Rect.Y, Z, color);
@@ -486,7 +486,7 @@ namespace VocaluxeLib.Menu
CBase.Fonts.SetStyle(Style); CBase.Fonts.SetStyle(Style);
SColorF currentColor = (Selected) ? SelColor : Color; 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); CBase.Fonts.DrawText(Text, Rect.H, Rect.X, Rect.Y, Z, color, begin, end);
+30 -33
View File
@@ -33,7 +33,7 @@ namespace VocaluxeLib.Menu.SingNotes
public SRectF Rect; public SRectF Rect;
public SColorF Color; public SColorF Color;
public float Alpha; public float Alpha;
public CLine[] Lines; public CSongLine[] Lines;
public int LineNr; public int LineNr;
public Stopwatch Timer; public Stopwatch Timer;
public List<CParticleEffect> GoldenStars; public List<CParticleEffect> GoldenStars;
@@ -205,7 +205,7 @@ namespace VocaluxeLib.Menu.SingNotes
public int AddPlayer(SRectF rect, SColorF color, int playerNr) public int AddPlayer(SRectF rect, SColorF color, int playerNr)
{ {
SPlayerNotes notes = new SPlayerNotes var notes = new SPlayerNotes
{ {
Rect = rect, Rect = rect,
Color = color, Color = color,
@@ -226,7 +226,7 @@ namespace VocaluxeLib.Menu.SingNotes
return notes.ID; return notes.ID;
} }
public void SetLines(int id, CLine[] lines, int lineNr) public void SetLines(int id, CSongLine[] lines, int lineNr)
{ {
if (lines == null) if (lines == null)
return; return;
@@ -278,7 +278,7 @@ namespace VocaluxeLib.Menu.SingNotes
Draw(id, null, player); Draw(id, null, player);
} }
public void Draw(int id, List<CLine> singLines, int player) public void Draw(int id, List<CSungLine> sungLines, int player)
{ {
int n = _FindPlayerNotes(id); int n = _FindPlayerNotes(id);
if (n == -1) if (n == -1)
@@ -293,7 +293,7 @@ namespace VocaluxeLib.Menu.SingNotes
if (_PlayerNotes[n].Lines.Length <= _PlayerNotes[n].LineNr) if (_PlayerNotes[n].Lines.Length <= _PlayerNotes[n].LineNr)
return; 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) 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)); _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) if (beats < 1)
return; return;
SColorF color = new SColorF( var color = new SColorF(
_PlayerNotes[n].Color.R, _PlayerNotes[n].Color.R,
_PlayerNotes[n].Color.G, _PlayerNotes[n].Color.G,
_PlayerNotes[n].Color.B, _PlayerNotes[n].Color.B,
@@ -319,13 +319,13 @@ namespace VocaluxeLib.Menu.SingNotes
float baseLine = line.BaseLine; float baseLine = line.BaseLine;
int nr = 1; int nr = 1;
foreach (CNote note in line.Notes) foreach (CSongNote note in line.Notes)
{ {
if (note.NoteType != ENoteType.Freestyle) if (note.NoteType != ENoteType.Freestyle)
{ {
float width = note.Duration / beats * w; 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.X + (note.StartBeat - line.FirstNoteBeat) / beats * w,
_PlayerNotes[n].Rect.Y + (CBase.Settings.GetNumNoteLines() - 1 - (note.Tone - baseLine) / 2) / CBase.Settings.GetNumNoteLines() * h - dh, _PlayerNotes[n].Rect.Y + (CBase.Settings.GetNumNoteLines() - 1 - (note.Tone - baseLine) / 2) / CBase.Settings.GetNumNoteLines() * h - dh,
width, width,
@@ -359,7 +359,7 @@ namespace VocaluxeLib.Menu.SingNotes
foreach (CParticleEffect perfline in _PlayerNotes[n].PerfectLineTwinkle) foreach (CParticleEffect perfline in _PlayerNotes[n].PerfectLineTwinkle)
perfline.Draw(); 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) foreach (CParticleEffect stars in _PlayerNotes[n].GoldenStars)
{ {
@@ -369,16 +369,14 @@ namespace VocaluxeLib.Menu.SingNotes
return; 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; float width = note.Duration / beats * w;
if (note.EndBeat == CBase.Game.GetCurrentBeatD()) if (note.EndBeat == CBase.Game.GetCurrentBeatD())
width -= (1 - (CBase.Game.GetMidBeatD() - CBase.Game.GetCurrentBeatD())) / beats * w; width -= (1 - (CBase.Game.GetMidBeatD() - CBase.Game.GetCurrentBeatD())) / beats * w;
SRectF rect = new SRectF( var rect = new SRectF(
_PlayerNotes[n].Rect.X + (note.StartBeat - line.FirstNoteBeat) / beats * w, _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, _PlayerNotes[n].Rect.Y + (CBase.Settings.GetNumNoteLines() - 1 - (note.Tone - baseLine) / 2) / CBase.Settings.GetNumNoteLines() * h - dh,
width, width,
@@ -390,9 +388,9 @@ namespace VocaluxeLib.Menu.SingNotes
_DrawNote(rect, color, f); _DrawNote(rect, color, f);
if (note.EndBeat >= CBase.Game.GetCurrentBeatD() && note.Hit && note.NoteType == ENoteType.Golden) if (note.EndBeat >= CBase.Game.GetCurrentBeatD() && note.Hit && note.HitNote.NoteType == ENoteType.Golden)
{ {
SRectF re = new SRectF(rect) {W = (CBase.Game.GetMidBeatD() - note.StartBeat) / beats * w}; var re = new SRectF(rect) {W = (CBase.Game.GetMidBeatD() - note.StartBeat) / beats * w};
_AddFlare(re, n); _AddFlare(re, n);
} }
@@ -402,15 +400,14 @@ namespace VocaluxeLib.Menu.SingNotes
note.Perfect = false; 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 (currentLine > 0)
{ {
if (CBase.Game.GetPlayers()[player].SingLine[currentLine - 1].PerfectLine) if (CBase.Game.GetPlayers()[player].SungLines[currentLine - 1].PerfectLine)
{ {
_AddPerfectLine(n); _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 dh = (1f - factor) * rect.H / 2;
float dw = Math.Min(dh, rect.W / 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 noteBegin = CBase.Theme.GetSkinTexture(_Theme.SkinLeftName, _PartyModeID);
CTexture noteMiddle = CBase.Theme.GetSkinTexture(_Theme.SkinMiddleName, _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); 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) if (noteRect.W >= 4 * endsW)
CBase.Drawing.DrawTexture(noteMiddle, middleRect, color); CBase.Drawing.DrawTexture(noteMiddle, middleRect, color);
else else
@@ -516,7 +513,7 @@ namespace VocaluxeLib.Menu.SingNotes
if (2 * dw > rect.W) if (2 * dw > rect.W)
dw = rect.W / 2; dw = rect.W / 2;
SRectF r = new SRectF( var r = new SRectF(
rect.X + dw + spacing, rect.X + dw + spacing,
rect.Y + d + spacing, rect.Y + d + spacing,
rect.W - 2 * dw - 2 * spacing, rect.W - 2 * dw - 2 * spacing,
@@ -532,7 +529,7 @@ namespace VocaluxeLib.Menu.SingNotes
if (2 * dx > r.W) if (2 * dx > r.W)
dx = r.W / 2; 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); 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) if (2 * dw > rect.W)
dw = rect.W / 2; dw = rect.W / 2;
SRectF r = new SRectF( var r = new SRectF(
rect.X + dw + spacing, rect.X + dw + spacing,
rect.Y + d + spacing, rect.Y + d + spacing,
rect.W - 2 * dw - 2 * spacing, rect.W - 2 * dw - 2 * spacing,
@@ -573,8 +570,8 @@ namespace VocaluxeLib.Menu.SingNotes
rect.Z rect.Z
); );
int numstars = (int)(r.W * 0.25f); var 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 stars = new CParticleEffect(_PartyModeID, numstars, new SColorF(1f, 1f, 0f, 1f), r, _Theme.SkinGoldenStarName, 20, EParticleType.Star);
_PlayerNotes[n].GoldenStars.Add(stars); _PlayerNotes[n].GoldenStars.Add(stars);
} }
} }
@@ -589,7 +586,7 @@ namespace VocaluxeLib.Menu.SingNotes
if (2 * dw > rect.W) if (2 * dw > rect.W)
dw = rect.W / 2; dw = rect.W / 2;
SRectF r = new SRectF( var r = new SRectF(
rect.X + dw + spacing + rect.W - 2 * dw - 2 * spacing, rect.X + dw + spacing + rect.W - 2 * dw - 2 * spacing,
rect.Y + d + spacing, rect.Y + d + spacing,
0f, 0f,
@@ -597,7 +594,7 @@ namespace VocaluxeLib.Menu.SingNotes
rect.Z 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); _PlayerNotes[n].Flares.Add(flares);
} }
@@ -611,7 +608,7 @@ namespace VocaluxeLib.Menu.SingNotes
if (2 * dw > rect.W) if (2 * dw > rect.W)
dw = rect.W / 2; dw = rect.W / 2;
SRectF r = new SRectF( var r = new SRectF(
rect.X + dw + spacing, rect.X + dw + spacing,
rect.Y + d + spacing, rect.Y + d + spacing,
rect.W - 2 * dw - 2 * spacing, rect.W - 2 * dw - 2 * spacing,
@@ -632,14 +629,14 @@ namespace VocaluxeLib.Menu.SingNotes
rect.Z rect.Z
); );
CParticleEffect stars = new CParticleEffect(_PartyModeID, CBase.Game.GetRandom(2) + 1, new SColorF(1f, 1f, 1f, 1f), r, _Theme.SkinPerfectNoteStarName, 35, var stars = new CParticleEffect(_PartyModeID, CBase.Game.GetRandom(2) + 1, new SColorF(1f, 1f, 1f, 1f), r, _Theme.SkinPerfectNoteStarName, 35,
EParticleType.PerfNoteStar); EParticleType.PerfNoteStar);
_PlayerNotes[n].PerfectNoteEffect.Add(stars); _PlayerNotes[n].PerfectNoteEffect.Add(stars);
} }
private void _AddPerfectLine(int n) 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); _PlayerNotes[n].PerfectLineTwinkle.Add(twinkle);
} }
@@ -662,7 +659,7 @@ namespace VocaluxeLib.Menu.SingNotes
offsetX = noteBounds.W; offsetX = noteBounds.W;
float dy = noteBounds.H / CBase.Settings.GetNumNoteLines(); float dy = noteBounds.H / CBase.Settings.GetNumNoteLines();
SRectF drawRect = new SRectF( var drawRect = new SRectF(
noteBounds.X - dy + offsetX, noteBounds.X - dy + offsetX,
noteBounds.Y + dy * (CBase.Settings.GetNumNoteLines() - 1 - (tonePlayer - baseLine) / 2f), noteBounds.Y + dy * (CBase.Settings.GetNumNoteLines() - 1 - (tonePlayer - baseLine) / 2f),
dy, dy,
@@ -670,7 +667,7 @@ namespace VocaluxeLib.Menu.SingNotes
noteBounds.Z noteBounds.Z
); );
SColorF color = new SColorF( var color = new SColorF(
_PlayerNotes[n].Color.R, _PlayerNotes[n].Color.R,
_PlayerNotes[n].Color.G, _PlayerNotes[n].Color.G,
_PlayerNotes[n].Color.B, _PlayerNotes[n].Color.B,
@@ -518,7 +518,10 @@ namespace VocaluxeLib.Menu.SongMenu
_Active = active; _Active = active;
} }
public virtual bool IsMouseOverActualSelection(SMouseEvent mEvent) { return false; } public virtual bool IsMouseOverActualSelection(SMouseEvent mEvent)
{
return false;
}
public virtual int GetSelectedSong() public virtual int GetSelectedSong()
{ {
+10 -10
View File
@@ -92,9 +92,9 @@ namespace VocaluxeLib.Menu.SongMenu
{ {
for (int j = 0; j < _NumW; j++) for (int j = 0; j < _NumW; j++)
{ {
SRectF rect = new SRectF(_Theme.SongMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW), var rect = new SRectF(_Theme.SongMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW),
_Theme.SongMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); _Theme.SongMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
CStatic tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect); var tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
_Tiles.Add(tile); _Tiles.Add(tile);
} }
} }
@@ -423,8 +423,8 @@ namespace VocaluxeLib.Menu.SongMenu
time = song.Finish; time = song.Finish;
time -= song.Start; time -= song.Start;
int min = (int)Math.Floor(time / 60f); var min = (int)Math.Floor(time / 60f);
int sec = (int)(time - min * 60f); var sec = (int)(time - min * 60f);
_SongLength.Text = min.ToString("00") + ":" + sec.ToString("00"); _SongLength.Text = min.ToString("00") + ":" + sec.ToString("00");
} }
} }
@@ -458,11 +458,11 @@ namespace VocaluxeLib.Menu.SongMenu
{ {
if (_Vidtex.Color.A < 1) if (_Vidtex.Color.A < 1)
_CoverBig.Draw(1f, EAspect.Crop); _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; RectangleF rect;
CHelper.SetRect(bounds, out rect, _Vidtex.OrigAspect, EAspect.Crop); CHelper.SetRect(bounds, out rect, _Vidtex.OrigAspect, EAspect.Crop);
SRectF vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z); var 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 vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f);
CBase.Drawing.DrawTexture(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds); CBase.Drawing.DrawTexture(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds);
CBase.Drawing.DrawTextureReflection(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); CBase.Drawing.DrawTextureReflection(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight);
@@ -490,7 +490,7 @@ namespace VocaluxeLib.Menu.SongMenu
CStatic selCov = GetSelectedSongCover(); CStatic selCov = GetSelectedSongCover();
if (selCov.Texture == null) if (selCov.Texture == null)
return false; 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); return CHelper.IsInBounds(rect, mEvent);
} }
@@ -679,8 +679,8 @@ namespace VocaluxeLib.Menu.SongMenu
{ {
for (int j = 0; j < _NumW; j++) 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); var 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 tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
_Tiles.Add(tile); _Tiles.Add(tile);
} }
} }
+1 -1
View File
@@ -25,7 +25,7 @@ namespace VocaluxeLib.PartyModes
{ {
public abstract class CPartyMode : IPartyMode public abstract class CPartyMode : IPartyMode
{ {
protected string _Folder; private string _Folder;
protected SScreenSongOptions _ScreenSongOptions; protected SScreenSongOptions _ScreenSongOptions;
protected readonly Dictionary<string, CMenuParty> _Screens; protected readonly Dictionary<string, CMenuParty> _Screens;
+82
View File
@@ -0,0 +1,82 @@
#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 <http://www.gnu.org/licenses/>.
// */
#endregion
namespace VocaluxeLib.Songs
{
/// <summary>
/// Base class for all note types
/// </summary>
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
}
}
+154
View File
@@ -0,0 +1,154 @@
#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 <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Collections.Generic;
using System.Linq;
namespace VocaluxeLib.Songs
{
public class CLineBase<T> where T : CBaseNote
{
protected readonly List<T> _Notes = new List<T>();
#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
}
}
-627
View File
@@ -17,9 +17,7 @@
// */ // */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace VocaluxeLib.Songs namespace VocaluxeLib.Songs
{ {
@@ -94,629 +92,4 @@ namespace VocaluxeLib.Songs
voice.SetMedley(startBeat, endBeat); 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<CNote> _Notes = new List<CNote>();
#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<CLine> _Lines = new List<CLine>();
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; }
}
/// <summary>
/// Total song length in beats
/// </summary>
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
}
} }
+9 -9
View File
@@ -149,7 +149,7 @@ namespace VocaluxeLib.Songs
public int DataBaseSongID = -1; public int DataBaseSongID = -1;
public string DateAdded = ""; public string DateAdded = "";
public int NumPlayed = 0; public int NumPlayed;
// Notes // Notes
public readonly CNotes Notes = new CNotes(); public readonly CNotes Notes = new CNotes();
@@ -158,7 +158,7 @@ namespace VocaluxeLib.Songs
{ {
get get
{ {
List<EGameMode> gms = new List<EGameMode> {IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL}; var gms = new List<EGameMode> {IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL};
if (Medley.Source != EMedleySource.None) if (Medley.Source != EMedleySource.None)
gms.Add(EGameMode.TR_GAMEMODE_MEDLEY); gms.Add(EGameMode.TR_GAMEMODE_MEDLEY);
gms.Add(EGameMode.TR_GAMEMODE_SHORTSONG); gms.Add(EGameMode.TR_GAMEMODE_SHORTSONG);
@@ -172,7 +172,7 @@ namespace VocaluxeLib.Songs
public static CSong LoadSong(string filePath) public static CSong LoadSong(string filePath)
{ {
CSong song = new CSong(); var song = new CSong();
return song.ReadHeader(filePath) ? song : null; return song.ReadHeader(filePath) ? song : null;
} }
@@ -289,7 +289,7 @@ namespace VocaluxeLib.Songs
FileName = Path.GetFileName(filePath); FileName = Path.GetFileName(filePath);
EHeaderFlags headerFlags = new EHeaderFlags(); var headerFlags = new EHeaderFlags();
StreamReader sr = null; StreamReader sr = null;
try try
{ {
@@ -737,7 +737,7 @@ namespace VocaluxeLib.Songs
private bool _ParseNote(int player, ENoteType noteType, int start, int length, int tone, string text) private bool _ParseNote(int player, ENoteType noteType, int start, int length, int tone, string text)
{ {
CNote note = new CNote(start, length, tone, text, noteType); var note = new CSongNote(start, length, tone, text, noteType);
CVoice voice = Notes.GetVoice(player); CVoice voice = Notes.GetVoice(player);
return voice.AddNote(note); return voice.AddNote(note);
} }
@@ -745,7 +745,7 @@ namespace VocaluxeLib.Songs
private void _NewSentence(int player, int start) private void _NewSentence(int player, int start)
{ {
CVoice voice = Notes.GetVoice(player); CVoice voice = Notes.GetVoice(player);
CLine line = new CLine {StartBeat = start}; var line = new CSongLine {StartBeat = start};
voice.AddLine(line); voice.AddLine(line);
} }
@@ -821,14 +821,14 @@ namespace VocaluxeLib.Songs
List<string> sentences = voice.Lines.Select(line => line.Points != 0 ? line.Lyrics : String.Empty).ToList(); List<string> sentences = voice.Lines.Select(line => line.Points != 0 ? line.Lyrics : String.Empty).ToList();
// find equal sentences series // find equal sentences series
List<SSeries> series = new List<SSeries>(); var series = new List<SSeries>();
for (int i = 0; i < voice.NumLines - 1; i++) for (int i = 0; i < voice.NumLines - 1; i++)
{ {
for (int j = i + 1; j < voice.NumLines; j++) for (int j = i + 1; j < voice.NumLines; j++)
{ {
if (sentences[i] != sentences[j] || sentences[i] == "") if (sentences[i] != sentences[j] || sentences[i] == "")
continue; continue;
SSeries tempSeries = new SSeries {Start = i, End = i}; var tempSeries = new SSeries {Start = i, End = i};
int max; int max;
if (j + j - i > voice.NumLines) if (j + j - i > voice.NumLines)
@@ -945,7 +945,7 @@ namespace VocaluxeLib.Songs
} }
//Check if stop is in line //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) if (line.FirstNoteBeat < stop && line.LastNoteBeat > stop)
{ {
+105
View File
@@ -0,0 +1,105 @@
#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 <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Linq;
namespace VocaluxeLib.Songs
{
public class CSongLine : CLineBase<CSongNote>
{
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
}
}
+66
View File
@@ -0,0 +1,66 @@
#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 <http://www.gnu.org/licenses/>.
// */
#endregion
namespace VocaluxeLib.Songs
{
/// <summary>
/// Class to represent a note in a song
/// </summary>
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, ENoteType noteType)
: base(startBeat, duration, tone)
{
NoteType = noteType;
Text = text;
}
#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
}
}
+37
View File
@@ -0,0 +1,37 @@
#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 <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Linq;
namespace VocaluxeLib.Songs
{
public class CSungLine : CLineBase<CSungNote>
{
// 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;
}
}
}
+82
View File
@@ -0,0 +1,82 @@
#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 <http://www.gnu.org/licenses/>.
// */
#endregion
namespace VocaluxeLib.Songs
{
/// <summary>
/// Note that was sung by a player
/// </summary>
public class CSungNote : CBaseNote
{
/// <summary>
/// Constructor for a sung note that was not hit
/// </summary>
/// <param name="startBeat"></param>
/// <param name="duration"></param>
/// <param name="tone"></param>
public CSungNote(int startBeat, int duration, int tone) : base(startBeat, duration, tone)
{
Perfect = false;
HitNote = null;
}
/// <summary>
/// Constructor for a sung note that hit the given note
/// </summary>
/// <param name="startBeat"></param>
/// <param name="duration"></param>
/// <param name="tone"></param>
/// <param name="hitNote"></param>
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; private 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; }
}
}
}
+210
View File
@@ -0,0 +1,210 @@
#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 <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Collections.Generic;
using System.Linq;
namespace VocaluxeLib.Songs
{
public class CVoice
{
private readonly List<CSongLine> _Lines = new List<CSongLine>();
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; }
}
/// <summary>
/// Total song length in beats
/// </summary>
public int Length
{
get
{
if (_Lines.Count == 0)
return 0;
int result = _Lines[_Lines.Count - 1].EndBeat - _Lines[0].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
var 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
}
}
+2 -2
View File
@@ -186,8 +186,8 @@ namespace VocaluxeLib
public double PointsLineBonus; public double PointsLineBonus;
public double PointsGoldenNotes; public double PointsGoldenNotes;
public int NoteDiff; public int NoteDiff;
public int LineNr; public int VoiceNr;
public List<CLine> SingLine; public List<CSungLine> SungLines;
public int CurrentLine; public int CurrentLine;
public int CurrentNote; public int CurrentNote;
+7
View File
@@ -158,6 +158,10 @@
<Compile Include="Menu\IMenuElement.cs" /> <Compile Include="Menu\IMenuElement.cs" />
<Compile Include="Profile\CAvatar.cs" /> <Compile Include="Profile\CAvatar.cs" />
<Compile Include="Profile\CProfile.cs" /> <Compile Include="Profile\CProfile.cs" />
<Compile Include="Songs\CLineBase.cs" />
<Compile Include="Songs\CBaseNote.cs" />
<Compile Include="Songs\CSongLine.cs" />
<Compile Include="Songs\CSongNote.cs" />
<Compile Include="Songs\CNotes.cs" /> <Compile Include="Songs\CNotes.cs" />
<Compile Include="Menu\SingNotes\CSingNotes.cs" /> <Compile Include="Menu\SingNotes\CSingNotes.cs" />
<Compile Include="Menu\SingNotes\CSingNotesClassic.cs" /> <Compile Include="Menu\SingNotes\CSingNotesClassic.cs" />
@@ -170,6 +174,9 @@
<Compile Include="Menu\SongMenu\CSongMenuList.cs" /> <Compile Include="Menu\SongMenu\CSongMenuList.cs" />
<Compile Include="Menu\SongMenu\CSongMenuTileBoard.cs" /> <Compile Include="Menu\SongMenu\CSongMenuTileBoard.cs" />
<Compile Include="Menu\SongMenu\ISongMenu.cs" /> <Compile Include="Menu\SongMenu\ISongMenu.cs" />
<Compile Include="Songs\CSungLine.cs" />
<Compile Include="Songs\CSungNote.cs" />
<Compile Include="Songs\CVoice.cs" />
<Compile Include="Structs.cs" /> <Compile Include="Structs.cs" />
<Compile Include="PartyModes\CPartyMode.cs" /> <Compile Include="PartyModes\CPartyMode.cs" />
<Compile Include="PartyModes\CPartyModeNone.cs" /> <Compile Include="PartyModes\CPartyModeNone.cs" />