From 1540be9120793c59ba376dc3fd12af1c3839ce98 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Tue, 23 Apr 2013 14:22:42 +0200 Subject: [PATCH] More refactoring and small fixes --- .../PartyModeChallenge/CChallengeRounds.cs | 54 +++------- .../PartyModeChallenge/CPartyModeChallenge.cs | 37 +++---- .../CPartyScreenChallengeConfig.cs | 2 + .../CPartyScreenChallengeMain.cs | 10 +- .../CPartyScreenChallengeNames.cs | 8 +- .../CPartyModeChallengeMedley.cs | 5 +- .../CPartyScreenChallengeMedleyConfig.cs | 2 + .../CPartyScreenChallengeMedleyMain.cs | 8 +- .../CPartyScreenChallengeMedleyNames.cs | 2 + .../CPartyScreenTicTacToeConfig.cs | 48 +++------ .../CPartyScreenTicTacToeMain.cs | 11 +-- .../CPartyScreenTicTacToeNames.cs | 2 + ...gs.DotSettings => Vocaluxe.sln.DotSettings | 0 Vocaluxe/Base/CInput.cs | 8 +- Vocaluxe/Base/CLog.cs | 28 +++--- Vocaluxe/Base/CMain.cs | 5 +- Vocaluxe/Base/CSettings.cs | 2 + Vocaluxe/Base/CSongSorter.cs | 5 + Vocaluxe/CSplashScreen.cs | 12 +++ Vocaluxe/Lib/Input/IInput.cs | 6 +- Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs | 31 ++---- Vocaluxe/Lib/Sound/COpenALPlay.cs | 14 +-- Vocaluxe/Lib/Sound/COpenALRecord.cs | 23 ----- Vocaluxe/Lib/Sound/CPortAudioPlay.cs | 6 +- Vocaluxe/Lib/Sound/Decoder/CAudioDecoder.cs | 60 ------------ .../Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs | 52 ++++------ Vocaluxe/Lib/Sound/Decoder/IAudioDecoder.cs | 3 +- Vocaluxe/Lib/Sound/IPlayback.cs | 2 - Vocaluxe/Lib/Sound/Portaudio/PortAudioASIO.cs | 98 ------------------- Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs | 48 +++++---- Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs | 34 ++----- .../Video/Gstreamer/CGstreamerVideoWrapper.cs | 2 + Vocaluxe/Lib/Video/IVideoDecoder.cs | 2 - Vocaluxe/Lib/Webcam/CAForgeNet.cs | 20 ++-- Vocaluxe/Program.cs | 1 + Vocaluxe/Vocaluxe.csproj | 3 - VocaluxeLib/Menu/CBasic.cs | 4 +- VocaluxeLib/Menu/CEqualizer.cs | 2 +- VocaluxeLib/Menu/CMenu.cs | 2 +- VocaluxeLib/Menu/COrderedDictionaryLite.cs | 7 -- VocaluxeLib/Menu/CScreenSetting.cs | 10 +- VocaluxeLib/Menu/IMenu.cs | 2 - VocaluxeLib/Menu/SingNotes/CSingNotes.cs | 2 +- VocaluxeLib/Menu/SingNotes/ISingNotes.cs | 41 -------- .../Menu/SongMenu/CSongMenuFramework.cs | 6 -- VocaluxeLib/VocaluxeLib.csproj | 1 - 46 files changed, 205 insertions(+), 526 deletions(-) rename Re#Settings.DotSettings => Vocaluxe.sln.DotSettings (100%) delete mode 100644 Vocaluxe/Lib/Sound/COpenALRecord.cs delete mode 100644 Vocaluxe/Lib/Sound/Decoder/CAudioDecoder.cs delete mode 100644 Vocaluxe/Lib/Sound/Portaudio/PortAudioASIO.cs delete mode 100644 VocaluxeLib/Menu/SingNotes/ISingNotes.cs diff --git a/PartyModes/PartyModeChallenge/CChallengeRounds.cs b/PartyModes/PartyModeChallenge/CChallengeRounds.cs index bc99aa57..1ad4fe25 100644 --- a/PartyModes/PartyModeChallenge/CChallengeRounds.cs +++ b/PartyModes/PartyModeChallenge/CChallengeRounds.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Linq; namespace VocaluxeLib.PartyModes.Challenge { @@ -27,7 +28,7 @@ namespace VocaluxeLib.PartyModes.Challenge private readonly Random _Rand; private readonly int _NumPlayer; - public List Rounds; + public readonly List Rounds; public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce) { @@ -60,7 +61,7 @@ namespace VocaluxeLib.PartyModes.Challenge Rounds.Add(combinations.GetNextCombination(_GetPlayerDemand(i))); } - private List _GetPlayerDemand(int roundIndex) + private IEnumerable _GetPlayerDemand(int roundIndex) { List numPlayed = new List(_NumPlayer); for (int i = 0; i < _NumPlayer; i++) @@ -72,12 +73,7 @@ namespace VocaluxeLib.PartyModes.Challenge numPlayed[playerIndex]++; } - int max = 0; - foreach (int p in numPlayed) - { - if (p > max) - max = p; - } + int max = numPlayed.Max(); int num = Rounds[0].Player.Count; List result = new List(); @@ -150,13 +146,11 @@ namespace VocaluxeLib.PartyModes.Challenge _Rand = rand; } - public CCombination GetNextCombination(List playerNrDemand) + public CCombination GetNextCombination(IEnumerable playerNrDemand) { if (_Combs.Count == 0) _Create(); - CCombination combs = new CCombination(); - if (_NumPlayer == _NumMics) return _Combs[0]; @@ -164,28 +158,19 @@ namespace VocaluxeLib.PartyModes.Challenge List combsFiltered = new List(); if (playerNrDemand != null) { - for (int i = 0; i < _Combs.Count; i++) - { - if (_Combs[i].IsAvailableAll(playerNrDemand)) - combsFiltered.Add(_Combs[i]); - } + combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableAll(playerNrDemand))); } //1st fallback if (playerNrDemand != null && combsFiltered.Count == 0) { - for (int i = 0; i < _Combs.Count; i++) - { - if (_Combs[i].IsAvailableSomeone(playerNrDemand)) - combsFiltered.Add(_Combs[i]); - } + combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableSomeone(playerNrDemand))); } //2nd fallback if (combsFiltered.Count == 0) { - for (int i = 0; i < _Combs.Count; i++) - combsFiltered.Add(_Combs[i]); + combsFiltered.AddRange(_Combs); } int num = combsFiltered.Count; @@ -222,7 +207,7 @@ namespace VocaluxeLib.PartyModes.Challenge public class CCombination { - public List Player; + public readonly List Player; public CCombination() { @@ -231,28 +216,17 @@ namespace VocaluxeLib.PartyModes.Challenge public bool IsAvailable(int playerIndex) { - foreach (int p in Player) - { - if (p == playerIndex) - return true; - } - return false; + return Player.Any(p => p == playerIndex); } - public bool IsAvailableAll(List playerIndices) + public bool IsAvailableAll(IEnumerable playerIndices) { - bool result = true; - foreach (int p in playerIndices) - result &= IsAvailable(p); - return result; + return playerIndices.All(IsAvailable); } - public bool IsAvailableSomeone(List playerIndices) + public bool IsAvailableSomeone(IEnumerable playerIndices) { - bool result = false; - foreach (int p in playerIndices) - result |= IsAvailable(p); - return result; + return playerIndices.Any(IsAvailable); } } } \ No newline at end of file diff --git a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs index 722713e6..b3e860af 100644 --- a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs +++ b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs @@ -58,17 +58,15 @@ namespace VocaluxeLib.PartyModes.Challenge public int Position; public int PlayerID; public int NumPlayed; - public int NumRounds; public int NumWon; public int NumSingPoints; public int NumGamePoints; 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); if (res == 0) { @@ -101,8 +99,7 @@ namespace VocaluxeLib.PartyModes.Challenge public struct SFromScreenNames { - public bool FadeToConfig; - public bool FadeToMain; + public bool FadeBack; public List ProfileIDs; } @@ -236,7 +233,7 @@ namespace VocaluxeLib.PartyModes.Challenge try { dataFrom = (SDataFromScreen)data; - if (dataFrom.ScreenNames.FadeToConfig) + if (dataFrom.ScreenNames.FadeBack) _Stage = EStage.NotStarted; else { @@ -590,13 +587,7 @@ namespace VocaluxeLib.PartyModes.Challenge { for (int i = 0; i < _GameData.NumPlayer; i++) { - CResultTableRow row = new CResultTableRow(); - row.PlayerID = _GameData.ProfileIDs[i]; - row.NumPlayed = 0; - row.NumRounds = 0; - row.NumWon = 0; - row.NumSingPoints = 0; - row.NumGamePoints = 0; + CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0}; _GameData.ResultTable.Add(row); } @@ -633,18 +624,16 @@ namespace VocaluxeLib.PartyModes.Challenge } } - if (index != -1) - { - CResultTableRow row = _GameData.ResultTable[index]; + if (index == -1) + continue; + CResultTableRow row = _GameData.ResultTable[index]; - row.NumPlayed++; - row.NumWon += points[i].Won; - row.NumRounds += 1; - row.NumSingPoints += points[i].SingPoints; - row.NumGamePoints += points[i].GamePoints; + row.NumPlayed++; + row.NumWon += points[i].Won; + row.NumSingPoints += points[i].SingPoints; + row.NumGamePoints += points[i].GamePoints; - _GameData.ResultTable[index] = row; - } + _GameData.ResultTable[index] = row; } } diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs index 27e36fa9..df3678be 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs @@ -23,7 +23,9 @@ using VocaluxeLib.Menu; namespace VocaluxeLib.PartyModes.Challenge { +// ReSharper disable UnusedMember.Global public class CPartyScreenChallengeConfig : CMenuParty +// ReSharper restore UnusedMember.Global { // Version number for theme files. Increment it, if you've changed something on the theme files! protected override int _ScreenVersion diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs index aacf1a83..43e6443c 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs @@ -41,7 +41,9 @@ namespace VocaluxeLib.PartyModes.Challenge public List TextScores; } +// ReSharper disable UnusedMember.Global public class CPartyScreenChallengeMain : CMenuParty +// ReSharper restore UnusedMember.Global { // Version number for theme files. Increment it, if you've changed something on the theme files! protected override int _ScreenVersion @@ -350,9 +352,9 @@ namespace VocaluxeLib.PartyModes.Challenge private void _UpdateNextPlayerPositions() { - float x = CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2; - float staticY = 590; - float textY = 550; + float x = (float) CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2; + const float staticY = 590; + const float textY = 550; for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) { //static @@ -606,7 +608,7 @@ namespace VocaluxeLib.PartyModes.Challenge row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + "."; 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.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString(); row.GamePoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumGamePoints.ToString(); diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs index 9da4b884..eadf2a62 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs @@ -89,7 +89,7 @@ namespace VocaluxeLib.PartyModes.Challenge _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _Data = new SDataFromScreen(); - SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, FadeToMain = false, ProfileIDs = new List()}; + SFromScreenNames names = new SFromScreenNames {FadeBack = false, ProfileIDs = new List()}; _Data.ScreenNames = names; } @@ -485,15 +485,13 @@ namespace VocaluxeLib.PartyModes.Challenge private void _Back() { - _Data.ScreenNames.FadeToConfig = true; - _Data.ScreenNames.FadeToMain = false; + _Data.ScreenNames.FadeBack = true; _PartyMode.DataFromScreen(ThemeName, _Data); } private void _Next() { - _Data.ScreenNames.FadeToConfig = false; - _Data.ScreenNames.FadeToMain = true; + _Data.ScreenNames.FadeBack = false; _PartyMode.DataFromScreen(ThemeName, _Data); } } diff --git a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs index eee61868..e82ac72b 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs @@ -66,10 +66,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley 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); if (res == 0) { diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs index 956954db..658c93fb 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs @@ -23,7 +23,9 @@ using VocaluxeLib.Menu; namespace VocaluxeLib.PartyModes.ChallengeMedley { +// ReSharper disable UnusedMember.Global public class CPartyScreenChallengeMedleyConfig : CMenuParty +// ReSharper restore UnusedMember.Global { // Version number for theme files. Increment it, if you've changed something on the theme files! protected override int _ScreenVersion diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs index d4729c2f..1150dff4 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs @@ -41,7 +41,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley public List TextScores; } +// ReSharper disable UnusedMember.Global public class CPartyScreenChallengeMedleyMain : CMenuParty +// ReSharper restore UnusedMember.Global { // Version number for theme files. Increment it, if you've changed something on the theme files! protected override int _ScreenVersion @@ -350,9 +352,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley private void _UpdateNextPlayerPositions() { - float x = CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2; - float staticY = 590; - float textY = 550; + float x = (float) CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2; + const float staticY = 590; + const float textY = 550; for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) { //static diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs index a7a259f3..cfbf84c6 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs @@ -24,7 +24,9 @@ using VocaluxeLib.Menu; namespace VocaluxeLib.PartyModes.ChallengeMedley { +// ReSharper disable UnusedMember.Global public class CPartyScreenChallengeMedleyNames : CMenuParty +// ReSharper restore UnusedMember.Global { // Version number for theme files. Increment it, if you've changed something on the theme files! protected override int _ScreenVersion diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs index e8a4b41a..516efd76 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs @@ -18,12 +18,15 @@ #endregion using System; +using System.Linq; using System.Windows.Forms; using VocaluxeLib.Menu; namespace VocaluxeLib.PartyModes.TicTacToe { +// ReSharper disable UnusedMember.Global public class CPartyScreenTicTacToeConfig : CMenuParty +// ReSharper restore UnusedMember.Global { // Version number for theme files. Increment it, if you've changed something on the theme files! protected override int _ScreenVersion @@ -57,14 +60,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe _ThemeButtons = new string[] {_ButtonNext, _ButtonBack}; _Data = new SDataFromScreen(); - SFromScreenConfig config = new SFromScreenConfig(); - config.PlaylistID = 0; - config.NumFields = 9; - config.NumPlayerTeam1 = 2; - config.NumPlayerTeam2 = 2; - config.GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL; - config.CategoryID = 0; - config.SongSource = ESongSource.TR_ALLSONGS; + SFromScreenConfig config = new SFromScreenConfig + { + PlaylistID = 0, + NumFields = 9, + NumPlayerTeam1 = 2, + NumPlayerTeam2 = 2, + GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL, + CategoryID = 0, + SongSource = ESongSource.TR_ALLSONGS + }; _Data.ScreenConfig = config; } @@ -263,14 +268,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(_Data.ScreenConfig.PlaylistID); i++) { int id = CBase.Playlist.GetPlaylistSong(_Data.ScreenConfig.PlaylistID, i).SongID; - foreach (EGameMode mode in CBase.Songs.GetSongByID(id).AvailableGameModes) - { - if (mode == gm) - { - _ConfigOk = true; - break; - } - } + _ConfigOk = CBase.Songs.GetSongByID(id).AvailableGameModes.Any(mode => mode == gm); if (_ConfigOk) break; } @@ -291,14 +289,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe _ConfigOk = false; for (int i = 0; i < CBase.Songs.NumSongsInCategory(_Data.ScreenConfig.CategoryID); i++) { - foreach (EGameMode mode in CBase.Songs.GetVisibleSong(i).AvailableGameModes) - { - if (mode == gm) - { - _ConfigOk = true; - break; - } - } + _ConfigOk=CBase.Songs.GetVisibleSong(i).AvailableGameModes.Any(mode => mode == gm); if (_ConfigOk) break; } @@ -316,14 +307,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe { for (int i = 0; i < CBase.Songs.GetNumSongs(); i++) { - foreach (EGameMode mode in CBase.Songs.GetSongByID(i).AvailableGameModes) - { - if (mode == gm) - { - _ConfigOk = true; - break; - } - } + _ConfigOk = CBase.Songs.GetSongByID(i).AvailableGameModes.Any(mode => mode == gm); if (_ConfigOk) break; } diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs index fbd05c8d..886a9779 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs @@ -400,13 +400,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe private void _UpdateFields() { int numOneRow = (int)Math.Sqrt(_GameData.NumFields); - float fieldSizeY = (CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow; - float fieldSizeX = (CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow; - if (fieldSizeX < fieldSizeY) - _FieldSize = fieldSizeX; - else - _FieldSize = fieldSizeY; - _FieldFirstX = CBase.Settings.GetRenderW() / 2 - (numOneRow * _FieldSize + (numOneRow - 1) * _FieldSpace) / 2; + 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); + _FieldFirstX = (float)CBase.Settings.GetRenderW() / 2 - (numOneRow * _FieldSize + (numOneRow - 1) * _FieldSpace) / 2; _FieldFirstY = 140 + (CBase.Settings.GetRenderH() - 140) / 2 - (numOneRow * _FieldSize + numOneRow * _FieldSpace) / 2; int row = 0; int column = 0; diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs index 6d5aae88..6ef12c28 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs @@ -24,7 +24,9 @@ using VocaluxeLib.Menu; namespace VocaluxeLib.PartyModes.TicTacToe { +// ReSharper disable UnusedMember.Global public class CPartyScreenTicTacToeNames : CMenuParty +// ReSharper restore UnusedMember.Global { // Version number for theme files. Increment it, if you've changed something on the theme files! protected override int _ScreenVersion diff --git a/Re#Settings.DotSettings b/Vocaluxe.sln.DotSettings similarity index 100% rename from Re#Settings.DotSettings rename to Vocaluxe.sln.DotSettings diff --git a/Vocaluxe/Base/CInput.cs b/Vocaluxe/Base/CInput.cs index 606b89d5..84632970 100644 --- a/Vocaluxe/Base/CInput.cs +++ b/Vocaluxe/Base/CInput.cs @@ -40,14 +40,14 @@ namespace Vocaluxe.Base _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() diff --git a/Vocaluxe/Base/CLog.cs b/Vocaluxe/Base/CLog.cs index fbb08230..b97b8d46 100644 --- a/Vocaluxe/Base/CLog.cs +++ b/Vocaluxe/Base/CLog.cs @@ -36,6 +36,15 @@ namespace Vocaluxe.Base _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() { if (_LogFile == null) @@ -53,21 +62,10 @@ namespace Vocaluxe.Base if (_LogFile == null) _Open(); - try - { - _LogFile.WriteLine(text); - _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(); +// ReSharper disable PossibleNullReferenceException + _LogFile.WriteLine(text); +// ReSharper restore PossibleNullReferenceException + _LogFile.Flush(); } public void Dispose() diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 4453d747..0b77a945 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -30,7 +30,6 @@ namespace Vocaluxe.Base public static IConfig Config = new CBconfig(); public static ISettings Settings = new CBsettings(); public static ITheme Theme = new CBtheme(); - public static IHelper Helper = new CBhelper(); public static IBackgroundMusic BackgroundMusic = new CBbackgroundMusic(); public static IDrawing Draw = new CBdraw(); public static IGraphics Graphics = new CBGraphics(); @@ -50,7 +49,7 @@ namespace Vocaluxe.Base 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); } } @@ -294,8 +293,6 @@ namespace Vocaluxe.Base } } - class CBhelper : IHelper {} - class CBbackgroundMusic : IBackgroundMusic { public bool IsDisabled() diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 3af6bf90..cbf890e2 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -26,10 +26,12 @@ namespace Vocaluxe.Base { enum ERevision { + // ReSharper disable UnusedMember.Global Alpha, Beta, RC, Release + // ReSharper restore UnusedMember.Global } static class CSettings diff --git a/Vocaluxe/Base/CSongSorter.cs b/Vocaluxe/Base/CSongSorter.cs index 1bd0fd11..1a4d569e 100644 --- a/Vocaluxe/Base/CSongSorter.cs +++ b/Vocaluxe/Base/CSongSorter.cs @@ -130,6 +130,11 @@ namespace Vocaluxe.Base else { 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); if (!isString && field.FieldType != typeof(List)) throw new Exception("Unkown sort field type"); diff --git a/Vocaluxe/CSplashScreen.cs b/Vocaluxe/CSplashScreen.cs index 69bc6e20..938588e4 100644 --- a/Vocaluxe/CSplashScreen.cs +++ b/Vocaluxe/CSplashScreen.cs @@ -71,6 +71,18 @@ namespace Vocaluxe 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 OnPaintBackground(PaintEventArgs e) diff --git a/Vocaluxe/Lib/Input/IInput.cs b/Vocaluxe/Lib/Input/IInput.cs index e3d0162c..aef32f7e 100644 --- a/Vocaluxe/Lib/Input/IInput.cs +++ b/Vocaluxe/Lib/Input/IInput.cs @@ -34,10 +34,10 @@ namespace Vocaluxe.Lib.Input interface IInput { - bool Init(); + void Init(); void Close(); - bool Connect(); - bool Disconnect(); + void Connect(); + void Disconnect(); bool IsConnected(); void Update(); diff --git a/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs b/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs index 4e419c32..98cef67b 100644 --- a/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs +++ b/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs @@ -50,15 +50,13 @@ namespace Vocaluxe.Lib.Input.WiiMote private CGesture _Gesture; - public bool Init() + public void Init() { _Sync = new Object(); _RumbleTimer = new CRumbleTimer(); _Gesture = new CGesture(); - _Active = true; - _HandlerThread = new Thread(_MainLoop); - _HandlerThread.Priority = ThreadPriority.BelowNormal; + _HandlerThread = new Thread(_MainLoop) {Priority = ThreadPriority.BelowNormal}; _KeysPool = new List(); _CurrentKeysPool = new List(); @@ -68,10 +66,6 @@ namespace Vocaluxe.Lib.Input.WiiMote _ButtonStates = new bool[11]; _OldPosition = new Point(); - - _HandlerThread.Start(); - - return true; } public void Close() @@ -79,20 +73,17 @@ namespace Vocaluxe.Lib.Input.WiiMote _Active = false; } - public bool Connect() + public void Connect() { - if (!_Active) - { - _Active = true; - _HandlerThread.Start(); - } - return true; + if (_Active) + return; + _Active = true; + _HandlerThread.Start(); } - public bool Disconnect() + public void Disconnect() { _Active = false; - return true; } public bool IsConnected() @@ -113,8 +104,7 @@ namespace Vocaluxe.Lib.Input.WiiMote _CurrentKeysPool.RemoveAt(0); return true; } - else - return false; + return false; } public bool PollMouseEvent(ref SMouseEvent mouseEvent) @@ -125,8 +115,7 @@ namespace Vocaluxe.Lib.Input.WiiMote _CurrentMousePool.RemoveAt(0); return true; } - else - return false; + return false; } public void SetRumble(float duration) diff --git a/Vocaluxe/Lib/Sound/COpenALPlay.cs b/Vocaluxe/Lib/Sound/COpenALPlay.cs index 43a2832c..775b6ca5 100644 --- a/Vocaluxe/Lib/Sound/COpenALPlay.cs +++ b/Vocaluxe/Lib/Sound/COpenALPlay.cs @@ -119,7 +119,6 @@ namespace Vocaluxe.Lib.Sound { _Decoder.Add(decoder); stream.Handle = _Count++; - stream.File = media; _Streams.Add(stream); return stream.Handle; } @@ -399,7 +398,6 @@ namespace Vocaluxe.Lib.Sound private Closeproc _Closeproc; private int _StreamID; - private string _FileName; private IAudioDecoder _Decoder; private float _BytesPerSecond; private bool _NoMoreData; @@ -506,7 +504,7 @@ namespace Vocaluxe.Lib.Sound { if (Finished) _Timer.Stop(); - + //TODO: Why not use Decoder.GetPosition()? return _CurrentTime + _Timer.ElapsedMilliseconds / 1000f; } } @@ -586,9 +584,6 @@ namespace Vocaluxe.Lib.Sound if (!File.Exists(fileName)) return -1; - if (_FileOpened) - return -1; - _Decoder = new CAudioDecoderFFmpeg(); _Decoder.Init(); @@ -609,7 +604,6 @@ namespace Vocaluxe.Lib.Sound return -1; } - _FileName = fileName; _Decoder.Open(fileName); _Duration = _Decoder.GetLength(); @@ -619,9 +613,7 @@ namespace Vocaluxe.Lib.Sound _CurrentTime = 0f; _Timer.Reset(); - SAudioStreams stream = new SAudioStreams(0); - - stream.Handle = _Buffers[0]; + SAudioStreams stream = new SAudioStreams(0) {Handle = _Buffers[0]}; if (stream.Handle != 0) { @@ -634,6 +626,7 @@ namespace Vocaluxe.Lib.Sound return stream.Handle; } + _Initialized = true; return -1; } @@ -758,6 +751,7 @@ namespace Vocaluxe.Lib.Sound AL.DeleteSource(_Source); AL.DeleteBuffers(_Buffers); } + _Decoder.Close(); } _Closeproc(_StreamID); diff --git a/Vocaluxe/Lib/Sound/COpenALRecord.cs b/Vocaluxe/Lib/Sound/COpenALRecord.cs deleted file mode 100644 index 92766765..00000000 --- a/Vocaluxe/Lib/Sound/COpenALRecord.cs +++ /dev/null @@ -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 . -// */ -#endregion - -namespace Vocaluxe.Lib.Sound -{ - class COpenALRecord {} -} \ No newline at end of file diff --git a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs index a6c904d3..e5a92632 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs @@ -104,7 +104,6 @@ namespace Vocaluxe.Lib.Sound { _Decoder.Add(decoder); stream.Handle = _Count++; - stream.File = media; _Streams.Add(stream); return stream.Handle; } @@ -376,7 +375,6 @@ namespace Vocaluxe.Lib.Sound private Closeproc _Closeproc; private CPortAudio.PaStreamCallbackDelegate _PaStreamCallback; private int _StreamID; - private string _FileName; private IAudioDecoder _Decoder; private float _BytesPerSecond; private bool _NoMoreData; @@ -489,7 +487,7 @@ namespace Vocaluxe.Lib.Sound { if (Finished) _SyncTimer.Pause(); - + //TODO: Why not use Decoder.GetPosition()? return _SyncTimer.Time; } } @@ -607,7 +605,6 @@ namespace Vocaluxe.Lib.Sound return -1; } - _FileName = fileName; _Decoder.Open(fileName); _Duration = _Decoder.GetLength(); @@ -800,6 +797,7 @@ namespace Vocaluxe.Lib.Sound _Initialized = false; } } + _Decoder.Close(); } _Closeproc(_StreamID); diff --git a/Vocaluxe/Lib/Sound/Decoder/CAudioDecoder.cs b/Vocaluxe/Lib/Sound/Decoder/CAudioDecoder.cs deleted file mode 100644 index 128d7ed2..00000000 --- a/Vocaluxe/Lib/Sound/Decoder/CAudioDecoder.cs +++ /dev/null @@ -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 . -// */ -#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; - } - } -} \ No newline at end of file diff --git a/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs b/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs index eb0a01d1..3bdd388c 100644 --- a/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs +++ b/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs @@ -24,7 +24,7 @@ using Vocaluxe.Lib.Video.Acinerella; namespace Vocaluxe.Lib.Sound.Decoder { - class CAudioDecoderFFmpeg : CAudioDecoder, IDisposable + class CAudioDecoderFFmpeg : IAudioDecoder, IDisposable { private IntPtr _InstancePtr = IntPtr.Zero; private IntPtr _Audiodecoder = IntPtr.Zero; @@ -36,17 +36,12 @@ namespace Vocaluxe.Lib.Sound.Decoder private string _FileName; 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; try @@ -88,11 +83,12 @@ namespace Vocaluxe.Lib.Sound.Decoder return; } - _FormatInfo = new SFormatInfo(); - - _FormatInfo.SamplesPerSecond = audiodecoder.StreamInfo.AudioInfo.SamplesPerSecond; - _FormatInfo.BitDepth = audiodecoder.StreamInfo.AudioInfo.BitDepth; - _FormatInfo.ChannelCount = audiodecoder.StreamInfo.AudioInfo.ChannelCount; + _FormatInfo = new SFormatInfo + { + SamplesPerSecond = audiodecoder.StreamInfo.AudioInfo.SamplesPerSecond, + BitDepth = audiodecoder.StreamInfo.AudioInfo.BitDepth, + ChannelCount = audiodecoder.StreamInfo.AudioInfo.ChannelCount + }; _CurrentTime = 0f; @@ -104,13 +100,8 @@ namespace Vocaluxe.Lib.Sound.Decoder _FileOpened = true; } - public override void Close() + public void Close() { - if (!_Initialized) - return; - - _Initialized = false; - if (!_FileOpened) return; @@ -126,25 +117,25 @@ namespace Vocaluxe.Lib.Sound.Decoder _FileOpened = false; } - public override SFormatInfo GetFormatInfo() + public SFormatInfo GetFormatInfo() { - if (!_Initialized && !_FileOpened) + if (!_FileOpened) return new SFormatInfo(); return _FormatInfo; } - public override float GetLength() + public float GetLength() { - if (!_Initialized && !_FileOpened) + if (!_FileOpened) return 0f; return _Instance.Info.Duration / 1000f; } - public override void SetPosition(float time) + public void SetPosition(float time) { - if (!_Initialized && !_FileOpened) + if (!_FileOpened) return; try @@ -158,17 +149,14 @@ namespace Vocaluxe.Lib.Sound.Decoder } } - public override float GetPosition() + public float GetPosition() { - if (!_Initialized && !_FileOpened) - return 0f; - - return _CurrentTime; + return !_FileOpened ? 0f : _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; timeStamp = 0f; diff --git a/Vocaluxe/Lib/Sound/Decoder/IAudioDecoder.cs b/Vocaluxe/Lib/Sound/Decoder/IAudioDecoder.cs index 4a58afc3..c98b66ec 100644 --- a/Vocaluxe/Lib/Sound/Decoder/IAudioDecoder.cs +++ b/Vocaluxe/Lib/Sound/Decoder/IAudioDecoder.cs @@ -31,8 +31,7 @@ namespace Vocaluxe.Lib.Sound.Decoder void Init(); void Close(); - void Open(string fileName); - void Open(string fileName, bool loop); + void Open(string fileName, bool loop=false); SFormatInfo GetFormatInfo(); float GetLength(); diff --git a/Vocaluxe/Lib/Sound/IPlayback.cs b/Vocaluxe/Lib/Sound/IPlayback.cs index c83a0fbd..69058546 100644 --- a/Vocaluxe/Lib/Sound/IPlayback.cs +++ b/Vocaluxe/Lib/Sound/IPlayback.cs @@ -24,12 +24,10 @@ namespace Vocaluxe.Lib.Sound struct SAudioStreams { public int Handle; - public string File; public SAudioStreams(int stream) { Handle = stream; - File = String.Empty; } } diff --git a/Vocaluxe/Lib/Sound/Portaudio/PortAudioASIO.cs b/Vocaluxe/Lib/Sound/Portaudio/PortAudioASIO.cs deleted file mode 100644 index 4bdd1091..00000000 --- a/Vocaluxe/Lib/Sound/Portaudio/PortAudioASIO.cs +++ /dev/null @@ -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 . -// */ -#endregion - -using System; -using System.Runtime.InteropServices; - -namespace Vocaluxe.Lib.Sound.PortAudio -{ - /// PortAudio v.19 bindings for .NET - ASIO bindings - 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 **** - // /// Retrieve legal latency settings for the specificed device, in samples. - // /// The global index of the device about which the query is being made. - // /// A pointer to the location which will recieve the minimum latency value. - // /// A pointer to the location which will recieve the maximum latency value. - // /// A pointer to the location which will recieve the preferred latency value. - // /// 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. - // /// See ASIOGetBufferSize in the ASIO SDK. - // PaError PaAsio_GetAvailableLatencyValues( PaDeviceIndex device, long *minLatency, long *maxLatency, - // long *preferredLatency, long *granularity ); - - /// Display the ASIO control panel for the specified device. - /// The global index of the device whose control panel is to be displayed. - /// - /// On Windows, the calling application's main window handle, - /// on Macintosh this value should be zero. - /// - [DllImport("PortAudio.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern EPaError PaAsio_ShowControlPanel(int device, IntPtr systemSpecific); - - // /// Retrieve a pointer to a string containing the name of the specified input channel. - // /// 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 ); - - // /// Retrieve a pointer to a string containing the name of the specified input channel. - // /// 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 ); - - /// Set the sample rate of an open paASIO stream. - /// - /// The stream to operate on. - /// - /// 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. - /// paIncompatibleStreamHostApi if stream is not a paASIO stream. - [DllImport("PortAudio.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern EPaError PaAsio_SetStreamSampleRate(IntPtr stream, double sampleRate); - #endregion - } -} \ No newline at end of file diff --git a/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs b/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs index 4127ae01..32eafb4f 100644 --- a/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs +++ b/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs @@ -22,6 +22,7 @@ using System.Runtime.InteropServices; namespace Vocaluxe.Lib.Video.Acinerella { + // ReSharper disable UnusedMember.Global public enum EACStreamType : sbyte { /*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 } + // ReSharper disable MemberCanBePrivate.Global + // Contains information about the whole file/stream that has been opened. Default // values are "" for strings and -1 for integer values. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct SACFileInfo { - public Int64 Duration; + public readonly Int64 Duration; } // TAc_instance represents an Acinerella instance. Each instance can open and @@ -66,12 +69,12 @@ namespace Vocaluxe.Lib.Video.Acinerella public struct SACInstance { //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 //after calling the ac_open function. - public Int32 StreamCount; + public readonly Int32 StreamCount; //Set this value to change the image output format - public EACOutputFormat OutputFormat; + public readonly EACOutputFormat OutputFormat; //Contains information about the opened stream/file public SACFileInfo Info; } @@ -81,11 +84,11 @@ namespace Vocaluxe.Lib.Video.Acinerella public struct SACAudioStreamInfo { //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. - public Int32 BitDepth; + public readonly Int32 BitDepth; //Count of channels in the audio stream. - public Int32 ChannelCount; + public readonly Int32 ChannelCount; } // Contains information about an Acinerella video stream. @@ -93,13 +96,13 @@ namespace Vocaluxe.Lib.Video.Acinerella public struct SACVideoStreamInfo { //The width of one frame. - public Int32 FrameWidth; + public readonly Int32 FrameWidth; //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 - public float PixelAspect; + public readonly float PixelAspect; //Frames per second that should be played. - public double FramesPerSecond; + public readonly double FramesPerSecond; } // Contains information about an Acinerella stream. @@ -107,7 +110,8 @@ namespace Vocaluxe.Lib.Video.Acinerella public struct SACStreamInfo { //Contains the type of the stream. - public EACStreamType StreamType; + public readonly EACStreamType StreamType; + //Additional info about the stream public SACAudioStreamInfo AudioInfo; public SACVideoStreamInfo VideoInfo; @@ -120,32 +124,33 @@ namespace Vocaluxe.Lib.Video.Acinerella //Pointer on the Acinerella instance private readonly IntPtr _ACInstancePtr; //Contains the type of the decoder. - public EACDecoderType DecType; + public readonly EACDecoderType DecType; //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. public SACStreamInfo StreamInfo; //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. internal IntPtr Buffer; //Size of the data in the buffer. - public Int32 BufferSize; + public readonly Int32 BufferSize; } - // Contains information about an Acinerella package. [StructLayout(LayoutKind.Sequential)] public struct SACPackage { //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 // 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; @@ -273,7 +278,9 @@ namespace Vocaluxe.Lib.Video.Acinerella string filename ); +// ReSharper disable UnusedMethodReturnValue.Global public static Int32 AcOpen2( +// ReSharper restore UnusedMethodReturnValue.Global IntPtr pAcInstance, string filename ) @@ -423,7 +430,9 @@ namespace Vocaluxe.Lib.Video.Acinerella [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); +// ReSharper disable UnusedMethodReturnValue.Global public static Int32 AcSeek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos) +// ReSharper restore UnusedMethodReturnValue.Global { lock (_Lock) { @@ -441,4 +450,5 @@ namespace Vocaluxe.Lib.Video.Acinerella out Int32 scoreMax ); } + // ReSharper restore UnusedMember.Global } \ No newline at end of file diff --git a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs index 9c33c6f5..aa998ad0 100644 --- a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs +++ b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs @@ -67,7 +67,6 @@ namespace Vocaluxe.Lib.Video { _Decoder.Add(decoder); stream.Handle = _Count++; - stream.File = videoFileName; _Streams.Add(stream); return stream.Handle; } @@ -232,7 +231,6 @@ namespace Vocaluxe.Lib.Video private bool _Paused; private bool _NoMoreFrames; - private bool _Finished; private bool _BeforeLoop; private int _Width; @@ -240,7 +238,6 @@ namespace Vocaluxe.Lib.Video private float _SetTime; private float _SetGap; private float _SetStart; - private bool _SetLoop; private bool _SetSkip; private bool _Terminated; @@ -267,16 +264,12 @@ namespace Vocaluxe.Lib.Video { get { - if (_FileOpened) - return _Duration; - - return 0f; + return _FileOpened ? _Duration : 0f; } } public bool Paused { - get { return _Paused; } set { lock (_MutexSyncSignals) @@ -290,16 +283,9 @@ namespace Vocaluxe.Lib.Video } } - public bool Loop - { - get { return _SetLoop; } - set { _SetLoop = value; } - } + public bool Loop { private get; set; } - public bool Finished - { - get { return _Finished; } - } + public bool Finished { get; private set; } public bool Open(string fileName) { @@ -325,7 +311,7 @@ namespace Vocaluxe.Lib.Video if (_Paused) return false; - if (_SetLoop) + if (Loop) { lock (_MutexSyncSignals) { @@ -343,7 +329,7 @@ namespace Vocaluxe.Lib.Video return true; } - if (_SetTime != time) + if (Math.Abs(_SetTime - time) > float.Epsilon) { lock (_MutexSyncSignals) { @@ -365,7 +351,7 @@ namespace Vocaluxe.Lib.Video _SetGap = gap; _SetSkip = true; _NoMoreFrames = false; - _Finished = false; + Finished = false; } //EventDecode.Set(); return true; @@ -443,7 +429,7 @@ namespace Vocaluxe.Lib.Video _SetSkip = false; _Gap = _SetGap; _Start = _SetStart; - _Loop = _SetLoop; + _Loop = Loop; } if (_Skip) @@ -678,7 +664,7 @@ namespace Vocaluxe.Lib.Video 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); frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].Data); @@ -690,12 +676,12 @@ namespace Vocaluxe.Lib.Video { _CurrentVideoTime = _FrameBuffer[num].Time; } - _Finished = false; + Finished = false; } else { if (_NoMoreFrames) - _Finished = true; + Finished = true; } } } diff --git a/Vocaluxe/Lib/Video/Gstreamer/CGstreamerVideoWrapper.cs b/Vocaluxe/Lib/Video/Gstreamer/CGstreamerVideoWrapper.cs index 544a28d2..5a863adc 100644 --- a/Vocaluxe/Lib/Video/Gstreamer/CGstreamerVideoWrapper.cs +++ b/Vocaluxe/Lib/Video/Gstreamer/CGstreamerVideoWrapper.cs @@ -24,11 +24,13 @@ namespace Vocaluxe.Lib.Video.Gstreamer { public struct SNativeFrame { +// ReSharper disable UnassignedField.Global internal IntPtr Buffer; public int Size; public int Width; public int Height; public float Videotime; + // ReSharper restore UnassignedField.Global } public struct SManagedFrame diff --git a/Vocaluxe/Lib/Video/IVideoDecoder.cs b/Vocaluxe/Lib/Video/IVideoDecoder.cs index dfdd3312..da0db810 100644 --- a/Vocaluxe/Lib/Video/IVideoDecoder.cs +++ b/Vocaluxe/Lib/Video/IVideoDecoder.cs @@ -25,12 +25,10 @@ namespace Vocaluxe.Lib.Video struct SVideoStreams { public int Handle; - public string File; public SVideoStreams(int stream) { Handle = stream; - File = String.Empty; } } diff --git a/Vocaluxe/Lib/Webcam/CAForgeNet.cs b/Vocaluxe/Lib/Webcam/CAForgeNet.cs index 1bc7ff7d..20d25328 100644 --- a/Vocaluxe/Lib/Webcam/CAForgeNet.cs +++ b/Vocaluxe/Lib/Webcam/CAForgeNet.cs @@ -17,6 +17,7 @@ // */ #endregion +using System; using AForge.Video; using AForge.Video.DirectShow; using System.Collections.Generic; @@ -56,7 +57,7 @@ namespace Vocaluxe.Lib.Webcam { 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); frame = CDraw.AddTexture(_Width, _Height, ref _Data); @@ -81,8 +82,7 @@ namespace Vocaluxe.Lib.Webcam return bmp; } } - else - return null; + return null; } public bool Init() @@ -101,13 +101,12 @@ namespace Vocaluxe.Lib.Webcam num++; 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 { - Framerate = tmpdev.VideoCapabilities[i].FrameRate, - Height = tmpdev.VideoCapabilities[i].FrameSize.Height, - Width = tmpdev.VideoCapabilities[i].FrameSize.Width + Framerate = capabilities.FrameRate, + Height = capabilities.FrameSize.Height, + Width = capabilities.FrameSize.Width }; device.Capabilities.Add(item); } @@ -174,10 +173,7 @@ namespace Vocaluxe.Lib.Webcam return false; //No MonikerString found, try first webcam - if (config.MonikerString.Length == 0) - _Webcam = new VideoCaptureDevice(_WebcamDevices[0].MonikerString); - else //Found MonikerString - _Webcam = new VideoCaptureDevice(config.MonikerString); + _Webcam = config.MonikerString == "" ? new VideoCaptureDevice(_WebcamDevices[0].MonikerString) : new VideoCaptureDevice(config.MonikerString); if (_Webcam == null) return false; diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index dfd3fea0..689bf2c5 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -185,6 +185,7 @@ namespace Vocaluxe // Init Input CLog.StartBenchmark(0, "Init Input"); CInput.Init(); + CInput.Connect(); CLog.StopBenchmark(0, "Init Input"); // Init Game; diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index b0c8c64f..58fa7a40 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -220,11 +220,9 @@ - - @@ -265,7 +263,6 @@ Designer - diff --git a/VocaluxeLib/Menu/CBasic.cs b/VocaluxeLib/Menu/CBasic.cs index 15162057..db31f26b 100644 --- a/VocaluxeLib/Menu/CBasic.cs +++ b/VocaluxeLib/Menu/CBasic.cs @@ -24,7 +24,6 @@ namespace VocaluxeLib.Menu public static IConfig Config; public static ISettings Settings; public static ITheme Theme; - public static IHelper Helper; public static ILog Log; public static IBackgroundMusic BackgroundMusic; public static IDrawing Drawing; @@ -42,14 +41,13 @@ namespace VocaluxeLib.Menu public static IInputs Input; 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, ISongs songs, IVideo video, ISound sound, ICover cover, IDataBase dataBase, IInputs input, IPlaylist playlist) { Config = config; Settings = settings; Theme = theme; - Helper = helper; Log = log; BackgroundMusic = backgroundMusic; Drawing = draw; diff --git a/VocaluxeLib/Menu/CEqualizer.cs b/VocaluxeLib/Menu/CEqualizer.cs index 91ac9265..a1d7fc89 100644 --- a/VocaluxeLib/Menu/CEqualizer.cs +++ b/VocaluxeLib/Menu/CEqualizer.cs @@ -241,7 +241,7 @@ namespace VocaluxeLib.Menu public void Draw() { - if (_Bars == null) + if (_Bars == null || _Theme.Style!=EEqualizerStyle.Collums) return; float dx = Rect.W / _Bars.Length; diff --git a/VocaluxeLib/Menu/CMenu.cs b/VocaluxeLib/Menu/CMenu.cs index 5f766e26..6b10e51d 100644 --- a/VocaluxeLib/Menu/CMenu.cs +++ b/VocaluxeLib/Menu/CMenu.cs @@ -144,7 +144,7 @@ namespace VocaluxeLib.Menu #region ThemeHandler private delegate void AddElementHandler(T element, String key); - private void _LoadThemeElement(string[] elements, AddElementHandler addElementHandler, CXMLReader xmlReader, int skinIndex) where T : IMenuElement + private void _LoadThemeElement(IEnumerable elements, AddElementHandler addElementHandler, CXMLReader xmlReader, int skinIndex) where T : IMenuElement { if (elements != null) { diff --git a/VocaluxeLib/Menu/COrderedDictionaryLite.cs b/VocaluxeLib/Menu/COrderedDictionaryLite.cs index da0563b8..76ef3a88 100644 --- a/VocaluxeLib/Menu/COrderedDictionaryLite.cs +++ b/VocaluxeLib/Menu/COrderedDictionaryLite.cs @@ -36,13 +36,6 @@ namespace VocaluxeLib.Menu _Parent = parent; } - public COrderedDictionaryLite(COrderedDictionaryLite dict) - { - _Items = new List(dict._Items); - _HtIndex = new Dictionary(dict._HtIndex); - _Parent = dict._Parent; - } - public T this[int index] { get { return _Items[index]; } diff --git a/VocaluxeLib/Menu/CScreenSetting.cs b/VocaluxeLib/Menu/CScreenSetting.cs index 4819b4d9..25063735 100644 --- a/VocaluxeLib/Menu/CScreenSetting.cs +++ b/VocaluxeLib/Menu/CScreenSetting.cs @@ -37,7 +37,10 @@ namespace VocaluxeLib.Menu public ESettingType Type; } +// ReSharper disable ClassNeverInstantiated.Global + //Instantiated by reflection public class CScreenSetting : IMenuElement +// ReSharper restore ClassNeverInstantiated.Global { private readonly int _PartyModeID; @@ -56,13 +59,6 @@ namespace VocaluxeLib.Menu _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) { string item = xmlPath + "/" + elementName; diff --git a/VocaluxeLib/Menu/IMenu.cs b/VocaluxeLib/Menu/IMenu.cs index 411c9f53..70813cfc 100644 --- a/VocaluxeLib/Menu/IMenu.cs +++ b/VocaluxeLib/Menu/IMenu.cs @@ -138,8 +138,6 @@ namespace VocaluxeLib.Menu void LoadTheme(); } - public interface IHelper {} - public interface IBackgroundMusic { bool IsDisabled(); diff --git a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs index d3d3e4f6..3cadcdbc 100644 --- a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs @@ -57,7 +57,7 @@ namespace VocaluxeLib.Menu.SingNotes public string SkinPerfectNoteStarName; } - public abstract class CSingNotes : ISingNotes, IMenuElement + public abstract class CSingNotes : IMenuElement { protected int _PartyModeID; private SThemeSingBar _Theme; diff --git a/VocaluxeLib/Menu/SingNotes/ISingNotes.cs b/VocaluxeLib/Menu/SingNotes/ISingNotes.cs deleted file mode 100644 index d5db470b..00000000 --- a/VocaluxeLib/Menu/SingNotes/ISingNotes.cs +++ /dev/null @@ -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 . -// */ -#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 singLine, int player); - } -} \ No newline at end of file diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index 81fe451c..42c2b03f 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -46,12 +46,6 @@ namespace VocaluxeLib.Menu.SongMenu public SThemeSongMenuTileBoard SongMenuTileBoard; } - struct SThemeSongMenuBook {} - - struct SThemeSongMenuDreidel {} - - struct SThemeSongMenuList {} - struct SThemeSongMenuTileBoard { /// diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj index 038db9ed..e9d4bd1e 100644 --- a/VocaluxeLib/VocaluxeLib.csproj +++ b/VocaluxeLib/VocaluxeLib.csproj @@ -137,7 +137,6 @@ -