More refactoring and small fixes

This commit is contained in:
Flamefire committed 2013-04-23 14:22:42 +02:00
1 parent dcbbc5caf3
commit 1540be9120
46 files changed
+205 -526

No files matched your search

@@ -19,6 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace VocaluxeLib.PartyModes.Challenge namespace VocaluxeLib.PartyModes.Challenge
{ {
@@ -27,7 +28,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private readonly Random _Rand; private readonly Random _Rand;
private readonly int _NumPlayer; private readonly int _NumPlayer;
public List<CCombination> Rounds; public readonly List<CCombination> Rounds;
public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce) public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce)
{ {
@@ -60,7 +61,7 @@ namespace VocaluxeLib.PartyModes.Challenge
Rounds.Add(combinations.GetNextCombination(_GetPlayerDemand(i))); Rounds.Add(combinations.GetNextCombination(_GetPlayerDemand(i)));
} }
private List<int> _GetPlayerDemand(int roundIndex) private IEnumerable<int> _GetPlayerDemand(int roundIndex)
{ {
List<int> numPlayed = new List<int>(_NumPlayer); List<int> numPlayed = new List<int>(_NumPlayer);
for (int i = 0; i < _NumPlayer; i++) for (int i = 0; i < _NumPlayer; i++)
@@ -72,12 +73,7 @@ namespace VocaluxeLib.PartyModes.Challenge
numPlayed[playerIndex]++; numPlayed[playerIndex]++;
} }
int max = 0; int max = numPlayed.Max();
foreach (int p in numPlayed)
{
if (p > max)
max = p;
}
int num = Rounds[0].Player.Count; int num = Rounds[0].Player.Count;
List<int> result = new List<int>(); List<int> result = new List<int>();
@@ -150,13 +146,11 @@ namespace VocaluxeLib.PartyModes.Challenge
_Rand = rand; _Rand = rand;
} }
public CCombination GetNextCombination(List<int> playerNrDemand) public CCombination GetNextCombination(IEnumerable<int> playerNrDemand)
{ {
if (_Combs.Count == 0) if (_Combs.Count == 0)
_Create(); _Create();
CCombination combs = new CCombination();
if (_NumPlayer == _NumMics) if (_NumPlayer == _NumMics)
return _Combs[0]; return _Combs[0];
@@ -164,28 +158,19 @@ namespace VocaluxeLib.PartyModes.Challenge
List<CCombination> combsFiltered = new List<CCombination>(); List<CCombination> combsFiltered = new List<CCombination>();
if (playerNrDemand != null) if (playerNrDemand != null)
{ {
for (int i = 0; i < _Combs.Count; i++) combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableAll(playerNrDemand)));
{
if (_Combs[i].IsAvailableAll(playerNrDemand))
combsFiltered.Add(_Combs[i]);
}
} }
//1st fallback //1st fallback
if (playerNrDemand != null && combsFiltered.Count == 0) if (playerNrDemand != null && combsFiltered.Count == 0)
{ {
for (int i = 0; i < _Combs.Count; i++) combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableSomeone(playerNrDemand)));
{
if (_Combs[i].IsAvailableSomeone(playerNrDemand))
combsFiltered.Add(_Combs[i]);
}
} }
//2nd fallback //2nd fallback
if (combsFiltered.Count == 0) if (combsFiltered.Count == 0)
{ {
for (int i = 0; i < _Combs.Count; i++) combsFiltered.AddRange(_Combs);
combsFiltered.Add(_Combs[i]);
} }
int num = combsFiltered.Count; int num = combsFiltered.Count;
@@ -222,7 +207,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public class CCombination public class CCombination
{ {
public List<int> Player; public readonly List<int> Player;
public CCombination() public CCombination()
{ {
@@ -231,28 +216,17 @@ namespace VocaluxeLib.PartyModes.Challenge
public bool IsAvailable(int playerIndex) public bool IsAvailable(int playerIndex)
{ {
foreach (int p in Player) return Player.Any(p => p == playerIndex);
{
if (p == playerIndex)
return true;
}
return false;
} }
public bool IsAvailableAll(List<int> playerIndices) public bool IsAvailableAll(IEnumerable<int> playerIndices)
{ {
bool result = true; return playerIndices.All(IsAvailable);
foreach (int p in playerIndices)
result &= IsAvailable(p);
return result;
} }
public bool IsAvailableSomeone(List<int> playerIndices) public bool IsAvailableSomeone(IEnumerable<int> playerIndices)
{ {
bool result = false; return playerIndices.Any(IsAvailable);
foreach (int p in playerIndices)
result |= IsAvailable(p);
return result;
} }
} }
} }
@@ -58,17 +58,15 @@ namespace VocaluxeLib.PartyModes.Challenge
public int Position; public int Position;
public int PlayerID; public int PlayerID;
public int NumPlayed; public int NumPlayed;
public int NumRounds;
public int NumWon; public int NumWon;
public int NumSingPoints; public int NumSingPoints;
public int NumGamePoints; public int NumGamePoints;
public int CompareTo(object obj) public int CompareTo(object obj)
{ {
if (obj is CResultTableRow) CResultTableRow row = obj as CResultTableRow;
if (row != null)
{ {
CResultTableRow row = (CResultTableRow)obj;
int res = row.NumGamePoints.CompareTo(NumGamePoints); int res = row.NumGamePoints.CompareTo(NumGamePoints);
if (res == 0) if (res == 0)
{ {
@@ -101,8 +99,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public struct SFromScreenNames public struct SFromScreenNames
{ {
public bool FadeToConfig; public bool FadeBack;
public bool FadeToMain;
public List<int> ProfileIDs; public List<int> ProfileIDs;
} }
@@ -236,7 +233,7 @@ namespace VocaluxeLib.PartyModes.Challenge
try try
{ {
dataFrom = (SDataFromScreen)data; dataFrom = (SDataFromScreen)data;
if (dataFrom.ScreenNames.FadeToConfig) if (dataFrom.ScreenNames.FadeBack)
_Stage = EStage.NotStarted; _Stage = EStage.NotStarted;
else else
{ {
@@ -590,13 +587,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
for (int i = 0; i < _GameData.NumPlayer; i++) for (int i = 0; i < _GameData.NumPlayer; i++)
{ {
CResultTableRow row = new CResultTableRow(); CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0};
row.PlayerID = _GameData.ProfileIDs[i];
row.NumPlayed = 0;
row.NumRounds = 0;
row.NumWon = 0;
row.NumSingPoints = 0;
row.NumGamePoints = 0;
_GameData.ResultTable.Add(row); _GameData.ResultTable.Add(row);
} }
@@ -633,18 +624,16 @@ namespace VocaluxeLib.PartyModes.Challenge
} }
} }
if (index != -1) if (index == -1)
{ continue;
CResultTableRow row = _GameData.ResultTable[index]; CResultTableRow row = _GameData.ResultTable[index];
row.NumPlayed++; row.NumPlayed++;
row.NumWon += points[i].Won; row.NumWon += points[i].Won;
row.NumRounds += 1; row.NumSingPoints += points[i].SingPoints;
row.NumSingPoints += points[i].SingPoints; row.NumGamePoints += points[i].GamePoints;
row.NumGamePoints += points[i].GamePoints;
_GameData.ResultTable[index] = row; _GameData.ResultTable[index] = row;
}
} }
} }
@@ -23,7 +23,9 @@ using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.Challenge namespace VocaluxeLib.PartyModes.Challenge
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeConfig : CMenuParty public class CPartyScreenChallengeConfig : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -41,7 +41,9 @@ namespace VocaluxeLib.PartyModes.Challenge
public List<CText> TextScores; public List<CText> TextScores;
} }
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMain : CMenuParty public class CPartyScreenChallengeMain : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -350,9 +352,9 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdateNextPlayerPositions() private void _UpdateNextPlayerPositions()
{ {
float x = CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2; float x = (float) CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2;
float staticY = 590; const float staticY = 590;
float textY = 550; const float textY = 550;
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
//static //static
@@ -606,7 +608,7 @@ namespace VocaluxeLib.PartyModes.Challenge
row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + "."; row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + ".";
row.Name.Text = profiles[_GameState.ResultTable[i + _PlayerTableOffset].PlayerID].PlayerName; row.Name.Text = profiles[_GameState.ResultTable[i + _PlayerTableOffset].PlayerID].PlayerName;
row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumRounds.ToString(); row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString();
row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString(); row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString();
row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString(); row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString();
row.GamePoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumGamePoints.ToString(); row.GamePoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumGamePoints.ToString();
@@ -89,7 +89,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, FadeToMain = false, ProfileIDs = new List<int>()}; SFromScreenNames names = new SFromScreenNames {FadeBack = false, ProfileIDs = new List<int>()};
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
@@ -485,15 +485,13 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _Back() private void _Back()
{ {
_Data.ScreenNames.FadeToConfig = true; _Data.ScreenNames.FadeBack = true;
_Data.ScreenNames.FadeToMain = false;
_PartyMode.DataFromScreen(ThemeName, _Data); _PartyMode.DataFromScreen(ThemeName, _Data);
} }
private void _Next() private void _Next()
{ {
_Data.ScreenNames.FadeToConfig = false; _Data.ScreenNames.FadeBack = false;
_Data.ScreenNames.FadeToMain = true;
_PartyMode.DataFromScreen(ThemeName, _Data); _PartyMode.DataFromScreen(ThemeName, _Data);
} }
} }
@@ -66,10 +66,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public int CompareTo(object obj) public int CompareTo(object obj)
{ {
if (obj is CResultTableRow) CResultTableRow row = obj as CResultTableRow;
if (row != null)
{ {
CResultTableRow row = (CResultTableRow)obj;
int res = row.NumGamePoints.CompareTo(NumGamePoints); int res = row.NumGamePoints.CompareTo(NumGamePoints);
if (res == 0) if (res == 0)
{ {
@@ -23,7 +23,9 @@ using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.ChallengeMedley namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMedleyConfig : CMenuParty public class CPartyScreenChallengeMedleyConfig : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -41,7 +41,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public List<CText> TextScores; public List<CText> TextScores;
} }
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMedleyMain : CMenuParty public class CPartyScreenChallengeMedleyMain : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -350,9 +352,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateNextPlayerPositions() private void _UpdateNextPlayerPositions()
{ {
float x = CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2; float x = (float) CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2;
float staticY = 590; const float staticY = 590;
float textY = 550; const float textY = 550;
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
//static //static
@@ -24,7 +24,9 @@ using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.ChallengeMedley namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMedleyNames : CMenuParty public class CPartyScreenChallengeMedleyNames : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -18,12 +18,15 @@
#endregion #endregion
using System; using System;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.TicTacToe namespace VocaluxeLib.PartyModes.TicTacToe
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenTicTacToeConfig : CMenuParty public class CPartyScreenTicTacToeConfig : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -57,14 +60,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack}; _ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenConfig config = new SFromScreenConfig(); SFromScreenConfig config = new SFromScreenConfig
config.PlaylistID = 0; {
config.NumFields = 9; PlaylistID = 0,
config.NumPlayerTeam1 = 2; NumFields = 9,
config.NumPlayerTeam2 = 2; NumPlayerTeam1 = 2,
config.GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL; NumPlayerTeam2 = 2,
config.CategoryID = 0; GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL,
config.SongSource = ESongSource.TR_ALLSONGS; CategoryID = 0,
SongSource = ESongSource.TR_ALLSONGS
};
_Data.ScreenConfig = config; _Data.ScreenConfig = config;
} }
@@ -263,14 +268,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(_Data.ScreenConfig.PlaylistID); i++) for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(_Data.ScreenConfig.PlaylistID); i++)
{ {
int id = CBase.Playlist.GetPlaylistSong(_Data.ScreenConfig.PlaylistID, i).SongID; int id = CBase.Playlist.GetPlaylistSong(_Data.ScreenConfig.PlaylistID, i).SongID;
foreach (EGameMode mode in CBase.Songs.GetSongByID(id).AvailableGameModes) _ConfigOk = CBase.Songs.GetSongByID(id).AvailableGameModes.Any(mode => mode == gm);
{
if (mode == gm)
{
_ConfigOk = true;
break;
}
}
if (_ConfigOk) if (_ConfigOk)
break; break;
} }
@@ -291,14 +289,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ConfigOk = false; _ConfigOk = false;
for (int i = 0; i < CBase.Songs.NumSongsInCategory(_Data.ScreenConfig.CategoryID); i++) for (int i = 0; i < CBase.Songs.NumSongsInCategory(_Data.ScreenConfig.CategoryID); i++)
{ {
foreach (EGameMode mode in CBase.Songs.GetVisibleSong(i).AvailableGameModes) _ConfigOk=CBase.Songs.GetVisibleSong(i).AvailableGameModes.Any(mode => mode == gm);
{
if (mode == gm)
{
_ConfigOk = true;
break;
}
}
if (_ConfigOk) if (_ConfigOk)
break; break;
} }
@@ -316,14 +307,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
for (int i = 0; i < CBase.Songs.GetNumSongs(); i++) for (int i = 0; i < CBase.Songs.GetNumSongs(); i++)
{ {
foreach (EGameMode mode in CBase.Songs.GetSongByID(i).AvailableGameModes) _ConfigOk = CBase.Songs.GetSongByID(i).AvailableGameModes.Any(mode => mode == gm);
{
if (mode == gm)
{
_ConfigOk = true;
break;
}
}
if (_ConfigOk) if (_ConfigOk)
break; break;
} }
@@ -400,13 +400,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateFields() private void _UpdateFields()
{ {
int numOneRow = (int)Math.Sqrt(_GameData.NumFields); int numOneRow = (int)Math.Sqrt(_GameData.NumFields);
float fieldSizeY = (CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow; float fieldSizeY = ((float)CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow;
float fieldSizeX = (CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow; float fieldSizeX = ((float)CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow;
if (fieldSizeX < fieldSizeY) _FieldSize = Math.Min(fieldSizeX, fieldSizeY);
_FieldSize = fieldSizeX; _FieldFirstX = (float)CBase.Settings.GetRenderW() / 2 - (numOneRow * _FieldSize + (numOneRow - 1) * _FieldSpace) / 2;
else
_FieldSize = fieldSizeY;
_FieldFirstX = CBase.Settings.GetRenderW() / 2 - (numOneRow * _FieldSize + (numOneRow - 1) * _FieldSpace) / 2;
_FieldFirstY = 140 + (CBase.Settings.GetRenderH() - 140) / 2 - (numOneRow * _FieldSize + numOneRow * _FieldSpace) / 2; _FieldFirstY = 140 + (CBase.Settings.GetRenderH() - 140) / 2 - (numOneRow * _FieldSize + numOneRow * _FieldSpace) / 2;
int row = 0; int row = 0;
int column = 0; int column = 0;
@@ -24,7 +24,9 @@ using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.TicTacToe namespace VocaluxeLib.PartyModes.TicTacToe
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenTicTacToeNames : CMenuParty public class CPartyScreenTicTacToeNames : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
File renamed without changes.
+4 -4
View File
@@ -40,14 +40,14 @@ namespace Vocaluxe.Base
_Input = null; _Input = null;
} }
public static bool Connect() public static void Connect()
{ {
return _Input.Connect(); _Input.Connect();
} }
public static bool Disconnect() public static void Disconnect()
{ {
return _Input.Disconnect(); _Input.Disconnect();
} }
public static bool IsConnected() public static bool IsConnected()
+13 -15
View File
@@ -36,6 +36,15 @@ namespace Vocaluxe.Base
_LogFileName = fileName; _LogFileName = fileName;
} }
private void _Open()
{
_LogFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, _LogFileName), false, Encoding.UTF8);
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
_LogFile.WriteLine("----------------------------------------");
_LogFile.WriteLine();
}
public void Close() public void Close()
{ {
if (_LogFile == null) if (_LogFile == null)
@@ -53,21 +62,10 @@ namespace Vocaluxe.Base
if (_LogFile == null) if (_LogFile == null)
_Open(); _Open();
try // ReSharper disable PossibleNullReferenceException
{ _LogFile.WriteLine(text);
_LogFile.WriteLine(text); // ReSharper restore PossibleNullReferenceException
_LogFile.Flush(); _LogFile.Flush();
}
catch (Exception) {}
}
private void _Open()
{
_LogFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, _LogFileName), false, Encoding.UTF8);
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
_LogFile.WriteLine("----------------------------------------");
_LogFile.WriteLine();
} }
public void Dispose() public void Dispose()
+1 -4
View File
@@ -30,7 +30,6 @@ namespace Vocaluxe.Base
public static IConfig Config = new CBconfig(); public static IConfig Config = new CBconfig();
public static ISettings Settings = new CBsettings(); public static ISettings Settings = new CBsettings();
public static ITheme Theme = new CBtheme(); public static ITheme Theme = new CBtheme();
public static IHelper Helper = new CBhelper();
public static IBackgroundMusic BackgroundMusic = new CBbackgroundMusic(); public static IBackgroundMusic BackgroundMusic = new CBbackgroundMusic();
public static IDrawing Draw = new CBdraw(); public static IDrawing Draw = new CBdraw();
public static IGraphics Graphics = new CBGraphics(); public static IGraphics Graphics = new CBGraphics();
@@ -50,7 +49,7 @@ namespace Vocaluxe.Base
public static void Init() public static void Init()
{ {
CBase.Assign(Config, Settings, Theme, Helper, Log, BackgroundMusic, Draw, Graphics, Fonts, Language, CBase.Assign(Config, Settings, Theme, Log, BackgroundMusic, Draw, Graphics, Fonts, Language,
Game, Profiles, Record, Songs, Video, Sound, Cover, DataBase, Input, Playlist); Game, Profiles, Record, Songs, Video, Sound, Cover, DataBase, Input, Playlist);
} }
} }
@@ -294,8 +293,6 @@ namespace Vocaluxe.Base
} }
} }
class CBhelper : IHelper {}
class CBbackgroundMusic : IBackgroundMusic class CBbackgroundMusic : IBackgroundMusic
{ {
public bool IsDisabled() public bool IsDisabled()
+2
View File
@@ -26,10 +26,12 @@ namespace Vocaluxe.Base
{ {
enum ERevision enum ERevision
{ {
// ReSharper disable UnusedMember.Global
Alpha, Alpha,
Beta, Beta,
RC, RC,
Release Release
// ReSharper restore UnusedMember.Global
} }
static class CSettings static class CSettings
+5
View File
@@ -130,6 +130,11 @@ namespace Vocaluxe.Base
else else
{ {
FieldInfo field = typeof(CSong).GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); FieldInfo field = typeof(CSong).GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
if (field == null)
{
CLog.LogError("Unknow sorting field: "+fieldName);
return _CreateSortList("");
}
bool isString = field.FieldType == typeof(string); bool isString = field.FieldType == typeof(string);
if (!isString && field.FieldType != typeof(List<String>)) if (!isString && field.FieldType != typeof(List<String>))
throw new Exception("Unkown sort field type"); throw new Exception("Unkown sort field type");
+12
View File
@@ -71,6 +71,18 @@ namespace Vocaluxe
Show(); Show();
} }
public override sealed string Text
{
get { return base.Text; }
set { base.Text = value; }
}
public override sealed Color BackColor
{
get { return base.BackColor; }
set { base.BackColor = value; }
}
protected override void OnPaint(PaintEventArgs e) {} protected override void OnPaint(PaintEventArgs e) {}
protected override void OnPaintBackground(PaintEventArgs e) protected override void OnPaintBackground(PaintEventArgs e)
+3 -3
View File
@@ -34,10 +34,10 @@ namespace Vocaluxe.Lib.Input
interface IInput interface IInput
{ {
bool Init(); void Init();
void Close(); void Close();
bool Connect(); void Connect();
bool Disconnect(); void Disconnect();
bool IsConnected(); bool IsConnected();
void Update(); void Update();
+10 -21
View File
@@ -50,15 +50,13 @@ namespace Vocaluxe.Lib.Input.WiiMote
private CGesture _Gesture; private CGesture _Gesture;
public bool Init() public void Init()
{ {
_Sync = new Object(); _Sync = new Object();
_RumbleTimer = new CRumbleTimer(); _RumbleTimer = new CRumbleTimer();
_Gesture = new CGesture(); _Gesture = new CGesture();
_Active = true; _HandlerThread = new Thread(_MainLoop) {Priority = ThreadPriority.BelowNormal};
_HandlerThread = new Thread(_MainLoop);
_HandlerThread.Priority = ThreadPriority.BelowNormal;
_KeysPool = new List<SKeyEvent>(); _KeysPool = new List<SKeyEvent>();
_CurrentKeysPool = new List<SKeyEvent>(); _CurrentKeysPool = new List<SKeyEvent>();
@@ -68,10 +66,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
_ButtonStates = new bool[11]; _ButtonStates = new bool[11];
_OldPosition = new Point(); _OldPosition = new Point();
_HandlerThread.Start();
return true;
} }
public void Close() public void Close()
@@ -79,20 +73,17 @@ namespace Vocaluxe.Lib.Input.WiiMote
_Active = false; _Active = false;
} }
public bool Connect() public void Connect()
{ {
if (!_Active) if (_Active)
{ return;
_Active = true; _Active = true;
_HandlerThread.Start(); _HandlerThread.Start();
}
return true;
} }
public bool Disconnect() public void Disconnect()
{ {
_Active = false; _Active = false;
return true;
} }
public bool IsConnected() public bool IsConnected()
@@ -113,8 +104,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
_CurrentKeysPool.RemoveAt(0); _CurrentKeysPool.RemoveAt(0);
return true; return true;
} }
else return false;
return false;
} }
public bool PollMouseEvent(ref SMouseEvent mouseEvent) public bool PollMouseEvent(ref SMouseEvent mouseEvent)
@@ -125,8 +115,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
_CurrentMousePool.RemoveAt(0); _CurrentMousePool.RemoveAt(0);
return true; return true;
} }
else return false;
return false;
} }
public void SetRumble(float duration) public void SetRumble(float duration)
+4 -10
View File
@@ -119,7 +119,6 @@ namespace Vocaluxe.Lib.Sound
{ {
_Decoder.Add(decoder); _Decoder.Add(decoder);
stream.Handle = _Count++; stream.Handle = _Count++;
stream.File = media;
_Streams.Add(stream); _Streams.Add(stream);
return stream.Handle; return stream.Handle;
} }
@@ -399,7 +398,6 @@ namespace Vocaluxe.Lib.Sound
private Closeproc _Closeproc; private Closeproc _Closeproc;
private int _StreamID; private int _StreamID;
private string _FileName;
private IAudioDecoder _Decoder; private IAudioDecoder _Decoder;
private float _BytesPerSecond; private float _BytesPerSecond;
private bool _NoMoreData; private bool _NoMoreData;
@@ -506,7 +504,7 @@ namespace Vocaluxe.Lib.Sound
{ {
if (Finished) if (Finished)
_Timer.Stop(); _Timer.Stop();
//TODO: Why not use Decoder.GetPosition()?
return _CurrentTime + _Timer.ElapsedMilliseconds / 1000f; return _CurrentTime + _Timer.ElapsedMilliseconds / 1000f;
} }
} }
@@ -586,9 +584,6 @@ namespace Vocaluxe.Lib.Sound
if (!File.Exists(fileName)) if (!File.Exists(fileName))
return -1; return -1;
if (_FileOpened)
return -1;
_Decoder = new CAudioDecoderFFmpeg(); _Decoder = new CAudioDecoderFFmpeg();
_Decoder.Init(); _Decoder.Init();
@@ -609,7 +604,6 @@ namespace Vocaluxe.Lib.Sound
return -1; return -1;
} }
_FileName = fileName;
_Decoder.Open(fileName); _Decoder.Open(fileName);
_Duration = _Decoder.GetLength(); _Duration = _Decoder.GetLength();
@@ -619,9 +613,7 @@ namespace Vocaluxe.Lib.Sound
_CurrentTime = 0f; _CurrentTime = 0f;
_Timer.Reset(); _Timer.Reset();
SAudioStreams stream = new SAudioStreams(0); SAudioStreams stream = new SAudioStreams(0) {Handle = _Buffers[0]};
stream.Handle = _Buffers[0];
if (stream.Handle != 0) if (stream.Handle != 0)
{ {
@@ -634,6 +626,7 @@ namespace Vocaluxe.Lib.Sound
return stream.Handle; return stream.Handle;
} }
_Initialized = true;
return -1; return -1;
} }
@@ -758,6 +751,7 @@ namespace Vocaluxe.Lib.Sound
AL.DeleteSource(_Source); AL.DeleteSource(_Source);
AL.DeleteBuffers(_Buffers); AL.DeleteBuffers(_Buffers);
} }
_Decoder.Close();
} }
_Closeproc(_StreamID); _Closeproc(_StreamID);
-23
View File
@@ -1,23 +0,0 @@
#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.Lib.Sound
{
class COpenALRecord {}
}
+2 -4
View File
@@ -104,7 +104,6 @@ namespace Vocaluxe.Lib.Sound
{ {
_Decoder.Add(decoder); _Decoder.Add(decoder);
stream.Handle = _Count++; stream.Handle = _Count++;
stream.File = media;
_Streams.Add(stream); _Streams.Add(stream);
return stream.Handle; return stream.Handle;
} }
@@ -376,7 +375,6 @@ namespace Vocaluxe.Lib.Sound
private Closeproc _Closeproc; private Closeproc _Closeproc;
private CPortAudio.PaStreamCallbackDelegate _PaStreamCallback; private CPortAudio.PaStreamCallbackDelegate _PaStreamCallback;
private int _StreamID; private int _StreamID;
private string _FileName;
private IAudioDecoder _Decoder; private IAudioDecoder _Decoder;
private float _BytesPerSecond; private float _BytesPerSecond;
private bool _NoMoreData; private bool _NoMoreData;
@@ -489,7 +487,7 @@ namespace Vocaluxe.Lib.Sound
{ {
if (Finished) if (Finished)
_SyncTimer.Pause(); _SyncTimer.Pause();
//TODO: Why not use Decoder.GetPosition()?
return _SyncTimer.Time; return _SyncTimer.Time;
} }
} }
@@ -607,7 +605,6 @@ namespace Vocaluxe.Lib.Sound
return -1; return -1;
} }
_FileName = fileName;
_Decoder.Open(fileName); _Decoder.Open(fileName);
_Duration = _Decoder.GetLength(); _Duration = _Decoder.GetLength();
@@ -800,6 +797,7 @@ namespace Vocaluxe.Lib.Sound
_Initialized = false; _Initialized = false;
} }
} }
_Decoder.Close();
} }
_Closeproc(_StreamID); _Closeproc(_StreamID);
@@ -1,60 +0,0 @@
#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.Lib.Sound.Decoder
{
abstract class CAudioDecoder : IAudioDecoder
{
protected bool _Initialized;
public virtual void Init() {}
public virtual void Close() {}
public void Open(string fileName)
{
Open(fileName, false);
}
public virtual void Open(string fileName, bool loop) {}
public virtual SFormatInfo GetFormatInfo()
{
return new SFormatInfo();
}
public virtual float GetLength()
{
return 0f;
}
public virtual void SetPosition(float time) {}
public virtual float GetPosition()
{
return 0f;
}
public virtual void Decode(out byte[] buffer, out float timeStamp)
{
buffer = null;
timeStamp = 0f;
}
}
}
@@ -24,7 +24,7 @@ using Vocaluxe.Lib.Video.Acinerella;
namespace Vocaluxe.Lib.Sound.Decoder namespace Vocaluxe.Lib.Sound.Decoder
{ {
class CAudioDecoderFFmpeg : CAudioDecoder, IDisposable class CAudioDecoderFFmpeg : IAudioDecoder, IDisposable
{ {
private IntPtr _InstancePtr = IntPtr.Zero; private IntPtr _InstancePtr = IntPtr.Zero;
private IntPtr _Audiodecoder = IntPtr.Zero; private IntPtr _Audiodecoder = IntPtr.Zero;
@@ -36,17 +36,12 @@ namespace Vocaluxe.Lib.Sound.Decoder
private string _FileName; private string _FileName;
private bool _FileOpened; private bool _FileOpened;
public override void Init() public void Init()
{ {
_FileOpened = false;
_Initialized = true;
} }
public override void Open(string fileName, bool loop) public void Open(string fileName, bool loop)
{ {
if (!_Initialized)
return;
_FileName = fileName; _FileName = fileName;
try try
@@ -88,11 +83,12 @@ namespace Vocaluxe.Lib.Sound.Decoder
return; return;
} }
_FormatInfo = new SFormatInfo(); _FormatInfo = new SFormatInfo
{
_FormatInfo.SamplesPerSecond = audiodecoder.StreamInfo.AudioInfo.SamplesPerSecond; SamplesPerSecond = audiodecoder.StreamInfo.AudioInfo.SamplesPerSecond,
_FormatInfo.BitDepth = audiodecoder.StreamInfo.AudioInfo.BitDepth; BitDepth = audiodecoder.StreamInfo.AudioInfo.BitDepth,
_FormatInfo.ChannelCount = audiodecoder.StreamInfo.AudioInfo.ChannelCount; ChannelCount = audiodecoder.StreamInfo.AudioInfo.ChannelCount
};
_CurrentTime = 0f; _CurrentTime = 0f;
@@ -104,13 +100,8 @@ namespace Vocaluxe.Lib.Sound.Decoder
_FileOpened = true; _FileOpened = true;
} }
public override void Close() public void Close()
{ {
if (!_Initialized)
return;
_Initialized = false;
if (!_FileOpened) if (!_FileOpened)
return; return;
@@ -126,25 +117,25 @@ namespace Vocaluxe.Lib.Sound.Decoder
_FileOpened = false; _FileOpened = false;
} }
public override SFormatInfo GetFormatInfo() public SFormatInfo GetFormatInfo()
{ {
if (!_Initialized && !_FileOpened) if (!_FileOpened)
return new SFormatInfo(); return new SFormatInfo();
return _FormatInfo; return _FormatInfo;
} }
public override float GetLength() public float GetLength()
{ {
if (!_Initialized && !_FileOpened) if (!_FileOpened)
return 0f; return 0f;
return _Instance.Info.Duration / 1000f; return _Instance.Info.Duration / 1000f;
} }
public override void SetPosition(float time) public void SetPosition(float time)
{ {
if (!_Initialized && !_FileOpened) if (!_FileOpened)
return; return;
try try
@@ -158,17 +149,14 @@ namespace Vocaluxe.Lib.Sound.Decoder
} }
} }
public override float GetPosition() public float GetPosition()
{ {
if (!_Initialized && !_FileOpened) return !_FileOpened ? 0f : _CurrentTime;
return 0f;
return _CurrentTime;
} }
public override void Decode(out byte[] buffer, out float timeStamp) public void Decode(out byte[] buffer, out float timeStamp)
{ {
if (!_Initialized && !_FileOpened) if (!_FileOpened)
{ {
buffer = null; buffer = null;
timeStamp = 0f; timeStamp = 0f;
+1 -2
View File
@@ -31,8 +31,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
void Init(); void Init();
void Close(); void Close();
void Open(string fileName); void Open(string fileName, bool loop=false);
void Open(string fileName, bool loop);
SFormatInfo GetFormatInfo(); SFormatInfo GetFormatInfo();
float GetLength(); float GetLength();
-2
View File
@@ -24,12 +24,10 @@ namespace Vocaluxe.Lib.Sound
struct SAudioStreams struct SAudioStreams
{ {
public int Handle; public int Handle;
public string File;
public SAudioStreams(int stream) public SAudioStreams(int stream)
{ {
Handle = stream; Handle = stream;
File = String.Empty;
} }
} }
@@ -1,98 +0,0 @@
#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.Sound.PortAudio
{
/// <summary> PortAudio v.19 bindings for .NET - ASIO bindings </summary>
public static partial class CPortAudio
{
#region **** PORTAUDIO DATA STRUCTURES ****
[StructLayout(LayoutKind.Sequential)]
public struct SPaAsioStreamInfo
{
public ulong Size; /**< sizeof(PaAsioStreamInfo) */
public int HostApiType; /**< paASIO */
public ulong Version; /**< 1 */
public ulong Flags;
/// Support for opening only specific channels of an ASIO device.
/// If the paAsioUseChannelSelectors flag is set, channelSelectors is a
/// pointer to an array of integers specifying the device channels to use.
/// When used, the length of the channelSelectors array must match the
/// corresponding channelCount parameter to Pa_OpenStream() otherwise a
/// crash may result.
/// The values in the selectors array must specify channels within the
/// range of supported channels for the device or paInvalidChannelCount will
/// result.
private readonly IntPtr _ChannelSelectors;
}
#endregion
#region **** PORTAUDIO DEFINES ****
public const int PaAsioUseChannelSelectors = 0x01;
#endregion
#region **** PORTAUDIO FUNCTIONS ****
// /// <summary> Retrieve legal latency settings for the specificed device, in samples. </summary>
// /// <param name="device"> The global index of the device about which the query is being made. </param>
// /// <param name="minLatency"> A pointer to the location which will recieve the minimum latency value. </param>
// /// <param name="maxLatency"> A pointer to the location which will recieve the maximum latency value. </param>
// /// <param name="preferredLatency"> A pointer to the location which will recieve the preferred latency value. </param>
// /// <param name="granularity"> A pointer to the location which will recieve the granularity. This value
// /// determines which values between minLatency and maxLatency are available. ie the step size,
// /// if granularity is -1 then available latency settings are powers of two. </param>
// /// See ASIOGetBufferSize in the ASIO SDK.
// PaError PaAsio_GetAvailableLatencyValues( PaDeviceIndex device, long *minLatency, long *maxLatency,
// long *preferredLatency, long *granularity );
/// <summary> Display the ASIO control panel for the specified device. </summary>
/// <param name="device"> The global index of the device whose control panel is to be displayed. </param>
/// <param name="systemSpecific">
/// On Windows, the calling application's main window handle,
/// on Macintosh this value should be zero.
/// </param>
[DllImport("PortAudio.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern EPaError PaAsio_ShowControlPanel(int device, IntPtr systemSpecific);
// /// <summary> Retrieve a pointer to a string containing the name of the specified input channel. </summary>
// /// The string is valid until Pa_Terminate is called.
// /// The string will be no longer than 32 characters including the null terminator.
// PaError PaAsio_GetInputChannelName(PaDeviceIndex device, int channelIndex, const char** channelName );
// /// <summary> Retrieve a pointer to a string containing the name of the specified input channel. </summary>
// /// The string is valid until Pa_Terminate is called.
// /// The string will be no longer than 32 characters including the null terminator.
// PaError PaAsio_GetOutputChannelName( PaDeviceIndex device, int channelIndex, const char** channelName );
/// <summary> Set the sample rate of an open paASIO stream. </summary>
/// <param name="stream"></param>
/// The stream to operate on.
/// <param name="sampleRate"></param>
/// The new sample rate.
/// Note that this function may fail if the stream is alredy running and the
/// ASIO driver does not support switching the sample rate of a running stream.
/// <returns> paIncompatibleStreamHostApi if stream is not a paASIO stream. </returns>
[DllImport("PortAudio.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern EPaError PaAsio_SetStreamSampleRate(IntPtr stream, double sampleRate);
#endregion
}
}
+29 -19
View File
@@ -22,6 +22,7 @@ using System.Runtime.InteropServices;
namespace Vocaluxe.Lib.Video.Acinerella namespace Vocaluxe.Lib.Video.Acinerella
{ {
// ReSharper disable UnusedMember.Global
public enum EACStreamType : sbyte public enum EACStreamType : sbyte
{ {
/*The type of the media stream is not known. This kind of stream can not be /*The type of the media stream is not known. This kind of stream can not be
@@ -51,12 +52,14 @@ namespace Vocaluxe.Lib.Video.Acinerella
ACOutputBGra32 = 3 ACOutputBGra32 = 3
} }
// ReSharper disable MemberCanBePrivate.Global
// Contains information about the whole file/stream that has been opened. Default // Contains information about the whole file/stream that has been opened. Default
// values are "" for strings and -1 for integer values. // values are "" for strings and -1 for integer values.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct SACFileInfo public struct SACFileInfo
{ {
public Int64 Duration; public readonly Int64 Duration;
} }
// TAc_instance represents an Acinerella instance. Each instance can open and // TAc_instance represents an Acinerella instance. Each instance can open and
@@ -66,12 +69,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACInstance public struct SACInstance
{ {
//If true, the instance currently opened a media file //If true, the instance currently opened a media file
public bool Opened; public readonly bool Opened;
//Contains the count of streams the media file has. This value is available //Contains the count of streams the media file has. This value is available
//after calling the ac_open function. //after calling the ac_open function.
public Int32 StreamCount; public readonly Int32 StreamCount;
//Set this value to change the image output format //Set this value to change the image output format
public EACOutputFormat OutputFormat; public readonly EACOutputFormat OutputFormat;
//Contains information about the opened stream/file //Contains information about the opened stream/file
public SACFileInfo Info; public SACFileInfo Info;
} }
@@ -81,11 +84,11 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACAudioStreamInfo public struct SACAudioStreamInfo
{ {
//Samples per second. Default values are 44100 or 48000. //Samples per second. Default values are 44100 or 48000.
public Int32 SamplesPerSecond; public readonly Int32 SamplesPerSecond;
//Bits per sample. Can be 8 or 16 Bit. //Bits per sample. Can be 8 or 16 Bit.
public Int32 BitDepth; public readonly Int32 BitDepth;
//Count of channels in the audio stream. //Count of channels in the audio stream.
public Int32 ChannelCount; public readonly Int32 ChannelCount;
} }
// Contains information about an Acinerella video stream. // Contains information about an Acinerella video stream.
@@ -93,13 +96,13 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACVideoStreamInfo public struct SACVideoStreamInfo
{ {
//The width of one frame. //The width of one frame.
public Int32 FrameWidth; public readonly Int32 FrameWidth;
//The height of one frame. //The height of one frame.
public Int32 FrameHeight; public readonly Int32 FrameHeight;
//The width of one pixel. 1.07 for 4:3 format, 1,42 for the 16:9 format //The width of one pixel. 1.07 for 4:3 format, 1,42 for the 16:9 format
public float PixelAspect; public readonly float PixelAspect;
//Frames per second that should be played. //Frames per second that should be played.
public double FramesPerSecond; public readonly double FramesPerSecond;
} }
// Contains information about an Acinerella stream. // Contains information about an Acinerella stream.
@@ -107,7 +110,8 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACStreamInfo public struct SACStreamInfo
{ {
//Contains the type of the stream. //Contains the type of the stream.
public EACStreamType StreamType; public readonly EACStreamType StreamType;
//Additional info about the stream //Additional info about the stream
public SACAudioStreamInfo AudioInfo; public SACAudioStreamInfo AudioInfo;
public SACVideoStreamInfo VideoInfo; public SACVideoStreamInfo VideoInfo;
@@ -120,32 +124,33 @@ namespace Vocaluxe.Lib.Video.Acinerella
//Pointer on the Acinerella instance //Pointer on the Acinerella instance
private readonly IntPtr _ACInstancePtr; private readonly IntPtr _ACInstancePtr;
//Contains the type of the decoder. //Contains the type of the decoder.
public EACDecoderType DecType; public readonly EACDecoderType DecType;
//The timecode of the currently decoded picture in seconds. //The timecode of the currently decoded picture in seconds.
public double Timecode; public readonly double Timecode;
public double VideoClock; public readonly double VideoClock;
//Contains information about the stream the decoder is attached to. //Contains information about the stream the decoder is attached to.
public SACStreamInfo StreamInfo; public SACStreamInfo StreamInfo;
//The index of the stream the decoder is attached to. //The index of the stream the decoder is attached to.
public Int32 StreamIndex; public readonly Int32 StreamIndex;
//Pointer to the buffer which contains the data. //Pointer to the buffer which contains the data.
internal IntPtr Buffer; internal IntPtr Buffer;
//Size of the data in the buffer. //Size of the data in the buffer.
public Int32 BufferSize; public readonly Int32 BufferSize;
} }
// Contains information about an Acinerella package. // Contains information about an Acinerella package.
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct SACPackage public struct SACPackage
{ {
//The stream the package belongs to. //The stream the package belongs to.
public Int32 StreamIndex; public readonly Int32 StreamIndex;
} }
// ReSharper restore MemberCanBePrivate.Global
// Callback function used to ask the application to read data. Should return // Callback function used to ask the application to read data. Should return
// the number of bytes read or an value smaller than zero if an error occured. // the number of bytes read or an value smaller than zero if an error occured.
//TAc_read_callback = function(sender: Pointer; byte[] buf, int size): integer; cdecl; //TAc_read_callback = function(sender: Pointer; byte[] buf, int size): integer; cdecl;
@@ -273,7 +278,9 @@ namespace Vocaluxe.Lib.Video.Acinerella
string filename string filename
); );
// ReSharper disable UnusedMethodReturnValue.Global
public static Int32 AcOpen2( public static Int32 AcOpen2(
// ReSharper restore UnusedMethodReturnValue.Global
IntPtr pAcInstance, IntPtr pAcInstance,
string filename string filename
) )
@@ -423,7 +430,9 @@ namespace Vocaluxe.Lib.Video.Acinerella
[DllImport(_AcDll, EntryPoint = "ac_seek", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] [DllImport(_AcDll, EntryPoint = "ac_seek", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern Int32 _ac_seek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos); private static extern Int32 _ac_seek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos);
// ReSharper disable UnusedMethodReturnValue.Global
public static Int32 AcSeek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos) public static Int32 AcSeek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos)
// ReSharper restore UnusedMethodReturnValue.Global
{ {
lock (_Lock) lock (_Lock)
{ {
@@ -441,4 +450,5 @@ namespace Vocaluxe.Lib.Video.Acinerella
out Int32 scoreMax out Int32 scoreMax
); );
} }
// ReSharper restore UnusedMember.Global
} }
+10 -24
View File
@@ -67,7 +67,6 @@ namespace Vocaluxe.Lib.Video
{ {
_Decoder.Add(decoder); _Decoder.Add(decoder);
stream.Handle = _Count++; stream.Handle = _Count++;
stream.File = videoFileName;
_Streams.Add(stream); _Streams.Add(stream);
return stream.Handle; return stream.Handle;
} }
@@ -232,7 +231,6 @@ namespace Vocaluxe.Lib.Video
private bool _Paused; private bool _Paused;
private bool _NoMoreFrames; private bool _NoMoreFrames;
private bool _Finished;
private bool _BeforeLoop; private bool _BeforeLoop;
private int _Width; private int _Width;
@@ -240,7 +238,6 @@ namespace Vocaluxe.Lib.Video
private float _SetTime; private float _SetTime;
private float _SetGap; private float _SetGap;
private float _SetStart; private float _SetStart;
private bool _SetLoop;
private bool _SetSkip; private bool _SetSkip;
private bool _Terminated; private bool _Terminated;
@@ -267,16 +264,12 @@ namespace Vocaluxe.Lib.Video
{ {
get get
{ {
if (_FileOpened) return _FileOpened ? _Duration : 0f;
return _Duration;
return 0f;
} }
} }
public bool Paused public bool Paused
{ {
get { return _Paused; }
set set
{ {
lock (_MutexSyncSignals) lock (_MutexSyncSignals)
@@ -290,16 +283,9 @@ namespace Vocaluxe.Lib.Video
} }
} }
public bool Loop public bool Loop { private get; set; }
{
get { return _SetLoop; }
set { _SetLoop = value; }
}
public bool Finished public bool Finished { get; private set; }
{
get { return _Finished; }
}
public bool Open(string fileName) public bool Open(string fileName)
{ {
@@ -325,7 +311,7 @@ namespace Vocaluxe.Lib.Video
if (_Paused) if (_Paused)
return false; return false;
if (_SetLoop) if (Loop)
{ {
lock (_MutexSyncSignals) lock (_MutexSyncSignals)
{ {
@@ -343,7 +329,7 @@ namespace Vocaluxe.Lib.Video
return true; return true;
} }
if (_SetTime != time) if (Math.Abs(_SetTime - time) > float.Epsilon)
{ {
lock (_MutexSyncSignals) lock (_MutexSyncSignals)
{ {
@@ -365,7 +351,7 @@ namespace Vocaluxe.Lib.Video
_SetGap = gap; _SetGap = gap;
_SetSkip = true; _SetSkip = true;
_NoMoreFrames = false; _NoMoreFrames = false;
_Finished = false; Finished = false;
} }
//EventDecode.Set(); //EventDecode.Set();
return true; return true;
@@ -443,7 +429,7 @@ namespace Vocaluxe.Lib.Video
_SetSkip = false; _SetSkip = false;
_Gap = _SetGap; _Gap = _SetGap;
_Start = _SetStart; _Start = _SetStart;
_Loop = _SetLoop; _Loop = Loop;
} }
if (_Skip) if (_Skip)
@@ -678,7 +664,7 @@ namespace Vocaluxe.Lib.Video
if (num >= 0) if (num >= 0)
{ {
if (frame.Index == -1 || _Width != frame.Width || _Height != frame.Height) if (frame.Index == -1 || Math.Abs(_Width - frame.Width) > float.Epsilon || Math.Abs(_Height - frame.Height) > float.Epsilon)
{ {
CDraw.RemoveTexture(ref frame); CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].Data); frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].Data);
@@ -690,12 +676,12 @@ namespace Vocaluxe.Lib.Video
{ {
_CurrentVideoTime = _FrameBuffer[num].Time; _CurrentVideoTime = _FrameBuffer[num].Time;
} }
_Finished = false; Finished = false;
} }
else else
{ {
if (_NoMoreFrames) if (_NoMoreFrames)
_Finished = true; Finished = true;
} }
} }
} }
@@ -24,11 +24,13 @@ namespace Vocaluxe.Lib.Video.Gstreamer
{ {
public struct SNativeFrame public struct SNativeFrame
{ {
// ReSharper disable UnassignedField.Global
internal IntPtr Buffer; internal IntPtr Buffer;
public int Size; public int Size;
public int Width; public int Width;
public int Height; public int Height;
public float Videotime; public float Videotime;
// ReSharper restore UnassignedField.Global
} }
public struct SManagedFrame public struct SManagedFrame
-2
View File
@@ -25,12 +25,10 @@ namespace Vocaluxe.Lib.Video
struct SVideoStreams struct SVideoStreams
{ {
public int Handle; public int Handle;
public string File;
public SVideoStreams(int stream) public SVideoStreams(int stream)
{ {
Handle = stream; Handle = stream;
File = String.Empty;
} }
} }
+8 -12
View File
@@ -17,6 +17,7 @@
// */ // */
#endregion #endregion
using System;
using AForge.Video; using AForge.Video;
using AForge.Video.DirectShow; using AForge.Video.DirectShow;
using System.Collections.Generic; using System.Collections.Generic;
@@ -56,7 +57,7 @@ namespace Vocaluxe.Lib.Webcam
{ {
lock (_MutexData) lock (_MutexData)
{ {
if (frame.Index == -1 || _Width != frame.Width || _Height != frame.Height) if (frame.Index == -1 || Math.Abs(_Width - frame.Width) > float.Epsilon || Math.Abs(_Height - frame.Height) > float.Epsilon)
{ {
CDraw.RemoveTexture(ref frame); CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(_Width, _Height, ref _Data); frame = CDraw.AddTexture(_Width, _Height, ref _Data);
@@ -81,8 +82,7 @@ namespace Vocaluxe.Lib.Webcam
return bmp; return bmp;
} }
} }
else return null;
return null;
} }
public bool Init() public bool Init()
@@ -101,13 +101,12 @@ namespace Vocaluxe.Lib.Webcam
num++; num++;
VideoCaptureDevice tmpdev = new VideoCaptureDevice(info.MonikerString); VideoCaptureDevice tmpdev = new VideoCaptureDevice(info.MonikerString);
for (int i = 0; i < tmpdev.VideoCapabilities.Length; i++) foreach (VideoCapabilities capabilities in tmpdev.VideoCapabilities) {
{
SCapabilities item = new SCapabilities SCapabilities item = new SCapabilities
{ {
Framerate = tmpdev.VideoCapabilities[i].FrameRate, Framerate = capabilities.FrameRate,
Height = tmpdev.VideoCapabilities[i].FrameSize.Height, Height = capabilities.FrameSize.Height,
Width = tmpdev.VideoCapabilities[i].FrameSize.Width Width = capabilities.FrameSize.Width
}; };
device.Capabilities.Add(item); device.Capabilities.Add(item);
} }
@@ -174,10 +173,7 @@ namespace Vocaluxe.Lib.Webcam
return false; return false;
//No MonikerString found, try first webcam //No MonikerString found, try first webcam
if (config.MonikerString.Length == 0) _Webcam = config.MonikerString == "" ? new VideoCaptureDevice(_WebcamDevices[0].MonikerString) : new VideoCaptureDevice(config.MonikerString);
_Webcam = new VideoCaptureDevice(_WebcamDevices[0].MonikerString);
else //Found MonikerString
_Webcam = new VideoCaptureDevice(config.MonikerString);
if (_Webcam == null) if (_Webcam == null)
return false; return false;
+1
View File
@@ -185,6 +185,7 @@ namespace Vocaluxe
// Init Input // Init Input
CLog.StartBenchmark(0, "Init Input"); CLog.StartBenchmark(0, "Init Input");
CInput.Init(); CInput.Init();
CInput.Connect();
CLog.StopBenchmark(0, "Init Input"); CLog.StopBenchmark(0, "Init Input");
// Init Game; // Init Game;
-3
View File
@@ -220,11 +220,9 @@
<Compile Include="Lib\Sound\CDirectSoundRecord.cs" /> <Compile Include="Lib\Sound\CDirectSoundRecord.cs" />
<Compile Include="Lib\Sound\CGstreamerAudio.cs" /> <Compile Include="Lib\Sound\CGstreamerAudio.cs" />
<Compile Include="Lib\Sound\COpenALPlay.cs" /> <Compile Include="Lib\Sound\COpenALPlay.cs" />
<Compile Include="Lib\Sound\COpenALRecord.cs" />
<Compile Include="Base\CSound.cs" /> <Compile Include="Base\CSound.cs" />
<Compile Include="Lib\Sound\CPortAudioPlay.cs" /> <Compile Include="Lib\Sound\CPortAudioPlay.cs" />
<Compile Include="Lib\Sound\CPortAudioRecord.cs" /> <Compile Include="Lib\Sound\CPortAudioRecord.cs" />
<Compile Include="Lib\Sound\Decoder\CAudioDecoder.cs" />
<Compile Include="Lib\Sound\Decoder\CAudioDecoderFFmpeg.cs" /> <Compile Include="Lib\Sound\Decoder\CAudioDecoderFFmpeg.cs" />
<Compile Include="Lib\Sound\Decoder\IAudioDecoder.cs" /> <Compile Include="Lib\Sound\Decoder\IAudioDecoder.cs" />
<Compile Include="Lib\Sound\Gstreamer\CGstreamerAudioWrapper.cs" /> <Compile Include="Lib\Sound\Gstreamer\CGstreamerAudioWrapper.cs" />
@@ -265,7 +263,6 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</None> </None>
<Compile Include="Lib\Sound\PortAudio\PortAudio.cs" /> <Compile Include="Lib\Sound\PortAudio\PortAudio.cs" />
<Compile Include="Lib\Sound\PortAudio\PortAudioASIO.cs" />
<None Include="Doc\SQLite.NET.chm" /> <None Include="Doc\SQLite.NET.chm" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+1 -3
View File
@@ -24,7 +24,6 @@ namespace VocaluxeLib.Menu
public static IConfig Config; public static IConfig Config;
public static ISettings Settings; public static ISettings Settings;
public static ITheme Theme; public static ITheme Theme;
public static IHelper Helper;
public static ILog Log; public static ILog Log;
public static IBackgroundMusic BackgroundMusic; public static IBackgroundMusic BackgroundMusic;
public static IDrawing Drawing; public static IDrawing Drawing;
@@ -42,14 +41,13 @@ namespace VocaluxeLib.Menu
public static IInputs Input; public static IInputs Input;
public static IPlaylist Playlist; public static IPlaylist Playlist;
public static void Assign(IConfig config, ISettings settings, ITheme theme, IHelper helper, ILog log, IBackgroundMusic backgroundMusic, public static void Assign(IConfig config, ISettings settings, ITheme theme, ILog log, IBackgroundMusic backgroundMusic,
IDrawing draw, IGraphics graphics, IFonts fonts, ILanguage language, IGame game, IProfiles profiles, IRecording record, IDrawing draw, IGraphics graphics, IFonts fonts, ILanguage language, IGame game, IProfiles profiles, IRecording record,
ISongs songs, IVideo video, ISound sound, ICover cover, IDataBase dataBase, IInputs input, IPlaylist playlist) ISongs songs, IVideo video, ISound sound, ICover cover, IDataBase dataBase, IInputs input, IPlaylist playlist)
{ {
Config = config; Config = config;
Settings = settings; Settings = settings;
Theme = theme; Theme = theme;
Helper = helper;
Log = log; Log = log;
BackgroundMusic = backgroundMusic; BackgroundMusic = backgroundMusic;
Drawing = draw; Drawing = draw;
+1 -1
View File
@@ -241,7 +241,7 @@ namespace VocaluxeLib.Menu
public void Draw() public void Draw()
{ {
if (_Bars == null) if (_Bars == null || _Theme.Style!=EEqualizerStyle.Collums)
return; return;
float dx = Rect.W / _Bars.Length; float dx = Rect.W / _Bars.Length;
+1 -1
View File
@@ -144,7 +144,7 @@ namespace VocaluxeLib.Menu
#region ThemeHandler #region ThemeHandler
private delegate void AddElementHandler<in T>(T element, String key); private delegate void AddElementHandler<in T>(T element, String key);
private void _LoadThemeElement<T>(string[] elements, AddElementHandler<T> addElementHandler, CXMLReader xmlReader, int skinIndex) where T : IMenuElement private void _LoadThemeElement<T>(IEnumerable<string> elements, AddElementHandler<T> addElementHandler, CXMLReader xmlReader, int skinIndex) where T : IMenuElement
{ {
if (elements != null) if (elements != null)
{ {
@@ -36,13 +36,6 @@ namespace VocaluxeLib.Menu
_Parent = parent; _Parent = parent;
} }
public COrderedDictionaryLite(COrderedDictionaryLite<T> dict)
{
_Items = new List<T>(dict._Items);
_HtIndex = new Dictionary<String, int>(dict._HtIndex);
_Parent = dict._Parent;
}
public T this[int index] public T this[int index]
{ {
get { return _Items[index]; } get { return _Items[index]; }
+3 -7
View File
@@ -37,7 +37,10 @@ namespace VocaluxeLib.Menu
public ESettingType Type; public ESettingType Type;
} }
// ReSharper disable ClassNeverInstantiated.Global
//Instantiated by reflection
public class CScreenSetting : IMenuElement public class CScreenSetting : IMenuElement
// ReSharper restore ClassNeverInstantiated.Global
{ {
private readonly int _PartyModeID; private readonly int _PartyModeID;
@@ -56,13 +59,6 @@ namespace VocaluxeLib.Menu
_ThemeLoaded = false; _ThemeLoaded = false;
} }
public CScreenSetting(CScreenSetting ts)
{
_PartyModeID = ts._PartyModeID;
_Theme = ts._Theme;
_ThemeLoaded = ts._ThemeLoaded;
}
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex) public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
{ {
string item = xmlPath + "/" + elementName; string item = xmlPath + "/" + elementName;
-2
View File
@@ -138,8 +138,6 @@ namespace VocaluxeLib.Menu
void LoadTheme(); void LoadTheme();
} }
public interface IHelper {}
public interface IBackgroundMusic public interface IBackgroundMusic
{ {
bool IsDisabled(); bool IsDisabled();
+1 -1
View File
@@ -57,7 +57,7 @@ namespace VocaluxeLib.Menu.SingNotes
public string SkinPerfectNoteStarName; public string SkinPerfectNoteStarName;
} }
public abstract class CSingNotes : ISingNotes, IMenuElement public abstract class CSingNotes : IMenuElement
{ {
protected int _PartyModeID; protected int _PartyModeID;
private SThemeSingBar _Theme; private SThemeSingBar _Theme;
-41
View File
@@ -1,41 +0,0 @@
#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;
namespace VocaluxeLib.Menu.SingNotes
{
public interface ISingNotes
{
void Reset();
int AddPlayer(SRectF rect, SColorF color, int playerNr);
void RemovePlayer(int iD);
void AddLine(int iD, CLine[] line, int lineNr, int player);
void RemoveLine(int iD);
void AddNote(int iD, CNote note);
void SetAlpha(int iD, float alpha);
float GetAlpha(int iD);
void Draw(int iD, int player);
void Draw(int iD, List<CLine> singLine, int player);
}
}
@@ -46,12 +46,6 @@ namespace VocaluxeLib.Menu.SongMenu
public SThemeSongMenuTileBoard SongMenuTileBoard; public SThemeSongMenuTileBoard SongMenuTileBoard;
} }
struct SThemeSongMenuBook {}
struct SThemeSongMenuDreidel {}
struct SThemeSongMenuList {}
struct SThemeSongMenuTileBoard struct SThemeSongMenuTileBoard
{ {
/// <summary> /// <summary>
-1
View File
@@ -137,7 +137,6 @@
<Compile Include="Menu\SingNotes\CNotes.cs" /> <Compile Include="Menu\SingNotes\CNotes.cs" />
<Compile Include="Menu\SingNotes\CSingNotes.cs" /> <Compile Include="Menu\SingNotes\CSingNotes.cs" />
<Compile Include="Menu\SingNotes\CSingNotesClassic.cs" /> <Compile Include="Menu\SingNotes\CSingNotesClassic.cs" />
<Compile Include="Menu\SingNotes\ISingNotes.cs" />
<Compile Include="Menu\SongMenu\CSong.cs" /> <Compile Include="Menu\SongMenu\CSong.cs" />
<Compile Include="Menu\SongMenu\CSongMenu.cs" /> <Compile Include="Menu\SongMenu\CSongMenu.cs" />
<Compile Include="Menu\SongMenu\CSongMenuBook.cs" /> <Compile Include="Menu\SongMenu\CSongMenuBook.cs" />