More refactoring (mainly LINQ)

This commit is contained in:
Flamefire committed 2013-04-24 00:41:08 +02:00
1 parent 181490fa87
commit b1e28ae7bc
43 files changed
+263 -437

No files matched your search

@@ -452,7 +452,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public override void SongSelected(int songID) public override void SongSelected(int songID)
{ {
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; const EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
CBase.Game.Reset(); CBase.Game.Reset();
CBase.Game.ClearSongs(); CBase.Game.ClearSongs();
@@ -93,7 +93,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private SRectF _PlayerTableScrollArea; private SRectF _PlayerTableScrollArea;
private int _RoundsTableOffset; private int _RoundsTableOffset;
private int _PlayerTableOffset; private int _PlayerTableOffset;
private int _NumPlayerVisible = 10; private const int _NumPlayerVisible = 10;
private int _NumRoundsVisible = 3; private int _NumRoundsVisible = 3;
public CPartyScreenChallengeMain() public CPartyScreenChallengeMain()
@@ -19,6 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace VocaluxeLib.PartyModes.ChallengeMedley namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
@@ -27,7 +28,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private readonly Random _Rand; private readonly Random _Rand;
private readonly int _NumPlayer; private readonly int _NumPlayer;
public List<CCombination> Rounds; public readonly List<CCombination> Rounds;
public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce) public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce)
{ {
@@ -72,12 +73,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
numPlayed[playerIndex]++; numPlayed[playerIndex]++;
} }
int max = 0; int max = numPlayed.Max();
foreach (int p in numPlayed)
{
if (p > max)
max = p;
}
int num = Rounds[0].Player.Count; int num = Rounds[0].Player.Count;
List<int> result = new List<int>(); List<int> result = new List<int>();
@@ -162,28 +158,19 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
List<CCombination> combsFiltered = new List<CCombination>(); List<CCombination> combsFiltered = new List<CCombination>();
if (playerNrDemand != null) if (playerNrDemand != null)
{ {
for (int i = 0; i < _Combs.Count; i++) combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableAll(playerNrDemand)));
{
if (_Combs[i].IsAvailableAll(playerNrDemand))
combsFiltered.Add(_Combs[i]);
}
} }
//1st fallback //1st fallback
if (playerNrDemand != null && combsFiltered.Count == 0) if (playerNrDemand != null && combsFiltered.Count == 0)
{ {
for (int i = 0; i < _Combs.Count; i++) combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableSomeone(playerNrDemand)));
{
if (_Combs[i].IsAvailableSomeone(playerNrDemand))
combsFiltered.Add(_Combs[i]);
}
} }
//2nd fallback //2nd fallback
if (combsFiltered.Count == 0) if (combsFiltered.Count == 0)
{ {
for (int i = 0; i < _Combs.Count; i++) combsFiltered.AddRange(_Combs);
combsFiltered.Add(_Combs[i]);
} }
int num = combsFiltered.Count; int num = combsFiltered.Count;
@@ -220,7 +207,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public class CCombination public class CCombination
{ {
public List<int> Player; public readonly List<int> Player;
public CCombination() public CCombination()
{ {
@@ -229,28 +216,17 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public bool IsAvailable(int playerIndex) public bool IsAvailable(int playerIndex)
{ {
foreach (int p in Player) return Player.Any(p => p == playerIndex);
{
if (p == playerIndex)
return true;
}
return false;
} }
public bool IsAvailableAll(IEnumerable<int> playerIndices) public bool IsAvailableAll(IEnumerable<int> playerIndices)
{ {
bool result = true; return playerIndices.All(IsAvailable);
foreach (int p in playerIndices)
result &= IsAvailable(p);
return result;
} }
public bool IsAvailableSomeone(IEnumerable<int> playerIndices) public bool IsAvailableSomeone(IEnumerable<int> playerIndices)
{ {
bool result = false; return playerIndices.Any(IsAvailable);
foreach (int p in playerIndices)
result |= IsAvailable(p);
return result;
} }
} }
} }
@@ -59,7 +59,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public int Position; public int Position;
public int PlayerID; public int PlayerID;
public int NumPlayed; public int NumPlayed;
public int NumRounds;
public int NumWon; public int NumWon;
public int NumSingPoints; public int NumSingPoints;
public int NumGamePoints; public int NumGamePoints;
@@ -102,7 +101,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public struct SFromScreenNames public struct SFromScreenNames
{ {
public bool FadeToConfig; public bool FadeToConfig;
public bool FadeToMain;
public List<int> ProfileIDs; public List<int> ProfileIDs;
} }
@@ -518,8 +516,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
if (CBase.Songs.GetNumVisibleSongs() < _NumSongs) if (CBase.Songs.GetNumVisibleSongs() < _NumSongs)
CBase.Songs.ResetPartySongSung(); CBase.Songs.ResetPartySongSung();
EGameMode gm = EGameMode.TR_GAMEMODE_MEDLEY; const EGameMode gm = EGameMode.TR_GAMEMODE_MEDLEY;
List<int> iDs = new List<int>(); List<int> ids = new List<int>();
CSong[] visSongs = CBase.Songs.GetSongsNotSung(); CSong[] visSongs = CBase.Songs.GetSongsNotSung();
if (visSongs == null) if (visSongs == null)
@@ -534,11 +532,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
foreach (EGameMode mode in visSongs[i].AvailableGameModes) foreach (EGameMode mode in visSongs[i].AvailableGameModes)
{ {
if (mode == EGameMode.TR_GAMEMODE_MEDLEY) if (mode == EGameMode.TR_GAMEMODE_MEDLEY)
iDs.Add(visSongs[i].ID); ids.Add(visSongs[i].ID);
} }
} }
if (iDs.Count == 0) if (ids.Count == 0)
{ {
CBase.Log.LogError("CPartyChallengeMedleyMode Error: There are no medley songs!"); CBase.Log.LogError("CPartyChallengeMedleyMode Error: There are no medley songs!");
CBase.Graphics.FadeTo(EScreens.ScreenParty); CBase.Graphics.FadeTo(EScreens.ScreenParty);
@@ -546,12 +544,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
} }
int s = 0; int s = 0;
while (s < _NumSongs && iDs.Count > 0) while (s < _NumSongs && ids.Count > 0)
{ {
int songID = iDs[CBase.Game.GetRandom(iDs.Count)]; int songID = ids[CBase.Game.GetRandom(ids.Count)];
CBase.Game.AddSong(songID, gm); CBase.Game.AddSong(songID, gm);
CBase.Songs.AddPartySongSung(songID); CBase.Songs.AddPartySongSung(songID);
iDs.Remove(songID); ids.Remove(songID);
s++; s++;
} }
return true; return true;
@@ -630,7 +628,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
for (int i = 0; i < _GameData.NumPlayer; i++) for (int i = 0; i < _GameData.NumPlayer; i++)
{ {
CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumRounds = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0}; CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0};
_GameData.ResultTable.Add(row); _GameData.ResultTable.Add(row);
} }
@@ -690,7 +688,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
row.NumPlayed++; row.NumPlayed++;
row.NumWon += points[i].Won; row.NumWon += points[i].Won;
row.NumRounds += 1;
row.NumSingPoints += points[i].SingPoints; row.NumSingPoints += points[i].SingPoints;
row.NumGamePoints += points[i].GamePoints; row.NumGamePoints += points[i].GamePoints;
@@ -93,7 +93,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private SRectF _PlayerTableScrollArea; private SRectF _PlayerTableScrollArea;
private int _RoundsTableOffset; private int _RoundsTableOffset;
private int _PlayerTableOffset; private int _PlayerTableOffset;
private int _NumPlayerVisible = 10; private const int _NumPlayerVisible = 10;
private int _NumRoundsVisible = 3; private int _NumRoundsVisible = 3;
public CPartyScreenChallengeMedleyMain() public CPartyScreenChallengeMedleyMain()
@@ -598,7 +598,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + "."; row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + ".";
row.Name.Text = profiles[_GameState.ResultTable[i + _PlayerTableOffset].PlayerID].PlayerName; row.Name.Text = profiles[_GameState.ResultTable[i + _PlayerTableOffset].PlayerID].PlayerName;
row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumRounds.ToString(); row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString();
row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString(); row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString();
row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString(); row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString();
row.GamePoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumGamePoints.ToString(); row.GamePoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumGamePoints.ToString();
@@ -55,7 +55,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private const int _PlayerChooseButtonsFirstY = 105; private const int _PlayerChooseButtonsFirstY = 105;
private const int _PlayerChooseButtonsSpaceH = 15; private const int _PlayerChooseButtonsSpaceH = 15;
private const int _PlayerChooseButtonsSpaceW = 25; private const int _PlayerChooseButtonsSpaceW = 25;
private int _PlayerChooseButtonsOffset = 0; private const int _PlayerChooseButtonsOffset = 0;
private CStatic _ChooseAvatarStatic; private CStatic _ChooseAvatarStatic;
private bool _SelectingMouseActive; private bool _SelectingMouseActive;
@@ -88,7 +88,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, FadeToMain = false, ProfileIDs = new List<int>()}; SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, ProfileIDs = new List<int>()};
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
@@ -339,7 +339,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateButtonPlayerChoose(int offset) private void _UpdateButtonPlayerChoose(int offset)
{ {
int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH; const int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
if (offset < 0) if (offset < 0)
offset = 0; offset = 0;
@@ -501,14 +501,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _Back() private void _Back()
{ {
_Data.ScreenNames.FadeToConfig = true; _Data.ScreenNames.FadeToConfig = true;
_Data.ScreenNames.FadeToMain = false;
_PartyMode.DataFromScreen(ThemeName, _Data); _PartyMode.DataFromScreen(ThemeName, _Data);
} }
private void _Next() private void _Next()
{ {
_Data.ScreenNames.FadeToConfig = false; _Data.ScreenNames.FadeToConfig = false;
_Data.ScreenNames.FadeToMain = true;
_PartyMode.DataFromScreen(ThemeName, _Data); _PartyMode.DataFromScreen(ThemeName, _Data);
} }
} }
@@ -81,8 +81,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
public int CurrentRoundNr; public int CurrentRoundNr;
public int Team; public int Team;
public int NumPlayerTeam1;
public int NumPlayerTeam2;
public int NumFields; public int NumFields;
public List<CRound> Rounds; public List<CRound> Rounds;
public List<int> Songs; public List<int> Songs;
@@ -115,7 +113,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public struct SFromScreenNames public struct SFromScreenNames
{ {
public bool FadeToConfig; public bool FadeToConfig;
public bool FadeToMain;
public List<int> ProfileIDsTeam1; public List<int> ProfileIDsTeam1;
public List<int> ProfileIDsTeam2; public List<int> ProfileIDsTeam2;
} }
@@ -380,8 +377,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
CBase.Songs.ResetPartySongSung(); CBase.Songs.ResetPartySongSung();
_GameData.CurrentRoundNr = 1; _GameData.CurrentRoundNr = 1;
_ToScreenMain.CurrentRoundNr = 1; _ToScreenMain.CurrentRoundNr = 1;
_ToScreenMain.NumPlayerTeam1 = _GameData.NumPlayerTeam1;
_ToScreenMain.NumPlayerTeam2 = _GameData.NumPlayerTeam2;
_ToScreenMain.NumFields = _GameData.NumFields; _ToScreenMain.NumFields = _GameData.NumFields;
_ToScreenMain.ProfileIDsTeam1 = _GameData.ProfileIDsTeam1; _ToScreenMain.ProfileIDsTeam1 = _GameData.ProfileIDsTeam1;
_ToScreenMain.ProfileIDsTeam2 = _GameData.ProfileIDsTeam2; _ToScreenMain.ProfileIDsTeam2 = _GameData.ProfileIDsTeam2;
@@ -410,8 +405,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_UpdateSongList(); _UpdateSongList();
_UpdatePlayerList(); _UpdatePlayerList();
_ToScreenMain.CurrentRoundNr = _GameData.CurrentRoundNr; _ToScreenMain.CurrentRoundNr = _GameData.CurrentRoundNr;
_ToScreenMain.NumPlayerTeam1 = _GameData.NumPlayerTeam1;
_ToScreenMain.NumPlayerTeam2 = _GameData.NumPlayerTeam2;
_ToScreenMain.NumFields = _GameData.NumFields; _ToScreenMain.NumFields = _GameData.NumFields;
_ToScreenMain.ProfileIDsTeam1 = _GameData.ProfileIDsTeam1; _ToScreenMain.ProfileIDsTeam1 = _GameData.ProfileIDsTeam1;
_ToScreenMain.ProfileIDsTeam2 = _GameData.ProfileIDsTeam2; _ToScreenMain.ProfileIDsTeam2 = _GameData.ProfileIDsTeam2;
@@ -588,23 +581,23 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case 1: case 1:
{ {
//Prepare Player-IDs //Prepare Player-IDs
List<int> iDs = new List<int>(); List<int> ids = new List<int>();
//Add IDs to team-list //Add IDs to team-list
while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && iDs.Count == 0) while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && ids.Count == 0)
{ {
if (iDs.Count == 0) if (ids.Count == 0)
{ {
for (int i = 0; i < _GameData.NumPlayerTeam1; i++) for (int i = 0; i < _GameData.NumPlayerTeam1; i++)
iDs.Add(i); ids.Add(i);
} }
if (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0]) if (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0])
{ {
int random = CBase.Game.GetRandom((iDs.Count - 1) * 10); int random = CBase.Game.GetRandom((ids.Count - 1) * 10);
int num = (int)Math.Round((double)random / 10); int num = (int)Math.Round((double)random / 10);
if (num >= iDs.Count) if (num >= ids.Count)
num = iDs.Count - 1; num = ids.Count - 1;
_GameData.PlayerTeam1.Add(iDs[num]); _GameData.PlayerTeam1.Add(ids[num]);
iDs.RemoveAt(num); ids.RemoveAt(num);
} }
} }
} }
@@ -79,7 +79,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private List<CField> _Fields; private List<CField> _Fields;
private float _FieldFirstX = 25; private float _FieldFirstX = 25;
private float _FieldFirstY = 25; private float _FieldFirstY = 25;
private int _FieldSpace = 10; private const int _FieldSpace = 10;
private float _FieldSize = 100; private float _FieldSize = 100;
private int _PreviewStream = -1; private int _PreviewStream = -1;
@@ -93,7 +93,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose, _ButtonPlayerChooseScrollUp, _ButtonPlayerChooseScrollDown}; _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose, _ButtonPlayerChooseScrollUp, _ButtonPlayerChooseScrollDown};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, FadeToMain = false, ProfileIDsTeam1 = new List<int>(), ProfileIDsTeam2 = new List<int>()}; SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, ProfileIDsTeam1 = new List<int>(), ProfileIDsTeam2 = new List<int>()};
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
@@ -403,7 +403,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateButtonPlayerChoose(int offset) private void _UpdateButtonPlayerChoose(int offset)
{ {
int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH; const int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
if (offset < 0) if (offset < 0)
offset = 0; offset = 0;
@@ -446,27 +446,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
//Show profile only if active //Show profile only if active
if (CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON) if (CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON)
{ {
visible = true; visible = _Data.ScreenNames.ProfileIDsTeam1.All(t => t != i) && _Data.ScreenNames.ProfileIDsTeam2.All(t => t != i);
for (int p = 0; p < _Data.ScreenNames.ProfileIDsTeam1.Count; p++)
{
//Don't show profile if is selected
if (_Data.ScreenNames.ProfileIDsTeam1[p] == i)
{
visible = false;
break;
}
}
for (int p = 0; p < _Data.ScreenNames.ProfileIDsTeam2.Count; p++)
{
//Don't show profile if is selected
if (_Data.ScreenNames.ProfileIDsTeam2[p] == i)
{
visible = false;
break;
}
}
} }
if (visible) if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(i); _PlayerChooseButtonsVisibleProfiles.Add(i);
@@ -642,14 +622,12 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _Back() private void _Back()
{ {
_Data.ScreenNames.FadeToConfig = true; _Data.ScreenNames.FadeToConfig = true;
_Data.ScreenNames.FadeToMain = false;
_PartyMode.DataFromScreen(ThemeName, _Data); _PartyMode.DataFromScreen(ThemeName, _Data);
} }
private void _Next() private void _Next()
{ {
_Data.ScreenNames.FadeToConfig = false; _Data.ScreenNames.FadeToConfig = false;
_Data.ScreenNames.FadeToMain = true;
_PartyMode.DataFromScreen(ThemeName, _Data); _PartyMode.DataFromScreen(ThemeName, _Data);
} }
} }
+2 -6
View File
@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -477,12 +478,7 @@ namespace Vocaluxe.Base
private static bool _IsBackgroundFile(CPlaylistElement element) private static bool _IsBackgroundFile(CPlaylistElement element)
{ {
foreach (CPlaylistElement elements in _BGMusicFileNames) return _BGMusicFileNames.Any(elements => elements.MusicFilePath == element.MusicFilePath);
{
if (elements.MusicFilePath == element.MusicFilePath)
return true;
}
return false;
} }
private static void _LoadVideo() private static void _LoadVideo()
-20
View File
@@ -283,26 +283,6 @@ namespace Vocaluxe.Base
return _GetDataBaseSongID(song.Artist, song.Title, 0, command); return _GetDataBaseSongID(song.Artist, song.Title, 0, command);
} }
private static int _GetDataBaseSongID(string artist, string title, string filePath, int defNumPlayed)
{
using (SQLiteConnection connection = new SQLiteConnection())
{
connection.ConnectionString = "Data Source=" + filePath;
try
{
connection.Open();
}
catch (Exception)
{
return -1;
}
using (SQLiteCommand command = new SQLiteCommand(connection))
return _GetDataBaseSongID(artist, title, defNumPlayed, command);
}
}
private static int _GetDataBaseSongID(string artist, string title, int defNumPlayed, SQLiteCommand command) private static int _GetDataBaseSongID(string artist, string title, int defNumPlayed, SQLiteCommand command)
{ {
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist"; command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
+6 -17
View File
@@ -23,6 +23,7 @@ using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Text; using System.Drawing.Text;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
@@ -39,8 +40,7 @@ namespace Vocaluxe.Base
} }
public STexture Texture; public STexture Texture;
public char Chr; public readonly int Width;
public int Width;
public CGlyph(char chr, float maxHigh) public CGlyph(char chr, float maxHigh)
{ {
@@ -110,7 +110,6 @@ namespace Vocaluxe.Base
* */ * */
Texture = CDraw.AddTexture(bmp); Texture = CDraw.AddTexture(bmp);
//bmp.Save("test.png", ImageFormat.Png); //bmp.Save("test.png", ImageFormat.Png);
Chr = chr;
Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width); Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width);
g.Dispose(); g.Dispose();
} }
@@ -158,7 +157,7 @@ namespace Vocaluxe.Base
private FontFamily _Family; private FontFamily _Family;
private readonly float _Sizeh; private readonly float _Sizeh;
public string FilePath; public readonly string FilePath;
public CFont(string file) public CFont(string file)
{ {
@@ -550,25 +549,15 @@ namespace Vocaluxe.Base
public static float GetTextWidth(string text) public static float GetTextWidth(string text)
{ {
float dx = 0;
CFont font = _GetCurrentFont(); CFont font = _GetCurrentFont();
foreach (char chr in text) return text.Sum(chr => font.GetWidth(chr));
dx += font.GetWidth(chr);
return dx;
} }
public static float GetTextHeight(string text) public static float GetTextHeight(string text)
{ {
//return TextRenderer.MeasureText(text, GetFont()).Height; //return TextRenderer.MeasureText(text, GetFont()).Height;
float h = 0f;
CFont font = _GetCurrentFont(); CFont font = _GetCurrentFont();
foreach (char chr in text) return text==""?0:text.Select(font.GetHeight).Max();
{
float hh = font.GetHeight(chr);
if (hh > h)
h = hh;
}
return h;
} }
private static void _LoadFontFiles(CXMLReader xmlReader, string fontFolder, string themeName = "", int partyModeId = -1) private static void _LoadFontFiles(CXMLReader xmlReader, string fontFolder, string themeName = "", int partyModeId = -1)
@@ -769,7 +758,7 @@ namespace Vocaluxe.Base
private static void _BuildGlyphs() private static void _BuildGlyphs()
{ {
string text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890"; const string text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890";
for (int i = 0; i < _Fonts.Count; i++) for (int i = 0; i < _Fonts.Count; i++)
{ {
-8
View File
@@ -28,14 +28,6 @@ using VocaluxeLib.PartyModes;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
enum EPopupScreens
{
PopupPlayerControl = 0,
PopupVolumeControl = 1,
NoPopup = -1
}
class CCursor class CCursor
{ {
private readonly Stopwatch _CursorFadingTimer; private readonly Stopwatch _CursorFadingTimer;
+7 -20
View File
@@ -19,7 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Linq;
using System.Threading; using System.Threading;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -28,7 +28,7 @@ namespace Vocaluxe.Base
{ {
public struct SSongPointer public struct SSongPointer
{ {
public int SongID; public readonly int SongID;
public string SortString; public string SortString;
public int CatIndex; public int CatIndex;
@@ -56,11 +56,9 @@ namespace Vocaluxe.Base
private static int _CatIndex = -1; private static int _CatIndex = -1;
private static readonly List<CCategory> _CategoriesForRandom = new List<CCategory>(); private static readonly List<CCategory> _CategoriesForRandom = new List<CCategory>();
private static readonly Stopwatch _CoverLoadTimer = new Stopwatch(); public static readonly CSongFilter Filter = new CSongFilter();
public static readonly CSongSorter Sorter = new CSongSorter();
public static CSongFilter Filter = new CSongFilter(); public static readonly CSongCategorizer Categorizer = new CSongCategorizer();
public static CSongSorter Sorter = new CSongSorter();
public static CSongCategorizer Categorizer = new CSongCategorizer();
private static Thread _CoverLoaderThread; private static Thread _CoverLoaderThread;
@@ -93,13 +91,7 @@ namespace Vocaluxe.Base
{ {
get get
{ {
int result = 0; return Sorter.SortedSongs.Count(sp => sp.Visible);
foreach (SSongPointer sp in Sorter.SortedSongs)
{
if (sp.Visible)
result++;
}
return result;
} }
} }
@@ -210,12 +202,7 @@ namespace Vocaluxe.Base
public static CSong GetSong(int songID) public static CSong GetSong(int songID)
{ {
foreach (CSong song in _Songs) return _Songs.FirstOrDefault(song => song.ID == songID);
{
if (song.ID == songID)
return song;
}
return null;
} }
public static void AddPartySongSung(int songID) public static void AddPartySongSung(int songID)
+18 -21
View File
@@ -171,7 +171,9 @@ namespace Vocaluxe.Base
_KeyPressed = true; _KeyPressed = true;
} }
// ReSharper disable UnusedParameter.Global
public void KeyUp(KeyEventArgs e) public void KeyUp(KeyEventArgs e)
// ReSharper restore UnusedParameter.Global
{ {
_CheckModifiers(); _CheckModifiers();
_KeyPressed = false; _KeyPressed = false;
@@ -206,9 +208,7 @@ namespace Vocaluxe.Base
private readonly Object _CopyLock = new Object(); private readonly Object _CopyLock = new Object();
private bool _ModAlt; private EModifier _Mod;
private bool _ModCtrl;
private bool _ModShift;
private readonly Stopwatch _Timer; private readonly Stopwatch _Timer;
@@ -216,22 +216,19 @@ namespace Vocaluxe.Base
public CMouse() public CMouse()
{ {
_ModAlt = false;
_ModCtrl = false;
_ModShift = false;
_EventsPool = new List<SMouseEvent>(); _EventsPool = new List<SMouseEvent>();
_CurrentPool = new List<SMouseEvent>(); _CurrentPool = new List<SMouseEvent>();
_Timer = new Stopwatch(); _Timer = new Stopwatch();
} }
private void _Add(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh) private void _Add(int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
{ {
_CheckModifiers();
x = (int)(x * (float)CSettings.RenderW / CDraw.GetScreenWidth()); x = (int)(x * (float)CSettings.RenderW / CDraw.GetScreenWidth());
y = (int)(y * (float)CSettings.RenderH / CDraw.GetScreenHeight()); y = (int)(y * (float)CSettings.RenderH / CDraw.GetScreenHeight());
SMouseEvent pool = new SMouseEvent(ESender.Mouse, alt, shift, ctrl, x, y, lb, ld, rb, -wheel / 120, lbh, rbh, mb, mbh); SMouseEvent pool = new SMouseEvent(ESender.Mouse, _Mod, x, y, lb, ld, rb, -wheel / 120, lbh, rbh, mb, mbh);
lock (_CopyLock) lock (_CopyLock)
{ {
@@ -247,30 +244,28 @@ namespace Vocaluxe.Base
private void _CheckModifiers() private void _CheckModifiers()
{ {
Keys keys = Control.ModifierKeys; Keys keys = Control.ModifierKeys;
_Mod = EModifier.None;
_ModShift = (keys & Keys.Shift) == Keys.Shift; if ((keys & Keys.Shift) != 0)
_ModAlt = (keys & Keys.Alt) == Keys.Alt; _Mod |= EModifier.Shift;
_ModCtrl = (keys & Keys.Control) == Keys.Control; if ((keys & Keys.Alt) != 0)
_Mod |= EModifier.Alt;
if ((keys & Keys.Control) != 0)
_Mod |= EModifier.Ctrl;
} }
public void MouseMove(MouseEventArgs e) public void MouseMove(MouseEventArgs e)
{ {
_CheckModifiers(); _Add(e.X, e.Y, false, false, false, 0, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, false, e.Button == MouseButtons.Middle);
_Add(_ModAlt, _ModShift, _ModCtrl, e.X, e.Y, false, false, false, e.Delta, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right,
false, e.Button == MouseButtons.Middle);
} }
public void MouseWheel(MouseEventArgs e) public void MouseWheel(MouseEventArgs e)
{ {
_CheckModifiers(); _Add(e.X, e.Y, false, false, false, e.Delta, false, false, false, false);
_Add(_ModAlt, _ModShift, _ModCtrl, e.X, e.Y, false, false, false, e.Delta, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right,
false, e.Button == MouseButtons.Middle);
} }
public void MouseDown(MouseEventArgs e) public void MouseDown(MouseEventArgs e)
{ {
_CheckModifiers();
bool lb = e.Button == MouseButtons.Left; bool lb = e.Button == MouseButtons.Left;
bool ld = false; bool ld = false;
if (lb) if (lb)
@@ -289,11 +284,13 @@ namespace Vocaluxe.Base
else else
_Timer.Reset(); _Timer.Reset();
_Add(_ModAlt, _ModShift, _ModCtrl, e.X, e.Y, lb, ld, e.Button == MouseButtons.Right, e.Delta, false, false, _Add(e.X, e.Y, lb, ld, e.Button == MouseButtons.Right, e.Delta, false, false,
e.Button == MouseButtons.Middle, false); e.Button == MouseButtons.Middle, false);
} }
// ReSharper disable UnusedParameter.Global
public void MouseUp(MouseEventArgs e) public void MouseUp(MouseEventArgs e)
// ReSharper restore UnusedParameter.Global
{ {
//CheckModifiers(); //CheckModifiers();
//Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, e.Delta); //Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, e.Delta);
+1 -1
View File
@@ -330,7 +330,7 @@ namespace Vocaluxe.Lib.Draw
public void MakeScreenShot() public void MakeScreenShot()
{ {
string file = "Screenshot_"; const string file = "Screenshot_";
string path = Path.Combine(Environment.CurrentDirectory, CSettings.FolderScreenshots); string path = Path.Combine(Environment.CurrentDirectory, CSettings.FolderScreenshots);
int i = 0; int i = 0;
+12 -10
View File
@@ -26,17 +26,19 @@ namespace Vocaluxe.Lib.Input
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SHIDDeviceInfo public struct SHIDDeviceInfo
{ {
[MarshalAs(UnmanagedType.LPTStr)] public String Path; // ReSharper disable MemberCanBePrivate.Global
public ushort VendorString; [MarshalAs(UnmanagedType.LPTStr)] public readonly String Path;
public ushort ProductID; public readonly ushort VendorString;
public String SerialNumber; public readonly ushort ProductID;
public ushort ReleaseNumber; public readonly String SerialNumber;
public String ManufacturerString; public readonly ushort ReleaseNumber;
public String ProductString; public readonly String ManufacturerString;
public ushort UsagePage; public readonly String ProductString;
public ushort Usage; public readonly ushort UsagePage;
public int InterfaceNumber; public readonly ushort Usage;
public readonly int InterfaceNumber;
internal IntPtr Next; internal IntPtr Next;
// ReSharper restore MemberCanBePrivate.Global
} }
public static class CHIDApi public static class CHIDApi
+2 -2
View File
@@ -277,12 +277,12 @@ namespace Vocaluxe.Lib.Input.WiiMote
if (!lb && !rb && (p.X != _OldPosition.X || p.Y != _OldPosition.Y)) if (!lb && !rb && (p.X != _OldPosition.X || p.Y != _OldPosition.Y))
{ {
mpool = new SMouseEvent(ESender.WiiMote, false, false, false, x, y, false, false, false, wheel, lbh, false, false, false); mpool = new SMouseEvent(ESender.WiiMote, EModifier.None, x, y, false, false, false, wheel, lbh, false, false, false);
trigger = true; trigger = true;
} }
else if (lb || rb) else if (lb || rb)
{ {
mpool = new SMouseEvent(ESender.WiiMote, false, false, false, x, y, lb, false, rb, wheel, false, false, false, false); mpool = new SMouseEvent(ESender.WiiMote, EModifier.None, x, y, lb, false, rb, wheel, false, false, false, false);
trigger = true; trigger = true;
} }
+2 -6
View File
@@ -17,6 +17,7 @@
// */ // */
#endregion #endregion
using System.Linq;
using OpenTK.Audio; using OpenTK.Audio;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -312,12 +313,7 @@ namespace Vocaluxe.Lib.Sound
private bool _AlreadyAdded(int stream) private bool _AlreadyAdded(int stream)
{ {
foreach (SAudioStreams st in _Streams) return _Streams.Any(st => st.Handle == stream);
{
if (st.Handle == stream)
return true;
}
return false;
} }
private int _GetStreamIndex(int stream) private int _GetStreamIndex(int stream)
+2
View File
@@ -46,7 +46,9 @@ namespace Vocaluxe.Lib.Sound
public string InputName; public string InputName;
public int Channel; public int Channel;
// ReSharper disable UnusedParameter.Local
public SMicConfig(int dummy) public SMicConfig(int dummy)
// ReSharper restore UnusedParameter.Local
{ {
DeviceName = String.Empty; DeviceName = String.Empty;
DeviceDriver = String.Empty; DeviceDriver = String.Empty;
+6 -1
View File
@@ -28,6 +28,8 @@ namespace Vocaluxe.Lib.Sound.PortAudio
</summary> </summary>
*/ */
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable MemberCanBePrivate.Global
public static class CPortAudio public static class CPortAudio
{ {
@@ -50,7 +52,8 @@ namespace Vocaluxe.Lib.Sound.PortAudio
public struct SPaDeviceInfo public struct SPaDeviceInfo
{ {
public int StructVersion; public int StructVersion;
[MarshalAs(UnmanagedType.LPStr)] public string Name; [MarshalAs(UnmanagedType.LPStr)]
public string Name;
public int HostApi; public int HostApi;
public int MaxInputChannels; public int MaxInputChannels;
public int MaxOutputChannels; public int MaxOutputChannels;
@@ -552,5 +555,7 @@ namespace Vocaluxe.Lib.Sound.PortAudio
#endregion #endregion
} }
// ReSharper restore UnusedMember.Global // ReSharper restore UnusedMember.Global
// ReSharper restore FieldCanBeMadeReadOnly.Global
// ReSharper restore MemberCanBePrivate.Global
} }
+2 -6
View File
@@ -18,6 +18,7 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace Vocaluxe.Lib.Video namespace Vocaluxe.Lib.Video
@@ -79,12 +80,7 @@ namespace Vocaluxe.Lib.Video
protected bool _AlreadyAdded(int streamID) protected bool _AlreadyAdded(int streamID)
{ {
foreach (SVideoStreams st in _Streams) return _Streams.Any(st => st.Handle == streamID);
{
if (st.Handle == streamID)
return true;
}
return false;
} }
protected int _GetStreamIndex(int streamID) protected int _GetStreamIndex(int streamID)
@@ -36,7 +36,6 @@ namespace Vocaluxe.Lib.Video.Gstreamer
public struct SManagedFrame public struct SManagedFrame
{ {
public byte[] Buffer; public byte[] Buffer;
public int Size;
public int Width; public int Width;
public int Height; public int Height;
public float Videotime; public float Videotime;
@@ -102,7 +101,6 @@ namespace Vocaluxe.Lib.Video.Gstreamer
SManagedFrame m; SManagedFrame m;
m.Buffer = buffer; m.Buffer = buffer;
m.Height = f.Height; m.Height = f.Height;
m.Size = f.Size;
m.Videotime = f.Videotime; m.Videotime = f.Videotime;
m.Width = f.Width; m.Width = f.Width;
return m; return m;
-3
View File
@@ -87,17 +87,14 @@ namespace Vocaluxe.Lib.Webcam
public bool Init() public bool Init()
{ {
_WebcamDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); _WebcamDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
int num = 0;
foreach (FilterInfo info in _WebcamDevices) foreach (FilterInfo info in _WebcamDevices)
{ {
SWebcamDevice device = new SWebcamDevice SWebcamDevice device = new SWebcamDevice
{ {
ID = num,
Name = info.Name, Name = info.Name,
MonikerString = info.MonikerString, MonikerString = info.MonikerString,
Capabilities = new List<SCapabilities>() Capabilities = new List<SCapabilities>()
}; };
num++;
VideoCaptureDevice tmpdev = new VideoCaptureDevice(info.MonikerString); VideoCaptureDevice tmpdev = new VideoCaptureDevice(info.MonikerString);
foreach (VideoCapabilities capabilities in tmpdev.VideoCapabilities) foreach (VideoCapabilities capabilities in tmpdev.VideoCapabilities)
-1
View File
@@ -25,7 +25,6 @@ namespace Vocaluxe.Lib.Webcam
{ {
struct SWebcamDevice struct SWebcamDevice
{ {
public int ID;
public string Name; public string Name;
public string MonikerString; public string MonikerString;
public List<SCapabilities> Capabilities; public List<SCapabilities> Capabilities;
+2 -7
View File
@@ -19,6 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -207,13 +208,7 @@ namespace Vocaluxe.Screens
private bool _IsNewEntry(int id) private bool _IsNewEntry(int id)
{ {
for (int i = 0; i < _NewEntryIDs.Count; i++) return _NewEntryIDs.Any(t => t == id);
{
if (_NewEntryIDs[i] == id)
return true;
}
return false;
} }
private void _AddScoresToDB() private void _AddScoresToDB()
-2
View File
@@ -40,7 +40,6 @@ namespace Vocaluxe.Screens
private const string _ButtonExit = "ButtonExit"; private const string _ButtonExit = "ButtonExit";
private int _BackgroundMusicVolume; private int _BackgroundMusicVolume;
private EOffOn _BackgroundMusic;
public override void Init() public override void Init()
{ {
@@ -142,7 +141,6 @@ namespace Vocaluxe.Screens
public override void OnShow() public override void OnShow()
{ {
base.OnShow(); base.OnShow();
_BackgroundMusic = CConfig.BackgroundMusic;
_BackgroundMusicVolume = CConfig.BackgroundMusicVolume; _BackgroundMusicVolume = CConfig.BackgroundMusicVolume;
_SelectSlides[_SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5; _SelectSlides[_SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5;
-5
View File
@@ -242,10 +242,5 @@ namespace Vocaluxe.Screens
_ResumeBG(); _ResumeBG();
} }
} }
private void _AfterSkinReload()
{
_Active = true;
}
} }
} }
+1 -1
View File
@@ -259,7 +259,7 @@ namespace Vocaluxe.Screens
private void _OnSaveSnapshot() private void _OnSaveSnapshot()
{ {
string filename = "snapshot"; const string filename = "snapshot";
int i = 0; int i = 0;
while (File.Exists(Path.Combine(CSettings.FolderProfiles, filename + i + ".png"))) while (File.Exists(Path.Combine(CSettings.FolderProfiles, filename + i + ".png")))
i++; i++;
+2 -2
View File
@@ -90,7 +90,7 @@ namespace Vocaluxe.Screens
private int _CurrentBeat; private int _CurrentBeat;
private int _CurrentStream = -1; private int _CurrentStream = -1;
//private int _NextStream = -1; //private int _NextStream = -1;
private float _Volume = 100f; private const float _Volume = 100f;
private int _CurrentVideo = -1; private int _CurrentVideo = -1;
private EAspect _VideoAspect = EAspect.Crop; private EAspect _VideoAspect = EAspect.Crop;
private STexture _CurrentVideoTexture = new STexture(-1); private STexture _CurrentVideoTexture = new STexture(-1);
@@ -769,7 +769,7 @@ namespace Vocaluxe.Screens
for (int j = 0; j < CGame.NumPlayer; j++) for (int j = 0; j < CGame.NumPlayer; j++)
{ {
if (CGame.Player[j].LineNr == i) if (CGame.Player[j].LineNr == i)
_SingNotes[_SingBars].AddLine(_NoteLines[j], line, nr, j); _SingNotes[_SingBars].AddLine(_NoteLines[j], line, nr);
} }
if (i == 0 && !song.IsDuet || i == 1 && song.IsDuet) if (i == 0 && !song.IsDuet || i == 1 && song.IsDuet)
+16 -16
View File
@@ -853,13 +853,13 @@ namespace Vocaluxe.Screens
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
List<int> iDs = new List<int>(); List<int> ids = new List<int>();
for (int i = 0; i < CSongs.AllSongs.Length; i++) for (int i = 0; i < CSongs.AllSongs.Length; i++)
iDs.Add(i); ids.Add(i);
while (iDs.Count > 0) while (ids.Count > 0)
{ {
int songNr = iDs[CGame.Rand.Next(iDs.Count)]; int songNr = ids[CGame.Rand.Next(ids.Count)];
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
if (CSongs.AllSongs[songNr].IsDuet) if (CSongs.AllSongs[songNr].IsDuet)
@@ -867,7 +867,7 @@ namespace Vocaluxe.Screens
CGame.AddSong(songNr, gm); CGame.AddSong(songNr, gm);
iDs.Remove(songNr); ids.Remove(songNr);
} }
if (CGame.GetNumSongs() > 0) if (CGame.GetNumSongs() > 0)
@@ -879,13 +879,13 @@ namespace Vocaluxe.Screens
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
List<int> iDs = new List<int>(); List<int> ids = new List<int>();
for (int i = 0; i < CSongs.VisibleSongs.Length; i++) for (int i = 0; i < CSongs.VisibleSongs.Length; i++)
iDs.Add(CSongs.VisibleSongs[i].ID); ids.Add(CSongs.VisibleSongs[i].ID);
while (iDs.Count > 0) while (ids.Count > 0)
{ {
int songNr = iDs[CGame.Rand.Next(iDs.Count)]; int songNr = ids[CGame.Rand.Next(ids.Count)];
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
if (CSongs.AllSongs[songNr].IsDuet) if (CSongs.AllSongs[songNr].IsDuet)
@@ -893,7 +893,7 @@ namespace Vocaluxe.Screens
CGame.AddSong(songNr, gm); CGame.AddSong(songNr, gm);
iDs.Remove(songNr); ids.Remove(songNr);
} }
if (CGame.GetNumSongs() > 0) if (CGame.GetNumSongs() > 0)
@@ -905,21 +905,21 @@ namespace Vocaluxe.Screens
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
List<int> iDs = new List<int>(); List<int> ids = new List<int>();
if (allSongs) if (allSongs)
{ {
for (int i = 0; i < CSongs.AllSongs.Length; i++) for (int i = 0; i < CSongs.AllSongs.Length; i++)
iDs.Add(i); ids.Add(i);
} }
else else
{ {
for (int i = 0; i < CSongs.VisibleSongs.Length; i++) for (int i = 0; i < CSongs.VisibleSongs.Length; i++)
iDs.Add(CSongs.VisibleSongs[i].ID); ids.Add(CSongs.VisibleSongs[i].ID);
} }
int s = 0; int s = 0;
while (s < numSongs && iDs.Count > 0) while (s < numSongs && ids.Count > 0)
{ {
int songNr = iDs[CGame.Rand.Next(iDs.Count)]; int songNr = ids[CGame.Rand.Next(ids.Count)];
foreach (EGameMode gm in CSongs.AllSongs[songNr].AvailableGameModes) foreach (EGameMode gm in CSongs.AllSongs[songNr].AvailableGameModes)
{ {
@@ -931,7 +931,7 @@ namespace Vocaluxe.Screens
} }
} }
iDs.Remove(songNr); ids.Remove(songNr);
} }
if (CGame.GetNumSongs() > 0) if (CGame.GetNumSongs() > 0)
+5 -2
View File
@@ -18,7 +18,6 @@
#endregion #endregion
using System; using System;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -33,7 +32,9 @@ namespace Vocaluxe.Screens
get { return 1; } get { return 1; }
} }
/*
private int _TestMusic = -1; private int _TestMusic = -1;
*/
public override bool HandleInput(SKeyEvent keyEvent) public override bool HandleInput(SKeyEvent keyEvent)
{ {
@@ -85,6 +86,7 @@ namespace Vocaluxe.Screens
return true; return true;
} }
/*
private void _PlayFile() private void _PlayFile()
{ {
if (_TestMusic == -1) if (_TestMusic == -1)
@@ -94,6 +96,7 @@ namespace Vocaluxe.Screens
CSound.Fade(_TestMusic, 100f, 2f); CSound.Fade(_TestMusic, 100f, 2f);
} }
private void _PauseFile() private void _PauseFile()
{ {
CSound.Pause(_TestMusic); CSound.Pause(_TestMusic);
@@ -102,6 +105,6 @@ namespace Vocaluxe.Screens
private void _FadeAndPause() private void _FadeAndPause()
{ {
CSound.FadeAndPause(_TestMusic, 0f, 2f); CSound.FadeAndPause(_TestMusic, 0f, 2f);
} }*/
} }
} }
+57 -57
View File
@@ -45,17 +45,17 @@ namespace VocaluxeLib.Menu
public SColorF Color; public SColorF Color;
public SColorF SelColor; public SColorF SelColor;
public bool IsSelText; private bool _IsSelText;
public CText Text; public readonly CText Text;
public CText SelText; private readonly CText _SelText;
public bool Reflection; private bool _Reflection;
public float ReflectionSpace; private float _ReflectionSpace;
public float ReflectionHeight; private float _ReflectionHeight;
public bool SelReflection; private bool _SelReflection;
public float SelReflectionSpace; private float _SelReflectionSpace;
public float SelReflectionHeight; private float _SelReflectionHeight;
public bool Pressed; public bool Pressed;
@@ -65,7 +65,7 @@ namespace VocaluxeLib.Menu
set set
{ {
Text.EditMode = value; Text.EditMode = value;
SelText.EditMode = value; _SelText.EditMode = value;
} }
} }
@@ -97,21 +97,21 @@ namespace VocaluxeLib.Menu
Texture = new STexture(-1); Texture = new STexture(-1);
SelTexture = new STexture(-1); SelTexture = new STexture(-1);
IsSelText = false; _IsSelText = false;
Text = new CText(_PartyModeID); Text = new CText(_PartyModeID);
SelText = new CText(_PartyModeID); _SelText = new CText(_PartyModeID);
Selected = false; Selected = false;
Visible = true; Visible = true;
EditMode = false; EditMode = false;
Enabled = true; Enabled = true;
Reflection = false; _Reflection = false;
ReflectionSpace = 0f; _ReflectionSpace = 0f;
ReflectionHeight = 0f; _ReflectionHeight = 0f;
SelReflection = false; _SelReflection = false;
SelReflectionSpace = 0f; _SelReflectionSpace = 0f;
SelReflectionHeight = 0f; _SelReflectionHeight = 0f;
} }
public CButton(CButton button) public CButton(CButton button)
@@ -131,22 +131,22 @@ namespace VocaluxeLib.Menu
Texture = button.Texture; Texture = button.Texture;
SelTexture = button.SelTexture; SelTexture = button.SelTexture;
IsSelText = false; _IsSelText = false;
Text = new CText(button.Text); Text = new CText(button.Text);
SelText = new CText(button.SelText); _SelText = new CText(button._SelText);
Selected = false; Selected = false;
Visible = true; Visible = true;
EditMode = false; EditMode = false;
_ThemeLoaded = false; _ThemeLoaded = false;
Enabled = button.Enabled; Enabled = button.Enabled;
Reflection = button.Reflection; _Reflection = button._Reflection;
ReflectionHeight = button.ReflectionHeight; _ReflectionHeight = button._ReflectionHeight;
ReflectionSpace = button.ReflectionSpace; _ReflectionSpace = button._ReflectionSpace;
SelReflection = button.SelReflection; _SelReflection = button._SelReflection;
SelReflectionHeight = button.SelReflectionHeight; _SelReflectionHeight = button._SelReflectionHeight;
SelReflectionSpace = button.SelReflectionSpace; _SelReflectionSpace = button._SelReflectionSpace;
} }
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex) public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
@@ -187,30 +187,30 @@ namespace VocaluxeLib.Menu
Text.Z = Rect.Z; Text.Z = Rect.Z;
if (xmlReader.ItemExists(item + "/SText")) if (xmlReader.ItemExists(item + "/SText"))
{ {
IsSelText = true; _IsSelText = true;
_ThemeLoaded &= SelText.LoadTheme(item, "SText", xmlReader, skinIndex, true); _ThemeLoaded &= _SelText.LoadTheme(item, "SText", xmlReader, skinIndex, true);
SelText.Z = Rect.Z; _SelText.Z = Rect.Z;
} }
//Reflections //Reflections
if (xmlReader.ItemExists(item + "/Reflection")) if (xmlReader.ItemExists(item + "/Reflection"))
{ {
Reflection = true; _Reflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref ReflectionSpace); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref _ReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref ReflectionHeight); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref _ReflectionHeight);
} }
else else
Reflection = false; _Reflection = false;
if (xmlReader.ItemExists(item + "/SReflection")) if (xmlReader.ItemExists(item + "/SReflection"))
{ {
SelReflection = true; _SelReflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Space", ref SelReflectionSpace); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Space", ref _SelReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Height", ref SelReflectionHeight); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Height", ref _SelReflectionHeight);
} }
else else
SelReflection = false; _SelReflection = false;
if (_ThemeLoaded) if (_ThemeLoaded)
{ {
@@ -264,28 +264,28 @@ namespace VocaluxeLib.Menu
} }
Text.SaveTheme(writer); Text.SaveTheme(writer);
if (IsSelText) if (_IsSelText)
SelText.SaveTheme(writer); _SelText.SaveTheme(writer);
writer.WriteComment("<Reflection> If exists:"); writer.WriteComment("<Reflection> If exists:");
writer.WriteComment(" <Space>: Reflection Space"); writer.WriteComment(" <Space>: Reflection Space");
writer.WriteComment(" <Height>: Reflection Height"); writer.WriteComment(" <Height>: Reflection Height");
if (Reflection) if (_Reflection)
{ {
writer.WriteStartElement("Reflection"); writer.WriteStartElement("Reflection");
writer.WriteElementString("Space", ReflectionSpace.ToString("#0")); writer.WriteElementString("Space", _ReflectionSpace.ToString("#0"));
writer.WriteElementString("Height", ReflectionHeight.ToString("#0")); writer.WriteElementString("Height", _ReflectionHeight.ToString("#0"));
writer.WriteEndElement(); writer.WriteEndElement();
} }
writer.WriteComment("<SReflection> If exists:"); writer.WriteComment("<SReflection> If exists:");
writer.WriteComment(" <Space>: Reflection Space of selected button"); writer.WriteComment(" <Space>: Reflection Space of selected button");
writer.WriteComment(" <Height>: Reflection Height of selected button"); writer.WriteComment(" <Height>: Reflection Height of selected button");
if (SelReflection) if (_SelReflection)
{ {
writer.WriteStartElement("SReflection"); writer.WriteStartElement("SReflection");
writer.WriteElementString("Space", ReflectionSpace.ToString("#0")); writer.WriteElementString("Space", _ReflectionSpace.ToString("#0"));
writer.WriteElementString("Height", ReflectionHeight.ToString("#0")); writer.WriteElementString("Height", _ReflectionHeight.ToString("#0"));
writer.WriteEndElement(); writer.WriteEndElement();
} }
@@ -309,41 +309,41 @@ namespace VocaluxeLib.Menu
CBase.Drawing.DrawTexture(texture, Rect, Color); CBase.Drawing.DrawTexture(texture, Rect, Color);
if (Reflection) if (_Reflection)
{ {
CBase.Drawing.DrawTextureReflection(texture, Rect, Color, Rect, ReflectionSpace, ReflectionHeight); CBase.Drawing.DrawTextureReflection(texture, Rect, Color, Rect, _ReflectionSpace, _ReflectionHeight);
Text.DrawRelative(Rect.X, Rect.Y, ReflectionSpace, ReflectionHeight, Rect.H); Text.DrawRelative(Rect.X, Rect.Y, _ReflectionSpace, _ReflectionHeight, Rect.H);
} }
else else
Text.DrawRelative(Rect.X, Rect.Y); Text.DrawRelative(Rect.X, Rect.Y);
} }
else if (!IsSelText) else if (!_IsSelText)
{ {
texture = Texture.Index != -1 ? Texture : CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID); texture = Texture.Index != -1 ? Texture : CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID);
CBase.Drawing.DrawTexture(texture, Rect, SelColor); CBase.Drawing.DrawTexture(texture, Rect, SelColor);
if (Reflection) if (_Reflection)
{ {
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, ReflectionSpace, ReflectionHeight); CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight);
Text.DrawRelative(Rect.X, Rect.Y, ReflectionSpace, ReflectionHeight, Rect.H); Text.DrawRelative(Rect.X, Rect.Y, _ReflectionSpace, _ReflectionHeight, Rect.H);
} }
else else
Text.DrawRelative(Rect.X, Rect.Y); Text.DrawRelative(Rect.X, Rect.Y);
} }
else if (IsSelText) else if (_IsSelText)
{ {
texture = SelTexture.Index != -1 ? SelTexture : CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID); texture = SelTexture.Index != -1 ? SelTexture : CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID);
CBase.Drawing.DrawTexture(texture, Rect, SelColor); CBase.Drawing.DrawTexture(texture, Rect, SelColor);
if (Reflection) if (_Reflection)
{ {
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, ReflectionSpace, ReflectionHeight); CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight);
SelText.DrawRelative(Rect.X, Rect.Y, ReflectionSpace, ReflectionHeight, Rect.H); _SelText.DrawRelative(Rect.X, Rect.Y, _ReflectionSpace, _ReflectionHeight, Rect.H);
} }
else else
SelText.DrawRelative(Rect.X, Rect.Y); _SelText.DrawRelative(Rect.X, Rect.Y);
} }
} }
+15 -10
View File
@@ -500,27 +500,27 @@ namespace VocaluxeLib.Menu
{ {
if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode)) if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode))
_Theme.ButtonPlaylistName.Text.Text = _Theme.ButtonPlaylistName.Text.Text + keyEvent.Unicode; _Theme.ButtonPlaylistName.Text.Text = _Theme.ButtonPlaylistName.Text.Text + keyEvent.Unicode;
else if (keyEvent.Key == Keys.Enter) else switch (keyEvent.Key)
{ {
case Keys.Enter:
CBase.Playlist.SetPlaylistName(ActivePlaylistID, _Theme.ButtonPlaylistName.Text.Text); CBase.Playlist.SetPlaylistName(ActivePlaylistID, _Theme.ButtonPlaylistName.Text.Text);
CBase.Playlist.SavePlaylist(ActivePlaylistID); CBase.Playlist.SavePlaylist(ActivePlaylistID);
EditMode = EEditMode.None; EditMode = EEditMode.None;
_Theme.ButtonPlaylistName.EditMode = false; _Theme.ButtonPlaylistName.EditMode = false;
} break;
else if (keyEvent.Key == Keys.Escape) case Keys.Escape:
{
_Theme.ButtonPlaylistName.Text.Text = CBase.Playlist.GetPlaylistName(ActivePlaylistID); _Theme.ButtonPlaylistName.Text.Text = CBase.Playlist.GetPlaylistName(ActivePlaylistID);
EditMode = EEditMode.None; EditMode = EEditMode.None;
_Theme.ButtonPlaylistName.EditMode = false; _Theme.ButtonPlaylistName.EditMode = false;
} break;
else if (keyEvent.Key == Keys.Back || keyEvent.Key == Keys.Delete) case Keys.Delete:
{ case Keys.Back:
if (_Theme.ButtonPlaylistName.Text.Text != "") if (_Theme.ButtonPlaylistName.Text.Text != "")
_Theme.ButtonPlaylistName.Text.Text = _Theme.ButtonPlaylistName.Text.Text.Remove(_Theme.ButtonPlaylistName.Text.Text.Length - 1); _Theme.ButtonPlaylistName.Text.Text = _Theme.ButtonPlaylistName.Text.Text.Remove(_Theme.ButtonPlaylistName.Text.Text.Length - 1);
break;
} }
return true;
} }
else
{
if (CurrentPlaylistElement == -1 || _PlaylistElementContents.Count == 0) if (CurrentPlaylistElement == -1 || _PlaylistElementContents.Count == 0)
{ {
//no song is selected //no song is selected
@@ -783,7 +783,12 @@ namespace VocaluxeLib.Menu
} }
} }
break; break;
} case Keys.PageDown:
_SetSelectionToLastEntry();
break;
case Keys.PageUp:
_SetSelectionToFirstEntry();
break;
} }
} }
return true; return true;
+1 -1
View File
@@ -115,7 +115,7 @@ namespace VocaluxeLib.Menu
private readonly List<SRectF> _ValueBounds = new List<SRectF>(); private readonly List<SRectF> _ValueBounds = new List<SRectF>();
public bool WithTextures; public readonly bool WithTextures;
private int _Selection = -1; private int _Selection = -1;
public int Selection public int Selection
+6 -6
View File
@@ -40,13 +40,13 @@ namespace VocaluxeLib.Menu
public float Width; public float Width;
public float Height; public float Height;
public STextPosition(int dummy) public STextPosition(float initVal)
{ {
X = 0f; X = initVal;
Y = 0f; Y = initVal;
TextHeight = 0f; TextHeight = initVal;
Width = 0f; Width = initVal;
Height = 0f; Height = initVal;
} }
} }
+10
View File
@@ -95,10 +95,12 @@ namespace VocaluxeLib.Menu
public enum EColorDepth public enum EColorDepth
{ {
// ReSharper disable UnusedMember.Global
Bit8 = 8, Bit8 = 8,
Bit16 = 16, Bit16 = 16,
Bit24 = 24, Bit24 = 24,
Bit32 = 32 Bit32 = 32
// ReSharper restore UnusedMember.Global
} }
public enum ETextureQuality public enum ETextureQuality
@@ -339,4 +341,12 @@ namespace VocaluxeLib.Menu
ScreenNull = -1 ScreenNull = -1
} }
public enum EPopupScreens
{
PopupPlayerControl = 0,
PopupVolumeControl = 1,
NoPopup = -1
}
} }
+4 -20
View File
@@ -19,6 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace VocaluxeLib.Menu.SingNotes namespace VocaluxeLib.Menu.SingNotes
{ {
@@ -572,19 +573,8 @@ namespace VocaluxeLib.Menu.SingNotes
if (_Lines.Count == 0) if (_Lines.Count == 0)
return 0; return 0;
int startbeat = int.MaxValue; int startbeat = _Lines.Max(line => line.FirstNoteBeat);
for (int i = 0; i < _Lines.Count; i++) int endbeat = _Lines.Min(line => line.LastNoteBeat);
{
if (_Lines[i].FirstNoteBeat < startbeat)
startbeat = _Lines[i].FirstNoteBeat;
}
int endbeat = int.MinValue;
for (int i = 0; i < _Lines.Count; i++)
{
if (_Lines[i].LastNoteBeat < endbeat)
endbeat = _Lines[i].LastNoteBeat;
}
int result = endbeat - startbeat; int result = endbeat - startbeat;
if (result > 0) if (result > 0)
@@ -609,13 +599,7 @@ namespace VocaluxeLib.Menu.SingNotes
{ {
get get
{ {
int num = 0; return _Lines.Count(line => line.Points > 0f);
foreach (CLine line in _Lines)
{
if (line.Points > 0f)
num++;
}
return num;
} }
} }
+9 -18
View File
@@ -195,13 +195,13 @@ namespace VocaluxeLib.Menu.SingNotes
return false; return false;
} }
public virtual void Reset() public void Reset()
{ {
_PlayerNotes.Clear(); _PlayerNotes.Clear();
_ActID = 0; _ActID = 0;
} }
public virtual int AddPlayer(SRectF rect, SColorF color, int playerNr) public int AddPlayer(SRectF rect, SColorF color, int playerNr)
{ {
SPlayerNotes notes = new SPlayerNotes SPlayerNotes notes = new SPlayerNotes
{ {
@@ -224,9 +224,7 @@ namespace VocaluxeLib.Menu.SingNotes
return notes.ID; return notes.ID;
} }
public virtual void RemovePlayer(int id) {} public void AddLine(int id, CLine[] line, int lineNr)
public virtual void AddLine(int id, CLine[] line, int lineNr, int player)
{ {
if (line == null) if (line == null)
return; return;
@@ -238,11 +236,11 @@ namespace VocaluxeLib.Menu.SingNotes
if (lineNr == _PlayerNotes[n].LineNr) if (lineNr == _PlayerNotes[n].LineNr)
return; return;
SPlayerNotes notes = _PlayerNotes[n];
if (line.Length <= lineNr) if (line.Length <= lineNr)
return; return;
SPlayerNotes notes = _PlayerNotes[n];
notes.Lines = line; notes.Lines = line;
notes.LineNr = lineNr; notes.LineNr = lineNr;
notes.GoldenStars.Clear(); notes.GoldenStars.Clear();
@@ -253,11 +251,7 @@ namespace VocaluxeLib.Menu.SingNotes
_PlayerNotes.Add(notes); _PlayerNotes.Add(notes);
} }
public virtual void RemoveLine(int id) {} public void SetAlpha(int id, float alpha)
public virtual void AddNote(int id, CNote note) {}
public virtual void SetAlpha(int id, float alpha)
{ {
int n = _FindPlayerLine(id); int n = _FindPlayerLine(id);
if (n == -1) if (n == -1)
@@ -268,7 +262,7 @@ namespace VocaluxeLib.Menu.SingNotes
_PlayerNotes[n] = pn; _PlayerNotes[n] = pn;
} }
public virtual float GetAlpha(int id) public float GetAlpha(int id)
{ {
int n = _FindPlayerLine(id); int n = _FindPlayerLine(id);
if (n == -1) if (n == -1)
@@ -277,12 +271,12 @@ namespace VocaluxeLib.Menu.SingNotes
return _PlayerNotes[n].Alpha; return _PlayerNotes[n].Alpha;
} }
public virtual void Draw(int id, int player) public void Draw(int id, int player)
{ {
Draw(id, null, player); Draw(id, null, player);
} }
public virtual void Draw(int id, List<CLine> singLine, int player) public void Draw(int id, List<CLine> singLine, int player)
{ {
int n = _FindPlayerLine(id); int n = _FindPlayerLine(id);
if (n == -1) if (n == -1)
@@ -463,9 +457,6 @@ namespace VocaluxeLib.Menu.SingNotes
private int _FindPlayerLine(int id) private int _FindPlayerLine(int id)
{ {
if (id < 0 || id > _PlayerNotes.Count)
return -1;
for (int i = 0; i < _PlayerNotes.Count; i++) for (int i = 0; i < _PlayerNotes.Count; i++)
{ {
if (_PlayerNotes[i].ID == id) if (_PlayerNotes[i].ID == id)
+6 -4
View File
@@ -47,7 +47,7 @@ namespace VocaluxeLib.Menu.SongMenu
public class CCategory public class CCategory
{ {
public string Name = String.Empty; public readonly string Name;
private STexture _CoverTextureSmall = new STexture(-1); private STexture _CoverTextureSmall = new STexture(-1);
private STexture _CoverTextureBig = new STexture(-1); private STexture _CoverTextureBig = new STexture(-1);
private bool _CoverBigLoaded; private bool _CoverBigLoaded;
@@ -100,7 +100,9 @@ namespace VocaluxeLib.Menu.SongMenu
public float FadeInTime; public float FadeInTime;
public float FadeOutTime; public float FadeOutTime;
// ReSharper disable UnusedParameter.Local
public SMedley(int dummy) public SMedley(int dummy)
// ReSharper restore UnusedParameter.Local
{ {
Source = EMedleySource.None; Source = EMedleySource.None;
StartBeat = 0; StartBeat = 0;
@@ -210,11 +212,11 @@ namespace VocaluxeLib.Menu.SongMenu
get { return Notes.Lines.Length > 1; } get { return Notes.Lines.Length > 1; }
} }
public List<string> Edition = new List<string>(); public readonly List<string> Edition = new List<string>();
public List<string> Genre = new List<string>(); public readonly List<string> Genre = new List<string>();
public string Year = ""; public string Year = "";
public List<string> Language = new List<string>(); public readonly List<string> Language = new List<string>();
// Notes // Notes
public readonly CNotes Notes = new CNotes(); public readonly CNotes Notes = new CNotes();
@@ -95,7 +95,7 @@ namespace VocaluxeLib.Menu.SongMenu
abstract class CSongMenuFramework : ISongMenu abstract class CSongMenuFramework : ISongMenu
{ {
protected int _PartyModeID; protected readonly int _PartyModeID;
protected SThemeSongMenu _Theme; protected SThemeSongMenu _Theme;
private bool _ThemeLoaded; private bool _ThemeLoaded;
@@ -164,7 +164,7 @@ namespace VocaluxeLib.Menu.SongMenu
} }
} }
protected virtual void _SetSelectedNow() protected void _SetSelectedNow()
{ {
_Timer.Stop(); _Timer.Stop();
_Timer.Reset(); _Timer.Reset();
@@ -425,7 +425,7 @@ namespace VocaluxeLib.Menu.SongMenu
_Initialized = true; _Initialized = true;
} }
public virtual void UpdateRect(SRectF rect) public void UpdateRect(SRectF rect)
{ {
_Rect = rect; _Rect = rect;
Init(); Init();
@@ -20,6 +20,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.PartyModes; using VocaluxeLib.PartyModes;
@@ -180,15 +181,7 @@ namespace VocaluxeLib.Menu.SongMenu
keyEvent.Key == Keys.PageDown || keyEvent.Key == Keys.PageUp)) keyEvent.Key == Keys.PageDown || keyEvent.Key == Keys.PageUp))
return; return;
bool sel = false; bool sel = _Tiles.Any(tile => tile.Selected);
foreach (CStatic tile in _Tiles)
{
if (tile.Selected)
{
sel = true;
break;
}
}
if ((_Locked == -1 || !sel) && if ((_Locked == -1 || !sel) &&
(keyEvent.Key != Keys.Escape && keyEvent.Key != Keys.Back && keyEvent.Key != Keys.PageUp && keyEvent.Key != Keys.PageDown)) (keyEvent.Key != Keys.Escape && keyEvent.Key != Keys.Back && keyEvent.Key != Keys.PageUp && keyEvent.Key != Keys.PageDown))
@@ -500,15 +493,7 @@ namespace VocaluxeLib.Menu.SongMenu
protected void _SetSelectedTile(int itemNr) protected void _SetSelectedTile(int itemNr)
{ {
bool sel = false; bool sel = _Tiles.Any(tile => tile.Selected);
foreach (CStatic tile in _Tiles)
{
if (tile.Selected)
{
sel = true;
break;
}
}
if (_Locked == -1 || !sel) if (_Locked == -1 || !sel)
{ {
+25 -45
View File
@@ -137,15 +137,15 @@ namespace VocaluxeLib.Menu
#region Inputs #region Inputs
public struct SKeyEvent public struct SKeyEvent
{ {
public ESender Sender; public readonly ESender Sender;
public bool ModAlt; public readonly bool ModAlt;
public bool ModShift; public readonly bool ModShift;
public bool ModCtrl; public readonly bool ModCtrl;
public bool KeyPressed; public readonly bool KeyPressed;
public bool Handled; public bool Handled;
public Keys Key; public Keys Key;
public Char Unicode; public readonly Char Unicode;
public EModifier Mod; public readonly EModifier Mod;
public SKeyEvent(ESender sender, bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key) public SKeyEvent(ESender sender, bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key)
{ {
@@ -171,27 +171,25 @@ namespace VocaluxeLib.Menu
public struct SMouseEvent public struct SMouseEvent
{ {
public ESender Sender; public readonly ESender Sender;
public bool Handled; public bool Handled;
public int X; public readonly int X;
public int Y; public readonly int Y;
public bool LB; //left button click public readonly bool LB; //left button click
public bool LD; //left button double click public readonly bool LD; //left button double click
public bool RB; //right button click public readonly bool RB; //right button click
public bool MB; //middle button click public readonly bool MB; //middle button click
public bool LBH; //left button hold (when moving) public readonly bool LBH; //left button hold (when moving)
public bool RBH; //right button hold (when moving) // ReSharper disable MemberCanBePrivate.Global
public bool MBH; //middle button hold (when moving) public readonly bool RBH; //right button hold (when moving)
public readonly bool MBH; //middle button hold (when moving)
// ReSharper restore MemberCanBePrivate.Global
public bool ModAlt; public readonly EModifier Mod;
public bool ModShift; public readonly int Wheel;
public bool ModCtrl;
public EModifier Mod; public SMouseEvent(ESender sender, EModifier mod, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
public int Wheel;
public SMouseEvent(ESender sender, bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
{ {
Sender = sender; Sender = sender;
Handled = false; Handled = false;
@@ -206,27 +204,7 @@ namespace VocaluxeLib.Menu
RBH = rbh; RBH = rbh;
MBH = mbh; MBH = mbh;
ModAlt = alt; Mod = mod;
ModShift = shift;
ModCtrl = ctrl;
EModifier mAlt = EModifier.None;
EModifier mShift = EModifier.None;
EModifier mCtrl = EModifier.None;
if (alt)
mAlt = EModifier.Alt;
if (shift)
mShift = EModifier.Shift;
if (ctrl)
mCtrl = EModifier.Ctrl;
if (!alt && !shift && !ctrl)
Mod = EModifier.None;
else
Mod = mAlt | mShift | mCtrl;
Wheel = wheel; Wheel = wheel;
} }
@@ -250,7 +228,9 @@ namespace VocaluxeLib.Menu
public string FileName; public string FileName;
public STexture Texture; public STexture Texture;
// ReSharper disable UnusedParameter.Local
public SAvatar(int dummy) public SAvatar(int dummy)
// ReSharper restore UnusedParameter.Local
{ {
FileName = String.Empty; FileName = String.Empty;
Texture = new STexture(-1); Texture = new STexture(-1);