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