From 124ed1c3d3de4b42682e28815c40a46c944ae4d6 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Fri, 26 Apr 2013 18:13:22 +0200 Subject: [PATCH 01/33] Renamed CGameMode to CSongQueue as this is what it actually is --- Vocaluxe/Base/CGame.cs | 54 +++++++++---------- Vocaluxe/GameModes/CGameModeNormal.cs | 24 --------- Vocaluxe/Screens/CScreenSong.cs | 2 +- .../CGameMode.cs => SongQueue/CSongQueue.cs} | 22 ++++---- .../IGameMode.cs => SongQueue/ISongQueue.cs} | 4 +- Vocaluxe/Vocaluxe.csproj | 5 +- 6 files changed, 40 insertions(+), 71 deletions(-) delete mode 100644 Vocaluxe/GameModes/CGameModeNormal.cs rename Vocaluxe/{GameModes/CGameMode.cs => SongQueue/CSongQueue.cs} (92%) rename Vocaluxe/{GameModes/IGameMode.cs => SongQueue/ISongQueue.cs} (96%) diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index ae909a92..d8403a9f 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -19,7 +19,7 @@ using System; using System.Collections.Generic; -using Vocaluxe.GameModes; +using Vocaluxe.SongQueue; using VocaluxeLib.Menu; using VocaluxeLib.Menu.SingNotes; using VocaluxeLib.Menu.SongMenu; @@ -28,7 +28,7 @@ namespace Vocaluxe.Base { static class CGame { - private static IGameMode _GameMode; + private static ISongQueue _SongQueue; private static int _NumPlayer = CConfig.NumPlayer; private static int _OldBeatD; @@ -64,103 +64,97 @@ namespace Vocaluxe.Base public static void Init() { - _GameMode = new CGameModeNormal(); - _GameMode.Init(); + _SongQueue = new CSongQueue(); + _SongQueue.Init(); Players = new SPlayer[CSettings.MaxNumPlayer]; ResetPlayer(); CConfig.UsePlayers(); } - public static void EnterNormalGame() - { - _GameMode = new CGameModeNormal(); - _GameMode.Init(); - } - public static EGameMode GameMode { - get { return _GameMode.GetCurrentGameMode(); } + get { return _SongQueue.GetCurrentGameMode(); } } public static bool AddVisibleSong(int visibleIndex, EGameMode gameMode) { - return _GameMode.AddVisibleSong(visibleIndex, gameMode); + return _SongQueue.AddVisibleSong(visibleIndex, gameMode); } public static bool AddSong(int absoluteIndex, EGameMode gameMode) { - return _GameMode.AddSong(absoluteIndex, gameMode); + return _SongQueue.AddSong(absoluteIndex, gameMode); } public static bool RemoveVisibleSong(int visibleIndex) { - return _GameMode.RemoveVisibleSong(visibleIndex); + return _SongQueue.RemoveVisibleSong(visibleIndex); } public static bool RemoveSong(int absoluteIndex) { - return _GameMode.RemoveSong(absoluteIndex); + return _SongQueue.RemoveSong(absoluteIndex); } public static void ClearSongs() { - _GameMode.ClearSongs(); + _SongQueue.ClearSongs(); } public static void Reset() { - _GameMode.Reset(); + _SongQueue.Reset(); } public static void Start() { - _GameMode.Start(Players); + _SongQueue.Start(Players); } public static void NextRound() { - _GameMode.NextRound(Players); + _SongQueue.NextRound(Players); } public static bool IsFinished() { - return _GameMode.IsFinished(); + return _SongQueue.IsFinished(); } public static int RoundNr { - get { return _GameMode.GetCurrentRoundNr(); } + get { return _SongQueue.GetCurrentRoundNr(); } } public static CSong GetSong() { - return _GameMode.GetSong(); + return _SongQueue.GetSong(); } public static CSong GetSong(int num) { - return _GameMode.GetSong(num); + return _SongQueue.GetSong(num); } public static EGameMode GetGameMode(int num) { - return _GameMode.GetGameMode(num); + return _SongQueue.GetGameMode(num); } public static int GetNumSongs() { - return _GameMode.GetNumSongs(); + return _SongQueue.GetNumSongs(); } public static CPoints GetPoints() { - return _GameMode.GetPoints(); + return _SongQueue.GetPoints(); } public static int NumRounds { - get { return _GameMode.GetNumSongs(); } + get { return _SongQueue.GetNumSongs(); } } public static int NumPlayer @@ -200,7 +194,7 @@ namespace Vocaluxe.Base public static void UpdatePoints(float time) { - CSong song = _GameMode.GetSong(); + CSong song = _SongQueue.GetSong(); if (song == null) return; @@ -225,8 +219,8 @@ namespace Vocaluxe.Base { for (int beat = _OldBeatD + 1; beat <= ActBeatD; beat++) { - if ((_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_MEDLEY && song.Medley.EndBeat == beat) || - (_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat)) + if ((_SongQueue.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_MEDLEY && song.Medley.EndBeat == beat) || + (_SongQueue.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat)) Players[p].SongFinished = true; CLine[] lines = song.Notes.GetVoice(Players[p].LineNr).Lines; diff --git a/Vocaluxe/GameModes/CGameModeNormal.cs b/Vocaluxe/GameModes/CGameModeNormal.cs deleted file mode 100644 index e728a923..00000000 --- a/Vocaluxe/GameModes/CGameModeNormal.cs +++ /dev/null @@ -1,24 +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.GameModes -{ - // Nomal singing - class CGameModeNormal : CGameMode {} -} \ No newline at end of file diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 054fddf3..852e6ebb 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -612,7 +612,7 @@ namespace Vocaluxe.Screens _SearchActive = _Sso.Sorting.SearchActive; _SearchText = _Sso.Sorting.SearchString; - CGame.EnterNormalGame(); + CGame.Reset(); _SongMenus[_SongMenu].OnShow(); if (_Sso.Selection.PartyMode) diff --git a/Vocaluxe/GameModes/CGameMode.cs b/Vocaluxe/SongQueue/CSongQueue.cs similarity index 92% rename from Vocaluxe/GameModes/CGameMode.cs rename to Vocaluxe/SongQueue/CSongQueue.cs index 2d6f2527..e8ad77f2 100644 --- a/Vocaluxe/GameModes/CGameMode.cs +++ b/Vocaluxe/SongQueue/CSongQueue.cs @@ -22,30 +22,30 @@ using Vocaluxe.Base; using VocaluxeLib.Menu; using VocaluxeLib.Menu.SongMenu; -namespace Vocaluxe.GameModes +namespace Vocaluxe.SongQueue { - struct SSongQueque + struct SSongQueueEntry { public readonly int SongID; public readonly EGameMode GameMode; - public SSongQueque(int songID, EGameMode gameMode) + public SSongQueueEntry(int songID, EGameMode gameMode) { SongID = songID; GameMode = gameMode; } } - abstract class CGameMode : IGameMode + class CSongQueue : ISongQueue { - private List _SongQueque; + private List _SongQueque; private int _CurrentSong; private CPoints _Points; #region Implementation public virtual void Init() { - _SongQueque = new List(); + _SongQueque = new List(); Reset(); } @@ -64,7 +64,7 @@ namespace Vocaluxe.GameModes if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet) return false; - _SongQueque.Add(new SSongQueque(songID, gameMode)); + _SongQueque.Add(new SSongQueueEntry(songID, gameMode)); return true; } return false; @@ -78,7 +78,7 @@ namespace Vocaluxe.GameModes if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet) return false; - _SongQueque.Add(new SSongQueque(songID, gameMode)); + _SongQueque.Add(new SSongQueueEntry(songID, gameMode)); return true; } return false; @@ -215,7 +215,7 @@ namespace Vocaluxe.GameModes public virtual CSong GetSong(int num) { - if (num - 1 < _SongQueque.Count && num - 1 > -1) + if (num - 1 < _SongQueque.Count && num > 0) return CSongs.GetSong(_SongQueque[num - 1].SongID); return null; @@ -223,8 +223,8 @@ namespace Vocaluxe.GameModes public virtual EGameMode GetGameMode(int num) { - if (num - 1 < _SongQueque.Count && num > -1) - return _SongQueque[num].GameMode; + if (num - 1 < _SongQueque.Count && num > 0) + return _SongQueque[num - 1].GameMode; return EGameMode.TR_GAMEMODE_NORMAL; } diff --git a/Vocaluxe/GameModes/IGameMode.cs b/Vocaluxe/SongQueue/ISongQueue.cs similarity index 96% rename from Vocaluxe/GameModes/IGameMode.cs rename to Vocaluxe/SongQueue/ISongQueue.cs index b9732b15..40bf808d 100644 --- a/Vocaluxe/GameModes/IGameMode.cs +++ b/Vocaluxe/SongQueue/ISongQueue.cs @@ -20,9 +20,9 @@ using VocaluxeLib.Menu; using VocaluxeLib.Menu.SongMenu; -namespace Vocaluxe.GameModes +namespace Vocaluxe.SongQueue { - interface IGameMode + interface ISongQueue { void Init(); diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 58fa7a40..1e170ebb 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -198,9 +198,8 @@ Form - - - + + Form From 780a179fcb84956d60119a65ba925ff4f67f87ef Mon Sep 17 00:00:00 2001 From: Flamefire Date: Fri, 26 Apr 2013 18:56:33 +0200 Subject: [PATCH 02/33] Added Gamemode-Classes --- .../PartyModeChallenge/CPartyModeChallenge.cs | 10 +- .../CPartyModeChallengeMedley.cs | 10 +- .../PartyModeTicTacToe/CPartyModeTicTacToe.cs | 16 +- Vocaluxe/Base/CGame.cs | 12 +- Vocaluxe/Base/CSongs.cs | 27 ++- Vocaluxe/GameModes/CGameMode.cs | 24 +++ Vocaluxe/GameModes/CGameModes.cs | 81 +++++++++ Vocaluxe/GameModes/IGameMode.cs | 9 + Vocaluxe/Screens/CScreenHighscore.cs | 8 +- Vocaluxe/Screens/CScreenScore.cs | 62 +++---- Vocaluxe/SongQueue/CSongQueue.cs | 163 ++++++------------ Vocaluxe/SongQueue/ISongQueue.cs | 4 +- Vocaluxe/Vocaluxe.csproj | 3 + VocaluxeLib/Menu/CPoints.cs | 28 +-- VocaluxeLib/Menu/SingNotes/CNotes.cs | 1 + VocaluxeLib/Menu/SongMenu/CSong.cs | 24 +-- 16 files changed, 258 insertions(+), 224 deletions(-) create mode 100644 Vocaluxe/GameModes/CGameMode.cs create mode 100644 Vocaluxe/GameModes/CGameModes.cs create mode 100644 Vocaluxe/GameModes/IGameMode.cs diff --git a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs index 5782df18..8479323b 100644 --- a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs +++ b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs @@ -459,11 +459,11 @@ namespace VocaluxeLib.PartyModes.Challenge CBase.Game.AddSong(songID, gm); CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce); - SPlayer[] player = CBase.Game.GetPlayers(); - if (player == null) + SPlayer[] players = CBase.Game.GetPlayers(); + if (players == null) return; - if (player.Length < _GameData.NumPlayerAtOnce) + if (players.Length < _GameData.NumPlayerAtOnce) return; CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1); @@ -472,9 +472,9 @@ namespace VocaluxeLib.PartyModes.Challenge { //try to fill with the right data if (c != null) - player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; + players[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; else - player[i].ProfileID = -1; + players[i].ProfileID = -1; } CBase.Songs.AddPartySongSung(songID); diff --git a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs index e733ddb3..89b4b1a0 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs @@ -482,11 +482,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley #region PlayerNames CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce); - SPlayer[] player = CBase.Game.GetPlayers(); - if (player == null) + SPlayer[] players = CBase.Game.GetPlayers(); + if (players == null) return false; - if (player.Length < _GameData.NumPlayerAtOnce) + if (players.Length < _GameData.NumPlayerAtOnce) return false; CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1); @@ -495,9 +495,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley { //try to fill with the right data if (c != null) - player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; + players[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; else - player[i].ProfileID = -1; + players[i].ProfileID = -1; } #endregion PlayerNames diff --git a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs index 4dc7e99f..21e9f455 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs @@ -718,11 +718,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe CBase.Game.SetNumPlayer(2); - SPlayer[] player = CBase.Game.GetPlayers(); - if (player == null) + SPlayer[] players = CBase.Game.GetPlayers(); + if (players == null) return; - if (player.Length < 2) + if (players.Length < 2) return; SProfile[] profiles = CBase.Profiles.GetProfiles(); @@ -732,7 +732,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe for (int i = 0; i < 2; i++) { //default values - player[i].ProfileID = -1; + players[i].ProfileID = -1; } //try to fill with the right data @@ -740,15 +740,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe { if (_GameData.ProfileIDsTeam1[r.SingerTeam1] < profiles.Length) { - player[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1]; + players[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1]; if (isDuet) - player[0].LineNr = 0; + players[0].LineNr = 0; } if (_GameData.ProfileIDsTeam2[r.SingerTeam2] < profiles.Length) { - player[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2]; + players[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2]; if (isDuet) - player[1].LineNr = 1; + players[1].LineNr = 1; } SongSelected(r.SongID); } diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index d8403a9f..672ac815 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -246,15 +246,9 @@ namespace Vocaluxe.Base Players[p].SingLine.Add(new CLine()); CNote[] notes = lines[line].Notes; - int note = -1; - for (int j = 0; j < notes.Length; j++) - { - if (beat >= notes[j].StartBeat && beat <= notes[j].EndBeat) - { - note = j; - break; - } - } + int note = lines[line].FindPreviousNote(beat); + if (notes[note].EndBeat < beat) + note = -1; if (note >= 0) { diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index b2780e53..876464ed 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -52,7 +52,6 @@ namespace Vocaluxe.Base private static bool _SongsLoaded; private static bool _CoverLoaded; - private static int _CoverLoadIndex; private static int _CatIndex = -1; private static readonly List _CategoriesForRandom = new List(); @@ -157,20 +156,17 @@ namespace Vocaluxe.Base if (!SongsLoaded) return -1; - if (_CoverLoadIndex < _Songs.Count) + if (NumSongsWithCoverLoaded < _Songs.Count) { - song = _Songs[_CoverLoadIndex]; - _CoverLoadIndex++; - return _CoverLoadIndex; + song = _Songs[NumSongsWithCoverLoaded]; + NumSongsWithCoverLoaded++; + return NumSongsWithCoverLoaded; } return -2; } - public static int NumSongsWithCoverLoaded - { - get { return _CoverLoadIndex; } - } + public static int NumSongsWithCoverLoaded { get; private set; } public static void SetCoverSmall(int songIndex, STexture texture) { @@ -392,12 +388,11 @@ namespace Vocaluxe.Base foreach (string file in files) { CSong song = CSong.LoadSong(file); - if (song != null) - { - song.ID = _Songs.Count; - if (song.ReadNotes()) - _Songs.Add(song); - } + if (song == null) + continue; + song.ID = _Songs.Count; + if (song.ReadNotes()) + _Songs.Add(song); } CLog.StopBenchmark(2, "Read TXTs"); @@ -460,7 +455,7 @@ namespace Vocaluxe.Base foreach (CSong song in _Songs) { song.LoadSmallCover(); - _CoverLoadIndex++; + NumSongsWithCoverLoaded++; } GC.Collect(); _CoverLoaded = true; diff --git a/Vocaluxe/GameModes/CGameMode.cs b/Vocaluxe/GameModes/CGameMode.cs new file mode 100644 index 00000000..b14830cf --- /dev/null +++ b/Vocaluxe/GameModes/CGameMode.cs @@ -0,0 +1,24 @@ +using Vocaluxe.Base; +using VocaluxeLib.Menu.SongMenu; + +namespace Vocaluxe.GameModes +{ + abstract class CGameMode : IGameMode + { + private CSong _LastSong; + private int _LastSongID; + + public CSong GetSong(int songID) + { + if (songID != _LastSongID) + { + CSong song = CSongs.GetSong(songID); + _LastSong = _PrepareSong(song); + _LastSongID = songID; + } + return _LastSong; + } + + protected abstract CSong _PrepareSong(CSong song); + } +} \ No newline at end of file diff --git a/Vocaluxe/GameModes/CGameModes.cs b/Vocaluxe/GameModes/CGameModes.cs new file mode 100644 index 00000000..18b1b980 --- /dev/null +++ b/Vocaluxe/GameModes/CGameModes.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Vocaluxe.Base; +using VocaluxeLib.Menu; +using VocaluxeLib.Menu.SongMenu; + +namespace Vocaluxe.GameModes +{ + static class CGameModes + { + private static Dictionary _GameModes; + + public static void Init() + { + _GameModes = new Dictionary + { + {EGameMode.TR_GAMEMODE_NORMAL, new CGameModeNormal()}, + {EGameMode.TR_GAMEMODE_DUET, new CGameModeDuet()}, + {EGameMode.TR_GAMEMODE_SHORTSONG, new CGameModeShort()}, + {EGameMode.TR_GAMEMODE_MEDLEY, new CGameModeMedley()} + }; + } + + public static IGameMode Get(EGameMode gameMode) + { + if (_GameModes == null) + return null; + IGameMode result; + if (!_GameModes.TryGetValue(gameMode, out result)) + result = _GameModes[EGameMode.TR_GAMEMODE_NORMAL]; + return result; + } + } + + class CGameModeNormal : CGameMode + { + protected override CSong _PrepareSong(CSong song) + { + return song; + } + } + + class CGameModeDuet : CGameMode + { + protected override CSong _PrepareSong(CSong song) + { + return (song.IsDuet) ? song : null; + } + } + + class CGameModeShort : CGameMode + { + protected override CSong _PrepareSong(CSong song) + { + CSong newSong = new CSong(song) {Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap}; + // set lines to short mode + newSong.Notes.SetMedley(song.Notes.GetVoice(0).Lines[0].FirstNoteBeat, song.ShortEnd); + + return newSong; + } + } + + class CGameModeMedley : CGameMode + { + protected override CSong _PrepareSong(CSong song) + { + CSong newSong = new CSong(song) {Start = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) - song.Medley.FadeInTime + song.Gap}; + if (newSong.Start < 0f) + newSong.Start = 0f; + + newSong.Finish = CGame.GetTimeFromBeats(song.Medley.EndBeat, song.BPM) + song.Medley.FadeOutTime + song.Gap; + + // set lines to medley mode + newSong.Notes.SetMedley(song.Medley.StartBeat, song.Medley.EndBeat); + + return newSong; + } + } +} \ No newline at end of file diff --git a/Vocaluxe/GameModes/IGameMode.cs b/Vocaluxe/GameModes/IGameMode.cs new file mode 100644 index 00000000..940bc1f1 --- /dev/null +++ b/Vocaluxe/GameModes/IGameMode.cs @@ -0,0 +1,9 @@ +using VocaluxeLib.Menu.SongMenu; + +namespace Vocaluxe.GameModes +{ + interface IGameMode + { + CSong GetSong(int songID); + } +} \ No newline at end of file diff --git a/Vocaluxe/Screens/CScreenHighscore.cs b/Vocaluxe/Screens/CScreenHighscore.cs index b8eb3d14..0f3bb0c4 100644 --- a/Vocaluxe/Screens/CScreenHighscore.cs +++ b/Vocaluxe/Screens/CScreenHighscore.cs @@ -219,12 +219,12 @@ namespace Vocaluxe.Screens for (int round = 0; round < points.NumRounds; round++) { - SPlayer[] player = points.GetPlayer(round, CGame.NumPlayer); + SPlayer[] players = points.GetPlayer(round, CGame.NumPlayer); - for (int p = 0; p < player.Length; p++) + for (int p = 0; p < players.Length; p++) { - if (player[p].Points > CSettings.MinScoreForDB && player[p].SongFinished && !CProfiles.IsGuestProfile(player[p].ProfileID)) - _NewEntryIDs.Add(CDataBase.AddScore(player[p])); + if (players[p].Points > CSettings.MinScoreForDB && players[p].SongFinished && !CProfiles.IsGuestProfile(players[p].ProfileID)) + _NewEntryIDs.Add(CDataBase.AddScore(players[p])); } } } diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index e02f912c..57764cac 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -127,31 +127,31 @@ namespace Vocaluxe.Screens public override bool UpdateGame() { - SPlayer[] player = new SPlayer[CGame.NumPlayer]; + SPlayer[] players = new SPlayer[CGame.NumPlayer]; if (_Round != 0) - player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); + players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); else { for (int i = 0; i < CGame.NumRounds; i++) { SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer); - for (int p = 0; p < player.Length; p++) - player[p].Points += points[p].Points; + for (int p = 0; p < players.Length; p++) + players[p].Points += points[p].Points; } - for (int p = 0; p < player.Length; p++) - player[p].Points = (int)(player[p].Points / CGame.NumRounds); + for (int p = 0; p < players.Length; p++) + players[p].Points = (int)(players[p].Points / CGame.NumRounds); } - for (int p = 0; p < player.Length; p++) + for (int p = 0; p < players.Length; p++) { - if (_StaticPointsBarDrawnPoints[p] < player[p].Points) + if (_StaticPointsBarDrawnPoints[p] < players[p].Points) { if (CConfig.ScoreAnimationTime >= 1) { _StaticPointsBarDrawnPoints[p] = (_Timer.ElapsedMilliseconds / 1000f) / CConfig.ScoreAnimationTime * 10000; - if (_StaticPointsBarDrawnPoints[p] > player[p].Points) - _StaticPointsBarDrawnPoints[p] = player[p].Points; + if (_StaticPointsBarDrawnPoints[p] > players[p].Points) + _StaticPointsBarDrawnPoints[p] = players[p].Points; string direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue(); if (direction.ToLower() == "vertical") { @@ -260,7 +260,7 @@ namespace Vocaluxe.Screens private void _UpdateRatings() { CSong song = null; - SPlayer[] player = new SPlayer[CGame.NumPlayer]; + SPlayer[] players = new SPlayer[CGame.NumPlayer]; if (_Round != 0) { song = CGame.GetSong(_Round); @@ -270,7 +270,7 @@ namespace Vocaluxe.Screens _Texts[_TextSong].Text = song.Artist + " - " + song.Title; if (_Points.NumRounds > 1) _Texts[_TextSong].Text += " (" + _Round + "/" + _Points.NumRounds + ")"; - player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); + players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); } else { @@ -278,47 +278,47 @@ namespace Vocaluxe.Screens for (int i = 0; i < CGame.NumRounds; i++) { SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer); - for (int p = 0; p < player.Length; p++) + for (int p = 0; p < players.Length; p++) { if (i < 1) - player[p].ProfileID = points[p].ProfileID; - player[p].Points += points[p].Points; + players[p].ProfileID = points[p].ProfileID; + players[p].Points += points[p].Points; } } - for (int p = 0; p < player.Length; p++) - player[p].Points = (int)Math.Round(player[p].Points / CGame.NumRounds); + for (int p = 0; p < players.Length; p++) + players[p].Points = (int)Math.Round(players[p].Points / CGame.NumRounds); } - for (int p = 0; p < player.Length; p++) + for (int p = 0; p < players.Length; p++) { - string name = CProfiles.GetPlayerName(player[p].ProfileID, p); + string name = CProfiles.GetPlayerName(players[p].ProfileID, p); if (song != null && song.IsDuet) { - if (player[p].LineNr == 0 && song.DuetPart1 != "Part 1") + if (players[p].LineNr == 0 && song.DuetPart1 != "Part 1") name += " (" + song.DuetPart1 + ")"; - else if (player[p].LineNr == 1 && song.DuetPart2 != "Part 2") + else if (players[p].LineNr == 1 && song.DuetPart2 != "Part 2") name += " (" + song.DuetPart2 + ")"; } _Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = name; if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortScore].GetValue()) - _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(player[p].Points)).ToString("0000") + " " + CLanguage.Translate("TR_SCREENSCORE_POINTS"); + _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(players[p].Points)).ToString("0000") + " " + CLanguage.Translate("TR_SCREENSCORE_POINTS"); else - _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(player[p].Points)).ToString("0000"); + _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(players[p].Points)).ToString("0000"); if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortDifficulty].GetValue()) { _Texts[_TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " + - CLanguage.Translate(CProfiles.GetDifficulty(player[p].ProfileID).ToString()); + CLanguage.Translate(CProfiles.GetDifficulty(players[p].ProfileID).ToString()); } else - _Texts[_TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(CProfiles.GetDifficulty(player[p].ProfileID).ToString()); + _Texts[_TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(CProfiles.GetDifficulty(players[p].ProfileID).ToString()); if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortRating].GetValue()) { _Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " + - CLanguage.Translate(_GetRating((int)Math.Round(player[p].Points))); + CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points))); } else - _Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(_GetRating((int)Math.Round(player[p].Points))); + _Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points))); _StaticPointsBarDrawnPoints[p] = 0.0; string direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue(); @@ -331,19 +331,19 @@ namespace Vocaluxe.Screens _Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y - _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H; } - if (CProfiles.IsProfileIDValid(player[p].ProfileID)) - _Statics[_StaticAvatar[p, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[player[p].ProfileID].Avatar.Texture; + if (CProfiles.IsProfileIDValid(players[p].ProfileID)) + _Statics[_StaticAvatar[p, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[players[p].ProfileID].Avatar.Texture; } if (CConfig.ScoreAnimationTime < 1) { for (int p = 0; p < CGame.NumPlayer; p++) { - _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H = ((float)player[p].Points) * (_Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H / 10000); + _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H = ((float)players[p].Points) * (_Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H / 10000); _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.Y = _Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H + _Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y - _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H; - _StaticPointsBarDrawnPoints[p] = player[p].Points; + _StaticPointsBarDrawnPoints[p] = players[p].Points; } } diff --git a/Vocaluxe/SongQueue/CSongQueue.cs b/Vocaluxe/SongQueue/CSongQueue.cs index e8ad77f2..0217fc47 100644 --- a/Vocaluxe/SongQueue/CSongQueue.cs +++ b/Vocaluxe/SongQueue/CSongQueue.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using Vocaluxe.Base; +using Vocaluxe.GameModes; using VocaluxeLib.Menu; using VocaluxeLib.Menu.SongMenu; @@ -43,110 +44,77 @@ namespace Vocaluxe.SongQueue private CPoints _Points; #region Implementation - public virtual void Init() + public void Init() { _SongQueque = new List(); Reset(); + CGameModes.Init(); } - public virtual EGameMode GetCurrentGameMode() + public EGameMode GetCurrentGameMode() { if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count) return _SongQueque[_CurrentSong].GameMode; return EGameMode.TR_GAMEMODE_NORMAL; } - public virtual bool AddVisibleSong(int visibleIndex, EGameMode gameMode) + public bool AddVisibleSong(int visibleIndex, EGameMode gameMode) { - if (CSongs.VisibleSongs.Length > visibleIndex) - { - int songID = CSongs.VisibleSongs[visibleIndex].ID; - if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet) - return false; + return CSongs.VisibleSongs.Length > visibleIndex && _AddSong(CSongs.VisibleSongs[visibleIndex].ID, gameMode); + } - _SongQueque.Add(new SSongQueueEntry(songID, gameMode)); + public bool AddSong(int absoluteIndex, EGameMode gameMode) + { + return CSongs.AllSongs.Length > absoluteIndex && _AddSong(CSongs.AllSongs[absoluteIndex].ID, gameMode); + } + + private bool _AddSong(int songID, EGameMode gameMode) + { + if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet) + return false; + + _SongQueque.Add(new SSongQueueEntry(songID, gameMode)); + return true; + } + + public bool RemoveVisibleSong(int visibleIndex) + { + return CSongs.VisibleSongs.Length > visibleIndex && _RemoveSong(CSongs.VisibleSongs[visibleIndex].ID); + } + + public bool RemoveSong(int absoluteIndex) + { + return CSongs.AllSongs.Length > absoluteIndex && _RemoveSong(CSongs.AllSongs[absoluteIndex].ID); + } + + private bool _RemoveSong(int songID) + { + for (int i = 0; i < _SongQueque.Count; i++) + { + if (_SongQueque[i].SongID != songID) + continue; + _SongQueque.RemoveAt(i); return true; } return false; } - public virtual bool AddSong(int absoluteIndex, EGameMode gameMode) - { - if (CSongs.AllSongs.Length > absoluteIndex) - { - int songID = CSongs.AllSongs[absoluteIndex].ID; - if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet) - return false; - - _SongQueque.Add(new SSongQueueEntry(songID, gameMode)); - return true; - } - return false; - } - - public virtual bool RemoveVisibleSong(int visibleIndex) - { - if (CSongs.VisibleSongs.Length > visibleIndex) - { - int index = -1; - int songID = CSongs.VisibleSongs[visibleIndex].ID; - for (int i = 0; i < _SongQueque.Count; i++) - { - if (_SongQueque[i].SongID == songID) - { - index = i; - break; - } - } - - if (index == -1) - return false; - - _SongQueque.RemoveAt(index); - return true; - } - return false; - } - - public virtual bool RemoveSong(int absoluteIndex) - { - if (CSongs.AllSongs.Length > absoluteIndex) - { - int index = -1; - int songID = CSongs.AllSongs[absoluteIndex].ID; - for (int i = 0; i < _SongQueque.Count; i++) - { - if (_SongQueque[i].SongID == songID) - { - index = i; - break; - } - } - if (index == -1) - return false; - - _SongQueque.RemoveAt(index); - return true; - } - return false; - } - - public virtual void ClearSongs() + public void ClearSongs() { _SongQueque.Clear(); } - public virtual void Reset() + public void Reset() { _CurrentSong = -1; } - public virtual void Start(SPlayer[] player) + public void Start(SPlayer[] players) { - _Points = new CPoints(_SongQueque.Count, player); + _Points = new CPoints(_SongQueque.Count, players); } - public virtual void NextRound(SPlayer[] player) + public void NextRound(SPlayer[] players) { if (_CurrentSong < _SongQueque.Count && _SongQueque.Count > 0) { @@ -155,7 +123,7 @@ namespace Vocaluxe.SongQueue _Points.SetPoints( _CurrentSong, _SongQueque[_CurrentSong].SongID, - player, + players, _SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_MEDLEY, _SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_DUET, _SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_SHORTSONG); @@ -164,56 +132,29 @@ namespace Vocaluxe.SongQueue } } - public virtual bool IsFinished() + public bool IsFinished() { return _CurrentSong == _SongQueque.Count || _SongQueque.Count == 0; } - public virtual int GetCurrentRoundNr() + public int GetCurrentRoundNr() { return _CurrentSong + 1; } - public virtual CSong GetSong() + public CSong GetSong() { if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count) - { - CSong song = CSongs.GetSong(_SongQueque[_CurrentSong].SongID); - song = new CSong(song); - - switch (GetCurrentGameMode()) - { - case EGameMode.TR_GAMEMODE_MEDLEY: - // set medley mode timings - song.Start = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) - song.Medley.FadeInTime + song.Gap; - if (song.Start < 0f) - song.Start = 0f; - - song.Finish = CGame.GetTimeFromBeats(song.Medley.EndBeat, song.BPM) + song.Medley.FadeOutTime + song.Gap; - - // set lines to medley mode - song.Notes.SetMedley(song.Medley.StartBeat, song.Medley.EndBeat); - break; - - case EGameMode.TR_GAMEMODE_SHORTSONG: - song.Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap; - - // set lines to medley mode - song.Notes.SetMedley(song.Notes.GetVoice(0).Lines[0].FirstNoteBeat, song.ShortEnd); - break; - } - - return song; - } + CGameModes.Get(GetCurrentGameMode()).GetSong(_SongQueque[_CurrentSong].SongID); return null; } - public virtual int GetNumSongs() + public int GetNumSongs() { return _SongQueque.Count; } - public virtual CSong GetSong(int num) + public CSong GetSong(int num) { if (num - 1 < _SongQueque.Count && num > 0) return CSongs.GetSong(_SongQueque[num - 1].SongID); @@ -221,7 +162,7 @@ namespace Vocaluxe.SongQueue return null; } - public virtual EGameMode GetGameMode(int num) + public EGameMode GetGameMode(int num) { if (num - 1 < _SongQueque.Count && num > 0) return _SongQueque[num - 1].GameMode; @@ -229,7 +170,7 @@ namespace Vocaluxe.SongQueue return EGameMode.TR_GAMEMODE_NORMAL; } - public virtual CPoints GetPoints() + public CPoints GetPoints() { return _Points; } diff --git a/Vocaluxe/SongQueue/ISongQueue.cs b/Vocaluxe/SongQueue/ISongQueue.cs index 40bf808d..05d48111 100644 --- a/Vocaluxe/SongQueue/ISongQueue.cs +++ b/Vocaluxe/SongQueue/ISongQueue.cs @@ -35,8 +35,8 @@ namespace Vocaluxe.SongQueue void ClearSongs(); void Reset(); - void Start(SPlayer[] player); - void NextRound(SPlayer[] player); + void Start(SPlayer[] players); + void NextRound(SPlayer[] players); bool IsFinished(); int GetCurrentRoundNr(); diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 1e170ebb..e77012f6 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -198,7 +198,10 @@ Form + + + diff --git a/VocaluxeLib/Menu/CPoints.cs b/VocaluxeLib/Menu/CPoints.cs index b9ff4b41..f6ab17fb 100644 --- a/VocaluxeLib/Menu/CPoints.cs +++ b/VocaluxeLib/Menu/CPoints.cs @@ -80,23 +80,23 @@ namespace VocaluxeLib.Menu if (round >= NumRounds) return new SPlayer[1]; - SPlayer[] player = new SPlayer[numPlayer]; + SPlayer[] players = new SPlayer[numPlayer]; - for (int p = 0; p < player.Length; p++) + for (int p = 0; p < players.Length; p++) { - player[p].Points = _Rounds[round, p].Points; - player[p].PointsGoldenNotes = _Rounds[round, p].PointsGoldenNotes; - player[p].PointsLineBonus = _Rounds[round, p].PointsLineBonus; - player[p].SongID = _Rounds[round, p].SongID; - player[p].LineNr = _Rounds[round, p].LineNr; - player[p].Medley = _Rounds[round, p].Medley; - player[p].Duet = _Rounds[round, p].Duet; - player[p].ShortSong = _Rounds[round, p].ShortSong; - player[p].DateTicks = _Rounds[round, p].DateTicks; - player[p].SongFinished = _Rounds[round, p].SongFinished; - player[p].ProfileID = _Rounds[round, p].ProfileID; + players[p].Points = _Rounds[round, p].Points; + players[p].PointsGoldenNotes = _Rounds[round, p].PointsGoldenNotes; + players[p].PointsLineBonus = _Rounds[round, p].PointsLineBonus; + players[p].SongID = _Rounds[round, p].SongID; + players[p].LineNr = _Rounds[round, p].LineNr; + players[p].Medley = _Rounds[round, p].Medley; + players[p].Duet = _Rounds[round, p].Duet; + players[p].ShortSong = _Rounds[round, p].ShortSong; + players[p].DateTicks = _Rounds[round, p].DateTicks; + players[p].SongFinished = _Rounds[round, p].SongFinished; + players[p].ProfileID = _Rounds[round, p].ProfileID; } - return player; + return players; } } } \ No newline at end of file diff --git a/VocaluxeLib/Menu/SingNotes/CNotes.cs b/VocaluxeLib/Menu/SingNotes/CNotes.cs index 0ba6dfb6..0de66cf3 100644 --- a/VocaluxeLib/Menu/SingNotes/CNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CNotes.cs @@ -423,6 +423,7 @@ namespace VocaluxeLib.Menu.SingNotes return _PerfectLine; } + //Find last note with StartBeat<=Beat public int FindPreviousNote(int beat) { //If no notes -> No previous note diff --git a/VocaluxeLib/Menu/SongMenu/CSong.cs b/VocaluxeLib/Menu/SongMenu/CSong.cs index 126a53c7..e4396d48 100644 --- a/VocaluxeLib/Menu/SongMenu/CSong.cs +++ b/VocaluxeLib/Menu/SongMenu/CSong.cs @@ -116,7 +116,6 @@ namespace VocaluxeLib.Menu.SongMenu { private bool _CoverSmallLoaded; private bool _CoverBigLoaded; - private bool _NotesLoaded; private STexture _CoverTextureSmall = new STexture(-1); private STexture _CoverTextureBig = new STexture(-1); @@ -140,18 +139,7 @@ namespace VocaluxeLib.Menu.SongMenu public EAspect VideoAspect = EAspect.Crop; - public bool CoverSmallLoaded - { - get { return _CoverSmallLoaded; } - } - public bool CoverBigLoaded - { - get { return _CoverBigLoaded; } - } - public bool NotesLoaded - { - get { return _NotesLoaded; } - } + public bool NotesLoaded { get; private set; } public STexture CoverTextureSmall { @@ -173,9 +161,7 @@ namespace VocaluxeLib.Menu.SongMenu { get { - if (_CoverBigLoaded) - return _CoverTextureBig; - return _CoverTextureSmall; + return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; } set { @@ -278,7 +264,7 @@ namespace VocaluxeLib.Menu.SongMenu VideoAspect = song.VideoAspect; _CoverSmallLoaded = song._CoverSmallLoaded; _CoverBigLoaded = song._CoverBigLoaded; - _NotesLoaded = song._NotesLoaded; + NotesLoaded = song.NotesLoaded; Artist = song.Artist; Title = song.Title; @@ -619,7 +605,7 @@ namespace VocaluxeLib.Menu.SongMenu private bool _ReadNotes(string filePath, bool forceReload = false) { //Skip loading if already done and no reload is forced - if (_NotesLoaded && !forceReload) + if (NotesLoaded && !forceReload) return true; if (!File.Exists(filePath)) @@ -784,7 +770,7 @@ namespace VocaluxeLib.Menu.SongMenu { _FindRefrain(); _FindShortEnd(); - _NotesLoaded = true; + NotesLoaded = true; if (IsDuet) _CheckDuet(); } From 98ad7a6be08877926df2fc02bbadbfd6f8f5aa5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Sat, 27 Apr 2013 12:28:22 +0200 Subject: [PATCH 03/33] Update for fast-player-selection. Press MB or P to start, use mouse or arrow-keys to choose player, select player with LB or Enter. Use [1..6] or MB to skip a player, RB or escape to abort. I will think about a easy reset-function... --- Vocaluxe/Screens/CScreenNames.cs | 155 ++++++++++++++++++++--------- VocaluxeLib/Menu/CNameSelection.cs | 18 +++- 2 files changed, 125 insertions(+), 48 deletions(-) diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 9f7fc909..16440de2 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -56,8 +56,8 @@ namespace Vocaluxe.Screens private readonly STexture[] _OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer]; private bool _SelectingKeyboardActive; - private bool _SelectingKeyboardUnendless; - private int _SelectingKeyboardPlayerNr; + private bool _SelectingFast; + private int _SelectingFastPlayerNr; private int _SelectedPlayerNr; public override void Init() @@ -137,16 +137,16 @@ namespace Vocaluxe.Screens case Keys.P: if (!_SelectingKeyboardActive) { - _SelectingKeyboardPlayerNr = 1; - _SelectingKeyboardUnendless = true; + _SelectingFastPlayerNr = 1; + _SelectingFast = true; } else { - if (_SelectingKeyboardPlayerNr + 1 <= CGame.NumPlayer) - _SelectingKeyboardPlayerNr++; + if (_SelectingFastPlayerNr + 1 <= CGame.NumPlayer) + _SelectingFastPlayerNr++; else - _SelectingKeyboardPlayerNr = 1; - _NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr); + _SelectingFastPlayerNr = 1; + _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); } break; } @@ -165,13 +165,13 @@ namespace Vocaluxe.Screens { _SelectedPlayerNr = _NameSelections[_NameSelection].Selection; //Update Game-infos with new player - CGame.Players[_SelectingKeyboardPlayerNr - 1].ProfileID = _SelectedPlayerNr; + CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = _SelectedPlayerNr; //Update config for default players. - CConfig.Players[_SelectingKeyboardPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; + CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; CConfig.SaveConfig(); //Update texture and name - _Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture; - _Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; + _Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture; + _Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; //Update profile-warning _CheckPlayers(); //Update Tiles-List @@ -179,14 +179,14 @@ namespace Vocaluxe.Screens _SetInteractionToButton(_Buttons[_ButtonStart]); } //Started selecting with 'P' - if (_SelectingKeyboardUnendless) + if (_SelectingFast) { - if (_SelectingKeyboardPlayerNr == CGame.NumPlayer) + if (_SelectingFastPlayerNr == CGame.NumPlayer) resetSelection = true; else { - _SelectingKeyboardPlayerNr++; - _NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr); + _SelectingFastPlayerNr++; + _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); } } else @@ -224,19 +224,19 @@ namespace Vocaluxe.Screens case Keys.Delete: //Delete profile-selection - CGame.Players[_SelectingKeyboardPlayerNr - 1].ProfileID = -1; + CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = -1; //Update config for default players. - CConfig.Players[_SelectingKeyboardPlayerNr - 1] = String.Empty; + CConfig.Players[_SelectingFastPlayerNr - 1] = String.Empty; CConfig.SaveConfig(); //Update texture and name - _Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = _OriginalPlayerAvatarTextures[_SelectingKeyboardPlayerNr - 1]; - _Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CProfiles.GetPlayerName(-1, _SelectingKeyboardPlayerNr); + _Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = _OriginalPlayerAvatarTextures[_SelectingFastPlayerNr - 1]; + _Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = CProfiles.GetPlayerName(-1, _SelectingFastPlayerNr); //Update profile-warning _CheckPlayers(); //Reset all values - _SelectingKeyboardPlayerNr = 0; + _SelectingFastPlayerNr = 0; _SelectingKeyboardActive = false; - _NameSelections[_NameSelection].KeyboardSelection(false, -1); + _NameSelections[_NameSelection].FastSelection(false, -1); //Update Tiles-List _NameSelections[_NameSelection].UpdateList(); break; @@ -244,32 +244,32 @@ namespace Vocaluxe.Screens case Keys.F10: if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) { - CSelectSlide selectSlideDuetPart = _SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]]; + CSelectSlide selectSlideDuetPart = _SelectSlides[_SelectSlideDuetPlayer[_SelectingFastPlayerNr - 1]]; selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2; //Reset all values - _SelectingKeyboardPlayerNr = 0; + _SelectingFastPlayerNr = 0; _SelectingKeyboardActive = false; - _SelectingKeyboardUnendless = false; - _NameSelections[_NameSelection].KeyboardSelection(false, -1); + _SelectingFast = false; + _NameSelections[_NameSelection].FastSelection(false, -1); _SetInteractionToButton(_Buttons[_ButtonStart]); } break; } if (numberPressed > 0 || resetSelection) { - if (numberPressed == _SelectingKeyboardPlayerNr || resetSelection) + if (numberPressed == _SelectingFastPlayerNr || resetSelection) { //Reset all values - _SelectingKeyboardPlayerNr = 0; + _SelectingFastPlayerNr = 0; _SelectingKeyboardActive = false; - _NameSelections[_NameSelection].KeyboardSelection(false, -1); + _NameSelections[_NameSelection].FastSelection(false, -1); } else if (numberPressed <= CConfig.NumPlayer) { - _SelectingKeyboardPlayerNr = numberPressed; - _NameSelections[_NameSelection].KeyboardSelection(true, numberPressed); + _SelectingFastPlayerNr = numberPressed; + _NameSelections[_NameSelection].FastSelection(true, numberPressed); } - _SelectingKeyboardUnendless = false; + _SelectingFast = false; } } //Normal Keyboard handling @@ -294,32 +294,32 @@ namespace Vocaluxe.Screens case Keys.D1: case Keys.NumPad1: - _SelectingKeyboardPlayerNr = 1; + _SelectingFastPlayerNr = 1; break; case Keys.D2: case Keys.NumPad2: - _SelectingKeyboardPlayerNr = 2; + _SelectingFastPlayerNr = 2; break; case Keys.D3: case Keys.NumPad3: - _SelectingKeyboardPlayerNr = 3; + _SelectingFastPlayerNr = 3; break; case Keys.D4: case Keys.NumPad4: - _SelectingKeyboardPlayerNr = 4; + _SelectingFastPlayerNr = 4; break; case Keys.D5: case Keys.NumPad5: - _SelectingKeyboardPlayerNr = 5; + _SelectingFastPlayerNr = 5; break; case Keys.D6: case Keys.NumPad6: - _SelectingKeyboardPlayerNr = 6; + _SelectingFastPlayerNr = 6; break; default: _UpdatePlayerNumber(); @@ -327,10 +327,10 @@ namespace Vocaluxe.Screens } - if (_SelectingKeyboardPlayerNr > 0 && _SelectingKeyboardPlayerNr <= CConfig.NumPlayer) + if (_SelectingFastPlayerNr > 0 && _SelectingFastPlayerNr <= CConfig.NumPlayer) { _SelectingKeyboardActive = true; - _NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr); + _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); } } @@ -339,10 +339,15 @@ namespace Vocaluxe.Screens public override bool HandleMouse(SMouseEvent mouseEvent) { - base.HandleMouse(mouseEvent); + bool stopSelectingFast = false; + + if (_SelectingFast) + _NameSelections[_NameSelection].HandleMouse(mouseEvent); + else + base.HandleMouse(mouseEvent); //Check if LeftButton is hold and Select-Mode inactive - if (mouseEvent.LBH && _SelectedPlayerNr < 0) + if (mouseEvent.LBH && _SelectedPlayerNr < 0 && !_SelectingFast) { //Save mouse-coords _OldMouseX = mouseEvent.X; @@ -366,7 +371,7 @@ namespace Vocaluxe.Screens } //Check if LeftButton is hold and Select-Mode active - if (mouseEvent.LBH && _SelectedPlayerNr >= 0) + if (mouseEvent.LBH && _SelectedPlayerNr >= 0 && !_SelectingFast) { //Update coords for Drag/Drop-Texture _ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX; @@ -374,8 +379,8 @@ namespace Vocaluxe.Screens _OldMouseX = mouseEvent.X; _OldMouseY = mouseEvent.Y; } - // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar - else if (_SelectedPlayerNr >= 0) + // LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar + else if (_SelectedPlayerNr >= 0 && !_SelectingFast) { //Foreach Drop-Area for (int i = 0; i < _StaticPlayer.Length; i++) @@ -405,7 +410,37 @@ namespace Vocaluxe.Screens _ChooseAvatarStatic.Visible = false; } - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _SelectingFast) + { + if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) + { + //Get player-number of tile + _SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); + if (_SelectedPlayerNr != -1) + { + //Update Game-infos with new player + CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = _SelectedPlayerNr; + //Update config for default players. + CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; + CConfig.SaveConfig(); + //Update texture and name + _Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture; + _Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; + //Update profile-warning + _CheckPlayers(); + //Update Tiles-List + _NameSelections[_NameSelection].UpdateList(); + _SelectingFastPlayerNr++; + if (_SelectingFastPlayerNr <= CGame.NumPlayer) + _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); + else + stopSelectingFast = true; + } + else + stopSelectingFast = true; + } + } + else if (mouseEvent.LB && _IsMouseOver(mouseEvent)) { if (_Buttons[_ButtonBack].Selected) CGraphics.FadeTo(EScreens.ScreenSong); @@ -417,7 +452,9 @@ namespace Vocaluxe.Screens _NameSelections[_NameSelection].UpdateList(); } - if (mouseEvent.RB) + if (mouseEvent.RB && _SelectingFast) + stopSelectingFast = true; + else if (mouseEvent.RB) { bool exit = true; //Remove profile-selection @@ -443,6 +480,22 @@ namespace Vocaluxe.Screens CGraphics.FadeTo(EScreens.ScreenSong); } + if (mouseEvent.MB && _SelectingFast) + { + _SelectingFastPlayerNr++; + if (_SelectingFastPlayerNr <= CGame.NumPlayer) + _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); + else + stopSelectingFast = true; + } + else if(mouseEvent.MB) + { + _SelectingFast = true; + _SelectingFastPlayerNr = 1; + _SelectingKeyboardActive = true; + _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); + } + //Check mouse-wheel for scrolling if (mouseEvent.Wheel != 0) { @@ -452,6 +505,14 @@ namespace Vocaluxe.Screens _NameSelections[_NameSelection].UpdateList(offset); } } + + if (stopSelectingFast) + { + _SelectingFast = false; + _SelectingFastPlayerNr = 0; + _SelectingKeyboardActive = false; + _NameSelections[_NameSelection].FastSelection(false, -1); + } return true; } diff --git a/VocaluxeLib/Menu/CNameSelection.cs b/VocaluxeLib/Menu/CNameSelection.cs index aeea2e33..2888d8ea 100644 --- a/VocaluxeLib/Menu/CNameSelection.cs +++ b/VocaluxeLib/Menu/CNameSelection.cs @@ -346,7 +346,23 @@ namespace VocaluxeLib.Menu Selection = -1; } - public void KeyboardSelection(bool active, int player) + public void HandleMouse(SMouseEvent mevent) + { + for (int i = 0; i < _Tiles.Count; i++ ) + { + if (CHelper.IsInBounds(_Tiles[i].Avatar.Rect, mevent)) + { + _ActualSelection = i; + + if (Offset * _Tiles.Count + _ActualSelection < _VisibleProfiles.Count) + Selection = _VisibleProfiles[Offset * _Tiles.Count + _ActualSelection]; + else + Selection = -1; + } + } + } + + public void FastSelection(bool active, int player) { //Overwrite player-selection; Same profile, but other player if (active && Selection != -1) From d2516d4ad013c22669c398ae511b8fc7360a4229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Sat, 27 Apr 2013 16:38:22 +0200 Subject: [PATCH 04/33] Double click on profile to use it for next free player. --- Vocaluxe/Screens/CScreenNames.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 16440de2..16642327 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -452,6 +452,33 @@ namespace Vocaluxe.Screens _NameSelections[_NameSelection].UpdateList(); } + if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast) + { + _SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); + if (_SelectedPlayerNr > -1) + { + for (int i = 0; i < CGame.NumPlayer; i++) + { + if (CGame.Players[i].ProfileID == -1) + { + //Update Game-infos with new player + CGame.Players[i].ProfileID = _SelectedPlayerNr; + //Update config for default players. + CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; + CConfig.SaveConfig(); + //Update texture and name + _Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture; + _Texts[_TextPlayer[i]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; + //Update profile-warning + _CheckPlayers(); + //Update Tiles-List + _NameSelections[_NameSelection].UpdateList(); + break; + } + } + } + } + if (mouseEvent.RB && _SelectingFast) stopSelectingFast = true; else if (mouseEvent.RB) From d3c33764a22ad6f0531fc6cad3d76083eb169442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Sat, 27 Apr 2013 17:03:40 +0200 Subject: [PATCH 05/33] Added drag'n'drop for selected profiles for easier switching and unsetting. --- Vocaluxe/Screens/CScreenNames.cs | 57 ++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 16642327..e104e317 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -57,8 +57,9 @@ namespace Vocaluxe.Screens private bool _SelectingKeyboardActive; private bool _SelectingFast; - private int _SelectingFastPlayerNr; - private int _SelectedPlayerNr; + private int _SelectingSwitchNr = -1; + private int _SelectingFastPlayerNr = 0; + private int _SelectedPlayerNr = -1; public override void Init() { @@ -368,6 +369,25 @@ namespace Vocaluxe.Screens _ChooseAvatarStatic.Texture = selectedPlayer.Texture; } } + else + { + for (int i = 0; i < CGame.NumPlayer; i++) + { + if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) + { + _SelectingSwitchNr = i; + _SelectedPlayerNr = CGame.Players[i].ProfileID; + //Update of Drag/Drop-Texture + CStatic selectedPlayer = _Statics[_StaticPlayerAvatar[i]]; + _ChooseAvatarStatic.Visible = true; + _ChooseAvatarStatic.Rect = selectedPlayer.Rect; + _ChooseAvatarStatic.Rect.Z = CSettings.ZNear; + _ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1); + _ChooseAvatarStatic.Texture = selectedPlayer.Texture; + break; + } + } + } } //Check if LeftButton is hold and Select-Mode active @@ -391,6 +411,26 @@ namespace Vocaluxe.Screens //Check if Mouse is in area if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) { + if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID > -1) + { + //Update Game-infos with new player + CGame.Players[_SelectingSwitchNr].ProfileID = CGame.Players[i].ProfileID; + //Update config for default players. + CConfig.Players[_SelectingSwitchNr] = CProfiles.Profiles[i].ProfileFile; + //Update texture and name + _Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = CProfiles.Profiles[CGame.Players[i].ProfileID].Avatar.Texture; + _Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.Profiles[CGame.Players[i].ProfileID].PlayerName; + } + else if (_SelectingSwitchNr > -1) + { + //Update Game-infos with new player + CGame.Players[_SelectingSwitchNr].ProfileID = -1; + //Update config for default players. + CConfig.Players[_SelectingSwitchNr] = string.Empty; + //Update texture and name + _Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = _OriginalPlayerAvatarTextures[_SelectingSwitchNr]; + _Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.GetPlayerName(-1, (_SelectingSwitchNr+1)); + } //Update Game-infos with new player CGame.Players[i].ProfileID = _SelectedPlayerNr; //Update config for default players. @@ -403,8 +443,21 @@ namespace Vocaluxe.Screens _CheckPlayers(); //Update Tiles-List _NameSelections[_NameSelection].UpdateList(); + break; + } + //Selected player is dropped out of area + else if (_SelectingSwitchNr > -1) + { + //Update Game-infos with new player + CGame.Players[_SelectingSwitchNr].ProfileID = -1; + //Update config for default players. + CConfig.Players[_SelectingSwitchNr] = string.Empty; + //Update texture and name + _Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = _OriginalPlayerAvatarTextures[_SelectingSwitchNr]; + _Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.GetPlayerName(-1, (_SelectingSwitchNr + 1)); } } + _SelectingSwitchNr = -1; _SelectedPlayerNr = -1; //Reset variables _ChooseAvatarStatic.Visible = false; From 3232a1e98929e02f2d67ea63fba9b501edea7105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Sat, 27 Apr 2013 17:50:02 +0200 Subject: [PATCH 06/33] Reset selected players before activating fast-selection. --- Vocaluxe/Screens/CScreenNames.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index e104e317..99006246 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -140,6 +140,7 @@ namespace Vocaluxe.Screens { _SelectingFastPlayerNr = 1; _SelectingFast = true; + _ResetPlayerSelections(); } else { @@ -570,6 +571,7 @@ namespace Vocaluxe.Screens } else if(mouseEvent.MB) { + _ResetPlayerSelections(); _SelectingFast = true; _SelectingFastPlayerNr = 1; _SelectingKeyboardActive = true; @@ -706,6 +708,21 @@ namespace Vocaluxe.Screens _CheckPlayers(); } + private void _ResetPlayerSelections() + { + for (int i = 0; i < CGame.NumPlayer; i++) + { + CGame.Players[i].ProfileID = -1; + //Update config for default players. + CConfig.Players[i] = String.Empty; + //Update texture and name + _Statics[_StaticPlayerAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i]; + _Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(-1, i + 1); + } + _NameSelections[_NameSelection].UpdateList(); + CConfig.SaveConfig(); + } + private void _CheckMics() { List playerWithoutMicro = new List(); From bad6b272459191cdd688031bb36c97abc870055f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Sun, 28 Apr 2013 10:15:40 +0200 Subject: [PATCH 07/33] Fixed webcam-image-aspect on ScreenProfiles. --- Vocaluxe/Screens/CScreenProfiles.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Vocaluxe/Screens/CScreenProfiles.cs b/Vocaluxe/Screens/CScreenProfiles.cs index 87ff1d71..b3c3740e 100644 --- a/Vocaluxe/Screens/CScreenProfiles.cs +++ b/Vocaluxe/Screens/CScreenProfiles.cs @@ -314,11 +314,9 @@ namespace Vocaluxe.Screens { if (_Snapshot == null) CWebcam.GetFrame(ref _WebcamTexture); - _Statics[_StaticAvatar].Texture = _WebcamTexture; - RectangleF bounds = new RectangleF(_WebcamTexture.Rect.X, _WebcamTexture.Rect.Y, _WebcamTexture.Rect.W, _WebcamTexture.Rect.H); - RectangleF rect = new RectangleF(0f, 0f, _WebcamTexture.Rect.W, _WebcamTexture.Rect.H); - CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, EAspect.Crop); + _Statics[_StaticAvatar].Aspect = EAspect.Crop; + _Statics[_StaticAvatar].Texture = _WebcamTexture; } else _Statics[_StaticAvatar].Texture = CProfiles.Avatars[avatarNr].Texture; From 5f28c5a10316da334afdb4dd54bcb73a46faf104 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 12:23:10 +0200 Subject: [PATCH 08/33] Fixed DX Close Bug and some typos closes #15 --- .../CPartyModeChallengeMedley.cs | 4 +- Vocaluxe/Base/CDataBase.cs | 4 +- Vocaluxe/Base/CDraw.cs | 4 +- Vocaluxe/Base/CSongs.cs | 2 +- Vocaluxe/Lib/Draw/CDirect3D.cs | 33 +++++++------ Vocaluxe/Lib/Draw/CDrawWinForm.cs | 2 +- Vocaluxe/Lib/Draw/COpenGL.cs | 30 ++++++------ Vocaluxe/Lib/Draw/IDraw.cs | 2 +- Vocaluxe/Screens/CScreenSing.cs | 6 +-- Vocaluxe/SongQueue/CSongQueue.cs | 46 +++++++++---------- 10 files changed, 69 insertions(+), 64 deletions(-) diff --git a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs index 89b4b1a0..cd0e61f3 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs @@ -501,7 +501,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley } #endregion PlayerNames - #region SongQueque + #region SongQueue if (CBase.Songs.GetNumVisibleSongs() < _NumSongs) CBase.Songs.ResetPartySongSung(); @@ -542,7 +542,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley s++; } return true; - #endregion SongQueque + #endregion SongQueue } private void _SetNumJokers() diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index da72c5b6..7d9ecdda 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -956,7 +956,7 @@ namespace Vocaluxe.Base reader.Read(); byte[] data = _GetBytes(reader); reader.Dispose(); - tex = CDraw.QuequeTexture(w, h, ref data); + tex = CDraw.EnqueueTexture(w, h, ref data); return true; } } @@ -1006,7 +1006,7 @@ namespace Vocaluxe.Base origin.Dispose(); } - tex = CDraw.QuequeTexture(w, h, ref data); + tex = CDraw.EnqueueTexture(w, h, ref data); command.CommandText = "INSERT INTO Cover (Path, width, height) VALUES (@path, @w, @h)"; command.Parameters.Add("@w", DbType.Int32).Value = w; diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs index bc843f7f..0bed36e9 100644 --- a/Vocaluxe/Base/CDraw.cs +++ b/Vocaluxe/Base/CDraw.cs @@ -211,9 +211,9 @@ namespace Vocaluxe.Base return _Draw.AddTexture(w, h, ref data); } - public static STexture QuequeTexture(int w, int h, ref byte[] data) + public static STexture EnqueueTexture(int w, int h, ref byte[] data) { - return _Draw.QuequeTexture(w, h, ref data); + return _Draw.EnqueueTexture(w, h, ref data); } public static bool UpdateTexture(ref STexture texture, ref byte[] data) diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 876464ed..c498eafb 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -418,7 +418,7 @@ namespace Vocaluxe.Base public static void LoadCover() { if (CConfig.Renderer == ERenderer.TR_CONFIG_SOFTWARE) - return; //should be removed as soon as the other renderer are ready for queque + return; //should be removed as soon as the other renderer are ready for queue if (!SongsLoaded || CoverLoaded) return; diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 53cca0ac..7a084bca 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -29,12 +29,13 @@ using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; +using SlimDX.Windows; using Vocaluxe.Base; using VocaluxeLib.Menu; namespace Vocaluxe.Lib.Draw { - class CDirect3D : Form, IDraw + class CDirect3D : RenderForm, IDraw { #region private vars private readonly CKeys _Keys; @@ -51,7 +52,7 @@ namespace Vocaluxe.Lib.Draw private readonly Dictionary _Textures; private readonly Dictionary _D3DTextures; - private readonly List _Queque; + private readonly List _Queue; private readonly Queue _IDs; private readonly Object _MutexTexture = new Object(); @@ -81,7 +82,7 @@ namespace Vocaluxe.Lib.Draw Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon)); _Textures = new Dictionary(); _D3DTextures = new Dictionary(); - _Queque = new List(); + _Queue = new List(); _IDs = new Queue(); //Fill Queue with 100000 IDs @@ -97,7 +98,7 @@ namespace Vocaluxe.Lib.Draw { _D3D = new Direct3D(); } - catch (Direct3D9NotFoundException e) + catch (Direct3DX9NotFoundException e) { MessageBox.Show("No DirectX runtimes were found, please download and install them " + "from http://www.microsoft.com/download/en/details.aspx?id=8109", @@ -515,13 +516,15 @@ namespace Vocaluxe.Lib.Draw //We want to begin drawing if (_Device.BeginScene().IsFailure) CLog.LogError("Failed to begin scene"); - _CheckQueque(); - _Run = _Run && CGraphics.Draw(); + _CheckQueue(); + if (!CGraphics.Draw()) + _Run = false; _RenderVertexBuffer(); //We finished drawing the frame if (_Device.EndScene().IsFailure) CLog.LogError("Failed to end scene"); - _Run = CGraphics.UpdateGameLogic(_Keys, _Mouse); + if (!CGraphics.UpdateGameLogic(_Keys, _Mouse)) + _Run = false; try { //Now push the frame to the Viewport @@ -1010,10 +1013,10 @@ namespace Vocaluxe.Lib.Draw return t; } - public STexture QuequeTexture(int w, int h, ref byte[] data) + public STexture EnqueueTexture(int w, int h, ref byte[] data) { STexture texture = new STexture(-1); - STextureQueque queque = new STextureQueque {Data = data, Height = h, Width = w}; + STextureQueue queue = new STextureQueue {Data = data, Height = h, Width = w}; texture.Height = h; texture.Width = w; @@ -1022,8 +1025,8 @@ namespace Vocaluxe.Lib.Draw { _D3DTextures.Add(_IDs.Peek(), null); texture.Index = _IDs.Dequeue(); - queque.ID = texture.Index; - _Queque.Add(queque); + queue.ID = texture.Index; + _Queue.Add(queue); _Textures[texture.Index] = texture; } return texture; @@ -1405,14 +1408,14 @@ namespace Vocaluxe.Lib.Draw } #endregion drawing - private void _CheckQueque() + private void _CheckQueue() { lock (_MutexTexture) { - if (_Queque.Count == 0) + if (_Queue.Count == 0) return; - STextureQueque q = _Queque[0]; + STextureQueue q = _Queue[0]; STexture texture; if (_Textures.ContainsKey(q.ID)) texture = _Textures[q.ID]; @@ -1423,7 +1426,7 @@ namespace Vocaluxe.Lib.Draw _D3DTextures[q.ID] = t; _Textures[texture.Index] = texture; - _Queque.RemoveAt(0); + _Queue.RemoveAt(0); } } diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs index 78203ff0..cb79cbc2 100644 --- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs +++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs @@ -418,7 +418,7 @@ namespace Vocaluxe.Lib.Draw return new STexture(-1); } - public STexture QuequeTexture(int w, int h, ref byte[] data) + public STexture EnqueueTexture(int w, int h, ref byte[] data) { return AddTexture(w, h, ref data); } diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index 54056001..13ee6f35 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -41,7 +41,7 @@ namespace Vocaluxe.Lib.Draw public int Height; }; - struct STextureQueque + struct STextureQueue { public int ID; public int Width; @@ -63,7 +63,7 @@ namespace Vocaluxe.Lib.Draw private readonly Dictionary _Textures; private readonly Queue _IDs; - private readonly List _Queque; + private readonly List _Queue; private readonly Object _MutexTexture = new Object(); @@ -80,7 +80,7 @@ namespace Vocaluxe.Lib.Draw Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon)); _Textures = new Dictionary(); - _Queque = new List(); + _Queue = new List(); _IDs = new Queue(1000000); for (int i = 1; i < 1000000; i++) @@ -412,15 +412,17 @@ namespace Vocaluxe.Lib.Draw if (_Run) { ClearScreen(); - _Run = _Run && CGraphics.Draw(); + if (!CGraphics.Draw()) + _Run = false; + if (!CGraphics.UpdateGameLogic(_Keys, _Mouse)) + _Run = false; - _Run = CGraphics.UpdateGameLogic(_Keys, _Mouse); _Control.SwapBuffers(); if ((CSettings.IsFullScreen && !_Fullscreen) || (!CSettings.IsFullScreen && _Fullscreen)) _ToggleFullScreen(); - _CheckQueque(); + _CheckQueue(); if (CTime.IsRunning()) delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds()); @@ -907,10 +909,10 @@ namespace Vocaluxe.Lib.Draw return texture; } - public STexture QuequeTexture(int w, int h, ref byte[] data) + public STexture EnqueueTexture(int w, int h, ref byte[] data) { STexture texture = new STexture(-1); - STextureQueque queque = new STextureQueque {Data = data, Height = h, Width = w}; + STextureQueue queue = new STextureQueue {Data = data, Height = h, Width = w}; texture.Height = h; texture.Width = w; @@ -918,8 +920,8 @@ namespace Vocaluxe.Lib.Draw lock (_MutexTexture) { texture.Index = _IDs.Dequeue(); - queque.ID = texture.Index; - _Queque.Add(queque); + queue.ID = texture.Index; + _Queue.Add(queue); _Textures[texture.Index] = texture; } @@ -1333,14 +1335,14 @@ namespace Vocaluxe.Lib.Draw return _Textures.Count; } - private void _CheckQueque() + private void _CheckQueue() { lock (_MutexTexture) { - if (_Queque.Count == 0) + if (_Queue.Count == 0) return; - STextureQueque q = _Queque[0]; + STextureQueue q = _Queue[0]; STexture texture = new STexture(-1); if (_Textures.ContainsKey(q.ID)) texture = _Textures[q.ID]; @@ -1407,7 +1409,7 @@ namespace Vocaluxe.Lib.Draw _Textures[texture.Index] = texture; q.Data = null; - _Queque.RemoveAt(0); + _Queue.RemoveAt(0); } } #endregion Textures diff --git a/Vocaluxe/Lib/Draw/IDraw.cs b/Vocaluxe/Lib/Draw/IDraw.cs index 6da270b0..1230145c 100644 --- a/Vocaluxe/Lib/Draw/IDraw.cs +++ b/Vocaluxe/Lib/Draw/IDraw.cs @@ -52,7 +52,7 @@ namespace Vocaluxe.Lib.Draw STexture AddTexture(Bitmap bitmap); STexture AddTexture(int w, int h, IntPtr data); STexture AddTexture(int w, int h, ref byte[] data); - STexture QuequeTexture(int w, int h, ref byte[] data); + STexture EnqueueTexture(int w, int h, ref byte[] data); bool UpdateTexture(ref STexture texture, ref byte[] data); bool UpdateTexture(ref STexture texture, IntPtr data); diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 119e5406..2a00110a 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -948,9 +948,9 @@ namespace Vocaluxe.Screens private void _UpdateMedleyCountdown() { - if (CGame.GetSong() != null) - { - CSong song = CGame.GetSong(); + CSong song = CGame.GetSong(); + if (song != null) + { float currentTime = _CurrentTime - song.Start; float timeToFirstMedleyNote = (CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) + song.Gap - song.Start); if (currentTime < timeToFirstMedleyNote && CGame.GameMode == EGameMode.TR_GAMEMODE_MEDLEY) diff --git a/Vocaluxe/SongQueue/CSongQueue.cs b/Vocaluxe/SongQueue/CSongQueue.cs index 0217fc47..30f6f509 100644 --- a/Vocaluxe/SongQueue/CSongQueue.cs +++ b/Vocaluxe/SongQueue/CSongQueue.cs @@ -39,22 +39,22 @@ namespace Vocaluxe.SongQueue class CSongQueue : ISongQueue { - private List _SongQueque; + private List _SongQueue; private int _CurrentSong; private CPoints _Points; #region Implementation public void Init() { - _SongQueque = new List(); + _SongQueue = new List(); Reset(); CGameModes.Init(); } public EGameMode GetCurrentGameMode() { - if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count) - return _SongQueque[_CurrentSong].GameMode; + if (_CurrentSong >= 0 && _CurrentSong < _SongQueue.Count) + return _SongQueue[_CurrentSong].GameMode; return EGameMode.TR_GAMEMODE_NORMAL; } @@ -73,7 +73,7 @@ namespace Vocaluxe.SongQueue if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet) return false; - _SongQueque.Add(new SSongQueueEntry(songID, gameMode)); + _SongQueue.Add(new SSongQueueEntry(songID, gameMode)); return true; } @@ -89,11 +89,11 @@ namespace Vocaluxe.SongQueue private bool _RemoveSong(int songID) { - for (int i = 0; i < _SongQueque.Count; i++) + for (int i = 0; i < _SongQueue.Count; i++) { - if (_SongQueque[i].SongID != songID) + if (_SongQueue[i].SongID != songID) continue; - _SongQueque.RemoveAt(i); + _SongQueue.RemoveAt(i); return true; } return false; @@ -101,7 +101,7 @@ namespace Vocaluxe.SongQueue public void ClearSongs() { - _SongQueque.Clear(); + _SongQueue.Clear(); } public void Reset() @@ -111,22 +111,22 @@ namespace Vocaluxe.SongQueue public void Start(SPlayer[] players) { - _Points = new CPoints(_SongQueque.Count, players); + _Points = new CPoints(_SongQueue.Count, players); } public void NextRound(SPlayer[] players) { - if (_CurrentSong < _SongQueque.Count && _SongQueque.Count > 0) + if (_CurrentSong < _SongQueue.Count && _SongQueue.Count > 0) { if (_CurrentSong > -1) { _Points.SetPoints( _CurrentSong, - _SongQueque[_CurrentSong].SongID, + _SongQueue[_CurrentSong].SongID, players, - _SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_MEDLEY, - _SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_DUET, - _SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_SHORTSONG); + _SongQueue[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_MEDLEY, + _SongQueue[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_DUET, + _SongQueue[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_SHORTSONG); } _CurrentSong++; } @@ -134,7 +134,7 @@ namespace Vocaluxe.SongQueue public bool IsFinished() { - return _CurrentSong == _SongQueque.Count || _SongQueque.Count == 0; + return _CurrentSong == _SongQueue.Count || _SongQueue.Count == 0; } public int GetCurrentRoundNr() @@ -144,28 +144,28 @@ namespace Vocaluxe.SongQueue public CSong GetSong() { - if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count) - CGameModes.Get(GetCurrentGameMode()).GetSong(_SongQueque[_CurrentSong].SongID); + if (_CurrentSong >= 0 && _CurrentSong < _SongQueue.Count) + CGameModes.Get(GetCurrentGameMode()).GetSong(_SongQueue[_CurrentSong].SongID); return null; } public int GetNumSongs() { - return _SongQueque.Count; + return _SongQueue.Count; } public CSong GetSong(int num) { - if (num - 1 < _SongQueque.Count && num > 0) - return CSongs.GetSong(_SongQueque[num - 1].SongID); + if (num - 1 < _SongQueue.Count && num > 0) + return CSongs.GetSong(_SongQueue[num - 1].SongID); return null; } public EGameMode GetGameMode(int num) { - if (num - 1 < _SongQueque.Count && num > 0) - return _SongQueque[num - 1].GameMode; + if (num - 1 < _SongQueue.Count && num > 0) + return _SongQueue[num - 1].GameMode; return EGameMode.TR_GAMEMODE_NORMAL; } From 5cea9e6775d55e2f265ddb1f29ae45641a03c400 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 13:12:45 +0200 Subject: [PATCH 09/33] Added better playlist Open-Option Fixed Bug with GameModes --- Vocaluxe/GameModes/CGameMode.cs | 2 +- Vocaluxe/Screens/CScreenSong.cs | 35 ++++++++++++-------------------- Vocaluxe/SongQueue/CSongQueue.cs | 2 +- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/Vocaluxe/GameModes/CGameMode.cs b/Vocaluxe/GameModes/CGameMode.cs index b14830cf..c246c3f0 100644 --- a/Vocaluxe/GameModes/CGameMode.cs +++ b/Vocaluxe/GameModes/CGameMode.cs @@ -6,7 +6,7 @@ namespace Vocaluxe.GameModes abstract class CGameMode : IGameMode { private CSong _LastSong; - private int _LastSongID; + private int _LastSongID = -1; public CSong GetSong(int songID) { diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 852e6ebb..6f0d83b7 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -338,7 +338,9 @@ namespace Vocaluxe.Screens else if (_Buttons[_ButtonOptionsOpenSelectedItem].Selected) _HandleSelectButton(); else if (_SelectSlides[_SelectSlideOptionsPlaylistOpen].Selected) - _OpenPlaylistAction(); + _OpenPlaylist(_SelectSlides[_SelectSlideOptionsPlaylistOpen].Selection); + else if (_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selected) + _OpenPlaylist(_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection - 1); else if (_Buttons[_ButtonOptionsRandomMedley].Selected) _ToggleSongOptions(ESongOptionsView.Medley); else if (_Buttons[_ButtonOptionsStartMedley].Selected) @@ -515,7 +517,12 @@ namespace Vocaluxe.Screens } else if (_SelectSlides[_SelectSlideOptionsPlaylistOpen].ValueSelected) { - _OpenPlaylistAction(); + _OpenPlaylist(_SelectSlides[_SelectSlideOptionsPlaylistOpen].Selection); + return true; + } + else if (_SelectSlides[_SelectSlideOptionsPlaylistAdd].ValueSelected) + { + _OpenPlaylist(_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection - 1); return true; } else if (_Buttons[_ButtonOptionsRandomMedley].Selected) @@ -832,15 +839,12 @@ namespace Vocaluxe.Screens { if ((CSongs.Category >= 0) && (songNr >= 0)) { - EGameMode gm; - if (CSongs.VisibleSongs[songNr].Medley.Source != EMedleySource.None) - gm = EGameMode.TR_GAMEMODE_MEDLEY; - else + if (CSongs.VisibleSongs[songNr].Medley.Source == EMedleySource.None) return; CGame.Reset(); CGame.ClearSongs(); - CGame.AddVisibleSong(songNr, gm); + CGame.AddVisibleSong(songNr, EGameMode.TR_GAMEMODE_MEDLEY); CGraphics.FadeTo(EScreens.ScreenNames); } @@ -1097,7 +1101,6 @@ namespace Vocaluxe.Screens EGameMode lastMode = EGameMode.TR_GAMEMODE_NORMAL; if (_AvailableGameModes.Count > 0) lastMode = _AvailableGameModes[_SelectSlides[_SelectSlideOptionsMode].Selection]; - _SetInteractionToButton(_Buttons[_ButtonOptionsSing]); _AvailableGameModes.Clear(); _SelectSlides[_SelectSlideOptionsMode].Clear(); if (CSongs.VisibleSongs[_SongMenus[_SongMenu].GetSelectedSong()].IsDuet) @@ -1183,11 +1186,12 @@ namespace Vocaluxe.Screens private void _OpenPlaylist(int playlistID) { - if (CPlaylists.Playlists.Length > playlistID && playlistID > -1) + if (CPlaylists.Playlists.Length > playlistID && playlistID >= 0) { _Playlists[_Playlist].LoadPlaylist(playlistID); _SongMenus[_SongMenu].SetSmallView(true); _Playlists[_Playlist].Visible = true; + _SetSelectSlidePlaylistToCurrentPlaylist(); } } @@ -1212,19 +1216,6 @@ namespace Vocaluxe.Screens _SelectSlides[_SelectSlideOptionsPlaylistOpen].AddValues(CPlaylists.PlaylistNames); } - private void _OpenPlaylistAction() - { - //Open a playlist - if (_Playlists[_Playlist].ActivePlaylistID != _SelectSlides[_SelectSlideOptionsPlaylistOpen].Selection) - { - _Playlists[_Playlist].ActivePlaylistID = _SelectSlides[_SelectSlideOptionsPlaylistOpen].Selection; - _SetSelectSlidePlaylistToCurrentPlaylist(); - - //Open playlist - _OpenPlaylist(_Playlists[_Playlist].ActivePlaylistID); - } - } - private void _OpenAndAddPlaylistAction() { //Open an existing playlist and add song diff --git a/Vocaluxe/SongQueue/CSongQueue.cs b/Vocaluxe/SongQueue/CSongQueue.cs index 30f6f509..62a3814c 100644 --- a/Vocaluxe/SongQueue/CSongQueue.cs +++ b/Vocaluxe/SongQueue/CSongQueue.cs @@ -145,7 +145,7 @@ namespace Vocaluxe.SongQueue public CSong GetSong() { if (_CurrentSong >= 0 && _CurrentSong < _SongQueue.Count) - CGameModes.Get(GetCurrentGameMode()).GetSong(_SongQueue[_CurrentSong].SongID); + return CGameModes.Get(_SongQueue[_CurrentSong].GameMode).GetSong(_SongQueue[_CurrentSong].SongID); return null; } From 5bc9044d895ef9abb1dfbf9fc36a467dac26a824 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 13:17:58 +0200 Subject: [PATCH 10/33] Bugfix for index check in Points calculation --- Vocaluxe/Base/CGame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index 672ac815..58bc9c2d 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -247,7 +247,7 @@ namespace Vocaluxe.Base CNote[] notes = lines[line].Notes; int note = lines[line].FindPreviousNote(beat); - if (notes[note].EndBeat < beat) + if (note >= 0 && notes[note].EndBeat < beat) note = -1; if (note >= 0) From 6634e4081d514892fdc7edba1791cc9aec1aa6fe Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 13:33:18 +0200 Subject: [PATCH 11/33] Some small optimizing to medley countdown --- Vocaluxe/Screens/CScreenSing.cs | 44 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 2a00110a..42eb3de7 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -450,8 +450,6 @@ namespace Vocaluxe.Screens { if (_Active) { - _UpdateMedleyCountdown(); - if (_CurrentVideo != -1 && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam) { RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH); @@ -517,7 +515,10 @@ namespace Vocaluxe.Screens _DrawLyricHelper(); if (CGame.GameMode == EGameMode.TR_GAMEMODE_MEDLEY) + { + _UpdateMedleyCountdown(); _Texts[_TextMedleyCountdown].Draw(); + } if (_Pause) { @@ -949,27 +950,26 @@ namespace Vocaluxe.Screens private void _UpdateMedleyCountdown() { CSong song = CGame.GetSong(); - if (song != null) - { - float currentTime = _CurrentTime - song.Start; - float timeToFirstMedleyNote = (CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) + song.Gap - song.Start); - if (currentTime < timeToFirstMedleyNote && CGame.GameMode == EGameMode.TR_GAMEMODE_MEDLEY) - { - float timeDiff = timeToFirstMedleyNote - currentTime + 1; - double t = timeDiff - Math.Truncate(timeDiff); - _Texts[_TextMedleyCountdown].Visible = true; - _Texts[_TextMedleyCountdown].Text = Math.Round((decimal)(timeDiff - t)).ToString(); - float h = (float)(t * CSettings.RenderH); - float w = CFonts.GetTextBounds(_Texts[_TextMedleyCountdown], h).Width; - float x = CSettings.RenderW / 2 - w / 2; - float y = CSettings.RenderH / 2 - h / 2; - _Texts[_TextMedleyCountdown].X = x; - _Texts[_TextMedleyCountdown].Y = y; - _Texts[_TextMedleyCountdown].Height = h; - } - else - _Texts[_TextMedleyCountdown].Visible = false; + if (song == null) + return; + float timeToFirstMedleyNote = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) + song.Gap; + if (_CurrentTime < timeToFirstMedleyNote) + { + float timeDiff = timeToFirstMedleyNote - _CurrentTime + 1; + float fullSeconds = (float)Math.Truncate(timeDiff); + float partSeconds = timeDiff - fullSeconds; + _Texts[_TextMedleyCountdown].Visible = true; + _Texts[_TextMedleyCountdown].Text = fullSeconds.ToString(); + float h = partSeconds * CSettings.RenderH; + float w = CFonts.GetTextBounds(_Texts[_TextMedleyCountdown], h).Width; + float x = CSettings.RenderW / 2 - w / 2; + float y = CSettings.RenderH / 2 - h / 2; + _Texts[_TextMedleyCountdown].X = x; + _Texts[_TextMedleyCountdown].Y = y; + _Texts[_TextMedleyCountdown].Height = h; } + else + _Texts[_TextMedleyCountdown].Visible = false; } private void _DrawLyricHelper() From 2f3f121f887e549d66e90fa4049f5602deeef8d8 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 14:02:27 +0200 Subject: [PATCH 12/33] Split Font-File --- Vocaluxe/Base/CGraphics.cs | 1 + Vocaluxe/Base/CMain.cs | 1 + Vocaluxe/Base/CTheme.cs | 1 + Vocaluxe/Base/Font/CFont.cs | 193 +++++++++++++ Vocaluxe/Base/{CFont.cs => Font/CFonts.cs} | 312 +-------------------- Vocaluxe/Base/Font/CGlyph.cs | 128 +++++++++ Vocaluxe/Lib/Draw/CDirect3D.cs | 1 + Vocaluxe/Lib/Draw/CDrawWinForm.cs | 1 + Vocaluxe/Lib/Draw/COpenGL.cs | 1 + Vocaluxe/Program.cs | 1 + Vocaluxe/Screens/CScreenMain.cs | 1 + Vocaluxe/Screens/CScreenOptionsTheme.cs | 1 + Vocaluxe/Screens/CScreenSing.cs | 5 +- Vocaluxe/Vocaluxe.csproj | 4 +- VocaluxeLib/Menu/CStatic.cs | 15 +- VocaluxeLib/Menu/CText.cs | 5 - 16 files changed, 343 insertions(+), 328 deletions(-) create mode 100644 Vocaluxe/Base/Font/CFont.cs rename Vocaluxe/Base/{CFont.cs => Font/CFonts.cs} (60%) create mode 100644 Vocaluxe/Base/Font/CGlyph.cs diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index b228a042..bab0a646 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Windows.Forms; +using Vocaluxe.Base.Font; using Vocaluxe.Screens; using VocaluxeLib.Menu; using VocaluxeLib.PartyModes; diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 4e9b3521..84ee348e 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using Vocaluxe.Base.Font; using VocaluxeLib.Menu; using VocaluxeLib.Menu.SongMenu; diff --git a/Vocaluxe/Base/CTheme.cs b/Vocaluxe/Base/CTheme.cs index c730d1d4..30ce2f20 100644 --- a/Vocaluxe/Base/CTheme.cs +++ b/Vocaluxe/Base/CTheme.cs @@ -23,6 +23,7 @@ using System.IO; using System.Text; using System.Windows.Forms; using System.Xml; +using Vocaluxe.Base.Font; using VocaluxeLib.Menu; namespace Vocaluxe.Base diff --git a/Vocaluxe/Base/Font/CFont.cs b/Vocaluxe/Base/Font/CFont.cs new file mode 100644 index 00000000..fb4fc0ee --- /dev/null +++ b/Vocaluxe/Base/Font/CFont.cs @@ -0,0 +1,193 @@ +#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.Collections.Generic; +using System.Drawing; +using System.Drawing.Text; +using VocaluxeLib.Menu; + +namespace Vocaluxe.Base.Font +{ + class CFont : IDisposable + { + private readonly Dictionary _Glyphs; + private PrivateFontCollection _Fonts; + private FontFamily _Family; + private readonly float _Sizeh; + + public readonly string FilePath; + + public CFont(string file) + { + FilePath = file; + + _Glyphs = new Dictionary(); + + switch (CConfig.TextureQuality) + { + case ETextureQuality.TR_CONFIG_TEXTURE_LOWEST: + _Sizeh = 25f; + break; + case ETextureQuality.TR_CONFIG_TEXTURE_LOW: + _Sizeh = 50f; + break; + case ETextureQuality.TR_CONFIG_TEXTURE_MEDIUM: + _Sizeh = 100f; + break; + case ETextureQuality.TR_CONFIG_TEXTURE_HIGH: + _Sizeh = 200f; + break; + case ETextureQuality.TR_CONFIG_TEXTURE_HIGHEST: + _Sizeh = 400f; + break; + default: + _Sizeh = 100f; + break; + } + } + + public System.Drawing.Font GetFont() + { + if (_Fonts == null) + { + _Fonts = new PrivateFontCollection(); + try + { + _Fonts.AddFontFile(FilePath); + _Family = _Fonts.Families[0]; + } + catch (Exception e) + { + CLog.LogError("Error opening font file " + FilePath + ": " + e.Message); + } + } + + return new System.Drawing.Font(_Family, CFonts.Height, CFonts.GetFontStyle(), GraphicsUnit.Pixel); + } + + public void DrawGlyph(char chr, float x, float y, float h, float z, SColorF color) + { + STexture texture; + SRectF rect; + _GetGlyphTextureAndRect(chr, x, y, z, h, out texture, out rect); + CDraw.DrawTexture(texture, rect, color); + } + + public void DrawGlyph(char chr, float x, float y, float h, float z, SColorF color, float begin, float end) + { + STexture texture; + SRectF rect; + _GetGlyphTextureAndRect(chr, x, y, z, h, out texture, out rect); + CDraw.DrawTexture(texture, rect, color, begin, end); + } + + public void DrawGlyphReflection(char chr, float x, float y, float h, float z, SColorF color, float rspace, float rheight) + { + STexture texture; + SRectF rect; + _GetGlyphTextureAndRect(chr, x, y, z, h, out texture, out rect); + CDraw.DrawTextureReflection(texture, rect, color, rect, rspace, rheight); + } + + private void _GetGlyphTextureAndRect(char chr, float x, float y, float z, float h, out STexture texture, out SRectF rect) + { + AddGlyph(chr); + + CFonts.Height = h; + CGlyph glyph = _Glyphs[chr]; + texture = glyph.Texture; + float factor = h / texture.Height; + float width = texture.Width * factor; + float d = glyph.Sizeh / 5f * factor; + rect = new SRectF(x - d, y, width, h, z); + } + + public float GetWidth(char chr) + { + AddGlyph(chr); + + CGlyph glyph = _Glyphs[chr]; + float factor = CFonts.Height / glyph.Texture.Height; + return glyph.Width * factor; + } + + public float GetHeight(char chr) + { + return CFonts.Height; + /*WTF??? + AddGlyph(chr); + + CGlyph glyph = _Glyphs[chr]; + float factor = CFonts.Height / glyph.Texture.height; + return glyph.Texture.height * factor;*/ + } + + public void AddGlyph(char chr) + { + if (_Glyphs.ContainsKey(chr)) + return; + + float h = CFonts.Height; + _Glyphs.Add(chr, new CGlyph(chr, _Sizeh)); + CFonts.Height = h; + } + + public void UnloadAllGlyphs() + { + foreach (CGlyph glyph in _Glyphs.Values) + glyph.UnloadTexture(); + _Glyphs.Clear(); + } + + public void Dispose() + { + if (_Fonts != null) + { + _Fonts.Dispose(); + _Fonts = null; + UnloadAllGlyphs(); + } + GC.SuppressFinalize(this); + } + } + + struct SFont + { + public string Name; + + public bool IsThemeFont; + public int PartyModeID; + public string ThemeName; + + public string Folder; + public string FileNormal; + public string FileItalic; + public string FileBold; + public string FileBoldItalic; + + public float Outline; //0..1, 0=not outline 1=100% outline + public SColorF OutlineColor; + + public CFont Normal; + public CFont Italic; + public CFont Bold; + public CFont BoldItalic; + } +} \ No newline at end of file diff --git a/Vocaluxe/Base/CFont.cs b/Vocaluxe/Base/Font/CFonts.cs similarity index 60% rename from Vocaluxe/Base/CFont.cs rename to Vocaluxe/Base/Font/CFonts.cs index 7b9b8cf0..8012af02 100644 --- a/Vocaluxe/Base/CFont.cs +++ b/Vocaluxe/Base/Font/CFonts.cs @@ -1,321 +1,13 @@ -#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.Collections.Generic; using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Text; using System.IO; using System.Linq; using System.Text; -using System.Windows.Forms; using System.Xml; using VocaluxeLib.Menu; -namespace Vocaluxe.Base +namespace Vocaluxe.Base.Font { - class CGlyph - { - private readonly float _Sizeh = 50f; - public float Sizeh - { - get { return _Sizeh; } - } - - public STexture Texture; - public readonly int Width; - - public CGlyph(char chr, float maxHigh) - { - _Sizeh = maxHigh; - - float outline = CFonts.Outline; - const TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix; - - float factor = _GetFactor(chr, flags); - CFonts.Height = Sizeh * factor; - Font fo; - Size sizeB; - SizeF size; - using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) - { - fo = CFonts.GetFont(); - sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags); - - size = g.MeasureString(chr.ToString(), fo); - } - - using (Bitmap bmp = new Bitmap((int)(sizeB.Width * 2f), sizeB.Height)) - { - Graphics g = Graphics.FromImage(bmp); - g.Clear(Color.Transparent); - - g.SmoothingMode = SmoothingMode.AntiAlias; - g.InterpolationMode = InterpolationMode.HighQualityBicubic; - g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; - CFonts.Height = Sizeh; - fo = CFonts.GetFont(); - - PointF point = new PointF( - outline * Math.Abs(sizeB.Width - size.Width) + (sizeB.Width - size.Width) / 2f + Sizeh / 5f, - (sizeB.Height - size.Height - (size.Height + Sizeh / 4f) * (1f - factor)) / 2f); - - using (GraphicsPath path = new GraphicsPath()) - { - path.AddString( - chr.ToString(), - fo.FontFamily, - (int)fo.Style, - Sizeh, - point, - new StringFormat()); - - using (Pen pen = new Pen( - Color.FromArgb( - (int)CFonts.OutlineColor.A * 255, - (int)CFonts.OutlineColor.R * 255, - (int)CFonts.OutlineColor.G * 255, - (int)CFonts.OutlineColor.B * 255), - Sizeh * outline)) - { - pen.LineJoin = LineJoin.Round; - g.DrawPath(pen, path); - g.FillPath(Brushes.White, path); - } - } - - /* - g.DrawString( - chr.ToString(), - fo, - Brushes.White, - point); - * */ - Texture = CDraw.AddTexture(bmp); - //bmp.Save("test.png", ImageFormat.Png); - Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width); - g.Dispose(); - } - fo.Dispose(); - } - - public void UnloadTexture() - { - CDraw.RemoveTexture(ref Texture); - } - - private float _GetFactor(char chr, TextFormatFlags flags) - { - if (CFonts.Style == EStyle.Normal) - return 1f; - - EStyle style = CFonts.Style; - - CFonts.Style = EStyle.Normal; - CFonts.Height = Sizeh; - float hStyle, hNormal; - using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) - { - Font fo = CFonts.GetFont(); - Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags); - //SizeF size = g.MeasureString(chr.ToString(), fo); - hNormal = sizeB.Height; - } - CFonts.Style = style; - using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) - { - Font fo = CFonts.GetFont(); - Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags); - //size = g.MeasureString(chr.ToString(), fo); - hStyle = sizeB.Height; - } - return hNormal / hStyle; - } - } - - class CFont : IDisposable - { - private readonly Dictionary _Glyphs; - private PrivateFontCollection _Fonts; - private FontFamily _Family; - private readonly float _Sizeh; - - public readonly string FilePath; - - public CFont(string file) - { - FilePath = file; - - _Glyphs = new Dictionary(); - - switch (CConfig.TextureQuality) - { - case ETextureQuality.TR_CONFIG_TEXTURE_LOWEST: - _Sizeh = 25f; - break; - case ETextureQuality.TR_CONFIG_TEXTURE_LOW: - _Sizeh = 50f; - break; - case ETextureQuality.TR_CONFIG_TEXTURE_MEDIUM: - _Sizeh = 100f; - break; - case ETextureQuality.TR_CONFIG_TEXTURE_HIGH: - _Sizeh = 200f; - break; - case ETextureQuality.TR_CONFIG_TEXTURE_HIGHEST: - _Sizeh = 400f; - break; - default: - _Sizeh = 100f; - break; - } - } - - public Font GetFont() - { - if (_Fonts == null) - { - _Fonts = new PrivateFontCollection(); - try - { - _Fonts.AddFontFile(FilePath); - _Family = _Fonts.Families[0]; - } - catch (Exception e) - { - CLog.LogError("Error opening font file " + FilePath + ": " + e.Message); - } - } - - return new Font(_Family, CFonts.Height, CFonts.GetFontStyle(), GraphicsUnit.Pixel); - } - - public void DrawGlyph(char chr, float x, float y, float h, float z, SColorF color) - { - STexture texture; - SRectF rect; - _GetGlyphTextureAndRect(chr, x, y, z, h, out texture, out rect); - CDraw.DrawTexture(texture, rect, color); - } - - public void DrawGlyph(char chr, float x, float y, float h, float z, SColorF color, float begin, float end) - { - STexture texture; - SRectF rect; - _GetGlyphTextureAndRect(chr, x, y, z, h, out texture, out rect); - CDraw.DrawTexture(texture, rect, color, begin, end); - } - - public void DrawGlyphReflection(char chr, float x, float y, float h, float z, SColorF color, float rspace, float rheight) - { - STexture texture; - SRectF rect; - _GetGlyphTextureAndRect(chr, x, y, z, h, out texture, out rect); - CDraw.DrawTextureReflection(texture, rect, color, rect, rspace, rheight); - } - - private void _GetGlyphTextureAndRect(char chr, float x, float y, float z, float h, out STexture texture, out SRectF rect) - { - AddGlyph(chr); - - CFonts.Height = h; - CGlyph glyph = _Glyphs[chr]; - texture = glyph.Texture; - float factor = h / texture.Height; - float width = texture.Width * factor; - float d = glyph.Sizeh / 5f * factor; - rect = new SRectF(x - d, y, width, h, z); - } - - public float GetWidth(char chr) - { - AddGlyph(chr); - - CGlyph glyph = _Glyphs[chr]; - float factor = CFonts.Height / glyph.Texture.Height; - return glyph.Width * factor; - } - - public float GetHeight(char chr) - { - return CFonts.Height; - /*WTF??? - AddGlyph(chr); - - CGlyph glyph = _Glyphs[chr]; - float factor = CFonts.Height / glyph.Texture.height; - return glyph.Texture.height * factor;*/ - } - - public void AddGlyph(char chr) - { - if (_Glyphs.ContainsKey(chr)) - return; - - float h = CFonts.Height; - _Glyphs.Add(chr, new CGlyph(chr, _Sizeh)); - CFonts.Height = h; - } - - public void UnloadAllGlyphs() - { - foreach (CGlyph glyph in _Glyphs.Values) - glyph.UnloadTexture(); - _Glyphs.Clear(); - } - - public void Dispose() - { - if (_Fonts != null) - { - _Fonts.Dispose(); - _Fonts = null; - UnloadAllGlyphs(); - } - GC.SuppressFinalize(this); - } - } - - struct SFont - { - public string Name; - - public bool IsThemeFont; - public int PartyModeID; - public string ThemeName; - - public string Folder; - public string FileNormal; - public string FileItalic; - public string FileBold; - public string FileBoldItalic; - - public float Outline; //0..1, 0=not outline 1=100% outline - public SColorF OutlineColor; - - public CFont Normal; - public CFont Italic; - public CFont Bold; - public CFont BoldItalic; - } - static class CFonts { private static readonly XmlWriterSettings _Settings = new XmlWriterSettings(); @@ -372,7 +64,7 @@ namespace Vocaluxe.Base _LoadFontList(); } - public static Font GetFont() + public static System.Drawing.Font GetFont() { return _GetCurrentFont().GetFont(); } diff --git a/Vocaluxe/Base/Font/CGlyph.cs b/Vocaluxe/Base/Font/CGlyph.cs new file mode 100644 index 00000000..0eb61054 --- /dev/null +++ b/Vocaluxe/Base/Font/CGlyph.cs @@ -0,0 +1,128 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Text; +using System.Windows.Forms; +using VocaluxeLib.Menu; + +namespace Vocaluxe.Base.Font +{ + class CGlyph + { + private readonly float _Sizeh = 50f; + public float Sizeh + { + get { return _Sizeh; } + } + + public STexture Texture; + public readonly int Width; + + public CGlyph(char chr, float maxHigh) + { + _Sizeh = maxHigh; + + float outline = CFonts.Outline; + const TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix; + + float factor = _GetFactor(chr, flags); + CFonts.Height = Sizeh * factor; + System.Drawing.Font fo; + Size sizeB; + SizeF size; + using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) + { + fo = CFonts.GetFont(); + sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags); + + size = g.MeasureString(chr.ToString(), fo); + } + + using (Bitmap bmp = new Bitmap((int)(sizeB.Width * 2f), sizeB.Height)) + { + Graphics g = Graphics.FromImage(bmp); + g.Clear(Color.Transparent); + + g.SmoothingMode = SmoothingMode.AntiAlias; + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; + CFonts.Height = Sizeh; + fo = CFonts.GetFont(); + + PointF point = new PointF( + outline * Math.Abs(sizeB.Width - size.Width) + (sizeB.Width - size.Width) / 2f + Sizeh / 5f, + (sizeB.Height - size.Height - (size.Height + Sizeh / 4f) * (1f - factor)) / 2f); + + using (GraphicsPath path = new GraphicsPath()) + { + path.AddString( + chr.ToString(), + fo.FontFamily, + (int)fo.Style, + Sizeh, + point, + new StringFormat()); + + using (Pen pen = new Pen( + Color.FromArgb( + (int)CFonts.OutlineColor.A * 255, + (int)CFonts.OutlineColor.R * 255, + (int)CFonts.OutlineColor.G * 255, + (int)CFonts.OutlineColor.B * 255), + Sizeh * outline)) + { + pen.LineJoin = LineJoin.Round; + g.DrawPath(pen, path); + g.FillPath(Brushes.White, path); + } + } + + /* + g.DrawString( + chr.ToString(), + fo, + Brushes.White, + point); + * */ + Texture = CDraw.AddTexture(bmp); + //bmp.Save("test.png", ImageFormat.Png); + Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width); + g.Dispose(); + } + fo.Dispose(); + } + + public void UnloadTexture() + { + CDraw.RemoveTexture(ref Texture); + } + + private float _GetFactor(char chr, TextFormatFlags flags) + { + if (CFonts.Style == EStyle.Normal) + return 1f; + + EStyle style = CFonts.Style; + + CFonts.Style = EStyle.Normal; + CFonts.Height = Sizeh; + float hStyle, hNormal; + using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) + { + System.Drawing.Font fo = CFonts.GetFont(); + Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags); + //SizeF size = g.MeasureString(chr.ToString(), fo); + hNormal = sizeB.Height; + } + CFonts.Style = style; + using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) + { + System.Drawing.Font fo = CFonts.GetFont(); + Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags); + //size = g.MeasureString(chr.ToString(), fo); + hStyle = sizeB.Height; + } + return hNormal / hStyle; + } + } +} \ No newline at end of file diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 7a084bca..1d4974d2 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -31,6 +31,7 @@ using System.Runtime.InteropServices; using System.Windows.Forms; using SlimDX.Windows; using Vocaluxe.Base; +using Vocaluxe.Base.Font; using VocaluxeLib.Menu; namespace Vocaluxe.Lib.Draw diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs index cb79cbc2..55a26fe5 100644 --- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs +++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs @@ -27,6 +27,7 @@ using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; using Vocaluxe.Base; +using Vocaluxe.Base.Font; using VocaluxeLib.Menu; namespace Vocaluxe.Lib.Draw diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index 13ee6f35..87042f2d 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -30,6 +30,7 @@ using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; using Vocaluxe.Base; +using Vocaluxe.Base.Font; using VocaluxeLib.Menu; namespace Vocaluxe.Lib.Draw diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 34c5f627..04c0b881 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -25,6 +25,7 @@ using System.Reflection; using System.Windows.Forms; using Vocaluxe.Base; using System.Runtime.ExceptionServices; +using Vocaluxe.Base.Font; namespace Vocaluxe { diff --git a/Vocaluxe/Screens/CScreenMain.cs b/Vocaluxe/Screens/CScreenMain.cs index 807ec508..977cb417 100644 --- a/Vocaluxe/Screens/CScreenMain.cs +++ b/Vocaluxe/Screens/CScreenMain.cs @@ -19,6 +19,7 @@ using System.Windows.Forms; using Vocaluxe.Base; +using Vocaluxe.Base.Font; using VocaluxeLib.Menu; namespace Vocaluxe.Screens diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index 5beca6e7..1ba85dd1 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -20,6 +20,7 @@ using System; using System.Windows.Forms; using Vocaluxe.Base; +using Vocaluxe.Base.Font; using VocaluxeLib.Menu; namespace Vocaluxe.Screens diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 42eb3de7..21aff197 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -25,6 +25,7 @@ using System.IO; using System.Linq; using System.Windows.Forms; using Vocaluxe.Base; +using Vocaluxe.Base.Font; using VocaluxeLib.Menu; using VocaluxeLib.Menu.SingNotes; using VocaluxeLib.Menu.SongMenu; @@ -522,8 +523,8 @@ namespace Vocaluxe.Screens if (_Pause) { - _Statics[_StaticPauseBG].ForceDraw(); - _Texts[_TextPause].ForceDraw(); + _Statics[_StaticPauseBG].Draw(true); + _Texts[_TextPause].Draw(true); foreach (CButton button in _Buttons) button.Draw(); diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index e77012f6..1d1164c9 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -176,7 +176,7 @@ - + @@ -195,6 +195,8 @@ + + Form diff --git a/VocaluxeLib/Menu/CStatic.cs b/VocaluxeLib/Menu/CStatic.cs index 78827930..8dfa8d07 100644 --- a/VocaluxeLib/Menu/CStatic.cs +++ b/VocaluxeLib/Menu/CStatic.cs @@ -221,27 +221,22 @@ namespace VocaluxeLib.Menu return false; } - public void Draw() + public void Draw(bool forceDraw = false) { - Draw(1f, Rect.Z, Aspect, false); + Draw(1f, Rect.Z, Aspect, forceDraw); } public void Draw(EAspect aspect) { - Draw(1f, Rect.Z, aspect, false); + Draw(1f, Rect.Z, aspect); } public void Draw(float scale, EAspect aspect) { - Draw(scale, Rect.Z, aspect, false); + Draw(scale, Rect.Z, aspect); } - public void ForceDraw() - { - Draw(1f, Rect.Z, Aspect, true); - } - - public void Draw(float scale, float z, EAspect aspect, bool forceDraw) + public void Draw(float scale, float z, EAspect aspect, bool forceDraw = false) { STexture texture = _Texture.Index != -1 ? _Texture : CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); diff --git a/VocaluxeLib/Menu/CText.cs b/VocaluxeLib/Menu/CText.cs index ea864d79..c164bfba 100644 --- a/VocaluxeLib/Menu/CText.cs +++ b/VocaluxeLib/Menu/CText.cs @@ -601,11 +601,6 @@ namespace VocaluxeLib.Menu return false; } - public void ForceDraw() - { - Draw(true); - } - public void Draw(bool forceDraw = false) { if (!forceDraw && !Visible && CBase.Settings.GetGameState() != EGameState.EditTheme) From 3956fa17d104d8afc90fc1f8510d913a86240e41 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 14:25:49 +0200 Subject: [PATCH 13/33] Small Font fixes --- Vocaluxe/Base/Font/CFonts.cs | 62 ++++++++++++------------------------ Vocaluxe/Base/Font/CGlyph.cs | 11 +++---- 2 files changed, 25 insertions(+), 48 deletions(-) diff --git a/Vocaluxe/Base/Font/CFonts.cs b/Vocaluxe/Base/Font/CFonts.cs index 8012af02..85d7fde3 100644 --- a/Vocaluxe/Base/Font/CFonts.cs +++ b/Vocaluxe/Base/Font/CFonts.cs @@ -20,15 +20,6 @@ namespace Vocaluxe.Base.Font public static EStyle Style = EStyle.Normal; - public static int CurrentFont - { - get { return _CurrentFont; } - set - { - if ((value >= 0) && (value < _Fonts.Count)) - _CurrentFont = value; - } - } public static float Height { get { return _Height; } @@ -196,35 +187,13 @@ namespace Vocaluxe.Base.Font public static void SetFont(string fontName) { - int index; - - if (PartyModeID != -1) - { - index = _GetFontIndexParty(PartyModeID, fontName); - - if (index >= 0 && index < _Fonts.Count) - { - _CurrentFont = index; - return; - } - } - - index = _GetFontIndex(CConfig.Theme, fontName); - - if (index >= 0 && index < _Fonts.Count) - { + int index = _GetPartyFontIndex(PartyModeID, fontName); + if (index < 0) + index = _GetThemeFontIndex(CConfig.Theme, fontName); + if (index < 0) + index = _GetFontIndex(fontName); + if (index >= 0) _CurrentFont = index; - return; - } - - for (int i = 0; i < _Fonts.Count; i++) - { - if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == fontName) - { - _CurrentFont = i; - return; - } - } } public static RectangleF GetTextBounds(CText text) @@ -420,7 +389,18 @@ namespace Vocaluxe.Base.Font } } - private static int _GetFontIndex(string themeName, string fontName) + private static int _GetFontIndex(string fontName) + { + for (int i = 0; i < _Fonts.Count; i++) + { + if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == fontName) + return i; + } + + return -1; + } + + private static int _GetThemeFontIndex(string themeName, string fontName) { if (themeName == "" || fontName == "") return -1; @@ -434,14 +414,14 @@ namespace Vocaluxe.Base.Font return -1; } - private static int _GetFontIndexParty(int partyModeID, string fontName) + private static int _GetPartyFontIndex(int partyModeID, string fontName) { if (partyModeID == -1 || fontName == "") return -1; for (int i = 0; i < _Fonts.Count; i++) { - if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == fontName && _Fonts[i].PartyModeID == partyModeID) + if (!_Fonts[i].IsThemeFont && _Fonts[i].PartyModeID == partyModeID && _Fonts[i].Name == fontName) return i; } @@ -454,7 +434,7 @@ namespace Vocaluxe.Base.Font for (int i = 0; i < _Fonts.Count; i++) { - CurrentFont = i; + _CurrentFont = i; foreach (char chr in text) { diff --git a/Vocaluxe/Base/Font/CGlyph.cs b/Vocaluxe/Base/Font/CGlyph.cs index 0eb61054..56ac78cd 100644 --- a/Vocaluxe/Base/Font/CGlyph.cs +++ b/Vocaluxe/Base/Font/CGlyph.cs @@ -1,6 +1,7 @@ using System; using System.Drawing; using System.Drawing.Drawing2D; +using System.Drawing.Imaging; using System.Drawing.Text; using System.Windows.Forms; using VocaluxeLib.Menu; @@ -9,18 +10,14 @@ namespace Vocaluxe.Base.Font { class CGlyph { - private readonly float _Sizeh = 50f; - public float Sizeh - { - get { return _Sizeh; } - } + public float Sizeh { get; private set; } public STexture Texture; public readonly int Width; public CGlyph(char chr, float maxHigh) { - _Sizeh = maxHigh; + Sizeh = maxHigh; float outline = CFonts.Outline; const TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix; @@ -85,7 +82,7 @@ namespace Vocaluxe.Base.Font point); * */ Texture = CDraw.AddTexture(bmp); - //bmp.Save("test.png", ImageFormat.Png); + bmp.Save("font/" + chr + CFonts.Style + ".png", ImageFormat.Png); Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width); g.Dispose(); } From 5172f17da7ae7bf8183f8ae2d2cd7baa6136054d Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 17:19:22 +0200 Subject: [PATCH 14/33] Fixed and changed category handling and visible songs --- .../PartyModeChallenge/CPartyModeChallenge.cs | 2 +- .../CPartyModeChallengeMedley.cs | 26 ++- .../PartyModeTicTacToe/CPartyModeTicTacToe.cs | 2 +- Vocaluxe/Base/CGraphics.cs | 2 +- Vocaluxe/Base/CMain.cs | 15 +- Vocaluxe/Base/CPlaylists.cs | 2 +- Vocaluxe/Base/CSongCategorizer.cs | 73 ++++---- Vocaluxe/Base/CSongSorter.cs | 22 +-- Vocaluxe/Base/CSongs.cs | 173 +++++------------- Vocaluxe/Base/Font/CGlyph.cs | 2 +- Vocaluxe/Lib/Playlist/CPlaylistFile.cs | 3 +- Vocaluxe/Screens/CScreenOptionsTheme.cs | 5 - Vocaluxe/Screens/CScreenSong.cs | 71 +++---- Vocaluxe/SongQueue/CSongQueue.cs | 8 +- VocaluxeLib/Menu/IMenu.cs | 9 +- VocaluxeLib/Menu/SongMenu/CSong.cs | 80 ++------ VocaluxeLib/Menu/SongMenu/CSongMenu.cs | 6 - .../Menu/SongMenu/CSongMenuFramework.cs | 6 +- .../Menu/SongMenu/CSongMenuTileBoard.cs | 17 +- VocaluxeLib/VocaluxeLib.csproj | 1 + 20 files changed, 189 insertions(+), 336 deletions(-) diff --git a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs index 8479323b..29ca14c1 100644 --- a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs +++ b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs @@ -308,7 +308,7 @@ namespace VocaluxeLib.PartyModes.Challenge _Screens.TryGetValue("CPartyScreenChallengeMain", out screen); if (screen != null) { - CBase.Songs.ResetPartySongSung(); + CBase.Songs.ResetSongSung(); _ToScreenMain.ResultTable = new List(); _GameData.ResultTable = new List(); _GameData.Rounds = new CChallengeRounds(_GameData.NumRounds, _GameData.NumPlayer, _GameData.NumPlayerAtOnce); diff --git a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs index cd0e61f3..0803558d 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs @@ -187,14 +187,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley { _Stage = EStage.NotStarted; - _ScreenSongOptions.Sorting.IgnoreArticles = CBase.Config.GetIgnoreArticles(); - _ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting(); + _ScreenSongOptions.Sorting.IgnoreArticles = EOffOn.TR_CONFIG_OFF; + _ScreenSongOptions.Sorting.SongSorting = ESongSorting.TR_CONFIG_NONE; _ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_OFF; _ScreenSongOptions.Selection.SongIndex = -1; - if (CBase.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE) - _ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON; - _ToScreenMain.ResultTable = new List(); _GameData.ResultTable = new List(); @@ -313,7 +310,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley _Screens.TryGetValue("CPartyScreenChallengeMedleyMain", out screen); if (screen != null) { - CBase.Songs.ResetPartySongSung(); + CBase.Songs.ResetSongSung(); _ToScreenMain.ResultTable = new List(); _GameData.ResultTable = new List(); _GameData.Rounds = new CChallengeRounds(_GameData.NumRounds, _GameData.NumPlayer, _GameData.NumPlayerAtOnce); @@ -502,26 +499,25 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley #endregion PlayerNames #region SongQueue - if (CBase.Songs.GetNumVisibleSongs() < _NumSongs) - CBase.Songs.ResetPartySongSung(); + if (CBase.Songs.GetNumSongsVisible() < _NumSongs) + CBase.Songs.ResetSongSung(); - const EGameMode gm = EGameMode.TR_GAMEMODE_MEDLEY; List ids = new List(); - CSong[] visSongs = CBase.Songs.GetSongsNotSung(); - if (visSongs == null) + var visibleSongs = CBase.Songs.GetVisibleSongs(); + if (visibleSongs.Count == 0) { CBase.Log.LogError("CPartyChallengeMedleyMode Error: There are no songs!"); CBase.Graphics.FadeTo(EScreens.ScreenParty); return false; } - for (int i = 0; i < visSongs.Length; i++) + foreach (CSong song in visibleSongs) { - foreach (EGameMode mode in visSongs[i].AvailableGameModes) + foreach (EGameMode mode in song.AvailableGameModes) { if (mode == EGameMode.TR_GAMEMODE_MEDLEY) - ids.Add(visSongs[i].ID); + ids.Add(song.ID); } } @@ -536,7 +532,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley while (s < _NumSongs && ids.Count > 0) { int songID = ids[CBase.Game.GetRandom(ids.Count)]; - CBase.Game.AddSong(songID, gm); + CBase.Game.AddSong(songID, EGameMode.TR_GAMEMODE_MEDLEY); CBase.Songs.AddPartySongSung(songID); ids.Remove(songID); s++; diff --git a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs index 21e9f455..649cce67 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs @@ -374,7 +374,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe if (screen != null) { _GameData.Team = _GameData.Team == 1 ? 0 : 1; - CBase.Songs.ResetPartySongSung(); + CBase.Songs.ResetSongSung(); _GameData.CurrentRoundNr = 1; _ToScreenMain.CurrentRoundNr = 1; _ToScreenMain.NumFields = _GameData.NumFields; diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index bab0a646..23e0c7ec 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -505,7 +505,7 @@ namespace Vocaluxe.Base bool popupVolumeControlAllowed = _CurrentScreen != EScreens.ScreenCredits && _CurrentScreen != EScreens.ScreenOptionsRecord; //Hide volume control for bg-music if bg-music is disabled - if (popupVolumeControlAllowed && (_CurrentScreen != EScreens.ScreenSong || (_CurrentScreen == EScreens.ScreenSong && CSongs.Category == -1)) + if (popupVolumeControlAllowed && (_CurrentScreen != EScreens.ScreenSong || CSongs.Category == -1) && _CurrentScreen != EScreens.ScreenSing && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_OFF) popupVolumeControlAllowed = false; diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 84ee348e..6b3781a8 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using Vocaluxe.Base.Font; using VocaluxeLib.Menu; @@ -568,9 +569,9 @@ namespace Vocaluxe.Base return CSongs.NumAllSongs; } - public int GetNumVisibleSongs() + public int GetNumSongsVisible() { - return CSongs.NumVisibleSongs; + return CSongs.NumSongsVisible; } public int GetNumCategories() @@ -618,14 +619,14 @@ namespace Vocaluxe.Base return CSongs.GetSong(songID); } - public CSong[] GetSongs() + public ReadOnlyCollection GetSongs() { return CSongs.AllSongs; } - public CSong[] GetSongsNotSung() + public ReadOnlyCollection GetVisibleSongs() { - return CSongs.SongsNotSung; + return CSongs.VisibleSongs; } public CCategory GetCategory(int index) @@ -641,12 +642,12 @@ namespace Vocaluxe.Base CSongs.AddPartySongSung(songID); } - public void ResetPartySongSung() + public void ResetSongSung() { CSongs.ResetPartySongSung(); } - public void ResetPartySongSung(int catIndex) + public void ResetSongSung(int catIndex) { CSongs.ResetPartySongSung(catIndex); } diff --git a/Vocaluxe/Base/CPlaylists.cs b/Vocaluxe/Base/CPlaylists.cs index a740bc97..ca3e8e34 100644 --- a/Vocaluxe/Base/CPlaylists.cs +++ b/Vocaluxe/Base/CPlaylists.cs @@ -223,7 +223,7 @@ namespace Vocaluxe.Base private static CPlaylistFile _ConvertUSDXPlaylist(string file) { CPlaylistFile pl = new CPlaylistFile(); - CSong[] allSongs = CSongs.AllSongs; + var allSongs = CSongs.AllSongs; if (!File.Exists(file)) return null; diff --git a/Vocaluxe/Base/CSongCategorizer.cs b/Vocaluxe/Base/CSongCategorizer.cs index a9aedb6b..3e4e4706 100644 --- a/Vocaluxe/Base/CSongCategorizer.cs +++ b/Vocaluxe/Base/CSongCategorizer.cs @@ -32,7 +32,7 @@ namespace Vocaluxe.Base public CSongCategorizer() { - CSongs.Filter.ObjectChanged += _HandleSortedSongsChanged; + CSongs.Sorter.ObjectChanged += _HandleSortedSongsChanged; } public List Categories @@ -49,11 +49,10 @@ namespace Vocaluxe.Base get { return _Tabs; } set { - if (value != _Tabs) - { - _Tabs = value; - _SetChanged(); - } + if (value == _Tabs) + return; + _Tabs = value; + _SetChanged(); } } @@ -64,58 +63,55 @@ namespace Vocaluxe.Base private void _CreateCategoriesLetter() { - string category = ""; - int notLetterCat = -1; + CCategory lastCategory = null; + CCategory notLetterCat = null; for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) { Char firstLetter = Char.ToUpper(CSongs.Sorter.SortedSongs[i].SortString.Normalize(NormalizationForm.FormD)[0]); - - if (!Char.IsLetter(firstLetter)) - firstLetter = '#'; - if (firstLetter.ToString() != category) + if (Char.IsLetter(firstLetter)) { - if (firstLetter != '#' || notLetterCat == -1) + if (lastCategory == null || CSongs.Sorter.SortedSongs[i].SortString != lastCategory.Name) { - category = firstLetter.ToString(); - _Categories.Add(new CCategory(category)); - - CSongs.Sorter.SortedSongs[i].CatIndex = _Categories.Count - 1; - - if (firstLetter == '#') - notLetterCat = CSongs.Sorter.SortedSongs[i].CatIndex; + lastCategory = new CCategory(CSongs.Sorter.SortedSongs[i].SortString); + _Categories.Add(lastCategory); } - else - CSongs.Sorter.SortedSongs[i].CatIndex = notLetterCat; + lastCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]); } else - CSongs.Sorter.SortedSongs[i].CatIndex = _Categories.Count - 1; + { + if (notLetterCat == null) + { + notLetterCat = new CCategory("#"); + _Categories.Add(notLetterCat); + } + notLetterCat.Songs.Add(CSongs.Sorter.SortedSongs[i]); + } } } private void _CreateCategoriesNormal(string noCategoryName) { - string category = ""; - int noCategoryIndex = -1; + CCategory lastCategory = null; + CCategory noCategory = null; for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) { if (CSongs.Sorter.SortedSongs[i].SortString != "") { - if (CSongs.Sorter.SortedSongs[i].SortString != category) + if (lastCategory == null || CSongs.Sorter.SortedSongs[i].SortString != lastCategory.Name) { - category = CSongs.Sorter.SortedSongs[i].SortString; - _Categories.Add(new CCategory(category)); + lastCategory = new CCategory(CSongs.Sorter.SortedSongs[i].SortString); + _Categories.Add(lastCategory); } - CSongs.Sorter.SortedSongs[i].CatIndex = _Categories.Count - 1; + lastCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]); } else { - if (noCategoryIndex < 0) + if (noCategory == null) { - category = noCategoryName; - _Categories.Add(new CCategory(category)); - noCategoryIndex = _Categories.Count - 1; + noCategory = new CCategory(noCategoryName); + _Categories.Add(noCategory); } - CSongs.Sorter.SortedSongs[i].CatIndex = noCategoryIndex; + noCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]); } } } @@ -172,15 +168,14 @@ namespace Vocaluxe.Base _Categories.Clear(); - if (_Tabs == EOffOn.TR_CONFIG_OFF) + if (_Tabs != EOffOn.TR_CONFIG_OFF) + _CreateCategories(); + else { //No categories. So don't create them! _Categories.Add(new CCategory("")); - for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) - CSongs.Sorter.SortedSongs[i].CatIndex = 0; + _Categories[0].Songs.AddRange(CSongs.Sorter.SortedSongs); } - else - _CreateCategories(); foreach (CCategory cat in _Categories) cat.CoverTextureSmall = CCover.Cover(cat.Name); diff --git a/Vocaluxe/Base/CSongSorter.cs b/Vocaluxe/Base/CSongSorter.cs index 6d10957b..743f9506 100644 --- a/Vocaluxe/Base/CSongSorter.cs +++ b/Vocaluxe/Base/CSongSorter.cs @@ -27,7 +27,7 @@ namespace Vocaluxe.Base { class CSongSorter : CObservable { - private SSongPointer[] _SortedSongs = new SSongPointer[0]; + private CSongPointer[] _SortedSongs = new CSongPointer[0]; private EOffOn _IgnoreArticles = CConfig.IgnoreArticles; private ESongSorting _SongSorting = CConfig.SongSorting; @@ -36,7 +36,7 @@ namespace Vocaluxe.Base CSongs.Filter.ObjectChanged += _HandleFilteredSongsChanged; } - public SSongPointer[] SortedSongs + public CSongPointer[] SortedSongs { get { @@ -84,7 +84,7 @@ namespace Vocaluxe.Base _SetChanged(); } - private int _SortByFieldArtistTitle(SSongPointer s1, SSongPointer s2) + private int _SortByFieldArtistTitle(CSongPointer s1, CSongPointer s2) { int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase); if (res == 0) @@ -100,7 +100,7 @@ namespace Vocaluxe.Base return res; } - private int _SortByFieldTitle(SSongPointer s1, SSongPointer s2) + private int _SortByFieldTitle(CSongPointer s1, CSongPointer s2) { int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase); if (res == 0) @@ -112,11 +112,11 @@ namespace Vocaluxe.Base return res; } - private List _CreateSortList(string fieldName) + private List _CreateSortList(string fieldName) { - List sortList = new List(); + List sortList = new List(); if (fieldName == "") - CSongs.Filter.FilteredSongs.ForEach(song => sortList.Add(new SSongPointer(song.ID, ""))); + CSongs.Filter.FilteredSongs.ForEach(song => sortList.Add(new CSongPointer(song.ID, ""))); else { FieldInfo field = typeof(CSong).GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); @@ -132,16 +132,16 @@ namespace Vocaluxe.Base { object value = field.GetValue(song); if (isString) - sortList.Add(new SSongPointer(song.ID, (String)value)); + sortList.Add(new CSongPointer(song.ID, (String)value)); else { List values = (List)value; if (values.Count == 0) - sortList.Add(new SSongPointer(song.ID, "")); + sortList.Add(new CSongPointer(song.ID, "")); else { foreach (String sortString in values) - sortList.Add(new SSongPointer(song.ID, sortString)); + sortList.Add(new CSongPointer(song.ID, sortString)); } } } @@ -183,7 +183,7 @@ namespace Vocaluxe.Base fieldName = ""; break; } - List sortList = _CreateSortList(fieldName); + List sortList = _CreateSortList(fieldName); switch (_SongSorting) { case ESongSorting.TR_CONFIG_ARTIST_LETTER: diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index c498eafb..b52dbd36 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Threading; using VocaluxeLib.Menu; @@ -26,31 +27,11 @@ using VocaluxeLib.Menu.SongMenu; namespace Vocaluxe.Base { - public struct SSongPointer - { - public readonly int SongID; - public string SortString; - - public int CatIndex; - public bool Visible; - public bool PartyHidden; - - public SSongPointer(int id, string sortString) - { - SongID = id; - SortString = sortString; - CatIndex = -1; - Visible = false; - PartyHidden = false; - } - } - static class CSongs { private static readonly List _Songs = new List(); private static readonly List _SongsForRandom = new List(); - private static bool _SongsLoaded; private static bool _CoverLoaded; private static int _CatIndex = -1; private static readonly List _CategoriesForRandom = new List(); @@ -66,16 +47,13 @@ namespace Vocaluxe.Base get { return _Songs; } } - public static bool SongsLoaded - { - get { return _SongsLoaded; } - } + public static bool SongsLoaded { get; private set; } public static bool CoverLoaded { get { - if (_SongsLoaded && NumAllSongs == 0) + if (SongsLoaded && NumAllSongs == 0) _CoverLoaded = true; return _CoverLoaded; } @@ -86,14 +64,14 @@ namespace Vocaluxe.Base get { return _Songs.Count; } } - public static int NumVisibleSongs + public static int NumSongsVisible { - get { return Sorter.SortedSongs.Count(sp => sp.Visible); } + get { return _CatIndex < 0 ? 0 : Categories[_CatIndex].Songs.Count(sp => !sp.IsSung); } } public static int NumCategories { - get { return Categorizer.Categories.Count; } + get { return Categories.Count; } } public static int Category @@ -101,13 +79,8 @@ namespace Vocaluxe.Base get { return _CatIndex; } set { - if (value >= -1 && value < Categorizer.Categories.Count) - { + if (value == -1 || IsCatIndexValid(value)) _CatIndex = value; - - for (int i = 0; i < Sorter.SortedSongs.Length; i++) - Sorter.SortedSongs[i].Visible = Sorter.SortedSongs[i].CatIndex == _CatIndex && !Sorter.SortedSongs[i].PartyHidden; - } } } @@ -116,6 +89,11 @@ namespace Vocaluxe.Base get { return _CatIndex >= 0; } } + private static bool IsCatIndexValid(int catIndex) + { + return catIndex >= 0 && catIndex < Categories.Count; + } + /// /// Returns the number of song in the category specified with CatIndex /// @@ -123,21 +101,12 @@ namespace Vocaluxe.Base /// public static int NumSongsInCategory(int catIndex) { - if (Categorizer.Categories.Count <= catIndex || catIndex < 0) - return 0; - - int num = 0; - for (int i = 0; i < Sorter.SortedSongs.Length; i++) - { - if (Sorter.SortedSongs[i].CatIndex == catIndex && !Sorter.SortedSongs[i].PartyHidden) - num++; - } - return num; + return IsCatIndexValid(catIndex) ? Categories[catIndex].Songs.Count(sp => !sp.IsSung) : 0; } public static void NextCategory() { - if (Category == Categorizer.Categories.Count - 1) + if (Category == Categories.Count - 1) Category = 0; else Category++; @@ -146,7 +115,7 @@ namespace Vocaluxe.Base public static void PrevCategory() { if (Category == 0) - Category = Categorizer.Categories.Count - 1; + Category = Categories.Count - 1; else Category--; } @@ -168,29 +137,9 @@ namespace Vocaluxe.Base public static int NumSongsWithCoverLoaded { get; private set; } - public static void SetCoverSmall(int songIndex, STexture texture) - { - if (!_SongsLoaded) - return; - - if (songIndex < _Songs.Count) - _Songs[songIndex].CoverTextureSmall = texture; - } - - public static void SetCoverBig(int songIndex, STexture texture) - { - if (!_SongsLoaded) - return; - - if (songIndex < _Songs.Count) - _Songs[songIndex].CoverTextureBig = texture; - } - public static string GetCurrentCategoryName() { - if ((Categorizer.Categories.Count > 0) && (_CatIndex >= 0) && (Categorizer.Categories.Count > _CatIndex)) - return Categorizer.Categories[_CatIndex].Name; - return String.Empty; + return IsCatIndexValid(_CatIndex) ? Categories[_CatIndex].Name : ""; } public static CSong GetSong(int songID) @@ -200,43 +149,31 @@ namespace Vocaluxe.Base public static void AddPartySongSung(int songID) { - int cat = -1; - for (int i = 0; i < Sorter.SortedSongs.Length; i++) + foreach (CCategory category in Categories) { - if (songID == Sorter.SortedSongs[i].SongID) + foreach (CSongPointer song in category.Songs.Where(song => song.SongID == songID)) { - Sorter.SortedSongs[i].PartyHidden = true; - Sorter.SortedSongs[i].Visible = false; - cat = Sorter.SortedSongs[i].CatIndex; - break; + song.IsSung = true; + int catIndex = _GetCategoryNumber(category); + if (NumSongsInCategory(catIndex) == 0) + ResetPartySongSung(catIndex); + return; } } - - if (cat != -1) - { - if (NumSongsInCategory(cat) == 0) - ResetPartySongSung(cat); - } } public static void ResetPartySongSung() { - for (int i = 0; i < Sorter.SortedSongs.Length; i++) - { - Sorter.SortedSongs[i].PartyHidden = false; - Sorter.SortedSongs[i].Visible = Sorter.SortedSongs[i].CatIndex == _CatIndex && !Sorter.SortedSongs[i].PartyHidden; - } + foreach (CSongPointer song in Sorter.SortedSongs) + song.IsSung = false; } public static void ResetPartySongSung(int catIndex) { - for (int i = 0; i < Sorter.SortedSongs.Length; i++) + if (IsCatIndexValid(catIndex)) { - if (Sorter.SortedSongs[i].CatIndex == catIndex) - { - Sorter.SortedSongs[i].PartyHidden = false; - Sorter.SortedSongs[i].Visible = Sorter.SortedSongs[i].CatIndex == _CatIndex && !Sorter.SortedSongs[i].PartyHidden; - } + foreach (CSongPointer song in Categories[catIndex].Songs) + song.IsSung = false; } } @@ -292,7 +229,7 @@ namespace Vocaluxe.Base private static int _GetCategoryNumber(CCategory category) { - for (int i = 0; i < Categories.Length; i++) + for (int i = 0; i < Categories.Count; i++) { if (Categories[i] == category) return i; @@ -300,59 +237,39 @@ namespace Vocaluxe.Base return -1; } - public static CSong[] AllSongs + public static ReadOnlyCollection AllSongs { - get { return _Songs.ToArray(); } + get { return _Songs.AsReadOnly(); } } - public static CSong[] SongsNotSung + public static ReadOnlyCollection VisibleSongs { get { List songs = new List(); - foreach (SSongPointer sp in Sorter.SortedSongs) + if (IsCatIndexValid(_CatIndex)) { - if (sp.Visible) - songs.Add(_Songs[sp.SongID]); + foreach (CSongPointer sp in Categories[_CatIndex].Songs) + { + if (!sp.IsSung) + songs.Add(_Songs[sp.SongID]); + } } - return songs.ToArray(); + return songs.AsReadOnly(); } } - public static CSong[] VisibleSongs + public static ReadOnlyCollection Categories { - get - { - List songs = new List(); - foreach (SSongPointer sp in Sorter.SortedSongs) - { - if (sp.Visible) - songs.Add(_Songs[sp.SongID]); - } - return songs.ToArray(); - } - } - - public static CCategory[] Categories - { - get { return Categorizer.Categories.ToArray(); } + get { return Categorizer.Categories.AsReadOnly(); } } public static CSong GetVisibleSongByIndex(int index) { if (index < 0) return null; - - foreach (SSongPointer sp in Sorter.SortedSongs) - { - if (sp.Visible) - { - if (index == 0) - return _Songs[sp.SongID]; - index--; - } - } - return null; + var visSongs = VisibleSongs; + return (index < visSongs.Count) ? visSongs[index] : null; } private static void _HandleCategoriesChanged(object sender, EventArgs args) @@ -371,7 +288,7 @@ namespace Vocaluxe.Base public static void LoadSongs() { CLog.StartBenchmark(1, "Load Songs"); - _SongsLoaded = false; + SongsLoaded = false; _Songs.Clear(); CLog.StartBenchmark(2, "List Songs"); @@ -403,7 +320,7 @@ namespace Vocaluxe.Base Categorizer.ObjectChanged += _HandleCategoriesChanged; CLog.StopBenchmark(2, "Sort Songs"); Category = -1; - _SongsLoaded = true; + SongsLoaded = true; if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART) { diff --git a/Vocaluxe/Base/Font/CGlyph.cs b/Vocaluxe/Base/Font/CGlyph.cs index 56ac78cd..bca65ad9 100644 --- a/Vocaluxe/Base/Font/CGlyph.cs +++ b/Vocaluxe/Base/Font/CGlyph.cs @@ -82,7 +82,7 @@ namespace Vocaluxe.Base.Font point); * */ Texture = CDraw.AddTexture(bmp); - bmp.Save("font/" + chr + CFonts.Style + ".png", ImageFormat.Png); + //bmp.Save("font/" + chr + CFonts.Style + ".png", ImageFormat.Png); Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width); g.Dispose(); } diff --git a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs index 08593a50..f0603d78 100644 --- a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs +++ b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs @@ -155,9 +155,8 @@ namespace Vocaluxe.Lib.Playlist xmlReader.TryGetEnumValue("//root/Songs/" + song + "/GameMode", ref gm); CPlaylistSong playlistSong = new CPlaylistSong {SongID = -1}; - CSong[] allSongs = CSongs.AllSongs; - foreach (CSong curSong in allSongs) + foreach (CSong curSong in CSongs.AllSongs) { if (curSong.Artist != artist || curSong.Title != title) continue; diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index 1ba85dd1..5ad72a24 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -181,12 +181,7 @@ namespace Vocaluxe.Screens CConfig.SaveConfig(); if (_OldCoverTheme != _SelectSlides[_SelectSlideCover].Selection) - { CCover.ReloadCover(); - CSongs.Filter.SearchString = String.Empty; - CSongs.Sorter.SetOptions(CConfig.SongSorting, CConfig.IgnoreArticles); - CSongs.Categorizer.Tabs = CConfig.Tabs; - } if (_OldTheme != _SelectSlides[_SelectSlideTheme].Selection) { diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 6f0d83b7..6495e45a 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -213,7 +213,7 @@ namespace Vocaluxe.Screens if (_Buttons[_ButtonStart].Selected) _HandlePartySongSelection(_SongMenus[_SongMenu].GetSelectedSong()); } - if (CSongs.NumVisibleSongs > 0 && !_Sso.Selection.PartyMode) + if (CSongs.NumSongsVisible > 0 && !_Sso.Selection.PartyMode) { if (_SongMenus[_SongMenu].GetSelectedSong() != -1 && !_SongOptionsActive) { @@ -276,7 +276,7 @@ namespace Vocaluxe.Screens break; case Keys.S: - if (keyEvent.Mod == EModifier.Ctrl && CSongs.NumVisibleSongs > 0 && !_Sso.Selection.PartyMode) + if (keyEvent.Mod == EModifier.Ctrl && CSongs.NumSongsVisible > 0 && !_Sso.Selection.PartyMode) _StartMedleySong(_SongMenus[_SongMenu].GetSelectedSong()); break; @@ -442,7 +442,7 @@ namespace Vocaluxe.Screens { //TODO: Causes Bug if you select a song (e.g. with Select random song) and double click a normal button. //E.g. clicking to fast on Select random song starts the next random song. is this OK? - if (CSongs.NumVisibleSongs > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1) + if (CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1) { _ToggleSongOptions(ESongOptionsView.None); _StartVisibleSong(_SongMenus[_SongMenu].GetActualSelection()); @@ -558,7 +558,7 @@ namespace Vocaluxe.Screens } } - if (CSongs.NumVisibleSongs > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1 && !_Sso.Selection.PartyMode) + if (CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1 && !_Sso.Selection.PartyMode) { if (_SongMenus[_SongMenu].GetSelectedSong() != -1 && !_SongOptionsActive) { @@ -572,7 +572,7 @@ namespace Vocaluxe.Screens if (mouseEvent.LBH) { - if (!_DragAndDropActive && _Playlists[_Playlist].Visible && CSongs.NumVisibleSongs > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1) + if (!_DragAndDropActive && _Playlists[_Playlist].Visible && CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1) { _DragAndDropCover = _SongMenus[_SongMenu].GetSelectedSongCover(); _DragAndDropCover.Rect.Z = CSettings.ZNear; @@ -653,9 +653,9 @@ namespace Vocaluxe.Screens CBackgroundMusic.Disabled = false; int song = _SongMenus[_SongMenu].GetActualSelection(); - if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Length) + if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Count) _Texts[_TextSelection].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title; - else if (!CSongs.IsInCategory && song >= 0 && song < CSongs.Categories.Length) + else if (!CSongs.IsInCategory && song >= 0 && song < CSongs.Categories.Count) _Texts[_TextSelection].Text = CSongs.Categories[song].Name; else _Texts[_TextSelection].Text = String.Empty; @@ -822,7 +822,7 @@ namespace Vocaluxe.Screens private void _StartVisibleSong(int songNr) { - if (CSongs.Category >= 0 && songNr >= 0 && CSongs.NumVisibleSongs > songNr) + if (CSongs.Category >= 0 && songNr >= 0 && CSongs.NumSongsVisible > songNr) { EGameMode gm = CSongs.VisibleSongs[songNr].IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL; @@ -856,7 +856,7 @@ namespace Vocaluxe.Screens CGame.ClearSongs(); List ids = new List(); - for (int i = 0; i < CSongs.AllSongs.Length; i++) + for (int i = 0; i < CSongs.AllSongs.Count; i++) ids.Add(i); while (ids.Count > 0) @@ -882,7 +882,7 @@ namespace Vocaluxe.Screens CGame.ClearSongs(); List ids = new List(); - for (int i = 0; i < CSongs.VisibleSongs.Length; i++) + for (int i = 0; i < CSongs.VisibleSongs.Count; i++) ids.Add(CSongs.VisibleSongs[i].ID); while (ids.Count > 0) @@ -910,12 +910,12 @@ namespace Vocaluxe.Screens List ids = new List(); if (allSongs) { - for (int i = 0; i < CSongs.AllSongs.Length; i++) + for (int i = 0; i < CSongs.AllSongs.Count; i++) ids.Add(i); } else { - for (int i = 0; i < CSongs.VisibleSongs.Length; i++) + for (int i = 0; i < CSongs.VisibleSongs.Count; i++) ids.Add(CSongs.VisibleSongs[i].ID); } int s = 0; @@ -985,6 +985,21 @@ namespace Vocaluxe.Screens return false; } + private int _FindIndex(IList list, int start, Predicate match) + { + for (int i = start; i < list.Count; i++) + { + if (match(list[i])) + return i; + } + for (int i = 0; i < start; i++) + { + if (match(list[i])) + return i; + } + return -1; + } + private void _JumpTo(char letter) { int start = 0; @@ -992,29 +1007,21 @@ namespace Vocaluxe.Screens if (CSongs.IsInCategory) { //TODO: Check and use sorting method - CSong[] songs = CSongs.VisibleSongs; - int ct = songs.Length; - if (curSelected >= 0 && curSelected < ct - 1) - { - CSong currentSong = CSongs.GetVisibleSongByIndex(curSelected); - if (currentSong != null && currentSong.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)) - start = curSelected + 1; - } - int visibleID = Array.FindIndex(songs, start, ct - start, element => element.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); - if (visibleID < 0 && start > 1) - visibleID = Array.FindIndex(songs, 0, start - 1, element => element.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); + var songs = CSongs.VisibleSongs; + int ct = songs.Count; + if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)) + start = curSelected + 1; + int visibleID = _FindIndex(songs, start, element => element.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); if (visibleID > -1) _SongMenus[_SongMenu].SetSelectedSong(visibleID); } else { - CCategory[] categories = CSongs.Categories; - int ct = categories.Length; + var categories = CSongs.Categories; + int ct = categories.Count; if (curSelected >= 0 && curSelected < ct - 1 && categories[curSelected].Name.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)) start = curSelected + 1; - int visibleID = Array.FindIndex(categories, start, ct - start, element => element.Name.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); - if (visibleID < 0 && start > 1) - visibleID = Array.FindIndex(categories, 0, start - 1, element => element.Name.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); + int visibleID = _FindIndex(categories, start, element => element.Name.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); if (visibleID > -1) _SongMenus[_SongMenu].SetSelectedCategory(visibleID); } @@ -1030,7 +1037,7 @@ namespace Vocaluxe.Screens int songIndex = _SongMenus[_SongMenu].GetSelectedSong(); int songID = -1; - if (songIndex != -1 && CSongs.NumVisibleSongs > 0 && CSongs.NumVisibleSongs > songIndex) + if (songIndex != -1 && CSongs.NumSongsVisible > 0 && CSongs.NumSongsVisible > songIndex) songID = CSongs.VisibleSongs[songIndex].ID; if (newFilterString == "" && _Sso.Sorting.Tabs == EOffOn.TR_CONFIG_ON) @@ -1047,7 +1054,7 @@ namespace Vocaluxe.Screens CSongs.Sort(_Sso.Sorting.SongSorting, _Sso.Sorting.Tabs, _Sso.Sorting.IgnoreArticles, newFilterString, _Sso.Sorting.DuetOptions); - if (songID == -1 || CSongs.NumVisibleSongs == 0 || CSongs.NumVisibleSongs <= songIndex || CSongs.GetVisibleSongByIndex(songIndex).ID != songID) + if (songID == -1 || CSongs.NumSongsVisible == 0 || CSongs.NumSongsVisible <= songIndex || CSongs.GetVisibleSongByIndex(songIndex).ID != songID) refresh = true; if (refresh) @@ -1162,12 +1169,12 @@ namespace Vocaluxe.Screens _SelectSlides[_SelectSlideOptionsNumMedleySongs].Clear(); if (CSongs.IsInCategory) { - for (int i = 1; i <= CSongs.VisibleSongs.Length; i++) + for (int i = 1; i <= CSongs.VisibleSongs.Count; i++) _SelectSlides[_SelectSlideOptionsNumMedleySongs].AddValue(i.ToString()); } else { - for (int i = 1; i <= CSongs.AllSongs.Length; i++) + for (int i = 1; i <= CSongs.AllSongs.Count; i++) _SelectSlides[_SelectSlideOptionsNumMedleySongs].AddValue(i.ToString()); } if (_SelectSlides[_SelectSlideOptionsNumMedleySongs].NumValues >= 5) diff --git a/Vocaluxe/SongQueue/CSongQueue.cs b/Vocaluxe/SongQueue/CSongQueue.cs index 62a3814c..eb32c0e5 100644 --- a/Vocaluxe/SongQueue/CSongQueue.cs +++ b/Vocaluxe/SongQueue/CSongQueue.cs @@ -60,12 +60,12 @@ namespace Vocaluxe.SongQueue public bool AddVisibleSong(int visibleIndex, EGameMode gameMode) { - return CSongs.VisibleSongs.Length > visibleIndex && _AddSong(CSongs.VisibleSongs[visibleIndex].ID, gameMode); + return CSongs.VisibleSongs.Count > visibleIndex && _AddSong(CSongs.VisibleSongs[visibleIndex].ID, gameMode); } public bool AddSong(int absoluteIndex, EGameMode gameMode) { - return CSongs.AllSongs.Length > absoluteIndex && _AddSong(CSongs.AllSongs[absoluteIndex].ID, gameMode); + return CSongs.AllSongs.Count > absoluteIndex && _AddSong(CSongs.AllSongs[absoluteIndex].ID, gameMode); } private bool _AddSong(int songID, EGameMode gameMode) @@ -79,12 +79,12 @@ namespace Vocaluxe.SongQueue public bool RemoveVisibleSong(int visibleIndex) { - return CSongs.VisibleSongs.Length > visibleIndex && _RemoveSong(CSongs.VisibleSongs[visibleIndex].ID); + return CSongs.VisibleSongs.Count > visibleIndex && _RemoveSong(CSongs.VisibleSongs[visibleIndex].ID); } public bool RemoveSong(int absoluteIndex) { - return CSongs.AllSongs.Length > absoluteIndex && _RemoveSong(CSongs.AllSongs[absoluteIndex].ID); + return CSongs.AllSongs.Count > absoluteIndex && _RemoveSong(CSongs.AllSongs[absoluteIndex].ID); } private bool _RemoveSong(int songID) diff --git a/VocaluxeLib/Menu/IMenu.cs b/VocaluxeLib/Menu/IMenu.cs index 38af4ff1..979328e2 100644 --- a/VocaluxeLib/Menu/IMenu.cs +++ b/VocaluxeLib/Menu/IMenu.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.PartyModes; @@ -240,7 +241,7 @@ namespace VocaluxeLib.Menu public interface ISongs { int GetNumSongs(); - int GetNumVisibleSongs(); + int GetNumSongsVisible(); int GetNumCategories(); int NumSongsInCategory(int categoryIndex); @@ -253,13 +254,11 @@ namespace VocaluxeLib.Menu CSong GetVisibleSong(int visibleIndex); CSong GetSongByID(int songID); - CSong[] GetSongs(); - CSong[] GetSongsNotSung(); + ReadOnlyCollection GetVisibleSongs(); CCategory GetCategory(int index); void AddPartySongSung(int songID); - void ResetPartySongSung(); - void ResetPartySongSung(int catIndex); + void ResetSongSung(int catIndex = -1); void SortSongs(ESongSorting sorting, EOffOn tabs, EOffOn ignoreArticles, String searchString, EDuetOptions duetOptions); diff --git a/VocaluxeLib/Menu/SongMenu/CSong.cs b/VocaluxeLib/Menu/SongMenu/CSong.cs index e4396d48..c3598585 100644 --- a/VocaluxeLib/Menu/SongMenu/CSong.cs +++ b/VocaluxeLib/Menu/SongMenu/CSong.cs @@ -26,6 +26,19 @@ using VocaluxeLib.Menu.SingNotes; namespace VocaluxeLib.Menu.SongMenu { + public class CSongPointer + { + public readonly int SongID; + public string SortString; + public bool IsSung; + + public CSongPointer(int id, string sortString) + { + SongID = id; + SortString = sortString; + } + } + [Flags] enum EHeaderFlags { @@ -40,58 +53,11 @@ namespace VocaluxeLib.Menu.SongMenu public enum EMedleySource { - None, + None = 0, Calculated, Tag } - public class CCategory - { - public readonly string Name; - private STexture _CoverTextureSmall = new STexture(-1); - private STexture _CoverTextureBig = new STexture(-1); - private bool _CoverBigLoaded; - - public CCategory(string name) - { - Name = name; - } - - public STexture CoverTextureSmall - { - get { return _CoverTextureSmall; } - - set { _CoverTextureSmall = value; } - } - - public STexture CoverTextureBig - { - get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; } - set - { - if (value.Index != -1) - { - _CoverTextureBig = value; - _CoverBigLoaded = true; - } - } - } - - public CCategory(string name, STexture coverSmall, STexture coverBig) - { - Name = name; - CoverTextureSmall = coverSmall; - CoverTextureBig = coverBig; - } - - public CCategory(CCategory cat) - { - Name = cat.Name; - CoverTextureSmall = cat.CoverTextureSmall; - CoverTextureBig = cat.CoverTextureBig; - } - } - public struct SMedley { public EMedleySource Source; @@ -99,17 +65,6 @@ namespace VocaluxeLib.Menu.SongMenu public int EndBeat; public float FadeInTime; public float FadeOutTime; - - // ReSharper disable UnusedParameter.Local - public SMedley(int dummy) - // ReSharper restore UnusedParameter.Local - { - Source = EMedleySource.None; - StartBeat = 0; - EndBeat = 0; - FadeInTime = 0f; - FadeOutTime = 0f; - } } public class CSong @@ -119,7 +74,7 @@ namespace VocaluxeLib.Menu.SongMenu private STexture _CoverTextureSmall = new STexture(-1); private STexture _CoverTextureBig = new STexture(-1); - public SMedley Medley = new SMedley(0); + public SMedley Medley; public bool CalculateMedley = true; public float PreviewStart; @@ -159,10 +114,7 @@ namespace VocaluxeLib.Menu.SongMenu public STexture CoverTextureBig { - get - { - return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; - } + get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; } set { _CoverTextureBig = value; diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs index d70f4393..b4c3f32a 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs @@ -35,12 +35,6 @@ namespace VocaluxeLib.Menu.SongMenu _CreateSongMenu(); } - public void UpdateSongMenuType() - { - if (_Type != CBase.Config.GetSongMenuType()) - _CreateSongMenu(); - } - public bool Selected { get { return _SongMenu.IsSelected(); } diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index 77d3f50b..e3329358 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -252,8 +252,6 @@ namespace VocaluxeLib.Menu.SongMenu StaticMedleyTagIcon = new CStatic(_PartyModeID) } }; - - _ThemeLoaded = false; } public string GetThemeName() @@ -598,7 +596,7 @@ namespace VocaluxeLib.Menu.SongMenu protected void _SelectSong(int nr) { - if (CBase.Songs.GetCurrentCategoryIndex() >= 0 && (CBase.Songs.GetNumVisibleSongs() > 0) && (nr >= 0) && ((_Actsong != nr) || (_Streams.Count == 0))) + if (CBase.Songs.GetCurrentCategoryIndex() >= 0 && (CBase.Songs.GetNumSongsVisible() > 0) && (nr >= 0) && ((_Actsong != nr) || (_Streams.Count == 0))) { _Streams.ForEach(soundStream => CBase.Sound.FadeAndStop(soundStream, 0f, 1f)); _Streams.Clear(); @@ -609,7 +607,7 @@ namespace VocaluxeLib.Menu.SongMenu CBase.Drawing.RemoveTexture(ref _Vidtex); _Actsong = nr; - if (_Actsong >= CBase.Songs.GetNumVisibleSongs()) + if (_Actsong >= CBase.Songs.GetNumSongsVisible()) _Actsong = 0; diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index 6a81f68e..35932a34 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -138,7 +138,6 @@ namespace VocaluxeLib.Menu.SongMenu //AfterCategoryChange(); SetSelectedSong(_ActSong); _AfterCategoryChange(); - CBase.Songs.UpdateRandomSongList(); int actcat = _PreviewSelected; if ((CBase.Songs.GetNumCategories() > 0) && (actcat < 0)) @@ -155,7 +154,7 @@ namespace VocaluxeLib.Menu.SongMenu _MedleyTagIcon.Visible = false; } - if (CBase.Songs.GetNumVisibleSongs() == 0 && CBase.Songs.GetSearchFilter() != "") + if (CBase.Songs.GetNumSongsVisible() == 0 && CBase.Songs.GetSearchFilter() != "") { _CoverBig.Texture = _CoverBigTexture; _Artist.Text = String.Empty; @@ -253,7 +252,7 @@ namespace VocaluxeLib.Menu.SongMenu } else { - if (CBase.Songs.GetCurrentCategoryIndex() != -1 && _Locked < CBase.Songs.GetNumVisibleSongs() - 1 && !songOptions.Selection.RandomOnly) + if (CBase.Songs.GetCurrentCategoryIndex() != -1 && _Locked < CBase.Songs.GetNumSongsVisible() - 1 && !songOptions.Selection.RandomOnly) { _Locked++; _UpdateList(); @@ -291,7 +290,7 @@ namespace VocaluxeLib.Menu.SongMenu _UpdateList(); } } - else if (_Locked < CBase.Songs.GetNumVisibleSongs() - _NumW && !songOptions.Selection.RandomOnly) + else if (_Locked < CBase.Songs.GetNumSongsVisible() - _NumW && !songOptions.Selection.RandomOnly) { _Locked += _NumW; _UpdateList(); @@ -403,7 +402,7 @@ namespace VocaluxeLib.Menu.SongMenu if (CBase.Songs.GetCurrentCategoryIndex() >= 0) { int actsong = _PreviewSelected; - if ((CBase.Songs.GetNumVisibleSongs() > actsong) && (actsong >= 0)) + if ((CBase.Songs.GetNumSongsVisible() > actsong) && (actsong >= 0)) { CSong song = CBase.Songs.GetVisibleSong(actsong); @@ -529,7 +528,7 @@ namespace VocaluxeLib.Menu.SongMenu { base.SetSelectedSong(visibleSongNr); - if (visibleSongNr >= 0 && visibleSongNr < CBase.Songs.GetNumVisibleSongs()) + if (visibleSongNr >= 0 && visibleSongNr < CBase.Songs.GetNumSongsVisible()) _SetSelectedTile(visibleSongNr); } @@ -592,11 +591,11 @@ namespace VocaluxeLib.Menu.SongMenu if (_ActualSelection >= 0 && _ActualSelection < _Tiles.Count) _Tiles[_ActualSelection].Selected = true; - if ((_LastKnownNumSongs == CBase.Songs.GetNumVisibleSongs()) && (_LastKnownCategory == CBase.Songs.GetCurrentCategoryIndex())) + if ((_LastKnownNumSongs == CBase.Songs.GetNumSongsVisible()) && (_LastKnownCategory == CBase.Songs.GetCurrentCategoryIndex())) return; _LastKnownCategory = CBase.Songs.GetCurrentCategoryIndex(); - _LastKnownNumSongs = CBase.Songs.GetNumVisibleSongs(); + _LastKnownNumSongs = CBase.Songs.GetNumSongsVisible(); _UpdateList(0, true); CBase.Songs.UpdateRandomSongList(); } @@ -609,7 +608,7 @@ namespace VocaluxeLib.Menu.SongMenu private void _UpdateList(int offset, bool force = false) { bool isInCategory = CBase.Songs.GetCurrentCategoryIndex() >= 0; - int itemCount = isInCategory ? CBase.Songs.GetNumVisibleSongs() : CBase.Songs.GetNumCategories(); + int itemCount = isInCategory ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories(); if (offset >= (itemCount / _NumW) * _NumW - (_NumW * (_NumH - 1))) offset = (itemCount / _NumW) * _NumW - (_NumW * (_NumH - 1)); diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj index e9d4bd1e..2c437927 100644 --- a/VocaluxeLib/VocaluxeLib.csproj +++ b/VocaluxeLib/VocaluxeLib.csproj @@ -137,6 +137,7 @@ + From 34c75ec7c579bdfa4cac5a99eada16232270695e Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 17:23:55 +0200 Subject: [PATCH 15/33] Fixed Bug with window not closing after error --- Vocaluxe.sln.DotSettings | 2 +- Vocaluxe/Lib/Draw/CDirect3D.cs | 5 +++++ Vocaluxe/Lib/Draw/CDrawWinForm.cs | 5 +++++ Vocaluxe/Lib/Draw/COpenGL.cs | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Vocaluxe.sln.DotSettings b/Vocaluxe.sln.DotSettings index 0ca89a5f..3dfb002c 100644 --- a/Vocaluxe.sln.DotSettings +++ b/Vocaluxe.sln.DotSettings @@ -10,7 +10,7 @@ DO_NOT_SHOW DO_NOT_SHOW <?xml version="1.0" encoding="utf-16"?><Profile name="Cleanup"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_EXPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_EXPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_EXPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSShortenReferences>True</CSShortenReferences><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpace>True</SA1006PreprocessorKeywordsMustNotBePrecededBySpace><SA1021NegativeSignsMustBeSpacedCorrectly>True</SA1021NegativeSignsMustBeSpacedCorrectly><SA1022PositiveSignsMustBeSpacedCorrectly>True</SA1022PositiveSignsMustBeSpacedCorrectly><SA1025CodeMustNotContainMultipleWhitespaceInARow>True</SA1025CodeMustNotContainMultipleWhitespaceInARow></StyleCop.Spacing><StyleCop.Ordering><AlphabeticalUsingDirectives>Ignore</AlphabeticalUsingDirectives><ExpandUsingDirectives>Ignore</ExpandUsingDirectives><SA1212PropertyAccessorsMustFollowOrder>True</SA1212PropertyAccessorsMustFollowOrder><SA1213EventAccessorsMustFollowOrder>True</SA1213EventAccessorsMustFollowOrder></StyleCop.Ordering><CSUpdateFileHeader>True</CSUpdateFileHeader></Profile> - <?xml version="1.0" encoding="utf-16"?><Profile name="Simple Reformat"><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpace>True</SA1006PreprocessorKeywordsMustNotBePrecededBySpace><SA1021NegativeSignsMustBeSpacedCorrectly>True</SA1021NegativeSignsMustBeSpacedCorrectly><SA1022PositiveSignsMustBeSpacedCorrectly>True</SA1022PositiveSignsMustBeSpacedCorrectly><SA1025CodeMustNotContainMultipleWhitespaceInARow>True</SA1025CodeMustNotContainMultipleWhitespaceInARow></StyleCop.Spacing><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Ordering><AlphabeticalUsingDirectives>Ignore</AlphabeticalUsingDirectives><ExpandUsingDirectives>Ignore</ExpandUsingDirectives><SA1212PropertyAccessorsMustFollowOrder>True</SA1212PropertyAccessorsMustFollowOrder><SA1213EventAccessorsMustFollowOrder>True</SA1213EventAccessorsMustFollowOrder></StyleCop.Ordering></Profile> + <?xml version="1.0" encoding="utf-16"?><Profile name="Simple Reformat"><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpace>True</SA1006PreprocessorKeywordsMustNotBePrecededBySpace><SA1021NegativeSignsMustBeSpacedCorrectly>True</SA1021NegativeSignsMustBeSpacedCorrectly><SA1022PositiveSignsMustBeSpacedCorrectly>True</SA1022PositiveSignsMustBeSpacedCorrectly><SA1025CodeMustNotContainMultipleWhitespaceInARow>True</SA1025CodeMustNotContainMultipleWhitespaceInARow></StyleCop.Spacing><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Ordering><AlphabeticalUsingDirectives>Ignore</AlphabeticalUsingDirectives><ExpandUsingDirectives>Ignore</ExpandUsingDirectives><SA1212PropertyAccessorsMustFollowOrder>True</SA1212PropertyAccessorsMustFollowOrder><SA1213EventAccessorsMustFollowOrder>True</SA1213EventAccessorsMustFollowOrder></StyleCop.Ordering><CSShortenReferences>True</CSShortenReferences></Profile> Cleanup Simple Reformat 0 diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 1d4974d2..37a09046 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -582,6 +582,11 @@ namespace Vocaluxe.Lib.Draw /// public bool Unload() { + try + { + Close(); + } + catch {} //Dispose all textures foreach (KeyValuePair p in _D3DTextures) { diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs index 55a26fe5..6032aeb6 100644 --- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs +++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs @@ -267,6 +267,11 @@ namespace Vocaluxe.Lib.Draw public bool Unload() { + try + { + Close(); + } + catch {} Dispose(); return true; } diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index 87042f2d..2d963a42 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -440,6 +440,11 @@ namespace Vocaluxe.Lib.Draw public bool Unload() { + try + { + Close(); + } + catch {} STexture[] textures = new STexture[_Textures.Count]; _Textures.Values.CopyTo(textures, 0); for (int i = 0; i < _Textures.Count; i++) From 0af6fbfcdeb55fab789a8c9eb49d0250f54b7f28 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 19:16:24 +0200 Subject: [PATCH 16/33] Added missing file --- VocaluxeLib/Menu/SongMenu/CCategory.cs | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 VocaluxeLib/Menu/SongMenu/CCategory.cs diff --git a/VocaluxeLib/Menu/SongMenu/CCategory.cs b/VocaluxeLib/Menu/SongMenu/CCategory.cs new file mode 100644 index 00000000..c8a043e9 --- /dev/null +++ b/VocaluxeLib/Menu/SongMenu/CCategory.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; + +namespace VocaluxeLib.Menu.SongMenu +{ + public class CCategory + { + public readonly string Name; + private STexture _CoverTextureSmall = new STexture(-1); + private STexture _CoverTextureBig = new STexture(-1); + private bool _CoverBigLoaded; + public readonly List Songs = new List(); + + public CCategory(string name) + { + Name = name; + } + + public STexture CoverTextureSmall + { + get { return _CoverTextureSmall; } + + set { _CoverTextureSmall = value; } + } + + public STexture CoverTextureBig + { + get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; } + set + { + if (value.Index == -1) + return; + _CoverTextureBig = value; + _CoverBigLoaded = true; + } + } + + public CCategory(string name, STexture coverSmall, STexture coverBig) + { + Name = name; + CoverTextureSmall = coverSmall; + CoverTextureBig = coverBig; + } + + public CCategory(CCategory cat) + { + Name = cat.Name; + CoverTextureSmall = cat.CoverTextureSmall; + CoverTextureBig = cat.CoverTextureBig; + } + } +} \ No newline at end of file From f437620e54966938a53eb48ddbcd0605c4e37a0e Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 20:46:01 +0200 Subject: [PATCH 17/33] Changed output dir for gstreamer helper --- .gitignore | 4 +-- GstreamerHelper/GstreamerHelper.vcxproj | 29 ++++++++++++++++--- .../Sound/Gstreamer/CGstreamerAudioWrapper.cs | 4 +-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index cd58e0f8..cc79e436 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ Output/Songs *.log /Output/Playlists/*.xml /Output/x64/gstreamer/GstreamerHelper.dll +/Output/x86/gstreamer/GstreamerHelper.dll *.tlog *.suo *.obj @@ -35,6 +36,5 @@ Output/Songs *.nativecodeanalysis* *.lastcodeanalysissucceeded /PartyModes/*/*/*.dll - *.Cache -/Output/x86/gstreamer/GstreamerHelper.dll +/GstreamerHelper/bin/* diff --git a/GstreamerHelper/GstreamerHelper.vcxproj b/GstreamerHelper/GstreamerHelper.vcxproj index 42933149..4c8a37a0 100644 --- a/GstreamerHelper/GstreamerHelper.vcxproj +++ b/GstreamerHelper/GstreamerHelper.vcxproj @@ -68,26 +68,29 @@ true - ..\Output\x86\gstreamer\ + bin\$(Configuration)\$(Platform) $(MSBuildProjectDirectory)\x86\lib\glib-2.0\include;$(MSBuildProjectDirectory)\x86\include\gstreamer-1.0;$(MSBuildProjectDirectory)\x86\include\glib-2.0;$(MSBuildProjectDirectory)\x86\include;$(IncludePath) $(MSBuildProjectDirectory)\x86\lib;$(LibraryPath) + false + $(Platform)\$(Configuration)\ true - ..\Output\x64\gstreamer\ + bin\$(Configuration)\$(Platform) $(MSBuildProjectDirectory)\x64\lib\glib-2.0\include;$(MSBuildProjectDirectory)\x64\include\gstreamer-1.0;$(MSBuildProjectDirectory)\x64\include\glib-2.0;$(MSBuildProjectDirectory)\x64\include;$(IncludePath) $(MSBuildProjectDirectory)\x64\lib;$(LibraryPath) ..\CheckingRules.ruleset false - ..\Output\x86\gstreamer\ + bin\$(Configuration)\$(Platform) $(MSBuildProjectDirectory)\x86\lib\glib-2.0\include;$(MSBuildProjectDirectory)\x86\include\gstreamer-1.0;$(MSBuildProjectDirectory)\x86\include\glib-2.0;$(MSBuildProjectDirectory)\x86\include;$(IncludePath) $(MSBuildProjectDirectory)\x86\lib;$(LibraryPath) + $(Platform)\$(Configuration)\ false - ..\Output\x64\gstreamer\ + bin\$(Configuration)\$(Platform) $(MSBuildProjectDirectory)\x64\lib\glib-2.0\include;$(MSBuildProjectDirectory)\x64\include\gstreamer-1.0;$(MSBuildProjectDirectory)\x64\include\glib-2.0;$(MSBuildProjectDirectory)\x64\include;$(IncludePath) $(MSBuildProjectDirectory)\x64\lib;$(LibraryPath) @@ -111,6 +114,12 @@ true gstreamer-1.0.lib;gstcontroller-1.0.lib;gobject-2.0.lib;glib-2.0.lib;gstapp-1.0.lib;%(AdditionalDependencies) + + xcopy "$(OutDir)*.dll" "$(SolutionDir)Output\x86\gstreamer\" /I /Y + + + Copying binary + @@ -125,6 +134,9 @@ true gstreamer-1.0.lib;gstcontroller-1.0.lib;gobject-2.0.lib;glib-2.0.lib;gstapp-1.0.lib;%(AdditionalDependencies) + + xcopy "$(OutDir)*.dll" "$(SolutionDir)Output\x64\gstreamer\" /I /Y + @@ -144,6 +156,12 @@ gstreamer-1.0.lib;gstcontroller-1.0.lib;gobject-2.0.lib;glib-2.0.lib;gstapp-1.0.lib;%(AdditionalDependencies) false + + xcopy "$(OutDir)*.dll" "$(SolutionDir)Output\x86\gstreamer\" /I /Y + + + Copying binary + @@ -164,6 +182,9 @@ true gstreamer-1.0.lib;gstcontroller-1.0.lib;gobject-2.0.lib;glib-2.0.lib;gstapp-1.0.lib;%(AdditionalDependencies) + + xcopy "$(OutDir)*.dll" "$(SolutionDir)Output\x64\gstreamer\" /I /Y + diff --git a/Vocaluxe/Lib/Sound/Gstreamer/CGstreamerAudioWrapper.cs b/Vocaluxe/Lib/Sound/Gstreamer/CGstreamerAudioWrapper.cs index 0793da9f..737c0010 100644 --- a/Vocaluxe/Lib/Sound/Gstreamer/CGstreamerAudioWrapper.cs +++ b/Vocaluxe/Lib/Sound/Gstreamer/CGstreamerAudioWrapper.cs @@ -26,13 +26,13 @@ namespace Vocaluxe.Lib.Sound.Gstreamer #region arch #if ARCH_X86 #if WIN - private const string _Dll = "x86\\gstreamer\\gstreamerhelper.dll"; + private const string _Dll = "x86\\gstreamer\\GstreamerHelper.dll"; #endif #endif #if ARCH_X64 #if WIN - private const string _Dll = "x64\\gstreamer\\gstreamerhelper.dll"; + private const string _Dll = "x64\\gstreamer\\GstreamerHelper.dll"; #endif #endif #endregion arch From 5463ea0546b18be005218394511b35652c51789d Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 21:51:54 +0200 Subject: [PATCH 18/33] Cleaned COpenGL.cs by use of using aliases --- Vocaluxe.sln.DotSettings | 5 +- Vocaluxe/Lib/Draw/COpenGL.cs | 459 +++++++++++++++++------------------ 2 files changed, 221 insertions(+), 243 deletions(-) diff --git a/Vocaluxe.sln.DotSettings b/Vocaluxe.sln.DotSettings index 3dfb002c..473f1044 100644 --- a/Vocaluxe.sln.DotSettings +++ b/Vocaluxe.sln.DotSettings @@ -9,7 +9,7 @@ DO_NOT_SHOW DO_NOT_SHOW DO_NOT_SHOW - <?xml version="1.0" encoding="utf-16"?><Profile name="Cleanup"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_EXPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_EXPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_EXPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSShortenReferences>True</CSShortenReferences><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpace>True</SA1006PreprocessorKeywordsMustNotBePrecededBySpace><SA1021NegativeSignsMustBeSpacedCorrectly>True</SA1021NegativeSignsMustBeSpacedCorrectly><SA1022PositiveSignsMustBeSpacedCorrectly>True</SA1022PositiveSignsMustBeSpacedCorrectly><SA1025CodeMustNotContainMultipleWhitespaceInARow>True</SA1025CodeMustNotContainMultipleWhitespaceInARow></StyleCop.Spacing><StyleCop.Ordering><AlphabeticalUsingDirectives>Ignore</AlphabeticalUsingDirectives><ExpandUsingDirectives>Ignore</ExpandUsingDirectives><SA1212PropertyAccessorsMustFollowOrder>True</SA1212PropertyAccessorsMustFollowOrder><SA1213EventAccessorsMustFollowOrder>True</SA1213EventAccessorsMustFollowOrder></StyleCop.Ordering><CSUpdateFileHeader>True</CSUpdateFileHeader></Profile> + <?xml version="1.0" encoding="utf-16"?><Profile name="Cleanup"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_EXPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_EXPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_EXPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSShortenReferences>True</CSShortenReferences><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpace>True</SA1006PreprocessorKeywordsMustNotBePrecededBySpace><SA1021NegativeSignsMustBeSpacedCorrectly>True</SA1021NegativeSignsMustBeSpacedCorrectly><SA1022PositiveSignsMustBeSpacedCorrectly>True</SA1022PositiveSignsMustBeSpacedCorrectly><SA1025CodeMustNotContainMultipleWhitespaceInARow>True</SA1025CodeMustNotContainMultipleWhitespaceInARow></StyleCop.Spacing><StyleCop.Ordering><AlphabeticalUsingDirectives>Ignore</AlphabeticalUsingDirectives><ExpandUsingDirectives>Ignore</ExpandUsingDirectives><SA1212PropertyAccessorsMustFollowOrder>True</SA1212PropertyAccessorsMustFollowOrder><SA1213EventAccessorsMustFollowOrder>True</SA1213EventAccessorsMustFollowOrder></StyleCop.Ordering><CSUpdateFileHeader>True</CSUpdateFileHeader><CSUseAutoProperty>True</CSUseAutoProperty></Profile> <?xml version="1.0" encoding="utf-16"?><Profile name="Simple Reformat"><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpace>True</SA1006PreprocessorKeywordsMustNotBePrecededBySpace><SA1021NegativeSignsMustBeSpacedCorrectly>True</SA1021NegativeSignsMustBeSpacedCorrectly><SA1022PositiveSignsMustBeSpacedCorrectly>True</SA1022PositiveSignsMustBeSpacedCorrectly><SA1025CodeMustNotContainMultipleWhitespaceInARow>True</SA1025CodeMustNotContainMultipleWhitespaceInARow></StyleCop.Spacing><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Ordering><AlphabeticalUsingDirectives>Ignore</AlphabeticalUsingDirectives><ExpandUsingDirectives>Ignore</ExpandUsingDirectives><SA1212PropertyAccessorsMustFollowOrder>True</SA1212PropertyAccessorsMustFollowOrder><SA1213EventAccessorsMustFollowOrder>True</SA1213EventAccessorsMustFollowOrder></StyleCop.Ordering><CSShortenReferences>True</CSShortenReferences></Profile> Cleanup Simple Reformat @@ -25,6 +25,7 @@ ONLY_FOR_MULTILINE ONLY_FOR_MULTILINE 1 + True True LINE_BREAK False @@ -36,7 +37,9 @@ 180 WRAP_IF_LONG WRAP_IF_LONG + False False + False license /* This file is part of $SOLUTION$. diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index 2d963a42..b923079c 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -18,6 +18,7 @@ #endregion using System.Drawing.Drawing2D; +using System.Drawing.Imaging; using System.Threading; using OpenTK; using OpenTK.Graphics; @@ -25,13 +26,33 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; -using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Base.Font; using VocaluxeLib.Menu; +using BeginMode = OpenTK.Graphics.OpenGL.BeginMode; +using BlendingFactorDest = OpenTK.Graphics.OpenGL.BlendingFactorDest; +using BlendingFactorSrc = OpenTK.Graphics.OpenGL.BlendingFactorSrc; +using BufferAccess = OpenTK.Graphics.OpenGL.BufferAccess; +using BufferTarget = OpenTK.Graphics.OpenGL.BufferTarget; +using BufferUsageHint = OpenTK.Graphics.OpenGL.BufferUsageHint; +using ClearBufferMask = OpenTK.Graphics.OpenGL.ClearBufferMask; +using DepthFunction = OpenTK.Graphics.OpenGL.DepthFunction; +using EnableCap = OpenTK.Graphics.OpenGL.EnableCap; +using GL = OpenTK.Graphics.OpenGL.GL; +using GenerateMipmapTarget = OpenTK.Graphics.OpenGL.GenerateMipmapTarget; +using KeyPressEventArgs = System.Windows.Forms.KeyPressEventArgs; +using MatrixMode = OpenTK.Graphics.OpenGL.MatrixMode; +using PixelFormat = OpenTK.Graphics.OpenGL.PixelFormat; +using PixelInternalFormat = OpenTK.Graphics.OpenGL.PixelInternalFormat; +using PixelStoreParameter = OpenTK.Graphics.OpenGL.PixelStoreParameter; +using PixelType = OpenTK.Graphics.OpenGL.PixelType; +using TextureMagFilter = OpenTK.Graphics.OpenGL.TextureMagFilter; +using TextureMinFilter = OpenTK.Graphics.OpenGL.TextureMinFilter; +using TextureParameterName = OpenTK.Graphics.OpenGL.TextureParameterName; +using TextureTarget = OpenTK.Graphics.OpenGL.TextureTarget; namespace Vocaluxe.Lib.Draw { @@ -221,8 +242,7 @@ namespace Vocaluxe.Lib.Draw screenNr = i; } - DesktopBounds = new Rectangle(Screen.AllScreens[screenNr].Bounds.Location, - new Size(Screen.AllScreens[screenNr].Bounds.Width, Screen.AllScreens[screenNr].Bounds.Height)); + DesktopBounds = new Rectangle(Screen.AllScreens[screenNr].Bounds.Location, new Size(Screen.AllScreens[screenNr].Bounds.Width, Screen.AllScreens[screenNr].Bounds.Height)); if (WindowState == FormWindowState.Maximized) { @@ -260,7 +280,7 @@ namespace Vocaluxe.Lib.Draw protected override void OnLoad(EventArgs e) { - OpenTK.Graphics.OpenGL.GL.ClearColor(Color.Black); + GL.ClearColor(Color.Black); } protected override void OnResize(EventArgs e) @@ -338,7 +358,7 @@ namespace Vocaluxe.Lib.Draw _Keys.KeyDown(e); } - private void _OnKeyPressEvent(object sender, System.Windows.Forms.KeyPressEventArgs e) + private void _OnKeyPressEvent(object sender, KeyPressEventArgs e) { _Keys.KeyPress(e); } @@ -368,10 +388,10 @@ namespace Vocaluxe.Lib.Draw _Y = (_Control.Height - _H) / 2; } - OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection); - OpenTK.Graphics.OpenGL.GL.LoadIdentity(); - OpenTK.Graphics.OpenGL.GL.Ortho(0, CSettings.RenderW, CSettings.RenderH, 0, CSettings.ZNear, CSettings.ZFar); - OpenTK.Graphics.OpenGL.GL.Viewport(_X, _Y, _W, _H); + GL.MatrixMode(MatrixMode.Projection); + GL.LoadIdentity(); + GL.Ortho(0, CSettings.RenderW, CSettings.RenderH, 0, CSettings.ZNear, CSettings.ZFar); + GL.Viewport(_X, _Y, _W, _H); } #region implementation @@ -382,14 +402,14 @@ namespace Vocaluxe.Lib.Draw Text = CSettings.GetFullVersionText(); // Init Texturing - OpenTK.Graphics.OpenGL.GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.Texture2D); + GL.Enable(EnableCap.Texture2D); - OpenTK.Graphics.OpenGL.GL.BlendFunc(OpenTK.Graphics.OpenGL.BlendingFactorSrc.SrcAlpha, OpenTK.Graphics.OpenGL.BlendingFactorDest.OneMinusSrcAlpha); - OpenTK.Graphics.OpenGL.GL.PixelStore(OpenTK.Graphics.OpenGL.PixelStoreParameter.UnpackAlignment, 1); + GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); + GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); - OpenTK.Graphics.OpenGL.GL.DepthRange(CSettings.ZFar, CSettings.ZNear); - OpenTK.Graphics.OpenGL.GL.DepthFunc(OpenTK.Graphics.OpenGL.DepthFunction.Lequal); - OpenTK.Graphics.OpenGL.GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.DepthTest); + GL.DepthRange(CSettings.ZFar, CSettings.ZNear); + GL.DepthFunc(DepthFunction.Lequal); + GL.Enable(EnableCap.DepthTest); return true; } @@ -480,15 +500,15 @@ namespace Vocaluxe.Lib.Draw #region Basic Draw Methods public void ClearScreen() { - OpenTK.Graphics.OpenGL.GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit | OpenTK.Graphics.OpenGL.ClearBufferMask.DepthBufferBit); + GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); } public STexture CopyScreen() { STexture texture = new STexture(-1); - int id = OpenTK.Graphics.OpenGL.GL.GenTexture(); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, id); + int id = GL.GenTexture(); + GL.BindTexture(TextureTarget.Texture2D, id); texture.ID = id; texture.Width = _W; @@ -499,19 +519,14 @@ namespace Vocaluxe.Lib.Draw texture.WidthRatio = texture.Width / texture.W2; texture.HeightRatio = texture.Height / texture.H2; - OpenTK.Graphics.OpenGL.GL.TexImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, OpenTK.Graphics.OpenGL.PixelInternalFormat.Rgba, (int)texture.W2, - (int)texture.H2, 0, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, IntPtr.Zero); + GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); - OpenTK.Graphics.OpenGL.GL.CopyTexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, _X, _Y, - (int)texture.Width, (int)texture.Height); + GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, _X, _Y, (int)texture.Width, (int)texture.Height); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMagFilter, - (int)OpenTK.Graphics.OpenGL.TextureMagFilter.Linear); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMinFilter, - (int)OpenTK.Graphics.OpenGL.TextureMinFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); + GL.BindTexture(TextureTarget.Texture2D, 0); // Add to Texture List texture.Color = new SColorF(1f, 1f, 1f, 1f); @@ -535,12 +550,11 @@ namespace Vocaluxe.Lib.Draw } else { - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID); + GL.BindTexture(TextureTarget.Texture2D, texture.ID); - OpenTK.Graphics.OpenGL.GL.CopyTexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, 0, 0, - (int)texture.Width, (int)texture.Height); + GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, (int)texture.Width, (int)texture.Height); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); + GL.BindTexture(TextureTarget.Texture2D, 0); } } @@ -560,7 +574,7 @@ namespace Vocaluxe.Lib.Draw { BitmapData bmpData = screen.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); - OpenTK.Graphics.OpenGL.GL.ReadPixels(0, 0, width, height, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, bmpData.Scan0); + GL.ReadPixels(0, 0, width, height, PixelFormat.Bgra, PixelType.UnsignedByte, bmpData.Scan0); screen.UnlockBits(bmpData); screen.RotateFlip(RotateFlipType.RotateNoneFlipY); @@ -578,17 +592,17 @@ namespace Vocaluxe.Lib.Draw public void DrawColor(SColorF color, SRectF rect) { - OpenTK.Graphics.OpenGL.GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.Blend); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); + GL.Enable(EnableCap.Blend); + GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); - OpenTK.Graphics.OpenGL.GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Quads); - OpenTK.Graphics.OpenGL.GL.Vertex3(rect.X, rect.Y, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.Vertex3(rect.X, rect.Y + rect.H, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.Vertex3(rect.X + rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.Vertex3(rect.X + rect.W, rect.Y, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.End(); + GL.Begin(BeginMode.Quads); + GL.Vertex3(rect.X, rect.Y, rect.Z + CGraphics.ZOffset); + GL.Vertex3(rect.X, rect.Y + rect.H, rect.Z + CGraphics.ZOffset); + GL.Vertex3(rect.X + rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset); + GL.Vertex3(rect.X + rect.W, rect.Y, rect.Z + CGraphics.ZOffset); + GL.End(); - OpenTK.Graphics.OpenGL.GL.Disable(OpenTK.Graphics.OpenGL.EnableCap.Blend); + GL.Disable(EnableCap.Blend); } public void DrawColorReflection(SColorF color, SRectF rect, float space, float height) @@ -614,32 +628,32 @@ namespace Vocaluxe.Lib.Draw ry2 = rect.Y + rect.H + space + height; - OpenTK.Graphics.OpenGL.GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.Blend); + GL.Enable(EnableCap.Blend); if (Math.Abs(rect.Rotation) > 0.001) { - OpenTK.Graphics.OpenGL.GL.Translate(0.5f, 0.5f, 0); - OpenTK.Graphics.OpenGL.GL.Rotate(-rect.Rotation, 0f, 0f, 1f); - OpenTK.Graphics.OpenGL.GL.Translate(-0.5f, -0.5f, 0); + GL.Translate(0.5f, 0.5f, 0); + GL.Rotate(-rect.Rotation, 0f, 0f, 1f); + GL.Translate(-0.5f, -0.5f, 0); } - OpenTK.Graphics.OpenGL.GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Quads); + GL.Begin(BeginMode.Quads); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset); + GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); + GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, 0f); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset); + GL.Color4(color.R, color.G, color.B, 0f); + GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, 0f); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset); + GL.Color4(color.R, color.G, color.B, 0f); + GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset); + GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); + GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.End(); + GL.End(); - OpenTK.Graphics.OpenGL.GL.Disable(OpenTK.Graphics.OpenGL.EnableCap.Blend); + GL.Disable(EnableCap.Blend); } #endregion Basic Draw Methods @@ -718,8 +732,8 @@ namespace Vocaluxe.Lib.Draw h = maxSize; } - int id = OpenTK.Graphics.OpenGL.GL.GenTexture(); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, id); + int id = GL.GenTexture(); + GL.BindTexture(TextureTarget.Texture2D, id); texture.ID = id; texture.Width = w; @@ -742,30 +756,22 @@ namespace Vocaluxe.Lib.Draw BitmapData bmpData = bmp2.LockBits(new Rectangle(0, 0, bmp2.Width, bmp2.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); - OpenTK.Graphics.OpenGL.GL.TexImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, OpenTK.Graphics.OpenGL.PixelInternalFormat.Rgba, (int)texture.W2, - (int)texture.H2, 0, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, IntPtr.Zero); + GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); - OpenTK.Graphics.OpenGL.GL.TexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, bmpData.Width, bmpData.Height, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, bmpData.Scan0); + GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, bmpData.Width, bmpData.Height, PixelFormat.Bgra, PixelType.UnsignedByte, bmpData.Scan0); bmp2.UnlockBits(bmpData); } - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureWrapS, - (int)OpenTK.Graphics.OpenGL.TextureParameterName.ClampToEdge); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureWrapT, - (int)OpenTK.Graphics.OpenGL.TextureParameterName.ClampToEdge); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMagFilter, - (int)OpenTK.Graphics.OpenGL.TextureMagFilter.Linear); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMinFilter, - (int)OpenTK.Graphics.OpenGL.TextureMinFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMinFilter, - (int)OpenTK.Graphics.OpenGL.TextureMinFilter.LinearMipmapLinear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); - OpenTK.Graphics.OpenGL.GL.Ext.GenerateMipmap(OpenTK.Graphics.OpenGL.GenerateMipmapTarget.Texture2D); + GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); // Add to Texture List @@ -790,11 +796,10 @@ namespace Vocaluxe.Lib.Draw { try { - OpenTK.Graphics.OpenGL.GL.GenBuffers(1, out texture.PBO); - OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, texture.PBO); - OpenTK.Graphics.OpenGL.GL.BufferData(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, (IntPtr)(w * h * 4), IntPtr.Zero, - OpenTK.Graphics.OpenGL.BufferUsageHint.StreamDraw); - OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, 0); + GL.GenBuffers(1, out texture.PBO); + GL.BindBuffer(BufferTarget.PixelUnpackBuffer, texture.PBO); + GL.BufferData(BufferTarget.PixelUnpackBuffer, (IntPtr)(w * h * 4), IntPtr.Zero, BufferUsageHint.StreamDraw); + GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0); } catch (Exception) { @@ -802,8 +807,8 @@ namespace Vocaluxe.Lib.Draw } } - int id = OpenTK.Graphics.OpenGL.GL.GenTexture(); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, id); + int id = GL.GenTexture(); + GL.BindTexture(TextureTarget.Texture2D, id); texture.ID = id; texture.Width = w; @@ -814,25 +819,20 @@ namespace Vocaluxe.Lib.Draw texture.WidthRatio = texture.Width / texture.W2; texture.HeightRatio = texture.Height / texture.H2; - OpenTK.Graphics.OpenGL.GL.TexImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, OpenTK.Graphics.OpenGL.PixelInternalFormat.Rgba, (int)texture.W2, - (int)texture.H2, 0, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, IntPtr.Zero); + GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); - OpenTK.Graphics.OpenGL.GL.TexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, w, h, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, data); + GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, data); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMagFilter, - (int)OpenTK.Graphics.OpenGL.TextureMagFilter.Linear); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMinFilter, - (int)OpenTK.Graphics.OpenGL.TextureMinFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); //GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); + GL.BindTexture(TextureTarget.Texture2D, 0); // Add to Texture List texture.Color = new SColorF(1f, 1f, 1f, 1f); @@ -856,11 +856,10 @@ namespace Vocaluxe.Lib.Draw { try { - OpenTK.Graphics.OpenGL.GL.GenBuffers(1, out texture.PBO); - OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, texture.PBO); - OpenTK.Graphics.OpenGL.GL.BufferData(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, (IntPtr)data.Length, IntPtr.Zero, - OpenTK.Graphics.OpenGL.BufferUsageHint.StreamDraw); - OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, 0); + GL.GenBuffers(1, out texture.PBO); + GL.BindBuffer(BufferTarget.PixelUnpackBuffer, texture.PBO); + GL.BufferData(BufferTarget.PixelUnpackBuffer, (IntPtr)data.Length, IntPtr.Zero, BufferUsageHint.StreamDraw); + GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0); } catch (Exception) { @@ -869,8 +868,8 @@ namespace Vocaluxe.Lib.Draw } } - int id = OpenTK.Graphics.OpenGL.GL.GenTexture(); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, id); + int id = GL.GenTexture(); + GL.BindTexture(TextureTarget.Texture2D, id); texture.ID = id; texture.Width = w; @@ -881,25 +880,20 @@ namespace Vocaluxe.Lib.Draw texture.WidthRatio = texture.Width / texture.W2; texture.HeightRatio = texture.Height / texture.H2; - OpenTK.Graphics.OpenGL.GL.TexImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, OpenTK.Graphics.OpenGL.PixelInternalFormat.Rgba, (int)texture.W2, - (int)texture.H2, 0, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, IntPtr.Zero); + GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); - OpenTK.Graphics.OpenGL.GL.TexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, w, h, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, data); + GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, data); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMagFilter, - (int)OpenTK.Graphics.OpenGL.TextureMagFilter.Linear); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMinFilter, - (int)OpenTK.Graphics.OpenGL.TextureMinFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); //GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); + GL.BindTexture(TextureTarget.Texture2D, 0); // Add to Texture List texture.Color = new SColorF(1f, 1f, 1f, 1f); @@ -944,22 +938,21 @@ namespace Vocaluxe.Lib.Draw { try { - OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, texture.PBO); + GL.BindBuffer(BufferTarget.PixelUnpackBuffer, texture.PBO); - IntPtr buffer = OpenTK.Graphics.OpenGL.GL.MapBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, OpenTK.Graphics.OpenGL.BufferAccess.WriteOnly); + IntPtr buffer = GL.MapBuffer(BufferTarget.PixelUnpackBuffer, BufferAccess.WriteOnly); byte[] d = new byte[(int)texture.Height * (int)texture.Width * 4]; Marshal.Copy(data, d, 0, (int)texture.Height * (int)texture.Width * 4); Marshal.Copy(d, 0, buffer, (int)texture.Height * (int)texture.Width * 4); - OpenTK.Graphics.OpenGL.GL.UnmapBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer); + GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID); - OpenTK.Graphics.OpenGL.GL.TexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, IntPtr.Zero); + GL.BindTexture(TextureTarget.Texture2D, texture.ID); + GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); - OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, 0); + GL.BindTexture(TextureTarget.Texture2D, 0); + GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0); return true; } @@ -969,26 +962,21 @@ namespace Vocaluxe.Lib.Draw } } - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID); + GL.BindTexture(TextureTarget.Texture2D, texture.ID); - OpenTK.Graphics.OpenGL.GL.TexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, data); + GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height, PixelFormat.Bgra, PixelType.UnsignedByte, data); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureWrapS, - (int)OpenTK.Graphics.OpenGL.TextureParameterName.ClampToEdge); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureWrapT, - (int)OpenTK.Graphics.OpenGL.TextureParameterName.ClampToEdge); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMinFilter, - (int)OpenTK.Graphics.OpenGL.TextureMinFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMinFilter, - (int)OpenTK.Graphics.OpenGL.TextureMinFilter.LinearMipmapLinear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); - OpenTK.Graphics.OpenGL.GL.Ext.GenerateMipmap(OpenTK.Graphics.OpenGL.GenerateMipmapTarget.Texture2D); + GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); + GL.BindTexture(TextureTarget.Texture2D, 0); return true; } @@ -1001,39 +989,35 @@ namespace Vocaluxe.Lib.Draw { if (_UsePBO) { - OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, texture.PBO); + GL.BindBuffer(BufferTarget.PixelUnpackBuffer, texture.PBO); - IntPtr buffer = OpenTK.Graphics.OpenGL.GL.MapBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, OpenTK.Graphics.OpenGL.BufferAccess.WriteOnly); + IntPtr buffer = GL.MapBuffer(BufferTarget.PixelUnpackBuffer, BufferAccess.WriteOnly); Marshal.Copy(data, 0, buffer, data.Length); - OpenTK.Graphics.OpenGL.GL.UnmapBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer); + GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID); - OpenTK.Graphics.OpenGL.GL.TexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, IntPtr.Zero); + GL.BindTexture(TextureTarget.Texture2D, texture.ID); + GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); - OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, 0); + GL.BindTexture(TextureTarget.Texture2D, 0); + GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0); return true; } - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID); + GL.BindTexture(TextureTarget.Texture2D, texture.ID); - OpenTK.Graphics.OpenGL.GL.TexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, data); + GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height, PixelFormat.Bgra, PixelType.UnsignedByte, data); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMagFilter, - (int)OpenTK.Graphics.OpenGL.TextureMagFilter.Linear); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMinFilter, - (int)OpenTK.Graphics.OpenGL.TextureMinFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); //GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); + GL.BindTexture(TextureTarget.Texture2D, 0); return true; } @@ -1048,9 +1032,9 @@ namespace Vocaluxe.Lib.Draw lock (_MutexTexture) { _IDs.Enqueue(texture.Index); - OpenTK.Graphics.OpenGL.GL.DeleteTexture(texture.ID); + GL.DeleteTexture(texture.ID); if (texture.PBO > 0) - OpenTK.Graphics.OpenGL.GL.DeleteBuffers(1, ref texture.PBO); + GL.DeleteBuffers(1, ref texture.PBO); _Textures.Remove(texture.Index); texture.Index = -1; texture.ID = -1; @@ -1114,7 +1098,7 @@ namespace Vocaluxe.Lib.Draw if (_TextureExists(ref texture)) { - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID); + GL.BindTexture(TextureTarget.Texture2D, texture.ID); float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio; float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio; @@ -1151,60 +1135,60 @@ namespace Vocaluxe.Lib.Draw if (ry2 > bounds.Y + bounds.H) ry2 = bounds.Y + bounds.H; - OpenTK.Graphics.OpenGL.GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.Blend); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); + GL.Enable(EnableCap.Blend); + GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); - OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Texture); - OpenTK.Graphics.OpenGL.GL.PushMatrix(); + GL.MatrixMode(MatrixMode.Texture); + GL.PushMatrix(); if (Math.Abs(rect.Rotation) > float.Epsilon) { - OpenTK.Graphics.OpenGL.GL.Translate(0.5f, 0.5f, 0); - OpenTK.Graphics.OpenGL.GL.Rotate(-rect.Rotation, 0f, 0f, 1f); - OpenTK.Graphics.OpenGL.GL.Translate(-0.5f, -0.5f, 0); + GL.Translate(0.5f, 0.5f, 0); + GL.Rotate(-rect.Rotation, 0f, 0f, 1f); + GL.Translate(-0.5f, -0.5f, 0); } if (!mirrored) { - OpenTK.Graphics.OpenGL.GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Quads); + GL.Begin(BeginMode.Quads); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x1, y1); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(x1, y1); + GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x1, y2); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(x1, y2); + GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x2, y2); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(x2, y2); + GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x2, y1); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(x2, y1); + GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.End(); + GL.End(); } else { - OpenTK.Graphics.OpenGL.GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Quads); + GL.Begin(BeginMode.Quads); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x2, y2); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(x2, y2); + GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x2, y1); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(x2, y1); + GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x1, y1); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(x1, y1); + GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x1, y2); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(x1, y2); + GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.End(); + GL.End(); } - OpenTK.Graphics.OpenGL.GL.PopMatrix(); + GL.PopMatrix(); - OpenTK.Graphics.OpenGL.GL.Disable(OpenTK.Graphics.OpenGL.EnableCap.Blend); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); + GL.Disable(EnableCap.Blend); + GL.BindTexture(TextureTarget.Texture2D, 0); } } @@ -1212,31 +1196,31 @@ namespace Vocaluxe.Lib.Draw { if (_TextureExists(ref texture)) { - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID); + GL.BindTexture(TextureTarget.Texture2D, texture.ID); - OpenTK.Graphics.OpenGL.GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.Blend); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); + GL.Enable(EnableCap.Blend); + GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); - OpenTK.Graphics.OpenGL.GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Quads); + GL.Begin(BeginMode.Quads); - OpenTK.Graphics.OpenGL.GL.TexCoord2(0f + begin * texture.WidthRatio, 0f); - OpenTK.Graphics.OpenGL.GL.Vertex3(rect.X + begin * rect.W, rect.Y, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(0f + begin * texture.WidthRatio, 0f); + GL.Vertex3(rect.X + begin * rect.W, rect.Y, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.TexCoord2(0f + begin * texture.WidthRatio, texture.HeightRatio); - OpenTK.Graphics.OpenGL.GL.Vertex3(rect.X + begin * rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(0f + begin * texture.WidthRatio, texture.HeightRatio); + GL.Vertex3(rect.X + begin * rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.TexCoord2(texture.WidthRatio * end, texture.HeightRatio); - OpenTK.Graphics.OpenGL.GL.Vertex3(rect.X + end * rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(texture.WidthRatio * end, texture.HeightRatio); + GL.Vertex3(rect.X + end * rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.TexCoord2(texture.WidthRatio * end, 0f); - OpenTK.Graphics.OpenGL.GL.Vertex3(rect.X + end * rect.W, rect.Y, rect.Z + CGraphics.ZOffset); + GL.TexCoord2(texture.WidthRatio * end, 0f); + GL.Vertex3(rect.X + end * rect.W, rect.Y, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.End(); + GL.End(); - OpenTK.Graphics.OpenGL.GL.Disable(OpenTK.Graphics.OpenGL.EnableCap.Blend); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); + GL.Disable(EnableCap.Blend); + GL.BindTexture(TextureTarget.Texture2D, 0); } } @@ -1257,7 +1241,7 @@ namespace Vocaluxe.Lib.Draw if (_TextureExists(ref texture)) { - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID); + GL.BindTexture(TextureTarget.Texture2D, texture.ID); float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio; float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio; @@ -1294,44 +1278,44 @@ namespace Vocaluxe.Lib.Draw if (ry2 > bounds.Y + bounds.H + space + height) ry2 = bounds.Y + bounds.H + space + height; - OpenTK.Graphics.OpenGL.GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.Blend); + GL.Enable(EnableCap.Blend); - OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Texture); - OpenTK.Graphics.OpenGL.GL.PushMatrix(); + GL.MatrixMode(MatrixMode.Texture); + GL.PushMatrix(); if (Math.Abs(rect.Rotation) > float.Epsilon) { - OpenTK.Graphics.OpenGL.GL.Translate(0.5f, 0.5f, 0); - OpenTK.Graphics.OpenGL.GL.Rotate(-rect.Rotation, 0f, 0f, 1f); - OpenTK.Graphics.OpenGL.GL.Translate(-0.5f, -0.5f, 0); + GL.Translate(0.5f, 0.5f, 0); + GL.Rotate(-rect.Rotation, 0f, 0f, 1f); + GL.Translate(-0.5f, -0.5f, 0); } - OpenTK.Graphics.OpenGL.GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Quads); + GL.Begin(BeginMode.Quads); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x2, y2); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset); + GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); + GL.TexCoord2(x2, y2); + GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, 0f); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x2, y1); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset); + GL.Color4(color.R, color.G, color.B, 0f); + GL.TexCoord2(x2, y1); + GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, 0f); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x1, y1); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset); + GL.Color4(color.R, color.G, color.B, 0f); + GL.TexCoord2(x1, y1); + GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); - OpenTK.Graphics.OpenGL.GL.TexCoord2(x1, y2); - OpenTK.Graphics.OpenGL.GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset); + GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); + GL.TexCoord2(x1, y2); + GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset); - OpenTK.Graphics.OpenGL.GL.End(); + GL.End(); - OpenTK.Graphics.OpenGL.GL.PopMatrix(); + GL.PopMatrix(); - OpenTK.Graphics.OpenGL.GL.Disable(OpenTK.Graphics.OpenGL.EnableCap.Blend); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); + GL.Disable(EnableCap.Blend); + GL.BindTexture(TextureTarget.Texture2D, 0); } } #endregion drawing @@ -1360,11 +1344,10 @@ namespace Vocaluxe.Lib.Draw { try { - OpenTK.Graphics.OpenGL.GL.GenBuffers(1, out texture.PBO); - OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, texture.PBO); - OpenTK.Graphics.OpenGL.GL.BufferData(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, (IntPtr)q.Data.Length, IntPtr.Zero, - OpenTK.Graphics.OpenGL.BufferUsageHint.StreamDraw); - OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, 0); + GL.GenBuffers(1, out texture.PBO); + GL.BindBuffer(BufferTarget.PixelUnpackBuffer, texture.PBO); + GL.BufferData(BufferTarget.PixelUnpackBuffer, (IntPtr)q.Data.Length, IntPtr.Zero, BufferUsageHint.StreamDraw); + GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0); } catch (Exception) { @@ -1373,8 +1356,8 @@ namespace Vocaluxe.Lib.Draw } } - int id = OpenTK.Graphics.OpenGL.GL.GenTexture(); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, id); + int id = GL.GenTexture(); + GL.BindTexture(TextureTarget.Texture2D, id); texture.ID = id; texture.Width = q.Width; @@ -1385,28 +1368,20 @@ namespace Vocaluxe.Lib.Draw texture.WidthRatio = texture.Width / texture.W2; texture.HeightRatio = texture.Height / texture.H2; - OpenTK.Graphics.OpenGL.GL.TexImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, OpenTK.Graphics.OpenGL.PixelInternalFormat.Rgba, (int)texture.W2, - (int)texture.H2, 0, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, IntPtr.Zero); + GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); - OpenTK.Graphics.OpenGL.GL.TexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, q.Width, q.Height, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, q.Data); + GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, q.Width, q.Height, PixelFormat.Bgra, PixelType.UnsignedByte, q.Data); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureWrapS, - (int)OpenTK.Graphics.OpenGL.TextureParameterName.ClampToEdge); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureWrapT, - (int)OpenTK.Graphics.OpenGL.TextureParameterName.ClampToEdge); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMagFilter, - (int)OpenTK.Graphics.OpenGL.TextureMagFilter.Linear); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMinFilter, - (int)OpenTK.Graphics.OpenGL.TextureMinFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); - OpenTK.Graphics.OpenGL.GL.TexParameter(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, OpenTK.Graphics.OpenGL.TextureParameterName.TextureMinFilter, - (int)OpenTK.Graphics.OpenGL.TextureMinFilter.LinearMipmapLinear); - OpenTK.Graphics.OpenGL.GL.Ext.GenerateMipmap(OpenTK.Graphics.OpenGL.GenerateMipmapTarget.Texture2D); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); + GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); - OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0); + GL.BindTexture(TextureTarget.Texture2D, 0); // Add to Texture List texture.Color = new SColorF(1f, 1f, 1f, 1f); From e8f85454e844e2acb9b2cc356892a748de7f6578 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 22:48:56 +0200 Subject: [PATCH 19/33] Compatibility for OpenGL <3 --- Vocaluxe/Lib/Draw/COpenGL.cs | 57 +++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index b923079c..34173edc 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -83,6 +83,8 @@ namespace Vocaluxe.Lib.Draw private SClientRect _Restore; private bool _Fullscreen; + private bool _IsV3OrHigher; + private readonly Dictionary _Textures; private readonly Queue _IDs; private readonly List _Queue; @@ -154,6 +156,7 @@ namespace Vocaluxe.Lib.Draw ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH); CenterToScreen(); + _IsV3OrHigher = int.Parse(GL.GetString(OpenTK.Graphics.OpenGL.StringName.Version)[0].ToString()) >= 3; } #region Helpers @@ -741,37 +744,44 @@ namespace Vocaluxe.Lib.Draw texture.W2 = MathHelper.NextPowerOfTwo(w); texture.H2 = MathHelper.NextPowerOfTwo(h); - - using (Bitmap bmp2 = new Bitmap((int)texture.W2, (int)texture.H2)) + try { - Graphics g = Graphics.FromImage(bmp2); - g.InterpolationMode = InterpolationMode.HighQualityBicubic; - g.SmoothingMode = SmoothingMode.HighQuality; - g.DrawImage(bmp, new Rectangle(0, 0, bmp2.Width, bmp2.Height)); - g.Dispose(); + using (Bitmap bmp2 = new Bitmap((int)texture.W2, (int)texture.H2)) + { + Graphics g = Graphics.FromImage(bmp2); + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.SmoothingMode = SmoothingMode.HighQuality; + g.DrawImage(bmp, new Rectangle(0, 0, bmp2.Width, bmp2.Height)); + g.Dispose(); - texture.WidthRatio = 1f; - texture.HeightRatio = 1f; + texture.WidthRatio = 1f; + texture.HeightRatio = 1f; - BitmapData bmpData = bmp2.LockBits(new Rectangle(0, 0, bmp2.Width, bmp2.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); + BitmapData bmpData = bmp2.LockBits(new Rectangle(0, 0, bmp2.Width, bmp2.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); + if (!_IsV3OrHigher) + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1); + GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); - GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); + GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, bmpData.Width, bmpData.Height, PixelFormat.Bgra, PixelType.UnsignedByte, bmpData.Scan0); - GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, bmpData.Width, bmpData.Height, PixelFormat.Bgra, PixelType.UnsignedByte, bmpData.Scan0); - - bmp2.UnlockBits(bmpData); + bmp2.UnlockBits(bmpData); + } + } + catch + { + CLog.LogError(w + " " + h + " " + (int)texture.W2 + " " + (int)texture.H2); + throw; } GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); - GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); + if (_IsV3OrHigher) + GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); // Add to Texture List @@ -949,6 +959,8 @@ namespace Vocaluxe.Lib.Draw GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer); GL.BindTexture(TextureTarget.Texture2D, texture.ID); + if (!_IsV3OrHigher) + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); GL.BindTexture(TextureTarget.Texture2D, 0); @@ -973,8 +985,9 @@ namespace Vocaluxe.Lib.Draw GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); - //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); - GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); + if (_IsV3OrHigher) + //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); + GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); GL.BindTexture(TextureTarget.Texture2D, 0); @@ -1368,6 +1381,9 @@ namespace Vocaluxe.Lib.Draw texture.WidthRatio = texture.Width / texture.W2; texture.HeightRatio = texture.Height / texture.H2; + if (!_IsV3OrHigher) + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1); + GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, q.Width, q.Height, PixelFormat.Bgra, PixelType.UnsignedByte, q.Data); @@ -1379,7 +1395,8 @@ namespace Vocaluxe.Lib.Draw GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); - GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); + if (!_IsV3OrHigher) + GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); GL.BindTexture(TextureTarget.Texture2D, 0); From f950b1f3add7948cd1726df8c342f824d08c37b3 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 23:19:08 +0200 Subject: [PATCH 20/33] Better fix for older OpenGL versions --- Vocaluxe/Base/CConfig.cs | 5 ----- Vocaluxe/Lib/Draw/COpenGL.cs | 24 +++++------------------- VocaluxeLib/Menu/Enums.cs | 10 ---------- 3 files changed, 5 insertions(+), 34 deletions(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index bf7964e7..f15bb95d 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -52,7 +52,6 @@ namespace Vocaluxe.Base public static int ScreenH = 576; public static EAntiAliasingModes AAMode = EAntiAliasingModes.X0; - public static EColorDepth ColorDepth = EColorDepth.Bit32; public static EOffOn VSync = EOffOn.TR_CONFIG_ON; public static EOffOn FullScreen = EOffOn.TR_CONFIG_ON; @@ -166,7 +165,6 @@ namespace Vocaluxe.Base xmlReader.TryGetIntValue("//root/Graphics/ScreenW", ref ScreenW); xmlReader.TryGetIntValue("//root/Graphics/ScreenH", ref ScreenH); xmlReader.TryGetEnumValue("//root/Graphics/AAMode", ref AAMode); - xmlReader.TryGetEnumValue("//root/Graphics/Colors", ref ColorDepth); xmlReader.TryGetFloatValue("//root/Graphics/MaxFPS", ref MaxFPS); xmlReader.TryGetEnumValue("//root/Graphics/VSync", ref VSync); xmlReader.TryGetEnumValue("//root/Graphics/FullScreen", ref FullScreen); @@ -330,9 +328,6 @@ namespace Vocaluxe.Base writer.WriteComment("AAMode: " + CHelper.ListStrings(Enum.GetNames(typeof(EAntiAliasingModes)))); writer.WriteElementString("AAMode", Enum.GetName(typeof(EAntiAliasingModes), AAMode)); - writer.WriteComment("Colors: " + CHelper.ListStrings(Enum.GetNames(typeof(EColorDepth)))); - writer.WriteElementString("Colors", Enum.GetName(typeof(EColorDepth), ColorDepth)); - writer.WriteComment("MaxFPS should be between 1..200"); writer.WriteElementString("MaxFPS", MaxFPS.ToString("#")); diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index 34173edc..f04a87c0 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -83,8 +83,6 @@ namespace Vocaluxe.Lib.Draw private SClientRect _Restore; private bool _Fullscreen; - private bool _IsV3OrHigher; - private readonly Dictionary _Textures; private readonly Queue _IDs; private readonly List _Queue; @@ -112,12 +110,11 @@ namespace Vocaluxe.Lib.Draw //Check AA Mode CConfig.AAMode = (EAntiAliasingModes)_CheckAntiAliasingMode((int)CConfig.AAMode); - CConfig.ColorDepth = (EColorDepth)_CheckColorDepth((int)CConfig.ColorDepth); bool ok = false; try { - GraphicsMode gm = new GraphicsMode((int)CConfig.ColorDepth, 24, 0, (int)CConfig.AAMode); + GraphicsMode gm = new GraphicsMode(32, 24, 0, (int)CConfig.AAMode); _Control = new GLControl(gm, 2, 1, GraphicsContextFlags.Default); if (_Control.GraphicsMode != null) ok = true; @@ -156,7 +153,6 @@ namespace Vocaluxe.Lib.Draw ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH); CenterToScreen(); - _IsV3OrHigher = int.Parse(GL.GetString(OpenTK.Graphics.OpenGL.StringName.Version)[0].ToString()) >= 3; } #region Helpers @@ -759,8 +755,6 @@ namespace Vocaluxe.Lib.Draw BitmapData bmpData = bmp2.LockBits(new Rectangle(0, 0, bmp2.Width, bmp2.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); - if (!_IsV3OrHigher) - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, bmpData.Width, bmpData.Height, PixelFormat.Bgra, PixelType.UnsignedByte, bmpData.Scan0); @@ -780,8 +774,7 @@ namespace Vocaluxe.Lib.Draw GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); - if (_IsV3OrHigher) - GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); + GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); // Add to Texture List @@ -959,8 +952,6 @@ namespace Vocaluxe.Lib.Draw GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer); GL.BindTexture(TextureTarget.Texture2D, texture.ID); - if (!_IsV3OrHigher) - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); GL.BindTexture(TextureTarget.Texture2D, 0); @@ -985,9 +976,8 @@ namespace Vocaluxe.Lib.Draw GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); - if (_IsV3OrHigher) - //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); - GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); + //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); + GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); GL.BindTexture(TextureTarget.Texture2D, 0); @@ -1381,9 +1371,6 @@ namespace Vocaluxe.Lib.Draw texture.WidthRatio = texture.Width / texture.W2; texture.HeightRatio = texture.Height / texture.H2; - if (!_IsV3OrHigher) - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1); - GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, q.Width, q.Height, PixelFormat.Bgra, PixelType.UnsignedByte, q.Data); @@ -1395,8 +1382,7 @@ namespace Vocaluxe.Lib.Draw GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); - if (!_IsV3OrHigher) - GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); + GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); GL.BindTexture(TextureTarget.Texture2D, 0); diff --git a/VocaluxeLib/Menu/Enums.cs b/VocaluxeLib/Menu/Enums.cs index 469b2084..29babf1e 100644 --- a/VocaluxeLib/Menu/Enums.cs +++ b/VocaluxeLib/Menu/Enums.cs @@ -93,16 +93,6 @@ namespace VocaluxeLib.Menu X32 = 32 } - public enum EColorDepth - { - // ReSharper disable UnusedMember.Global - Bit8 = 8, - Bit16 = 16, - Bit24 = 24, - Bit32 = 32 - // ReSharper restore UnusedMember.Global - } - public enum ETextureQuality { // ReSharper disable InconsistentNaming From 34be084729490e389fce5948fa46ccd3e52a7a90 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 23:36:02 +0200 Subject: [PATCH 21/33] Improved postbuild event --- GstreamerHelper/GstreamerHelper.vcxproj | 2 +- PartyModes/PartyModeChallenge/PartyModeChallenge.csproj | 3 ++- .../PartyModeChallengeMedley/PartyModeChallengeMedley.csproj | 3 ++- PartyModes/PartyModeTicTacToe/PartyModeTicTacToe.csproj | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/GstreamerHelper/GstreamerHelper.vcxproj b/GstreamerHelper/GstreamerHelper.vcxproj index 4c8a37a0..275afa60 100644 --- a/GstreamerHelper/GstreamerHelper.vcxproj +++ b/GstreamerHelper/GstreamerHelper.vcxproj @@ -68,7 +68,7 @@ true - bin\$(Configuration)\$(Platform) + bin\$(Configuration)\$(Platform)\ $(MSBuildProjectDirectory)\x86\lib\glib-2.0\include;$(MSBuildProjectDirectory)\x86\include\gstreamer-1.0;$(MSBuildProjectDirectory)\x86\include\glib-2.0;$(MSBuildProjectDirectory)\x86\include;$(IncludePath) $(MSBuildProjectDirectory)\x86\lib;$(LibraryPath) false diff --git a/PartyModes/PartyModeChallenge/PartyModeChallenge.csproj b/PartyModes/PartyModeChallenge/PartyModeChallenge.csproj index 571ceefc..4623278b 100644 --- a/PartyModes/PartyModeChallenge/PartyModeChallenge.csproj +++ b/PartyModes/PartyModeChallenge/PartyModeChallenge.csproj @@ -130,7 +130,8 @@ - cd $(SolutionDir)Partymodes\ + if exist "$(SolutionDir)Output\PartyModes\$(TargetName)\Code" rd "$(SolutionDir)Output\PartyModes\$(TargetName)\Code" /S /Q +cd $(SolutionDir)Partymodes\ xcopy "$(ProjectDir)*.cs" "$(SolutionDir)Output\PartyModes\$(TargetName)\Code\" /EXCLUDE:Excludes.txt /I /Y + + + 850 + 560 + + 0,00 + + 32 + + 600 + + + TextWarningColor + + + TextSColor + + Center + + Center + + + + Outline + + TR_SCREENPARTY_ERROR_MICS + + + + Button @@ -653,4 +683,4 @@ 1 - \ No newline at end of file + diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs index f6e37116..d81e0fec 100644 --- a/Vocaluxe/Screens/CScreenParty.cs +++ b/Vocaluxe/Screens/CScreenParty.cs @@ -39,6 +39,7 @@ namespace Vocaluxe.Screens private const string _TextAuthor = "TextAuthor"; private const string _TextVersion = "TextVersion"; private const string _TextError = "TextError"; + private const string _TextErrorMics = "TextErrorMics"; private const string _ButtonStart = "ButtonStart"; private const string _ButtonExit = "ButtonExit"; private const string _SelectSlideModes = "SelectSlideModes"; @@ -49,7 +50,7 @@ namespace Vocaluxe.Screens { base.Init(); - _ThemeTexts = new string[] {_TextDescription, _TextTargetAudience, _TextNumTeams, _TextNumPlayers, _TextAuthor, _TextVersion, _TextError}; + _ThemeTexts = new string[] {_TextDescription, _TextTargetAudience, _TextNumTeams, _TextNumPlayers, _TextAuthor, _TextVersion, _TextError, _TextErrorMics}; _ThemeButtons = new string[] {_ButtonStart, _ButtonExit}; _ThemeSelectSlides = new string[] {_SelectSlideModes}; } @@ -120,6 +121,8 @@ namespace Vocaluxe.Screens _SelectSlides[_SelectSlideModes].Selection = 0; _UpdateSelection(); + _Texts[_TextErrorMics].Visible = CConfig.GetMaxNumMics() == 0; + _SetInteractionToSelectSlide(_SelectSlides[_SelectSlideModes]); } @@ -174,16 +177,8 @@ namespace Vocaluxe.Screens _Texts[_TextVersion].Text = _PartyModeInfos[index].VersionMajor + "." + _PartyModeInfos[index].VersionMinor; _Texts[_TextVersion].TranslationID = _PartyModeInfos[index].PartyModeID; - if (!_PartyModeInfos[index].Playable) - { - _Buttons[_ButtonStart].Visible = false; - _Texts[_TextError].Visible = true; - } - else - { - _Buttons[_ButtonStart].Visible = true; - _Texts[_TextError].Visible = false; - } + _Buttons[_ButtonStart].Visible = _PartyModeInfos[index].Playable && CConfig.GetMaxNumMics() > 0; + _Texts[_TextError].Visible = !_PartyModeInfos[index].Playable; } private void _StartPartyMode() @@ -196,7 +191,7 @@ namespace Vocaluxe.Screens return; if (CConfig.GetMaxNumMics() == 0) - return; //TODO: Add message! + return; CParty.SetPartyMode(_PartyModeInfos[index].PartyModeID); CGraphics.FadeTo(EScreens.ScreenPartyDummy); From 4aa94e188c2e74fa20f6a1e1bb0bb178e0ac165d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 29 Apr 2013 09:24:18 +0200 Subject: [PATCH 27/33] Added more lyric-position-options. TRANSIFEX: Add: TR_SCREENOLYRICS_POSITION, TR_CONFIG_LYRICSPOSITION_BOTTOM, TR_CONFIG_LYRICSPOSITION_TOP, TR_CONFIG_LYRICSPOSITION_BOTH, TR_CONFIG_LYRICSPOSITION_DYNAMIC Remove: TR_SCREENOLYRICS_ONTOP --- .../Ambient/Screens/ScreenOptionsLyrics.xml | 10 ++--- .../Changelog_ScreenOptionsLyrics.txt | 4 +- Vocaluxe/Base/CConfig.cs | 8 ++-- Vocaluxe/Screens/CScreenOptionsLyrics.cs | 10 ++--- Vocaluxe/Screens/CScreenSing.cs | 40 +++++++++++++------ VocaluxeLib/Menu/Enums.cs | 8 ++++ 6 files changed, 52 insertions(+), 28 deletions(-) diff --git a/Output/Themes/Ambient/Screens/ScreenOptionsLyrics.xml b/Output/Themes/Ambient/Screens/ScreenOptionsLyrics.xml index 72cd3bdb..0276de59 100644 --- a/Output/Themes/Ambient/Screens/ScreenOptionsLyrics.xml +++ b/Output/Themes/Ambient/Screens/ScreenOptionsLyrics.xml @@ -1,7 +1,7 @@  - 1 + 2 Video @@ -111,7 +111,7 @@ Outline - TR_SCREENOLYRICS_ONTOP + TR_SCREENOLYRICS_POSITION @@ -240,7 +240,7 @@ 4 - + Invisible @@ -306,6 +306,6 @@ Bold 2 - + - \ No newline at end of file + diff --git a/Output/Themes/Changelog/Changelog_ScreenOptionsLyrics.txt b/Output/Themes/Changelog/Changelog_ScreenOptionsLyrics.txt index 8af47a1e..2c584a57 100644 --- a/Output/Themes/Changelog/Changelog_ScreenOptionsLyrics.txt +++ b/Output/Themes/Changelog/Changelog_ScreenOptionsLyrics.txt @@ -1,5 +1,7 @@ ScreenOptionsSound - +++++++++++ +Version 2: +Rename to ++++++++++ Version 1: diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index f15bb95d..af26eae3 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -93,7 +93,7 @@ namespace Vocaluxe.Base public static int NumPlayer = 2; public static EOffOn Tabs = EOffOn.TR_CONFIG_OFF; public static string Language = "English"; - public static EOffOn LyricsOnTop = EOffOn.TR_CONFIG_OFF; + public static ELyricsPosition LyricsPosition = ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTTOM; public static readonly string[] Players = new string[CSettings.MaxNumPlayer]; public static float MinLineBreakTime = 0.1f; //Minimum time to show the text before it is (to be) sung (if possible) @@ -221,7 +221,7 @@ namespace Vocaluxe.Base xmlReader.TryGetIntValue("//root/Game/NumPlayer", ref NumPlayer); xmlReader.TryGetEnumValue("//root/Game/Tabs", ref Tabs); xmlReader.GetValue("//root/Game/Language", out Language, Language); - xmlReader.TryGetEnumValue("//root/Game/LyricsOnTop", ref LyricsOnTop); + xmlReader.TryGetEnumValue("//root/Game/LyricsOnTop", ref LyricsPosition); xmlReader.TryGetFloatValue("//root/Game/MinLineBreakTime", ref MinLineBreakTime); if ((ScoreAnimationTime > 0 && ScoreAnimationTime < 1) || ScoreAnimationTime < 0) @@ -461,8 +461,8 @@ namespace Vocaluxe.Base writer.WriteComment("Order songs in tabs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("Tabs", Enum.GetName(typeof(EOffOn), Tabs)); - writer.WriteComment("Lyrics also on Top of screen: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("LyricsOnTop", Enum.GetName(typeof(EOffOn), LyricsOnTop)); + writer.WriteComment("Lyrics also on Top of screen: " + CHelper.ListStrings(Enum.GetNames(typeof(ELyricsPosition)))); + writer.WriteElementString("LyricsOnTop", Enum.GetName(typeof(ELyricsPosition), LyricsPosition)); writer.WriteComment("MinLineBreakTime: Value >= 0 in s. Minimum time the text is shown before it is to be sung"); writer.WriteElementString("MinLineBreakTime", MinLineBreakTime.ToString()); diff --git a/Vocaluxe/Screens/CScreenOptionsLyrics.cs b/Vocaluxe/Screens/CScreenOptionsLyrics.cs index 718b9b2d..029923e2 100644 --- a/Vocaluxe/Screens/CScreenOptionsLyrics.cs +++ b/Vocaluxe/Screens/CScreenOptionsLyrics.cs @@ -28,11 +28,11 @@ namespace Vocaluxe.Screens // Version number for theme files. Increment it, if you've changed something on the theme files! protected override int _ScreenVersion { - get { return 1; } + get { return 2; } } private const string _SelectSlideLyricStyle = "SelectSlideLyricStyle"; - private const string _SelectSlideLyricsOnTop = "SelectSlideLyricsOnTop"; + private const string _SelectSlideLyricsPosition = "SelectSlideLyricsPosition"; private const string _ButtonExit = "ButtonExit"; @@ -41,14 +41,14 @@ namespace Vocaluxe.Screens base.Init(); _ThemeButtons = new string[] {_ButtonExit}; - _ThemeSelectSlides = new string[] {_SelectSlideLyricStyle, _SelectSlideLyricsOnTop}; + _ThemeSelectSlides = new string[] {_SelectSlideLyricStyle, _SelectSlideLyricsPosition}; } public override void LoadTheme(string xmlPath) { base.LoadTheme(xmlPath); _SelectSlides[_SelectSlideLyricStyle].SetValues((int)CConfig.LyricStyle); - _SelectSlides[_SelectSlideLyricsOnTop].SetValues((int)CConfig.LyricsOnTop); + _SelectSlides[_SelectSlideLyricsPosition].SetValues((int)CConfig.LyricsPosition); } public override bool HandleInput(SKeyEvent keyEvent) @@ -122,7 +122,7 @@ namespace Vocaluxe.Screens private void _SaveConfig() { - CConfig.LyricsOnTop = (EOffOn)_SelectSlides[_SelectSlideLyricsOnTop].Selection; + CConfig.LyricsPosition = (ELyricsPosition)_SelectSlides[_SelectSlideLyricsPosition].Selection; CConfig.LyricStyle = (ELyricStyle)_SelectSlides[_SelectSlideLyricStyle].Selection; CConfig.SaveConfig(); } diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 21aff197..88e61824 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -649,6 +649,7 @@ namespace Vocaluxe.Screens } } _SetDuetLyricsVisibility(song.IsDuet); + _SetNormalLyricsVisibility(); for (int p = 0; p < CGame.NumPlayer; p++) _NoteLines[p] = _SingNotes[_SingBars].AddPlayer(_SingNotes[_SingBars].BarPos[p, CGame.NumPlayer - 1], CTheme.GetPlayerColor(p + 1), p); @@ -688,13 +689,23 @@ namespace Vocaluxe.Screens } else { - bool lyricsOnTop = (CGame.NumPlayer != 1) && CConfig.LyricsOnTop == EOffOn.TR_CONFIG_ON; + bool lyricsOnTop = CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_TOP + || CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH + || (CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && (CGame.NumPlayer > 2 && CGame.NumPlayer != 4)); _Lyrics[_LyricMainTop].Visible = lyricsOnTop; _Lyrics[_LyricSubTop].Visible = lyricsOnTop; _Statics[_StaticLyricsTop].Visible = lyricsOnTop; } } + private void _SetNormalLyricsVisibility() + { + bool visible = CConfig.LyricsPosition != ELyricsPosition.TR_CONFIG_LYRICSPOSITION_TOP; + _Lyrics[_LyricMain].Visible = visible; + _Lyrics[_LyricSub].Visible = visible; + _Statics[_StaticLyrics].Visible = visible; + } + private void _StartSong() { _PrepareTimeLine(); @@ -999,27 +1010,30 @@ namespace Vocaluxe.Screens if (time > totaltime) time = totaltime; - SRectF rect = _Statics[_StaticLyricHelper].Rect; - SColorF color = new SColorF( - _Statics[_StaticLyricHelper].Color.R, - _Statics[_StaticLyricHelper].Color.G, - _Statics[_StaticLyricHelper].Color.B, - _Statics[_StaticLyricHelper].Color.A * _Statics[_StaticLyricHelper].Alpha * alpha); + if (_Statics[_StaticLyrics].Visible) + { + SRectF rect = _Statics[_StaticLyricHelper].Rect; + SColorF color = new SColorF( + _Statics[_StaticLyricHelper].Color.R, + _Statics[_StaticLyricHelper].Color.G, + _Statics[_StaticLyricHelper].Color.B, + _Statics[_StaticLyricHelper].Color.A * _Statics[_StaticLyricHelper].Alpha * alpha); - float distance = _Lyrics[_LyricMain].GetCurrentLyricPosX() - rect.X - rect.W; - CDraw.DrawTexture(_Statics[_StaticLyricHelper].Texture, - new SRectF(rect.X + distance * (1f - time / totaltime), rect.Y, rect.W, rect.H, rect.Z), color); + float distance = _Lyrics[_LyricMain].GetCurrentLyricPosX() - rect.X - rect.W; + CDraw.DrawTexture(_Statics[_StaticLyricHelper].Texture, + new SRectF(rect.X + distance * (1f - time / totaltime), rect.Y, rect.W, rect.H, rect.Z), color); + } if (_Statics[_StaticLyricsTop].Visible) { - rect = _Statics[_StaticLyricHelperTop].Rect; - color = new SColorF( + SRectF rect = _Statics[_StaticLyricHelperTop].Rect; + SColorF color = new SColorF( _Statics[_StaticLyricHelperTop].Color.R, _Statics[_StaticLyricHelperTop].Color.G, _Statics[_StaticLyricHelperTop].Color.B, _Statics[_StaticLyricHelperTop].Color.A * _Statics[_StaticLyricHelper].Alpha * alpha); - distance = _Lyrics[_LyricMainTop].GetCurrentLyricPosX() - rect.X - rect.W; + float distance = _Lyrics[_LyricMainTop].GetCurrentLyricPosX() - rect.X - rect.W; CDraw.DrawTexture(_Statics[_StaticLyricHelperTop].Texture, new SRectF(rect.X + distance * (1f - time / totaltime), rect.Y, rect.W, rect.H, rect.Z), color); } diff --git a/VocaluxeLib/Menu/Enums.cs b/VocaluxeLib/Menu/Enums.cs index 29babf1e..126575ce 100644 --- a/VocaluxeLib/Menu/Enums.cs +++ b/VocaluxeLib/Menu/Enums.cs @@ -272,6 +272,14 @@ namespace VocaluxeLib.Menu // ReSharper restore InconsistentNaming } + public enum ELyricsPosition + { + TR_CONFIG_LYRICSPOSITION_BOTTOM, + TR_CONFIG_LYRICSPOSITION_TOP, + TR_CONFIG_LYRICSPOSITION_BOTH, + TR_CONFIG_LYRICSPOSITION_DYNAMIC + } + public enum ELyricStyle { Fill, From 0187dd5638809bec8020cc118eebbe410c134465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 29 Apr 2013 11:28:18 +0200 Subject: [PATCH 28/33] Fixed wrong game-mode on ScreenHighscore. --- Vocaluxe/Screens/CScreenHighscore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vocaluxe/Screens/CScreenHighscore.cs b/Vocaluxe/Screens/CScreenHighscore.cs index 0f3bb0c4..3dc5ef1e 100644 --- a/Vocaluxe/Screens/CScreenHighscore.cs +++ b/Vocaluxe/Screens/CScreenHighscore.cs @@ -255,7 +255,7 @@ namespace Vocaluxe.Screens if (points.NumRounds > 1) _Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")"; - switch (CGame.GetGameMode(_Round)) + switch (CGame.GetGameMode(_Round + 1)) { case EGameMode.TR_GAMEMODE_NORMAL: _Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL"; From 2967a01cb8dc9d00c21be4b0f84a99a51713ce74 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Mon, 29 Apr 2013 16:14:24 +0200 Subject: [PATCH 29/33] Changed name of CInput to CController Added message for missing mic in partymode Removed pointless input entry for record devices --- .../CPartyScreenChallengeMain.cs | 2 + .../CPartyScreenChallengeMedleyMain.cs | 2 + Vocaluxe/Base/CConfig.cs | 99 +++++--------- Vocaluxe/Base/{CInput.cs => CController.cs} | 26 ++-- Vocaluxe/Base/CDataBase.cs | 16 +-- Vocaluxe/Base/CGraphics.cs | 10 +- Vocaluxe/Base/CLanguage.cs | 8 +- Vocaluxe/Base/CMain.cs | 8 +- Vocaluxe/Base/CSongCategorizer.cs | 30 ++-- Vocaluxe/Base/CSound.cs | 25 ++-- Vocaluxe/Base/Font/CGlyph.cs | 1 - Vocaluxe/GameModes/CGameModes.cs | 3 - .../Lib/Input/{IInput.cs => IController.cs} | 2 +- Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs | 2 +- Vocaluxe/Lib/Sound/CDirectSoundRecord.cs | 61 ++++----- Vocaluxe/Lib/Sound/CPortAudioRecord.cs | 60 ++++---- Vocaluxe/Lib/Sound/IRecord.cs | 16 +-- Vocaluxe/Program.cs | 6 +- Vocaluxe/Screens/CScreenOptionsRecord.cs | 129 ++++++------------ Vocaluxe/Screens/CScreenOptionsTheme.cs | 1 - Vocaluxe/Screens/CScreenParty.cs | 14 +- Vocaluxe/Screens/CScreenSing.cs | 2 + Vocaluxe/Screens/CScreenSong.cs | 2 + Vocaluxe/Vocaluxe.csproj | 4 +- VocaluxeLib/Menu/CBasic.cs | 6 +- VocaluxeLib/Menu/CParticle.cs | 2 + VocaluxeLib/Menu/CText.cs | 12 ++ VocaluxeLib/Menu/IMenu.cs | 2 +- VocaluxeLib/Menu/SingNotes/CNotes.cs | 16 +-- .../Menu/SongMenu/CSongMenuTileBoard.cs | 11 +- 30 files changed, 232 insertions(+), 346 deletions(-) rename Vocaluxe/Base/{CInput.cs => CController.cs} (73%) rename Vocaluxe/Lib/Input/{IInput.cs => IController.cs} (99%) diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs index 85730d80..21a40bc0 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs @@ -504,7 +504,9 @@ namespace VocaluxeLib.PartyModes.Challenge _RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")"; int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]; _RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName; + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression _RoundsTable[i].TextScores[p].Text = _GameState.Results[i + _RoundsTableOffset, p].ToString(); else _RoundsTable[i].TextScores[p].Text = ""; diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs index 02343aa0..99046d1e 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs @@ -504,7 +504,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley _RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")"; int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]; _RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName; + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression _RoundsTable[i].TextScores[p].Text = _GameState.Results[i + _RoundsTableOffset, p].ToString(); else _RoundsTable[i].TextScores[p].Text = ""; diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index f15bb95d..01fcfac2 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Text; @@ -266,7 +267,6 @@ namespace Vocaluxe.Base MicConfig[p - 1] = new SMicConfig(0); xmlReader.GetValue("//root/Record/MicConfig" + p + "/DeviceName", out MicConfig[p - 1].DeviceName, String.Empty); xmlReader.GetValue("//root/Record/MicConfig" + p + "/DeviceDriver", out MicConfig[p - 1].DeviceDriver, String.Empty); - xmlReader.GetValue("//root/Record/MicConfig" + p + "/InputName", out MicConfig[p - 1].InputName, String.Empty); xmlReader.TryGetIntValue("//root/Record/MicConfig" + p + "/Channel", ref MicConfig[p - 1].Channel); } @@ -514,13 +514,12 @@ namespace Vocaluxe.Base for (int p = 1; p <= CSettings.MaxNumPlayer; p++) { - if (MicConfig[p - 1].DeviceName != "" && MicConfig[p - 1].InputName != "" && MicConfig[p - 1].Channel > 0) + if (MicConfig[p - 1].DeviceName != "" && MicConfig[p - 1].Channel > 0) { writer.WriteStartElement("MicConfig" + p); writer.WriteElementString("DeviceName", MicConfig[p - 1].DeviceName); writer.WriteElementString("DeviceDriver", MicConfig[p - 1].DeviceDriver); - writer.WriteElementString("InputName", MicConfig[p - 1].InputName); writer.WriteElementString("Channel", MicConfig[p - 1].Channel.ToString()); writer.WriteEndElement(); @@ -563,19 +562,11 @@ namespace Vocaluxe.Base /// public static bool IsMicConfig() { - SRecordDevice[] devices = CSound.RecordGetDevices(); + ReadOnlyCollection devices = CSound.RecordGetDevices(); if (devices == null) return false; - for (int dev = 0; dev < devices.Length; dev++) - { - for (int inp = 0; inp < devices[dev].Inputs.Count; inp++) - { - if (devices[dev].Inputs[inp].PlayerChannel1 != 0 || devices[dev].Inputs[inp].PlayerChannel2 != 0) - return true; - } - } - return false; + return devices.Any(t => t.PlayerChannel1 != 0 || t.PlayerChannel2 != 0); } /// @@ -585,19 +576,11 @@ namespace Vocaluxe.Base /// public static bool IsMicConfig(int player) { - SRecordDevice[] devices = CSound.RecordGetDevices(); + ReadOnlyCollection devices = CSound.RecordGetDevices(); if (devices == null) return false; - for (int dev = 0; dev < devices.Length; dev++) - { - for (int inp = 0; inp < devices[dev].Inputs.Count; inp++) - { - if (devices[dev].Inputs[inp].PlayerChannel1 == player || devices[dev].Inputs[inp].PlayerChannel2 == player) - return true; - } - } - return false; + return devices.Any(t => t.PlayerChannel1 == player || t.PlayerChannel2 == player); } public static int GetMaxNumMics() @@ -620,65 +603,53 @@ namespace Vocaluxe.Base { //Look for (usb-)mic //SRecordDevice[] Devices = new SRecordDevice[CSound.RecordGetDevices().Length]; - SRecordDevice[] devices = CSound.RecordGetDevices(); + ReadOnlyCollection devices = CSound.RecordGetDevices(); if (devices == null) return false; - for (int dev = 0; dev < devices.Length; dev++) + foreach (CRecordDevice device in devices) { //Has Device some signal-names in name -> This could be a (usb-)mic - if (Regex.IsMatch(devices[dev].Name, "Usb|Wireless", RegexOptions.IgnoreCase)) + if (Regex.IsMatch(device.Name, "Usb|Wireless", RegexOptions.IgnoreCase)) { - //Check if there are inputs. - if (devices[dev].Inputs.Count >= 1) + //Check if there is one or more channels + if (device.Channels >= 2) { - //Check if there is one or more channels - if (devices[dev].Inputs[0].Channels >= 2) - { - //Set this device to player 1 - MicConfig[0].DeviceName = devices[dev].Name; - MicConfig[0].DeviceDriver = devices[dev].Driver; - MicConfig[0].InputName = devices[dev].Inputs[0].Name; - MicConfig[0].Channel = 1; - //Set this device to player 2 - MicConfig[1].DeviceName = devices[dev].Name; - MicConfig[1].DeviceDriver = devices[dev].Driver; - MicConfig[1].InputName = devices[dev].Inputs[0].Name; - MicConfig[1].Channel = 2; + //Set this device to player 1 + MicConfig[0].DeviceName = device.Name; + MicConfig[0].DeviceDriver = device.Driver; + MicConfig[0].Channel = 1; + //Set this device to player 2 + MicConfig[1].DeviceName = device.Name; + MicConfig[1].DeviceDriver = device.Driver; + MicConfig[1].Channel = 2; - return true; - } + return true; } } } //If no usb-mics found -> Look for Devices with "mic" or "mik" - for (int dev = 0; dev < devices.Length; dev++) + foreach (CRecordDevice device in devices) { //Has Device some signal-names in name -> This could be a mic - if (Regex.IsMatch(devices[dev].Name, "Mic|Mik", RegexOptions.IgnoreCase)) + if (Regex.IsMatch(device.Name, "Mic|Mik", RegexOptions.IgnoreCase)) { - //Check if there are inputs. - if (devices[dev].Inputs.Count >= 1) + //Check if there is one or more channels + if (device.Channels >= 1) { - //Check if there is one or more channels - if (devices[dev].Inputs[0].Channels >= 1) + //Set this device to player 1 + MicConfig[0].DeviceName = device.Name; + MicConfig[0].DeviceDriver = device.Driver; + MicConfig[0].Channel = 1; + + if (device.Channels >= 2) { - //Set this device to player 1 - MicConfig[0].DeviceName = devices[dev].Name; - MicConfig[0].DeviceDriver = devices[dev].Driver; - MicConfig[0].InputName = devices[dev].Inputs[0].Name; - MicConfig[0].Channel = 1; + //Set this device to player 2 + MicConfig[1].DeviceName = device.Name; + MicConfig[1].DeviceDriver = device.Driver; + MicConfig[1].Channel = 2; - if (devices[dev].Inputs[0].Channels >= 2) - { - //Set this device to player 2 - MicConfig[1].DeviceName = devices[dev].Name; - MicConfig[1].DeviceDriver = devices[dev].Driver; - MicConfig[1].InputName = devices[dev].Inputs[0].Name; - MicConfig[1].Channel = 2; - - return true; - } + return true; } } } diff --git a/Vocaluxe/Base/CInput.cs b/Vocaluxe/Base/CController.cs similarity index 73% rename from Vocaluxe/Base/CInput.cs rename to Vocaluxe/Base/CController.cs index 84632970..5014eef8 100644 --- a/Vocaluxe/Base/CInput.cs +++ b/Vocaluxe/Base/CController.cs @@ -23,56 +23,56 @@ using VocaluxeLib.Menu; namespace Vocaluxe.Base { - static class CInput + static class CController { - private static IInput _Input; + private static IController _Controller; public static void Init() { - _Input = new CWiiMote(); + _Controller = new CWiiMote(); - _Input.Init(); + _Controller.Init(); } public static void Close() { - _Input.Close(); - _Input = null; + _Controller.Close(); + _Controller = null; } public static void Connect() { - _Input.Connect(); + _Controller.Connect(); } public static void Disconnect() { - _Input.Disconnect(); + _Controller.Disconnect(); } public static bool IsConnected() { - return _Input.IsConnected(); + return _Controller.IsConnected(); } public static void Update() { - _Input.Update(); + _Controller.Update(); } public static bool PollKeyEvent(ref SKeyEvent keyEvent) { - return _Input.PollKeyEvent(ref keyEvent); + return _Controller.PollKeyEvent(ref keyEvent); } public static bool PollMouseEvent(ref SMouseEvent mouseEvent) { - return _Input.PollMouseEvent(ref mouseEvent); + return _Controller.PollMouseEvent(ref mouseEvent); } public static void SetRumble(float duration) { - _Input.SetRumble(duration); + _Controller.SetRumble(duration); } } } \ No newline at end of file diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 7d9ecdda..79ae5999 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -708,17 +708,9 @@ namespace Vocaluxe.Base } //This is a USDX 1.01 DB - if (!dateExists) - { - command.CommandText = - "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', '0', '0', '0', Difficulty from US_Scores"; - } - else - { - // This is a CMD 1.01 DB - command.CommandText = - "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', Date, '0', '0', Difficulty from US_Scores"; - } + command.CommandText = !dateExists + ? "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', '0', '0', '0', Difficulty from US_Scores" + : "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', Date, '0', '0', Difficulty from US_Scores"; command.ExecuteNonQuery(); command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs"; @@ -763,7 +755,9 @@ namespace Vocaluxe.Base stmt = new Sqlite3.Vdbe(); + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (!dateExists) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression res = Sqlite3.sqlite3_prepare_v2(oldDB, "SELECT id, PlayerName FROM Scores", -1, ref stmt, 0); else res = Sqlite3.sqlite3_prepare_v2(oldDB, "SELECT id, PlayerName, Date FROM Scores", -1, ref stmt, 0); diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index 23e0c7ec..a7f03f65 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -320,7 +320,7 @@ namespace Vocaluxe.Base CVideo.Update(); CSound.Update(); CBackgroundMusic.Update(); - CInput.Update(); + CController.Update(); if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC && _CurrentScreen != EScreens.ScreenSing) CSongs.LoadCover(); @@ -512,7 +512,7 @@ namespace Vocaluxe.Base bool resume = true; bool eventsAvailable; - bool inputEventsAvailable = CInput.PollKeyEvent(ref inputKeyEvent); + bool inputEventsAvailable = CController.PollKeyEvent(ref inputKeyEvent); while ((eventsAvailable = keys.PollEvent(ref keyEvent)) || inputEventsAvailable) { @@ -617,10 +617,10 @@ namespace Vocaluxe.Base } if (!eventsAvailable) - inputEventsAvailable = CInput.PollKeyEvent(ref inputKeyEvent); + inputEventsAvailable = CController.PollKeyEvent(ref inputKeyEvent); } - inputEventsAvailable = CInput.PollMouseEvent(ref inputMouseEvent); + inputEventsAvailable = CController.PollMouseEvent(ref inputMouseEvent); while ((eventsAvailable = mouse.PollEvent(ref mouseEvent)) || inputEventsAvailable) { @@ -678,7 +678,7 @@ namespace Vocaluxe.Base resume &= _Screens[(int)_CurrentScreen].HandleMouse(mouseEvent); if (!eventsAvailable) - inputEventsAvailable = CInput.PollMouseEvent(ref inputMouseEvent); + inputEventsAvailable = CController.PollMouseEvent(ref inputMouseEvent); } return resume; } diff --git a/Vocaluxe/Base/CLanguage.cs b/Vocaluxe/Base/CLanguage.cs index c9024d67..fa48225c 100644 --- a/Vocaluxe/Base/CLanguage.cs +++ b/Vocaluxe/Base/CLanguage.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using System.Xml; using VocaluxeLib.Menu; @@ -168,12 +169,7 @@ namespace Vocaluxe.Base List files = new List(); files.AddRange(CHelper.ListFiles(path, "*.xml", true, true)); - foreach (string file in files) - { - if (!_LoadPartyLanguageFile(partyModeID, file)) - return false; - } - return true; + return files.All(file => _LoadPartyLanguageFile(partyModeID, file)); } private static bool _LoadLanguageEntries(CXMLReader xmlReader, out Dictionary texts) diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index e894da18..4f959225 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -46,13 +46,13 @@ namespace Vocaluxe.Base private static readonly ISound _Sound = new CBsound(); private static readonly ICover _Cover = new CBcover(); private static readonly IDataBase _DataBase = new CBdataBase(); - private static readonly IInputs _Input = new CBinputs(); + private static readonly IControllers _Controller = new CBcontrollers(); private static readonly IPlaylist _Playlist = new CBplaylist(); public static void Init() { 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, _Controller, _Playlist); } } @@ -770,11 +770,11 @@ namespace Vocaluxe.Base } } - class CBinputs : IInputs + class CBcontrollers : IControllers { public void SetRumble(float duration) { - CInput.SetRumble(duration); + CController.SetRumble(duration); } } diff --git a/Vocaluxe/Base/CSongCategorizer.cs b/Vocaluxe/Base/CSongCategorizer.cs index d442bd20..db61fe26 100644 --- a/Vocaluxe/Base/CSongCategorizer.cs +++ b/Vocaluxe/Base/CSongCategorizer.cs @@ -67,17 +67,17 @@ namespace Vocaluxe.Base { CCategory lastCategory = null; CCategory notLetterCat = null; - for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) + foreach (CSongPointer songPointer in CSongs.Sorter.SortedSongs) { - Char firstLetter = Char.ToUpper(CSongs.Sorter.SortedSongs[i].SortString.Normalize(NormalizationForm.FormD)[0]); + Char firstLetter = Char.ToUpper(songPointer.SortString.Normalize(NormalizationForm.FormD)[0]); if (Char.IsLetter(firstLetter)) { - if (lastCategory == null || CSongs.Sorter.SortedSongs[i].SortString != lastCategory.Name) + if (lastCategory == null || songPointer.SortString != lastCategory.Name) { - lastCategory = new CCategory(CSongs.Sorter.SortedSongs[i].SortString); + lastCategory = new CCategory(songPointer.SortString); _Categories.Add(lastCategory); } - lastCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]); + lastCategory.Songs.Add(songPointer); } else { @@ -86,7 +86,7 @@ namespace Vocaluxe.Base notLetterCat = new CCategory("#"); _Categories.Add(notLetterCat); } - notLetterCat.Songs.Add(CSongs.Sorter.SortedSongs[i]); + notLetterCat.Songs.Add(songPointer); } } } @@ -95,16 +95,16 @@ namespace Vocaluxe.Base { CCategory lastCategory = null; CCategory noCategory = null; - for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) + foreach (CSongPointer songPointer in CSongs.Sorter.SortedSongs) { - if (CSongs.Sorter.SortedSongs[i].SortString != "") + if (songPointer.SortString != "") { - if (lastCategory == null || CSongs.Sorter.SortedSongs[i].SortString != lastCategory.Name) + if (lastCategory == null || songPointer.SortString != lastCategory.Name) { - lastCategory = new CCategory(CSongs.Sorter.SortedSongs[i].SortString); + lastCategory = new CCategory(songPointer.SortString); _Categories.Add(lastCategory); } - lastCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]); + lastCategory.Songs.Add(songPointer); } else { @@ -113,7 +113,7 @@ namespace Vocaluxe.Base noCategory = new CCategory(noCategoryName); _Categories.Add(noCategory); } - noCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]); + noCategory.Songs.Add(songPointer); } } } @@ -149,13 +149,13 @@ namespace Vocaluxe.Base { if (sorting == ESongSorting.TR_CONFIG_DECADE) { - for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) + foreach (CSongPointer songPointer in CSongs.Sorter.SortedSongs) { - string year = CSongs.Sorter.SortedSongs[i].SortString; + string year = songPointer.SortString; if (year != "") { year = year.Substring(0, 3); - CSongs.Sorter.SortedSongs[i].SortString = year + "0 - " + year + "9"; + songPointer.SortString = year + "0 - " + year + "9"; } } } diff --git a/Vocaluxe/Base/CSound.cs b/Vocaluxe/Base/CSound.cs index 70b0e598..1ac824a7 100644 --- a/Vocaluxe/Base/CSound.cs +++ b/Vocaluxe/Base/CSound.cs @@ -18,6 +18,7 @@ #endregion using System; +using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using Vocaluxe.Lib.Sound; @@ -226,9 +227,7 @@ namespace Vocaluxe.Base public static bool RecordStart() { - SRecordDevice[] devices = RecordGetDevices(); - - return _Record.Start(devices); + return _Record.Start(); } public static bool RecordStop() @@ -276,23 +275,16 @@ namespace Vocaluxe.Base return _Record.ToneWeigth(player); } - public static SRecordDevice[] RecordGetDevices() + public static ReadOnlyCollection RecordGetDevices() { - SRecordDevice[] devices = _Record.RecordDevices(); + ReadOnlyCollection devices = _Record.RecordDevices(); if (devices != null) { - for (int dev = 0; dev < devices.Length; dev++) + foreach (CRecordDevice device in devices) { - for (int inp = 0; inp < devices[dev].Inputs.Count; inp++) - { - SInput input = devices[dev].Inputs[inp]; - - input.PlayerChannel1 = _GetPlayerFromMicConfig(devices[dev].Name, devices[dev].Driver, input.Name, 1); - input.PlayerChannel2 = _GetPlayerFromMicConfig(devices[dev].Name, devices[dev].Driver, input.Name, 2); - - devices[dev].Inputs[inp] = input; - } + device.PlayerChannel1 = _GetPlayerFromMicConfig(device.Name, device.Driver, 1); + device.PlayerChannel2 = _GetPlayerFromMicConfig(device.Name, device.Driver, 2); } return devices; } @@ -300,14 +292,13 @@ namespace Vocaluxe.Base return null; } - private static int _GetPlayerFromMicConfig(string device, string devicedriver, string input, int channel) + private static int _GetPlayerFromMicConfig(string device, string devicedriver, int channel) { for (int p = 0; p < CSettings.MaxNumPlayer; p++) { if (CConfig.MicConfig[p].Channel != 0 && CConfig.MicConfig[p].DeviceName == device && CConfig.MicConfig[p].DeviceDriver == devicedriver && - CConfig.MicConfig[p].InputName == input && CConfig.MicConfig[p].Channel == channel) return p + 1; } diff --git a/Vocaluxe/Base/Font/CGlyph.cs b/Vocaluxe/Base/Font/CGlyph.cs index c9cfe58b..a8b5bdc8 100644 --- a/Vocaluxe/Base/Font/CGlyph.cs +++ b/Vocaluxe/Base/Font/CGlyph.cs @@ -20,7 +20,6 @@ using System; using System.Drawing; using System.Drawing.Drawing2D; -using System.Drawing.Imaging; using System.Drawing.Text; using System.Windows.Forms; using VocaluxeLib.Menu; diff --git a/Vocaluxe/GameModes/CGameModes.cs b/Vocaluxe/GameModes/CGameModes.cs index a29847a0..822d599e 100644 --- a/Vocaluxe/GameModes/CGameModes.cs +++ b/Vocaluxe/GameModes/CGameModes.cs @@ -17,10 +17,7 @@ // */ #endregion -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using Vocaluxe.Base; using VocaluxeLib.Menu; using VocaluxeLib.Menu.SongMenu; diff --git a/Vocaluxe/Lib/Input/IInput.cs b/Vocaluxe/Lib/Input/IController.cs similarity index 99% rename from Vocaluxe/Lib/Input/IInput.cs rename to Vocaluxe/Lib/Input/IController.cs index a78a5018..f54c25bf 100644 --- a/Vocaluxe/Lib/Input/IInput.cs +++ b/Vocaluxe/Lib/Input/IController.cs @@ -32,7 +32,7 @@ namespace Vocaluxe.Lib.Input ScrollUp } - interface IInput + interface IController { void Init(); void Close(); diff --git a/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs b/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs index 867458d6..2ff404d1 100644 --- a/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs +++ b/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs @@ -27,7 +27,7 @@ using VocaluxeLib.Menu; namespace Vocaluxe.Lib.Input.WiiMote { - class CWiiMote : IInput, IDisposable + class CWiiMote : IController, IDisposable { private CWiiMoteLib _WiiMote; diff --git a/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs b/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs index 746e4bca..fad206a4 100644 --- a/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs +++ b/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs @@ -17,6 +17,7 @@ // */ #endregion +using System.Collections.ObjectModel; using SlimDX.DirectSound; using SlimDX.Multimedia; using System; @@ -29,8 +30,7 @@ namespace Vocaluxe.Lib.Sound class CDirectSoundRecord : IRecord { private bool _Initialized; - private List _Devices; - private SRecordDevice[] _DeviceConfig; + private List _Devices; private List _Sources; private readonly CBuffer[] _Buffer; @@ -47,7 +47,7 @@ namespace Vocaluxe.Lib.Sound public bool Init() { DeviceCollection devices = DirectSoundCapture.GetDevices(); - _Devices = new List(); + _Devices = new List(); _Sources = new List(); int id = 0; @@ -55,21 +55,17 @@ namespace Vocaluxe.Lib.Sound { using (DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid)) { - SRecordDevice device = new SRecordDevice {Driver = dev.DriverGuid.ToString(), ID = id, Name = dev.Description, Inputs = new List()}; + CRecordDevice device = new CRecordDevice {Driver = dev.DriverGuid.ToString(), ID = id, Name = dev.Description, Channels = ds.Capabilities.Channels}; - SInput inp = new SInput {Name = "Default", Channels = ds.Capabilities.Channels}; + if (device.Channels > 2) + device.Channels = 2; //more are not supported in vocaluxe - if (inp.Channels > 2) - inp.Channels = 2; //more are not supported in vocaluxe - - device.Inputs.Add(inp); _Devices.Add(device); id++; } } - _DeviceConfig = _Devices.ToArray(); _Initialized = true; return true; @@ -85,7 +81,7 @@ namespace Vocaluxe.Lib.Sound //System.IO.File.WriteAllBytes("test0.raw", _Buffer[0].Buffer); } - public bool Start(SRecordDevice[] deviceConfig) + public bool Start() { if (!_Initialized) return false; @@ -93,21 +89,16 @@ namespace Vocaluxe.Lib.Sound foreach (CBuffer buffer in _Buffer) buffer.Reset(); - _DeviceConfig = deviceConfig; - bool[] active = new bool[deviceConfig.Length]; - Guid[] guid = new Guid[deviceConfig.Length]; - short[] channels = new short[deviceConfig.Length]; - for (int dev = 0; dev < deviceConfig.Length; dev++) + bool[] active = new bool[_Devices.Count]; + Guid[] guid = new Guid[_Devices.Count]; + short[] channels = new short[_Devices.Count]; + for (int dev = 0; dev < _Devices.Count; dev++) { active[dev] = false; - for (int inp = 0; inp < deviceConfig[dev].Inputs.Count; inp++) - { - if (deviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 || - deviceConfig[dev].Inputs[inp].PlayerChannel2 > 0) - active[dev] = true; - guid[dev] = new Guid(deviceConfig[dev].Driver); - channels[dev] = (short)deviceConfig[dev].Inputs[0].Channels; - } + if (_Devices[dev].PlayerChannel1 > 0 || _Devices[dev].PlayerChannel2 > 0) + active[dev] = true; + guid[dev] = new Guid(_Devices[dev].Driver); + channels[dev] = (short)_Devices[dev].Channels; } for (int i = 0; i < _Devices.Count; i++) @@ -121,8 +112,6 @@ namespace Vocaluxe.Lib.Sound _Sources.Add(source); } } - - _DeviceConfig = deviceConfig; return true; } @@ -189,7 +178,7 @@ namespace Vocaluxe.Lib.Sound return _Buffer[player].ToneValid; } - public SRecordDevice[] RecordDevices() + public ReadOnlyCollection RecordDevices() { if (!_Initialized) return null; @@ -197,7 +186,7 @@ namespace Vocaluxe.Lib.Sound if (_Devices.Count == 0) return null; - return _Devices.ToArray(); + return _Devices.AsReadOnly(); } public int NumHalfTones(int player) @@ -232,21 +221,21 @@ namespace Vocaluxe.Lib.Sound rightBuffer[i] = e.Data[i * 2 - (i % 2) + 2]; } - for (int i = 0; i < _DeviceConfig.Length; i++) + foreach (CRecordDevice device in _Devices) { - if (_DeviceConfig[i].Driver == e.Guid.ToString()) + if (device.Driver == e.Guid.ToString()) { - if (_DeviceConfig[i].Inputs[0].PlayerChannel1 > 0) - _Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer); + if (device.PlayerChannel1 > 0) + _Buffer[device.PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer); - if (_DeviceConfig[i].Inputs[0].PlayerChannel2 > 0) - _Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer); + if (device.PlayerChannel2 > 0) + _Buffer[device.PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer); } } } } - public class CSampleDataEventArgs : EventArgs + private class CSampleDataEventArgs : EventArgs { public CSampleDataEventArgs(byte[] data, Guid guid) { @@ -258,7 +247,7 @@ namespace Vocaluxe.Lib.Sound public Guid Guid { get; private set; } } - public class CSoundCardSource : IDisposable + private class CSoundCardSource : IDisposable { private volatile bool _Running; private readonly int _BufferSize; diff --git a/Vocaluxe/Lib/Sound/CPortAudioRecord.cs b/Vocaluxe/Lib/Sound/CPortAudioRecord.cs index 5508dfce..0f51fa31 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioRecord.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioRecord.cs @@ -17,6 +17,7 @@ // */ #endregion +using System.Collections.ObjectModel; using System.Threading; using System; using System.Collections.Generic; @@ -29,8 +30,7 @@ namespace Vocaluxe.Lib.Sound class CPortAudioRecord : IRecord { private bool _Initialized; - private List _Devices; - private SRecordDevice[] _DeviceConfig; + private List _Devices; private CPortAudio.PaStreamCallbackDelegate _MyRecProc; private IntPtr[] _RecHandle; @@ -39,7 +39,7 @@ namespace Vocaluxe.Lib.Sound public CPortAudioRecord() { - _DeviceConfig = null; + _Devices = null; _Buffer = new CBuffer[CSettings.MaxNumPlayer]; for (int i = 0; i < _Buffer.Length; i++) @@ -54,7 +54,7 @@ namespace Vocaluxe.Lib.Sound /// true if success public bool Init() { - _Devices = new List(); + _Devices = new List(); try { @@ -73,22 +73,17 @@ namespace Vocaluxe.Lib.Sound CPortAudio.SPaDeviceInfo info = CPortAudio.PaGetDeviceInfo(i); if (info.HostApi == hostAPI && info.MaxInputChannels > 0) { - SRecordDevice dev = new SRecordDevice {ID = i, Name = info.Name, Driver = info.Name + i, Inputs = new List()}; + CRecordDevice dev = new CRecordDevice {ID = i, Name = info.Name, Driver = info.Name + i, Channels = info.MaxInputChannels}; - SInput inp = new SInput {Name = "Default", Channels = info.MaxInputChannels}; + if (dev.Channels > 2) + dev.Channels = 2; //more are not supported in vocaluxe - if (inp.Channels > 2) - inp.Channels = 2; //more are not supported in vocaluxe - - dev.Inputs.Add(inp); _Devices.Add(dev); } } _RecHandle = new IntPtr[_Devices.Count]; - _MyRecProc = MyPaStreamCallback; - - _DeviceConfig = _Devices.ToArray(); + _MyRecProc = _MyPaStreamCallback; } catch (Exception e) { @@ -103,16 +98,12 @@ namespace Vocaluxe.Lib.Sound /// /// Start Voice Capturing /// - /// /// - public bool Start(SRecordDevice[] deviceConfig) + public bool Start() { if (!_Initialized) return false; - if (deviceConfig == null) - return false; - if (_RecHandle == null || _RecHandle.Length == 0) return false; @@ -132,17 +123,12 @@ namespace Vocaluxe.Lib.Sound for (int i = 0; i < _RecHandle.Length; i++) _RecHandle[i] = IntPtr.Zero; - _DeviceConfig = deviceConfig; - bool[] active = new bool[deviceConfig.Length]; - for (int dev = 0; dev < deviceConfig.Length; dev++) + bool[] active = new bool[_Devices.Count]; + for (int dev = 0; dev < _Devices.Count; dev++) { active[dev] = false; - for (int inp = 0; inp < deviceConfig[dev].Inputs.Count; inp++) - { - if (deviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 || - deviceConfig[dev].Inputs[inp].PlayerChannel2 > 0) - active[dev] = true; - } + if (_Devices[dev].PlayerChannel1 > 0 || _Devices[dev].PlayerChannel2 > 0) + active[dev] = true; } for (int i = 0; i < _RecHandle.Length; i++) @@ -151,10 +137,10 @@ namespace Vocaluxe.Lib.Sound { CPortAudio.SPaStreamParameters inputParams = new CPortAudio.SPaStreamParameters { - ChannelCount = _DeviceConfig[i].Inputs[0].Channels, - Device = _DeviceConfig[i].ID, + ChannelCount = _Devices[i].Channels, + Device = _Devices[i].ID, SampleFormat = CPortAudio.EPaSampleFormat.PaInt16, - SuggestedLatency = CPortAudio.PaGetDeviceInfo(_DeviceConfig[i].ID).DefaultLowInputLatency + SuggestedLatency = CPortAudio.PaGetDeviceInfo(_Devices[i].ID).DefaultLowInputLatency }; if (_ErrorCheck("OpenStream (rec)", CPortAudio.Pa_OpenStream( @@ -273,7 +259,7 @@ namespace Vocaluxe.Lib.Sound return _Buffer[player].ToneWeigth; } - public SRecordDevice[] RecordDevices() + public ReadOnlyCollection RecordDevices() { if (!_Initialized) return null; @@ -281,10 +267,10 @@ namespace Vocaluxe.Lib.Sound if (_Devices.Count == 0) return null; - return _Devices.ToArray(); + return _Devices.AsReadOnly(); } - public CPortAudio.EPaStreamCallbackResult MyPaStreamCallback( + private CPortAudio.EPaStreamCallbackResult _MyPaStreamCallback( IntPtr input, IntPtr output, uint frameCount, @@ -315,11 +301,11 @@ namespace Vocaluxe.Lib.Sound { if (new IntPtr(i) == userData) { - if (_DeviceConfig[i].Inputs[0].PlayerChannel1 > 0) - _Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer); + if (_Devices[i].PlayerChannel1 > 0) + _Buffer[_Devices[i].PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer); - if (_DeviceConfig[i].Inputs[0].PlayerChannel2 > 0) - _Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer); + if (_Devices[i].PlayerChannel2 > 0) + _Buffer[_Devices[i].PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer); break; } diff --git a/Vocaluxe/Lib/Sound/IRecord.cs b/Vocaluxe/Lib/Sound/IRecord.cs index 2246f3e3..e7de0ce8 100644 --- a/Vocaluxe/Lib/Sound/IRecord.cs +++ b/Vocaluxe/Lib/Sound/IRecord.cs @@ -18,23 +18,17 @@ #endregion using System; -using System.Collections.Generic; +using System.Collections.ObjectModel; namespace Vocaluxe.Lib.Sound { - struct SRecordDevice + class CRecordDevice { public int ID; public string Name; public string Driver; - public List Inputs; - } - struct SInput - { - public string Name; public int Channels; - public int PlayerChannel1; public int PlayerChannel2; } @@ -43,7 +37,6 @@ namespace Vocaluxe.Lib.Sound { public string DeviceName; public string DeviceDriver; - public string InputName; public int Channel; // ReSharper disable UnusedParameter.Local @@ -52,7 +45,6 @@ namespace Vocaluxe.Lib.Sound { DeviceName = String.Empty; DeviceDriver = String.Empty; - InputName = String.Empty; Channel = 0; } } @@ -62,7 +54,7 @@ namespace Vocaluxe.Lib.Sound bool Init(); void CloseAll(); - bool Start(SRecordDevice[] deviceConfig); + bool Start(); bool Stop(); void AnalyzeBuffer(int player); @@ -74,6 +66,6 @@ namespace Vocaluxe.Lib.Sound int NumHalfTones(int player); float[] ToneWeigth(int player); - SRecordDevice[] RecordDevices(); + ReadOnlyCollection RecordDevices(); } } \ No newline at end of file diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 75845cb1..5f204724 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -185,8 +185,8 @@ namespace Vocaluxe // Init Input CLog.StartBenchmark(0, "Init Input"); - CInput.Init(); - CInput.Connect(); + CController.Init(); + CController.Connect(); CLog.StopBenchmark(0, "Init Input"); // Init Game; @@ -220,7 +220,7 @@ namespace Vocaluxe try { CLog.CloseAll(); - CInput.Close(); + CController.Close(); CSound.RecordCloseAll(); CSound.CloseAllStreams(); CVideo.VdCloseAll(); diff --git a/Vocaluxe/Screens/CScreenOptionsRecord.cs b/Vocaluxe/Screens/CScreenOptionsRecord.cs index a1ced44f..ae4d785c 100644 --- a/Vocaluxe/Screens/CScreenOptionsRecord.cs +++ b/Vocaluxe/Screens/CScreenOptionsRecord.cs @@ -18,6 +18,7 @@ #endregion using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Windows.Forms; using Vocaluxe.Base; @@ -42,7 +43,6 @@ namespace Vocaluxe.Screens private const float _MaxDelayTime = 1f; private const string _SelectSlideRecordDevices = "SelectSlideRecordDevices"; - private const string _SelectSlideRecordInputs = "SelectSlideRecordInputs"; private const string _SelectSlideRecordChannel1 = "SelectSlideRecordChannel1"; private const string _SelectSlideRecordChannel2 = "SelectSlideRecordChannel2"; @@ -63,9 +63,8 @@ namespace Vocaluxe.Screens private readonly string[] _StaticEnergyChannel = new string[] {"StaticEnergyChannel1", "StaticEnergyChannel2"}; private float[] _ChannelEnergy; - private SRecordDevice[] _Devices; + private ReadOnlyCollection _Devices; private int _DeviceNr; - private int _InputNr; private SDelayTest[] _DelayTest; private bool _DelayTestRunning; @@ -81,7 +80,7 @@ namespace Vocaluxe.Screens _ThemeTexts = new string[] {_TextWarning, _TextDelayChannel1, _TextDelayChannel2}; _ThemeButtons = new string[] {_ButtonExit, _ButtonDelayTest}; - _ThemeSelectSlides = new string[] {_SelectSlideRecordDevices, _SelectSlideRecordInputs, _SelectSlideRecordChannel1, _SelectSlideRecordChannel2, _SelectSlideDelay}; + _ThemeSelectSlides = new string[] {_SelectSlideRecordDevices, _SelectSlideRecordChannel1, _SelectSlideRecordChannel2, _SelectSlideDelay}; _ThemeEqualizers = new string[] {_EqualizerChannel1, _EqualizerChannel2}; } @@ -160,9 +159,6 @@ namespace Vocaluxe.Screens if (_SelectSlides[_SelectSlideRecordDevices].Selected) _OnDeviceEvent(); - if (_SelectSlides[_SelectSlideRecordInputs].Selected) - _OnInputEvent(); - if (_SelectSlides[_SelectSlideRecordChannel1].Selected || _SelectSlides[_SelectSlideRecordChannel2].Selected) _SetMicConfig(); @@ -175,9 +171,6 @@ namespace Vocaluxe.Screens if (_SelectSlides[_SelectSlideRecordDevices].Selected) _OnDeviceEvent(); - if (_SelectSlides[_SelectSlideRecordInputs].Selected) - _OnInputEvent(); - if (_SelectSlides[_SelectSlideRecordChannel1].Selected || _SelectSlides[_SelectSlideRecordChannel2].Selected) _SetMicConfig(); @@ -205,9 +198,6 @@ namespace Vocaluxe.Screens if (_SelectSlides[_SelectSlideRecordDevices].Selected) _OnDeviceEvent(); - if (_SelectSlides[_SelectSlideRecordInputs].Selected) - _OnInputEvent(); - if (_SelectSlides[_SelectSlideRecordChannel1].Selected || _SelectSlides[_SelectSlideRecordChannel2].Selected) _SetMicConfig(); @@ -311,28 +301,22 @@ namespace Vocaluxe.Screens base.OnShow(); _SelectSlides[_SelectSlideRecordDevices].Clear(); - _SelectSlides[_SelectSlideRecordInputs].Clear(); for (int i = 0; i < _ChannelEnergy.Length; i++) _ChannelEnergy[i] = 0f; _DeviceNr = -1; - _InputNr = -1; _Devices = CSound.RecordGetDevices(); if (_Devices != null) { _DeviceNr = 0; - _InputNr = 0; - _GetFirstConfiguredRecordDevice(ref _DeviceNr, ref _InputNr); + _GetFirstConfiguredRecordDevice(ref _DeviceNr); - for (int dev = 0; dev < _Devices.Length; dev++) - _SelectSlides[_SelectSlideRecordDevices].AddValue(_Devices[dev].Name); + foreach (CRecordDevice device in _Devices) + _SelectSlides[_SelectSlideRecordDevices].AddValue(device.Name); _SelectSlides[_SelectSlideRecordDevices].Selection = _DeviceNr; - for (int inp = 0; inp < _Devices[0].Inputs.Count; inp++) - _SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[0].Inputs[inp].Name); - _SelectSlides[_SelectSlideRecordInputs].Selection = _InputNr; _UpdateChannels(); } @@ -416,24 +400,7 @@ namespace Vocaluxe.Screens { if (_SelectSlides[_SelectSlideRecordDevices].Selection != _DeviceNr) { - _SelectSlides[_SelectSlideRecordInputs].Clear(); _DeviceNr = _SelectSlides[_SelectSlideRecordDevices].Selection; - _InputNr = 0; - - for (int inp = 0; inp < _Devices[_DeviceNr].Inputs.Count; inp++) - _SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[_DeviceNr].Inputs[inp].Name); - _InputNr = 0; - _SelectSlides[_SelectSlideRecordInputs].Selection = 0; - _UpdateChannels(); - } - } - - private void _OnInputEvent() - { - if (_SelectSlides[_SelectSlideRecordInputs].Selection != _InputNr) - { - _InputNr = _SelectSlides[_SelectSlideRecordInputs].Selection; - _UpdateChannels(); } } @@ -457,25 +424,20 @@ namespace Vocaluxe.Screens for (int p = 0; p < CSettings.MaxNumPlayer; p++) CConfig.MicConfig[p].Channel = 0; - for (int dev = 0; dev < _Devices.Length; dev++) + foreach (CRecordDevice device in _Devices) { - for (int inp = 0; inp < _Devices[dev].Inputs.Count; inp++) + if (device.PlayerChannel1 > 0) { - if (_Devices[dev].Inputs[inp].PlayerChannel1 > 0) - { - CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel1 - 1].Channel = 1; - CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel1 - 1].DeviceName = _Devices[dev].Name; - CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel1 - 1].DeviceDriver = _Devices[dev].Driver; - CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel1 - 1].InputName = _Devices[dev].Inputs[inp].Name; - } + CConfig.MicConfig[device.PlayerChannel1 - 1].Channel = 1; + CConfig.MicConfig[device.PlayerChannel1 - 1].DeviceName = device.Name; + CConfig.MicConfig[device.PlayerChannel1 - 1].DeviceDriver = device.Driver; + } - if (_Devices[dev].Inputs[inp].PlayerChannel2 > 0) - { - CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel2 - 1].Channel = 2; - CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel2 - 1].DeviceName = _Devices[dev].Name; - CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel2 - 1].DeviceDriver = _Devices[dev].Driver; - CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel2 - 1].InputName = _Devices[dev].Inputs[inp].Name; - } + if (device.PlayerChannel2 > 0) + { + CConfig.MicConfig[device.PlayerChannel2 - 1].Channel = 2; + CConfig.MicConfig[device.PlayerChannel2 - 1].DeviceName = device.Name; + CConfig.MicConfig[device.PlayerChannel2 - 1].DeviceDriver = device.Driver; } } CConfig.SaveConfig(); @@ -487,16 +449,15 @@ namespace Vocaluxe.Screens { if (_DeviceNr < 0) return; - SInput input = _Devices[_DeviceNr].Inputs[_InputNr]; - input.PlayerChannel1 = _SelectSlides[_SelectSlideRecordChannel1].Selection; - input.PlayerChannel2 = _SelectSlides[_SelectSlideRecordChannel2].Selection; - _Devices[_DeviceNr].Inputs[_InputNr] = input; + CRecordDevice device = _Devices[_DeviceNr]; + device.PlayerChannel1 = _SelectSlides[_SelectSlideRecordChannel1].Selection; + device.PlayerChannel2 = _SelectSlides[_SelectSlideRecordChannel2].Selection; } private void _UpdateChannels() { - _SelectSlides[_SelectSlideRecordChannel1].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel1; - _SelectSlides[_SelectSlideRecordChannel2].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel2; + _SelectSlides[_SelectSlideRecordChannel1].Selection = _Devices[_DeviceNr].PlayerChannel1; + _SelectSlides[_SelectSlideRecordChannel2].Selection = _Devices[_DeviceNr].PlayerChannel2; _SaveMicConfig(); } @@ -510,25 +471,22 @@ namespace Vocaluxe.Screens if (_Devices == null) return true; - for (int dev = 0; dev < _Devices.Length; dev++) + foreach (CRecordDevice device in _Devices) { - for (int inp = 0; inp < _Devices[dev].Inputs.Count; inp++) + if (device.PlayerChannel1 > 0) { - if (_Devices[dev].Inputs[inp].PlayerChannel1 > 0) - { - if (isSet[_Devices[dev].Inputs[inp].PlayerChannel1 - 1]) - return false; + if (isSet[device.PlayerChannel1 - 1]) + return false; - isSet[_Devices[dev].Inputs[inp].PlayerChannel1 - 1] = true; - } + isSet[device.PlayerChannel1 - 1] = true; + } - if (_Devices[dev].Inputs[inp].PlayerChannel2 > 0) - { - if (isSet[_Devices[dev].Inputs[inp].PlayerChannel2 - 1]) - return false; + if (device.PlayerChannel2 > 0) + { + if (isSet[device.PlayerChannel2 - 1]) + return false; - isSet[_Devices[dev].Inputs[inp].PlayerChannel2 - 1] = true; - } + isSet[device.PlayerChannel2 - 1] = true; } } return true; @@ -545,7 +503,7 @@ namespace Vocaluxe.Screens _DelayTestRunning = true; } - private void _GetFirstConfiguredRecordDevice(ref int device, ref int input) + private void _GetFirstConfiguredRecordDevice(ref int device) { if (_Devices == null) return; @@ -553,22 +511,15 @@ namespace Vocaluxe.Screens if (CConfig.MicConfig == null) return; - for (int i = 0; i < _Devices.Length; i++) + if (CConfig.MicConfig[0].Channel <= 0) + return; + + for (int i = 0; i < _Devices.Count; i++) { if (_Devices[i].Name == CConfig.MicConfig[0].DeviceName && _Devices[i].Driver == CConfig.MicConfig[0].DeviceDriver) { - for (int j = 0; j < _Devices[i].Inputs.Count; j++) - { - if (_Devices[i].Inputs[j].Name == CConfig.MicConfig[0].InputName) - { - if (CConfig.MicConfig[0].Channel > 0) - { - device = i; - input = j; - return; - } - } - } + device = i; + return; } } } diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index 5ad72a24..a0570294 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -17,7 +17,6 @@ // */ #endregion -using System; using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Base.Font; diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs index f6e37116..79d12cad 100644 --- a/Vocaluxe/Screens/CScreenParty.cs +++ b/Vocaluxe/Screens/CScreenParty.cs @@ -177,6 +177,7 @@ namespace Vocaluxe.Screens if (!_PartyModeInfos[index].Playable) { _Buttons[_ButtonStart].Visible = false; + _Texts[_TextError].Text = "TR_SCREENPARTY_ERROR"; _Texts[_TextError].Visible = true; } else @@ -193,10 +194,19 @@ namespace Vocaluxe.Screens int index = _SelectSlides[_SelectSlideModes].Selection; if (index >= _PartyModeInfos.Count) - return; + { + _Buttons[_ButtonStart].Visible = false; + _Texts[_TextError].Text = "TR_SCREENPARTY_ERROR"; + _Texts[_TextError].Visible = true; + } if (CConfig.GetMaxNumMics() == 0) - return; //TODO: Add message! + { + _Buttons[_ButtonStart].Visible = false; + _Texts[_TextError].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_PL").Replace("%v", ""); + _Texts[_TextError].Visible = true; + return; + } CParty.SetPartyMode(_PartyModeInfos[index].PartyModeID); CGraphics.FadeTo(EScreens.ScreenPartyDummy); diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 21aff197..43772d45 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -384,7 +384,9 @@ namespace Vocaluxe.Screens for (int p = 0; p < CGame.NumPlayer; p++) { + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (CGame.Players[p].Points < 10000) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Players[p].Points.ToString("0000"); else _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Players[p].Points.ToString("00000"); diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 49e62367..a9de0f7d 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -1157,7 +1157,9 @@ namespace Vocaluxe.Screens if (_SelectSlides[_SelectSlideOptionsPlaylistOpen].NumValues > 0) _SelectSlides[_SelectSlideOptionsPlaylistOpen].Visible = true; + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (_Buttons[_ButtonOptionsRandom].Visible) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression _SetInteractionToButton(_Buttons[_ButtonOptionsRandom]); else _SetInteractionToButton(_Buttons[_ButtonOptionsRandomCategory]); diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 1d1164c9..46d4c11c 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -178,7 +178,7 @@ - + @@ -217,7 +217,7 @@ - + diff --git a/VocaluxeLib/Menu/CBasic.cs b/VocaluxeLib/Menu/CBasic.cs index db31f26b..99fe0818 100644 --- a/VocaluxeLib/Menu/CBasic.cs +++ b/VocaluxeLib/Menu/CBasic.cs @@ -38,12 +38,12 @@ namespace VocaluxeLib.Menu public static ISound Sound; public static ICover Cover; public static IDataBase DataBase; - public static IInputs Input; + public static IControllers Controller; public static IPlaylist Playlist; 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) + ISongs songs, IVideo video, ISound sound, ICover cover, IDataBase dataBase, IControllers controller, IPlaylist playlist) { Config = config; Settings = settings; @@ -62,7 +62,7 @@ namespace VocaluxeLib.Menu Sound = sound; Cover = cover; DataBase = dataBase; - Input = input; + Controller = controller; Playlist = playlist; } } diff --git a/VocaluxeLib/Menu/CParticle.cs b/VocaluxeLib/Menu/CParticle.cs index d33001f0..e9a832cc 100644 --- a/VocaluxeLib/Menu/CParticle.cs +++ b/VocaluxeLib/Menu/CParticle.cs @@ -297,7 +297,9 @@ namespace VocaluxeLib.Menu public void Draw() { + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (_TextureName != "") + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression CBase.Drawing.DrawTexture(CBase.Theme.GetSkinTexture(_TextureName, _PartyModeID), _Rect, new SColorF(_Color.R, _Color.G, _Color.B, _Color.A * Alpha2 * _Alpha)); else CBase.Drawing.DrawTexture(_Texture, _Rect, new SColorF(_Color.R, _Color.G, _Color.B, _Color.A * Alpha2 * _Alpha)); diff --git a/VocaluxeLib/Menu/CText.cs b/VocaluxeLib/Menu/CText.cs index c164bfba..6284e88b 100644 --- a/VocaluxeLib/Menu/CText.cs +++ b/VocaluxeLib/Menu/CText.cs @@ -127,7 +127,9 @@ namespace VocaluxeLib.Menu if (Math.Abs(_MaxWidth - value) > 0.01) { _MaxWidth = value; + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (_MaxWidth > 0) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), _MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); else Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); @@ -332,7 +334,9 @@ namespace VocaluxeLib.Menu Selected = false; + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (MaxWidth > 0) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); else Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); @@ -367,7 +371,9 @@ namespace VocaluxeLib.Menu Selected = false; + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (MaxWidth > 0) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); else Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); @@ -400,7 +406,9 @@ namespace VocaluxeLib.Menu Selected = false; + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (MaxWidth > 0) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); else Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); @@ -435,7 +443,9 @@ namespace VocaluxeLib.Menu Selected = false; + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (MaxWidth > 0) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); else Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); @@ -509,7 +519,9 @@ namespace VocaluxeLib.Menu { LoadTextures(); + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (MaxWidth > 0) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); else Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); diff --git a/VocaluxeLib/Menu/IMenu.cs b/VocaluxeLib/Menu/IMenu.cs index 6c82b349..b698adaa 100644 --- a/VocaluxeLib/Menu/IMenu.cs +++ b/VocaluxeLib/Menu/IMenu.cs @@ -302,7 +302,7 @@ namespace VocaluxeLib.Menu bool GetCover(string fileName, ref STexture texture, int coverSize); } - public interface IInputs + public interface IControllers { void SetRumble(float duration); } diff --git a/VocaluxeLib/Menu/SingNotes/CNotes.cs b/VocaluxeLib/Menu/SingNotes/CNotes.cs index 0de66cf3..de2da998 100644 --- a/VocaluxeLib/Menu/SingNotes/CNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CNotes.cs @@ -348,13 +348,7 @@ namespace VocaluxeLib.Menu.SingNotes public string Lyrics { - get - { - string lyrics = String.Empty; - foreach (CNote note in _Notes) - lyrics += note.Text; - return lyrics; - } + get { return _Notes.Aggregate(String.Empty, (current, note) => current + note.Text); } } public int NoteCount @@ -364,13 +358,7 @@ namespace VocaluxeLib.Menu.SingNotes public int Points { - get - { - int points = 0; - foreach (CNote note in _Notes) - points += note.Points; - return points; - } + get { return _Notes.Sum(note => note.Points); } } public CNote[] Notes diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index ccdc15bd..542e4d67 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -347,7 +347,7 @@ namespace VocaluxeLib.Menu.SongMenu sel = true; if (mouseEvent.Sender == ESender.WiiMote && _ActualSelection != lastselection && _ActualSelection != -1) - CBase.Input.SetRumble(0.050f); + CBase.Controller.SetRumble(0.050f); if (!sel) _ActualSelection = -1; @@ -392,7 +392,9 @@ namespace VocaluxeLib.Menu.SongMenu tile.Draw(1.2f, tile.Rect.Z - 0.1f, EAspect.Crop); else { + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (tile.Texture.Index != _CoverTexture.Index) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression tile.Draw(1f, tile.Rect.Z, EAspect.Crop); else tile.Draw(1f, tile.Rect.Z, EAspect.Stretch); @@ -433,7 +435,9 @@ namespace VocaluxeLib.Menu.SongMenu _Artist.Text = CBase.Songs.GetCategory(actcat).Name; int num = CBase.Songs.NumSongsInCategory(actcat); + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (num != 1) + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression _Title.Text = CBase.Language.Translate("TR_SCREENSONG_NUMSONGS").Replace("%v", num.ToString()); else _Title.Text = CBase.Language.Translate("TR_SCREENSONG_NUMSONG").Replace("%v", num.ToString()); @@ -623,10 +627,7 @@ namespace VocaluxeLib.Menu.SongMenu { if (itemCount > i + offset) { - if (isInCategory) - _Tiles[i].Texture = CBase.Songs.GetVisibleSong(i + offset).CoverTextureSmall; - else - _Tiles[i].Texture = CBase.Songs.GetCategory(i + offset).CoverTextureSmall; + _Tiles[i].Texture = isInCategory ? CBase.Songs.GetVisibleSong(i + offset).CoverTextureSmall : CBase.Songs.GetCategory(i + offset).CoverTextureSmall; _Tiles[i].Color = new SColorF(1f, 1f, 1f, 1f); } else From d239492f1946e27d8beb50a76220b111c8db6d94 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Mon, 29 Apr 2013 16:17:02 +0200 Subject: [PATCH 30/33] Updated record options screen --- .../Ambient/Screens/ScreenOptionsRecord.xml | 108 +----------------- Vocaluxe/Screens/CScreenOptionsRecord.cs | 2 +- 2 files changed, 7 insertions(+), 103 deletions(-) diff --git a/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml b/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml index 4692b664..9362f766 100644 --- a/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml +++ b/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml @@ -1,7 +1,7 @@  - 2 + 3 Video @@ -216,35 +216,6 @@ - - 75 - 165 - - 0,00 - - 32 - - - - StaticColor - - - TextSColor - - Left - - Center - - - - Outline - - TR_SCREENORECORD_INPUT - - - - - 75 225 @@ -272,8 +243,8 @@ - - + + 75 285 @@ -301,8 +272,8 @@ - - + + 75 345 @@ -330,7 +301,7 @@ - + 640 @@ -600,73 +571,6 @@ 1 - - - Invisible - - SelectSlideArrowLeft - - SelectSlideArrowRight - - SelectSlide - - SelectSlideArrowLeft - - SelectSlideArrowRight - - SelectSlide - - 500 - 160 - 0,00 - 700 - 50 - - 505 - 165 - 0,00 - 40 - 40 - - 1170 - 165 - 0,00 - 40 - 40 - - - SelectSlideColor - - - SelectSlideSColor - - - SelectSlideHColor - - - ArrowColor - - - ArrowSColor - - - TextColor - - - TextSColor - - 32,00 - - - - 616,00 - - Outline - - Bold - - 1 - Invisible diff --git a/Vocaluxe/Screens/CScreenOptionsRecord.cs b/Vocaluxe/Screens/CScreenOptionsRecord.cs index ae4d785c..36e0c51e 100644 --- a/Vocaluxe/Screens/CScreenOptionsRecord.cs +++ b/Vocaluxe/Screens/CScreenOptionsRecord.cs @@ -38,7 +38,7 @@ namespace Vocaluxe.Screens // Version number for theme files. Increment it, if you've changed something on the theme files! protected override int _ScreenVersion { - get { return 2; } + get { return 3; } } private const float _MaxDelayTime = 1f; From 331fbb152642a41be536d54f0390cca3893de51e Mon Sep 17 00:00:00 2001 From: Flamefire Date: Tue, 30 Apr 2013 19:42:37 +0200 Subject: [PATCH 31/33] Revert "Added message for no-mics-error on party-screen." This reverts commit 3884632772aaa390859814c46669b88ecb640053. --- Output/Themes/Ambient/Screens/ScreenParty.xml | 32 +------------------ Vocaluxe/Screens/CScreenParty.cs | 19 +++++++---- 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/Output/Themes/Ambient/Screens/ScreenParty.xml b/Output/Themes/Ambient/Screens/ScreenParty.xml index c6779b60..86df74ac 100644 --- a/Output/Themes/Ambient/Screens/ScreenParty.xml +++ b/Output/Themes/Ambient/Screens/ScreenParty.xml @@ -471,36 +471,6 @@ - - - 850 - 560 - - 0,00 - - 32 - - 600 - - - TextWarningColor - - - TextSColor - - Center - - Center - - - - Outline - - TR_SCREENPARTY_ERROR_MICS - - - - Button @@ -683,4 +653,4 @@ 1 - + \ No newline at end of file diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs index d81e0fec..f6e37116 100644 --- a/Vocaluxe/Screens/CScreenParty.cs +++ b/Vocaluxe/Screens/CScreenParty.cs @@ -39,7 +39,6 @@ namespace Vocaluxe.Screens private const string _TextAuthor = "TextAuthor"; private const string _TextVersion = "TextVersion"; private const string _TextError = "TextError"; - private const string _TextErrorMics = "TextErrorMics"; private const string _ButtonStart = "ButtonStart"; private const string _ButtonExit = "ButtonExit"; private const string _SelectSlideModes = "SelectSlideModes"; @@ -50,7 +49,7 @@ namespace Vocaluxe.Screens { base.Init(); - _ThemeTexts = new string[] {_TextDescription, _TextTargetAudience, _TextNumTeams, _TextNumPlayers, _TextAuthor, _TextVersion, _TextError, _TextErrorMics}; + _ThemeTexts = new string[] {_TextDescription, _TextTargetAudience, _TextNumTeams, _TextNumPlayers, _TextAuthor, _TextVersion, _TextError}; _ThemeButtons = new string[] {_ButtonStart, _ButtonExit}; _ThemeSelectSlides = new string[] {_SelectSlideModes}; } @@ -121,8 +120,6 @@ namespace Vocaluxe.Screens _SelectSlides[_SelectSlideModes].Selection = 0; _UpdateSelection(); - _Texts[_TextErrorMics].Visible = CConfig.GetMaxNumMics() == 0; - _SetInteractionToSelectSlide(_SelectSlides[_SelectSlideModes]); } @@ -177,8 +174,16 @@ namespace Vocaluxe.Screens _Texts[_TextVersion].Text = _PartyModeInfos[index].VersionMajor + "." + _PartyModeInfos[index].VersionMinor; _Texts[_TextVersion].TranslationID = _PartyModeInfos[index].PartyModeID; - _Buttons[_ButtonStart].Visible = _PartyModeInfos[index].Playable && CConfig.GetMaxNumMics() > 0; - _Texts[_TextError].Visible = !_PartyModeInfos[index].Playable; + if (!_PartyModeInfos[index].Playable) + { + _Buttons[_ButtonStart].Visible = false; + _Texts[_TextError].Visible = true; + } + else + { + _Buttons[_ButtonStart].Visible = true; + _Texts[_TextError].Visible = false; + } } private void _StartPartyMode() @@ -191,7 +196,7 @@ namespace Vocaluxe.Screens return; if (CConfig.GetMaxNumMics() == 0) - return; + return; //TODO: Add message! CParty.SetPartyMode(_PartyModeInfos[index].PartyModeID); CGraphics.FadeTo(EScreens.ScreenPartyDummy); From 9a6f94a769ddb314a0a99923c8328a179c16889c Mon Sep 17 00:00:00 2001 From: Flamefire Date: Tue, 30 Apr 2013 19:46:57 +0200 Subject: [PATCH 32/33] Changed message for No mics in Party mode TRANSIFEX: add TR_SCREENPARTY_ERROR_MICS --- Vocaluxe/Screens/CScreenParty.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs index 79d12cad..6b31fab1 100644 --- a/Vocaluxe/Screens/CScreenParty.cs +++ b/Vocaluxe/Screens/CScreenParty.cs @@ -180,6 +180,12 @@ namespace Vocaluxe.Screens _Texts[_TextError].Text = "TR_SCREENPARTY_ERROR"; _Texts[_TextError].Visible = true; } + else if (CConfig.GetMaxNumMics() == 0) + { + _Buttons[_ButtonStart].Visible = false; + _Texts[_TextError].Text = "TR_SCREENPARTY_ERROR_MICS"; + _Texts[_TextError].Visible = true; + } else { _Buttons[_ButtonStart].Visible = true; @@ -198,13 +204,6 @@ namespace Vocaluxe.Screens _Buttons[_ButtonStart].Visible = false; _Texts[_TextError].Text = "TR_SCREENPARTY_ERROR"; _Texts[_TextError].Visible = true; - } - - if (CConfig.GetMaxNumMics() == 0) - { - _Buttons[_ButtonStart].Visible = false; - _Texts[_TextError].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_PL").Replace("%v", ""); - _Texts[_TextError].Visible = true; return; } From 1402d92c5b9cd5cc09f156974ba182087d0107ff Mon Sep 17 00:00:00 2001 From: Flamefire Date: Tue, 30 Apr 2013 19:53:44 +0200 Subject: [PATCH 33/33] Changed config for lyrics position --- Vocaluxe/Base/CConfig.cs | 6 +++--- VocaluxeLib/Menu/Enums.cs | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 7a939e8d..baf4b93c 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -222,7 +222,7 @@ namespace Vocaluxe.Base xmlReader.TryGetIntValue("//root/Game/NumPlayer", ref NumPlayer); xmlReader.TryGetEnumValue("//root/Game/Tabs", ref Tabs); xmlReader.GetValue("//root/Game/Language", out Language, Language); - xmlReader.TryGetEnumValue("//root/Game/LyricsOnTop", ref LyricsPosition); + xmlReader.TryGetEnumValue("//root/Game/LyricsPosition", ref LyricsPosition); xmlReader.TryGetFloatValue("//root/Game/MinLineBreakTime", ref MinLineBreakTime); if ((ScoreAnimationTime > 0 && ScoreAnimationTime < 1) || ScoreAnimationTime < 0) @@ -461,8 +461,8 @@ namespace Vocaluxe.Base writer.WriteComment("Order songs in tabs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("Tabs", Enum.GetName(typeof(EOffOn), Tabs)); - writer.WriteComment("Lyrics also on Top of screen: " + CHelper.ListStrings(Enum.GetNames(typeof(ELyricsPosition)))); - writer.WriteElementString("LyricsOnTop", Enum.GetName(typeof(ELyricsPosition), LyricsPosition)); + writer.WriteComment("Position if lyrics on screen: " + CHelper.ListStrings(Enum.GetNames(typeof(ELyricsPosition)))); + writer.WriteElementString("LyricsPosition", Enum.GetName(typeof(ELyricsPosition), LyricsPosition)); writer.WriteComment("MinLineBreakTime: Value >= 0 in s. Minimum time the text is shown before it is to be sung"); writer.WriteElementString("MinLineBreakTime", MinLineBreakTime.ToString()); diff --git a/VocaluxeLib/Menu/Enums.cs b/VocaluxeLib/Menu/Enums.cs index 126575ce..6f05dd61 100644 --- a/VocaluxeLib/Menu/Enums.cs +++ b/VocaluxeLib/Menu/Enums.cs @@ -274,10 +274,12 @@ namespace VocaluxeLib.Menu public enum ELyricsPosition { + // ReSharper disable InconsistentNaming TR_CONFIG_LYRICSPOSITION_BOTTOM, TR_CONFIG_LYRICSPOSITION_TOP, TR_CONFIG_LYRICSPOSITION_BOTH, TR_CONFIG_LYRICSPOSITION_DYNAMIC + // ReSharper restore InconsistentNaming } public enum ELyricStyle