Merge branch 'flamedevelop' into develop

This commit is contained in:
Alexander Eckart committed 2013-04-26 18:23:10 +02:00
commit 242a177eb8
152 files changed
+6722 -5909

No files matched your search

Binary file not shown.
+1
View File
@@ -13,6 +13,7 @@
<string name="TR_DEBUG_MAX_VOLUME">Max Volume</string> <string name="TR_DEBUG_MAX_VOLUME">Max Volume</string>
<string name="TR_DEBUG_SONGS">Loaded songs</string> <string name="TR_DEBUG_SONGS">Loaded songs</string>
<string name="TR_DEBUG_MOUSE">Mouse</string> <string name="TR_DEBUG_MOUSE">Mouse</string>
<string name="TR_DEBUG_MEMORY">Memory usage</string>
<string name="TR_GAMEMODE_NORMAL">Normal</string> <string name="TR_GAMEMODE_NORMAL">Normal</string>
<string name="TR_GAMEMODE_DUET">Duet</string> <string name="TR_GAMEMODE_DUET">Duet</string>
<string name="TR_GAMEMODE_MEDLEY">Medley</string> <string name="TR_GAMEMODE_MEDLEY">Medley</string>
+1
View File
@@ -13,6 +13,7 @@
<string name="TR_DEBUG_MAX_VOLUME">Max. Volume</string> <string name="TR_DEBUG_MAX_VOLUME">Max. Volume</string>
<string name="TR_DEBUG_SONGS">Geladene Songs</string> <string name="TR_DEBUG_SONGS">Geladene Songs</string>
<string name="TR_DEBUG_MOUSE">Maus</string> <string name="TR_DEBUG_MOUSE">Maus</string>
<string name="TR_DEBUG_MEMORY">Speicherverbrauch</string>
<string name="TR_GAMEMODE_NORMAL">Normal</string> <string name="TR_GAMEMODE_NORMAL">Normal</string>
<string name="TR_GAMEMODE_DUET">Duett</string> <string name="TR_GAMEMODE_DUET">Duett</string>
<string name="TR_GAMEMODE_MEDLEY">Medley</string> <string name="TR_GAMEMODE_MEDLEY">Medley</string>
+31 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<ScreenSing> <ScreenSing>
<ScreenVersion>6</ScreenVersion> <ScreenVersion>7</ScreenVersion>
<Background1> <Background1>
<!--<Type>: Background type: None, Color, Texture, Video--> <!--<Type>: Background type: None, Color, Texture, Video-->
<Type>None</Type> <Type>None</Type>
@@ -988,6 +988,36 @@
<!-- <Space>: Reflection Space--> <!-- <Space>: Reflection Space-->
<!-- <Height>: Reflection Height--> <!-- <Height>: Reflection Height-->
</TextSongName> </TextSongName>
<TextMedleyCountdown>
<!--<X>, <Y>: Text position-->
<X>640</X>
<Y>18</Y>
<!--<Z>: Text position-->
<Z>-1,00</Z>
<!--<H>: Text height-->
<H>32</H>
<!--<MaxW>: Maximum text width (if exists)-->
<MaxW />
<!--<Color>: Text color from ColorScheme (high priority)-->
<!--or <R>, <G>, <B>, <A> (lower priority)-->
<Color>TextColor</Color>
<!--<SColor>: Selected Text color from ColorScheme (high priority)-->
<!--or <SR>, <SG>, <SB>, <SA> (lower priority)-->
<SColor>TextSColor</SColor>
<!--<Align>: Text align horizontal: Left, Center, Right-->
<Align>Left</Align>
<!--<HAlign>: Text align vertical (on downsizing): Top, Center, Bottom-->
<HAlign>Center</HAlign>
<!--<Style>: Text style: Normal, Italic, Bold, BoldItalic-->
<Style>Bold</Style>
<!--<Font>: Text font name-->
<Font>Outline</Font>
<!--<Text>: Nothing or translation tag-->
<Text />
<!--<Reflection> If exists:-->
<!-- <Space>: Reflection Space-->
<!-- <Height>: Reflection Height-->
</TextMedleyCountdown>
<TextTime> <TextTime>
<!--<X>, <Y>: Text position--> <!--<X>, <Y>: Text position-->
<X>1214</X> <X>1214</X>
+1 -1
View File
@@ -1844,7 +1844,7 @@
<!--<Font>: Text font name--> <!--<Font>: Text font name-->
<Font>Outline</Font> <Font>Outline</Font>
<!--<Text>: Nothing or translation tag--> <!--<Text>: Nothing or translation tag-->
<Text /> <Text>%a - %t</Text>
<!--<Reflection> If exists:--> <!--<Reflection> If exists:-->
<!-- <Space>: Reflection Space--> <!-- <Space>: Reflection Space-->
<!-- <Height>: Reflection Height--> <!-- <Height>: Reflection Height-->
@@ -1,5 +1,11 @@
ScreenSing ScreenSing
+++++++++
Version 7
Add:
<TextMedleyCountdown> !text-position and size will be overwritten by vocaluxe!
+++++++++ +++++++++
Version 6 Version 6
@@ -1,5 +1,25 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace VocaluxeLib.PartyModes.Challenge namespace VocaluxeLib.PartyModes.Challenge
{ {
@@ -8,7 +28,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private readonly Random _Rand; private readonly Random _Rand;
private readonly int _NumPlayer; private readonly int _NumPlayer;
public List<CCombination> Rounds; public readonly List<CCombination> Rounds;
public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce) public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce)
{ {
@@ -41,7 +61,7 @@ namespace VocaluxeLib.PartyModes.Challenge
Rounds.Add(combinations.GetNextCombination(_GetPlayerDemand(i))); Rounds.Add(combinations.GetNextCombination(_GetPlayerDemand(i)));
} }
private List<int> _GetPlayerDemand(int roundIndex) private IEnumerable<int> _GetPlayerDemand(int roundIndex)
{ {
List<int> numPlayed = new List<int>(_NumPlayer); List<int> numPlayed = new List<int>(_NumPlayer);
for (int i = 0; i < _NumPlayer; i++) for (int i = 0; i < _NumPlayer; i++)
@@ -53,12 +73,7 @@ namespace VocaluxeLib.PartyModes.Challenge
numPlayed[playerIndex]++; numPlayed[playerIndex]++;
} }
int max = 0; int max = numPlayed.Max();
foreach (int p in numPlayed)
{
if (p > max)
max = p;
}
int num = Rounds[0].Player.Count; int num = Rounds[0].Player.Count;
List<int> result = new List<int>(); List<int> result = new List<int>();
@@ -131,43 +146,26 @@ namespace VocaluxeLib.PartyModes.Challenge
_Rand = rand; _Rand = rand;
} }
public CCombination GetNextCombination(List<int> playerNrDemand) public CCombination GetNextCombination(IEnumerable<int> playerNrDemand)
{ {
if (_Combs.Count == 0) if (_Combs.Count == 0)
_Create(); _Create();
CCombination combs = new CCombination();
if (_NumPlayer == _NumMics) if (_NumPlayer == _NumMics)
return _Combs[0]; return _Combs[0];
//filter against PlayerNrDemand //filter against PlayerNrDemand
List<CCombination> combsFiltered = new List<CCombination>(); List<CCombination> combsFiltered = new List<CCombination>();
if (playerNrDemand != null) if (playerNrDemand != null)
{ combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableAll(playerNrDemand)));
for (int i = 0; i < _Combs.Count; i++)
{
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)
{ combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableSomeone(playerNrDemand)));
for (int i = 0; i < _Combs.Count; i++)
{
if (_Combs[i].IsAvailableSomeone(playerNrDemand))
combsFiltered.Add(_Combs[i]);
}
}
//2nd fallback //2nd fallback
if (combsFiltered.Count == 0) if (combsFiltered.Count == 0)
{ combsFiltered.AddRange(_Combs);
for (int i = 0; i < _Combs.Count; i++)
combsFiltered.Add(_Combs[i]);
}
int num = combsFiltered.Count; int num = combsFiltered.Count;
int rand = _Rand.Next(num); int rand = _Rand.Next(num);
@@ -203,7 +201,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public class CCombination public class CCombination
{ {
public List<int> Player; public readonly List<int> Player;
public CCombination() public CCombination()
{ {
@@ -212,28 +210,17 @@ namespace VocaluxeLib.PartyModes.Challenge
public bool IsAvailable(int playerIndex) public bool IsAvailable(int playerIndex)
{ {
foreach (int p in Player) return Player.Any(p => p == playerIndex);
{
if (p == playerIndex)
return true;
}
return false;
} }
public bool IsAvailableAll(List<int> playerIndices) public bool IsAvailableAll(IEnumerable<int> playerIndices)
{ {
bool result = true; return playerIndices.All(IsAvailable);
foreach (int p in playerIndices)
result &= IsAvailable(p);
return result;
} }
public bool IsAvailableSomeone(List<int> playerIndices) public bool IsAvailableSomeone(IEnumerable<int> playerIndices)
{ {
bool result = false; return playerIndices.Any(IsAvailable);
foreach (int p in playerIndices)
result |= IsAvailable(p);
return result;
} }
} }
} }
@@ -1,3 +1,22 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -39,17 +58,15 @@ namespace VocaluxeLib.PartyModes.Challenge
public int Position; public int Position;
public int PlayerID; public int PlayerID;
public int NumPlayed; public int NumPlayed;
public int NumRounds;
public int NumWon; public int NumWon;
public int NumSingPoints; public int NumSingPoints;
public int NumGamePoints; public int NumGamePoints;
public int CompareTo(object obj) public int CompareTo(object obj)
{ {
if (obj is CResultTableRow) CResultTableRow row = obj as CResultTableRow;
if (row != null)
{ {
CResultTableRow row = (CResultTableRow)obj;
int res = row.NumGamePoints.CompareTo(NumGamePoints); int res = row.NumGamePoints.CompareTo(NumGamePoints);
if (res == 0) if (res == 0)
{ {
@@ -82,8 +99,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public struct SFromScreenNames public struct SFromScreenNames
{ {
public bool FadeToConfig; public bool FadeBack;
public bool FadeToMain;
public List<int> ProfileIDs; public List<int> ProfileIDs;
} }
@@ -162,14 +178,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_ToScreenNames = new SDataToScreenNames(); _ToScreenNames = new SDataToScreenNames();
_ToScreenMain = new SDataToScreenMain(); _ToScreenMain = new SDataToScreenMain();
_GameData = new SData(); _GameData = new SData {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 2, CurrentRoundNr = 1, ProfileIDs = new List<int>(), CatSongIndices = null, Results = null};
_GameData.NumPlayer = 4;
_GameData.NumPlayerAtOnce = 2;
_GameData.NumRounds = 2;
_GameData.CurrentRoundNr = 1;
_GameData.ProfileIDs = new List<int>();
_GameData.CatSongIndices = null;
_GameData.Results = null;
} }
public override bool Init() public override bool Init()
@@ -192,7 +201,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public override void DataFromScreen(string screenName, Object data) public override void DataFromScreen(string screenName, Object data)
{ {
SDataFromScreen dataFrom = new SDataFromScreen(); SDataFromScreen dataFrom;
switch (screenName) switch (screenName)
{ {
case "PartyScreenChallengeConfig": case "PartyScreenChallengeConfig":
@@ -217,7 +226,7 @@ namespace VocaluxeLib.PartyModes.Challenge
try try
{ {
dataFrom = (SDataFromScreen)data; dataFrom = (SDataFromScreen)data;
if (dataFrom.ScreenNames.FadeToConfig) if (dataFrom.ScreenNames.FadeBack)
_Stage = EStage.NotStarted; _Stage = EStage.NotStarted;
else else
{ {
@@ -352,9 +361,10 @@ namespace VocaluxeLib.PartyModes.Challenge
return _ScreenSongOptions; return _ScreenSongOptions;
} }
// ReSharper disable RedundantAssignment
public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions) public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{ {
if (_ScreenSongOptions.Selection.SongIndex != -1)
_ScreenSongOptions.Selection.SongIndex = -1; _ScreenSongOptions.Selection.SongIndex = -1;
if (_ScreenSongOptions.Selection.SelectNextRandomSong && songIndex != -1) if (_ScreenSongOptions.Selection.SelectNextRandomSong && songIndex != -1)
@@ -372,7 +382,9 @@ namespace VocaluxeLib.PartyModes.Challenge
screenSongOptions = _ScreenSongOptions; screenSongOptions = _ScreenSongOptions;
} }
// ReSharper disable RedundantAssignment
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions) public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{ {
if (_GameData.CatSongIndices != null && categoryIndex != -1) if (_GameData.CatSongIndices != null && categoryIndex != -1)
{ {
@@ -440,40 +452,29 @@ 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();
CBase.Game.AddSong(songID, gm); CBase.Game.AddSong(songID, gm);
CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce); CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce);
SPlayer[] player = CBase.Game.GetPlayer(); SPlayer[] player = CBase.Game.GetPlayers();
if (player == null) if (player == null)
return; return;
if (player.Length < _GameData.NumPlayerAtOnce) if (player.Length < _GameData.NumPlayerAtOnce)
return; return;
SProfile[] profiles = CBase.Profiles.GetProfiles();
CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1); CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1);
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
{ {
//default values
player[i].Name = "foobar";
player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
player[i].ProfileID = -1;
//try to fill with the right data //try to fill with the right data
if (c != null) if (c != null)
{
if (_GameData.ProfileIDs[c.Player[i]] < profiles.Length)
{
player[i].Name = profiles[_GameData.ProfileIDs[c.Player[i]]].PlayerName;
player[i].Difficulty = profiles[_GameData.ProfileIDs[c.Player[i]]].Difficulty;
player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]];
} else
} player[i].ProfileID = -1;
} }
CBase.Songs.AddPartySongSung(songID); CBase.Songs.AddPartySongSung(songID);
@@ -568,13 +569,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
for (int i = 0; i < _GameData.NumPlayer; i++) for (int i = 0; i < _GameData.NumPlayer; i++)
{ {
CResultTableRow row = new CResultTableRow(); CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0};
row.PlayerID = _GameData.ProfileIDs[i];
row.NumPlayed = 0;
row.NumRounds = 0;
row.NumWon = 0;
row.NumSingPoints = 0;
row.NumGamePoints = 0;
_GameData.ResultTable.Add(row); _GameData.ResultTable.Add(row);
} }
@@ -587,7 +582,7 @@ namespace VocaluxeLib.PartyModes.Challenge
} }
else else
{ {
SPlayer[] results = CBase.Game.GetPlayer(); SPlayer[] results = CBase.Game.GetPlayers();
if (results == null) if (results == null)
return; return;
@@ -611,20 +606,18 @@ namespace VocaluxeLib.PartyModes.Challenge
} }
} }
if (index != -1) if (index == -1)
{ continue;
CResultTableRow row = _GameData.ResultTable[index]; CResultTableRow row = _GameData.ResultTable[index];
row.NumPlayed++; row.NumPlayed++;
row.NumWon += points[i].Won; row.NumWon += points[i].Won;
row.NumRounds += 1;
row.NumSingPoints += points[i].SingPoints; row.NumSingPoints += points[i].SingPoints;
row.NumGamePoints += points[i].GamePoints; row.NumGamePoints += points[i].GamePoints;
_GameData.ResultTable[index] = row; _GameData.ResultTable[index] = row;
} }
} }
}
_GameData.ResultTable.Sort(); _GameData.ResultTable.Sort();
@@ -632,13 +625,13 @@ namespace VocaluxeLib.PartyModes.Challenge
int pos = 1; int pos = 1;
int lastPoints = 0; int lastPoints = 0;
int lastSingPoints = 0; int lastSingPoints = 0;
for (int i = 0; i < _GameData.ResultTable.Count; i++) foreach (CResultTableRow resultRow in _GameData.ResultTable)
{ {
if (lastPoints > _GameData.ResultTable[i].NumGamePoints || lastSingPoints > _GameData.ResultTable[i].NumSingPoints) if (lastPoints > resultRow.NumGamePoints || lastSingPoints > resultRow.NumSingPoints)
pos++; pos++;
_GameData.ResultTable[i].Position = pos; resultRow.Position = pos;
lastPoints = _GameData.ResultTable[i].NumGamePoints; lastPoints = resultRow.NumGamePoints;
lastSingPoints = _GameData.ResultTable[i].NumSingPoints; lastSingPoints = resultRow.NumSingPoints;
} }
} }
@@ -647,15 +640,11 @@ namespace VocaluxeLib.PartyModes.Challenge
List<SStats> result = new List<SStats>(); List<SStats> result = new List<SStats>();
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
{ {
SStats stat = new SStats(); SStats stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0};
stat.ProfileID = results[i].ProfileID;
stat.SingPoints = (int)Math.Round(results[i].Points);
stat.Won = 0;
stat.GamePoints = 0;
result.Add(stat); result.Add(stat);
} }
result.Sort(delegate(SStats s1, SStats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); }); result.Sort((s1, s2) => s1.SingPoints.CompareTo(s2.SingPoints));
int current = result[result.Count - 1].SingPoints; int current = result[result.Count - 1].SingPoints;
int points = result.Count; int points = result.Count;
@@ -1,10 +1,31 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.Challenge namespace VocaluxeLib.PartyModes.Challenge
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeConfig : CMenuParty public class CPartyScreenChallengeConfig : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -32,20 +53,15 @@ namespace VocaluxeLib.PartyModes.Challenge
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack}; _ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenConfig config = new SFromScreenConfig(); SFromScreenConfig config = new SFromScreenConfig {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 12};
config.NumPlayer = 4;
config.NumPlayerAtOnce = 2;
config.NumRounds = 12;
_Data.ScreenConfig = config; _Data.ScreenConfig = config;
} }
public override void DataToScreen(object receivedData) public override void DataToScreen(object receivedData)
{ {
SDataToScreenConfig config = new SDataToScreenConfig();
try try
{ {
config = (SDataToScreenConfig)receivedData; SDataToScreenConfig config = (SDataToScreenConfig)receivedData;
_Data.ScreenConfig.NumPlayer = config.NumPlayer; _Data.ScreenConfig.NumPlayer = config.NumPlayer;
_Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce; _Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce;
_Data.ScreenConfig.NumRounds = config.NumRounds; _Data.ScreenConfig.NumRounds = config.NumRounds;
@@ -73,10 +89,10 @@ namespace VocaluxeLib.PartyModes.Challenge
case Keys.Enter: case Keys.Enter:
_UpdateSlides(); _UpdateSlides();
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
break; break;
@@ -96,13 +112,13 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
_UpdateSlides(); _UpdateSlides();
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
} }
@@ -139,10 +155,10 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _RebuildSlides() private void _RebuildSlides()
{ {
// build num player slide (min player ... max player); // build num player slide (min player ... max player);
SelectSlides[_SelectSlideNumPlayers].Clear(); _SelectSlides[_SelectSlideNumPlayers].Clear();
for (int i = _PartyMode.GetMinPlayer(); i <= _PartyMode.GetMaxPlayer(); i++) for (int i = _PartyMode.GetMinPlayer(); i <= _PartyMode.GetMaxPlayer(); i++)
SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString()); _SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString());
SelectSlides[_SelectSlideNumPlayers].Selection = _Data.ScreenConfig.NumPlayer - _PartyMode.GetMinPlayer(); _SelectSlides[_SelectSlideNumPlayers].Selection = _Data.ScreenConfig.NumPlayer - _PartyMode.GetMinPlayer();
_UpdateMicsAtOnce(); _UpdateMicsAtOnce();
_SetRoundSteps(); _SetRoundSteps();
@@ -153,9 +169,9 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
int player = _Data.ScreenConfig.NumPlayer; int player = _Data.ScreenConfig.NumPlayer;
int mics = _Data.ScreenConfig.NumPlayerAtOnce; int mics = _Data.ScreenConfig.NumPlayerAtOnce;
_Data.ScreenConfig.NumPlayer = SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.GetMinPlayer(); _Data.ScreenConfig.NumPlayer = _SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumPlayerAtOnce = SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.GetMinPlayer(); _Data.ScreenConfig.NumPlayerAtOnce = _SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumRounds = (SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps; _Data.ScreenConfig.NumRounds = (_SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps;
_UpdateMicsAtOnce(); _UpdateMicsAtOnce();
_SetRoundSteps(); _SetRoundSteps();
@@ -182,19 +198,19 @@ namespace VocaluxeLib.PartyModes.Challenge
_Data.ScreenConfig.NumPlayerAtOnce = maxNum; _Data.ScreenConfig.NumPlayerAtOnce = maxNum;
// build mics at once slide // build mics at once slide
SelectSlides[_SelectSlideNumMics].Clear(); _SelectSlides[_SelectSlideNumMics].Clear();
for (int i = 1; i <= maxNum; i++) for (int i = 1; i <= maxNum; i++)
SelectSlides[_SelectSlideNumMics].AddValue(i.ToString()); _SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
SelectSlides[_SelectSlideNumMics].Selection = _Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer(); _SelectSlides[_SelectSlideNumMics].Selection = _Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
} }
private void _UpdateSlideRounds() private void _UpdateSlideRounds()
{ {
// build num rounds slide // build num rounds slide
SelectSlides[_SelectSlideNumRounds].Clear(); _SelectSlides[_SelectSlideNumRounds].Clear();
for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps) for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString()); _SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString());
SelectSlides[_SelectSlideNumRounds].Selection = _Data.ScreenConfig.NumRounds / _RoundSteps - 1; _SelectSlides[_SelectSlideNumRounds].Selection = _Data.ScreenConfig.NumRounds / _RoundSteps - 1;
} }
private void _SetRoundSteps() private void _SetRoundSteps()
@@ -208,10 +224,7 @@ namespace VocaluxeLib.PartyModes.Challenge
int res = _Data.ScreenConfig.NumPlayer / _Data.ScreenConfig.NumPlayerAtOnce; int res = _Data.ScreenConfig.NumPlayer / _Data.ScreenConfig.NumPlayerAtOnce;
int mod = _Data.ScreenConfig.NumPlayer % _Data.ScreenConfig.NumPlayerAtOnce; int mod = _Data.ScreenConfig.NumPlayer % _Data.ScreenConfig.NumPlayerAtOnce;
if (mod == 0) _RoundSteps = mod == 0 ? res : _Data.ScreenConfig.NumPlayer;
_RoundSteps = res;
else
_RoundSteps = _Data.ScreenConfig.NumPlayer;
} }
private void _Back() private void _Back()
@@ -1,3 +1,22 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
@@ -22,7 +41,9 @@ namespace VocaluxeLib.PartyModes.Challenge
public List<CText> TextScores; public List<CText> TextScores;
} }
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMain : CMenuParty public class CPartyScreenChallengeMain : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -72,13 +93,12 @@ 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()
{ {
_Data = new SDataFromScreen(); _Data = new SDataFromScreen {ScreenMain = new SFromScreenMain()};
_Data.ScreenMain = new SFromScreenMain();
} }
public override void Init() public override void Init()
@@ -87,11 +107,15 @@ namespace VocaluxeLib.PartyModes.Challenge
_ThemeTexts = new string[] _ThemeTexts = new string[]
{ {
_TextPosition, _TextPlayerName, _TextNumPlayed, _TextWon, _TextSingPoints, _TextGamePoints, _TextNextPlayer, _TextPopupReallyExit, _TextRoundNumber, _TextRoundPlayer, _TextPosition, _TextPlayerName, _TextNumPlayed, _TextWon, _TextSingPoints, _TextGamePoints, _TextNextPlayer, _TextPopupReallyExit, _TextRoundNumber,
_TextRoundPlayer,
_TextRoundScore, _TextFinishMessage, _TextFinishPlayerWin, _TextNextPlayerMessage _TextRoundScore, _TextFinishMessage, _TextFinishPlayerWin, _TextNextPlayerMessage
}; };
_ThemeButtons = new string[] _ThemeButtons = new string[]
{_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonPlayerScrollDown, _ButtonPlayerScrollUp, _ButtonRoundsScrollDown, _ButtonRoundsScrollUp}; {
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonPlayerScrollDown, _ButtonPlayerScrollUp, _ButtonRoundsScrollDown,
_ButtonRoundsScrollUp
};
_ThemeStatics = new string[] {_StaticPopupBG, _StaticNextPlayer}; _ThemeStatics = new string[] {_StaticPopupBG, _StaticNextPlayer};
} }
@@ -107,20 +131,18 @@ namespace VocaluxeLib.PartyModes.Challenge
for (int i = 0; i < _PartyMode.GetMaxPlayer(); i++) for (int i = 0; i < _PartyMode.GetMaxPlayer(); i++)
{ {
_NextPlayerTexts.Add(GetNewText(Texts[_TextNextPlayer])); _NextPlayerTexts.Add(GetNewText(_Texts[_TextNextPlayer]));
AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]); _AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]);
_NextPlayerStatics.Add(GetNewStatic(Statics[_StaticNextPlayer])); _NextPlayerStatics.Add(GetNewStatic(_Statics[_StaticNextPlayer]));
AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]); _AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]);
} }
} }
public override void DataToScreen(object receivedData) public override void DataToScreen(object receivedData)
{ {
SDataToScreenMain data = new SDataToScreenMain();
try try
{ {
data = (SDataToScreenMain)receivedData; SDataToScreenMain data = (SDataToScreenMain)receivedData;
_GameState = data; _GameState = data;
} }
catch (Exception e) catch (Exception e)
@@ -154,26 +176,26 @@ namespace VocaluxeLib.PartyModes.Challenge
case Keys.Enter: case Keys.Enter:
if (!_ExitPopupVisible) if (!_ExitPopupVisible)
{ {
if (Buttons[_ButtonNextRound].Selected) if (_Buttons[_ButtonNextRound].Selected)
_NextRound(); _NextRound();
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1) if (_Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
_Back(); _Back();
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1) if (_Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
_ShowPopup(true); _ShowPopup(true);
if (Buttons[_ButtonPlayerScrollUp].Selected) if (_Buttons[_ButtonPlayerScrollUp].Selected)
_ScrollPlayerTable(-1); _ScrollPlayerTable(-1);
if (Buttons[_ButtonPlayerScrollDown].Selected) if (_Buttons[_ButtonPlayerScrollDown].Selected)
_ScrollPlayerTable(1); _ScrollPlayerTable(1);
if (Buttons[_ButtonRoundsScrollUp].Selected) if (_Buttons[_ButtonRoundsScrollUp].Selected)
_ScrollRoundsTable(-1); _ScrollRoundsTable(-1);
if (Buttons[_ButtonRoundsScrollDown].Selected) if (_Buttons[_ButtonRoundsScrollDown].Selected)
_ScrollRoundsTable(1); _ScrollRoundsTable(1);
} }
else else
{ {
if (Buttons[_ButtonPopupYes].Selected) if (_Buttons[_ButtonPopupYes].Selected)
_EndParty(); _EndParty();
if (Buttons[_ButtonPopupNo].Selected) if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false); _ShowPopup(false);
} }
break; break;
@@ -186,30 +208,30 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (!_ExitPopupVisible) if (!_ExitPopupVisible)
{ {
if (Buttons[_ButtonNextRound].Selected) if (_Buttons[_ButtonNextRound].Selected)
_NextRound(); _NextRound();
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1) if (_Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
_Back(); _Back();
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1) if (_Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
_ShowPopup(true); _ShowPopup(true);
if (Buttons[_ButtonPlayerScrollUp].Selected) if (_Buttons[_ButtonPlayerScrollUp].Selected)
_ScrollPlayerTable(-1); _ScrollPlayerTable(-1);
if (Buttons[_ButtonPlayerScrollDown].Selected) if (_Buttons[_ButtonPlayerScrollDown].Selected)
_ScrollPlayerTable(1); _ScrollPlayerTable(1);
if (Buttons[_ButtonRoundsScrollUp].Selected) if (_Buttons[_ButtonRoundsScrollUp].Selected)
_ScrollRoundsTable(-1); _ScrollRoundsTable(-1);
if (Buttons[_ButtonRoundsScrollDown].Selected) if (_Buttons[_ButtonRoundsScrollDown].Selected)
_ScrollRoundsTable(1); _ScrollRoundsTable(1);
} }
else else
{ {
if (Buttons[_ButtonPopupYes].Selected) if (_Buttons[_ButtonPopupYes].Selected)
_EndParty(); _EndParty();
if (Buttons[_ButtonPopupNo].Selected) if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false); _ShowPopup(false);
} }
} }
@@ -256,29 +278,29 @@ namespace VocaluxeLib.PartyModes.Challenge
if (_GameState.CurrentRoundNr == 1) if (_GameState.CurrentRoundNr == 1)
{ {
Buttons[_ButtonBack].Visible = true; _Buttons[_ButtonBack].Visible = true;
Buttons[_ButtonExit].Visible = false; _Buttons[_ButtonExit].Visible = false;
} }
else else
{ {
Buttons[_ButtonBack].Visible = false; _Buttons[_ButtonBack].Visible = false;
Buttons[_ButtonExit].Visible = true; _Buttons[_ButtonExit].Visible = true;
} }
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count) if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{ {
Buttons[_ButtonNextRound].Visible = true; _Buttons[_ButtonNextRound].Visible = true;
Texts[_TextFinishMessage].Visible = false; _Texts[_TextFinishMessage].Visible = false;
Texts[_TextFinishPlayerWin].Visible = false; _Texts[_TextFinishPlayerWin].Visible = false;
SetInteractionToButton(Buttons[_ButtonNextRound]); _SetInteractionToButton(_Buttons[_ButtonNextRound]);
} }
else else
{ {
Buttons[_ButtonNextRound].Visible = false; _Buttons[_ButtonNextRound].Visible = false;
Texts[_TextFinishMessage].Visible = true; _Texts[_TextFinishMessage].Visible = true;
Texts[_TextFinishPlayerWin].Visible = true; _Texts[_TextFinishPlayerWin].Visible = true;
Texts[_TextFinishPlayerWin].Text = _GetPlayerWinString(); _Texts[_TextFinishPlayerWin].Text = _GetPlayerWinString();
SetInteractionToButton(Buttons[_ButtonExit]); _SetInteractionToButton(_Buttons[_ButtonExit]);
} }
_ShowPopup(false); _ShowPopup(false);
@@ -311,13 +333,13 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
_ExitPopupVisible = visible; _ExitPopupVisible = visible;
Statics[_StaticPopupBG].Visible = _ExitPopupVisible; _Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible; _Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible; _Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible; _Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
if (_ExitPopupVisible) if (_ExitPopupVisible)
SetInteractionToButton(Buttons[_ButtonPopupNo]); _SetInteractionToButton(_Buttons[_ButtonPopupNo]);
} }
private void _Back() private void _Back()
@@ -329,9 +351,9 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdateNextPlayerPositions() private void _UpdateNextPlayerPositions()
{ {
float x = CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2; float x = (float)CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2;
float staticY = 590; const float staticY = 590;
float textY = 550; const float textY = 550;
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
//static //static
@@ -339,11 +361,11 @@ namespace VocaluxeLib.PartyModes.Challenge
_NextPlayerStatics[i].Rect.Y = staticY; _NextPlayerStatics[i].Rect.Y = staticY;
_NextPlayerStatics[i].Visible = true; _NextPlayerStatics[i].Visible = true;
//text //text
_NextPlayerTexts[i].X = x + Statics[_StaticNextPlayer].Rect.W / 2; _NextPlayerTexts[i].X = x + _Statics[_StaticNextPlayer].Rect.W / 2;
_NextPlayerTexts[i].Y = textY; _NextPlayerTexts[i].Y = textY;
_NextPlayerTexts[i].Visible = true; _NextPlayerTexts[i].Visible = true;
x += Statics[_StaticNextPlayer].Rect.W + 15; x += _Statics[_StaticNextPlayer].Rect.W + 15;
} }
for (int i = _GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++) for (int i = _GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
{ {
@@ -356,7 +378,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count) if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{ {
Texts[_TextNextPlayerMessage].Visible = true; _Texts[_TextNextPlayerMessage].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles(); SProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
@@ -368,7 +390,7 @@ namespace VocaluxeLib.PartyModes.Challenge
} }
else else
{ {
Texts[_TextNextPlayerMessage].Visible = false; _Texts[_TextNextPlayerMessage].Visible = false;
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
_NextPlayerStatics[i].Visible = false; _NextPlayerStatics[i].Visible = false;
@@ -383,30 +405,28 @@ namespace VocaluxeLib.PartyModes.Challenge
_RoundsTable = new List<CRoundsTableRow>(); _RoundsTable = new List<CRoundsTableRow>();
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
CRoundsTableRow rtr = new CRoundsTableRow(); CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()};
rtr.TextPlayer = new List<CText>();
rtr.TextScores = new List<CText>();
_RoundsTable.Add(rtr); _RoundsTable.Add(rtr);
} }
//Create statics and texts for rounds //Create statics and texts for rounds
for (int round = 0; round < _RoundsTable.Count; round++) foreach (CRoundsTableRow roundRow in _RoundsTable)
{ {
//Round-number //Round-number
CText text = GetNewText(Texts[_TextRoundNumber]); CText text = GetNewText(_Texts[_TextRoundNumber]);
AddText(text); _AddText(text);
_RoundsTable[round].Number = text; roundRow.Number = text;
for (int row = 0; row < 2; row++) for (int row = 0; row < 2; row++)
{ {
for (int column = 0; column < 3; column++) for (int column = 0; column < 3; column++)
{ {
//Player //Player
text = GetNewText(Texts[_TextRoundPlayer]); text = GetNewText(_Texts[_TextRoundPlayer]);
AddText(text); _AddText(text);
_RoundsTable[round].TextPlayer.Add(text); roundRow.TextPlayer.Add(text);
//Score //Score
text = GetNewText(Texts[_TextRoundScore]); text = GetNewText(_Texts[_TextRoundScore]);
AddText(text); _AddText(text);
_RoundsTable[round].TextScores.Add(text); roundRow.TextScores.Add(text);
} }
} }
} }
@@ -416,30 +436,27 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
_RoundsTableScrollArea = new SRectF(); _RoundsTableScrollArea = new SRectF();
int numPlayerInOneRow = 3; const int numPlayerInOneRow = 3;
if (_GameState.NumPlayerAtOnce <= numPlayerInOneRow) _NumRoundsVisible = _GameState.NumPlayerAtOnce <= numPlayerInOneRow ? 5 : 3;
_NumRoundsVisible = 5;
else
_NumRoundsVisible = 3;
if (_NumRoundsVisible > _GameState.Combs.Count) if (_NumRoundsVisible > _GameState.Combs.Count)
_NumRoundsVisible = _GameState.Combs.Count; _NumRoundsVisible = _GameState.Combs.Count;
float numberX = Texts[_TextRoundNumber].X; float numberX = _Texts[_TextRoundNumber].X;
float numberY = Texts[_TextRoundNumber].Y; float numberY = _Texts[_TextRoundNumber].Y;
_RoundsTableScrollArea.X = numberX; _RoundsTableScrollArea.X = numberX;
_RoundsTableScrollArea.Y = numberY; _RoundsTableScrollArea.Y = numberY;
_RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20; _RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20;
float delta = Texts[_TextRoundNumber].Height; float delta = _Texts[_TextRoundNumber].Height;
//Update statics and texts for rounds //Update statics and texts for rounds
for (int round = 0; round < _RoundsTable.Count; round++) foreach (CRoundsTableRow roundRow in _RoundsTable)
{ {
//Round-number //Round-number
_RoundsTable[round].Number.X = numberX; roundRow.Number.X = numberX;
_RoundsTable[round].Number.Y = numberY; roundRow.Number.Y = numberY;
int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow)); int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow));
for (int row = 0; row < numInnerRows; row++) for (int row = 0; row < numInnerRows; row++)
{ {
@@ -453,17 +470,17 @@ namespace VocaluxeLib.PartyModes.Challenge
for (int column = row * numPlayerInOneRow; column < num; column++) for (int column = row * numPlayerInOneRow; column < num; column++)
{ {
//Player //Player
float x = numberX + 15 + (CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) + float x = numberX + 15 + (CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) +
((CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2; ((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2;
float maxw = ((CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5; float maxw = ((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5;
_RoundsTable[round].TextPlayer[column].X = x; roundRow.TextPlayer[column].X = x;
_RoundsTable[round].TextPlayer[column].Y = numberY; roundRow.TextPlayer[column].Y = numberY;
_RoundsTable[round].TextPlayer[column].MaxWidth = maxw; roundRow.TextPlayer[column].MaxWidth = maxw;
//Score //Score
_RoundsTable[round].TextScores[column] = _RoundsTable[round].TextScores[column]; roundRow.TextScores[column] = roundRow.TextScores[column];
_RoundsTable[round].TextScores[column].X = x; roundRow.TextScores[column].X = x;
_RoundsTable[round].TextScores[column].Y = numberY + delta; roundRow.TextScores[column].Y = numberY + delta;
_RoundsTable[round].TextScores[column].MaxWidth = maxw; roundRow.TextScores[column].MaxWidth = maxw;
} }
numberY = numberY + delta + delta; numberY = numberY + delta + delta;
} }
@@ -484,7 +501,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_RoundsTable[i].Number.Visible = true; _RoundsTable[i].Number.Visible = true;
_RoundsTable[i].TextPlayer[p].Visible = true; _RoundsTable[i].TextPlayer[p].Visible = true;
_RoundsTable[i].TextScores[p].Visible = true; _RoundsTable[i].TextScores[p].Visible = true;
_RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset).ToString() + ")"; _RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")";
int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]; int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]];
_RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName; _RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset) if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset)
@@ -509,32 +526,30 @@ namespace VocaluxeLib.PartyModes.Challenge
} }
} }
Buttons[_ButtonRoundsScrollUp].Visible = _RoundsTableOffset > 0; _Buttons[_ButtonRoundsScrollUp].Visible = _RoundsTableOffset > 0;
Buttons[_ButtonRoundsScrollDown].Visible = _GameState.Combs.Count - _NumRoundsVisible - _RoundsTableOffset > 0; _Buttons[_ButtonRoundsScrollDown].Visible = _GameState.Combs.Count - _NumRoundsVisible - _RoundsTableOffset > 0;
} }
private void _BuildPlayerTable() private void _BuildPlayerTable()
{ {
_PlayerTableScrollArea = new SRectF(); _PlayerTableScrollArea = new SRectF {X = _Texts[_TextPosition].X, Y = _Texts[_TextPosition].Y, W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X};
_PlayerTableScrollArea.X = Texts[_TextPosition].X;
_PlayerTableScrollArea.Y = Texts[_TextPosition].Y;
_PlayerTableScrollArea.W = Texts[_TextGamePoints].X - Texts[_TextPosition].X;
_PlayerTable = new List<STableRow>(); _PlayerTable = new List<STableRow>();
float delta = Texts[_TextPosition].Height * 1.2f; float delta = _Texts[_TextPosition].Height * 1.2f;
float h = 0; float h = 0;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
STableRow row = new STableRow(); STableRow row = new STableRow
{
row.Pos = GetNewText(Texts[_TextPosition]); Pos = GetNewText(_Texts[_TextPosition]),
row.Name = GetNewText(Texts[_TextPlayerName]); Name = GetNewText(_Texts[_TextPlayerName]),
row.Rounds = GetNewText(Texts[_TextNumPlayed]); Rounds = GetNewText(_Texts[_TextNumPlayed]),
row.Won = GetNewText(Texts[_TextWon]); Won = GetNewText(_Texts[_TextWon]),
row.SingPoints = GetNewText(Texts[_TextSingPoints]); SingPoints = GetNewText(_Texts[_TextSingPoints]),
row.GamePoints = GetNewText(Texts[_TextGamePoints]); GamePoints = GetNewText(_Texts[_TextGamePoints])
};
row.Pos.Y += delta * (i + 1); row.Pos.Y += delta * (i + 1);
row.Name.Y += delta * (i + 1); row.Name.Y += delta * (i + 1);
@@ -543,7 +558,7 @@ namespace VocaluxeLib.PartyModes.Challenge
row.SingPoints.Y += delta * (i + 1); row.SingPoints.Y += delta * (i + 1);
row.GamePoints.Y += delta * (i + 1); row.GamePoints.Y += delta * (i + 1);
row.Pos.Text = (i + 1).ToString() + "."; row.Pos.Text = (i + 1) + ".";
row.Pos.Visible = false; row.Pos.Visible = false;
row.Name.Visible = false; row.Name.Visible = false;
@@ -552,12 +567,12 @@ namespace VocaluxeLib.PartyModes.Challenge
row.SingPoints.Visible = false; row.SingPoints.Visible = false;
row.GamePoints.Visible = false; row.GamePoints.Visible = false;
AddText(row.Pos); _AddText(row.Pos);
AddText(row.Name); _AddText(row.Name);
AddText(row.Rounds); _AddText(row.Rounds);
AddText(row.Won); _AddText(row.Won);
AddText(row.SingPoints); _AddText(row.SingPoints);
AddText(row.GamePoints); _AddText(row.GamePoints);
_PlayerTable.Add(row); _PlayerTable.Add(row);
@@ -583,9 +598,9 @@ namespace VocaluxeLib.PartyModes.Challenge
row.SingPoints.Visible = true; row.SingPoints.Visible = true;
row.GamePoints.Visible = true; row.GamePoints.Visible = true;
row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position.ToString() + "."; 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();
@@ -601,8 +616,8 @@ namespace VocaluxeLib.PartyModes.Challenge
} }
} }
Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0; _Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0;
Buttons[_ButtonPlayerScrollDown].Visible = _GameState.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0; _Buttons[_ButtonPlayerScrollDown].Visible = _GameState.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0;
} }
private void _ScrollPlayerTable(int offset) private void _ScrollPlayerTable(int offset)
@@ -1,11 +1,33 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.Challenge namespace VocaluxeLib.PartyModes.Challenge
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeNames : CMenuParty public class CPartyScreenChallengeNames : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -22,7 +44,6 @@ namespace VocaluxeLib.PartyModes.Challenge
private List<CButton> _PlayerDestinationButtons; private List<CButton> _PlayerDestinationButtons;
//PlayerDestinationButtons-Option //PlayerDestinationButtons-Option
private const int _PlayerDestinationButtonsNumH = 3; private const int _PlayerDestinationButtonsNumH = 3;
private const int _PlayerDestinationButtonsNumW = 4;
private const int _PlayerDestinationButtonsFirstX = 900; private const int _PlayerDestinationButtonsFirstX = 900;
private const int _PlayerDestinationButtonsFirstY = 105; private const int _PlayerDestinationButtonsFirstY = 105;
private const int _PlayerDestinationButtonsSpaceH = 15; private const int _PlayerDestinationButtonsSpaceH = 15;
@@ -35,7 +56,7 @@ namespace VocaluxeLib.PartyModes.Challenge
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;
@@ -65,27 +86,19 @@ namespace VocaluxeLib.PartyModes.Challenge
_Data.ScreenNames.ProfileIDs = new List<int>(); _Data.ScreenNames.ProfileIDs = new List<int>();
List<string> buttons = new List<string>();
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames(); SFromScreenNames names = new SFromScreenNames {FadeBack = false, ProfileIDs = new List<int>()};
names.FadeToConfig = false;
names.FadeToMain = false;
names.ProfileIDs = new List<int>();
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
public override void DataToScreen(object receivedData) public override void DataToScreen(object receivedData)
{ {
SDataToScreenNames config = new SDataToScreenNames();
try try
{ {
config = (SDataToScreenNames)receivedData; SDataToScreenNames config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDs = config.ProfileIDs; _Data.ScreenNames.ProfileIDs = config.ProfileIDs ?? new List<int>();
if (_Data.ScreenNames.ProfileIDs == null)
_Data.ScreenNames.ProfileIDs = new List<int>();
_NumPlayer = config.NumPlayer; _NumPlayer = config.NumPlayer;
@@ -113,10 +126,10 @@ namespace VocaluxeLib.PartyModes.Challenge
break; break;
case Keys.Enter: case Keys.Enter:
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
if (!_OnAdd()) if (!_OnAdd())
@@ -218,12 +231,12 @@ namespace VocaluxeLib.PartyModes.Challenge
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
} }
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
if (!_OnAdd()) if (!_OnAdd())
@@ -268,13 +281,13 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _AddButtonPlayerDestination() private void _AddButtonPlayerDestination()
{ {
Buttons[_ButtonPlayerDestination].Visible = false; _Buttons[_ButtonPlayerDestination].Visible = false;
_PlayerDestinationButtons = new List<CButton>(); _PlayerDestinationButtons = new List<CButton>();
int row = 0; int row = 0;
int column = 0; int column = 0;
for (int i = 1; i <= _PartyMode.GetMaxPlayer(); i++) for (int i = 1; i <= _PartyMode.GetMaxPlayer(); i++)
{ {
CButton b = GetNewButton(Buttons[_ButtonPlayerDestination]); CButton b = GetNewButton(_Buttons[_ButtonPlayerDestination]);
b.Rect.X = _PlayerDestinationButtonsFirstX + column * (b.Rect.W + _PlayerDestinationButtonsSpaceH); b.Rect.X = _PlayerDestinationButtonsFirstX + column * (b.Rect.W + _PlayerDestinationButtonsSpaceH);
b.Rect.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW); b.Rect.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW);
_PlayerDestinationButtons.Add(b); _PlayerDestinationButtons.Add(b);
@@ -286,24 +299,22 @@ namespace VocaluxeLib.PartyModes.Challenge
} }
b.Visible = true; b.Visible = true;
b.Enabled = false; b.Enabled = false;
AddButton(b); _AddButton(b);
} }
} }
private void _AddButtonPlayerChoose() private void _AddButtonPlayerChoose()
{ {
Buttons[_ButtonPlayerChoose].Visible = false; _Buttons[_ButtonPlayerChoose].Visible = false;
_PlayerChooseButtons = new List<CPlayerChooseButton>(); _PlayerChooseButtons = new List<CPlayerChooseButton>();
int row = 0; int row = 0;
int column = 0; int column = 0;
for (int i = 1; i <= _PlayerChooseButtonsNumH * _PlayerChooseButtonsNumW; i++) for (int i = 1; i <= _PlayerChooseButtonsNumH * _PlayerChooseButtonsNumW; i++)
{ {
CButton b = GetNewButton(Buttons[_ButtonPlayerChoose]); CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]);
b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH); b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH);
b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW); b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW);
CPlayerChooseButton pcb = new CPlayerChooseButton(); CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1};
pcb.Button = b;
pcb.ProfileID = -1;
_PlayerChooseButtons.Add(pcb); _PlayerChooseButtons.Add(pcb);
column++; column++;
if (column >= _PlayerChooseButtonsNumH) if (column >= _PlayerChooseButtonsNumH)
@@ -313,7 +324,7 @@ namespace VocaluxeLib.PartyModes.Challenge
} }
b.Visible = true; b.Visible = true;
b.Enabled = false; b.Enabled = false;
AddButton(b); _AddButton(b);
} }
} }
@@ -329,7 +340,7 @@ namespace VocaluxeLib.PartyModes.Challenge
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;
@@ -341,8 +352,10 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
_PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]; _PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose];
_PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName; _PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName;
_PlayerChooseButtons[i].Button.Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; _PlayerChooseButtons[i].Button.Texture =
_PlayerChooseButtons[i].Button.SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.SelTexture =
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f); _PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
_PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1); _PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1);
_PlayerChooseButtons[i].Button.Enabled = true; _PlayerChooseButtons[i].Button.Enabled = true;
@@ -351,10 +364,10 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
_PlayerChooseButtons[i].ProfileID = -1; _PlayerChooseButtons[i].ProfileID = -1;
_PlayerChooseButtons[i].Button.Text.Text = String.Empty; _PlayerChooseButtons[i].Button.Text.Text = String.Empty;
_PlayerChooseButtons[i].Button.Texture = Buttons[_ButtonPlayerChoose].Texture; _PlayerChooseButtons[i].Button.Texture = _Buttons[_ButtonPlayerChoose].Texture;
_PlayerChooseButtons[i].Button.SelTexture = Buttons[_ButtonPlayerChoose].SelTexture; _PlayerChooseButtons[i].Button.SelTexture = _Buttons[_ButtonPlayerChoose].SelTexture;
_PlayerChooseButtons[i].Button.Color = Buttons[_ButtonPlayerChoose].Color; _PlayerChooseButtons[i].Button.Color = _Buttons[_ButtonPlayerChoose].Color;
_PlayerChooseButtons[i].Button.SelColor = Buttons[_ButtonPlayerChoose].SelColor; _PlayerChooseButtons[i].Button.SelColor = _Buttons[_ButtonPlayerChoose].SelColor;
_PlayerChooseButtons[i].Button.Enabled = false; _PlayerChooseButtons[i].Button.Enabled = false;
} }
} }
@@ -369,19 +382,7 @@ namespace VocaluxeLib.PartyModes.Challenge
bool visible = false; bool visible = false;
//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 = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != i);
visible = true;
for (int p = 0; p < _Data.ScreenNames.ProfileIDs.Count; p++)
{
//Don't show profile if is selected
if (_Data.ScreenNames.ProfileIDs[p] == i)
{
visible = false;
break;
}
}
}
if (visible) if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(i); _PlayerChooseButtonsVisibleProfiles.Add(i);
} }
@@ -418,10 +419,10 @@ namespace VocaluxeLib.PartyModes.Challenge
} }
else else
{ {
_PlayerDestinationButtons[i].Color = Buttons[_ButtonPlayerDestination].Color; _PlayerDestinationButtons[i].Color = _Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i].SelColor = Buttons[_ButtonPlayerDestination].SelColor; _PlayerDestinationButtons[i].SelColor = _Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i].Texture = Buttons[_ButtonPlayerDestination].Texture; _PlayerDestinationButtons[i].Texture = _Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i].SelTexture = Buttons[_ButtonPlayerDestination].SelTexture; _PlayerDestinationButtons[i].SelTexture = _Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i].Text.Text = String.Empty; _PlayerDestinationButtons[i].Text.Text = String.Empty;
_PlayerDestinationButtons[i].Enabled = false; _PlayerDestinationButtons[i].Enabled = false;
} }
@@ -432,72 +433,63 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
if (_Data.ScreenNames.ProfileIDs.Count == _NumPlayer) if (_Data.ScreenNames.ProfileIDs.Count == _NumPlayer)
{ {
Buttons[_ButtonNext].Visible = true; _Buttons[_ButtonNext].Visible = true;
SetInteractionToButton(Buttons[_ButtonNext]); _SetInteractionToButton(_Buttons[_ButtonNext]);
} }
else else
Buttons[_ButtonNext].Visible = false; _Buttons[_ButtonNext].Visible = false;
} }
private bool _OnAdd() private bool _OnAdd()
{ {
for (int i = 0; i < _PlayerChooseButtons.Count; i++) foreach (CPlayerChooseButton button in _PlayerChooseButtons)
{ {
if (_PlayerChooseButtons[i].Button.Selected && _PlayerChooseButtons[i].ProfileID != -1) if (!button.Button.Selected || button.ProfileID == -1 || _Data.ScreenNames.ProfileIDs.Count >= _NumPlayer)
{ continue;
if (_Data.ScreenNames.ProfileIDs.Count < _NumPlayer) _Data.ScreenNames.ProfileIDs.Add(button.ProfileID);
{
_Data.ScreenNames.ProfileIDs.Add(_PlayerChooseButtons[i].ProfileID);
int added = _Data.ScreenNames.ProfileIDs.Count - 1; int added = _Data.ScreenNames.ProfileIDs.Count - 1;
_UpdateButtonNext(); _UpdateButtonNext();
//Update texture and name //Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[button.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[button.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName; _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[button.ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true; _PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List //Update Tiles-List
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
CheckInteraction(); _CheckInteraction();
return true; return true;
} }
}
}
return false; return false;
} }
private bool _OnRemove() private void _OnRemove()
{ {
for (int i = 0; i < _PlayerDestinationButtons.Count; i++) for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
{ {
if (_PlayerDestinationButtons[i].Selected) if (!_PlayerDestinationButtons[i].Selected)
{ continue;
if ((i + 1) <= _Data.ScreenNames.ProfileIDs.Count) if ((i + 1) > _Data.ScreenNames.ProfileIDs.Count)
{ continue;
_Data.ScreenNames.ProfileIDs.RemoveAt(i); _Data.ScreenNames.ProfileIDs.RemoveAt(i);
_UpdateButtonNext(); _UpdateButtonNext();
_UpdateButtonPlayerDestination(); _UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
CheckInteraction(); _CheckInteraction();
return true; return;
} }
} }
}
return false;
}
private void _Back() private void _Back()
{ {
_Data.ScreenNames.FadeToConfig = true; _Data.ScreenNames.FadeBack = true;
_Data.ScreenNames.FadeToMain = false;
_PartyMode.DataFromScreen(ThemeName, _Data); _PartyMode.DataFromScreen(ThemeName, _Data);
} }
private void _Next() private void _Next()
{ {
_Data.ScreenNames.FadeToConfig = false; _Data.ScreenNames.FadeBack = false;
_Data.ScreenNames.FadeToMain = true;
_PartyMode.DataFromScreen(ThemeName, _Data); _PartyMode.DataFromScreen(ThemeName, _Data);
} }
} }
Binary file not shown.
@@ -1,5 +1,25 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace VocaluxeLib.PartyModes.ChallengeMedley namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
@@ -8,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)
{ {
@@ -53,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>();
@@ -136,38 +151,21 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
if (_Combs.Count == 0) if (_Combs.Count == 0)
_Create(); _Create();
CCombination combs = new CCombination();
if (_NumPlayer == _NumMics) if (_NumPlayer == _NumMics)
return _Combs[0]; return _Combs[0];
//filter against PlayerNrDemand //filter against PlayerNrDemand
List<CCombination> combsFiltered = new List<CCombination>(); List<CCombination> combsFiltered = new List<CCombination>();
if (playerNrDemand != null) if (playerNrDemand != null)
{ combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableAll(playerNrDemand)));
for (int i = 0; i < _Combs.Count; i++)
{
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)
{ combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableSomeone(playerNrDemand)));
for (int i = 0; i < _Combs.Count; i++)
{
if (_Combs[i].IsAvailableSomeone(playerNrDemand))
combsFiltered.Add(_Combs[i]);
}
}
//2nd fallback //2nd fallback
if (combsFiltered.Count == 0) if (combsFiltered.Count == 0)
{ combsFiltered.AddRange(_Combs);
for (int i = 0; i < _Combs.Count; i++)
combsFiltered.Add(_Combs[i]);
}
int num = combsFiltered.Count; int num = combsFiltered.Count;
int rand = _Rand.Next(num); int rand = _Rand.Next(num);
@@ -203,7 +201,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public class CCombination public class CCombination
{ {
public List<int> Player; public readonly List<int> Player;
public CCombination() public CCombination()
{ {
@@ -212,28 +210,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(List<int> playerIndices) public bool IsAvailableAll(IEnumerable<int> playerIndices)
{ {
bool result = true; return playerIndices.All(IsAvailable);
foreach (int p in playerIndices)
result &= IsAvailable(p);
return result;
} }
public bool IsAvailableSomeone(List<int> playerIndices) public bool IsAvailableSomeone(IEnumerable<int> playerIndices)
{ {
bool result = false; return playerIndices.Any(IsAvailable);
foreach (int p in playerIndices)
result |= IsAvailable(p);
return result;
} }
} }
} }
@@ -1,3 +1,22 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -40,17 +59,15 @@ 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;
public int CompareTo(object obj) public int CompareTo(object obj)
{ {
if (obj is CResultTableRow) CResultTableRow row = obj as CResultTableRow;
if (row != null)
{ {
CResultTableRow row = (CResultTableRow)obj;
int res = row.NumGamePoints.CompareTo(NumGamePoints); int res = row.NumGamePoints.CompareTo(NumGamePoints);
if (res == 0) if (res == 0)
{ {
@@ -84,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;
} }
@@ -164,14 +180,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ToScreenNames = new SDataToScreenNames(); _ToScreenNames = new SDataToScreenNames();
_ToScreenMain = new SDataToScreenMain(); _ToScreenMain = new SDataToScreenMain();
_GameData = new SData(); _GameData = new SData {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 2, CurrentRoundNr = 1, ProfileIDs = new List<int>(), CatSongIndices = null, Results = null};
_GameData.NumPlayer = 4;
_GameData.NumPlayerAtOnce = 2;
_GameData.NumRounds = 2;
_GameData.CurrentRoundNr = 1;
_GameData.ProfileIDs = new List<int>();
_GameData.CatSongIndices = null;
_GameData.Results = null;
} }
public override bool Init() public override bool Init()
@@ -197,7 +206,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public override void DataFromScreen(string screenName, Object data) public override void DataFromScreen(string screenName, Object data)
{ {
SDataFromScreen dataFrom = new SDataFromScreen(); SDataFromScreen dataFrom;
switch (screenName) switch (screenName)
{ {
case "PartyScreenChallengeMedleyConfig": case "PartyScreenChallengeMedleyConfig":
@@ -357,9 +366,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
return _ScreenSongOptions; return _ScreenSongOptions;
} }
// ReSharper disable RedundantAssignment
public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions) public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{ {
if (_ScreenSongOptions.Selection.SongIndex != -1)
_ScreenSongOptions.Selection.SongIndex = -1; _ScreenSongOptions.Selection.SongIndex = -1;
if (_ScreenSongOptions.Selection.SelectNextRandomSong && songIndex != -1) if (_ScreenSongOptions.Selection.SelectNextRandomSong && songIndex != -1)
@@ -377,7 +387,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
screenSongOptions = _ScreenSongOptions; screenSongOptions = _ScreenSongOptions;
} }
// ReSharper disable RedundantAssignment
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions) public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{ {
if (_GameData.CatSongIndices != null && categoryIndex != -1) if (_GameData.CatSongIndices != null && categoryIndex != -1)
{ {
@@ -470,33 +482,22 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
#region PlayerNames #region PlayerNames
CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce); CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce);
SPlayer[] player = CBase.Game.GetPlayer(); SPlayer[] player = CBase.Game.GetPlayers();
if (player == null) if (player == null)
return false; return false;
if (player.Length < _GameData.NumPlayerAtOnce) if (player.Length < _GameData.NumPlayerAtOnce)
return false; return false;
SProfile[] profiles = CBase.Profiles.GetProfiles();
CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1); CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1);
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
{ {
//default values
player[i].Name = "foobar";
player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
player[i].ProfileID = -1;
//try to fill with the right data //try to fill with the right data
if (c != null) if (c != null)
{
if (_GameData.ProfileIDs[c.Player[i]] < profiles.Length)
{
player[i].Name = profiles[_GameData.ProfileIDs[c.Player[i]]].PlayerName;
player[i].Difficulty = profiles[_GameData.ProfileIDs[c.Player[i]]].Difficulty;
player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]];
} else
} player[i].ProfileID = -1;
} }
#endregion PlayerNames #endregion PlayerNames
@@ -504,8 +505,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)
@@ -520,11 +521,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);
@@ -532,12 +533,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;
@@ -616,13 +617,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(); CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0};
row.PlayerID = _GameData.ProfileIDs[i];
row.NumPlayed = 0;
row.NumRounds = 0;
row.NumWon = 0;
row.NumSingPoints = 0;
row.NumGamePoints = 0;
_GameData.ResultTable.Add(row); _GameData.ResultTable.Add(row);
} }
@@ -682,7 +677,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;
@@ -697,13 +691,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
int pos = 1; int pos = 1;
int lastPoints = 0; int lastPoints = 0;
int lastSingPoints = 0; int lastSingPoints = 0;
for (int i = 0; i < _GameData.ResultTable.Count; i++) foreach (CResultTableRow resultRow in _GameData.ResultTable)
{ {
if (lastPoints > _GameData.ResultTable[i].NumGamePoints || lastSingPoints > _GameData.ResultTable[i].NumSingPoints) if (lastPoints > resultRow.NumGamePoints || lastSingPoints > resultRow.NumSingPoints)
pos++; pos++;
_GameData.ResultTable[i].Position = pos; resultRow.Position = pos;
lastPoints = _GameData.ResultTable[i].NumGamePoints; lastPoints = resultRow.NumGamePoints;
lastSingPoints = _GameData.ResultTable[i].NumSingPoints; lastSingPoints = resultRow.NumSingPoints;
} }
} }
@@ -712,15 +706,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
List<SStats> result = new List<SStats>(); List<SStats> result = new List<SStats>();
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
{ {
SStats stat = new SStats(); SStats stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0};
stat.ProfileID = results[i].ProfileID;
stat.SingPoints = (int)Math.Round(results[i].Points);
stat.Won = 0;
stat.GamePoints = 0;
result.Add(stat); result.Add(stat);
} }
result.Sort(delegate(SStats s1, SStats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); }); result.Sort((s1, s2) => s1.SingPoints.CompareTo(s2.SingPoints));
int current = result[result.Count - 1].SingPoints; int current = result[result.Count - 1].SingPoints;
int points = result.Count; int points = result.Count;
@@ -1,10 +1,31 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.ChallengeMedley namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMedleyConfig : CMenuParty public class CPartyScreenChallengeMedleyConfig : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -32,20 +53,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack}; _ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenConfig config = new SFromScreenConfig(); SFromScreenConfig config = new SFromScreenConfig {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 12};
config.NumPlayer = 4;
config.NumPlayerAtOnce = 2;
config.NumRounds = 12;
_Data.ScreenConfig = config; _Data.ScreenConfig = config;
} }
public override void DataToScreen(object receivedData) public override void DataToScreen(object receivedData)
{ {
SDataToScreenConfig config = new SDataToScreenConfig();
try try
{ {
config = (SDataToScreenConfig)receivedData; SDataToScreenConfig config = (SDataToScreenConfig)receivedData;
_Data.ScreenConfig.NumPlayer = config.NumPlayer; _Data.ScreenConfig.NumPlayer = config.NumPlayer;
_Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce; _Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce;
_Data.ScreenConfig.NumRounds = config.NumRounds; _Data.ScreenConfig.NumRounds = config.NumRounds;
@@ -73,10 +89,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
case Keys.Enter: case Keys.Enter:
_UpdateSlides(); _UpdateSlides();
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
break; break;
@@ -96,13 +112,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
_UpdateSlides(); _UpdateSlides();
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
} }
@@ -139,10 +155,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _RebuildSlides() private void _RebuildSlides()
{ {
// build num player slide (min player ... max player); // build num player slide (min player ... max player);
SelectSlides[_SelectSlideNumPlayers].Clear(); _SelectSlides[_SelectSlideNumPlayers].Clear();
for (int i = _PartyMode.GetMinPlayer(); i <= _PartyMode.GetMaxPlayer(); i++) for (int i = _PartyMode.GetMinPlayer(); i <= _PartyMode.GetMaxPlayer(); i++)
SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString()); _SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString());
SelectSlides[_SelectSlideNumPlayers].Selection = _Data.ScreenConfig.NumPlayer - _PartyMode.GetMinPlayer(); _SelectSlides[_SelectSlideNumPlayers].Selection = _Data.ScreenConfig.NumPlayer - _PartyMode.GetMinPlayer();
_UpdateMicsAtOnce(); _UpdateMicsAtOnce();
_SetRoundSteps(); _SetRoundSteps();
@@ -153,9 +169,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
int player = _Data.ScreenConfig.NumPlayer; int player = _Data.ScreenConfig.NumPlayer;
int mics = _Data.ScreenConfig.NumPlayerAtOnce; int mics = _Data.ScreenConfig.NumPlayerAtOnce;
_Data.ScreenConfig.NumPlayer = SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.GetMinPlayer(); _Data.ScreenConfig.NumPlayer = _SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumPlayerAtOnce = SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.GetMinPlayer(); _Data.ScreenConfig.NumPlayerAtOnce = _SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumRounds = (SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps; _Data.ScreenConfig.NumRounds = (_SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps;
_UpdateMicsAtOnce(); _UpdateMicsAtOnce();
_SetRoundSteps(); _SetRoundSteps();
@@ -182,19 +198,19 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_Data.ScreenConfig.NumPlayerAtOnce = maxNum; _Data.ScreenConfig.NumPlayerAtOnce = maxNum;
// build mics at once slide // build mics at once slide
SelectSlides[_SelectSlideNumMics].Clear(); _SelectSlides[_SelectSlideNumMics].Clear();
for (int i = 1; i <= maxNum; i++) for (int i = 1; i <= maxNum; i++)
SelectSlides[_SelectSlideNumMics].AddValue(i.ToString()); _SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
SelectSlides[_SelectSlideNumMics].Selection = _Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer(); _SelectSlides[_SelectSlideNumMics].Selection = _Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
} }
private void _UpdateSlideRounds() private void _UpdateSlideRounds()
{ {
// build num rounds slide // build num rounds slide
SelectSlides[_SelectSlideNumRounds].Clear(); _SelectSlides[_SelectSlideNumRounds].Clear();
for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps) for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString()); _SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString());
SelectSlides[_SelectSlideNumRounds].Selection = _Data.ScreenConfig.NumRounds / _RoundSteps - 1; _SelectSlides[_SelectSlideNumRounds].Selection = _Data.ScreenConfig.NumRounds / _RoundSteps - 1;
} }
private void _SetRoundSteps() private void _SetRoundSteps()
@@ -208,10 +224,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
int res = _Data.ScreenConfig.NumPlayer / _Data.ScreenConfig.NumPlayerAtOnce; int res = _Data.ScreenConfig.NumPlayer / _Data.ScreenConfig.NumPlayerAtOnce;
int mod = _Data.ScreenConfig.NumPlayer % _Data.ScreenConfig.NumPlayerAtOnce; int mod = _Data.ScreenConfig.NumPlayer % _Data.ScreenConfig.NumPlayerAtOnce;
if (mod == 0) _RoundSteps = mod == 0 ? res : _Data.ScreenConfig.NumPlayer;
_RoundSteps = res;
else
_RoundSteps = _Data.ScreenConfig.NumPlayer;
} }
private void _Back() private void _Back()
@@ -1,3 +1,22 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
@@ -22,7 +41,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public List<CText> TextScores; public List<CText> TextScores;
} }
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMedleyMain : CMenuParty public class CPartyScreenChallengeMedleyMain : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -72,13 +93,12 @@ 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()
{ {
_Data = new SDataFromScreen(); _Data = new SDataFromScreen {ScreenMain = new SFromScreenMain()};
_Data.ScreenMain = new SFromScreenMain();
} }
public override void Init() public override void Init()
@@ -87,11 +107,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ThemeTexts = new string[] _ThemeTexts = new string[]
{ {
_TextPosition, _TextPlayerName, _TextNumPlayed, _TextWon, _TextSingPoints, _TextGamePoints, _TextNextPlayer, _TextPopupReallyExit, _TextRoundNumber, _TextRoundPlayer, _TextPosition, _TextPlayerName, _TextNumPlayed, _TextWon, _TextSingPoints, _TextGamePoints, _TextNextPlayer, _TextPopupReallyExit, _TextRoundNumber,
_TextRoundPlayer,
_TextRoundScore, _TextFinishMessage, _TextFinishPlayerWin, _TextNextPlayerMessage _TextRoundScore, _TextFinishMessage, _TextFinishPlayerWin, _TextNextPlayerMessage
}; };
_ThemeButtons = new string[] _ThemeButtons = new string[]
{_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonPlayerScrollDown, _ButtonPlayerScrollUp, _ButtonRoundsScrollDown, _ButtonRoundsScrollUp}; {
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonPlayerScrollDown, _ButtonPlayerScrollUp, _ButtonRoundsScrollDown,
_ButtonRoundsScrollUp
};
_ThemeStatics = new string[] {_StaticPopupBG, _StaticNextPlayer}; _ThemeStatics = new string[] {_StaticPopupBG, _StaticNextPlayer};
} }
@@ -107,20 +131,18 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
for (int i = 0; i < _PartyMode.GetMaxPlayer(); i++) for (int i = 0; i < _PartyMode.GetMaxPlayer(); i++)
{ {
_NextPlayerTexts.Add(GetNewText(Texts[_TextNextPlayer])); _NextPlayerTexts.Add(GetNewText(_Texts[_TextNextPlayer]));
AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]); _AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]);
_NextPlayerStatics.Add(GetNewStatic(Statics[_StaticNextPlayer])); _NextPlayerStatics.Add(GetNewStatic(_Statics[_StaticNextPlayer]));
AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]); _AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]);
} }
} }
public override void DataToScreen(object receivedData) public override void DataToScreen(object receivedData)
{ {
SDataToScreenMain data = new SDataToScreenMain();
try try
{ {
data = (SDataToScreenMain)receivedData; SDataToScreenMain data = (SDataToScreenMain)receivedData;
_GameState = data; _GameState = data;
} }
catch (Exception e) catch (Exception e)
@@ -154,26 +176,26 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
case Keys.Enter: case Keys.Enter:
if (!_ExitPopupVisible) if (!_ExitPopupVisible)
{ {
if (Buttons[_ButtonNextRound].Selected) if (_Buttons[_ButtonNextRound].Selected)
_NextRound(); _NextRound();
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1) if (_Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
_Back(); _Back();
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1) if (_Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
_ShowPopup(true); _ShowPopup(true);
if (Buttons[_ButtonPlayerScrollUp].Selected) if (_Buttons[_ButtonPlayerScrollUp].Selected)
_ScrollPlayerTable(-1); _ScrollPlayerTable(-1);
if (Buttons[_ButtonPlayerScrollDown].Selected) if (_Buttons[_ButtonPlayerScrollDown].Selected)
_ScrollPlayerTable(1); _ScrollPlayerTable(1);
if (Buttons[_ButtonRoundsScrollUp].Selected) if (_Buttons[_ButtonRoundsScrollUp].Selected)
_ScrollRoundsTable(-1); _ScrollRoundsTable(-1);
if (Buttons[_ButtonRoundsScrollDown].Selected) if (_Buttons[_ButtonRoundsScrollDown].Selected)
_ScrollRoundsTable(1); _ScrollRoundsTable(1);
} }
else else
{ {
if (Buttons[_ButtonPopupYes].Selected) if (_Buttons[_ButtonPopupYes].Selected)
_EndParty(); _EndParty();
if (Buttons[_ButtonPopupNo].Selected) if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false); _ShowPopup(false);
} }
break; break;
@@ -186,30 +208,30 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (!_ExitPopupVisible) if (!_ExitPopupVisible)
{ {
if (Buttons[_ButtonNextRound].Selected) if (_Buttons[_ButtonNextRound].Selected)
_NextRound(); _NextRound();
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1) if (_Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
_Back(); _Back();
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1) if (_Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
_ShowPopup(true); _ShowPopup(true);
if (Buttons[_ButtonPlayerScrollUp].Selected) if (_Buttons[_ButtonPlayerScrollUp].Selected)
_ScrollPlayerTable(-1); _ScrollPlayerTable(-1);
if (Buttons[_ButtonPlayerScrollDown].Selected) if (_Buttons[_ButtonPlayerScrollDown].Selected)
_ScrollPlayerTable(1); _ScrollPlayerTable(1);
if (Buttons[_ButtonRoundsScrollUp].Selected) if (_Buttons[_ButtonRoundsScrollUp].Selected)
_ScrollRoundsTable(-1); _ScrollRoundsTable(-1);
if (Buttons[_ButtonRoundsScrollDown].Selected) if (_Buttons[_ButtonRoundsScrollDown].Selected)
_ScrollRoundsTable(1); _ScrollRoundsTable(1);
} }
else else
{ {
if (Buttons[_ButtonPopupYes].Selected) if (_Buttons[_ButtonPopupYes].Selected)
_EndParty(); _EndParty();
if (Buttons[_ButtonPopupNo].Selected) if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false); _ShowPopup(false);
} }
} }
@@ -256,29 +278,29 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
if (_GameState.CurrentRoundNr == 1) if (_GameState.CurrentRoundNr == 1)
{ {
Buttons[_ButtonBack].Visible = true; _Buttons[_ButtonBack].Visible = true;
Buttons[_ButtonExit].Visible = false; _Buttons[_ButtonExit].Visible = false;
} }
else else
{ {
Buttons[_ButtonBack].Visible = false; _Buttons[_ButtonBack].Visible = false;
Buttons[_ButtonExit].Visible = true; _Buttons[_ButtonExit].Visible = true;
} }
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count) if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{ {
Buttons[_ButtonNextRound].Visible = true; _Buttons[_ButtonNextRound].Visible = true;
Texts[_TextFinishMessage].Visible = false; _Texts[_TextFinishMessage].Visible = false;
Texts[_TextFinishPlayerWin].Visible = false; _Texts[_TextFinishPlayerWin].Visible = false;
SetInteractionToButton(Buttons[_ButtonNextRound]); _SetInteractionToButton(_Buttons[_ButtonNextRound]);
} }
else else
{ {
Buttons[_ButtonNextRound].Visible = false; _Buttons[_ButtonNextRound].Visible = false;
Texts[_TextFinishMessage].Visible = true; _Texts[_TextFinishMessage].Visible = true;
Texts[_TextFinishPlayerWin].Visible = true; _Texts[_TextFinishPlayerWin].Visible = true;
Texts[_TextFinishPlayerWin].Text = _GetPlayerWinString(); _Texts[_TextFinishPlayerWin].Text = _GetPlayerWinString();
SetInteractionToButton(Buttons[_ButtonExit]); _SetInteractionToButton(_Buttons[_ButtonExit]);
} }
_ShowPopup(false); _ShowPopup(false);
@@ -311,13 +333,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
_ExitPopupVisible = visible; _ExitPopupVisible = visible;
Statics[_StaticPopupBG].Visible = _ExitPopupVisible; _Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible; _Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible; _Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible; _Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
if (_ExitPopupVisible) if (_ExitPopupVisible)
SetInteractionToButton(Buttons[_ButtonPopupNo]); _SetInteractionToButton(_Buttons[_ButtonPopupNo]);
} }
private void _Back() private void _Back()
@@ -329,9 +351,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateNextPlayerPositions() private void _UpdateNextPlayerPositions()
{ {
float x = CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2; float x = (float)CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2;
float staticY = 590; const float staticY = 590;
float textY = 550; const float textY = 550;
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
//static //static
@@ -339,11 +361,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_NextPlayerStatics[i].Rect.Y = staticY; _NextPlayerStatics[i].Rect.Y = staticY;
_NextPlayerStatics[i].Visible = true; _NextPlayerStatics[i].Visible = true;
//text //text
_NextPlayerTexts[i].X = x + Statics[_StaticNextPlayer].Rect.W / 2; _NextPlayerTexts[i].X = x + _Statics[_StaticNextPlayer].Rect.W / 2;
_NextPlayerTexts[i].Y = textY; _NextPlayerTexts[i].Y = textY;
_NextPlayerTexts[i].Visible = true; _NextPlayerTexts[i].Visible = true;
x += Statics[_StaticNextPlayer].Rect.W + 15; x += _Statics[_StaticNextPlayer].Rect.W + 15;
} }
for (int i = _GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++) for (int i = _GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
{ {
@@ -356,7 +378,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count) if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{ {
Texts[_TextNextPlayerMessage].Visible = true; _Texts[_TextNextPlayerMessage].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles(); SProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
@@ -368,7 +390,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
} }
else else
{ {
Texts[_TextNextPlayerMessage].Visible = false; _Texts[_TextNextPlayerMessage].Visible = false;
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
_NextPlayerStatics[i].Visible = false; _NextPlayerStatics[i].Visible = false;
@@ -383,30 +405,28 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_RoundsTable = new List<CRoundsTableRow>(); _RoundsTable = new List<CRoundsTableRow>();
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
CRoundsTableRow rtr = new CRoundsTableRow(); CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()};
rtr.TextPlayer = new List<CText>();
rtr.TextScores = new List<CText>();
_RoundsTable.Add(rtr); _RoundsTable.Add(rtr);
} }
//Create statics and texts for rounds //Create statics and texts for rounds
for (int round = 0; round < _RoundsTable.Count; round++) foreach (CRoundsTableRow roundRow in _RoundsTable)
{ {
//Round-number //Round-number
CText text = GetNewText(Texts[_TextRoundNumber]); CText text = GetNewText(_Texts[_TextRoundNumber]);
AddText(text); _AddText(text);
_RoundsTable[round].Number = text; roundRow.Number = text;
for (int row = 0; row < 2; row++) for (int row = 0; row < 2; row++)
{ {
for (int column = 0; column < 3; column++) for (int column = 0; column < 3; column++)
{ {
//Player //Player
text = GetNewText(Texts[_TextRoundPlayer]); text = GetNewText(_Texts[_TextRoundPlayer]);
AddText(text); _AddText(text);
_RoundsTable[round].TextPlayer.Add(text); roundRow.TextPlayer.Add(text);
//Score //Score
text = GetNewText(Texts[_TextRoundScore]); text = GetNewText(_Texts[_TextRoundScore]);
AddText(text); _AddText(text);
_RoundsTable[round].TextScores.Add(text); roundRow.TextScores.Add(text);
} }
} }
} }
@@ -416,30 +436,27 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
_RoundsTableScrollArea = new SRectF(); _RoundsTableScrollArea = new SRectF();
int numPlayerInOneRow = 3; const int numPlayerInOneRow = 3;
if (_GameState.NumPlayerAtOnce <= numPlayerInOneRow) _NumRoundsVisible = _GameState.NumPlayerAtOnce <= numPlayerInOneRow ? 5 : 3;
_NumRoundsVisible = 5;
else
_NumRoundsVisible = 3;
if (_NumRoundsVisible > _GameState.Combs.Count) if (_NumRoundsVisible > _GameState.Combs.Count)
_NumRoundsVisible = _GameState.Combs.Count; _NumRoundsVisible = _GameState.Combs.Count;
float numberX = Texts[_TextRoundNumber].X; float numberX = _Texts[_TextRoundNumber].X;
float numberY = Texts[_TextRoundNumber].Y; float numberY = _Texts[_TextRoundNumber].Y;
_RoundsTableScrollArea.X = numberX; _RoundsTableScrollArea.X = numberX;
_RoundsTableScrollArea.Y = numberY; _RoundsTableScrollArea.Y = numberY;
_RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20; _RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20;
float delta = Texts[_TextRoundNumber].Height; float delta = _Texts[_TextRoundNumber].Height;
//Update statics and texts for rounds //Update statics and texts for rounds
for (int round = 0; round < _RoundsTable.Count; round++) foreach (CRoundsTableRow roundRow in _RoundsTable)
{ {
//Round-number //Round-number
_RoundsTable[round].Number.X = numberX; roundRow.Number.X = numberX;
_RoundsTable[round].Number.Y = numberY; roundRow.Number.Y = numberY;
int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow)); int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow));
for (int row = 0; row < numInnerRows; row++) for (int row = 0; row < numInnerRows; row++)
{ {
@@ -453,17 +470,17 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
for (int column = row * numPlayerInOneRow; column < num; column++) for (int column = row * numPlayerInOneRow; column < num; column++)
{ {
//Player //Player
float x = numberX + 15 + (CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) + float x = numberX + 15 + (CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) +
((CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2; ((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2;
float maxw = ((CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5; float maxw = ((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5;
_RoundsTable[round].TextPlayer[column].X = x; roundRow.TextPlayer[column].X = x;
_RoundsTable[round].TextPlayer[column].Y = numberY; roundRow.TextPlayer[column].Y = numberY;
_RoundsTable[round].TextPlayer[column].MaxWidth = maxw; roundRow.TextPlayer[column].MaxWidth = maxw;
//Score //Score
_RoundsTable[round].TextScores[column] = _RoundsTable[round].TextScores[column]; roundRow.TextScores[column] = roundRow.TextScores[column];
_RoundsTable[round].TextScores[column].X = x; roundRow.TextScores[column].X = x;
_RoundsTable[round].TextScores[column].Y = numberY + delta; roundRow.TextScores[column].Y = numberY + delta;
_RoundsTable[round].TextScores[column].MaxWidth = maxw; roundRow.TextScores[column].MaxWidth = maxw;
} }
numberY = numberY + delta + delta; numberY = numberY + delta + delta;
} }
@@ -484,7 +501,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_RoundsTable[i].Number.Visible = true; _RoundsTable[i].Number.Visible = true;
_RoundsTable[i].TextPlayer[p].Visible = true; _RoundsTable[i].TextPlayer[p].Visible = true;
_RoundsTable[i].TextScores[p].Visible = true; _RoundsTable[i].TextScores[p].Visible = true;
_RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset).ToString() + ")"; _RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")";
int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]; int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]];
_RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName; _RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset) if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset)
@@ -509,32 +526,30 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
} }
} }
Buttons[_ButtonRoundsScrollUp].Visible = _RoundsTableOffset > 0; _Buttons[_ButtonRoundsScrollUp].Visible = _RoundsTableOffset > 0;
Buttons[_ButtonRoundsScrollDown].Visible = _GameState.Combs.Count - _NumRoundsVisible - _RoundsTableOffset > 0; _Buttons[_ButtonRoundsScrollDown].Visible = _GameState.Combs.Count - _NumRoundsVisible - _RoundsTableOffset > 0;
} }
private void _BuildPlayerTable() private void _BuildPlayerTable()
{ {
_PlayerTableScrollArea = new SRectF(); _PlayerTableScrollArea = new SRectF {X = _Texts[_TextPosition].X, Y = _Texts[_TextPosition].Y, W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X};
_PlayerTableScrollArea.X = Texts[_TextPosition].X;
_PlayerTableScrollArea.Y = Texts[_TextPosition].Y;
_PlayerTableScrollArea.W = Texts[_TextGamePoints].X - Texts[_TextPosition].X;
_PlayerTable = new List<STableRow>(); _PlayerTable = new List<STableRow>();
float delta = Texts[_TextPosition].Height * 1.2f; float delta = _Texts[_TextPosition].Height * 1.2f;
float h = 0; float h = 0;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
STableRow row = new STableRow(); STableRow row = new STableRow
{
row.Pos = GetNewText(Texts[_TextPosition]); Pos = GetNewText(_Texts[_TextPosition]),
row.Name = GetNewText(Texts[_TextPlayerName]); Name = GetNewText(_Texts[_TextPlayerName]),
row.Rounds = GetNewText(Texts[_TextNumPlayed]); Rounds = GetNewText(_Texts[_TextNumPlayed]),
row.Won = GetNewText(Texts[_TextWon]); Won = GetNewText(_Texts[_TextWon]),
row.SingPoints = GetNewText(Texts[_TextSingPoints]); SingPoints = GetNewText(_Texts[_TextSingPoints]),
row.GamePoints = GetNewText(Texts[_TextGamePoints]); GamePoints = GetNewText(_Texts[_TextGamePoints])
};
row.Pos.Y += delta * (i + 1); row.Pos.Y += delta * (i + 1);
row.Name.Y += delta * (i + 1); row.Name.Y += delta * (i + 1);
@@ -543,7 +558,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
row.SingPoints.Y += delta * (i + 1); row.SingPoints.Y += delta * (i + 1);
row.GamePoints.Y += delta * (i + 1); row.GamePoints.Y += delta * (i + 1);
row.Pos.Text = (i + 1).ToString() + "."; row.Pos.Text = (i + 1) + ".";
row.Pos.Visible = false; row.Pos.Visible = false;
row.Name.Visible = false; row.Name.Visible = false;
@@ -552,12 +567,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
row.SingPoints.Visible = false; row.SingPoints.Visible = false;
row.GamePoints.Visible = false; row.GamePoints.Visible = false;
AddText(row.Pos); _AddText(row.Pos);
AddText(row.Name); _AddText(row.Name);
AddText(row.Rounds); _AddText(row.Rounds);
AddText(row.Won); _AddText(row.Won);
AddText(row.SingPoints); _AddText(row.SingPoints);
AddText(row.GamePoints); _AddText(row.GamePoints);
_PlayerTable.Add(row); _PlayerTable.Add(row);
@@ -583,9 +598,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
row.SingPoints.Visible = true; row.SingPoints.Visible = true;
row.GamePoints.Visible = true; row.GamePoints.Visible = true;
row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position.ToString() + "."; 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();
@@ -601,8 +616,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
} }
} }
Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0; _Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0;
Buttons[_ButtonPlayerScrollDown].Visible = _GameState.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0; _Buttons[_ButtonPlayerScrollDown].Visible = _GameState.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0;
} }
private void _ScrollPlayerTable(int offset) private void _ScrollPlayerTable(int offset)
@@ -1,3 +1,22 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
@@ -5,7 +24,9 @@ using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.ChallengeMedley namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMedleyNames : CMenuParty public class CPartyScreenChallengeMedleyNames : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -22,7 +43,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private List<CButton> _PlayerDestinationButtons; private List<CButton> _PlayerDestinationButtons;
//PlayerDestinationButtons-Option //PlayerDestinationButtons-Option
private const int _PlayerDestinationButtonsNumH = 3; private const int _PlayerDestinationButtonsNumH = 3;
private const int _PlayerDestinationButtonsNumW = 4;
private const int _PlayerDestinationButtonsFirstX = 900; private const int _PlayerDestinationButtonsFirstX = 900;
private const int _PlayerDestinationButtonsFirstY = 105; private const int _PlayerDestinationButtonsFirstY = 105;
private const int _PlayerDestinationButtonsSpaceH = 15; private const int _PlayerDestinationButtonsSpaceH = 15;
@@ -35,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;
@@ -65,27 +85,19 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_Data.ScreenNames.ProfileIDs = new List<int>(); _Data.ScreenNames.ProfileIDs = new List<int>();
List<string> buttons = new List<string>();
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames(); SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, ProfileIDs = new List<int>()};
names.FadeToConfig = false;
names.FadeToMain = false;
names.ProfileIDs = new List<int>();
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
public override void DataToScreen(object receivedData) public override void DataToScreen(object receivedData)
{ {
SDataToScreenNames config = new SDataToScreenNames();
try try
{ {
config = (SDataToScreenNames)receivedData; SDataToScreenNames config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDs = config.ProfileIDs; _Data.ScreenNames.ProfileIDs = config.ProfileIDs ?? new List<int>();
if (_Data.ScreenNames.ProfileIDs == null)
_Data.ScreenNames.ProfileIDs = new List<int>();
_NumPlayer = config.NumPlayer; _NumPlayer = config.NumPlayer;
@@ -113,10 +125,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
break; break;
case Keys.Enter: case Keys.Enter:
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
if (!_OnAdd()) if (!_OnAdd())
@@ -218,12 +230,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
} }
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
if (!_OnAdd()) if (!_OnAdd())
@@ -268,13 +280,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _AddButtonPlayerDestination() private void _AddButtonPlayerDestination()
{ {
Buttons[_ButtonPlayerDestination].Visible = false; _Buttons[_ButtonPlayerDestination].Visible = false;
_PlayerDestinationButtons = new List<CButton>(); _PlayerDestinationButtons = new List<CButton>();
int row = 0; int row = 0;
int column = 0; int column = 0;
for (int i = 1; i <= _PartyMode.GetMaxPlayer(); i++) for (int i = 1; i <= _PartyMode.GetMaxPlayer(); i++)
{ {
CButton b = GetNewButton(Buttons[_ButtonPlayerDestination]); CButton b = GetNewButton(_Buttons[_ButtonPlayerDestination]);
b.Rect.X = _PlayerDestinationButtonsFirstX + column * (b.Rect.W + _PlayerDestinationButtonsSpaceH); b.Rect.X = _PlayerDestinationButtonsFirstX + column * (b.Rect.W + _PlayerDestinationButtonsSpaceH);
b.Rect.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW); b.Rect.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW);
_PlayerDestinationButtons.Add(b); _PlayerDestinationButtons.Add(b);
@@ -286,24 +298,22 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
} }
b.Visible = true; b.Visible = true;
b.Enabled = false; b.Enabled = false;
AddButton(b); _AddButton(b);
} }
} }
private void _AddButtonPlayerChoose() private void _AddButtonPlayerChoose()
{ {
Buttons[_ButtonPlayerChoose].Visible = false; _Buttons[_ButtonPlayerChoose].Visible = false;
_PlayerChooseButtons = new List<CPlayerChooseButton>(); _PlayerChooseButtons = new List<CPlayerChooseButton>();
int row = 0; int row = 0;
int column = 0; int column = 0;
for (int i = 1; i <= _PlayerChooseButtonsNumH * _PlayerChooseButtonsNumW; i++) for (int i = 1; i <= _PlayerChooseButtonsNumH * _PlayerChooseButtonsNumW; i++)
{ {
CButton b = GetNewButton(Buttons[_ButtonPlayerChoose]); CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]);
b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH); b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH);
b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW); b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW);
CPlayerChooseButton pcb = new CPlayerChooseButton(); CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1};
pcb.Button = b;
pcb.ProfileID = -1;
_PlayerChooseButtons.Add(pcb); _PlayerChooseButtons.Add(pcb);
column++; column++;
if (column >= _PlayerChooseButtonsNumH) if (column >= _PlayerChooseButtonsNumH)
@@ -313,7 +323,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
} }
b.Visible = true; b.Visible = true;
b.Enabled = false; b.Enabled = false;
AddButton(b); _AddButton(b);
} }
} }
@@ -329,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;
@@ -341,8 +351,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
_PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]; _PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose];
_PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName; _PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName;
_PlayerChooseButtons[i].Button.Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; _PlayerChooseButtons[i].Button.Texture =
_PlayerChooseButtons[i].Button.SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.SelTexture =
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f); _PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
_PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1); _PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1);
_PlayerChooseButtons[i].Button.Enabled = true; _PlayerChooseButtons[i].Button.Enabled = true;
@@ -351,10 +363,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
_PlayerChooseButtons[i].ProfileID = -1; _PlayerChooseButtons[i].ProfileID = -1;
_PlayerChooseButtons[i].Button.Text.Text = String.Empty; _PlayerChooseButtons[i].Button.Text.Text = String.Empty;
_PlayerChooseButtons[i].Button.Texture = Buttons[_ButtonPlayerChoose].Texture; _PlayerChooseButtons[i].Button.Texture = _Buttons[_ButtonPlayerChoose].Texture;
_PlayerChooseButtons[i].Button.SelTexture = Buttons[_ButtonPlayerChoose].SelTexture; _PlayerChooseButtons[i].Button.SelTexture = _Buttons[_ButtonPlayerChoose].SelTexture;
_PlayerChooseButtons[i].Button.Color = Buttons[_ButtonPlayerChoose].Color; _PlayerChooseButtons[i].Button.Color = _Buttons[_ButtonPlayerChoose].Color;
_PlayerChooseButtons[i].Button.SelColor = Buttons[_ButtonPlayerChoose].SelColor; _PlayerChooseButtons[i].Button.SelColor = _Buttons[_ButtonPlayerChoose].SelColor;
_PlayerChooseButtons[i].Button.Enabled = false; _PlayerChooseButtons[i].Button.Enabled = false;
} }
} }
@@ -418,10 +430,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
} }
else else
{ {
_PlayerDestinationButtons[i].Color = Buttons[_ButtonPlayerDestination].Color; _PlayerDestinationButtons[i].Color = _Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i].SelColor = Buttons[_ButtonPlayerDestination].SelColor; _PlayerDestinationButtons[i].SelColor = _Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i].Texture = Buttons[_ButtonPlayerDestination].Texture; _PlayerDestinationButtons[i].Texture = _Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i].SelTexture = Buttons[_ButtonPlayerDestination].SelTexture; _PlayerDestinationButtons[i].SelTexture = _Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i].Text.Text = String.Empty; _PlayerDestinationButtons[i].Text.Text = String.Empty;
_PlayerDestinationButtons[i].Enabled = false; _PlayerDestinationButtons[i].Enabled = false;
} }
@@ -432,34 +444,34 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
if (_Data.ScreenNames.ProfileIDs.Count == _NumPlayer) if (_Data.ScreenNames.ProfileIDs.Count == _NumPlayer)
{ {
Buttons[_ButtonNext].Visible = true; _Buttons[_ButtonNext].Visible = true;
SetInteractionToButton(Buttons[_ButtonNext]); _SetInteractionToButton(_Buttons[_ButtonNext]);
} }
else else
Buttons[_ButtonNext].Visible = false; _Buttons[_ButtonNext].Visible = false;
} }
private bool _OnAdd() private bool _OnAdd()
{ {
for (int i = 0; i < _PlayerChooseButtons.Count; i++) foreach (CPlayerChooseButton chooseButton in _PlayerChooseButtons)
{ {
if (_PlayerChooseButtons[i].Button.Selected && _PlayerChooseButtons[i].ProfileID != -1) if (chooseButton.Button.Selected && chooseButton.ProfileID != -1)
{ {
if (_Data.ScreenNames.ProfileIDs.Count < _NumPlayer) if (_Data.ScreenNames.ProfileIDs.Count < _NumPlayer)
{ {
_Data.ScreenNames.ProfileIDs.Add(_PlayerChooseButtons[i].ProfileID); _Data.ScreenNames.ProfileIDs.Add(chooseButton.ProfileID);
int added = _Data.ScreenNames.ProfileIDs.Count - 1; int added = _Data.ScreenNames.ProfileIDs.Count - 1;
_UpdateButtonNext(); _UpdateButtonNext();
//Update texture and name //Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName; _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true; _PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List //Update Tiles-List
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
CheckInteraction(); _CheckInteraction();
return true; return true;
} }
} }
@@ -479,7 +491,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_UpdateButtonNext(); _UpdateButtonNext();
_UpdateButtonPlayerDestination(); _UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
CheckInteraction(); _CheckInteraction();
return true; return true;
} }
} }
@@ -490,14 +502,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);
} }
} }
@@ -1,3 +1,22 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -33,7 +52,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public int PointsTeam1; public int PointsTeam1;
public int PointsTeam2; public int PointsTeam2;
public int Winner; public int Winner;
public bool Finished = false; public bool Finished;
} }
#region Communication #region Communication
@@ -62,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;
@@ -96,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;
} }
@@ -184,24 +200,26 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ToScreenNames = new SDataToScreenNames(); _ToScreenNames = new SDataToScreenNames();
_ToScreenMain = new SDataToScreenMain(); _ToScreenMain = new SDataToScreenMain();
_GameData = new SData(); _GameData = new SData
_GameData.NumFields = 9; {
_GameData.NumPlayerTeam1 = 2; NumFields = 9,
_GameData.NumPlayerTeam2 = 2; NumPlayerTeam1 = 2,
_GameData.ProfileIDsTeam1 = new List<int>(); NumPlayerTeam2 = 2,
_GameData.ProfileIDsTeam2 = new List<int>(); ProfileIDsTeam1 = new List<int>(),
_GameData.PlayerTeam1 = new List<int>(); ProfileIDsTeam2 = new List<int>(),
_GameData.PlayerTeam2 = new List<int>(); PlayerTeam1 = new List<int>(),
_GameData.CurrentRoundNr = 0; PlayerTeam2 = new List<int>(),
_GameData.SingRoundNr = 0; CurrentRoundNr = 0,
_GameData.SongSource = ESongSource.TR_ALLSONGS; SingRoundNr = 0,
_GameData.PlaylistID = 0; SongSource = ESongSource.TR_ALLSONGS,
_GameData.CategoryID = 0; PlaylistID = 0,
_GameData.GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL; CategoryID = 0,
_GameData.Rounds = new List<CRound>(); GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL,
_GameData.Songs = new List<int>(); Rounds = new List<CRound>(),
_GameData.NumJokerRandom = new int[2]; Songs = new List<int>(),
_GameData.NumJokerRetry = new int[2]; NumJokerRandom = new int[2],
NumJokerRetry = new int[2]
};
} }
public override bool Init() public override bool Init()
@@ -262,10 +280,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Stage = EStage.NotStarted; _Stage = EStage.NotStarted;
else else
{ {
if (CBase.Game.GetRandom(100) < 50) _GameData.Team = CBase.Game.GetRandom(100) < 50 ? 0 : 1;
_GameData.Team = 0;
else
_GameData.Team = 1;
_GameData.ProfileIDsTeam1 = dataFrom.ScreenNames.ProfileIDsTeam1; _GameData.ProfileIDsTeam1 = dataFrom.ScreenNames.ProfileIDsTeam1;
_GameData.ProfileIDsTeam2 = dataFrom.ScreenNames.ProfileIDsTeam2; _GameData.ProfileIDsTeam2 = dataFrom.ScreenNames.ProfileIDsTeam2;
_Stage = EStage.Names; _Stage = EStage.Names;
@@ -358,15 +373,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen); _Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen);
if (screen != null) if (screen != null)
{ {
if (_GameData.Team == 1) _GameData.Team = _GameData.Team == 1 ? 0 : 1;
_GameData.Team = 0;
else
_GameData.Team = 1;
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;
@@ -391,15 +401,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen); _Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen);
if (screen != null) if (screen != null)
{ {
if (_GameData.Team == 1) _GameData.Team = _GameData.Team == 1 ? 0 : 1;
_GameData.Team = 0;
else
_GameData.Team = 1;
_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;
@@ -437,12 +442,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
return _ScreenSongOptions; return _ScreenSongOptions;
} }
// ReSharper disable RedundantAssignment
public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions) public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{ {
screenSongOptions = _ScreenSongOptions; screenSongOptions = _ScreenSongOptions;
} }
// ReSharper disable RedundantAssignment
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions) public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{ {
screenSongOptions = _ScreenSongOptions; screenSongOptions = _ScreenSongOptions;
} }
@@ -522,100 +531,102 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _PreparePlayerList(int team) private void _PreparePlayerList(int team)
{ {
if (team == 0) switch (team)
{
case 0:
{ {
_GameData.PlayerTeam1 = new List<int>(); _GameData.PlayerTeam1 = new List<int>();
_GameData.PlayerTeam2 = new List<int>(); _GameData.PlayerTeam2 = new List<int>();
//Prepare Player-IDs //Prepare Player-IDs
List<int> iDs1 = new List<int>(); List<int> ids1 = new List<int>();
List<int> iDs2 = new List<int>(); List<int> ids2 = new List<int>();
int num = 0;
int random = 0;
//Add IDs to team-list //Add IDs to team-list
while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && iDs1.Count == 0 && while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && ids1.Count == 0 &&
_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && iDs2.Count == 0) _GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && ids2.Count == 0)
{ {
if (iDs1.Count == 0) if (ids1.Count == 0)
{ {
for (int i = 0; i < _GameData.NumPlayerTeam1; i++) for (int i = 0; i < _GameData.NumPlayerTeam1; i++)
iDs1.Add(i); ids1.Add(i);
} }
if (iDs2.Count == 0) if (ids2.Count == 0)
{ {
for (int i = 0; i < _GameData.NumPlayerTeam2; i++) for (int i = 0; i < _GameData.NumPlayerTeam2; i++)
iDs2.Add(i); ids2.Add(i);
} }
int num;
int random;
if (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0]) if (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0])
{ {
random = CBase.Game.GetRandom((iDs1.Count - 1) * 10); random = CBase.Game.GetRandom((ids1.Count - 1) * 10);
num = (int)Math.Round((double)random / 10); num = (int)Math.Round((double)random / 10);
if (num >= iDs1.Count) if (num >= ids1.Count)
num = iDs1.Count - 1; num = ids1.Count - 1;
_GameData.PlayerTeam1.Add(iDs1[num]); _GameData.PlayerTeam1.Add(ids1[num]);
iDs1.RemoveAt(num); ids1.RemoveAt(num);
} }
if (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1]) if (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1])
{ {
random = CBase.Game.GetRandom((iDs2.Count - 1) * 20); random = CBase.Game.GetRandom((ids2.Count - 1) * 20);
num = (int)Math.Round((double)random / 20); num = (int)Math.Round((double)random / 20);
if (num >= iDs2.Count) if (num >= ids2.Count)
num = iDs2.Count - 1; num = ids2.Count - 1;
_GameData.PlayerTeam2.Add(iDs2[num]); _GameData.PlayerTeam2.Add(ids2[num]);
iDs2.RemoveAt(num); ids2.RemoveAt(num);
} }
} }
} }
else if (team == 1) break;
case 1:
{ {
//Prepare Player-IDs //Prepare Player-IDs
List<int> iDs = new List<int>(); List<int> ids = new List<int>();
int num = 0;
int random = 0;
//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])
{ {
random = CBase.Game.GetRandom((iDs.Count - 1) * 10); int random = CBase.Game.GetRandom((ids.Count - 1) * 10);
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);
} }
} }
} }
else if (team == 2) break;
case 2:
{ {
//Prepare Player-IDs //Prepare Player-IDs
List<int> iDs = new List<int>(); List<int> ids = new List<int>();
int num = 0;
int random = 0;
//Add IDs to team-list //Add IDs to team-list
while (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && iDs.Count == 0) while (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && ids.Count == 0)
{ {
if (iDs.Count == 0) if (ids.Count == 0)
{ {
for (int i = 0; i < _GameData.NumPlayerTeam2; i++) for (int i = 0; i < _GameData.NumPlayerTeam2; i++)
iDs.Add(i); ids.Add(i);
} }
if (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1]) if (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1])
{ {
random = CBase.Game.GetRandom((iDs.Count - 1) * 20); int random = CBase.Game.GetRandom((ids.Count - 1) * 20);
num = (int)Math.Round((double)random / 20); int num = (int)Math.Round((double)random / 20);
if (num >= iDs.Count) if (num >= ids.Count)
num = iDs.Count - 1; num = ids.Count - 1;
_GameData.PlayerTeam2.Add(iDs[num]); _GameData.PlayerTeam2.Add(ids[num]);
iDs.RemoveAt(num); ids.RemoveAt(num);
} }
} }
} }
break;
}
} }
private void _PrepareSongList() private void _PrepareSongList()
@@ -707,7 +718,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
CBase.Game.SetNumPlayer(2); CBase.Game.SetNumPlayer(2);
SPlayer[] player = CBase.Game.GetPlayer(); SPlayer[] player = CBase.Game.GetPlayers();
if (player == null) if (player == null)
return; return;
@@ -721,8 +732,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
//default values //default values
player[i].Name = "foobar";
player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
player[i].ProfileID = -1; player[i].ProfileID = -1;
} }
@@ -731,24 +740,18 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
if (_GameData.ProfileIDsTeam1[r.SingerTeam1] < profiles.Length) if (_GameData.ProfileIDsTeam1[r.SingerTeam1] < profiles.Length)
{ {
player[0].Name = profiles[_GameData.ProfileIDsTeam1[r.SingerTeam1]].PlayerName;
player[0].Difficulty = profiles[_GameData.ProfileIDsTeam1[r.SingerTeam1]].Difficulty;
player[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1]; player[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1];
if (isDuet) if (isDuet)
player[0].LineNr = 0; player[0].LineNr = 0;
} }
if (_GameData.ProfileIDsTeam2[r.SingerTeam2] < profiles.Length) if (_GameData.ProfileIDsTeam2[r.SingerTeam2] < profiles.Length)
{ {
player[1].Name = profiles[_GameData.ProfileIDsTeam2[r.SingerTeam2]].PlayerName;
player[1].Difficulty = profiles[_GameData.ProfileIDsTeam2[r.SingerTeam2]].Difficulty;
player[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2]; player[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2];
if (isDuet) if (isDuet)
player[1].LineNr = 1; player[1].LineNr = 1;
} }
SongSelected(r.SongID); SongSelected(r.SongID);
} }
else
return;
} }
private void _SetNumJokers() private void _SetNumJokers()
@@ -783,7 +786,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (!_GameData.Rounds[_GameData.SingRoundNr].Finished) if (!_GameData.Rounds[_GameData.SingRoundNr].Finished)
_GameData.CurrentRoundNr++; _GameData.CurrentRoundNr++;
SPlayer[] results = CBase.Game.GetPlayer(); SPlayer[] results = CBase.Game.GetPlayers();
if (results == null) if (results == null)
return; return;
@@ -1,10 +1,33 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.TicTacToe namespace VocaluxeLib.PartyModes.TicTacToe
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenTicTacToeConfig : CMenuParty public class CPartyScreenTicTacToeConfig : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -31,28 +54,31 @@ namespace VocaluxeLib.PartyModes.TicTacToe
base.Init(); base.Init();
_ThemeSelectSlides = new string[] _ThemeSelectSlides = new string[]
{_SelectSlideNumPlayerTeam1, _SelectSlideNumPlayerTeam2, _SelectSlideNumFields, _SelectSlideSongSource, _SelectSlidePlaylist, _SelectSlideCategory, _SelectSlideGameMode}; {
_SelectSlideNumPlayerTeam1, _SelectSlideNumPlayerTeam2, _SelectSlideNumFields, _SelectSlideSongSource, _SelectSlidePlaylist, _SelectSlideCategory,
_SelectSlideGameMode
};
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack}; _ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenConfig config = new SFromScreenConfig(); SFromScreenConfig config = new SFromScreenConfig
config.PlaylistID = 0; {
config.NumFields = 9; PlaylistID = 0,
config.NumPlayerTeam1 = 2; NumFields = 9,
config.NumPlayerTeam2 = 2; NumPlayerTeam1 = 2,
config.GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL; NumPlayerTeam2 = 2,
config.CategoryID = 0; GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL,
config.SongSource = ESongSource.TR_ALLSONGS; CategoryID = 0,
SongSource = ESongSource.TR_ALLSONGS
};
_Data.ScreenConfig = config; _Data.ScreenConfig = config;
} }
public override void DataToScreen(object receivedData) public override void DataToScreen(object receivedData)
{ {
SDataToScreenConfig config = new SDataToScreenConfig();
try try
{ {
config = (SDataToScreenConfig)receivedData; SDataToScreenConfig config = (SDataToScreenConfig)receivedData;
_Data.ScreenConfig.NumFields = config.NumFields; _Data.ScreenConfig.NumFields = config.NumFields;
_Data.ScreenConfig.NumPlayerTeam1 = config.NumPlayerTeam1; _Data.ScreenConfig.NumPlayerTeam1 = config.NumPlayerTeam1;
_Data.ScreenConfig.NumPlayerTeam2 = config.NumPlayerTeam2; _Data.ScreenConfig.NumPlayerTeam2 = config.NumPlayerTeam2;
@@ -84,10 +110,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case Keys.Enter: case Keys.Enter:
_UpdateSlides(); _UpdateSlides();
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
break; break;
@@ -107,13 +133,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
_UpdateSlides(); _UpdateSlides();
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
} }
@@ -136,7 +162,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public override bool UpdateGame() public override bool UpdateGame()
{ {
Buttons[_ButtonNext].Visible = _ConfigOk; _Buttons[_ButtonNext].Visible = _ConfigOk;
return true; return true;
} }
@@ -149,72 +175,72 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _FillSlides() private void _FillSlides()
{ {
// build num player slide (min player ... max player); // build num player slide (min player ... max player);
SelectSlides[_SelectSlideNumPlayerTeam1].Clear(); _SelectSlides[_SelectSlideNumPlayerTeam1].Clear();
for (int i = _PartyMode.GetMinPlayer() / 2; i <= _PartyMode.GetMaxPlayer() / 2; i++) for (int i = _PartyMode.GetMinPlayer() / 2; i <= _PartyMode.GetMaxPlayer() / 2; i++)
SelectSlides[_SelectSlideNumPlayerTeam1].AddValue(i.ToString()); _SelectSlides[_SelectSlideNumPlayerTeam1].AddValue(i.ToString());
SelectSlides[_SelectSlideNumPlayerTeam1].Selection = _Data.ScreenConfig.NumPlayerTeam1 - (_PartyMode.GetMinPlayer() / 2); _SelectSlides[_SelectSlideNumPlayerTeam1].Selection = _Data.ScreenConfig.NumPlayerTeam1 - (_PartyMode.GetMinPlayer() / 2);
SelectSlides[_SelectSlideNumPlayerTeam2].Clear(); _SelectSlides[_SelectSlideNumPlayerTeam2].Clear();
for (int i = _PartyMode.GetMinPlayer() / 2; i <= _PartyMode.GetMaxPlayer() / 2; i++) for (int i = _PartyMode.GetMinPlayer() / 2; i <= _PartyMode.GetMaxPlayer() / 2; i++)
SelectSlides[_SelectSlideNumPlayerTeam2].AddValue(i.ToString()); _SelectSlides[_SelectSlideNumPlayerTeam2].AddValue(i.ToString());
SelectSlides[_SelectSlideNumPlayerTeam2].Selection = _Data.ScreenConfig.NumPlayerTeam2 - (_PartyMode.GetMinPlayer() / 2); _SelectSlides[_SelectSlideNumPlayerTeam2].Selection = _Data.ScreenConfig.NumPlayerTeam2 - (_PartyMode.GetMinPlayer() / 2);
SelectSlides[_SelectSlideNumFields].Clear(); _SelectSlides[_SelectSlideNumFields].Clear();
SelectSlides[_SelectSlideNumFields].AddValue("9"); _SelectSlides[_SelectSlideNumFields].AddValue("9");
SelectSlides[_SelectSlideNumFields].AddValue("16"); _SelectSlides[_SelectSlideNumFields].AddValue("16");
SelectSlides[_SelectSlideNumFields].AddValue("25"); _SelectSlides[_SelectSlideNumFields].AddValue("25");
if (_Data.ScreenConfig.NumFields == 9) if (_Data.ScreenConfig.NumFields == 9)
SelectSlides[_SelectSlideNumFields].Selection = 0; _SelectSlides[_SelectSlideNumFields].Selection = 0;
else if (_Data.ScreenConfig.NumFields == 16) else if (_Data.ScreenConfig.NumFields == 16)
SelectSlides[_SelectSlideNumFields].Selection = 1; _SelectSlides[_SelectSlideNumFields].Selection = 1;
else if (_Data.ScreenConfig.NumFields == 25) else if (_Data.ScreenConfig.NumFields == 25)
SelectSlides[_SelectSlideNumFields].Selection = 2; _SelectSlides[_SelectSlideNumFields].Selection = 2;
SelectSlides[_SelectSlideSongSource].Clear(); _SelectSlides[_SelectSlideSongSource].Clear();
SelectSlides[_SelectSlideSongSource].SetValues<ESongSource>((int)_Data.ScreenConfig.SongSource); _SelectSlides[_SelectSlideSongSource].SetValues<ESongSource>((int)_Data.ScreenConfig.SongSource);
string[] playlists = CBase.Playlist.GetPlaylistNames(); List<string> playlists = CBase.Playlist.GetPlaylistNames();
SelectSlides[_SelectSlidePlaylist].Clear(); _SelectSlides[_SelectSlidePlaylist].Clear();
for (int i = 0; i < playlists.Length; i++) for (int i = 0; i < playlists.Count; i++)
{ {
string value = playlists[i] + " (" + CBase.Playlist.GetPlaylistSongCount(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")"; string value = playlists[i] + " (" + CBase.Playlist.GetPlaylistSongCount(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")";
SelectSlides[_SelectSlidePlaylist].AddValue(value); _SelectSlides[_SelectSlidePlaylist].AddValue(value);
} }
SelectSlides[_SelectSlidePlaylist].Selection = _Data.ScreenConfig.PlaylistID; _SelectSlides[_SelectSlidePlaylist].Selection = _Data.ScreenConfig.PlaylistID;
SelectSlides[_SelectSlidePlaylist].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST; _SelectSlides[_SelectSlidePlaylist].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST;
string[] categories = new string[CBase.Songs.GetNumCategories()]; string[] categories = new string[CBase.Songs.GetNumCategories()];
for (int i = 0; i < CBase.Songs.GetNumCategories(); i++) for (int i = 0; i < CBase.Songs.GetNumCategories(); i++)
categories[i] = CBase.Songs.GetCategory(i).Name; categories[i] = CBase.Songs.GetCategory(i).Name;
SelectSlides[_SelectSlideCategory].Clear(); _SelectSlides[_SelectSlideCategory].Clear();
for (int i = 0; i < categories.Length; i++) for (int i = 0; i < categories.Length; i++)
{ {
string value = categories[i] + " (" + CBase.Songs.NumSongsInCategory(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")"; string value = categories[i] + " (" + CBase.Songs.NumSongsInCategory(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")";
SelectSlides[_SelectSlideCategory].AddValue(value); _SelectSlides[_SelectSlideCategory].AddValue(value);
} }
SelectSlides[_SelectSlideCategory].Selection = _Data.ScreenConfig.CategoryID; _SelectSlides[_SelectSlideCategory].Selection = _Data.ScreenConfig.CategoryID;
SelectSlides[_SelectSlideCategory].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY; _SelectSlides[_SelectSlideCategory].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY;
SelectSlides[_SelectSlideGameMode].Visible = true; _SelectSlides[_SelectSlideGameMode].Visible = true;
SelectSlides[_SelectSlideGameMode].SetValues<EPartyGameMode>((int)_Data.ScreenConfig.GameMode); _SelectSlides[_SelectSlideGameMode].SetValues<EPartyGameMode>((int)_Data.ScreenConfig.GameMode);
} }
private void _UpdateSlides() private void _UpdateSlides()
{ {
_Data.ScreenConfig.NumPlayerTeam1 = SelectSlides[_SelectSlideNumPlayerTeam1].Selection + (_PartyMode.GetMinPlayer() / 2); _Data.ScreenConfig.NumPlayerTeam1 = _SelectSlides[_SelectSlideNumPlayerTeam1].Selection + (_PartyMode.GetMinPlayer() / 2);
_Data.ScreenConfig.NumPlayerTeam2 = SelectSlides[_SelectSlideNumPlayerTeam2].Selection + (_PartyMode.GetMinPlayer() / 2); _Data.ScreenConfig.NumPlayerTeam2 = _SelectSlides[_SelectSlideNumPlayerTeam2].Selection + (_PartyMode.GetMinPlayer() / 2);
if (SelectSlides[_SelectSlideNumFields].Selection == 0) if (_SelectSlides[_SelectSlideNumFields].Selection == 0)
_Data.ScreenConfig.NumFields = 9; _Data.ScreenConfig.NumFields = 9;
else if (SelectSlides[_SelectSlideNumFields].Selection == 1) else if (_SelectSlides[_SelectSlideNumFields].Selection == 1)
_Data.ScreenConfig.NumFields = 16; _Data.ScreenConfig.NumFields = 16;
else if (SelectSlides[_SelectSlideNumFields].Selection == 2) else if (_SelectSlides[_SelectSlideNumFields].Selection == 2)
_Data.ScreenConfig.NumFields = 25; _Data.ScreenConfig.NumFields = 25;
_Data.ScreenConfig.SongSource = (ESongSource)SelectSlides[_SelectSlideSongSource].Selection; _Data.ScreenConfig.SongSource = (ESongSource)_SelectSlides[_SelectSlideSongSource].Selection;
_Data.ScreenConfig.PlaylistID = SelectSlides[_SelectSlidePlaylist].Selection; _Data.ScreenConfig.PlaylistID = _SelectSlides[_SelectSlidePlaylist].Selection;
_Data.ScreenConfig.CategoryID = SelectSlides[_SelectSlideCategory].Selection; _Data.ScreenConfig.CategoryID = _SelectSlides[_SelectSlideCategory].Selection;
_Data.ScreenConfig.GameMode = (EPartyGameMode)SelectSlides[_SelectSlideGameMode].Selection; _Data.ScreenConfig.GameMode = (EPartyGameMode)_SelectSlides[_SelectSlideGameMode].Selection;
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
@@ -243,14 +269,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(_Data.ScreenConfig.PlaylistID); i++) for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(_Data.ScreenConfig.PlaylistID); i++)
{ {
int id = CBase.Playlist.GetPlaylistSong(_Data.ScreenConfig.PlaylistID, i).SongID; int id = CBase.Playlist.GetPlaylistSong(_Data.ScreenConfig.PlaylistID, i).SongID;
foreach (EGameMode mode in CBase.Songs.GetSongByID(id).AvailableGameModes) _ConfigOk = CBase.Songs.GetSongByID(id).AvailableGameModes.Any(mode => mode == gm);
{
if (mode == gm)
{
_ConfigOk = true;
break;
}
}
if (_ConfigOk) if (_ConfigOk)
break; break;
} }
@@ -271,14 +290,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ConfigOk = false; _ConfigOk = false;
for (int i = 0; i < CBase.Songs.NumSongsInCategory(_Data.ScreenConfig.CategoryID); i++) for (int i = 0; i < CBase.Songs.NumSongsInCategory(_Data.ScreenConfig.CategoryID); i++)
{ {
foreach (EGameMode mode in CBase.Songs.GetVisibleSong(i).AvailableGameModes) _ConfigOk = CBase.Songs.GetVisibleSong(i).AvailableGameModes.Any(mode => mode == gm);
{
if (mode == gm)
{
_ConfigOk = true;
break;
}
}
if (_ConfigOk) if (_ConfigOk)
break; break;
} }
@@ -296,14 +308,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
for (int i = 0; i < CBase.Songs.GetNumSongs(); i++) for (int i = 0; i < CBase.Songs.GetNumSongs(); i++)
{ {
foreach (EGameMode mode in CBase.Songs.GetSongByID(i).AvailableGameModes) _ConfigOk = CBase.Songs.GetSongByID(i).AvailableGameModes.Any(mode => mode == gm);
{
if (mode == gm)
{
_ConfigOk = true;
break;
}
}
if (_ConfigOk) if (_ConfigOk)
break; break;
} }
@@ -311,8 +316,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
else else
_ConfigOk = false; _ConfigOk = false;
} }
SelectSlides[_SelectSlideCategory].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY; _SelectSlides[_SelectSlideCategory].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY;
SelectSlides[_SelectSlidePlaylist].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST; _SelectSlides[_SelectSlidePlaylist].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST;
} }
private void _Back() private void _Back()
@@ -1,3 +1,22 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
@@ -60,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;
@@ -74,7 +93,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
base.Init(); base.Init();
_ThemeTexts = new string[] {_TextPopupReallyExit, _TextTeamChoosing, _TextFinishMessage, _TextNextPlayerT1, _TextNextPlayerT2, _TextNextPlayerNameT1, _TextNextPlayerNameT2}; _ThemeTexts = new string[]
{_TextPopupReallyExit, _TextTeamChoosing, _TextFinishMessage, _TextNextPlayerT1, _TextNextPlayerT2, _TextNextPlayerNameT1, _TextNextPlayerNameT2};
_ThemeButtons = new string[] _ThemeButtons = new string[]
{ {
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonField, _ButtonJokerRandomT1, _ButtonJokerRandomT2, _ButtonJokerRetryT1, _ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonField, _ButtonJokerRandomT1, _ButtonJokerRandomT2, _ButtonJokerRetryT1,
@@ -102,16 +122,14 @@ namespace VocaluxeLib.PartyModes.TicTacToe
base.LoadTheme(xmlPath); base.LoadTheme(xmlPath);
_CreateFields(); _CreateFields();
Buttons[_ButtonField].Visible = false; _Buttons[_ButtonField].Visible = false;
} }
public override void DataToScreen(object receivedData) public override void DataToScreen(object receivedData)
{ {
SDataToScreenMain config = new SDataToScreenMain();
try try
{ {
config = (SDataToScreenMain)receivedData; SDataToScreenMain config = (SDataToScreenMain)receivedData;
_GameData = config; _GameData = config;
} }
catch (Exception e) catch (Exception e)
@@ -147,11 +165,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case Keys.Enter: case Keys.Enter:
if (!_ExitPopupVisible) if (!_ExitPopupVisible)
{ {
if (Buttons[_ButtonNextRound].Selected) if (_Buttons[_ButtonNextRound].Selected)
_NextRound(); _NextRound();
if (Buttons[_ButtonBack].Selected && _GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected) if (_Buttons[_ButtonBack].Selected && _GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
_Back(); _Back();
if (Buttons[_ButtonExit].Selected && (_GameData.CurrentRoundNr > 1 || _Status == EStatus.FieldSelected) && _Status != EStatus.None) if (_Buttons[_ButtonExit].Selected && (_GameData.CurrentRoundNr > 1 || _Status == EStatus.FieldSelected) && _Status != EStatus.None)
_ShowPopup(true); _ShowPopup(true);
else if (_Status == EStatus.None) else if (_Status == EStatus.None)
_EndParty(); _EndParty();
@@ -178,21 +196,21 @@ namespace VocaluxeLib.PartyModes.TicTacToe
} }
if (_Status == EStatus.FieldSelected) if (_Status == EStatus.FieldSelected)
{ {
if (Buttons[_ButtonJokerRandomT1].Selected) if (_Buttons[_ButtonJokerRandomT1].Selected)
_UseJoker(0, 0); _UseJoker(0, 0);
if (Buttons[_ButtonJokerRandomT2].Selected) if (_Buttons[_ButtonJokerRandomT2].Selected)
_UseJoker(1, 0); _UseJoker(1, 0);
if (Buttons[_ButtonJokerRetryT1].Selected) if (_Buttons[_ButtonJokerRetryT1].Selected)
_UseJoker(0, 1); _UseJoker(0, 1);
if (Buttons[_ButtonJokerRetryT2].Selected) if (_Buttons[_ButtonJokerRetryT2].Selected)
_UseJoker(1, 1); _UseJoker(1, 1);
} }
} }
else else
{ {
if (Buttons[_ButtonPopupYes].Selected) if (_Buttons[_ButtonPopupYes].Selected)
_EndParty(); _EndParty();
if (Buttons[_ButtonPopupNo].Selected) if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false); _ShowPopup(false);
} }
break; break;
@@ -205,15 +223,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (!_ExitPopupVisible) if (!_ExitPopupVisible)
{ {
if (Buttons[_ButtonNextRound].Selected) if (_Buttons[_ButtonNextRound].Selected)
_NextRound(); _NextRound();
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
{ {
if (_Status == EStatus.None) if (_Status == EStatus.None)
_EndParty(); _EndParty();
@@ -243,21 +261,21 @@ namespace VocaluxeLib.PartyModes.TicTacToe
} }
if (_Status == EStatus.FieldSelected) if (_Status == EStatus.FieldSelected)
{ {
if (Buttons[_ButtonJokerRandomT1].Selected) if (_Buttons[_ButtonJokerRandomT1].Selected)
_UseJoker(0, 0); _UseJoker(0, 0);
if (Buttons[_ButtonJokerRandomT2].Selected) if (_Buttons[_ButtonJokerRandomT2].Selected)
_UseJoker(1, 0); _UseJoker(1, 0);
if (Buttons[_ButtonJokerRetryT1].Selected) if (_Buttons[_ButtonJokerRetryT1].Selected)
_UseJoker(0, 1); _UseJoker(0, 1);
if (Buttons[_ButtonJokerRetryT2].Selected) if (_Buttons[_ButtonJokerRetryT2].Selected)
_UseJoker(1, 1); _UseJoker(1, 1);
} }
} }
else else
{ {
if (Buttons[_ButtonPopupYes].Selected) if (_Buttons[_ButtonPopupYes].Selected)
_EndParty(); _EndParty();
if (Buttons[_ButtonPopupNo].Selected) if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false); _ShowPopup(false);
} }
} }
@@ -292,15 +310,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
_BuildWinnerPossibilities(); _BuildWinnerPossibilities();
_SelectedField = -1; _SelectedField = -1;
Buttons[_ButtonBack].Visible = true; _Buttons[_ButtonBack].Visible = true;
Buttons[_ButtonExit].Visible = false; _Buttons[_ButtonExit].Visible = false;
SetInteractionToButton(Buttons[_ButtonBack]); _SetInteractionToButton(_Buttons[_ButtonBack]);
} }
else else
{ {
Buttons[_ButtonBack].Visible = false; _Buttons[_ButtonBack].Visible = false;
Buttons[_ButtonExit].Visible = true; _Buttons[_ButtonExit].Visible = true;
SetInteractionToButton(Buttons[_ButtonExit]); _SetInteractionToButton(_Buttons[_ButtonExit]);
} }
_Status = EStatus.FieldChoosing; _Status = EStatus.FieldChoosing;
@@ -312,37 +330,37 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (_GameData.CurrentRoundNr <= _GameData.NumFields && winner == 0) if (_GameData.CurrentRoundNr <= _GameData.NumFields && winner == 0)
{ {
_UpdateTeamChoosingMessage(); _UpdateTeamChoosingMessage();
Texts[_TextNextPlayerT1].Visible = false; _Texts[_TextNextPlayerT1].Visible = false;
Texts[_TextNextPlayerT2].Visible = false; _Texts[_TextNextPlayerT2].Visible = false;
Texts[_TextNextPlayerNameT1].Visible = false; _Texts[_TextNextPlayerNameT1].Visible = false;
Texts[_TextNextPlayerNameT2].Visible = false; _Texts[_TextNextPlayerNameT2].Visible = false;
Statics[_StaticAvatarT1].Visible = false; _Statics[_StaticAvatarT1].Visible = false;
Statics[_StaticAvatarT2].Visible = false; _Statics[_StaticAvatarT2].Visible = false;
Buttons[_ButtonJokerRandomT1].Visible = false; _Buttons[_ButtonJokerRandomT1].Visible = false;
Buttons[_ButtonJokerRandomT2].Visible = false; _Buttons[_ButtonJokerRandomT2].Visible = false;
Buttons[_ButtonJokerRetryT1].Visible = false; _Buttons[_ButtonJokerRetryT1].Visible = false;
Buttons[_ButtonJokerRetryT2].Visible = false; _Buttons[_ButtonJokerRetryT2].Visible = false;
Buttons[_ButtonNextRound].Visible = false; _Buttons[_ButtonNextRound].Visible = false;
Texts[_TextFinishMessage].Visible = false; _Texts[_TextFinishMessage].Visible = false;
} }
else else
{ {
_Status = EStatus.None; _Status = EStatus.None;
Buttons[_ButtonNextRound].Visible = false; _Buttons[_ButtonNextRound].Visible = false;
Texts[_TextFinishMessage].Visible = true; _Texts[_TextFinishMessage].Visible = true;
Texts[_TextTeamChoosing].Visible = false; _Texts[_TextTeamChoosing].Visible = false;
if (winner > 0) if (winner > 0)
{ {
Texts[_TextFinishMessage].Color = CBase.Theme.GetPlayerColor(winner); _Texts[_TextFinishMessage].Color = CBase.Theme.GetPlayerColor(winner);
Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_WINNER", _PartyModeID) + " " + CBase.Language.Translate("TR_TEAM", _PartyModeID) + " " + _Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_WINNER", _PartyModeID) + " " + CBase.Language.Translate("TR_TEAM", _PartyModeID) + " " +
winner; winner;
} }
else else
{ {
Texts[_TextFinishMessage].Color = new SColorF(1, 1, 1, 1); _Texts[_TextFinishMessage].Color = new SColorF(1, 1, 1, 1);
Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", _PartyModeID); _Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", _PartyModeID);
} }
SetInteractionToButton(Buttons[_ButtonExit]); _SetInteractionToButton(_Buttons[_ButtonExit]);
} }
_ShowPopup(false); _ShowPopup(false);
@@ -370,11 +388,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
for (int i = 0; i < 25; i++) for (int i = 0; i < 25; i++)
{ {
CField f = new CField(); CField f = new CField {Button = GetNewButton(_Buttons[_ButtonField])};
f.Button = GetNewButton(Buttons[_ButtonField]);
f.Button.Visible = false; f.Button.Visible = false;
f.Content = new CRound(); f.Content = new CRound();
AddButton(f.Button); _AddButton(f.Button);
_Fields.Add(f); _Fields.Add(f);
} }
} }
@@ -382,13 +399,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateFields() private void _UpdateFields()
{ {
int numOneRow = (int)Math.Sqrt(_GameData.NumFields); int numOneRow = (int)Math.Sqrt(_GameData.NumFields);
float fieldSizeY = (CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow; float fieldSizeY = ((float)CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow;
float fieldSizeX = (CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow; float fieldSizeX = ((float)CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow;
if (fieldSizeX < fieldSizeY) _FieldSize = Math.Min(fieldSizeX, fieldSizeY);
_FieldSize = fieldSizeX; _FieldFirstX = (float)CBase.Settings.GetRenderW() / 2 - (numOneRow * _FieldSize + (numOneRow - 1) * _FieldSpace) / 2;
else
_FieldSize = fieldSizeY;
_FieldFirstX = CBase.Settings.GetRenderW() / 2 - (numOneRow * _FieldSize + (numOneRow - 1) * _FieldSpace) / 2;
_FieldFirstY = 140 + (CBase.Settings.GetRenderH() - 140) / 2 - (numOneRow * _FieldSize + numOneRow * _FieldSpace) / 2; _FieldFirstY = 140 + (CBase.Settings.GetRenderH() - 140) / 2 - (numOneRow * _FieldSize + numOneRow * _FieldSpace) / 2;
int row = 0; int row = 0;
int column = 0; int column = 0;
@@ -428,9 +442,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
for (int i = 0; i < _GameData.Rounds.Count; i++) for (int i = 0; i < _GameData.Rounds.Count; i++)
{ {
_Fields[i].Button.Enabled = true; _Fields[i].Button.Enabled = true;
_Fields[i].Button.Texture = Buttons[_ButtonField].Texture; _Fields[i].Button.Texture = _Buttons[_ButtonField].Texture;
_Fields[i].Button.Color = Buttons[_ButtonField].Color; _Fields[i].Button.Color = _Buttons[_ButtonField].Color;
_Fields[i].Button.SelColor = Buttons[_ButtonField].SelColor; _Fields[i].Button.SelColor = _Buttons[_ButtonField].SelColor;
_Fields[i].Content = _GameData.Rounds[i]; _Fields[i].Content = _GameData.Rounds[i];
if (_Fields[i].Content.Finished) if (_Fields[i].Content.Finished)
{ {
@@ -495,25 +509,25 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_GameData.Rounds[_SelectedField].SingerTeam2 = singerTeam2; _GameData.Rounds[_SelectedField].SingerTeam2 = singerTeam2;
_UpdateFieldContents(); _UpdateFieldContents();
Texts[_TextNextPlayerT1].Visible = true; _Texts[_TextNextPlayerT1].Visible = true;
Texts[_TextNextPlayerT2].Visible = true; _Texts[_TextNextPlayerT2].Visible = true;
Texts[_TextNextPlayerNameT1].Visible = true; _Texts[_TextNextPlayerNameT1].Visible = true;
Texts[_TextNextPlayerNameT2].Visible = true; _Texts[_TextNextPlayerNameT2].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles(); SProfile[] profiles = CBase.Profiles.GetProfiles();
Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName; _Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName;
Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName; _Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName;
Statics[_StaticAvatarT1].Visible = true; _Statics[_StaticAvatarT1].Visible = true;
Statics[_StaticAvatarT2].Visible = true; _Statics[_StaticAvatarT2].Visible = true;
Statics[_StaticAvatarT1].Texture = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].Avatar.Texture; _Statics[_StaticAvatarT1].Texture = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].Avatar.Texture;
Statics[_StaticAvatarT2].Texture = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].Avatar.Texture; _Statics[_StaticAvatarT2].Texture = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].Avatar.Texture;
_UpdateJokerButtons(); _UpdateJokerButtons();
Buttons[_ButtonNextRound].Visible = true; _Buttons[_ButtonNextRound].Visible = true;
Buttons[_ButtonExit].Visible = true; _Buttons[_ButtonExit].Visible = true;
Buttons[_ButtonBack].Visible = false; _Buttons[_ButtonBack].Visible = false;
SetInteractionToButton(Buttons[_ButtonNextRound]); _SetInteractionToButton(_Buttons[_ButtonNextRound]);
} }
private void _FieldSelectedAgain() private void _FieldSelectedAgain()
@@ -534,25 +548,25 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_GameData.Rounds[_SelectedField].SingerTeam2 = _GameData.Rounds[_OldSelectedField].SingerTeam2; _GameData.Rounds[_SelectedField].SingerTeam2 = _GameData.Rounds[_OldSelectedField].SingerTeam2;
_UpdateFieldContents(); _UpdateFieldContents();
Texts[_TextNextPlayerT1].Visible = true; _Texts[_TextNextPlayerT1].Visible = true;
Texts[_TextNextPlayerT2].Visible = true; _Texts[_TextNextPlayerT2].Visible = true;
Texts[_TextNextPlayerNameT1].Visible = true; _Texts[_TextNextPlayerNameT1].Visible = true;
Texts[_TextNextPlayerNameT2].Visible = true; _Texts[_TextNextPlayerNameT2].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles(); SProfile[] profiles = CBase.Profiles.GetProfiles();
Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName; _Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName;
Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName; _Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName;
Statics[_StaticAvatarT1].Visible = true; _Statics[_StaticAvatarT1].Visible = true;
Statics[_StaticAvatarT2].Visible = true; _Statics[_StaticAvatarT2].Visible = true;
Statics[_StaticAvatarT1].Texture = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].Avatar.Texture; _Statics[_StaticAvatarT1].Texture = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].Avatar.Texture;
Statics[_StaticAvatarT2].Texture = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].Avatar.Texture; _Statics[_StaticAvatarT2].Texture = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].Avatar.Texture;
_UpdateJokerButtons(); _UpdateJokerButtons();
Buttons[_ButtonNextRound].Visible = true; _Buttons[_ButtonNextRound].Visible = true;
Buttons[_ButtonExit].Visible = true; _Buttons[_ButtonExit].Visible = true;
Buttons[_ButtonBack].Visible = false; _Buttons[_ButtonBack].Visible = false;
SetInteractionToButton(Buttons[_ButtonNextRound]); _SetInteractionToButton(_Buttons[_ButtonNextRound]);
} }
private void _UseJoker(int teamNr, int jokerNum) private void _UseJoker(int teamNr, int jokerNum)
@@ -590,29 +604,29 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateTeamChoosingMessage() private void _UpdateTeamChoosingMessage()
{ {
Texts[_TextTeamChoosing].Color = CBase.Theme.GetPlayerColor(_GameData.Team + 1); _Texts[_TextTeamChoosing].Color = CBase.Theme.GetPlayerColor(_GameData.Team + 1);
Texts[_TextTeamChoosing].Text = CBase.Language.Translate("TR_TEAM", _PartyModeID) + " " + (_GameData.Team + 1) + "! " + _Texts[_TextTeamChoosing].Text = CBase.Language.Translate("TR_TEAM", _PartyModeID) + " " + (_GameData.Team + 1) + "! " +
CBase.Language.Translate("TR_SCREENMAIN_TEAM_CHOOSE", _PartyModeID); CBase.Language.Translate("TR_SCREENMAIN_TEAM_CHOOSE", _PartyModeID);
if (_Status == EStatus.JokerRetry || _Status == EStatus.FieldChoosing) if (_Status == EStatus.JokerRetry || _Status == EStatus.FieldChoosing)
Texts[_TextTeamChoosing].Visible = true; _Texts[_TextTeamChoosing].Visible = true;
else else
Texts[_TextTeamChoosing].Visible = false; _Texts[_TextTeamChoosing].Visible = false;
} }
private void _UpdateJokerButtons() private void _UpdateJokerButtons()
{ {
Buttons[_ButtonJokerRandomT1].Visible = true; _Buttons[_ButtonJokerRandomT1].Visible = true;
Buttons[_ButtonJokerRandomT2].Visible = true; _Buttons[_ButtonJokerRandomT2].Visible = true;
Buttons[_ButtonJokerRandomT1].Text.Text = _GameData.NumJokerRandom[0].ToString(); _Buttons[_ButtonJokerRandomT1].Text.Text = _GameData.NumJokerRandom[0].ToString();
Buttons[_ButtonJokerRandomT2].Text.Text = _GameData.NumJokerRandom[1].ToString(); _Buttons[_ButtonJokerRandomT2].Text.Text = _GameData.NumJokerRandom[1].ToString();
Buttons[_ButtonJokerRandomT1].Enabled = _GameData.NumJokerRandom[0] > 0; _Buttons[_ButtonJokerRandomT1].Enabled = _GameData.NumJokerRandom[0] > 0;
Buttons[_ButtonJokerRandomT2].Enabled = _GameData.NumJokerRandom[1] > 0; _Buttons[_ButtonJokerRandomT2].Enabled = _GameData.NumJokerRandom[1] > 0;
Buttons[_ButtonJokerRetryT1].Visible = true; _Buttons[_ButtonJokerRetryT1].Visible = true;
Buttons[_ButtonJokerRetryT2].Visible = true; _Buttons[_ButtonJokerRetryT2].Visible = true;
Buttons[_ButtonJokerRetryT1].Text.Text = _GameData.NumJokerRetry[0].ToString(); _Buttons[_ButtonJokerRetryT1].Text.Text = _GameData.NumJokerRetry[0].ToString();
Buttons[_ButtonJokerRetryT2].Text.Text = _GameData.NumJokerRetry[1].ToString(); _Buttons[_ButtonJokerRetryT2].Text.Text = _GameData.NumJokerRetry[1].ToString();
Buttons[_ButtonJokerRetryT1].Enabled = _GameData.NumJokerRetry[0] > 0; _Buttons[_ButtonJokerRetryT1].Enabled = _GameData.NumJokerRetry[0] > 0;
Buttons[_ButtonJokerRetryT2].Enabled = _GameData.NumJokerRetry[1] > 0; _Buttons[_ButtonJokerRetryT2].Enabled = _GameData.NumJokerRetry[1] > 0;
} }
private void _NextRound() private void _NextRound()
@@ -638,13 +652,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
_ExitPopupVisible = visible; _ExitPopupVisible = visible;
Statics[_StaticPopupBG].Visible = _ExitPopupVisible; _Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible; _Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible; _Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible; _Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
if (_ExitPopupVisible) if (_ExitPopupVisible)
SetInteractionToButton(Buttons[_ButtonPopupNo]); _SetInteractionToButton(_Buttons[_ButtonPopupNo]);
} }
private void _Back() private void _Back()
@@ -696,15 +710,14 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (_Fields[_Possibilities[i, j]].Content.Winner > 0) if (_Fields[_Possibilities[i, j]].Content.Winner > 0)
check.Add(_Fields[_Possibilities[i, j]].Content.Winner); check.Add(_Fields[_Possibilities[i, j]].Content.Winner);
} }
if (check.Count == _Possibilities.GetLength(1)) if (check.Count != _Possibilities.GetLength(1))
{ continue;
//Check for winner //Check for winner
if (check.Contains(1) && !check.Contains(2)) if (check.Contains(1) && !check.Contains(2))
return 1; return 1;
else if (check.Contains(2) && !check.Contains(1)) if (check.Contains(2) && !check.Contains(1))
return 2; return 2;
} }
}
return 0; return 0;
} }
} }
@@ -1,11 +1,33 @@
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.TicTacToe namespace VocaluxeLib.PartyModes.TicTacToe
{ {
// ReSharper disable UnusedMember.Global
public class CPartyScreenTicTacToeNames : CMenuParty public class CPartyScreenTicTacToeNames : CMenuParty
// ReSharper restore UnusedMember.Global
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion protected override int _ScreenVersion
@@ -24,7 +46,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private List<CButton> _PlayerDestinationButtons; private List<CButton> _PlayerDestinationButtons;
//PlayerDestinationButtons-Option //PlayerDestinationButtons-Option
private const int _PlayerDestinationButtonsNumH = 10; private const int _PlayerDestinationButtonsNumH = 10;
private const int _PlayerDestinationButtonsNumW = 2;
private const int _PlayerDestinationButtonsFirstX = 58; private const int _PlayerDestinationButtonsFirstX = 58;
private const int _PlayerDestinationButtonsFirstY = 380; private const int _PlayerDestinationButtonsFirstY = 380;
private const int _PlayerDestinationButtonsSpaceH = 15; private const int _PlayerDestinationButtonsSpaceH = 15;
@@ -69,25 +90,18 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Data.ScreenNames.ProfileIDsTeam1 = new List<int>(); _Data.ScreenNames.ProfileIDsTeam1 = new List<int>();
_Data.ScreenNames.ProfileIDsTeam2 = new List<int>(); _Data.ScreenNames.ProfileIDsTeam2 = new List<int>();
List<string> buttons = new List<string>();
_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(); SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, ProfileIDsTeam1 = new List<int>(), ProfileIDsTeam2 = new List<int>()};
names.FadeToConfig = false;
names.FadeToMain = false;
names.ProfileIDsTeam1 = new List<int>();
names.ProfileIDsTeam2 = new List<int>();
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
public override void DataToScreen(object receivedData) public override void DataToScreen(object receivedData)
{ {
SDataToScreenNames config = new SDataToScreenNames();
try try
{ {
config = (SDataToScreenNames)receivedData; SDataToScreenNames config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDsTeam1 = config.ProfileIDsTeam1; _Data.ScreenNames.ProfileIDsTeam1 = config.ProfileIDsTeam1;
_Data.ScreenNames.ProfileIDsTeam2 = config.ProfileIDsTeam2; _Data.ScreenNames.ProfileIDsTeam2 = config.ProfileIDsTeam2;
if (_Data.ScreenNames.ProfileIDsTeam1 == null) if (_Data.ScreenNames.ProfileIDsTeam1 == null)
@@ -124,16 +138,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
break; break;
case Keys.Enter: case Keys.Enter:
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
if (Buttons[_ButtonPlayerChooseScrollUp].Selected) if (_Buttons[_ButtonPlayerChooseScrollUp].Selected)
_Scroll(-1); _Scroll(-1);
if (Buttons[_ButtonPlayerChooseScrollDown].Selected) if (_Buttons[_ButtonPlayerChooseScrollDown].Selected)
_Scroll(1); _Scroll(1);
if (!_OnAdd()) if (!_OnAdd())
@@ -159,18 +173,18 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y; _OldMouseY = mouseEvent.Y;
//Check if mouse if over tile //Check if mouse if over tile
for (int i = 0; i < _PlayerChooseButtons.Count; i++) foreach (CPlayerChooseButton chooseButton in _PlayerChooseButtons)
{ {
if (_PlayerChooseButtons[i].Button.Selected) if (chooseButton.Button.Selected)
{ {
_SelectedPlayerNr = _PlayerChooseButtons[i].ProfileID; _SelectedPlayerNr = chooseButton.ProfileID;
if (_SelectedPlayerNr != -1) if (_SelectedPlayerNr != -1)
{ {
//Activate mouse-selecting //Activate mouse-selecting
_SelectingMouseActive = true; _SelectingMouseActive = true;
//Update of Drag/Drop-Texture //Update of Drag/Drop-Texture
_ChooseAvatarStatic.Visible = true; _ChooseAvatarStatic.Visible = true;
_ChooseAvatarStatic.Rect = _PlayerChooseButtons[i].Button.Rect; _ChooseAvatarStatic.Rect = chooseButton.Button.Rect;
_ChooseAvatarStatic.Rect.Z = -100; _ChooseAvatarStatic.Rect.Z = -100;
_ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1); _ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
_ChooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].Avatar.Texture; _ChooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].Avatar.Texture;
@@ -192,7 +206,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
return true; return true;
} }
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
else if (_SelectingMouseActive) if (_SelectingMouseActive)
{ {
//Check if really a player was selected //Check if really a player was selected
if (_SelectedPlayerNr != -1) if (_SelectedPlayerNr != -1)
@@ -255,22 +269,22 @@ namespace VocaluxeLib.PartyModes.TicTacToe
return true; return true;
} }
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
_Back(); _Back();
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
_Next(); _Next();
if (Buttons[_ButtonPlayerChooseScrollUp].Selected) if (_Buttons[_ButtonPlayerChooseScrollUp].Selected)
_Scroll(-1); _Scroll(-1);
if (Buttons[_ButtonPlayerChooseScrollDown].Selected) if (_Buttons[_ButtonPlayerChooseScrollDown].Selected)
_Scroll(1); _Scroll(1);
} }
if (mouseEvent.LD && IsMouseOver(mouseEvent)) if (mouseEvent.LD && _IsMouseOver(mouseEvent))
{ {
if (!_OnAdd()) if (!_OnAdd())
_OnRemove(); _OnRemove();
@@ -328,13 +342,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _AddButtonPlayerDestination() private void _AddButtonPlayerDestination()
{ {
Buttons[_ButtonPlayerDestination].Visible = false; _Buttons[_ButtonPlayerDestination].Visible = false;
_PlayerDestinationButtons = new List<CButton>(); _PlayerDestinationButtons = new List<CButton>();
int row = 0; int row = 0;
int column = 0; int column = 0;
for (int i = 1; i <= _PartyMode.GetMaxPlayer(); i++) for (int i = 1; i <= _PartyMode.GetMaxPlayer(); i++)
{ {
CButton b = GetNewButton(Buttons[_ButtonPlayerDestination]); CButton b = GetNewButton(_Buttons[_ButtonPlayerDestination]);
b.Rect.X = _PlayerDestinationButtonsFirstX + column * (b.Rect.W + _PlayerDestinationButtonsSpaceH); b.Rect.X = _PlayerDestinationButtonsFirstX + column * (b.Rect.W + _PlayerDestinationButtonsSpaceH);
b.Rect.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW); b.Rect.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW);
_PlayerDestinationButtons.Add(b); _PlayerDestinationButtons.Add(b);
@@ -346,24 +360,22 @@ namespace VocaluxeLib.PartyModes.TicTacToe
} }
b.Visible = true; b.Visible = true;
b.Enabled = false; b.Enabled = false;
AddButton(b); _AddButton(b);
} }
} }
private void _AddButtonPlayerChoose() private void _AddButtonPlayerChoose()
{ {
Buttons[_ButtonPlayerChoose].Visible = false; _Buttons[_ButtonPlayerChoose].Visible = false;
_PlayerChooseButtons = new List<CPlayerChooseButton>(); _PlayerChooseButtons = new List<CPlayerChooseButton>();
int row = 0; int row = 0;
int column = 0; int column = 0;
for (int i = 1; i <= _PlayerChooseButtonsNumH * _PlayerChooseButtonsNumW; i++) for (int i = 1; i <= _PlayerChooseButtonsNumH * _PlayerChooseButtonsNumW; i++)
{ {
CButton b = GetNewButton(Buttons[_ButtonPlayerChoose]); CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]);
b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH); b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH);
b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW); b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW);
CPlayerChooseButton pcb = new CPlayerChooseButton(); CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1};
pcb.Button = b;
pcb.ProfileID = -1;
_PlayerChooseButtons.Add(pcb); _PlayerChooseButtons.Add(pcb);
column++; column++;
if (column >= _PlayerChooseButtonsNumH) if (column >= _PlayerChooseButtonsNumH)
@@ -373,7 +385,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
} }
b.Visible = true; b.Visible = true;
b.Enabled = false; b.Enabled = false;
AddButton(b); _AddButton(b);
} }
} }
@@ -385,14 +397,14 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset - 1); _UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset - 1);
else else
_UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset); _UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset);
Buttons[_ButtonPlayerChooseScrollUp].Enabled = _PlayerChooseButtonsOffset > 0; _Buttons[_ButtonPlayerChooseScrollUp].Enabled = _PlayerChooseButtonsOffset > 0;
Buttons[_ButtonPlayerChooseScrollDown].Enabled = _PlayerChooseButtonsVisibleProfiles.Count > _Buttons[_ButtonPlayerChooseScrollDown].Enabled = _PlayerChooseButtonsVisibleProfiles.Count >
_PlayerChooseButtons.Count + _PlayerChooseButtonsOffset * _PlayerChooseButtonsNumH; _PlayerChooseButtons.Count + _PlayerChooseButtonsOffset * _PlayerChooseButtonsNumH;
} }
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;
@@ -404,8 +416,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
_PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]; _PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose];
_PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName; _PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName;
_PlayerChooseButtons[i].Button.Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; _PlayerChooseButtons[i].Button.Texture =
_PlayerChooseButtons[i].Button.SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.SelTexture =
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f); _PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
_PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1); _PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1);
_PlayerChooseButtons[i].Button.Enabled = true; _PlayerChooseButtons[i].Button.Enabled = true;
@@ -414,10 +428,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
_PlayerChooseButtons[i].ProfileID = -1; _PlayerChooseButtons[i].ProfileID = -1;
_PlayerChooseButtons[i].Button.Text.Text = String.Empty; _PlayerChooseButtons[i].Button.Text.Text = String.Empty;
_PlayerChooseButtons[i].Button.Texture = Buttons[_ButtonPlayerChoose].Texture; _PlayerChooseButtons[i].Button.Texture = _Buttons[_ButtonPlayerChoose].Texture;
_PlayerChooseButtons[i].Button.SelTexture = Buttons[_ButtonPlayerChoose].SelTexture; _PlayerChooseButtons[i].Button.SelTexture = _Buttons[_ButtonPlayerChoose].SelTexture;
_PlayerChooseButtons[i].Button.Color = Buttons[_ButtonPlayerChoose].Color; _PlayerChooseButtons[i].Button.Color = _Buttons[_ButtonPlayerChoose].Color;
_PlayerChooseButtons[i].Button.SelColor = Buttons[_ButtonPlayerChoose].SelColor; _PlayerChooseButtons[i].Button.SelColor = _Buttons[_ButtonPlayerChoose].SelColor;
_PlayerChooseButtons[i].Button.Enabled = false; _PlayerChooseButtons[i].Button.Enabled = false;
} }
} }
@@ -432,29 +446,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
bool visible = false; bool visible = false;
//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 = _Data.ScreenNames.ProfileIDsTeam1.All(t => t != i) && _Data.ScreenNames.ProfileIDsTeam2.All(t => t != i);
visible = true;
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);
} }
@@ -504,10 +496,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
} }
else else
{ {
_PlayerDestinationButtons[i].Color = Buttons[_ButtonPlayerDestination].Color; _PlayerDestinationButtons[i].Color = _Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i].SelColor = Buttons[_ButtonPlayerDestination].SelColor; _PlayerDestinationButtons[i].SelColor = _Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i].Texture = Buttons[_ButtonPlayerDestination].Texture; _PlayerDestinationButtons[i].Texture = _Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i].SelTexture = Buttons[_ButtonPlayerDestination].SelTexture; _PlayerDestinationButtons[i].SelTexture = _Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i].Text.Text = String.Empty; _PlayerDestinationButtons[i].Text.Text = String.Empty;
_PlayerDestinationButtons[i].Enabled = false; _PlayerDestinationButtons[i].Enabled = false;
} }
@@ -528,10 +520,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
} }
else else
{ {
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Color = Buttons[_ButtonPlayerDestination].Color; _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Color = _Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelColor = Buttons[_ButtonPlayerDestination].SelColor; _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelColor = _Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Texture = Buttons[_ButtonPlayerDestination].Texture; _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Texture = _Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelTexture = Buttons[_ButtonPlayerDestination].SelTexture; _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelTexture = _Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Text.Text = String.Empty; _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Text.Text = String.Empty;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Enabled = false; _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Enabled = false;
} }
@@ -542,55 +534,52 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
if (_Data.ScreenNames.ProfileIDsTeam1.Count == _NumPlayerTeam1 && _Data.ScreenNames.ProfileIDsTeam2.Count == _NumPlayerTeam2) if (_Data.ScreenNames.ProfileIDsTeam1.Count == _NumPlayerTeam1 && _Data.ScreenNames.ProfileIDsTeam2.Count == _NumPlayerTeam2)
{ {
Buttons[_ButtonNext].Visible = true; _Buttons[_ButtonNext].Visible = true;
SetInteractionToButton(Buttons[_ButtonNext]); _SetInteractionToButton(_Buttons[_ButtonNext]);
} }
else else
Buttons[_ButtonNext].Visible = false; _Buttons[_ButtonNext].Visible = false;
} }
private bool _OnAdd() private bool _OnAdd()
{ {
for (int i = 0; i < _PlayerChooseButtons.Count; i++) foreach (CPlayerChooseButton chooseButton in _PlayerChooseButtons.Where(chooseButton => chooseButton.Button.Selected && chooseButton.ProfileID != -1))
{
if (_PlayerChooseButtons[i].Button.Selected && _PlayerChooseButtons[i].ProfileID != -1)
{ {
if (_Data.ScreenNames.ProfileIDsTeam1.Count < _NumPlayerTeam1) if (_Data.ScreenNames.ProfileIDsTeam1.Count < _NumPlayerTeam1)
{ {
_Data.ScreenNames.ProfileIDsTeam1.Add(_PlayerChooseButtons[i].ProfileID); _Data.ScreenNames.ProfileIDsTeam1.Add(chooseButton.ProfileID);
int added = _Data.ScreenNames.ProfileIDsTeam1.Count - 1; int added = _Data.ScreenNames.ProfileIDsTeam1.Count - 1;
_UpdateButtonNext(); _UpdateButtonNext();
//Update texture and name //Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName; _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true; _PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List //Update Tiles-List
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
CheckInteraction(); _CheckInteraction();
return true; return true;
} }
else if (_Data.ScreenNames.ProfileIDsTeam2.Count < _NumPlayerTeam2) if (_Data.ScreenNames.ProfileIDsTeam2.Count < _NumPlayerTeam2)
{ {
_Data.ScreenNames.ProfileIDsTeam2.Add(_PlayerChooseButtons[i].ProfileID); _Data.ScreenNames.ProfileIDsTeam2.Add(chooseButton.ProfileID);
int added = (_Data.ScreenNames.ProfileIDsTeam2.Count - 1) + _PlayerDestinationButtonsNumH; int added = (_Data.ScreenNames.ProfileIDsTeam2.Count - 1) + _PlayerDestinationButtonsNumH;
_UpdateButtonNext(); _UpdateButtonNext();
//Update texture and name //Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName; _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true; _PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List //Update Tiles-List
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
CheckInteraction(); _CheckInteraction();
return true; return true;
} }
} }
}
return false; return false;
} }
@@ -606,7 +595,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_UpdateButtonNext(); _UpdateButtonNext();
_UpdateButtonPlayerDestination(); _UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
CheckInteraction(); _CheckInteraction();
return true; return true;
} }
} }
@@ -621,7 +610,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_UpdateButtonNext(); _UpdateButtonNext();
_UpdateButtonPlayerDestination(); _UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
CheckInteraction(); _CheckInteraction();
return true; return true;
} }
} }
@@ -632,14 +621,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);
} }
} }
Binary file not shown.
File renamed without changes.
+47 -42
View File
@@ -1,7 +1,27 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.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;
@@ -26,7 +46,6 @@ namespace Vocaluxe.Base
private static bool _OwnMusicAdded; private static bool _OwnMusicAdded;
private static bool _BackgroundMusicAdded; private static bool _BackgroundMusicAdded;
private static bool _Playing;
private static bool _Disabled; private static bool _Disabled;
private static bool _CanSing; private static bool _CanSing;
private static bool _RepeatSong; private static bool _RepeatSong;
@@ -88,18 +107,14 @@ namespace Vocaluxe.Base
get { return File.Exists(_CurrentPlaylistElement.VideoFilePath); } get { return File.Exists(_CurrentPlaylistElement.VideoFilePath); }
} }
public static bool Playing public static bool IsPlaying { get; private set; }
{
get { return _Playing; }
}
public static string ArtistAndTitle public static string ArtistAndTitle
{ {
get get
{ {
if (_CurrentPlaylistElement.Artist.Length > 0 && _CurrentPlaylistElement.Title.Length > 0) if (_CurrentPlaylistElement.Artist != "" && _CurrentPlaylistElement.Title != "")
return _CurrentPlaylistElement.Artist + " - " + _CurrentPlaylistElement.Title; return _CurrentPlaylistElement.Artist + " - " + _CurrentPlaylistElement.Title;
else
return Path.GetFileNameWithoutExtension(_CurrentPlaylistElement.MusicFilePath); return Path.GetFileNameWithoutExtension(_CurrentPlaylistElement.MusicFilePath);
} }
} }
@@ -124,12 +139,12 @@ namespace Vocaluxe.Base
if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON) if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON)
_VideoEnabled = true; _VideoEnabled = true;
_Playing = false; IsPlaying = false;
} }
public static void Play() public static void Play()
{ {
if (_Playing) if (IsPlaying)
return; return;
if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON) if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
@@ -142,22 +157,19 @@ namespace Vocaluxe.Base
CSound.Play(_CurrentMusicStream); CSound.Play(_CurrentMusicStream);
if (_VideoEnabled && _Video != -1) if (_VideoEnabled && _Video != -1)
CVideo.VdResume(_Video); CVideo.VdResume(_Video);
_Playing = true; IsPlaying = true;
} }
else else
Next(); Next();
if (!_IsBackgroundFile(_CurrentPlaylistElement)) _CanSing = !_IsBackgroundFile(_CurrentPlaylistElement);
_CanSing = true;
else
_CanSing = false;
} }
} }
} }
public static void Stop() public static void Stop()
{ {
if (!_Playing) if (!IsPlaying)
return; return;
if (_VideoEnabled && _Video != -1) if (_VideoEnabled && _Video != -1)
@@ -170,12 +182,12 @@ namespace Vocaluxe.Base
_CurrentMusicStream = -1; _CurrentMusicStream = -1;
_CurrentPlaylistElement = new CPlaylistElement(); _CurrentPlaylistElement = new CPlaylistElement();
_Playing = false; IsPlaying = false;
} }
public static void Pause() public static void Pause()
{ {
if (!_Playing) if (!IsPlaying)
return; return;
if (_VideoEnabled && _Video != -1) if (_VideoEnabled && _Video != -1)
@@ -184,7 +196,7 @@ namespace Vocaluxe.Base
CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap);
} }
CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime); CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
_Playing = false; IsPlaying = false;
} }
public static void Update() public static void Update()
@@ -192,24 +204,24 @@ namespace Vocaluxe.Base
if (_AllFileNames.Count > 0 && _CurrentMusicStream != -1) if (_AllFileNames.Count > 0 && _CurrentMusicStream != -1)
{ {
float timeToPlay; float timeToPlay;
if (_CurrentPlaylistElement.Finish == 0f) //No End-Tag defined if (Math.Abs(_CurrentPlaylistElement.Finish) < 0.001) //No End-Tag defined
timeToPlay = CSound.GetLength(_CurrentMusicStream) - CSound.GetPosition(_CurrentMusicStream); timeToPlay = CSound.GetLength(_CurrentMusicStream) - CSound.GetPosition(_CurrentMusicStream);
else //End-Tag found else //End-Tag found
timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream); timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream);
bool finished = CSound.IsFinished(_CurrentMusicStream); bool finished = CSound.IsFinished(_CurrentMusicStream);
if (_Playing && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished)) if (IsPlaying && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished))
{ {
if (_RepeatSong) if (_RepeatSong)
{ {
//Seek to #Start-Tag, if found //Seek to #Start-Tag, if found
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start); CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
else else
CSound.SetPosition(_CurrentMusicStream, 0); CSound.SetPosition(_CurrentMusicStream, 0);
if (_VideoEnabled && _Video != -1) if (_VideoEnabled && _Video != -1)
{ {
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
else else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
@@ -250,7 +262,7 @@ namespace Vocaluxe.Base
CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume); CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume);
//Seek to #Start-Tag, if found //Seek to #Start-Tag, if found
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start); CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
if (_VideoEnabled) if (_VideoEnabled)
@@ -266,17 +278,16 @@ namespace Vocaluxe.Base
{ {
if (_PreviousFileNames.Count > 0 && _PreviousMusicIndex >= 0) if (_PreviousFileNames.Count > 0 && _PreviousMusicIndex >= 0)
{ {
float pos = CSound.GetPosition(_CurrentMusicStream);
if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f) if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f)
{ {
//Seek to #Start-Tag, if found //Seek to #Start-Tag, if found
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start); CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
else else
CSound.SetPosition(_CurrentMusicStream, 0); CSound.SetPosition(_CurrentMusicStream, 0);
if (_VideoEnabled && _Video != -1) if (_VideoEnabled && _Video != -1)
{ {
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
else else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
@@ -302,13 +313,13 @@ namespace Vocaluxe.Base
else if (_CurrentMusicStream != -1) else if (_CurrentMusicStream != -1)
{ {
//Seek to #Start-Tag, if found //Seek to #Start-Tag, if found
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start); CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
else else
CSound.SetPosition(_CurrentMusicStream, 0); CSound.SetPosition(_CurrentMusicStream, 0);
if (_VideoEnabled && _Video != -1) if (_VideoEnabled && _Video != -1)
{ {
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
else else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
@@ -345,7 +356,7 @@ namespace Vocaluxe.Base
_NotPlayedFileNames.AddRange(_BGMusicFileNames); _NotPlayedFileNames.AddRange(_BGMusicFileNames);
} }
if (Playing && !_IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0) if (IsPlaying && !_IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0)
Next(); Next();
_OwnMusicAdded = false; _OwnMusicAdded = false;
@@ -370,7 +381,7 @@ namespace Vocaluxe.Base
AddOwnMusic(); AddOwnMusic();
_BackgroundMusicAdded = false; _BackgroundMusicAdded = false;
if (Playing && _IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0) if (IsPlaying && _IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0)
Next(); Next();
} }
} }
@@ -415,7 +426,7 @@ namespace Vocaluxe.Base
Pause(); Pause();
} }
if (CConfig.BackgroundMusicVolume != newVolume) if (Math.Abs(CConfig.BackgroundMusicVolume - newVolume) > 0.01)
{ {
CConfig.BackgroundMusicVolume = (int)newVolume; CConfig.BackgroundMusicVolume = (int)newVolume;
ApplyVolume(); ApplyVolume();
@@ -441,7 +452,6 @@ namespace Vocaluxe.Base
CVideo.VdClose(_Video); CVideo.VdClose(_Video);
CDraw.RemoveTexture(ref _CurrentVideoTexture); CDraw.RemoveTexture(ref _CurrentVideoTexture);
_Video = -1; _Video = -1;
return;
} }
} }
else else
@@ -452,8 +462,8 @@ namespace Vocaluxe.Base
{ {
if (_Video != -1) if (_Video != -1)
{ {
float vtime = 0f; float vtime;
CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), ref vtime); CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), out vtime);
if (_FadeTimer.ElapsedMilliseconds <= 3000L) if (_FadeTimer.ElapsedMilliseconds <= 3000L)
_CurrentVideoTexture.Color.A = _FadeTimer.ElapsedMilliseconds / 3000f; _CurrentVideoTexture.Color.A = _FadeTimer.ElapsedMilliseconds / 3000f;
else else
@@ -468,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()
@@ -481,7 +486,7 @@ namespace Vocaluxe.Base
if (_Video == -1) if (_Video == -1)
{ {
_Video = CVideo.VdLoad(_CurrentPlaylistElement.VideoFilePath); _Video = CVideo.VdLoad(_CurrentPlaylistElement.VideoFilePath);
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
else else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
+93 -69
View File
@@ -1,6 +1,26 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
@@ -32,7 +52,7 @@ namespace Vocaluxe.Base
public static int ScreenH = 576; public static int ScreenH = 576;
public static EAntiAliasingModes AAMode = EAntiAliasingModes.X0; public static EAntiAliasingModes AAMode = EAntiAliasingModes.X0;
public static EColorDeep Colors = EColorDeep.Bit32; public static EColorDepth ColorDepth = EColorDepth.Bit32;
public static EOffOn VSync = EOffOn.TR_CONFIG_ON; public static EOffOn VSync = EOffOn.TR_CONFIG_ON;
public static EOffOn FullScreen = EOffOn.TR_CONFIG_ON; public static EOffOn FullScreen = EOffOn.TR_CONFIG_ON;
@@ -56,8 +76,8 @@ namespace Vocaluxe.Base
public static EPlaybackLib PlayBackLib = EPlaybackLib.Gstreamer; public static EPlaybackLib PlayBackLib = EPlaybackLib.Gstreamer;
public static ERecordLib RecordLib = ERecordLib.PortAudio; public static ERecordLib RecordLib = ERecordLib.PortAudio;
public static EBufferSize AudioBufferSize = EBufferSize.B2048; public static EBufferSize AudioBufferSize = EBufferSize.B2048;
public static int AudioLatency = 0; public static int AudioLatency;
public static int BackgroundMusicVolume = 30; private static int _BackgroundMusicVolume = 30;
public static EOffOn BackgroundMusic = EOffOn.TR_CONFIG_ON; public static EOffOn BackgroundMusic = EOffOn.TR_CONFIG_ON;
public static EBackgroundMusicSource BackgroundMusicSource = EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC; public static EBackgroundMusicSource BackgroundMusicSource = EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC;
public static EOffOn BackgroundMusicUseStart = EOffOn.TR_CONFIG_ON; public static EOffOn BackgroundMusicUseStart = EOffOn.TR_CONFIG_ON;
@@ -65,7 +85,7 @@ namespace Vocaluxe.Base
public static int GameMusicVolume = 80; public static int GameMusicVolume = 80;
// Game // Game
public static List<string> SongFolder = new List<string>(); public static readonly List<string> SongFolder = new List<string>();
public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_TILE_BOARD; public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_TILE_BOARD;
public static ESongSorting SongSorting = ESongSorting.TR_CONFIG_ARTIST; public static ESongSorting SongSorting = ESongSorting.TR_CONFIG_ARTIST;
public static EOffOn IgnoreArticles = EOffOn.TR_CONFIG_ON; public static EOffOn IgnoreArticles = EOffOn.TR_CONFIG_ON;
@@ -75,7 +95,7 @@ namespace Vocaluxe.Base
public static EOffOn Tabs = EOffOn.TR_CONFIG_OFF; public static EOffOn Tabs = EOffOn.TR_CONFIG_OFF;
public static string Language = "English"; public static string Language = "English";
public static EOffOn LyricsOnTop = EOffOn.TR_CONFIG_OFF; public static EOffOn LyricsOnTop = EOffOn.TR_CONFIG_OFF;
public static string[] Players = new string[CSettings.MaxNumPlayer]; 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) public static float MinLineBreakTime = 0.1f; //Minimum time to show the text before it is (to be) sung (if possible)
@@ -98,6 +118,20 @@ namespace Vocaluxe.Base
//Variables to save old values for commandline-parameters //Variables to save old values for commandline-parameters
private static readonly List<string> _SongFolderOld = new List<string>(); private static readonly List<string> _SongFolderOld = new List<string>();
public static int BackgroundMusicVolume
{
get { return _BackgroundMusicVolume; }
set
{
if (value < 0)
_BackgroundMusicVolume = 0;
else if (value > 100)
_BackgroundMusicVolume = 100;
else
_BackgroundMusicVolume = value;
SaveConfig();
}
}
public static void Init() public static void Init()
{ {
@@ -113,17 +147,14 @@ namespace Vocaluxe.Base
if (!File.Exists(CSettings.FileConfig)) if (!File.Exists(CSettings.FileConfig))
SaveConfig(); SaveConfig();
LoadConfig(); _LoadConfig();
} }
public static bool LoadConfig() private static void _LoadConfig()
{ {
CXMLReader xmlReader = CXMLReader.OpenFile(CSettings.FileConfig); CXMLReader xmlReader = CXMLReader.OpenFile(CSettings.FileConfig);
if (xmlReader == null) if (xmlReader == null)
return false; return;
string value = string.Empty;
xmlReader.TryGetEnumValue("//root/Debug/DebugLevel", ref DebugLevel); xmlReader.TryGetEnumValue("//root/Debug/DebugLevel", ref DebugLevel);
@@ -135,7 +166,7 @@ namespace Vocaluxe.Base
xmlReader.TryGetIntValue("//root/Graphics/ScreenW", ref ScreenW); xmlReader.TryGetIntValue("//root/Graphics/ScreenW", ref ScreenW);
xmlReader.TryGetIntValue("//root/Graphics/ScreenH", ref ScreenH); xmlReader.TryGetIntValue("//root/Graphics/ScreenH", ref ScreenH);
xmlReader.TryGetEnumValue("//root/Graphics/AAMode", ref AAMode); xmlReader.TryGetEnumValue("//root/Graphics/AAMode", ref AAMode);
xmlReader.TryGetEnumValue("//root/Graphics/Colors", ref Colors); xmlReader.TryGetEnumValue("//root/Graphics/Colors", ref ColorDepth);
xmlReader.TryGetFloatValue("//root/Graphics/MaxFPS", ref MaxFPS); xmlReader.TryGetFloatValue("//root/Graphics/MaxFPS", ref MaxFPS);
xmlReader.TryGetEnumValue("//root/Graphics/VSync", ref VSync); xmlReader.TryGetEnumValue("//root/Graphics/VSync", ref VSync);
xmlReader.TryGetEnumValue("//root/Graphics/FullScreen", ref FullScreen); xmlReader.TryGetEnumValue("//root/Graphics/FullScreen", ref FullScreen);
@@ -143,9 +174,9 @@ namespace Vocaluxe.Base
#endregion Graphics #endregion Graphics
#region Theme #region Theme
xmlReader.GetValue("//root/Theme/Name", ref Theme, Theme); xmlReader.GetValue("//root/Theme/Name", out Theme, Theme);
xmlReader.GetValue("//root/Theme/Skin", ref Skin, Skin); xmlReader.GetValue("//root/Theme/Skin", out Skin, Skin);
xmlReader.GetValue("//root/Theme/Cover", ref CoverTheme, CoverTheme); xmlReader.GetValue("//root/Theme/Cover", out CoverTheme, CoverTheme);
xmlReader.TryGetEnumValue("//root/Theme/DrawNoteLines", ref DrawNoteLines); xmlReader.TryGetEnumValue("//root/Theme/DrawNoteLines", ref DrawNoteLines);
xmlReader.TryGetEnumValue("//root/Theme/DrawToneHelper", ref DrawToneHelper); xmlReader.TryGetEnumValue("//root/Theme/DrawToneHelper", ref DrawToneHelper);
xmlReader.TryGetEnumValue("//root/Theme/TimerLook", ref TimerLook); xmlReader.TryGetEnumValue("//root/Theme/TimerLook", ref TimerLook);
@@ -163,7 +194,7 @@ namespace Vocaluxe.Base
xmlReader.TryGetIntValueRange("//root/Sound/AudioLatency", ref AudioLatency, -500, 500); xmlReader.TryGetIntValueRange("//root/Sound/AudioLatency", ref AudioLatency, -500, 500);
xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusic", ref BackgroundMusic); xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusic", ref BackgroundMusic);
xmlReader.TryGetIntValueRange("//root/Sound/BackgroundMusicVolume", ref BackgroundMusicVolume); xmlReader.TryGetIntValueRange("//root/Sound/BackgroundMusicVolume", ref _BackgroundMusicVolume);
xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicSource", ref BackgroundMusicSource); xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicSource", ref BackgroundMusicSource);
xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicUseStart", ref BackgroundMusicUseStart); xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicUseStart", ref BackgroundMusicUseStart);
xmlReader.TryGetIntValueRange("//root/Sound/PreviewMusicVolume", ref PreviewMusicVolume); xmlReader.TryGetIntValueRange("//root/Sound/PreviewMusicVolume", ref PreviewMusicVolume);
@@ -172,9 +203,9 @@ namespace Vocaluxe.Base
#region Game #region Game
// Songfolder // Songfolder
value = string.Empty; string value = string.Empty;
int i = 1; int i = 1;
while (xmlReader.GetValue("//root/Game/SongFolder" + i.ToString(), ref value, value)) while (xmlReader.GetValue("//root/Game/SongFolder" + i, out value, value))
{ {
if (i == 1) if (i == 1)
SongFolder.Clear(); SongFolder.Clear();
@@ -191,7 +222,7 @@ namespace Vocaluxe.Base
xmlReader.TryGetEnumValue("//root/Game/TimerMode", ref TimerMode); xmlReader.TryGetEnumValue("//root/Game/TimerMode", ref TimerMode);
xmlReader.TryGetIntValue("//root/Game/NumPlayer", ref NumPlayer); xmlReader.TryGetIntValue("//root/Game/NumPlayer", ref NumPlayer);
xmlReader.TryGetEnumValue("//root/Game/Tabs", ref Tabs); xmlReader.TryGetEnumValue("//root/Game/Tabs", ref Tabs);
xmlReader.GetValue("//root/Game/Language", ref Language, Language); xmlReader.GetValue("//root/Game/Language", out Language, Language);
xmlReader.TryGetEnumValue("//root/Game/LyricsOnTop", ref LyricsOnTop); xmlReader.TryGetEnumValue("//root/Game/LyricsOnTop", ref LyricsOnTop);
xmlReader.TryGetFloatValue("//root/Game/MinLineBreakTime", ref MinLineBreakTime); xmlReader.TryGetFloatValue("//root/Game/MinLineBreakTime", ref MinLineBreakTime);
@@ -212,7 +243,7 @@ namespace Vocaluxe.Base
//Read players from config //Read players from config
for (i = 1; i <= CSettings.MaxNumPlayer; i++) for (i = 1; i <= CSettings.MaxNumPlayer; i++)
xmlReader.GetValue("//root/Game/Players/Player" + i.ToString(), ref Players[i - 1], string.Empty); xmlReader.GetValue("//root/Game/Players/Player" + i, out Players[i - 1], string.Empty);
#endregion Game #endregion Game
#region Video #region Video
@@ -224,7 +255,7 @@ namespace Vocaluxe.Base
xmlReader.TryGetEnumValue("//root/Video/WebcamLib", ref WebcamLib); xmlReader.TryGetEnumValue("//root/Video/WebcamLib", ref WebcamLib);
WebcamConfig = new SWebcamConfig(); WebcamConfig = new SWebcamConfig();
xmlReader.GetValue("//root/Video/WebcamConfig/MonikerString", ref WebcamConfig.MonikerString, String.Empty); xmlReader.GetValue("//root/Video/WebcamConfig/MonikerString", out WebcamConfig.MonikerString, String.Empty);
xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Framerate", ref WebcamConfig.Framerate); xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Framerate", ref WebcamConfig.Framerate);
xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Width", ref WebcamConfig.Width); xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Width", ref WebcamConfig.Width);
xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Height", ref WebcamConfig.Height); xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Height", ref WebcamConfig.Height);
@@ -232,21 +263,18 @@ namespace Vocaluxe.Base
#region Record #region Record
MicConfig = new SMicConfig[CSettings.MaxNumPlayer]; MicConfig = new SMicConfig[CSettings.MaxNumPlayer];
value = string.Empty;
for (int p = 1; p <= CSettings.MaxNumPlayer; p++) for (int p = 1; p <= CSettings.MaxNumPlayer; p++)
{ {
MicConfig[p - 1] = new SMicConfig(0); MicConfig[p - 1] = new SMicConfig(0);
xmlReader.GetValue("//root/Record/MicConfig" + p.ToString() + "/DeviceName", ref MicConfig[p - 1].DeviceName, String.Empty); xmlReader.GetValue("//root/Record/MicConfig" + p + "/DeviceName", out MicConfig[p - 1].DeviceName, String.Empty);
xmlReader.GetValue("//root/Record/MicConfig" + p.ToString() + "/DeviceDriver", ref MicConfig[p - 1].DeviceDriver, String.Empty); xmlReader.GetValue("//root/Record/MicConfig" + p + "/DeviceDriver", out MicConfig[p - 1].DeviceDriver, String.Empty);
xmlReader.GetValue("//root/Record/MicConfig" + p.ToString() + "/InputName", ref MicConfig[p - 1].InputName, String.Empty); xmlReader.GetValue("//root/Record/MicConfig" + p + "/InputName", out MicConfig[p - 1].InputName, String.Empty);
xmlReader.TryGetIntValue("//root/Record/MicConfig" + p.ToString() + "/Channel", ref MicConfig[p - 1].Channel); xmlReader.TryGetIntValue("//root/Record/MicConfig" + p + "/Channel", ref MicConfig[p - 1].Channel);
} }
xmlReader.TryGetIntValueRange("//root/Record/MicDelay", ref MicDelay, 0, 500); xmlReader.TryGetIntValueRange("//root/Record/MicDelay", ref MicDelay, 0, 500);
MicDelay = (int)(20 * Math.Round(MicDelay / 20.0)); MicDelay = (int)(20 * Math.Round(MicDelay / 20.0));
#endregion Record #endregion Record
return true;
} }
public static bool SaveConfig() public static bool SaveConfig()
@@ -302,8 +330,8 @@ namespace Vocaluxe.Base
writer.WriteComment("AAMode: " + CHelper.ListStrings(Enum.GetNames(typeof(EAntiAliasingModes)))); writer.WriteComment("AAMode: " + CHelper.ListStrings(Enum.GetNames(typeof(EAntiAliasingModes))));
writer.WriteElementString("AAMode", Enum.GetName(typeof(EAntiAliasingModes), AAMode)); writer.WriteElementString("AAMode", Enum.GetName(typeof(EAntiAliasingModes), AAMode));
writer.WriteComment("Colors: " + CHelper.ListStrings(Enum.GetNames(typeof(EColorDeep)))); writer.WriteComment("Colors: " + CHelper.ListStrings(Enum.GetNames(typeof(EColorDepth))));
writer.WriteElementString("Colors", Enum.GetName(typeof(EColorDeep), Colors)); writer.WriteElementString("Colors", Enum.GetName(typeof(EColorDepth), ColorDepth));
writer.WriteComment("MaxFPS should be between 1..200"); writer.WriteComment("MaxFPS should be between 1..200");
writer.WriteElementString("MaxFPS", MaxFPS.ToString("#")); writer.WriteElementString("MaxFPS", MaxFPS.ToString("#"));
@@ -407,14 +435,14 @@ namespace Vocaluxe.Base
//Write "old" song-folders to config. //Write "old" song-folders to config.
writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ..."); writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ...");
for (int i = 0; i < _SongFolderOld.Count; i++) for (int i = 0; i < _SongFolderOld.Count; i++)
writer.WriteElementString("SongFolder" + (i + 1).ToString(), _SongFolderOld[i]); writer.WriteElementString("SongFolder" + (i + 1), _SongFolderOld[i]);
} }
else else
{ {
//Write "normal" song-folders to config. //Write "normal" song-folders to config.
writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ..."); writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ...");
for (int i = 0; i < SongFolder.Count; i++) for (int i = 0; i < SongFolder.Count; i++)
writer.WriteElementString("SongFolder" + (i + 1).ToString(), SongFolder[i]); writer.WriteElementString("SongFolder" + (i + 1), SongFolder[i]);
} }
writer.WriteComment("SongMenu: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongMenu)))); writer.WriteComment("SongMenu: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongMenu))));
@@ -432,7 +460,7 @@ namespace Vocaluxe.Base
writer.WriteComment("TimerMode: " + CHelper.ListStrings(Enum.GetNames(typeof(ETimerMode)))); writer.WriteComment("TimerMode: " + CHelper.ListStrings(Enum.GetNames(typeof(ETimerMode))));
writer.WriteElementString("TimerMode", Enum.GetName(typeof(ETimerMode), TimerMode)); writer.WriteElementString("TimerMode", Enum.GetName(typeof(ETimerMode), TimerMode));
writer.WriteComment("NumPlayer: 1.." + CSettings.MaxNumPlayer.ToString()); writer.WriteComment("NumPlayer: 1.." + CSettings.MaxNumPlayer);
writer.WriteElementString("NumPlayer", NumPlayer.ToString()); writer.WriteElementString("NumPlayer", NumPlayer.ToString());
writer.WriteComment("Order songs in tabs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteComment("Order songs in tabs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))));
@@ -444,10 +472,10 @@ namespace Vocaluxe.Base
writer.WriteComment("MinLineBreakTime: Value >= 0 in s. Minimum time the text is shown before it is to be sung"); writer.WriteComment("MinLineBreakTime: Value >= 0 in s. Minimum time the text is shown before it is to be sung");
writer.WriteElementString("MinLineBreakTime", MinLineBreakTime.ToString()); writer.WriteElementString("MinLineBreakTime", MinLineBreakTime.ToString());
writer.WriteComment("Default profile for players 1..." + CSettings.MaxNumPlayer.ToString() + ":"); writer.WriteComment("Default profile for players 1..." + CSettings.MaxNumPlayer + ":");
writer.WriteStartElement("Players"); writer.WriteStartElement("Players");
for (int i = 1; i <= CSettings.MaxNumPlayer; i++) for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
writer.WriteElementString("Player" + i.ToString(), Path.GetFileName(Players[i - 1])); writer.WriteElementString("Player" + i, Path.GetFileName(Players[i - 1]));
writer.WriteEndElement(); writer.WriteEndElement();
writer.WriteEndElement(); writer.WriteEndElement();
@@ -491,9 +519,9 @@ namespace Vocaluxe.Base
for (int p = 1; p <= CSettings.MaxNumPlayer; p++) for (int p = 1; p <= CSettings.MaxNumPlayer; p++)
{ {
if (MicConfig[p - 1].DeviceName.Length > 0 && MicConfig[p - 1].InputName.Length > 0 && MicConfig[p - 1].Channel > 0) if (MicConfig[p - 1].DeviceName != "" && MicConfig[p - 1].InputName != "" && MicConfig[p - 1].Channel > 0)
{ {
writer.WriteStartElement("MicConfig" + p.ToString()); writer.WriteStartElement("MicConfig" + p);
writer.WriteElementString("DeviceName", MicConfig[p - 1].DeviceName); writer.WriteElementString("DeviceName", MicConfig[p - 1].DeviceName);
writer.WriteElementString("DeviceDriver", MicConfig[p - 1].DeviceDriver); writer.WriteElementString("DeviceDriver", MicConfig[p - 1].DeviceDriver);
@@ -566,8 +594,6 @@ namespace Vocaluxe.Base
if (devices == null) if (devices == null)
return false; return false;
if (devices != null)
{
for (int dev = 0; dev < devices.Length; dev++) for (int dev = 0; dev < devices.Length; dev++)
{ {
for (int inp = 0; inp < devices[dev].Inputs.Count; inp++) for (int inp = 0; inp < devices[dev].Inputs.Count; inp++)
@@ -578,7 +604,18 @@ namespace Vocaluxe.Base
} }
return false; return false;
} }
return false;
public static int GetMaxNumMics()
{
int max = 0;
for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
{
if (IsMicConfig(i))
max = i;
else
break;
}
return max;
} }
/// <summary> /// <summary>
@@ -595,7 +632,7 @@ namespace Vocaluxe.Base
for (int dev = 0; dev < devices.Length; dev++) for (int dev = 0; dev < devices.Length; dev++)
{ {
//Has Device some signal-names in name -> This could be a (usb-)mic //Has Device some signal-names in name -> This could be a (usb-)mic
if (Regex.IsMatch(devices[dev].Name, @"ReplacedStr:::0:::", RegexOptions.IgnoreCase)) if (Regex.IsMatch(devices[dev].Name, "Usb|Wireless", RegexOptions.IgnoreCase))
{ {
//Check if there are inputs. //Check if there are inputs.
if (devices[dev].Inputs.Count >= 1) if (devices[dev].Inputs.Count >= 1)
@@ -619,11 +656,11 @@ namespace Vocaluxe.Base
} }
} }
} }
//If no usb-mics found -> Look for Devices with "ReplacedStr:::1:::" or "ReplacedStr:::2:::" //If no usb-mics found -> Look for Devices with "mic" or "mik"
for (int dev = 0; dev < devices.Length; dev++) for (int dev = 0; dev < devices.Length; dev++)
{ {
//Has Device some signal-names in name -> This could be a mic //Has Device some signal-names in name -> This could be a mic
if (Regex.IsMatch(devices[dev].Name, @"ReplacedStr:::3:::", RegexOptions.IgnoreCase)) if (Regex.IsMatch(devices[dev].Name, "Mic|Mik", RegexOptions.IgnoreCase))
{ {
//Check if there are inputs. //Check if there are inputs.
if (devices[dev].Inputs.Count >= 1) if (devices[dev].Inputs.Count >= 1)
@@ -661,30 +698,25 @@ namespace Vocaluxe.Base
/// <param name="args">Parameters</param> /// <param name="args">Parameters</param>
public static void LoadCommandLineParams(string[] args) public static void LoadCommandLineParams(string[] args)
{ {
Regex spliterParam = new Regex(@"ReplacedStr:::0:::", RegexOptions.IgnoreCase); Regex spliterParam = new Regex(@"-{1,2}|\/", RegexOptions.IgnoreCase);
//Complete argument string //Complete argument string
string arguments = string.Empty; string arguments = args.Aggregate(string.Empty, (current, arg) => current + (arg + " "));
foreach (string arg in args)
arguments += arg + " ";
args = spliterParam.Split(arguments); args = spliterParam.Split(arguments);
foreach (string text in args) foreach (string text in args)
{ {
Regex spliterVal = new Regex(@"ReplacedStr:::2:::", RegexOptions.IgnoreCase); Regex spliterVal = new Regex(@"\s", RegexOptions.IgnoreCase);
//Array for parts of an arg
string[] parts;
//split arg with Spilter-Regex and save in parts //split arg with Spilter-Regex and save in parts
parts = spliterVal.Split(text, 2); string[] parts = spliterVal.Split(text, 2);
switch (parts.Length) switch (parts.Length)
{ {
//Only found a parameter //Only found a parameter
case 1: case 1:
if (!Regex.IsMatch(parts[0], @"ReplacedStr:::3:::") && parts[0].Length > 0) if (parts[0] != "")
{ {
//Add parameter //Add parameter
_Params.Add(parts[0]); _Params.Add(parts[0]);
@@ -697,7 +729,7 @@ namespace Vocaluxe.Base
//Found parameter and value //Found parameter and value
case 2: case 2:
if (!Regex.IsMatch(parts[0], @"ReplacedStr:::5:::") && parts[0].Length > 0) if (parts[0] != "")
{ {
//Add parameter //Add parameter
_Params.Add(parts[0]); _Params.Add(parts[0]);
@@ -793,35 +825,27 @@ namespace Vocaluxe.Base
if (value.Contains(chars[i].ToString())) if (value.Contains(chars[i].ToString()))
return false; return false;
} }
if (Path.GetFileName(value).Length == 0) return !String.IsNullOrEmpty(Path.GetFileName(value)) && Path.HasExtension(value);
return false;
if (!Path.HasExtension(value))
return false;
return true;
} }
/// <summary> /// <summary>
/// Use saved players from config now for games /// Use saved players from config now for games
/// </summary> /// </summary>
public static void UsePlayers() public static void UsePlayers()
{
for (int i = 0; i < CProfiles.Profiles.Length; i++)
{ {
for (int j = 0; j < CSettings.MaxNumPlayer; j++) for (int j = 0; j < CSettings.MaxNumPlayer; j++)
{ {
if (Players[j].Length > 0) CGame.Players[j].ProfileID = -1;
if (Players[j] == "")
continue;
for (int i = 0; i < CProfiles.Profiles.Length; i++)
{ {
if (Path.GetFileName(CProfiles.Profiles[i].ProfileFile) == Players[j] && CProfiles.Profiles[i].Active == EOffOn.TR_CONFIG_ON) if (Path.GetFileName(CProfiles.Profiles[i].ProfileFile) == Players[j] && CProfiles.Profiles[i].Active == EOffOn.TR_CONFIG_ON)
{ {
//Update Game-infos with player //Update Game-infos with player
CGame.Player[j].Name = CProfiles.Profiles[i].PlayerName; CGame.Players[j].ProfileID = i;
CGame.Player[j].Difficulty = CProfiles.Profiles[i].Difficulty;
CGame.Player[j].ProfileID = i;
} }
} }
else
CGame.Player[j].ProfileID = -1;
}
} }
} }
} }
+48 -42
View File
@@ -1,6 +1,26 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using System.Xml; using System.Xml;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -97,19 +117,13 @@ namespace Vocaluxe.Base
/// <summary> /// <summary>
/// Returns true if a cover with the given name exists. /// Returns true if a cover with the given name exists.
/// </summary> /// </summary>
public static bool CoverExists(string name) private static bool _CoverExists(string name)
{ {
STexture cov = _NoCover;
lock (_MutexCover) lock (_MutexCover)
{ {
foreach (SCover cover in _Cover) return _Cover.Any(cover => cover.Name == name);
{
if (cover.Name == name)
return true;
} }
} }
return false;
}
/// <summary> /// <summary>
/// Reloads cover to use a new cover-theme /// Reloads cover to use a new cover-theme
@@ -149,8 +163,8 @@ namespace Vocaluxe.Base
{ {
_CoverThemes.Clear(); _CoverThemes.Clear();
string path = CSettings.FolderCover; const string path = CSettings.FolderCover;
List<string> files = CHelper.ListFiles(path, "*.xml", false); List<string> files = CHelper.ListFiles(path, "*.xml");
foreach (string file in files) foreach (string file in files)
{ {
@@ -160,10 +174,10 @@ namespace Vocaluxe.Base
{ {
SCoverTheme coverTheme = new SCoverTheme(); SCoverTheme coverTheme = new SCoverTheme();
xmlReader.GetValue("//root/Info/Name", ref coverTheme.Name, String.Empty); xmlReader.GetValue("//root/Info/Name", out coverTheme.Name, String.Empty);
xmlReader.GetValue("//root/Info/Folder", ref coverTheme.Folder, String.Empty); xmlReader.GetValue("//root/Info/Folder", out coverTheme.Folder, String.Empty);
if (coverTheme.Folder.Length > 0 && coverTheme.Name.Length > 0) if (coverTheme.Folder != "" && coverTheme.Name != "")
{ {
coverTheme.File = file; coverTheme.File = file;
@@ -178,12 +192,10 @@ namespace Vocaluxe.Base
/// </summary> /// </summary>
private static void _LoadCover(string coverThemeName) private static void _LoadCover(string coverThemeName)
{ {
SCoverTheme coverTheme = new SCoverTheme(); SCoverTheme coverTheme = _CoverTheme(coverThemeName);
coverTheme = _CoverTheme(coverThemeName); if (coverTheme.Name == "")
return;
if (coverTheme.Name.Length > 0)
{
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderCover, coverTheme.File)); CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderCover, coverTheme.File));
if (xmlReader != null) if (xmlReader != null)
@@ -192,19 +204,17 @@ namespace Vocaluxe.Base
{ {
_Cover.Clear(); _Cover.Clear();
List<string> cover = xmlReader.GetValues("Cover"); List<string> cover = xmlReader.GetValues("Cover");
for (int i = 0; i < cover.Count; i++) foreach (string coverName in cover)
{ {
SCover sk = new SCover(); SCover sk = new SCover();
string name = String.Empty; string name;
string value = String.Empty; string value;
xmlReader.GetValue("//root/Cover/" + cover[i] + "/Name", ref name, String.Empty); xmlReader.GetValue("//root/Cover/" + coverName + "/Name", out name, String.Empty);
xmlReader.GetValue("//root/Cover/" + cover[i] + "/Path", ref value, String.Empty); xmlReader.GetValue("//root/Cover/" + coverName + "/Path", out value, String.Empty);
sk.Name = name; sk.Name = name;
sk.Value = Path.Combine(coverTheme.Folder, value); sk.Value = Path.Combine(coverTheme.Folder, value);
if (File.Exists(Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, value)))) sk.Texture = File.Exists(Path.Combine(CSettings.FolderCover, sk.Value))
sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, value))); ? CDraw.AddTexture(Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, value))) : _NoCover;
else
sk.Texture = _NoCover;
_Cover.Add(sk); _Cover.Add(sk);
@@ -216,24 +226,22 @@ namespace Vocaluxe.Base
List<string> files = new List<string>(); List<string> files = new List<string>();
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.FolderCover, coverTheme.Folder), "*.png", true, true)); string path = Path.Combine(CSettings.FolderCover, coverTheme.Folder);
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.FolderCover, coverTheme.Folder), "*.jpg", true, true)); files.AddRange(CHelper.ListFiles(path, "*.png", true, true));
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.FolderCover, coverTheme.Folder), "*.jpeg", true, true)); files.AddRange(CHelper.ListFiles(path, "*.jpg", true, true));
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.FolderCover, coverTheme.Folder), "*.bmp", true, true)); files.AddRange(CHelper.ListFiles(path, "*.jpeg", true, true));
files.AddRange(CHelper.ListFiles(path, "*.bmp", true, true));
foreach (string file in files) foreach (string file in files)
{ {
string name = Path.GetFileNameWithoutExtension(file); string name = Path.GetFileNameWithoutExtension(file);
if (!CoverExists(name)) if (_CoverExists(name))
{ continue;
SCover sk = new SCover(); // ReSharper disable AssignNullToNotNullAttribute
SCover sk = new SCover {Name = name, Value = Path.Combine(coverTheme.Folder, Path.GetFileName(file))};
string value = String.Empty; // ReSharper restore AssignNullToNotNullAttribute
sk.Name = name;
sk.Value = Path.Combine(coverTheme.Folder, Path.GetFileName(file));
sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.FolderCover, sk.Value)); sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.FolderCover, sk.Value));
@@ -241,6 +249,4 @@ namespace Vocaluxe.Base
} }
} }
} }
}
}
} }
+72 -121
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
@@ -51,19 +70,9 @@ namespace Vocaluxe.Base
} }
#region Highscores #region Highscores
public static int AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int diff, public static int AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int difficulty,
string artist, string title, int numPlayed, string filePath) string artist, string title, int numPlayed, string filePath)
{ {
SPlayer player = new SPlayer();
player.Name = playerName;
player.Points = score;
player.LineNr = lineNr;
player.DateTicks = date;
player.Medley = medley == 1;
player.Duet = duet == 1;
player.ShortSong = shortSong == 1;
player.Difficulty = (EGameDifficulty)diff;
using (SQLiteConnection connection = new SQLiteConnection()) using (SQLiteConnection connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + filePath; connection.ConnectionString = "Data Source=" + filePath;
@@ -80,7 +89,7 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
int dataBaseSongID = _GetDataBaseSongID(artist, title, numPlayed, command); int dataBaseSongID = _GetDataBaseSongID(artist, title, numPlayed, command);
int result = _AddScore(player, command, dataBaseSongID); int result = _AddScore(playerName, score, lineNr, date, medley, duet, shortSong, difficulty, dataBaseSongID, command);
return result; return result;
} }
} }
@@ -104,42 +113,30 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
int dataBaseSongID = _GetDataBaseSongID(player, command); int dataBaseSongID = _GetDataBaseSongID(player, command);
int result = _AddScore(player, command, dataBaseSongID); return _AddScore(CProfiles.GetPlayerName(player.ProfileID), (int)Math.Round(player.Points), player.LineNr, player.DateTicks, player.Medley ? 1 : 0,
player.Duet ? 1 : 0, player.ShortSong ? 1 : 0, (int)CProfiles.GetDifficulty(player.ProfileID), dataBaseSongID, command);
return result;
} }
} }
} }
private static int _AddScore(SPlayer player, SQLiteCommand command, int dataBaseSongID) private static int _AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int difficulty,
int dataBaseSongID, SQLiteCommand command)
{ {
int lastInsertID = -1; int lastInsertID = -1;
if (dataBaseSongID >= 0) if (dataBaseSongID >= 0)
{ {
int medley = 0;
if (player.Medley)
medley = 1;
int duet = 0;
if (player.Duet)
duet = 1;
int shortSong = 0;
if (player.ShortSong)
shortSong = 1;
command.CommandText = "SELECT id FROM Scores WHERE SongID = @SongID AND PlayerName = @PlayerName AND Score = @Score AND " + command.CommandText = "SELECT id FROM Scores WHERE SongID = @SongID AND PlayerName = @PlayerName AND Score = @Score AND " +
"LineNr = @LineNr AND Date = @Date AND Medley = @Medley AND Duet = @Duet AND ShortSong = @ShortSong AND Difficulty = @Difficulty"; "LineNr = @LineNr AND Date = @Date AND Medley = @Medley AND Duet = @Duet AND ShortSong = @ShortSong AND Difficulty = @Difficulty";
command.Parameters.Add("@SongID", DbType.Int32, 0).Value = dataBaseSongID; command.Parameters.Add("@SongID", DbType.Int32, 0).Value = dataBaseSongID;
command.Parameters.Add("@PlayerName", DbType.String, 0).Value = player.Name; command.Parameters.Add("@PlayerName", DbType.String, 0).Value = playerName;
command.Parameters.Add("@Score", DbType.Int32, 0).Value = (int)Math.Round(player.Points); command.Parameters.Add("@Score", DbType.Int32, 0).Value = score;
command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = player.LineNr; command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = lineNr;
command.Parameters.Add("@Date", DbType.Int64, 0).Value = player.DateTicks; command.Parameters.Add("@Date", DbType.Int64, 0).Value = date;
command.Parameters.Add("@Medley", DbType.Int32, 0).Value = medley; command.Parameters.Add("@Medley", DbType.Int32, 0).Value = medley;
command.Parameters.Add("@Duet", DbType.Int32, 0).Value = duet; command.Parameters.Add("@Duet", DbType.Int32, 0).Value = duet;
command.Parameters.Add("@ShortSong", DbType.Int32, 0).Value = shortSong; command.Parameters.Add("@ShortSong", DbType.Int32, 0).Value = shortSong;
command.Parameters.Add("@Difficulty", DbType.Int32, 0).Value = (int)player.Difficulty; command.Parameters.Add("@Difficulty", DbType.Int32, 0).Value = difficulty;
SQLiteDataReader reader = null; SQLiteDataReader reader = null;
try try
@@ -155,22 +152,19 @@ namespace Vocaluxe.Base
} }
if (reader != null) if (reader != null)
{
reader.Dispose(); reader.Dispose();
reader = null;
}
command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty) " + command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty) " +
"VALUES (@SongID, @PlayerName, @Score, @LineNr, @Date, @Medley, @Duet, @ShortSong, @Difficulty)"; "VALUES (@SongID, @PlayerName, @Score, @LineNr, @Date, @Medley, @Duet, @ShortSong, @Difficulty)";
command.Parameters.Add("@SongID", DbType.Int32, 0).Value = dataBaseSongID; command.Parameters.Add("@SongID", DbType.Int32, 0).Value = dataBaseSongID;
command.Parameters.Add("@PlayerName", DbType.String, 0).Value = player.Name; command.Parameters.Add("@PlayerName", DbType.String, 0).Value = playerName;
command.Parameters.Add("@Score", DbType.Int32, 0).Value = (int)Math.Round(player.Points); command.Parameters.Add("@Score", DbType.Int32, 0).Value = score;
command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = player.LineNr; command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = lineNr;
command.Parameters.Add("@Date", DbType.Int64, 0).Value = player.DateTicks; command.Parameters.Add("@Date", DbType.Int64, 0).Value = date;
command.Parameters.Add("@Medley", DbType.Int32, 0).Value = medley; command.Parameters.Add("@Medley", DbType.Int32, 0).Value = medley;
command.Parameters.Add("@Duet", DbType.Int32, 0).Value = duet; command.Parameters.Add("@Duet", DbType.Int32, 0).Value = duet;
command.Parameters.Add("@ShortSong", DbType.Int32, 0).Value = shortSong; command.Parameters.Add("@ShortSong", DbType.Int32, 0).Value = shortSong;
command.Parameters.Add("@Difficulty", DbType.Int32, 0).Value = (int)player.Difficulty; command.Parameters.Add("@Difficulty", DbType.Int32, 0).Value = difficulty;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
//Read last insert line //Read last insert line
@@ -189,7 +183,7 @@ namespace Vocaluxe.Base
return lastInsertID; return lastInsertID;
} }
public static void LoadScore(ref List<SScores> scores, SPlayer player) public static void LoadScore(out List<SScores> scores, SPlayer player)
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (SQLiteConnection connection = new SQLiteConnection())
{ {
@@ -236,13 +230,15 @@ namespace Vocaluxe.Base
{ {
while (reader.Read()) while (reader.Read())
{ {
SScores score = new SScores(); SScores score = new SScores
score.Name = reader.GetString(0); {
score.Score = reader.GetInt32(1); Name = reader.GetString(0),
score.Date = new DateTime(reader.GetInt64(2)).ToString("dd/MM/yyyy"); Score = reader.GetInt32(1),
score.Difficulty = (EGameDifficulty)reader.GetInt32(3); Date = new DateTime(reader.GetInt64(2)).ToString("dd/MM/yyyy"),
score.LineNr = reader.GetInt32(4); Difficulty = (EGameDifficulty)reader.GetInt32(3),
score.ID = reader.GetInt32(5); LineNr = reader.GetInt32(4),
ID = reader.GetInt32(5)
};
scores.Add(score); scores.Add(score);
} }
@@ -263,26 +259,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";
@@ -298,8 +274,6 @@ namespace Vocaluxe.Base
reader.Dispose(); reader.Dispose();
return id; return id;
} }
else
{
if (reader != null) if (reader != null)
reader.Close(); reader.Close();
@@ -323,10 +297,6 @@ namespace Vocaluxe.Base
reader.Dispose(); reader.Dispose();
return id; return id;
} }
}
if (reader != null)
reader.Dispose();
return -1; return -1;
} }
@@ -355,7 +325,7 @@ namespace Vocaluxe.Base
command.CommandText = "SELECT Artist, Title, NumPlayed FROM Songs WHERE [id] = @id"; command.CommandText = "SELECT Artist, Title, NumPlayed FROM Songs WHERE [id] = @id";
command.Parameters.Add("@id", DbType.String, 0).Value = songID; command.Parameters.Add("@id", DbType.String, 0).Value = songID;
SQLiteDataReader reader = null; SQLiteDataReader reader;
try try
{ {
reader = command.ExecuteReader(); reader = command.ExecuteReader();
@@ -391,7 +361,7 @@ namespace Vocaluxe.Base
{ {
_CreateOrConvert(oldDBFilePath); _CreateOrConvert(oldDBFilePath);
_CreateOrConvert(_HighscoreFilePath); _CreateOrConvert(_HighscoreFilePath);
_ImportData(oldDBFilePath, _HighscoreFilePath); _ImportData(oldDBFilePath);
File.Delete(oldDBFilePath); File.Delete(oldDBFilePath);
} }
@@ -497,11 +467,10 @@ namespace Vocaluxe.Base
return false; return false;
} }
SQLiteDataReader reader = null;
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
command.CommandText = "PRAGMA user_version"; command.CommandText = "PRAGMA user_version";
reader = command.ExecuteReader(); SQLiteDataReader reader = command.ExecuteReader();
reader.Read(); reader.Read();
int version = reader.GetInt32(0); int version = reader.GetInt32(0);
@@ -617,24 +586,14 @@ namespace Vocaluxe.Base
List<SData> scores = new List<SData>(); List<SData> scores = new List<SData>();
List<SData> songs = new List<SData>(); List<SData> songs = new List<SData>();
SQLiteDataReader reader = null;
command.CommandText = "SELECT id, PlayerName, Date FROM Scores"; command.CommandText = "SELECT id, PlayerName, Date FROM Scores";
try SQLiteDataReader reader = command.ExecuteReader();
{
reader = command.ExecuteReader();
}
catch (Exception)
{
throw;
}
if (reader != null && reader.HasRows) if (reader != null && reader.HasRows)
{ {
while (reader.Read()) while (reader.Read())
{ {
SData data = new SData(); SData data = new SData {Id = reader.GetInt32(0), Str1 = reader.GetString(1)};
data.Id = reader.GetInt32(0);
data.Str1 = reader.GetString(1);
Int64 ticks = 0; Int64 ticks = 0;
try try
@@ -658,10 +617,7 @@ namespace Vocaluxe.Base
{ {
while (reader.Read()) while (reader.Read())
{ {
SData data = new SData(); SData data = new SData {Id = reader.GetInt32(0), Str1 = reader.GetString(1), Str2 = reader.GetString(2)};
data.Id = reader.GetInt32(0);
data.Str1 = reader.GetString(1);
data.Str2 = reader.GetString(2);
songs.Add(data); songs.Add(data);
} }
} }
@@ -792,21 +748,13 @@ namespace Vocaluxe.Base
while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW) while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW)
{ {
SData data = new SData(); SData data = new SData {Id = Sqlite3.sqlite3_column_int(stmt, 0)};
data.Id = Sqlite3.sqlite3_column_int(stmt, 0);
byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1); byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1);
if (bytes != null) data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone";
data.Str1 = utf8.GetString(Encoding.Convert(cp1252, utf8, bytes));
else
data.Str1 = "Someone";
bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 2); bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 2);
if (bytes != null) data.Str2 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone";
data.Str2 = utf8.GetString(Encoding.Convert(cp1252, utf8, bytes));
else
data.Str2 = "Someone";
songs.Add(data); songs.Add(data);
} }
@@ -830,15 +778,10 @@ namespace Vocaluxe.Base
while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW) while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW)
{ {
SData data = new SData(); SData data = new SData {Id = Sqlite3.sqlite3_column_int(stmt, 0)};
data.Id = Sqlite3.sqlite3_column_int(stmt, 0);
byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1); byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1);
if (bytes != null) data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone";
data.Str1 = utf8.GetString(Encoding.Convert(cp1252, utf8, bytes));
else
data.Str1 = "Someone";
if (dateExists) if (dateExists)
data.Ticks = _UnixTimeToTicks(Sqlite3.sqlite3_column_int(stmt, 2)); data.Ticks = _UnixTimeToTicks(Sqlite3.sqlite3_column_int(stmt, 2));
@@ -915,7 +858,7 @@ namespace Vocaluxe.Base
return true; return true;
} }
private static bool _ImportData(string sourceDBPath, string destinationDBPath) private static bool _ImportData(string sourceDBPath)
{ {
#region open db #region open db
using (SQLiteConnection connSource = new SQLiteConnection()) using (SQLiteConnection connSource = new SQLiteConnection())
@@ -935,11 +878,9 @@ namespace Vocaluxe.Base
using (SQLiteCommand cmdSource = new SQLiteCommand(connSource)) using (SQLiteCommand cmdSource = new SQLiteCommand(connSource))
{ {
SQLiteDataReader source;
#region import table scores #region import table scores
cmdSource.CommandText = "SELECT SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty FROM Scores"; cmdSource.CommandText = "SELECT SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty FROM Scores";
source = cmdSource.ExecuteReader(); SQLiteDataReader source = cmdSource.ExecuteReader();
if (source == null) if (source == null)
return false; return false;
@@ -987,8 +928,7 @@ namespace Vocaluxe.Base
if (_ConnectionCover == null) if (_ConnectionCover == null)
{ {
_ConnectionCover = new SQLiteConnection(); _ConnectionCover = new SQLiteConnection {ConnectionString = "Data Source=" + _CoverFilePath};
_ConnectionCover.ConnectionString = "Data Source=" + _CoverFilePath;
_ConnectionCover.Open(); _ConnectionCover.Open();
} }
@@ -1247,6 +1187,13 @@ namespace Vocaluxe.Base
reader.Read(); reader.Read();
byte[] data = _GetBytes(reader); byte[] data = _GetBytes(reader);
tex = CDraw.AddTexture(w, h, ref data); tex = CDraw.AddTexture(w, h, ref data);
/*using (Bitmap bmp = new Bitmap(w, h))
{
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Marshal.Copy(data, 0, bmpData.Scan0, w * h * 4);
bmp.UnlockBits(bmpData);
bmp.Save(fileName);
}*/
} }
} }
@@ -1259,6 +1206,7 @@ namespace Vocaluxe.Base
} }
//If you want to add an image to db, call this method! //If you want to add an image to db, call this method!
/*
private static bool _AddImageToCreditsDB(String imagePath) private static bool _AddImageToCreditsDB(String imagePath)
{ {
bool result = false; bool result = false;
@@ -1332,6 +1280,7 @@ namespace Vocaluxe.Base
return result; return result;
} }
*/
private static bool _InitCreditsRessourcesDB() private static bool _InitCreditsRessourcesDB()
{ {
@@ -1387,6 +1336,7 @@ namespace Vocaluxe.Base
return true; return true;
} }
/*
private static void _CreateCreditsRessourcesDB() private static void _CreateCreditsRessourcesDB()
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (SQLiteConnection connection = new SQLiteConnection())
@@ -1421,16 +1371,17 @@ namespace Vocaluxe.Base
} }
} }
} }
*/
#endregion CreditsRessources #endregion CreditsRessources
private static byte[] _GetBytes(SQLiteDataReader reader) private static byte[] _GetBytes(SQLiteDataReader reader)
{ {
const int chunkSize = 2 * 1024; const int chunkSize = 2 * 1024;
byte[] buffer = new byte[chunkSize]; byte[] buffer = new byte[chunkSize];
long bytesRead;
long fieldOffset = 0; long fieldOffset = 0;
using (MemoryStream stream = new MemoryStream()) using (MemoryStream stream = new MemoryStream())
{ {
long bytesRead;
while ((bytesRead = reader.GetBytes(0, fieldOffset, buffer, 0, buffer.Length)) > 0) while ((bytesRead = reader.GetBytes(0, fieldOffset, buffer, 0, buffer.Length)) > 0)
{ {
byte[] actualRead = new byte[bytesRead]; byte[] actualRead = new byte[bytesRead];
+21 -2
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
@@ -255,7 +274,7 @@ namespace Vocaluxe.Base
if (rect.Height <= 0f) if (rect.Height <= 0f)
return; return;
CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, aspect); CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, aspect);
DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, staticBounds.Rect.Z), DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, staticBounds.Rect.Z),
texture.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false); texture.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false);
} }
+50 -66
View File
@@ -1,9 +1,29 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; 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;
@@ -20,15 +40,14 @@ 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)
{ {
_Sizeh = maxHigh; _Sizeh = maxHigh;
float outline = CFonts.Outline; float outline = CFonts.Outline;
TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix; const TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix;
float factor = _GetFactor(chr, flags); float factor = _GetFactor(chr, flags);
CFonts.Height = Sizeh * factor; CFonts.Height = Sizeh * factor;
@@ -91,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();
} }
@@ -139,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)
{ {
@@ -322,37 +340,17 @@ namespace Vocaluxe.Base
public static float Height public static float Height
{ {
get { return _Height; } get { return _Height; }
set set { _Height = value < 0f ? 0f : value; }
{
if (value < 0f)
_Height = 0f;
else
_Height = value;
}
} }
public static float Outline public static float Outline
{ {
get { return _Fonts[_CurrentFont].Outline; } get { return _Fonts[_CurrentFont].Outline; }
set
{
SFont font = _Fonts[_CurrentFont];
font.Outline = value;
if (font.Outline < 0f)
font.Outline = 0f;
if (font.Outline > 1f)
font.Outline = 1f;
}
} }
public static SColorF OutlineColor public static SColorF OutlineColor
{ {
get { return _Fonts[_CurrentFont].OutlineColor; } get { return _Fonts[_CurrentFont].OutlineColor; }
set
{
SFont font = _Fonts[_CurrentFont];
font.OutlineColor = value;
}
} }
public static void Init() public static void Init()
@@ -412,7 +410,7 @@ namespace Vocaluxe.Base
if (h <= 0f) if (h <= 0f)
return; return;
if (text.Length == 0) if (text == "")
return; return;
Height = h; Height = h;
@@ -431,7 +429,7 @@ namespace Vocaluxe.Base
if (h <= 0f) if (h <= 0f)
return; return;
if (text.Length == 0) if (text == "")
return; return;
Height = h; Height = h;
@@ -450,7 +448,7 @@ namespace Vocaluxe.Base
if (h <= 0f) if (h <= 0f)
return; return;
if (text.Length == 0) if (text == "")
return; return;
Height = h; Height = h;
@@ -506,7 +504,7 @@ namespace Vocaluxe.Base
public static void SetFont(string fontName) public static void SetFont(string fontName)
{ {
int index = -1; int index;
if (PartyModeID != -1) if (PartyModeID != -1)
{ {
@@ -551,77 +549,63 @@ 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)
{ {
string value = string.Empty; string value = string.Empty;
int i = 1; int i = 1;
while (xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Folder", ref value, value)) while (xmlReader.GetValue("//root/Fonts/Font" + i + "/Folder", out value, value))
{ {
SFont sf = new SFont(); SFont sf = new SFont {Folder = value, IsThemeFont = themeName != "", ThemeName = themeName, PartyModeID = partyModeId};
sf.Folder = value;
sf.IsThemeFont = themeName.Length > 0;
sf.ThemeName = themeName;
sf.PartyModeID = partyModeId;
bool ok = true; bool ok = true;
string name = String.Empty; string name;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Name", ref name, value); ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/Name", out name, value);
sf.Name = name; sf.Name = name;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileNormal", ref value, value); ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/FileNormal", out value, value);
sf.FileNormal = value; sf.FileNormal = value;
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value)); value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
CFont f = new CFont(value); CFont f = new CFont(value);
sf.Normal = f; sf.Normal = f;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileItalic", ref value, value); ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/FileItalic", out value, value);
sf.FileItalic = value; sf.FileItalic = value;
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value)); value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
f = new CFont(value); f = new CFont(value);
sf.Italic = f; sf.Italic = f;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileBold", ref value, value); ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/FileBold", out value, value);
sf.FileBold = value; sf.FileBold = value;
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value)); value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
f = new CFont(value); f = new CFont(value);
sf.Bold = f; sf.Bold = f;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileBoldItalic", ref value, value); ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/FileBoldItalic", out value, value);
sf.FileBoldItalic = value; sf.FileBoldItalic = value;
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value)); value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
f = new CFont(value); f = new CFont(value);
sf.BoldItalic = f; sf.BoldItalic = f;
sf.Outline = 0f; sf.Outline = 0f;
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/Outline", ref sf.Outline); ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i + "/Outline", ref sf.Outline);
sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f); sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/OutlineColorR", ref sf.OutlineColor.R); ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i + "/OutlineColorR", ref sf.OutlineColor.R);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/OutlineColorG", ref sf.OutlineColor.G); ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i + "/OutlineColorG", ref sf.OutlineColor.G);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/OutlineColorB", ref sf.OutlineColor.B); ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i + "/OutlineColorB", ref sf.OutlineColor.B);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/OutlineColorA", ref sf.OutlineColor.A); ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i + "/OutlineColorA", ref sf.OutlineColor.A);
if (ok) if (ok)
_Fonts.Add(sf); _Fonts.Add(sf);
@@ -630,11 +614,11 @@ namespace Vocaluxe.Base
string fontTypes; string fontTypes;
if (partyModeId >= 0) if (partyModeId >= 0)
fontTypes = "theme fonts for party mode"; fontTypes = "theme fonts for party mode";
else if (themeName.Length > 0) else if (themeName != "")
fontTypes = "theme fonts for theme \"" + themeName + "\""; fontTypes = "theme fonts for theme \"" + themeName + "\"";
else else
fontTypes = "basic fonts"; fontTypes = "basic fonts";
CLog.LogError("Error loading " + fontTypes + ": Error in Font" + i.ToString()); CLog.LogError("Error loading " + fontTypes + ": Error in Font" + i);
} }
i++; i++;
} }
@@ -696,7 +680,7 @@ namespace Vocaluxe.Base
setStart = true; setStart = true;
} }
writer.WriteStartElement("Font" + fontNr.ToString()); writer.WriteStartElement("Font" + fontNr);
writer.WriteElementString("Name", _Fonts[index].Name); writer.WriteElementString("Name", _Fonts[index].Name);
writer.WriteElementString("Folder", _Fonts[index].Folder); writer.WriteElementString("Folder", _Fonts[index].Folder);
@@ -746,7 +730,7 @@ namespace Vocaluxe.Base
private static int _GetFontIndex(string themeName, string fontName) private static int _GetFontIndex(string themeName, string fontName)
{ {
if (themeName.Length == 0 || fontName.Length == 0) if (themeName == "" || fontName == "")
return -1; return -1;
for (int i = 0; i < _Fonts.Count; i++) for (int i = 0; i < _Fonts.Count; i++)
@@ -760,7 +744,7 @@ namespace Vocaluxe.Base
private static int _GetFontIndexParty(int partyModeID, string fontName) private static int _GetFontIndexParty(int partyModeID, string fontName)
{ {
if (partyModeID == -1 || fontName.Length == 0) if (partyModeID == -1 || fontName == "")
return -1; return -1;
for (int i = 0; i < _Fonts.Count; i++) for (int i = 0; i < _Fonts.Count; i++)
@@ -774,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++)
{ {
+89 -97
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Vocaluxe.GameModes; using Vocaluxe.GameModes;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -10,14 +29,8 @@ namespace Vocaluxe.Base
static class CGame static class CGame
{ {
private static IGameMode _GameMode; private static IGameMode _GameMode;
private static SPlayer[] _Player;
private static int _NumPlayer = CConfig.NumPlayer; private static int _NumPlayer = CConfig.NumPlayer;
private static float _Beat;
private static int _CurrentBeat;
private static float _MidBeatD;
private static int _CurrentBeatD;
private static int _OldBeatD; private static int _OldBeatD;
private static readonly Random _Rand = new Random(); private static readonly Random _Rand = new Random();
@@ -39,36 +52,21 @@ namespace Vocaluxe.Base
return 0f; return 0f;
} }
public static int CurrentBeat public static int CurrentBeat { get; private set; }
{
get { return _CurrentBeat; }
}
public static float Beat public static float Beat { get; private set; }
{
get { return _Beat; }
}
public static float MidBeatD public static float MidBeatD { get; private set; }
{
get { return _MidBeatD; }
}
public static int ActBeatD public static int ActBeatD { get; private set; }
{
get { return _CurrentBeatD; }
}
public static SPlayer[] Player public static SPlayer[] Players { get; private set; }
{
get { return _Player; }
}
public static void Init() public static void Init()
{ {
_GameMode = new CGameModeNormal(); _GameMode = new CGameModeNormal();
_GameMode.Init(); _GameMode.Init();
_Player = new SPlayer[CSettings.MaxNumPlayer]; Players = new SPlayer[CSettings.MaxNumPlayer];
ResetPlayer(); ResetPlayer();
CConfig.UsePlayers(); CConfig.UsePlayers();
@@ -117,12 +115,12 @@ namespace Vocaluxe.Base
public static void Start() public static void Start()
{ {
_GameMode.Start(_Player); _GameMode.Start(Players);
} }
public static void NextRound() public static void NextRound()
{ {
_GameMode.NextRound(_Player); _GameMode.NextRound(Players);
} }
public static bool IsFinished() public static bool IsFinished()
@@ -177,63 +175,61 @@ namespace Vocaluxe.Base
public static void ResetPlayer() public static void ResetPlayer()
{ {
for (int i = 0; i < _Player.Length; i++) for (int i = 0; i < Players.Length; i++)
{ {
_Player[i].Points = 0f; Players[i].Points = 0f;
_Player[i].PointsLineBonus = 0f; Players[i].PointsLineBonus = 0f;
_Player[i].PointsGoldenNotes = 0f; Players[i].PointsGoldenNotes = 0f;
_Player[i].LineNr = 0; Players[i].LineNr = 0;
_Player[i].NoteDiff = 0; Players[i].NoteDiff = 0;
_Player[i].SingLine = new List<CLine>(); Players[i].SingLine = new List<CLine>();
_Player[i].CurrentLine = -1; Players[i].CurrentLine = -1;
_Player[i].CurrentNote = -1; Players[i].CurrentNote = -1;
_Player[i].SongID = -1; Players[i].SongID = -1;
_Player[i].Medley = false; Players[i].Medley = false;
_Player[i].Duet = false; Players[i].Duet = false;
_Player[i].ShortSong = false; Players[i].ShortSong = false;
_Player[i].DateTicks = DateTime.Now.Ticks; Players[i].DateTicks = DateTime.Now.Ticks;
_Player[i].SongFinished = false; Players[i].SongFinished = false;
} }
_OldBeatD = -100; _OldBeatD = -100;
_Beat = -100; Beat = -100;
_CurrentBeat = -100; CurrentBeat = -100;
_CurrentBeatD = -100; ActBeatD = -100;
} }
public static void UpdatePoints(float time) public static void UpdatePoints(float time)
{ {
bool debugHit = false;
CSong song = _GameMode.GetSong(); CSong song = _GameMode.GetSong();
if (song == null) if (song == null)
return; return;
float b = GetBeatFromTime(time, song.BPM, song.Gap); float b = GetBeatFromTime(time, song.BPM, song.Gap);
if (b <= _Beat) if (b <= Beat)
return; return;
_Beat = b; Beat = b;
_CurrentBeat = (int)Math.Floor(_Beat); CurrentBeat = (int)Math.Floor(Beat);
_MidBeatD = -0.5f + GetBeatFromTime(time, song.BPM, song.Gap + CConfig.MicDelay / 1000f); MidBeatD = -0.5f + GetBeatFromTime(time, song.BPM, song.Gap + CConfig.MicDelay / 1000f);
_CurrentBeatD = (int)Math.Floor(_MidBeatD); ActBeatD = (int)Math.Floor(MidBeatD);
for (int p = 0; p < _NumPlayer; p++) for (int p = 0; p < _NumPlayer; p++)
CSound.AnalyzeBuffer(p); CSound.AnalyzeBuffer(p);
if (_OldBeatD >= _CurrentBeatD) if (_OldBeatD >= ActBeatD)
return; return;
for (int p = 0; p < _NumPlayer; p++) for (int p = 0; p < _NumPlayer; p++)
{ {
for (int beat = _OldBeatD + 1; beat <= _CurrentBeatD; beat++) for (int beat = _OldBeatD + 1; beat <= ActBeatD; beat++)
{ {
if ((_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_MEDLEY && song.Medley.EndBeat == beat) || if ((_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_MEDLEY && song.Medley.EndBeat == beat) ||
(_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat)) (_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat))
_Player[p].SongFinished = true; Players[p].SongFinished = true;
CLine[] lines = song.Notes.GetLines(_Player[p].LineNr).Line; CLine[] lines = song.Notes.GetVoice(Players[p].LineNr).Lines;
int line = -1; int line = -1;
for (int j = 0; j < lines.Length; j++) for (int j = 0; j < lines.Length; j++)
@@ -245,15 +241,15 @@ namespace Vocaluxe.Base
} }
} }
if (line >= 0) if (line < 0)
{ continue;
if (line != _Player[p].CurrentLine) if (line != Players[p].CurrentLine)
_Player[p].CurrentNote = -1; Players[p].CurrentNote = -1;
_Player[p].CurrentLine = line; Players[p].CurrentLine = line;
while (_Player[p].SingLine.Count <= line) while (Players[p].SingLine.Count <= line)
_Player[p].SingLine.Add(new CLine()); Players[p].SingLine.Add(new CLine());
CNote[] notes = lines[line].Notes; CNote[] notes = lines[line].Notes;
int note = -1; int note = -1;
@@ -268,18 +264,18 @@ namespace Vocaluxe.Base
if (note >= 0) if (note >= 0)
{ {
_Player[p].CurrentNote = note; Players[p].CurrentNote = note;
if (line == lines.Length - 1) if (line == lines.Length - 1)
{ {
if (note == lines[line].NoteCount - 1) if (note == lines[line].NoteCount - 1)
{ {
if (notes[note].EndBeat == beat) if (notes[note].EndBeat == beat)
_Player[p].SongFinished = true; Players[p].SongFinished = true;
} }
} }
if (notes[note].PointsForBeat > 0 && (CSound.RecordToneValid(p) || debugHit)) if (notes[note].PointsForBeat > 0 && CSound.RecordToneValid(p))
{ {
int tone = notes[note].Tone; int tone = notes[note].Tone;
int tonePlayer = CSound.RecordGetTone(p); int tonePlayer = CSound.RecordGetTone(p);
@@ -290,59 +286,56 @@ namespace Vocaluxe.Base
while (tonePlayer - tone < -6) while (tonePlayer - tone < -6)
tonePlayer += 12; tonePlayer += 12;
if (debugHit) Players[p].NoteDiff = Math.Abs(tone - tonePlayer);
tonePlayer = tone; bool hit = Players[p].NoteDiff <= (2 - (int)CProfiles.GetDifficulty(Players[p].ProfileID));
_Player[p].NoteDiff = Math.Abs(tone - tonePlayer);
bool hit = _Player[p].NoteDiff <= (2 - (int)_Player[p].Difficulty);
if (hit) if (hit)
{ {
// valid // valid
//CSound.RecordSetTone(p, Tone); //CSound.RecordSetTone(p, Tone);
double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat / double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat /
song.Notes.GetLines(_Player[p].LineNr).Points; song.Notes.GetVoice(Players[p].LineNr).Points;
if (notes[note].NoteType == ENoteType.Golden) if (notes[note].NoteType == ENoteType.Golden)
_Player[p].PointsGoldenNotes += points; Players[p].PointsGoldenNotes += points;
_Player[p].Points += points; Players[p].Points += points;
// update player notes (sung notes) // update player notes (sung notes)
if (_Player[p].SingLine[line].NoteCount > 0) if (Players[p].SingLine[line].NoteCount > 0)
{ {
CNote nt = _Player[p].SingLine[line].LastNote; CNote lastNote = Players[p].SingLine[line].LastNote;
if (notes[note].StartBeat == beat || nt.EndBeat + 1 != beat || nt.Tone != tone || !nt.Hit) if (notes[note].StartBeat == beat || lastNote.EndBeat + 1 != beat || lastNote.Tone != tone || !lastNote.Hit)
_Player[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType)); Players[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType));
else else
_Player[p].SingLine[line].IncLastNoteLength(); Players[p].SingLine[line].IncLastNoteLength();
} }
else else
_Player[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType)); Players[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType));
_Player[p].SingLine[line].LastNote.IsPerfect(notes[note]); Players[p].SingLine[line].LastNote.IsPerfect(notes[note]);
_Player[p].SingLine[line].IsPerfect(lines[line]); Players[p].SingLine[line].IsPerfect(lines[line]);
} }
else else
{ {
if (_Player[p].SingLine[line].NoteCount > 0) if (Players[p].SingLine[line].NoteCount > 0)
{ {
CNote nt = _Player[p].SingLine[line].LastNote; CNote lastNote = Players[p].SingLine[line].LastNote;
if (nt.Tone == tonePlayer && nt.EndBeat + 1 == beat && !nt.Hit) if (lastNote.Tone == tonePlayer && lastNote.EndBeat + 1 == beat && !lastNote.Hit)
_Player[p].SingLine[line].IncLastNoteLength(); Players[p].SingLine[line].IncLastNoteLength();
else else
_Player[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle)); Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle));
} }
else else
_Player[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle)); Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle));
} }
} }
// Line Bonus // Line Bonus
int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(_Player[p].LineNr); int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(Players[p].LineNr);
if (note == lines[line].NoteCount - 1 && numLinesWithPoints > 0) if (note == lines[line].NoteCount - 1 && numLinesWithPoints > 0)
{ {
if (notes[note].EndBeat == beat && lines[line].Points > 0f) if (notes[note].EndBeat == beat && lines[line].Points > 0f)
{ {
double factor = _Player[p].SingLine[line].Points / (double)lines[line].Points; double factor = Players[p].SingLine[line].Points / (double)lines[line].Points;
if (factor < 0.4) if (factor < 0.4)
factor = 0.0; factor = 0.0;
else if (factor > 0.9) else if (factor > 0.9)
@@ -355,15 +348,14 @@ namespace Vocaluxe.Base
} }
double points = CSettings.LinebonusScore * factor * 1f / numLinesWithPoints; double points = CSettings.LinebonusScore * factor * 1f / numLinesWithPoints;
_Player[p].Points += points; Players[p].Points += points;
_Player[p].PointsLineBonus += points; Players[p].PointsLineBonus += points;
} }
} }
} }
} }
} }
} _OldBeatD = ActBeatD;
_OldBeatD = _CurrentBeatD;
} }
} }
} }
+72 -141
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
@@ -9,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;
@@ -103,7 +114,7 @@ namespace Vocaluxe.Base
if (Math.Abs(_Cursor.Rect.X - x) > CSettings.MouseMoveDiffMin || if (Math.Abs(_Cursor.Rect.X - x) > CSettings.MouseMoveDiffMin ||
Math.Abs(_Cursor.Rect.Y - y) > CSettings.MouseMoveDiffMin) Math.Abs(_Cursor.Rect.Y - y) > CSettings.MouseMoveDiffMin)
{ {
if (_CursorTargetAlpha == 0f) if (_CursorTargetAlpha < 0.01)
_Fade(1f, 0.2f); _Fade(1f, 0.2f);
_Movetimer.Reset(); _Movetimer.Reset();
@@ -254,41 +265,41 @@ namespace Vocaluxe.Base
CLog.StopBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]); CLog.StopBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
} }
for (int i = 0; i < _PopupScreens.Count; i++) foreach (IMenu popup in _PopupScreens)
{ {
_PopupScreens[i].Init(); popup.Init();
_PopupScreens[i].LoadTheme(CTheme.GetThemeScreensPath(-1)); popup.LoadTheme(CTheme.GetThemeScreensPath(-1));
} }
} }
public static void ReloadTheme() public static void ReloadTheme()
{ {
_ReloadCursor(); _ReloadCursor();
for (int i = 0; i < _Screens.Count; i++) foreach (IMenu screen in _Screens)
_Screens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1)); screen.ReloadTheme(CTheme.GetThemeScreensPath(-1));
for (int i = 0; i < _PopupScreens.Count; i++) foreach (IMenu popup in _PopupScreens)
_PopupScreens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1)); popup.ReloadTheme(CTheme.GetThemeScreensPath(-1));
} }
public static void ReloadSkin() public static void ReloadSkin()
{ {
_ReloadCursor(); _ReloadCursor();
for (int i = 0; i < _Screens.Count; i++) foreach (IMenu menu in _Screens)
_Screens[i].ReloadTextures(); menu.ReloadTextures();
for (int i = 0; i < _PopupScreens.Count; i++) foreach (IMenu menu in _PopupScreens)
_PopupScreens[i].ReloadTextures(); menu.ReloadTextures();
} }
public static void SaveTheme() public static void SaveTheme()
{ {
CTheme.SaveTheme(); CTheme.SaveTheme();
for (int i = 0; i < _Screens.Count; i++) foreach (IMenu screen in _Screens)
_Screens[i].SaveTheme(); screen.SaveTheme();
for (int i = 0; i < _PopupScreens.Count; i++) foreach (IMenu popup in _PopupScreens)
_PopupScreens[i].SaveTheme(); popup.SaveTheme();
} }
public static void InitFirstScreen() public static void InitFirstScreen()
@@ -393,7 +404,7 @@ namespace Vocaluxe.Base
GC.Collect(); GC.Collect();
_CurrentScreen = _NextScreen; _CurrentScreen = _NextScreen;
_NextScreen = EScreens.ScreenNull; _NextScreen = EScreens.ScreenNull;
if (CBackgroundMusic.Playing) if (CBackgroundMusic.IsPlaying)
CBackgroundMusic.Play(); CBackgroundMusic.Play();
_Screens[(int)_CurrentScreen].OnShowFinish(); _Screens[(int)_CurrentScreen].OnShowFinish();
_Screens[(int)_CurrentScreen].ProcessMouseMove(_Cursor.X, _Cursor.Y); _Screens[(int)_CurrentScreen].ProcessMouseMove(_Cursor.X, _Cursor.Y);
@@ -425,8 +436,8 @@ namespace Vocaluxe.Base
_OldScreen = _Screens[(int)_CurrentScreen]; _OldScreen = _Screens[(int)_CurrentScreen];
} }
for (int i = 0; i < _PopupScreens.Count; i++) foreach (IMenu popup in _PopupScreens)
_PopupScreens[i].Draw(); popup.Draw();
_Cursor.Draw(); _Cursor.Draw();
_DrawDebugInfos(); _DrawDebugInfos();
@@ -499,7 +510,7 @@ namespace Vocaluxe.Base
bool resume = true; bool resume = true;
bool eventsAvailable = false; bool eventsAvailable;
bool inputEventsAvailable = CInput.PollKeyEvent(ref inputKeyEvent); bool inputEventsAvailable = CInput.PollKeyEvent(ref inputKeyEvent);
while ((eventsAvailable = keys.PollEvent(ref keyEvent)) || inputEventsAvailable) while ((eventsAvailable = keys.PollEvent(ref keyEvent)) || inputEventsAvailable)
@@ -524,15 +535,15 @@ namespace Vocaluxe.Base
if (popupPlayerControlAllowed && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON) if (popupPlayerControlAllowed && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
{ {
if (keyEvent.Key == Keys.MediaNextTrack) if (keyEvent.Key == Keys.MediaNextTrack)
CMain.BackgroundMusic.Next(); CBackgroundMusic.Next();
else if (keyEvent.Key == Keys.MediaPreviousTrack) else if (keyEvent.Key == Keys.MediaPreviousTrack)
CMain.BackgroundMusic.Previous(); CBackgroundMusic.Previous();
else if (keyEvent.Key == Keys.MediaPlayPause) else if (keyEvent.Key == Keys.MediaPlayPause)
{ {
if (CMain.BackgroundMusic.IsPlaying()) if (CBackgroundMusic.IsPlaying)
CMain.BackgroundMusic.Pause(); CBackgroundMusic.Pause();
else else
CMain.BackgroundMusic.Play(); CBackgroundMusic.Play();
} }
} }
@@ -582,7 +593,7 @@ namespace Vocaluxe.Base
_VolumePopupTimer.Start(); _VolumePopupTimer.Start();
} }
CMain.BackgroundMusic.ApplyVolume(); CBackgroundMusic.ApplyVolume();
} }
if (keyEvent.ModShift && (keyEvent.Key == Keys.F1)) if (keyEvent.ModShift && (keyEvent.Key == Keys.F1))
@@ -727,125 +738,46 @@ namespace Vocaluxe.Base
private static void _DrawDebugInfos() private static void _DrawDebugInfos()
{ {
string txt = String.Empty; if (CConfig.DebugLevel == EDebugLevel.TR_CONFIG_OFF)
CFonts.Style = EStyle.Normal; return;
CFonts.SetFont("Normal");
SColorF gray = new SColorF(1f, 1f, 1f, 0.5f);
float dy = 0; List<String> debugOutput = new List<string> {CTime.GetFPS().ToString("FPS: 000")};
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_ONLY_FPS)
{
txt = CTime.GetFPS().ToString("FPS: 000");
CFonts.Height = 30f;
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height;
}
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
{
txt = CSound.GetStreamCount().ToString(CLanguage.Translate("TR_DEBUG_AUDIO_STREAMS") + ": 00");
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height;
}
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
{
txt = CVideo.GetNumStreams().ToString(CLanguage.Translate("TR_DEBUG_VIDEO_STREAMS") + ": 00");
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height;
}
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
{
txt = CDraw.TextureCount().ToString(CLanguage.Translate("TR_DEBUG_TEXTURES") + ": 00000");
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height;
}
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1) if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
{ {
debugOutput.Add(CSound.GetStreamCount().ToString(CLanguage.Translate("TR_DEBUG_AUDIO_STREAMS") + ": 00"));
debugOutput.Add(CVideo.GetNumStreams().ToString(CLanguage.Translate("TR_DEBUG_VIDEO_STREAMS") + ": 00"));
debugOutput.Add(CDraw.TextureCount().ToString(CLanguage.Translate("TR_DEBUG_TEXTURES") + ": 00000"));
long memory = GC.GetTotalMemory(false); long memory = GC.GetTotalMemory(false);
txt = (memory / 1000000L).ToString(CLanguage.Translate("TR_DEBUG_MEMORY") + ": 00000 MB"); debugOutput.Add((memory / 1000000L).ToString(CLanguage.Translate("TR_DEBUG_MEMORY") + ": 00000 MB"));
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height;
}
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2) if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2)
{ {
txt = CSound.RecordGetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00"); debugOutput.Add(CSound.RecordGetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00"));
debugOutput.Add(CSound.RecordGetMaxVolume(0).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P1: 0.000"));
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt)); debugOutput.Add(CSound.RecordGetToneAbs(1).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P2: 00"));
debugOutput.Add(CSound.RecordGetMaxVolume(1).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P2: 0.000"));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height;
txt = CSound.RecordGetMaxVolume(0).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P1: 0.000");
rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height;
txt = CSound.RecordGetToneAbs(1).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P2: 00");
rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height;
txt = CSound.RecordGetMaxVolume(1).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P2: 0.000");
rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height;
}
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3) if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3)
{ {
txt = CSongs.NumSongsWithCoverLoaded.ToString(CLanguage.Translate("TR_DEBUG_SONGS") + ": 00000"); debugOutput.Add(CSongs.NumSongsWithCoverLoaded.ToString(CLanguage.Translate("TR_DEBUG_SONGS") + ": 00000"));
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height;
}
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL_MAX) if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL_MAX)
debugOutput.Add(_Cursor.X.ToString(CLanguage.Translate("TR_DEBUG_MOUSE") + " : (0000/") + _Cursor.Y.ToString("0000)"));
}
}
}
CFonts.Style = EStyle.Normal;
CFonts.SetFont("Normal");
CFonts.Height = 30;
SColorF gray = new SColorF(1f, 1f, 1f, 0.5f);
float y = 0;
foreach (string txt in debugOutput)
{ {
txt = _Cursor.X.ToString(CLanguage.Translate("TR_DEBUG_MOUSE") + " : (0000/") + _Cursor.Y.ToString("0000)"); RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), y, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear)); CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear); CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
dy += rect.Height; y += rect.Height;
} }
} }
@@ -853,10 +785,9 @@ namespace Vocaluxe.Base
{ {
_Cursor.UnloadTextures(); _Cursor.UnloadTextures();
if (CTheme.Cursor.Color.Length > 0) if (CTheme.Cursor.Color != "")
{ {
SColorF color; SColorF color = CTheme.GetColor(CTheme.Cursor.Color, -1);
color = CTheme.GetColor(CTheme.Cursor.Color, -1);
CTheme.Cursor.R = color.R; CTheme.Cursor.R = color.R;
CTheme.Cursor.G = color.G; CTheme.Cursor.G = color.G;
CTheme.Cursor.B = color.B; CTheme.Cursor.B = color.B;
+24 -5
View File
@@ -1,4 +1,23 @@
using Vocaluxe.Lib.Input; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using Vocaluxe.Lib.Input;
using Vocaluxe.Lib.Input.WiiMote; using Vocaluxe.Lib.Input.WiiMote;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -21,14 +40,14 @@ namespace Vocaluxe.Base
_Input = null; _Input = null;
} }
public static bool Connect() public static void Connect()
{ {
return _Input.Connect(); _Input.Connect();
} }
public static bool Disconnect() public static void Disconnect()
{ {
return _Input.Disconnect(); _Input.Disconnect();
} }
public static bool IsConnected() public static bool IsConnected()
+33 -25
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
@@ -44,7 +63,7 @@ namespace Vocaluxe.Base
return _Languages[lang].Name; return _Languages[lang].Name;
} }
public static string[] GetLanguageNames() public static IEnumerable<string> GetLanguageNames()
{ {
string[] languages = new string[_Languages.Count]; string[] languages = new string[_Languages.Count];
@@ -89,12 +108,7 @@ namespace Vocaluxe.Base
return -1; return -1;
} }
public static string Translate(string keyWord) public static string Translate(string keyWord, int partyModeID = -1)
{
return Translate(keyWord, -1);
}
public static string Translate(string keyWord, int partyModeID)
{ {
if (keyWord == null) if (keyWord == null)
return "Error"; return "Error";
@@ -162,15 +176,15 @@ namespace Vocaluxe.Base
return true; return true;
} }
private static bool _LoadLanguageEntries(CXMLReader xmlReader, ref Dictionary<string, string> texts) private static bool _LoadLanguageEntries(CXMLReader xmlReader, out Dictionary<string, string> texts)
{ {
texts = new Dictionary<string, string>(); texts = new Dictionary<string, string>();
List<string> names = xmlReader.GetAttributes("resources", "name"); IEnumerable<string> names = xmlReader.GetAttributes("resources", "name");
string value = string.Empty;
foreach (string name in names) foreach (string name in names)
{ {
if (xmlReader.GetValue("//resources/string[@name='" + name + "']", ref value, "")) string value;
{ if (!xmlReader.GetValue("//resources/string[@name='" + name + "']", out value, ""))
continue;
try try
{ {
texts.Add(name, value); texts.Add(name, value);
@@ -181,7 +195,6 @@ namespace Vocaluxe.Base
return false; return false;
} }
} }
}
return true; return true;
} }
@@ -192,39 +205,34 @@ namespace Vocaluxe.Base
return false; return false;
string value = string.Empty; string value = string.Empty;
if (xmlReader.GetValue("//resources/string[@name='language']", ref value, value)) if (xmlReader.GetValue("//resources/string[@name='language']", out value, value))
{ {
int nr = GetLanguageNr(value); int nr = GetLanguageNr(value);
if (nr == -1) if (nr == -1)
return true; return true;
SPartyLanguage lang = new SPartyLanguage(); SPartyLanguage lang = new SPartyLanguage {PartyModeID = partyModeID};
lang.PartyModeID = partyModeID; if (!_LoadLanguageEntries(xmlReader, out lang.Texts))
if (!_LoadLanguageEntries(xmlReader, ref lang.Texts))
return false; return false;
_Languages[nr].PartyModeTexts.Add(lang); _Languages[nr].PartyModeTexts.Add(lang);
return true; return true;
} }
else
{
CLog.LogError("Error reading Party Language File " + file); CLog.LogError("Error reading Party Language File " + file);
return false; return false;
} }
}
private static void _LoadLanguageFile(string fileName) private static void _LoadLanguageFile(string fileName)
{ {
SLanguage lang = new SLanguage(); SLanguage lang = new SLanguage {LanguageFilePath = Path.Combine(CSettings.FolderLanguages, fileName)};
lang.LanguageFilePath = Path.Combine(CSettings.FolderLanguages, fileName);
CXMLReader xmlReader = CXMLReader.OpenFile(lang.LanguageFilePath); CXMLReader xmlReader = CXMLReader.OpenFile(lang.LanguageFilePath);
if (xmlReader == null) if (xmlReader == null)
return; return;
string value = string.Empty; string value = string.Empty;
if (xmlReader.GetValue("//resources/string[@name='language']", ref value, value)) if (xmlReader.GetValue("//resources/string[@name='language']", out value, value))
{ {
lang.Name = value; lang.Name = value;
@@ -233,7 +241,7 @@ namespace Vocaluxe.Base
lang.PartyModeTexts = new List<SPartyLanguage>(); lang.PartyModeTexts = new List<SPartyLanguage>();
_LoadLanguageEntries(xmlReader, ref lang.Texts); _LoadLanguageEntries(xmlReader, out lang.Texts);
_Languages.Add(lang); _Languages.Add(lang);
} }
+32 -15
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Text; using System.Text;
@@ -17,6 +36,15 @@ namespace Vocaluxe.Base
_LogFileName = fileName; _LogFileName = fileName;
} }
private void _Open()
{
_LogFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, _LogFileName), false, Encoding.UTF8);
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
_LogFile.WriteLine("----------------------------------------");
_LogFile.WriteLine();
}
public void Close() public void Close()
{ {
if (_LogFile == null) if (_LogFile == null)
@@ -34,22 +62,11 @@ namespace Vocaluxe.Base
if (_LogFile == null) if (_LogFile == null)
_Open(); _Open();
try // ReSharper disable PossibleNullReferenceException
{
_LogFile.WriteLine(text); _LogFile.WriteLine(text);
// ReSharper restore PossibleNullReferenceException
_LogFile.Flush(); _LogFile.Flush();
} }
catch (Exception) {}
}
private void _Open()
{
_LogFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, _LogFileName), false, Encoding.UTF8);
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
_LogFile.WriteLine("----------------------------------------");
_LogFile.WriteLine();
}
public void Dispose() public void Dispose()
{ {
@@ -139,7 +156,7 @@ namespace Vocaluxe.Base
space += " "; space += " ";
float ms; float ms;
if (Stopwatch.IsHighResolution && _NanosecPerTick != 0.0) if (Stopwatch.IsHighResolution && _NanosecPerTick > 0)
ms = (float)((_NanosecPerTick * _BenchmarkTimer[benchmarkNr].ElapsedTicks) / (1000.0 * 1000.0)); ms = (float)((_NanosecPerTick * _BenchmarkTimer[benchmarkNr].ElapsedTicks) / (1000.0 * 1000.0));
else else
ms = _BenchmarkTimer[benchmarkNr].ElapsedMilliseconds; ms = _BenchmarkTimer[benchmarkNr].ElapsedMilliseconds;
+60 -49
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -8,31 +27,30 @@ namespace Vocaluxe.Base
{ {
static class CMain static class CMain
{ {
public static IConfig Config = new CBconfig(); private static readonly IConfig _Config = new CBconfig();
public static ISettings Settings = new CBsettings(); private static readonly ISettings _Settings = new CBsettings();
public static ITheme Theme = new CBtheme(); private static readonly ITheme _Theme = new CBtheme();
public static IHelper Helper = new CBhelper(); private static readonly IBackgroundMusic _BackgroundMusic = new CBbackgroundMusic();
public static IBackgroundMusic BackgroundMusic = new CBbackgroundMusic(); private static readonly IDrawing _Draw = new CBdraw();
public static IDrawing Draw = new CBdraw(); private static readonly IGraphics _Graphics = new CBGraphics();
public static IGraphics Graphics = new CBGraphics(); private static readonly ILog _Log = new CBlog();
public static ILog Log = new CBlog(); private static readonly IFonts _Fonts = new CBfonts();
public static IFonts Fonts = new CBfonts(); private static readonly ILanguage _Language = new CBlanguage();
public static ILanguage Language = new CBlanguage(); private static readonly IGame _Game = new CBGame();
public static IGame Game = new CBGame(); private static readonly IProfiles _Profiles = new CBprofiles();
public static IProfiles Profiles = new CBprofiles(); private static readonly IRecording _Record = new CBrecord();
public static IRecording Record = new CBrecord(); private static readonly ISongs _Songs = new CBsongs();
public static ISongs Songs = new CBsongs(); private static readonly IVideo _Video = new CBvideo();
public static IVideo Video = new CBvideo(); private static readonly ISound _Sound = new CBsound();
public static ISound Sound = new CBsound(); private static readonly ICover _Cover = new CBcover();
public static ICover Cover = new CBcover(); private static readonly IDataBase _DataBase = new CBdataBase();
public static IDataBase DataBase = new CBdataBase(); private static readonly IInputs _Input = new CBinputs();
public static IInputs Input = new CBinputs(); private static readonly IPlaylist _Playlist = new CBplaylist();
public static IPlaylist Playlist = new CBplaylist();
public static void Init() public static void Init()
{ {
CBase.Assign(Config, Settings, Theme, Helper, Log, BackgroundMusic, Draw, Graphics, Fonts, Language, CBase.Assign(_Config, _Settings, _Theme, _Log, _BackgroundMusic, _Draw, _Graphics, _Fonts, _Language,
Game, Profiles, Record, Songs, Video, Sound, Cover, DataBase, Input, Playlist); _Game, _Profiles, _Record, _Songs, _Video, _Sound, _Cover, _DataBase, _Input, _Playlist);
} }
} }
@@ -40,14 +58,7 @@ namespace Vocaluxe.Base
{ {
public void SetBackgroundMusicVolume(int newVolume) public void SetBackgroundMusicVolume(int newVolume)
{ {
if (newVolume < 0)
CConfig.BackgroundMusicVolume = 0;
else if (newVolume > 100)
CConfig.BackgroundMusicVolume = 100;
else
CConfig.BackgroundMusicVolume = newVolume; CConfig.BackgroundMusicVolume = newVolume;
CConfig.SaveConfig();
} }
public int GetBackgroundMusicVolume() public int GetBackgroundMusicVolume()
@@ -95,7 +106,7 @@ namespace Vocaluxe.Base
return CConfig.CoverSize; return CConfig.CoverSize;
} }
public List<string> GetSongFolder() public IEnumerable<string> GetSongFolder()
{ {
return CConfig.SongFolder; return CConfig.SongFolder;
} }
@@ -122,15 +133,7 @@ namespace Vocaluxe.Base
public int GetMaxNumMics() public int GetMaxNumMics()
{ {
int max = 0; return CConfig.GetMaxNumMics();
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
if (CConfig.IsMicConfig(i + 1))
max = i + 1;
else
break;
}
return max;
} }
} }
@@ -275,8 +278,6 @@ namespace Vocaluxe.Base
} }
} }
class CBhelper : IHelper {}
class CBbackgroundMusic : IBackgroundMusic class CBbackgroundMusic : IBackgroundMusic
{ {
public bool IsDisabled() public bool IsDisabled()
@@ -286,7 +287,7 @@ namespace Vocaluxe.Base
public bool IsPlaying() public bool IsPlaying()
{ {
return CBackgroundMusic.Playing; return CBackgroundMusic.IsPlaying;
} }
public bool SongHasVideo() public bool SongHasVideo()
@@ -477,9 +478,9 @@ namespace Vocaluxe.Base
CGame.NumPlayer = numPlayer; CGame.NumPlayer = numPlayer;
} }
public SPlayer[] GetPlayer() public SPlayer[] GetPlayers()
{ {
return CGame.Player; return CGame.Players;
} }
public CPoints GetPoints() public CPoints GetPoints()
@@ -539,6 +540,16 @@ namespace Vocaluxe.Base
{ {
return CProfiles.Profiles; return CProfiles.Profiles;
} }
public EGameDifficulty GetDifficulty(int profileID)
{
return CProfiles.GetDifficulty(profileID);
}
public string GetPlayerName(int profileID, int playerNum = 0)
{
return CProfiles.GetPlayerName(profileID, playerNum);
}
} }
class CBrecord : IRecording class CBrecord : IRecording
@@ -667,9 +678,9 @@ namespace Vocaluxe.Base
return CVideo.VdSkip(videoStream, startPosition, videoGap); return CVideo.VdSkip(videoStream, startPosition, videoGap);
} }
public bool GetFrame(int videoStream, ref STexture videoTexture, float time, ref float videoTime) public bool GetFrame(int videoStream, ref STexture videoTexture, float time, out float videoTime)
{ {
return CVideo.VdGetFrame(videoStream, ref videoTexture, time, ref videoTime); return CVideo.VdGetFrame(videoStream, ref videoTexture, time, out videoTime);
} }
public bool IsFinished(int videoStream) public bool IsFinished(int videoStream)
@@ -767,9 +778,9 @@ namespace Vocaluxe.Base
CPlaylists.SetPlaylistName(playlistID, name); CPlaylists.SetPlaylistName(playlistID, name);
} }
public string[] GetPlaylistNames() public List<string> GetPlaylistNames()
{ {
return CPlaylists.GetPlaylistNames(); return CPlaylists.PlaylistNames;
} }
public string GetPlaylistName(int playlistID) public string GetPlaylistName(int playlistID)
+21 -2
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
@@ -7,7 +26,7 @@ namespace Vocaluxe.Base
public event EventHandler ObjectChanged = delegate { }; public event EventHandler ObjectChanged = delegate { };
protected bool _Changed = true; protected bool _Changed = true;
protected void _NotifyObservers() private void _NotifyObservers()
{ {
ObjectChanged.Invoke(this, null); ObjectChanged.Invoke(this, null);
} }
+54 -42
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.CodeDom.Compiler; using System.CodeDom.Compiler;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -48,9 +67,7 @@ namespace Vocaluxe.Base
_IDs.Enqueue(i); _IDs.Enqueue(i);
//add dummy normal game mode and set it as default //add dummy normal game mode and set it as default
SPartyMode pm = new SPartyMode(); SPartyMode pm = new SPartyMode {PartyMode = new CPartyModeNone(), ScreenFiles = new List<string>()};
pm.PartyMode = new CPartyModeNone();
pm.ScreenFiles = new List<string>();
pm.PartyMode.Initialize(); pm.PartyMode.Initialize();
pm.PartyModeID = _IDs.Dequeue(); pm.PartyModeID = _IDs.Dequeue();
_NormalGameModeID = pm.PartyModeID; _NormalGameModeID = pm.PartyModeID;
@@ -81,33 +98,33 @@ namespace Vocaluxe.Base
{ {
List<SPartyModeInfos> infos = new List<SPartyModeInfos>(); List<SPartyModeInfos> infos = new List<SPartyModeInfos>();
int[] usedKeys = new int[_PartyModes.Count]; int[] pmIDs = new int[_PartyModes.Count];
_PartyModes.Keys.CopyTo(usedKeys, 0); _PartyModes.Keys.CopyTo(pmIDs, 0);
for (int i = 0; i < usedKeys.Length; i++) foreach (int pmID in pmIDs)
{ {
if (usedKeys[i] != _NormalGameModeID) if (pmID != _NormalGameModeID)
{ {
SPartyMode mode = new SPartyMode(); SPartyMode mode;
_PartyModes.TryGetValue(usedKeys[i], out mode); _PartyModes.TryGetValue(pmID, out mode);
if (mode.PartyMode != null) if (mode.PartyMode != null)
{ {
SPartyModeInfos info = new SPartyModeInfos(); SPartyModeInfos info = new SPartyModeInfos
{
info.Author = mode.Author; Author = mode.Author,
info.Description = mode.Description; Description = mode.Description,
info.Name = mode.Name; Name = mode.Name,
info.PartyModeID = mode.PartyModeID; PartyModeID = mode.PartyModeID,
info.Playable = mode.NoErrors; Playable = mode.NoErrors,
info.VersionMajor = mode.PartyModeVersionMajor; VersionMajor = mode.PartyModeVersionMajor,
info.VersionMinor = mode.PartyModeVersionMinor; VersionMinor = mode.PartyModeVersionMinor,
TargetAudience = mode.TargetAudience,
info.TargetAudience = mode.TargetAudience; MaxPlayers = mode.PartyMode.GetMaxPlayer(),
info.MaxPlayers = mode.PartyMode.GetMaxPlayer(); MinPlayers = mode.PartyMode.GetMinPlayer(),
info.MinPlayers = mode.PartyMode.GetMinPlayer(); MaxTeams = mode.PartyMode.GetMaxTeams(),
info.MaxTeams = mode.PartyMode.GetMaxTeams(); MinTeams = mode.PartyMode.GetMinTeams()
info.MinTeams = mode.PartyMode.GetMinTeams(); };
infos.Add(info); infos.Add(info);
} }
@@ -125,7 +142,7 @@ namespace Vocaluxe.Base
public static void SetPartyMode(int partyModeID) public static void SetPartyMode(int partyModeID)
{ {
if (!_PartyModes.TryGetValue(partyModeID, out _CurrentPartyMode)) if (!_PartyModes.TryGetValue(partyModeID, out _CurrentPartyMode))
CLog.LogError("CParty: Can't find party mode ID: " + partyModeID.ToString()); CLog.LogError("CParty: Can't find party mode ID: " + partyModeID);
_CurrentPartyMode.PartyMode.Init(); _CurrentPartyMode.PartyMode.Init();
} }
@@ -213,10 +230,7 @@ namespace Vocaluxe.Base
private static SPartyMode _LoadPartyMode(string file) private static SPartyMode _LoadPartyMode(string file)
{ {
SPartyMode pm = new SPartyMode(); SPartyMode pm = new SPartyMode {PartyModeID = _IDs.Dequeue(), ScreenFiles = new List<string>(), NoErrors = false};
pm.PartyModeID = _IDs.Dequeue();
pm.ScreenFiles = new List<string>();
pm.NoErrors = false;
CXMLReader xmlReader = CXMLReader.OpenFile(file); CXMLReader xmlReader = CXMLReader.OpenFile(file);
@@ -227,15 +241,15 @@ namespace Vocaluxe.Base
bool loaded = true; bool loaded = true;
loaded &= xmlReader.TryGetIntValue("//root/PartyModeSystemVersion", ref pm.PartyModeSystemVersion); loaded &= xmlReader.TryGetIntValue("//root/PartyModeSystemVersion", ref pm.PartyModeSystemVersion);
loaded &= xmlReader.GetValue("//root/Info/Name", ref pm.Name, "ERROR Name"); loaded &= xmlReader.GetValue("//root/Info/Name", out pm.Name, "ERROR Name");
loaded &= xmlReader.GetValue("//root/Info/Description", ref pm.Description, "ERROR Description"); loaded &= xmlReader.GetValue("//root/Info/Description", out pm.Description, "ERROR Description");
loaded &= xmlReader.GetValue("//root/Info/Author", ref pm.Author, "ERROR Author"); loaded &= xmlReader.GetValue("//root/Info/Author", out pm.Author, "ERROR Author");
loaded &= xmlReader.GetValue("//root/Info/Folder", ref pm.Folder, "ERROR Folder"); loaded &= xmlReader.GetValue("//root/Info/Folder", out pm.Folder, "ERROR Folder");
loaded &= xmlReader.GetValue("//root/Info/PartyModeFile", ref pm.PartyModeFile, "ERROR PartyModeFile"); loaded &= xmlReader.GetValue("//root/Info/PartyModeFile", out pm.PartyModeFile, "ERROR PartyModeFile");
loaded &= xmlReader.GetInnerValues("PartyScreens", ref pm.ScreenFiles); loaded &= xmlReader.GetInnerValues("PartyScreens", ref pm.ScreenFiles);
loaded &= xmlReader.TryGetIntValue("//root/Info/PartyModeVersionMajor", ref pm.PartyModeVersionMajor); loaded &= xmlReader.TryGetIntValue("//root/Info/PartyModeVersionMajor", ref pm.PartyModeVersionMajor);
loaded &= xmlReader.TryGetIntValue("//root/Info/PartyModeVersionMinor", ref pm.PartyModeVersionMinor); loaded &= xmlReader.TryGetIntValue("//root/Info/PartyModeVersionMinor", ref pm.PartyModeVersionMinor);
loaded &= xmlReader.GetValue("//root/Info/TargetAudience", ref pm.TargetAudience, "ERROR TargetAudience"); loaded &= xmlReader.GetValue("//root/Info/TargetAudience", out pm.TargetAudience, "ERROR TargetAudience");
if (!loaded) if (!loaded)
{ {
@@ -324,14 +338,12 @@ namespace Vocaluxe.Base
private static Assembly _CompileFiles(string[] files) private static Assembly _CompileFiles(string[] files)
{ {
if (files == null) if (files == null || files.Length == 0)
return null;
if (files.Length == 0)
return null; return null;
CompilerParameters compilerParams = new CompilerParameters(); CompilerParameters compilerParams = new CompilerParameters();
compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll"); compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");
compilerParams.ReferencedAssemblies.Add("System.Core.dll");
compilerParams.ReferencedAssemblies.Add("VocaluxeLib.dll"); compilerParams.ReferencedAssemblies.Add("VocaluxeLib.dll");
compilerParams.GenerateInMemory = true; compilerParams.GenerateInMemory = true;
#if DEBUG #if DEBUG
@@ -340,7 +352,7 @@ namespace Vocaluxe.Base
using (CodeDomProvider cdp = CodeDomProvider.CreateProvider("CSharp")) using (CodeDomProvider cdp = CodeDomProvider.CreateProvider("CSharp"))
{ {
CompilerResults compileResult = null; CompilerResults compileResult;
try try
{ {
@@ -374,7 +386,7 @@ namespace Vocaluxe.Base
return null; return null;
} }
CMenuParty screen = null; CMenuParty screen;
try try
{ {
screen = (CMenuParty)instance; screen = (CMenuParty)instance;
+32 -26
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
@@ -17,14 +36,14 @@ namespace Vocaluxe.Base
get { return _Playlists.ToArray(); } get { return _Playlists.ToArray(); }
} }
public static string[] PlaylistNames public static List<string> PlaylistNames
{ {
get get
{ {
List<string> names = new List<string>(); List<string> names = new List<string>();
for (int i = 0; i < _Playlists.Count; i++) for (int i = 0; i < _Playlists.Count; i++)
names.Add(_Playlists[i].PlaylistName); names.Add(_Playlists[i].PlaylistName);
return names.ToArray(); return names;
} }
} }
@@ -75,16 +94,6 @@ namespace Vocaluxe.Base
return _Playlists[playlistID].PlaylistName; return _Playlists[playlistID].PlaylistName;
} }
public static string[] GetPlaylistNames()
{
List<string> result = new List<string>();
foreach (CPlaylistFile playlist in _Playlists)
result.Add(playlist.PlaylistName);
return result.ToArray();
}
public static void SetPlaylistName(int playlistID, string name) public static void SetPlaylistName(int playlistID, string name)
{ {
if (playlistID >= _Playlists.Count || playlistID < 0) if (playlistID >= _Playlists.Count || playlistID < 0)
@@ -97,7 +106,7 @@ namespace Vocaluxe.Base
{ {
if (playlistID < 0 || playlistID >= _Playlists.Count) if (playlistID < 0 || playlistID >= _Playlists.Count)
return; return;
if (_Playlists[playlistID].PlaylistFile.Length > 0) if (_Playlists[playlistID].PlaylistFile != "")
{ {
try try
{ {
@@ -120,8 +129,7 @@ namespace Vocaluxe.Base
public static int NewPlaylist() public static int NewPlaylist()
{ {
CPlaylistFile pl = new CPlaylistFile(); CPlaylistFile pl = new CPlaylistFile {PlaylistName = "New Playlist"};
pl.PlaylistName = "New Playlist";
_Playlists.Add(pl); _Playlists.Add(pl);
return _Playlists.Count - 1; return _Playlists.Count - 1;
} }
@@ -209,7 +217,7 @@ namespace Vocaluxe.Base
private static int _CompareByPlaylistName(CPlaylistFile a, CPlaylistFile b) private static int _CompareByPlaylistName(CPlaylistFile a, CPlaylistFile b)
{ {
return String.Compare(a.PlaylistName, b.PlaylistName); return String.CompareOrdinal(a.PlaylistName, b.PlaylistName);
} }
private static CPlaylistFile _ConvertUSDXPlaylist(string file) private static CPlaylistFile _ConvertUSDXPlaylist(string file)
@@ -219,18 +227,17 @@ namespace Vocaluxe.Base
if (!File.Exists(file)) if (!File.Exists(file))
return null; return null;
StreamReader sr;
try try
{ {
StreamReader sr;
using (sr = new StreamReader(file, Encoding.Default, true)) using (sr = new StreamReader(file, Encoding.Default, true))
{ {
int pos = -1;
string line; string line;
while ((line = sr.ReadLine()) != null) while ((line = sr.ReadLine()) != null)
{ {
pos = line.IndexOf(":"); int pos = line.IndexOf(":", StringComparison.Ordinal);
if (pos > 0) if (pos <= 0)
{ continue;
//Name or comment //Name or comment
if (line[0] == '#') if (line[0] == '#')
{ {
@@ -245,11 +252,11 @@ namespace Vocaluxe.Base
string artist = line.Substring(0, pos - 1).Trim(); string artist = line.Substring(0, pos - 1).Trim();
string title = line.Substring(pos + 1, line.Length - pos - 1).Trim(); string title = line.Substring(pos + 1, line.Length - pos - 1).Trim();
bool found = false; bool found = false;
for (int s = 0; s < allSongs.Length; s++) foreach (CSong song in allSongs)
{ {
if (allSongs[s].Artist == artist && allSongs[s].Title == title) if (song.Artist == artist && song.Title == title)
{ {
pl.AddSong(allSongs[s].ID); pl.AddSong(song.ID);
found = true; found = true;
break; break;
} }
@@ -259,7 +266,6 @@ namespace Vocaluxe.Base
} }
} }
} }
}
File.Delete(file); File.Delete(file);
} }
catch catch
+110 -89
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
@@ -43,25 +62,27 @@ namespace Vocaluxe.Base
LoadProfiles(); LoadProfiles();
} }
public static int NewProfile() public static string GetPlayerName(int profileID, int playerNum = 0)
{ {
return NewProfile(String.Empty); if (IsProfileIDValid(profileID))
return _Profiles[profileID].PlayerName;
string playerName = CLanguage.Translate("TR_SCREENNAMES_PLAYER");
if (playerNum > 0)
playerName += " " + playerNum;
return playerName;
} }
public static int NewProfile(string fileName) public static int NewProfile(string fileName = "")
{ {
SProfile profile = new SProfile(); SProfile profile = new SProfile
{
profile.PlayerName = String.Empty; PlayerName = String.Empty,
profile.Difficulty = EGameDifficulty.TR_CONFIG_EASY; Difficulty = EGameDifficulty.TR_CONFIG_EASY,
profile.Avatar = new SAvatar(-1); Avatar = new SAvatar(-1),
profile.GuestProfile = EOffOn.TR_CONFIG_OFF; GuestProfile = EOffOn.TR_CONFIG_OFF,
profile.Active = EOffOn.TR_CONFIG_ON; Active = EOffOn.TR_CONFIG_ON,
ProfileFile = fileName != "" ? Path.Combine(CSettings.FolderProfiles, fileName) : String.Empty
if (fileName.Length > 0) };
profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName);
else
profile.ProfileFile = String.Empty;
if (File.Exists(profile.ProfileFile)) if (File.Exists(profile.ProfileFile))
return -1; return -1;
@@ -110,133 +131,119 @@ namespace Vocaluxe.Base
if (tex.Index != -1) if (tex.Index != -1)
{ {
SAvatar avatar = new SAvatar(); SAvatar avatar = new SAvatar {Texture = tex, FileName = Path.GetFileName(file)};
avatar.Texture = tex;
avatar.FileName = Path.GetFileName(file);
_Avatars.Add(avatar); _Avatars.Add(avatar);
} }
} }
} }
public static string AddGetPlayerName(int profileNr, char chr) public static string AddGetPlayerName(int profileID, char chr)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) if (!IsProfileIDValid(profileID))
return String.Empty; return String.Empty;
SProfile profile = _Profiles[profileNr]; SProfile profile = _Profiles[profileID];
profile.PlayerName += chr; profile.PlayerName += chr;
_Profiles[profileNr] = profile; _Profiles[profileID] = profile;
return profile.PlayerName; return profile.PlayerName;
} }
public static string GetPlayerName(int profileNr) public static string GetDeleteCharInPlayerName(int profileID)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) if (!IsProfileIDValid(profileID))
return String.Empty; return String.Empty;
return _Profiles[profileNr].PlayerName; SProfile profile = _Profiles[profileID];
} if (profile.PlayerName != "")
public static string GetDeleteCharInPlayerName(int profileNr)
{
if (profileNr < 0 || profileNr >= _Profiles.Count)
return String.Empty;
SProfile profile = _Profiles[profileNr];
if (profile.PlayerName.Length > 0)
profile.PlayerName = profile.PlayerName.Remove(profile.PlayerName.Length - 1); profile.PlayerName = profile.PlayerName.Remove(profile.PlayerName.Length - 1);
_Profiles[profileNr] = profile; _Profiles[profileID] = profile;
return profile.PlayerName; return profile.PlayerName;
} }
public static EGameDifficulty GetDifficulty(int profileNr) public static bool IsProfileIDValid(int profileID)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) return profileID >= 0 && profileID < _Profiles.Count;
return EGameDifficulty.TR_CONFIG_NORMAL;
return _Profiles[profileNr].Difficulty;
} }
public static void SetDifficulty(int profileNr, EGameDifficulty difficulty) public static EGameDifficulty GetDifficulty(int profileID)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) return IsProfileIDValid(profileID) ? _Profiles[profileID].Difficulty : EGameDifficulty.TR_CONFIG_NORMAL;
}
public static void SetDifficulty(int profileID, EGameDifficulty difficulty)
{
if (!IsProfileIDValid(profileID))
return; return;
SProfile profile = _Profiles[profileNr]; SProfile profile = _Profiles[profileID];
profile.Difficulty = difficulty; profile.Difficulty = difficulty;
_Profiles[profileNr] = profile; _Profiles[profileID] = profile;
} }
public static EOffOn GetGuestProfile(int profileNr) public static EOffOn GetGuestProfile(int profileID)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) return IsProfileIDValid(profileID) ? _Profiles[profileID].GuestProfile : EOffOn.TR_CONFIG_OFF;
return EOffOn.TR_CONFIG_OFF;
return _Profiles[profileNr].GuestProfile;
} }
public static EOffOn GetActive(int profileNr) public static EOffOn GetActive(int profileID)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) return IsProfileIDValid(profileID) ? _Profiles[profileID].Active : EOffOn.TR_CONFIG_OFF;
return EOffOn.TR_CONFIG_OFF;
return _Profiles[profileNr].Active;
} }
public static void SetGuestProfile(int profileNr, EOffOn option) public static void SetGuestProfile(int profileID, EOffOn option)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) if (!IsProfileIDValid(profileID))
return; return;
SProfile profile = _Profiles[profileNr]; SProfile profile = _Profiles[profileID];
profile.GuestProfile = option; profile.GuestProfile = option;
_Profiles[profileNr] = profile; _Profiles[profileID] = profile;
} }
public static void SetActive(int profileNr, EOffOn option) public static void SetActive(int profileID, EOffOn option)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) if (!IsProfileIDValid(profileID))
return; return;
SProfile profile = _Profiles[profileNr]; SProfile profile = _Profiles[profileID];
profile.Active = option; profile.Active = option;
_Profiles[profileNr] = profile; _Profiles[profileID] = profile;
} }
public static bool IsGuestProfile(int profileNr) public static bool IsGuestProfile(int profileID)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) if (!IsProfileIDValid(profileID))
return true; // this will prevent from saving dummy profiles to highscore db return true; // this will prevent from saving dummy profiles to highscore db
return _Profiles[profileNr].GuestProfile == EOffOn.TR_CONFIG_ON; return _Profiles[profileID].GuestProfile == EOffOn.TR_CONFIG_ON;
} }
public static bool IsActive(int profileNr) public static bool IsActive(int profileID)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) if (!IsProfileIDValid(profileID))
return false; return false;
return _Profiles[profileNr].Active == EOffOn.TR_CONFIG_ON; return _Profiles[profileID].Active == EOffOn.TR_CONFIG_ON;
} }
public static void SetAvatar(int profileNr, int avatarNr) public static void SetAvatar(int profileID, int avatarNr)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count || avatarNr < 0 || avatarNr >= _Avatars.Count) if (!IsProfileIDValid(profileID) || avatarNr < 0 || avatarNr >= _Avatars.Count)
return; return;
SProfile profile = _Profiles[profileNr]; SProfile profile = _Profiles[profileID];
profile.Avatar = _Avatars[avatarNr]; profile.Avatar = _Avatars[avatarNr];
_Profiles[profileNr] = profile; _Profiles[profileID] = profile;
} }
public static int GetAvatarNr(int profileNr) public static int GetAvatarNr(int profileID)
{ {
if (profileNr < 0 || profileNr >= _Profiles.Count) if (!IsProfileIDValid(profileID))
return 0; return 0;
for (int i = 0; i < _Avatars.Count; i++) for (int i = 0; i < _Avatars.Count; i++)
{ {
if (_Profiles[profileNr].Avatar.FileName == _Avatars[i].FileName) if (_Profiles[profileID].Avatar.FileName == _Avatars[i].FileName)
return i; return i;
} }
@@ -245,21 +252,37 @@ namespace Vocaluxe.Base
public static void DeleteProfile(int profileID) public static void DeleteProfile(int profileID)
{ {
if (profileID < 0 || profileID >= _Profiles.Count) if (!IsProfileIDValid(profileID))
return;
if (_Profiles[profileID].ProfileFile == "")
return; return;
if (_Profiles[profileID].ProfileFile.Length > 0)
{
try try
{ {
//Check if profile saved in config
for (int i = 0; i < CConfig.Players.Length; i++)
{
if (CConfig.Players[i] == _Profiles[profileID].ProfileFile)
{
CConfig.Players[i] = string.Empty;
CConfig.SaveConfig();
}
}
File.Delete(_Profiles[profileID].ProfileFile); File.Delete(_Profiles[profileID].ProfileFile);
_Profiles.RemoveAt(profileID); _Profiles.RemoveAt(profileID);
//Check if profile is selected in game
for (int i = 0; i < CGame.Players.Length; i++)
{
if (CGame.Players[i].ProfileID > profileID)
CGame.Players[i].ProfileID--;
else if (CGame.Players[i].ProfileID == profileID)
CGame.Players[i].ProfileID = -1;
}
} }
catch (Exception) catch (Exception)
{ {
CLog.LogError("Can't delete Profile File " + _Profiles[profileID].ProfileFile + ".xml"); CLog.LogError("Can't delete Profile File " + _Profiles[profileID].ProfileFile + ".xml");
} }
} }
}
private static void _SortProfilesByName() private static void _SortProfilesByName()
{ {
@@ -268,7 +291,7 @@ namespace Vocaluxe.Base
private static int _CompareByPlayerName(SProfile a, SProfile b) private static int _CompareByPlayerName(SProfile a, SProfile b)
{ {
return String.Compare(a.PlayerName, b.PlayerName); return String.CompareOrdinal(a.PlayerName, b.PlayerName);
} }
#region private methods #region private methods
@@ -284,10 +307,10 @@ namespace Vocaluxe.Base
private static void _SaveProfile(int profileID) private static void _SaveProfile(int profileID)
{ {
if (profileID < 0 || profileID >= _Profiles.Count) if (!IsProfileIDValid(profileID))
return; return;
if (_Profiles[profileID].ProfileFile.Length == 0) if (_Profiles[profileID].ProfileFile == "")
{ {
string filename = string.Empty; string filename = string.Empty;
foreach (char chr in _Profiles[profileID].PlayerName) foreach (char chr in _Profiles[profileID].PlayerName)
@@ -296,7 +319,7 @@ namespace Vocaluxe.Base
filename += chr.ToString(); filename += chr.ToString();
} }
if (filename.Length == 0) if (filename == "")
filename = "1"; filename = "1";
int i = 0; int i = 0;
@@ -343,21 +366,19 @@ namespace Vocaluxe.Base
finally finally
{ {
writer.Close(); writer.Close();
writer = null;
} }
} }
private static void _LoadProfile(string fileName) private static void _LoadProfile(string fileName)
{ {
SProfile profile = new SProfile(); SProfile profile = new SProfile {ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName)};
profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName);
CXMLReader xmlReader = CXMLReader.OpenFile(profile.ProfileFile); CXMLReader xmlReader = CXMLReader.OpenFile(profile.ProfileFile);
if (xmlReader == null) if (xmlReader == null)
return; return;
string value = String.Empty; string value = String.Empty;
if (xmlReader.GetValue("//root/Info/PlayerName", ref value, value)) if (xmlReader.GetValue("//root/Info/PlayerName", out value, value))
{ {
profile.PlayerName = value; profile.PlayerName = value;
@@ -365,7 +386,7 @@ namespace Vocaluxe.Base
xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref profile.Difficulty); xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref profile.Difficulty);
profile.Avatar = new SAvatar(-1); profile.Avatar = new SAvatar(-1);
if (xmlReader.GetValue("//root/Info/Avatar", ref value, value)) if (xmlReader.GetValue("//root/Info/Avatar", out value, value))
profile.Avatar = _GetAvatar(value); profile.Avatar = _GetAvatar(value);
profile.GuestProfile = EOffOn.TR_CONFIG_OFF; profile.GuestProfile = EOffOn.TR_CONFIG_OFF;
+69 -39
View File
@@ -1,59 +1,77 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
enum ERevision enum ERevision
{ {
// ReSharper disable UnusedMember.Global
Alpha, Alpha,
Beta, Beta,
RC, RC,
Release Release
// ReSharper restore UnusedMember.Global
} }
static class CSettings static class CSettings
{ {
#if ARCH_X86 #if ARCH_X86
public const String Arch = "x86"; private const String _Arch = "x86";
#endif #endif
#if ARCH_X64 #if ARCH_X64
public const String Arch = "x64"; private const String _Arch = "x64";
#endif #endif
public static EGameState GameState = EGameState.Start; public static EGameState GameState = EGameState.Start;
public const string ProgramName = "Vocaluxe"; //Adjusting of programName and version now in the assembly config.
public const string ProgramCodeName = "Shining Heaven"; //I'd use the major and minor for Main releases, build number for every public release and revision for every bugfix version without any features
//As it is different than before, this is open for discussion.
//TODO: Remove this when this is decided
private const string _ProgramCodeName = "Shining Heaven";
public const int VersionMajor = 0;
public const int VersionMinor = 3; // milestones
public const int VersionSub = 0; // patches
public const ERevision VersionRevision = ERevision.Alpha; public const ERevision VersionRevision = ERevision.Alpha;
public const int Build = 78; // Increase on every published version! Never Reset!
public const int DatabaseHighscoreVersion = 2; public const int DatabaseHighscoreVersion = 2;
public const int DatabaseCoverVersion = 1; public const int DatabaseCoverVersion = 1;
public const int DatabaseCreditsRessourcesVersion = 1; public const int DatabaseCreditsRessourcesVersion = 1;
public static int RenderW = 1280; public const int RenderW = 1280;
public static int RenderH = 720; public const int RenderH = 720;
public const int ZNear = -100; public const int ZNear = -100;
public const int ZFar = 100; public const int ZFar = 100;
public static bool IsFullScreen = false; public static bool IsFullScreen;
public static int VertexBufferElements = 10000; public const int VertexBufferElements = 10000;
public const string Icon = "Vocaluxe.ico"; public const string Icon = "Vocaluxe.ico";
public const string Logo = "Logo.png"; public const string Logo = "Logo.png";
public const string FallbackLanguage = "English"; public const string FallbackLanguage = "English";
public const string BassRegistration = "Registration.xml";
public static string FileConfig = "Config.xml"; public static string FileConfig = "Config.xml";
public const string FileCover = "Cover.xml";
public const string FileFonts = "Fonts.xml"; public const string FileFonts = "Fonts.xml";
public const string FileOldHighscoreDB = "Ultrastar.db"; public const string FileOldHighscoreDB = "Ultrastar.db";
@@ -70,7 +88,6 @@ namespace Vocaluxe.Base
public const string FolderGraphics = "Graphics"; public const string FolderGraphics = "Graphics";
public const string FolderFonts = "Fonts"; public const string FolderFonts = "Fonts";
public const string FolderThemes = "Themes"; public const string FolderThemes = "Themes";
public const string FolderSkins = "Skins";
public const string FolderThemeFonts = "Fonts"; public const string FolderThemeFonts = "Fonts";
public const string FolderScreens = "Screens"; public const string FolderScreens = "Screens";
public static string FolderProfiles = "Profiles"; public static string FolderProfiles = "Profiles";
@@ -109,11 +126,11 @@ namespace Vocaluxe.Base
public const int MedleyMinSeriesLength = 3; public const int MedleyMinSeriesLength = 3;
public const float MedleyMinDuration = 40f; public const float MedleyMinDuration = 40f;
public static bool TabNavigation = false; public const bool TabNavigation = false;
public const float BackgroundMusicFadeTime = 0.5f; public const float BackgroundMusicFadeTime = 0.5f;
public static List<string> MusicFileTypes = new List<string> public static readonly List<string> MusicFileTypes = new List<string>
{ {
"*.mp3", "*.mp3",
"*.wma", "*.wma",
@@ -121,14 +138,32 @@ namespace Vocaluxe.Base
"*.wav" "*.wav"
}; };
public static string GetVersionText() private static AssemblyName _Assembly
{ {
string version = "v" + VersionMajor.ToString() + "." + get { return Assembly.GetExecutingAssembly().GetName(); }
VersionMinor.ToString() + "." + }
VersionSub.ToString() + " (" + Arch + ")";
public static string ProgramName
{
get { return _Assembly.Name; }
}
private static string _Version
{
get
{
Version v = _Assembly.Version;
return "v" + v.Major + "." + v.Minor + "." + v.Build;
}
}
private static string _GetVersionText()
{
string version = _Version + " (" + _Arch + ")";
// ReSharper disable ConditionIsAlwaysTrueOrFalse
if (VersionRevision != ERevision.Release) if (VersionRevision != ERevision.Release)
version += " " + GetVersionStatus() + String.Format(" ({0:0000)}", Build); // ReSharper restore ConditionIsAlwaysTrueOrFalse
version += " " + _GetVersionStatus() + String.Format(" ({0:0000)}", _Assembly.Version.Revision);
return version; return version;
} }
@@ -137,17 +172,21 @@ namespace Vocaluxe.Base
{ {
string version = ProgramName; string version = ProgramName;
if (ProgramCodeName.Length > 0) // ReSharper disable ConditionIsAlwaysTrueOrFalse
version += " \"" + ProgramCodeName + "\""; if (_ProgramCodeName != "")
// ReSharper restore ConditionIsAlwaysTrueOrFalse
version += " \"" + _ProgramCodeName + "\"";
return version + " " + GetVersionText(); return version + " " + _GetVersionText();
} }
public static string GetVersionStatus() private static string _GetVersionStatus()
{ {
string result = String.Empty; string result;
// ReSharper disable ConditionIsAlwaysTrueOrFalse
if (VersionRevision != ERevision.Release) if (VersionRevision != ERevision.Release)
// ReSharper restore ConditionIsAlwaysTrueOrFalse
result = Enum.GetName(typeof(ERevision), VersionRevision); result = Enum.GetName(typeof(ERevision), VersionRevision);
return result; return result;
@@ -170,16 +209,7 @@ namespace Vocaluxe.Base
public static void CreateFolders() public static void CreateFolders()
{ {
List<string> folders = new List<string>(); List<string> folders = new List<string> {FolderCover, FolderFonts, FolderProfiles, FolderSongs, FolderScreenshots, FolderBackgroundMusic, FolderSounds, FolderPlaylists};
folders.Add(FolderCover);
folders.Add(FolderFonts);
folders.Add(FolderProfiles);
folders.Add(FolderSongs);
folders.Add(FolderScreenshots);
folders.Add(FolderBackgroundMusic);
folders.Add(FolderSounds);
folders.Add(FolderPlaylists);
foreach (string folder in folders) foreach (string folder in folders)
{ {
+22 -3
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -79,7 +98,7 @@ namespace Vocaluxe.Base
int noCategoryIndex = -1; int noCategoryIndex = -1;
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
{ {
if (CSongs.Sorter.SortedSongs[i].SortString.Length > 0) if (CSongs.Sorter.SortedSongs[i].SortString != "")
{ {
if (CSongs.Sorter.SortedSongs[i].SortString != category) if (CSongs.Sorter.SortedSongs[i].SortString != category)
{ {
@@ -135,7 +154,7 @@ namespace Vocaluxe.Base
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
{ {
string year = CSongs.Sorter.SortedSongs[i].SortString; string year = CSongs.Sorter.SortedSongs[i].SortString;
if (year.Length > 0) if (year != "")
{ {
year = year.Substring(0, 3); year = year.Substring(0, 3);
CSongs.Sorter.SortedSongs[i].SortString = year + "0 - " + year + "9"; CSongs.Sorter.SortedSongs[i].SortString = year + "0 - " + year + "9";
+23 -7
View File
@@ -1,5 +1,25 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -65,7 +85,7 @@ namespace Vocaluxe.Base
_FilteredSongs.Clear(); _FilteredSongs.Clear();
string[] searchStrings = null; string[] searchStrings = null;
if (_SearchString.Length > 0) if (_SearchString != "")
searchStrings = _SearchString.ToUpper().Split(new char[] {' '}); searchStrings = _SearchString.ToUpper().Split(new char[] {' '});
foreach (CSong song in CSongs.Songs) foreach (CSong song in CSongs.Songs)
@@ -78,11 +98,7 @@ namespace Vocaluxe.Base
{ {
string search = song.Title.ToUpper() + " " + song.Artist.ToUpper() + " " + song.FolderName.ToUpper() + " " + song.FileName.ToUpper(); string search = song.Title.ToUpper() + " " + song.Artist.ToUpper() + " " + song.FolderName.ToUpper() + " " + song.FileName.ToUpper();
bool contains = true; if (searchStrings.All(search.Contains))
foreach (string str in searchStrings)
contains &= search.Contains(str);
if (contains)
_FilteredSongs.Add(song); _FilteredSongs.Add(song);
} }
} }
+45 -39
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -31,26 +50,24 @@ namespace Vocaluxe.Base
get { return _IgnoreArticles; } get { return _IgnoreArticles; }
set set
{ {
if (value != _IgnoreArticles) if (value == _IgnoreArticles)
{ return;
_IgnoreArticles = value; _IgnoreArticles = value;
_SetChanged(); _SetChanged();
} }
} }
}
public ESongSorting SongSorting public ESongSorting SongSorting
{ {
get { return _SongSorting; } get { return _SongSorting; }
set set
{ {
if (value != _SongSorting) if (value == _SongSorting)
{ return;
_SongSorting = value; _SongSorting = value;
_SetChanged(); _SetChanged();
} }
} }
}
public void SetOptions(ESongSorting songSorting, EOffOn ignoreArticles) public void SetOptions(ESongSorting songSorting, EOffOn ignoreArticles)
{ {
@@ -69,51 +86,46 @@ namespace Vocaluxe.Base
private int _SortByFieldArtistTitle(SSongPointer s1, SSongPointer s2) private int _SortByFieldArtistTitle(SSongPointer s1, SSongPointer s2)
{ {
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase);
if (res == 0) if (res == 0)
{ {
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
{ {
res = CSongs.Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].ArtistSorting.ToUpper()); res = String.Compare(CSongs.Songs[s1.SongID].ArtistSorting, CSongs.Songs[s2.SongID].ArtistSorting, StringComparison.OrdinalIgnoreCase);
if (res == 0) return res != 0 ? res : String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.OrdinalIgnoreCase);
return CSongs.Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].TitleSorting.ToUpper());
return res;
}
else
{
res = CSongs.Songs[s1.SongID].Artist.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Artist.ToUpper());
if (res == 0)
return CSongs.Songs[s1.SongID].Title.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Title.ToUpper());
return res;
} }
res = String.Compare(CSongs.Songs[s1.SongID].Artist, CSongs.Songs[s2.SongID].Artist, StringComparison.OrdinalIgnoreCase);
return res != 0 ? res : String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.OrdinalIgnoreCase);
} }
return res; return res;
} }
private int _SortByFieldTitle(SSongPointer s1, SSongPointer s2) private int _SortByFieldTitle(SSongPointer s1, SSongPointer s2)
{ {
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase);
if (res == 0) if (res == 0)
{ {
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) return _IgnoreArticles == EOffOn.TR_CONFIG_ON
return CSongs.Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].TitleSorting.ToUpper()); ? String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.OrdinalIgnoreCase) :
else String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.OrdinalIgnoreCase);
return CSongs.Songs[s1.SongID].Title.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Title.ToUpper());
} }
return res; return res;
} }
private List<SSongPointer> _CreateSortList(string fieldName) private List<SSongPointer> _CreateSortList(string fieldName)
{ {
FieldInfo field = null;
bool isString = false;
List<SSongPointer> sortList = new List<SSongPointer>(); List<SSongPointer> sortList = new List<SSongPointer>();
if (fieldName.Length == 0) if (fieldName == "")
CSongs.Filter.FilteredSongs.ForEach((song) => sortList.Add(new SSongPointer(song.ID, ""))); CSongs.Filter.FilteredSongs.ForEach(song => sortList.Add(new SSongPointer(song.ID, "")));
else else
{ {
field = typeof(CSong).GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); FieldInfo field = typeof(CSong).GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
isString = field.FieldType == typeof(string); if (field == null)
{
CLog.LogError("Unknow sorting field: " + fieldName);
return _CreateSortList("");
}
bool isString = field.FieldType == typeof(string);
if (!isString && field.FieldType != typeof(List<String>)) if (!isString && field.FieldType != typeof(List<String>))
throw new Exception("Unkown sort field type"); throw new Exception("Unkown sort field type");
foreach (CSong song in CSongs.Filter.FilteredSongs) foreach (CSong song in CSongs.Filter.FilteredSongs)
@@ -128,7 +140,7 @@ namespace Vocaluxe.Base
sortList.Add(new SSongPointer(song.ID, "")); sortList.Add(new SSongPointer(song.ID, ""));
else else
{ {
foreach (String sortString in (List<String>)value) foreach (String sortString in values)
sortList.Add(new SSongPointer(song.ID, sortString)); sortList.Add(new SSongPointer(song.ID, sortString));
} }
} }
@@ -155,16 +167,10 @@ namespace Vocaluxe.Base
break; break;
case ESongSorting.TR_CONFIG_ARTIST_LETTER: case ESongSorting.TR_CONFIG_ARTIST_LETTER:
case ESongSorting.TR_CONFIG_ARTIST: case ESongSorting.TR_CONFIG_ARTIST:
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) fieldName = _IgnoreArticles == EOffOn.TR_CONFIG_ON ? "ArtistSorting" : "Artist";
fieldName = "ArtistSorting";
else
fieldName = "Artist";
break; break;
case ESongSorting.TR_CONFIG_TITLE_LETTER: case ESongSorting.TR_CONFIG_TITLE_LETTER:
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) fieldName = _IgnoreArticles == EOffOn.TR_CONFIG_ON ? "TitleSorting" : "Title";
fieldName = "TitleSorting";
else
fieldName = "Title";
break; break;
case ESongSorting.TR_CONFIG_YEAR: case ESongSorting.TR_CONFIG_YEAR:
case ESongSorting.TR_CONFIG_DECADE: case ESongSorting.TR_CONFIG_DECADE:
+35 -38
View File
@@ -1,8 +1,26 @@
using System; #region license
using System.Collections.Generic; // /*
using System.Diagnostics; // This file is part of Vocaluxe.
using System.Threading; //
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -10,16 +28,16 @@ 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;
public bool Visible; public bool Visible;
public bool PartyHidden; public bool PartyHidden;
public SSongPointer(int iD, string sortString) public SSongPointer(int id, string sortString)
{ {
SongID = iD; SongID = id;
SortString = sortString; SortString = sortString;
CatIndex = -1; CatIndex = -1;
Visible = false; Visible = false;
@@ -38,13 +56,11 @@ 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 readonly CSongCategorizer Categorizer = new CSongCategorizer();
public static CSongFilter Filter = new CSongFilter(); private static Thread _CoverLoaderThread;
public static CSongSorter Sorter = new CSongSorter();
public static CSongCategorizer Categorizer = new CSongCategorizer();
private static Thread _CoverLoaderThread = null;
public static List<CSong> Songs public static List<CSong> Songs
{ {
@@ -73,16 +89,7 @@ namespace Vocaluxe.Base
public static int NumVisibleSongs public static int NumVisibleSongs
{ {
get get { return Sorter.SortedSongs.Count(sp => sp.Visible); }
{
int result = 0;
foreach (SSongPointer sp in Sorter.SortedSongs)
{
if (sp.Visible)
result++;
}
return result;
}
} }
public static int NumCategories public static int NumCategories
@@ -187,18 +194,12 @@ namespace Vocaluxe.Base
{ {
if ((Categorizer.Categories.Count > 0) && (_CatIndex >= 0) && (Categorizer.Categories.Count > _CatIndex)) if ((Categorizer.Categories.Count > 0) && (_CatIndex >= 0) && (Categorizer.Categories.Count > _CatIndex))
return Categorizer.Categories[_CatIndex].Name; return Categorizer.Categories[_CatIndex].Name;
else
return String.Empty; return String.Empty;
} }
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)
@@ -394,7 +395,7 @@ namespace Vocaluxe.Base
if (song != null) if (song != null)
{ {
song.ID = _Songs.Count; song.ID = _Songs.Count;
if(song.ReadNotes()) if (song.ReadNotes())
_Songs.Add(song); _Songs.Add(song);
} }
} }
@@ -427,14 +428,10 @@ namespace Vocaluxe.Base
if (!SongsLoaded || CoverLoaded) if (!SongsLoaded || CoverLoaded)
return; return;
if (_CoverLoaderThread == null) if (_CoverLoaderThread != null)
{ return;
_CoverLoaderThread = new Thread(new ThreadStart(_LoadCover)); _CoverLoaderThread = new Thread(_LoadCover) {Name = "CoverLoader", Priority = ThreadPriority.BelowNormal, IsBackground = true};
_CoverLoaderThread.Name = "CoverLoader";
_CoverLoaderThread.Priority = ThreadPriority.BelowNormal;
_CoverLoaderThread.IsBackground = true;
_CoverLoaderThread.Start(); _CoverLoaderThread.Start();
}
/* /*
if (_CoverLoadTimer.ElapsedMilliseconds >= WaitTime) if (_CoverLoadTimer.ElapsedMilliseconds >= WaitTime)
+32 -10
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using Vocaluxe.Lib.Sound; using Vocaluxe.Lib.Sound;
@@ -16,7 +35,7 @@ namespace Vocaluxe.Base
#region Playback #region Playback
private static IPlayback _Playback; private static IPlayback _Playback;
public static bool PlaybackInit() public static bool Init()
{ {
switch (CConfig.PlayBackLib) switch (CConfig.PlayBackLib)
{ {
@@ -36,7 +55,7 @@ namespace Vocaluxe.Base
_Playback = new CPortAudioPlay(); _Playback = new CPortAudioPlay();
break; break;
} }
return true; return _Playback.Init();
} }
public static void SetGlobalVolume(float volume) public static void SetGlobalVolume(float volume)
@@ -164,7 +183,7 @@ namespace Vocaluxe.Base
break; break;
} }
if (file.Length == 0) if (file == "")
return -1; return -1;
int stream = Load(file); int stream = Load(file);
@@ -467,16 +486,19 @@ namespace Vocaluxe.Base
_MaxVolume = volume; _MaxVolume = volume;
} }
if (_MaxVolume >= 0.02f) _AnalyzeByAutocorrelation(_MaxVolume >= 0.02f);
_AnalyzeByAutocorrelation(true);
else
_AnalyzeByAutocorrelation(false);
} }
catch (Exception) {} catch (Exception) {}
} }
private void _AnalyzeByAutocorrelation(bool valid) private void _AnalyzeByAutocorrelation(bool valid)
{ {
if (!valid)
{
_ToneValid = false;
return;
}
const double halftoneBase = 1.05946309436; // 2^(1/12) -> HalftoneBase^12 = 2 (one octave) const double halftoneBase = 1.05946309436; // 2^(1/12) -> HalftoneBase^12 = 2 (one octave)
// prepare to analyze // prepare to analyze
@@ -506,7 +528,7 @@ namespace Vocaluxe.Base
weigth[toneIndex] = (float)curWeight; weigth[toneIndex] = (float)curWeight;
} }
if (valid && maxWeight - minWeight > 0.01) if (maxWeight - minWeight > 0.01)
{ {
for (int i = 0; i < weigth.Length; i++) for (int i = 0; i < weigth.Length; i++)
_ToneWeigth[i] = weigth[i]; _ToneWeigth[i] = weigth[i];
@@ -594,7 +616,7 @@ namespace Vocaluxe.Base
float dt = Time; float dt = Time;
float diff = _ExternTime.Time - dt; float diff = et - dt;
if (Math.Abs(diff) > 0.05f) if (Math.Abs(diff) > 0.05f)
{ {
_Timer.Reset(); _Timer.Reset();
+57 -66
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
@@ -115,7 +134,7 @@ namespace Vocaluxe.Base
} }
} }
public static SCursor Cursor = new SCursor(); public static SCursor Cursor;
#endregion Vars #endregion Vars
#region Theme and Skin loading and writing #region Theme and Skin loading and writing
@@ -147,7 +166,7 @@ namespace Vocaluxe.Base
if (xmlReader == null) if (xmlReader == null)
return false; return false;
string value = String.Empty; string value;
// load skins/textures // load skins/textures
@@ -157,7 +176,7 @@ namespace Vocaluxe.Base
{ {
try try
{ {
xmlReader.GetValue("//root/Skins/" + name, ref value, String.Empty); xmlReader.GetValue("//root/Skins/" + name, out value, String.Empty);
SSkinElement sk = _Skins[skinIndex].SkinList[name]; SSkinElement sk = _Skins[skinIndex].SkinList[name];
sk.Value = value; sk.Value = value;
sk.VideoIndex = -1; sk.VideoIndex = -1;
@@ -177,10 +196,8 @@ namespace Vocaluxe.Base
{ {
try try
{ {
xmlReader.GetValue("//root/Videos/" + _Skins[skinIndex].VideoList[i].Name, ref value, String.Empty); xmlReader.GetValue("//root/Videos/" + _Skins[skinIndex].VideoList[i].Name, out value, String.Empty);
SSkinElement sk = new SSkinElement(); SSkinElement sk = new SSkinElement {Name = _Skins[skinIndex].VideoList[i].Name, Value = value};
sk.Name = _Skins[skinIndex].VideoList[i].Name;
sk.Value = value;
sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[skinIndex].Path, sk.Value)); sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[skinIndex].Path, sk.Value));
CVideo.VdSetLoop(sk.VideoIndex, true); CVideo.VdSetLoop(sk.VideoIndex, true);
CVideo.VdPause(sk.VideoIndex); CVideo.VdPause(sk.VideoIndex);
@@ -248,7 +265,7 @@ namespace Vocaluxe.Base
{ {
if (themeIndex < 0 || themeIndex >= _Themes.Count) if (themeIndex < 0 || themeIndex >= _Themes.Count)
{ {
CLog.LogError("Can't find Theme Index " + themeIndex.ToString()); CLog.LogError("Can't find Theme Index " + themeIndex);
return false; return false;
} }
@@ -387,7 +404,7 @@ namespace Vocaluxe.Base
_Themes.Clear(); _Themes.Clear();
string path = Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderThemes); string path = Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderThemes);
List<string> files = CHelper.ListFiles(path, "*.xml", false); List<string> files = CHelper.ListFiles(path, "*.xml");
foreach (string file in files) foreach (string file in files)
AddTheme(Path.Combine(path, file), -1); AddTheme(Path.Combine(path, file), -1);
@@ -406,11 +423,11 @@ namespace Vocaluxe.Base
if (version == _ThemeSystemVersion) if (version == _ThemeSystemVersion)
{ {
xmlReader.GetValue("//root/Info/Name", ref theme.Name, String.Empty); xmlReader.GetValue("//root/Info/Name", out theme.Name, String.Empty);
if (theme.Name.Length > 0) if (theme.Name != "")
{ {
xmlReader.GetValue("//root/Info/Author", ref theme.Author, String.Empty); xmlReader.GetValue("//root/Info/Author", out theme.Author, String.Empty);
xmlReader.GetValue("//root/Info/SkinFolder", ref theme.SkinFolder, String.Empty); xmlReader.GetValue("//root/Info/SkinFolder", out theme.SkinFolder, String.Empty);
xmlReader.TryGetIntValue("//root/Info/ThemeVersionMajor", ref theme.ThemeVersionMajor); xmlReader.TryGetIntValue("//root/Info/ThemeVersionMajor", ref theme.ThemeVersionMajor);
xmlReader.TryGetIntValue("//root/Info/ThemeVersionMinor", ref theme.ThemeVersionMinor); xmlReader.TryGetIntValue("//root/Info/ThemeVersionMinor", ref theme.ThemeVersionMinor);
theme.Path = Path.GetDirectoryName(filePath); theme.Path = Path.GetDirectoryName(filePath);
@@ -428,7 +445,7 @@ namespace Vocaluxe.Base
else else
msg += "the file is for newer program versions! "; msg += "the file is for newer program versions! ";
msg += "Current ThemeSystemVersion is " + _ThemeSystemVersion.ToString() + " but found " + version; msg += "Current ThemeSystemVersion is " + _ThemeSystemVersion + " but found " + version;
CLog.LogError(msg); CLog.LogError(msg);
} }
return true; return true;
@@ -451,14 +468,14 @@ namespace Vocaluxe.Base
{ {
if (themeIndex < 0 || themeIndex >= _Themes.Count) if (themeIndex < 0 || themeIndex >= _Themes.Count)
{ {
CLog.LogError("Error List Skins. Can't find Theme index: " + themeIndex.ToString()); CLog.LogError("Error List Skins. Can't find Theme index: " + themeIndex);
return; return;
} }
STheme theme = _Themes[themeIndex]; STheme theme = _Themes[themeIndex];
string path = Path.Combine(theme.Path, theme.SkinFolder); string path = Path.Combine(theme.Path, theme.SkinFolder);
List<string> files = CHelper.ListFiles(path, "*.xml", false); List<string> files = CHelper.ListFiles(path, "*.xml");
foreach (string file in files) foreach (string file in files)
{ {
@@ -473,10 +490,10 @@ namespace Vocaluxe.Base
if (version == _SkinSystemVersion) if (version == _SkinSystemVersion)
{ {
xmlReader.GetValue("//root/Info/Name", ref skin.Name, String.Empty); xmlReader.GetValue("//root/Info/Name", out skin.Name, String.Empty);
if (skin.Name.Length > 0) if (skin.Name != "")
{ {
xmlReader.GetValue("//root/Info/Author", ref skin.Author, String.Empty); xmlReader.GetValue("//root/Info/Author", out skin.Author, String.Empty);
xmlReader.TryGetIntValue("//root/Info/SkinVersionMajor", ref skin.SkinVersionMajor); xmlReader.TryGetIntValue("//root/Info/SkinVersionMajor", ref skin.SkinVersionMajor);
xmlReader.TryGetIntValue("//root/Info/SkinVersionMinor", ref skin.SkinVersionMinor); xmlReader.TryGetIntValue("//root/Info/SkinVersionMinor", ref skin.SkinVersionMinor);
@@ -489,9 +506,7 @@ namespace Vocaluxe.Base
List<string> names = xmlReader.GetValues("Skins"); List<string> names = xmlReader.GetValues("Skins");
foreach (string str in names) foreach (string str in names)
{ {
SSkinElement sk = new SSkinElement(); SSkinElement sk = new SSkinElement {Name = str, Value = String.Empty};
sk.Name = str;
sk.Value = String.Empty;
skin.SkinList[str] = sk; skin.SkinList[str] = sk;
} }
@@ -499,9 +514,7 @@ namespace Vocaluxe.Base
names = xmlReader.GetValues("Videos"); names = xmlReader.GetValues("Videos");
foreach (string str in names) foreach (string str in names)
{ {
SSkinElement sk = new SSkinElement(); SSkinElement sk = new SSkinElement {Name = str, Value = String.Empty};
sk.Name = str;
sk.Value = String.Empty;
skin.VideoList.Add(sk); skin.VideoList.Add(sk);
} }
_Skins.Add(skin); _Skins.Add(skin);
@@ -515,7 +528,7 @@ namespace Vocaluxe.Base
else else
msg += "the file is for newer program versions! "; msg += "the file is for newer program versions! ";
msg += "Current SkinSystemVersion is " + _SkinSystemVersion.ToString(); msg += "Current SkinSystemVersion is " + _SkinSystemVersion;
CLog.LogError(msg); CLog.LogError(msg);
} }
} }
@@ -529,7 +542,7 @@ namespace Vocaluxe.Base
{ {
if (partyModeID != -1 && _Skins[i].PartyModeID == partyModeID) if (partyModeID != -1 && _Skins[i].PartyModeID == partyModeID)
return i; return i;
else if (partyModeID == -1 && _Skins[i].Name == CConfig.Skin) if (partyModeID == -1 && _Skins[i].Name == CConfig.Skin)
return i; return i;
} }
@@ -542,7 +555,7 @@ namespace Vocaluxe.Base
{ {
if (partyModeID != -1 && _Themes[i].PartyModeID == partyModeID) if (partyModeID != -1 && _Themes[i].PartyModeID == partyModeID)
return i; return i;
else if (partyModeID == -1 && _Themes[i].Name == CConfig.Theme) if (partyModeID == -1 && _Themes[i].Name == CConfig.Theme)
return i; return i;
} }
@@ -578,22 +591,12 @@ namespace Vocaluxe.Base
return _GetSkinFileName(skinName, GetSkinIndex(partyModeID), true); return _GetSkinFileName(skinName, GetSkinIndex(partyModeID), true);
} }
private static string _GetSkinFileName(string skinName, int skinIndex) private static string _GetSkinFileName(string skinName, int skinIndex, bool returnPath = false)
{
return _GetSkinFileName(skinName, skinIndex, false);
}
private static string _GetSkinFileName(string skinName, int skinIndex, bool returnPath)
{ {
foreach (SSkinElement sk in _Skins[skinIndex].SkinList.Values) foreach (SSkinElement sk in _Skins[skinIndex].SkinList.Values)
{ {
if (sk.Name == skinName) if (sk.Name == skinName)
{ return !returnPath ? sk.Value : Path.Combine(_Skins[skinIndex].Path, sk.Value);
if (!returnPath)
return sk.Value;
else
return Path.Combine(_Skins[skinIndex].Path, sk.Value);
}
} }
CLog.LogError("Can't find Skin Element \"" + skinName); CLog.LogError("Can't find Skin Element \"" + skinName);
@@ -616,7 +619,7 @@ namespace Vocaluxe.Base
sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, partyModeID)); sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, partyModeID));
CVideo.VdSetLoop(sk.VideoIndex, true); CVideo.VdSetLoop(sk.VideoIndex, true);
} }
CVideo.VdGetFrame(sk.VideoIndex, ref sk.Texture, time, ref time); CVideo.VdGetFrame(sk.VideoIndex, ref sk.Texture, time, out time);
_Skins[skinIndex].VideoList[i] = sk; _Skins[skinIndex].VideoList[i] = sk;
return sk.Texture; return sk.Texture;
} }
@@ -676,22 +679,12 @@ namespace Vocaluxe.Base
return _GetVideoFileName(videoName, GetSkinIndex(partyModeID), true); return _GetVideoFileName(videoName, GetSkinIndex(partyModeID), true);
} }
private static string _GetVideoFileName(string videoName, int skinIndex) private static string _GetVideoFileName(string videoName, int skinIndex, bool returnPath = false)
{
return _GetVideoFileName(videoName, skinIndex, false);
}
private static string _GetVideoFileName(string videoName, int skinIndex, bool returnPath)
{ {
foreach (SSkinElement sk in _Skins[skinIndex].VideoList) foreach (SSkinElement sk in _Skins[skinIndex].VideoList)
{ {
if (sk.Name == videoName) if (sk.Name == videoName)
{ return !returnPath ? sk.Value : Path.Combine(_Skins[skinIndex].Path, sk.Value);
if (!returnPath)
return sk.Value;
else
return Path.Combine(_Skins[skinIndex].Path, sk.Value);
}
} }
CLog.LogError("Can't find Video Element \"" + videoName); CLog.LogError("Can't find Video Element \"" + videoName);
@@ -710,14 +703,13 @@ namespace Vocaluxe.Base
float value = 0f; float value = 0f;
int i = 1; int i = 1;
while (xmlReader.TryGetFloatValue("//root/Colors/Player" + i.ToString() + "/R", ref value)) while (xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/R", ref value))
{ {
SColorF color = new SColorF(); SColorF color = new SColorF {R = value};
color.R = value; xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/G", ref color.G);
xmlReader.TryGetFloatValue("//root/Colors/Player" + i.ToString() + "/G", ref color.G); xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/B", ref color.B);
xmlReader.TryGetFloatValue("//root/Colors/Player" + i.ToString() + "/B", ref color.B); xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/A", ref color.A);
xmlReader.TryGetFloatValue("//root/Colors/Player" + i.ToString() + "/A", ref color.A);
playerColors.Add(color); playerColors.Add(color);
i++; i++;
@@ -729,8 +721,7 @@ namespace Vocaluxe.Base
List<string> names = xmlReader.GetValues("ColorSchemes"); List<string> names = xmlReader.GetValues("ColorSchemes");
foreach (string str in names) foreach (string str in names)
{ {
SColorScheme scheme = new SColorScheme(); SColorScheme scheme = new SColorScheme {Name = str};
scheme.Name = str;
xmlReader.TryGetFloatValue("//root/ColorSchemes/" + str + "/R", ref scheme.Color.R); xmlReader.TryGetFloatValue("//root/ColorSchemes/" + str + "/R", ref scheme.Color.R);
xmlReader.TryGetFloatValue("//root/ColorSchemes/" + str + "/G", ref scheme.Color.G); xmlReader.TryGetFloatValue("//root/ColorSchemes/" + str + "/G", ref scheme.Color.G);
@@ -747,12 +738,12 @@ namespace Vocaluxe.Base
private static void _LoadCursor(CXMLReader xmlReader, int skinIndex) private static void _LoadCursor(CXMLReader xmlReader, int skinIndex)
{ {
string value = String.Empty; string value = String.Empty;
xmlReader.GetValue("//root/Cursor/Skin", ref Cursor.SkinName, value); xmlReader.GetValue("//root/Cursor/Skin", out Cursor.SkinName, value);
xmlReader.TryGetFloatValue("//root/Cursor/W", ref Cursor.W); xmlReader.TryGetFloatValue("//root/Cursor/W", ref Cursor.W);
xmlReader.TryGetFloatValue("//root/Cursor/H", ref Cursor.H); xmlReader.TryGetFloatValue("//root/Cursor/H", ref Cursor.H);
if (xmlReader.GetValue("//root/Cursor/Color", ref value, value)) if (xmlReader.GetValue("//root/Cursor/Color", out value, value))
{ {
SColorF color = GetColor(value, _Skins[skinIndex].PartyModeID); SColorF color = GetColor(value, _Skins[skinIndex].PartyModeID);
Cursor.R = color.R; Cursor.R = color.R;
@@ -780,7 +771,7 @@ namespace Vocaluxe.Base
writer.WriteStartElement("Colors"); writer.WriteStartElement("Colors");
for (int i = 0; i < _Skins[skinIndex].ThemeColors.Player.Length; i++) for (int i = 0; i < _Skins[skinIndex].ThemeColors.Player.Length; i++)
{ {
writer.WriteStartElement("Player" + (i + 1).ToString()); writer.WriteStartElement("Player" + (i + 1));
writer.WriteElementString("R", _Skins[skinIndex].ThemeColors.Player[i].R.ToString("#0.000")); writer.WriteElementString("R", _Skins[skinIndex].ThemeColors.Player[i].R.ToString("#0.000"));
writer.WriteElementString("G", _Skins[skinIndex].ThemeColors.Player[i].G.ToString("#0.000")); writer.WriteElementString("G", _Skins[skinIndex].ThemeColors.Player[i].G.ToString("#0.000"));
@@ -816,7 +807,7 @@ namespace Vocaluxe.Base
writer.WriteElementString("W", Cursor.W.ToString("#0.000")); writer.WriteElementString("W", Cursor.W.ToString("#0.000"));
writer.WriteElementString("H", Cursor.H.ToString("#0.000")); writer.WriteElementString("H", Cursor.H.ToString("#0.000"));
if (Cursor.Color.Length > 0) if (Cursor.Color != "")
writer.WriteElementString("Color", Cursor.Color); writer.WriteElementString("Color", Cursor.Color);
else else
{ {
+44 -56
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
@@ -40,21 +59,17 @@ namespace Vocaluxe.Base
long ticks = _Stopwatch.ElapsedTicks; long ticks = _Stopwatch.ElapsedTicks;
if (Stopwatch.IsHighResolution && ticks != 0) if (Stopwatch.IsHighResolution && ticks != 0)
return (float)((_NanosecPerTick * ticks) / (1000.0 * 1000.0)); return (float)((_NanosecPerTick * ticks) / (1000.0 * 1000.0));
else
return _Stopwatch.ElapsedMilliseconds; return _Stopwatch.ElapsedMilliseconds;
} }
else
return 0f; return 0f;
} }
public static float CalculateFPS() public static void CalculateFPS()
{ {
float ms = GetMilliseconds(); float ms = GetMilliseconds();
if (ms > 0) if (ms > 0)
_Fps = 1 / ms; _Fps = 1 / ms;
return _Fps * 1000f;
} }
public static double GetFPS() public static double GetFPS()
@@ -136,17 +151,12 @@ namespace Vocaluxe.Base
{ {
_CheckModifiers(); _CheckModifiers();
bool repeat = false; bool repeat = _Keys == e.KeyCode;
if (_Keys == e.KeyCode)
repeat = true;
if (!_Timer.IsRunning || (_Timer.ElapsedMilliseconds > 75) || !repeat) if (!_Timer.IsRunning || (_Timer.ElapsedMilliseconds > 75) || !repeat)
{ {
_Keys = e.KeyCode; _Keys = e.KeyCode;
if (repeat) _Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, repeat ? _Char : Char.MinValue, _Keys);
_Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, _Char, _Keys);
else
_Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, Char.MinValue, _Keys);
} }
} }
@@ -159,7 +169,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;
@@ -173,7 +185,6 @@ namespace Vocaluxe.Base
_Del(0); _Del(0);
return true; return true;
} }
else
return false; return false;
} }
@@ -193,54 +204,34 @@ namespace Vocaluxe.Base
private readonly List<SMouseEvent> _EventsPool; private readonly List<SMouseEvent> _EventsPool;
private readonly List<SMouseEvent> _CurrentPool; private readonly List<SMouseEvent> _CurrentPool;
private int _X;
private int _Y;
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;
public int X public bool Visible;
{
get { return _X; }
}
public int Y
{
get { return _Y; }
}
public bool Visible = false;
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)
{ {
_EventsPool.Add(pool); _EventsPool.Add(pool);
} }
_X = x;
_Y = y;
} }
private void _Del(int index) private void _Del(int index)
@@ -251,30 +242,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)
@@ -293,11 +282,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);
@@ -305,15 +296,12 @@ namespace Vocaluxe.Base
public bool PollEvent(ref SMouseEvent mouseEvent) public bool PollEvent(ref SMouseEvent mouseEvent)
{ {
if (_CurrentPool.Count > 0) if (_CurrentPool.Count <= 0)
{ return false;
mouseEvent = _CurrentPool[0]; mouseEvent = _CurrentPool[0];
_Del(0); _Del(0);
return true; return true;
} }
else
return false;
}
public void CopyEvents() public void CopyEvents()
{ {
+27 -9
View File
@@ -1,4 +1,23 @@
using System.Diagnostics; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using Vocaluxe.Lib.Video; using Vocaluxe.Lib.Video;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -61,9 +80,9 @@ namespace Vocaluxe.Base
return _VideoDecoder.GetLength(streamID); return _VideoDecoder.GetLength(streamID);
} }
public static bool VdGetFrame(int streamID, ref STexture frame, float time, ref float videoTime) public static bool VdGetFrame(int streamID, ref STexture frame, float time, out float videoTime)
{ {
return _VideoDecoder.GetFrame(streamID, ref frame, time, ref videoTime); return _VideoDecoder.GetFrame(streamID, ref frame, time, out videoTime);
} }
public static bool VdSkip(int streamID, float start, float gap) public static bool VdSkip(int streamID, float start, float gap)
@@ -157,9 +176,8 @@ namespace Vocaluxe.Base
float videoTime = _VideoTimer.ElapsedMilliseconds / 1000f; float videoTime = _VideoTimer.ElapsedMilliseconds / 1000f;
_Finished = CVideo.VdFinished(_VideoStream); _Finished = CVideo.VdFinished(_VideoStream);
STexture tex = new STexture(-1); STexture tex = new STexture(-1) {Height = 0f};
tex.Height = 0f; CVideo.VdGetFrame(_VideoStream, ref tex, videoTime, out videoTime);
CVideo.VdGetFrame(_VideoStream, ref tex, videoTime, ref videoTime);
if (tex.Height > 0) if (tex.Height > 0)
{ {
@@ -169,7 +187,7 @@ namespace Vocaluxe.Base
} }
RectangleF bounds = new RectangleF(0f, 0f, CSettings.RenderW, CSettings.RenderH); RectangleF bounds = new RectangleF(0f, 0f, CSettings.RenderW, CSettings.RenderH);
RectangleF rect = new RectangleF(0f, 0f, _VideoTexture.Width, _VideoTexture.Height); RectangleF rect = new RectangleF(0f, 0f, _VideoTexture.Width, _VideoTexture.Height);
CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop); CHelper.SetRect(bounds, out rect, rect.Width / rect.Height, EAspect.Crop);
CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.ZFar / 4)); CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.ZFar / 4));
} }
@@ -179,8 +197,8 @@ namespace Vocaluxe.Base
float videoTime = 0f; float videoTime = 0f;
while (_VideoTexture.Index == -1 && videoTime < 1f) while (_VideoTexture.Index == -1 && videoTime < 1f)
{ {
float dummy = 0f; float dummy;
CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, ref dummy); CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, out dummy);
videoTime += 0.05f; videoTime += 0.05f;
} }
} }
+25 -1
View File
@@ -1,4 +1,23 @@
using System.Drawing; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Drawing;
using Vocaluxe.Lib.Webcam; using Vocaluxe.Lib.Webcam;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -67,5 +86,10 @@ namespace Vocaluxe.Base
{ {
return _Webcam.GetDevices(); return _Webcam.GetDevices();
} }
public static bool IsDeviceAvailable()
{
return _Webcam.IsDeviceAvailable();
}
} }
} }
+32 -1
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
@@ -52,6 +71,18 @@ namespace Vocaluxe
Show(); Show();
} }
public override sealed string Text
{
get { return base.Text; }
set { base.Text = value; }
}
public override sealed Color BackColor
{
get { return base.BackColor; }
set { base.BackColor = value; }
}
protected override void OnPaint(PaintEventArgs e) {} protected override void OnPaint(PaintEventArgs e) {}
protected override void OnPaintBackground(PaintEventArgs e) protected override void OnPaintBackground(PaintEventArgs e)
+26 -10
View File
@@ -1,4 +1,23 @@
using System.Collections.Generic; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Collections.Generic;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -7,8 +26,8 @@ namespace Vocaluxe.GameModes
{ {
struct SSongQueque struct SSongQueque
{ {
public int SongID; public readonly int SongID;
public EGameMode GameMode; public readonly EGameMode GameMode;
public SSongQueque(int songID, EGameMode gameMode) public SSongQueque(int songID, EGameMode gameMode)
{ {
@@ -19,10 +38,9 @@ namespace Vocaluxe.GameModes
abstract class CGameMode : IGameMode abstract class CGameMode : IGameMode
{ {
protected bool _Initialized = false; private List<SSongQueque> _SongQueque;
protected List<SSongQueque> _SongQueque; private int _CurrentSong;
protected int _CurrentSong; private CPoints _Points;
protected CPoints _Points;
#region Implementation #region Implementation
public virtual void Init() public virtual void Init()
@@ -181,7 +199,7 @@ namespace Vocaluxe.GameModes
song.Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap; song.Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap;
// set lines to medley mode // set lines to medley mode
song.Notes.SetMedley(song.Notes.GetLines(0).Line[0].FirstNoteBeat, song.ShortEnd); song.Notes.SetMedley(song.Notes.GetVoice(0).Lines[0].FirstNoteBeat, song.ShortEnd);
break; break;
} }
@@ -216,7 +234,5 @@ namespace Vocaluxe.GameModes
return _Points; return _Points;
} }
#endregion Implementation #endregion Implementation
protected virtual void _SongManipulation(int songIndex) {}
} }
} }
+21 -10
View File
@@ -1,13 +1,24 @@
namespace Vocaluxe.GameModes #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
namespace Vocaluxe.GameModes
{ {
// Nomal singing // Nomal singing
class CGameModeNormal : CGameMode class CGameModeNormal : CGameMode {}
{
public override void Init()
{
base.Init();
_Initialized = true;
}
}
} }
+20 -1
View File
@@ -1,4 +1,23 @@
using VocaluxeLib.Menu; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
namespace Vocaluxe.GameModes namespace Vocaluxe.GameModes
+18 -8
View File
@@ -1,12 +1,22 @@
// Diese Datei wird von der Codeanalyse zur Wartung der SuppressMessage- #region license
// Attribute verwendet, die auf dieses Projekt angewendet werden. // /*
// Unterdrückungen auf Projektebene haben entweder kein Ziel oder // This file is part of Vocaluxe.
// erhalten ein spezifisches Ziel mit Namespace-, Typ-, Memberbereich usw.
// //
// Wenn Sie dieser Datei eine Unterdrückung hinzufügen möchten, klicken Sie mit der // Vocaluxe is free software: you can redistribute it and/or modify
// rechten Maustaste auf die Meldung in der Fehlerliste, zeigen Sie auf // it under the terms of the GNU General Public License as published by
// "Meldung(en) unterdrücken", und klicken Sie auf "In Projektunterdrückungsdatei". // the Free Software Foundation, either version 3 of the License, or
// Sie müssen dieser Datei nicht manuell Unterdrückungen hinzufügen. // (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
[assembly: [assembly:
+75 -113
View File
@@ -126,19 +126,21 @@ namespace Vocaluxe.Lib.Draw
ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH); ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH);
_SizeBeforeMinimize = ClientSize; _SizeBeforeMinimize = ClientSize;
_PresentParameters = new PresentParameters(); _PresentParameters = new PresentParameters
_PresentParameters.Windowed = true; {
_PresentParameters.SwapEffect = SwapEffect.Discard; Windowed = true,
_PresentParameters.BackBufferHeight = CConfig.ScreenH; SwapEffect = SwapEffect.Discard,
_PresentParameters.BackBufferWidth = CConfig.ScreenW; BackBufferHeight = CConfig.ScreenH,
_PresentParameters.BackBufferFormat = _D3D.Adapters.DefaultAdapter.CurrentDisplayMode.Format; BackBufferWidth = CConfig.ScreenW,
_PresentParameters.Multisample = MultisampleType.None; BackBufferFormat = _D3D.Adapters.DefaultAdapter.CurrentDisplayMode.Format,
_PresentParameters.MultisampleQuality = 0; Multisample = MultisampleType.None,
MultisampleQuality = 0
};
//Apply antialiasing and check if antialiasing mode is supported //Apply antialiasing and check if antialiasing mode is supported
#region Antialiasing #region Antialiasing
int quality = 1; int quality;
MultisampleType msType; MultisampleType msType;
switch (CConfig.AAMode) switch (CConfig.AAMode)
{ {
@@ -174,18 +176,11 @@ namespace Vocaluxe.Lib.Draw
#endregion Antialiasing #endregion Antialiasing
//Apply the VSync configuration //Apply the VSync configuration
if (CConfig.VSync == EOffOn.TR_CONFIG_ON) _PresentParameters.PresentationInterval = CConfig.VSync == EOffOn.TR_CONFIG_ON ? PresentInterval.Default : PresentInterval.Immediate;
_PresentParameters.PresentationInterval = PresentInterval.Default;
else
_PresentParameters.PresentationInterval = PresentInterval.Immediate;
//GMA 950 graphics devices can only process vertices in software mode //GMA 950 graphics devices can only process vertices in software mode
Capabilities caps = _D3D.GetDeviceCaps(_D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware); Capabilities caps = _D3D.GetDeviceCaps(_D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware);
CreateFlags flags = CreateFlags.None; CreateFlags flags = (caps.DeviceCaps & DeviceCaps.HWTransformAndLight) != 0 ? CreateFlags.HardwareVertexProcessing : CreateFlags.SoftwareVertexProcessing;
if ((caps.DeviceCaps & DeviceCaps.HWTransformAndLight) != 0)
flags = CreateFlags.HardwareVertexProcessing;
else
flags = CreateFlags.SoftwareVertexProcessing;
//Check if Pow2 textures are needed //Check if Pow2 textures are needed
_NonPowerOf2TextureSupported = true; _NonPowerOf2TextureSupported = true;
@@ -290,7 +285,7 @@ namespace Vocaluxe.Lib.Draw
_PresentParameters.BackBufferHeight = ClientSize.Height; _PresentParameters.BackBufferHeight = ClientSize.Height;
ClearScreen(); ClearScreen();
//To set new PresentParameters the device has to be resetted //To set new PresentParameters the device has to be resetted
Reset(); _Reset();
//All configurations got flushed due to Reset(), so apply them again //All configurations got flushed due to Reset(), so apply them again
Init(); Init();
@@ -417,11 +412,12 @@ namespace Vocaluxe.Lib.Draw
/// <returns>True if it succeeded else false</returns> /// <returns>True if it succeeded else false</returns>
public bool Init() public bool Init()
{ {
if (!_Device.Disposed) if (_Device.Disposed)
{ return false;
Text = CSettings.GetFullVersionText(); Text = CSettings.GetFullVersionText();
SlimDX.Matrix translate = SlimDX.Matrix.Translation(new Vector3(-CSettings.RenderW / 2, CSettings.RenderH / 2, 0)); SlimDX.Matrix translate = SlimDX.Matrix.Translation(new Vector3(-(float)CSettings.RenderW / 2, (float)CSettings.RenderH / 2, 0));
SlimDX.Matrix projection = SlimDX.Matrix.OrthoOffCenterLH(-CSettings.RenderW / 2, CSettings.RenderW / 2, -CSettings.RenderH / 2, CSettings.RenderH / 2, SlimDX.Matrix projection = SlimDX.Matrix.OrthoOffCenterLH(-(float)CSettings.RenderW / 2, (float)CSettings.RenderW / 2, -(float)CSettings.RenderH / 2,
(float)CSettings.RenderH / 2,
CSettings.ZNear, CSettings.ZFar); CSettings.ZNear, CSettings.ZFar);
_VertexBuffer = new VertexBuffer(_Device, CSettings.VertexBufferElements * (4 * Marshal.SizeOf(typeof(STexturedColoredVertex))), Usage.WriteOnly | Usage.Dynamic, _VertexBuffer = new VertexBuffer(_Device, CSettings.VertexBufferElements * (4 * Marshal.SizeOf(typeof(STexturedColoredVertex))), Usage.WriteOnly | Usage.Dynamic,
VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default); VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default);
@@ -491,9 +487,6 @@ namespace Vocaluxe.Lib.Draw
} }
return true; return true;
} }
else
return false;
}
/// <summary> /// <summary>
/// Starts the rendering /// Starts the rendering
@@ -511,15 +504,12 @@ namespace Vocaluxe.Lib.Draw
} }
//Resize window if aspect ratio is incorrect //Resize window if aspect ratio is incorrect
if (_W / (float)_H != CSettings.GetRenderAspect()) if (Math.Abs(_W / (float)_H - CSettings.GetRenderAspect()) > 0.01)
_DoResize(); _DoResize();
while (_Run) while (_Run)
{ {
Application.DoEvents(); Application.DoEvents();
if (_Run)
{
//Clear the previous Frame //Clear the previous Frame
ClearScreen(); ClearScreen();
//We want to begin drawing //We want to begin drawing
@@ -545,7 +535,7 @@ namespace Vocaluxe.Lib.Draw
//After a reset Init() needs to be called because all data in the Direct3D default pool are lost and need to be recreated //After a reset Init() needs to be called because all data in the Direct3D default pool are lost and need to be recreated
if (_Device.TestCooperativeLevel() == ResultCode.DeviceNotReset) if (_Device.TestCooperativeLevel() == ResultCode.DeviceNotReset)
{ {
Reset(); _Reset();
Init(); Init();
} }
} }
@@ -566,14 +556,13 @@ namespace Vocaluxe.Lib.Draw
CTime.CalculateFPS(); CTime.CalculateFPS();
CTime.Restart(); CTime.Restart();
} }
}
Close(); Close();
} }
/// <summary> /// <summary>
/// Resets the device, all objects in the Direct3D default pool get flushed and need to be recreated /// Resets the device, all objects in the Direct3D default pool get flushed and need to be recreated
/// </summary> /// </summary>
public void Reset() private void _Reset()
{ {
//Dispose all objects in the default pool, those need to be recreated //Dispose all objects in the default pool, those need to be recreated
STexturedColoredVertex.GetDeclaration(_Device).Dispose(); STexturedColoredVertex.GetDeclaration(_Device).Dispose();
@@ -670,8 +659,8 @@ namespace Vocaluxe.Lib.Draw
/// </summary> /// </summary>
private void _RenderVertexBuffer() private void _RenderVertexBuffer()
{ {
if (_Vertices.Count > 0) if (_Vertices.Count <= 0)
{ return;
//The vertex buffer locks are slow actions, its better to lock once per frame and write all vertices to the buffer at once //The vertex buffer locks are slow actions, its better to lock once per frame and write all vertices to the buffer at once
DataStream stream = _VertexBuffer.Lock(0, _Vertices.Count * Marshal.SizeOf(typeof(STexturedColoredVertex)), LockFlags.Discard); DataStream stream = _VertexBuffer.Lock(0, _Vertices.Count * Marshal.SizeOf(typeof(STexturedColoredVertex)), LockFlags.Discard);
stream.WriteRange(_Vertices.ToArray()); stream.WriteRange(_Vertices.ToArray());
@@ -695,7 +684,6 @@ namespace Vocaluxe.Lib.Draw
_VerticesTextures.Clear(); _VerticesTextures.Clear();
_VerticesRotationMatrices.Clear(); _VerticesRotationMatrices.Clear();
} }
}
#endregion main stuff #endregion main stuff
#region Basic Draw Methods #region Basic Draw Methods
@@ -744,7 +732,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="texture">The texture in which the frame is copied to</param> /// <param name="texture">The texture in which the frame is copied to</param>
public void CopyScreen(ref STexture texture) public void CopyScreen(ref STexture texture)
{ {
if (!_TextureExists(ref texture) || (texture.Width != GetScreenWidth()) || (texture.Height != GetScreenHeight())) if (!_TextureExists(ref texture) || (int)texture.Width != GetScreenWidth() || (int)texture.Height != GetScreenHeight())
{ {
RemoveTexture(ref texture); RemoveTexture(ref texture);
texture = CopyScreen(); texture = CopyScreen();
@@ -762,7 +750,7 @@ namespace Vocaluxe.Lib.Draw
/// </summary> /// </summary>
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;
@@ -794,7 +782,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="y2">The end y-value</param> /// <param name="y2">The end y-value</param>
public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2) public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2)
{ {
SColorF color = new SColorF(a / 255, g / 255, b / 255, a / 255); SColorF color = new SColorF((float)a / 255, (float)g / 255, (float)b / 255, (float)a / 255);
DrawTexture(_BlankTexture, new SRectF(x1, y1, x2, y2, 1), color); DrawTexture(_BlankTexture, new SRectF(x1, y1, x2, y2, 1), color);
} }
@@ -805,20 +793,8 @@ namespace Vocaluxe.Lib.Draw
/// <param name="x">The text's x-position</param> /// <param name="x">The text's x-position</param>
/// <param name="y">The text's y-position</param> /// <param name="y">The text's y-position</param>
/// <param name="h">The text's height</param> /// <param name="h">The text's height</param>
public void DrawText(string text, int x, int y, int h) /// <param name="z">The text's z-position</param>
{ public void DrawText(string text, int x, int y, int h, int z = 0)
DrawText(text, x, y, h, 0f);
}
/// <summary>
/// Draws a text string
/// </summary>
/// <param name="text">The text to be drawn</param>
/// <param name="x">The text's x-position</param>
/// <param name="y">The text's y-position</param>
/// <param name="h">The text's height</param>
/// <param name="z">The text's x-position</param>
public void DrawText(string text, int x, int y, float h, float z)
{ {
CFonts.DrawText(text, h, x, y, z, new SColorF(1f, 1f, 1f, 1f)); CFonts.DrawText(text, h, x, y, z, new SColorF(1f, 1f, 1f, 1f));
} }
@@ -871,7 +847,7 @@ namespace Vocaluxe.Lib.Draw
STexture s; STexture s;
try try
{ {
s = AddTexture(bmp, texturePath); s = AddTexture(bmp);
} }
finally finally
{ {
@@ -887,9 +863,8 @@ namespace Vocaluxe.Lib.Draw
/// Adds a texture and stores it in the Vram /// Adds a texture and stores it in the Vram
/// </summary> /// </summary>
/// <param name="bmp">The Bitmap of which the texure will be created from</param> /// <param name="bmp">The Bitmap of which the texure will be created from</param>
/// <param name="texturePath">The path to the texture</param>
/// <returns>A STexture object containing the added texture</returns> /// <returns>A STexture object containing the added texture</returns>
public STexture AddTexture(Bitmap bmp, string texturePath) public STexture AddTexture(Bitmap bmp)
{ {
if (bmp.Height == 0 || bmp.Width == 0) if (bmp.Height == 0 || bmp.Width == 0)
return new STexture(-1); return new STexture(-1);
@@ -919,29 +894,35 @@ namespace Vocaluxe.Lib.Draw
int w = bmp.Width; int w = bmp.Width;
int h = bmp.Height; int h = bmp.Height;
float ratio = (float)w / h;
int newW = w;
int newH = h;
if (w > maxSize && w > h) if (w > maxSize && w > h)
{ newW = maxSize;
h = (int)Math.Round((float)maxSize / bmp.Width * bmp.Height); else if (h > maxSize)
w = maxSize; newH = maxSize;
} else if (w > h)
newW = (int)_CheckForNextPowerOf2(w);
if (h > maxSize) else
{ newH = (int)_CheckForNextPowerOf2(h);
w = (int)Math.Round((float)maxSize / bmp.Height * bmp.Width);
h = maxSize;
}
//Older graphics card can only handle textures with sizes being powers of two
w = (int)_CheckForNextPowerOf2(w);
h = (int)_CheckForNextPowerOf2(h);
Bitmap bmp2 = null; Bitmap bmp2 = null;
byte[] data; byte[] data;
try try
{ {
if (w != bmp.Width || h != bmp.Height) if (w != newW || h != newH)
{ {
if (w != newW)
{
w = newW;
h = (int)Math.Round(w / ratio);
}
else
{
h = newH;
w = (int)Math.Round(h * ratio);
}
//Create a new Bitmap with the new sizes //Create a new Bitmap with the new sizes
bmp2 = new Bitmap(w, h); bmp2 = new Bitmap(w, h);
//Scale the texture //Scale the texture
@@ -965,22 +946,9 @@ namespace Vocaluxe.Lib.Draw
bmp2.Dispose(); bmp2.Dispose();
} }
if (data == null)
return new STexture(-1);
return AddTexture(w, h, ref data); return AddTexture(w, h, ref data);
} }
/// <summary>
/// Adds a texture and stores it in the Vram
/// </summary>
/// <param name="bmp">The Bitmap of which the texure will be created from</param>
/// <returns>A STexture object containing the added texture</returns>
public STexture AddTexture(Bitmap bmp)
{
return AddTexture(bmp, String.Empty);
}
public STexture AddTexture(int w, int h, IntPtr data) public STexture AddTexture(int w, int h, IntPtr data)
{ {
byte[] pointerData = new Byte[4 * w * h]; byte[] pointerData = new Byte[4 * w * h];
@@ -1045,11 +1013,8 @@ namespace Vocaluxe.Lib.Draw
public STexture QuequeTexture(int w, int h, ref byte[] data) public STexture QuequeTexture(int w, int h, ref byte[] data)
{ {
STexture texture = new STexture(-1); STexture texture = new STexture(-1);
STextureQueque queque = new STextureQueque(); STextureQueque queque = new STextureQueque {Data = data, Height = h, Width = w};
queque.Data = data;
queque.Height = h;
queque.Width = w;
texture.Height = h; texture.Height = h;
texture.Width = w; texture.Width = w;
@@ -1125,7 +1090,6 @@ namespace Vocaluxe.Lib.Draw
s.UnlockRectangle(); s.UnlockRectangle();
return true; */ return true; */
} }
else
return false; return false;
} }
#endregion updating #endregion updating
@@ -1325,14 +1289,14 @@ namespace Vocaluxe.Lib.Draw
/// <param name="end">A Value ranging from 0 to 1 containing the ending of the texture</param> /// <param name="end">A Value ranging from 0 to 1 containing the ending of the texture</param>
public void DrawTexture(STexture texture, SRectF rect, SColorF color, float begin, float end) public void DrawTexture(STexture texture, SRectF rect, SColorF color, float begin, float end)
{ {
if (_TextureExists(ref texture)) if (!_TextureExists(ref texture))
{ return;
if (_D3DTextures[texture.Index] == null) if (_D3DTextures[texture.Index] == null)
return; return;
float x1 = 0f + begin * texture.WidthRatio; float x1 = 0f + begin * texture.WidthRatio;
float x2 = texture.WidthRatio * end; float x2 = texture.WidthRatio * end;
float y1 = 0f; const float y1 = 0f;
float y2 = texture.HeightRatio; float y2 = texture.HeightRatio;
float rx1 = rect.X + begin * rect.W; float rx1 = rect.X + begin * rect.W;
@@ -1355,7 +1319,6 @@ namespace Vocaluxe.Lib.Draw
vert[3] = new STexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb()); vert[3] = new STexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb());
_AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2)); _AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
} }
}
/// <summary> /// <summary>
/// Draws a reflection of a texture /// Draws a reflection of a texture
@@ -1368,12 +1331,13 @@ namespace Vocaluxe.Lib.Draw
/// <param name="height">The height of the reflection</param> /// <param name="height">The height of the reflection</param>
public void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float space, float height) public void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
{ {
if (_TextureExists(ref texture)) if (!_TextureExists(ref texture))
{ return;
if (_D3DTextures[texture.Index] == null) if (_D3DTextures[texture.Index] == null)
return; return;
if (rect.W == 0f || rect.H == 0f || bounds.H == 0f || bounds.W == 0f || color.A == 0f || height <= 0f) if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(bounds.H) < float.Epsilon || Math.Abs(bounds.W) < float.Epsilon ||
Math.Abs(color.A) < float.Epsilon || height <= 0f)
return; return;
if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X) if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X)
@@ -1439,7 +1403,6 @@ namespace Vocaluxe.Lib.Draw
_AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2)); _AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
} }
} }
}
#endregion drawing #endregion drawing
private void _CheckQueque() private void _CheckQueque()
@@ -1484,20 +1447,17 @@ namespace Vocaluxe.Lib.Draw
/// <returns>The next power of two</returns> /// <returns>The next power of two</returns>
private float _CheckForNextPowerOf2(float n) private float _CheckForNextPowerOf2(float n)
{ {
if (!_NonPowerOf2TextureSupported) if (_NonPowerOf2TextureSupported)
{ return n;
if (n < 0) if (n < 0)
throw new ArgumentOutOfRangeException("n", "Must be positive."); throw new ArgumentOutOfRangeException("n", "Must be positive.");
return (float)Math.Pow(2, Math.Ceiling(Math.Log(n, 2))); return (float)Math.Pow(2, Math.Ceiling(Math.Log(n, 2)));
} }
else
return n;
}
private SlimDX.Matrix _CalculateRotationMatrix(float rot, float rx1, float rx2, float ry1, float ry2) private SlimDX.Matrix _CalculateRotationMatrix(float rot, float rx1, float rx2, float ry1, float ry2)
{ {
SlimDX.Matrix originTranslation = SlimDX.Matrix.Translation(new Vector3(-CSettings.RenderW / 2, CSettings.RenderH / 2, 0)); SlimDX.Matrix originTranslation = SlimDX.Matrix.Translation(new Vector3(-(float)CSettings.RenderW / 2, (float)CSettings.RenderH / 2, 0));
if (rot != 0) if (Math.Abs(rot) > float.Epsilon)
{ {
float rotation = rot * (float)Math.PI / 180; float rotation = rot * (float)Math.PI / 180;
float centerX = (rx1 + rx2) / 2f; float centerX = (rx1 + rx2) / 2f;
@@ -1519,10 +1479,10 @@ namespace Vocaluxe.Lib.Draw
#endregion utility #endregion utility
#region TexturedColoredVertex #region TexturedColoredVertex
public struct STexturedColoredVertex private struct STexturedColoredVertex
{ {
private static VertexDeclaration _Declaration; private static VertexDeclaration _Declaration;
public static VertexElement[] Elements = private static readonly VertexElement[] _Elements =
{ {
new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0), new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
new VertexElement(0, sizeof(float) * 3, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), new VertexElement(0, sizeof(float) * 3, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
@@ -1530,21 +1490,23 @@ namespace Vocaluxe.Lib.Draw
VertexElement.VertexDeclarationEnd VertexElement.VertexDeclarationEnd
}; };
public Vector3 Position; // ReSharper disable NotAccessedField.Local
public Vector2 Texture; private Vector3 _Position;
public int Color; private Vector2 _Texture;
private int _Color;
// ReSharper restore NotAccessedField.Local
public STexturedColoredVertex(Vector3 position, Vector2 texture, int color) public STexturedColoredVertex(Vector3 position, Vector2 texture, int color)
{ {
Position = position; _Position = position;
Texture = texture; _Texture = texture;
Color = color; _Color = color;
} }
public static VertexDeclaration GetDeclaration(Device device) public static VertexDeclaration GetDeclaration(Device device)
{ {
if (_Declaration == null || _Declaration.Disposed) if (_Declaration == null || _Declaration.Disposed)
_Declaration = new VertexDeclaration(device, Elements); _Declaration = new VertexDeclaration(device, _Elements);
return _Declaration; return _Declaration;
} }
+25 -23
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
@@ -300,7 +319,7 @@ namespace Vocaluxe.Lib.Draw
public void CopyScreen(ref STexture texture) public void CopyScreen(ref STexture texture)
{ {
if ((texture.Index == 0) || (texture.Width != GetScreenWidth()) || (texture.Height != GetScreenHeight())) if (texture.Index == 0 || (int)texture.Width != GetScreenWidth() || (int)texture.Height != GetScreenHeight())
{ {
RemoveTexture(ref texture); RemoveTexture(ref texture);
texture = CopyScreen(); texture = CopyScreen();
@@ -311,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;
@@ -327,13 +346,7 @@ namespace Vocaluxe.Lib.Draw
} }
// Draw Basic Text // Draw Basic Text
public void DrawText(string text, int x, int y, int h) public void DrawText(string text, int x, int y, int h, int z = 0)
{
DrawText(text, x, y, h, 0f);
}
// Draw Basic Text
public void DrawText(string text, int x, int y, float h, float z)
{ {
CFonts.DrawText(text, h, x, y, z, new SColorF(1, 1, 1, 1)); CFonts.DrawText(text, h, x, y, z, new SColorF(1, 1, 1, 1));
} }
@@ -346,15 +359,9 @@ namespace Vocaluxe.Lib.Draw
{ {
Bitmap bmp2 = new Bitmap(bmp); Bitmap bmp2 = new Bitmap(bmp);
_Bitmaps.Add(bmp2); _Bitmaps.Add(bmp2);
STexture texture = new STexture(); STexture texture = new STexture {Index = _Bitmaps.Count - 1, Width = bmp.Width, Height = bmp.Height, Color = new SColorF(1f, 1f, 1f, 1f)};
texture.Index = _Bitmaps.Count - 1;
texture.Width = bmp.Width;
texture.Height = bmp.Height;
// Add to Texture List // Add to Texture List
texture.Color = new SColorF(1f, 1f, 1f, 1f);
texture.Rect = new SRectF(0f, 0f, texture.Width, texture.Height, 0f); texture.Rect = new SRectF(0f, 0f, texture.Width, texture.Height, 0f);
texture.TexturePath = String.Empty; texture.TexturePath = String.Empty;
@@ -499,12 +506,7 @@ namespace Vocaluxe.Lib.Draw
using (Graphics g = Graphics.FromImage(newBitmap)) using (Graphics g = Graphics.FromImage(newBitmap))
{ {
ColorMatrix cm = new ColorMatrix(); ColorMatrix cm = new ColorMatrix {Matrix33 = color.A, Matrix00 = color.R, Matrix11 = color.G, Matrix22 = color.B, Matrix44 = 1};
cm.Matrix33 = color.A;
cm.Matrix00 = color.R;
cm.Matrix11 = color.G;
cm.Matrix22 = color.B;
cm.Matrix44 = 1;
using (ImageAttributes ia = new ImageAttributes()) using (ImageAttributes ia = new ImageAttributes())
{ {
+61 -131
View File
@@ -1,8 +1,26 @@
using System.Drawing.Drawing2D; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Drawing.Drawing2D;
using System.Threading; using System.Threading;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -70,14 +88,12 @@ namespace Vocaluxe.Lib.Draw
//Check AA Mode //Check AA Mode
CConfig.AAMode = (EAntiAliasingModes)_CheckAntiAliasingMode((int)CConfig.AAMode); CConfig.AAMode = (EAntiAliasingModes)_CheckAntiAliasingMode((int)CConfig.AAMode);
CConfig.ColorDepth = (EColorDepth)_CheckColorDepth((int)CConfig.ColorDepth);
ColorFormat cf = new ColorFormat(32);
GraphicsMode gm;
bool ok = false; bool ok = false;
try try
{ {
gm = new GraphicsMode(cf, 24, 0, (int)CConfig.AAMode); GraphicsMode gm = new GraphicsMode((int)CConfig.ColorDepth, 24, 0, (int)CConfig.AAMode);
_Control = new GLControl(gm, 2, 1, GraphicsContextFlags.Default); _Control = new GLControl(gm, 2, 1, GraphicsContextFlags.Default);
if (_Control.GraphicsMode != null) if (_Control.GraphicsMode != null)
ok = true; ok = true;
@@ -121,127 +137,60 @@ namespace Vocaluxe.Lib.Draw
#region Helpers #region Helpers
private int _CheckAntiAliasingMode(int setValue) private int _CheckAntiAliasingMode(int setValue)
{ {
int result = 0; int samples = 0;
GraphicsMode mode = null;
bool done = false;
while (!done && (result <= 32)) if (setValue > 32)
setValue = 32;
while (samples <= setValue)
{ {
GraphicsMode mode;
try try
{ {
mode = new GraphicsMode(16, 0, 0, result); mode = new GraphicsMode(16, 0, 0, samples);
} }
catch (Exception) catch (Exception)
{ {
done = true; break;
result /= 2;
if (result == 1)
result = 0;
} }
if (mode != null) if (mode.Samples != samples)
{ break;
try if (samples == 0)
{ samples = 2;
if (mode.Samples == result)
{
if (result == 0)
result = 2;
else else
result *= 2; samples *= 2;
}
else
{
done = true;
result /= 2;
if (result == 1)
result = 0;
}
}
catch (Exception)
{
done = true;
result /= 2;
if (result == 1)
result = 0;
}
}
else
{
done = true;
result /= 2;
if (result == 1)
result = 0;
}
} }
if (result > 64) if (samples == 2)
result = 32; return 0;
return samples / 2;
if (setValue < result)
return setValue;
else
return result;
} }
private int _CheckColorDeep(int setValue) private int _CheckColorDepth(int setValue)
{ {
int result = 8; int result = 16;
GraphicsMode mode = null;
bool done = false;
while (!done && (result <= 32)) if (setValue > 32)
setValue = 32;
while (result <= setValue)
{ {
GraphicsMode mode;
try try
{ {
mode = new GraphicsMode(result, 0, 0, 0); mode = new GraphicsMode(result, 0, 0, 0);
} }
catch (Exception) catch (Exception)
{ {
done = true; break;
result -= 8;
if (result == 0)
result = 8;
} }
if (mode.ColorFormat != result)
if (mode != null) break;
{
try
{
if (mode.ColorFormat == result)
result += 8; result += 8;
else
{
done = true;
result -= 8;
if (result == 0)
result = 8;
}
}
catch (Exception)
{
done = true;
result -= 8;
if (result == 0)
result = 8;
}
}
else
{
done = true;
result -= 8;
if (result == 0)
result = 8;
}
} }
if (result > 32) return result - 8;
result = 32;
if (setValue < result)
return setValue;
else
return result;
} }
private void _ToggleFullScreen() private void _ToggleFullScreen()
@@ -571,7 +520,7 @@ namespace Vocaluxe.Lib.Draw
public void CopyScreen(ref STexture texture) public void CopyScreen(ref STexture texture)
{ {
if (!_TextureExists(ref texture) || (texture.Width != GetScreenWidth()) || (texture.Height != GetScreenHeight())) if (!_TextureExists(ref texture) || Math.Abs(texture.Width - GetScreenWidth()) > 1 || Math.Abs(texture.Height - GetScreenHeight()) > 1)
{ {
RemoveTexture(ref texture); RemoveTexture(ref texture);
texture = CopyScreen(); texture = CopyScreen();
@@ -589,7 +538,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;
@@ -614,12 +563,7 @@ namespace Vocaluxe.Lib.Draw
public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2) {} public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2) {}
// Draw Basic Text (must be deleted later) // Draw Basic Text (must be deleted later)
public void DrawText(string text, int x, int y, int h) public void DrawText(string text, int x, int y, int h, int z = 0)
{
DrawText(text, x, y, h, 0f);
}
public void DrawText(string text, int x, int y, float h, float z)
{ {
CFonts.DrawText(text, h, x, y, z, new SColorF(1, 1, 1, 1)); CFonts.DrawText(text, h, x, y, z, new SColorF(1, 1, 1, 1));
} }
@@ -664,7 +608,7 @@ namespace Vocaluxe.Lib.Draw
OpenTK.Graphics.OpenGL.GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.Blend); OpenTK.Graphics.OpenGL.GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.Blend);
if (rect.Rotation != 0f) if (Math.Abs(rect.Rotation) > 0.001)
{ {
OpenTK.Graphics.OpenGL.GL.Translate(0.5f, 0.5f, 0); OpenTK.Graphics.OpenGL.GL.Translate(0.5f, 0.5f, 0);
OpenTK.Graphics.OpenGL.GL.Rotate(-rect.Rotation, 0f, 0f, 1f); OpenTK.Graphics.OpenGL.GL.Rotate(-rect.Rotation, 0f, 0f, 1f);
@@ -710,7 +654,7 @@ namespace Vocaluxe.Lib.Draw
} }
try try
{ {
return AddTexture(bmp, texturePath); return AddTexture(bmp);
} }
finally finally
{ {
@@ -722,11 +666,6 @@ namespace Vocaluxe.Lib.Draw
} }
public STexture AddTexture(Bitmap bmp) public STexture AddTexture(Bitmap bmp)
{
return AddTexture(bmp, String.Empty);
}
public STexture AddTexture(Bitmap bmp, string texturePath)
{ {
STexture texture = new STexture(-1); STexture texture = new STexture(-1);
@@ -971,11 +910,8 @@ namespace Vocaluxe.Lib.Draw
public STexture QuequeTexture(int w, int h, ref byte[] data) public STexture QuequeTexture(int w, int h, ref byte[] data)
{ {
STexture texture = new STexture(-1); STexture texture = new STexture(-1);
STextureQueque queque = new STextureQueque(); STextureQueque queque = new STextureQueque {Data = data, Height = h, Width = w};
queque.Data = data;
queque.Height = h;
queque.Width = w;
texture.Height = h; texture.Height = h;
texture.Width = w; texture.Width = w;
@@ -1056,8 +992,6 @@ namespace Vocaluxe.Lib.Draw
if (_TextureExists(ref texture)) if (_TextureExists(ref texture))
{ {
if (_UsePBO) if (_UsePBO)
{
try
{ {
OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, texture.PBO); OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, texture.PBO);
@@ -1075,12 +1009,6 @@ namespace Vocaluxe.Lib.Draw
return true; return true;
} }
catch (Exception)
{
throw;
//_UsePBO = false;
}
}
OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID); OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID);
@@ -1166,7 +1094,8 @@ namespace Vocaluxe.Lib.Draw
public void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored) public void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored)
{ {
if (rect.W == 0f || rect.H == 0f || bounds.H == 0f || bounds.W == 0f || color.A == 0f) if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(bounds.H) < float.Epsilon || Math.Abs(bounds.W) < float.Epsilon ||
Math.Abs(color.A) < float.Epsilon)
return; return;
if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X) if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X)
@@ -1220,7 +1149,7 @@ namespace Vocaluxe.Lib.Draw
OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Texture); OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Texture);
OpenTK.Graphics.OpenGL.GL.PushMatrix(); OpenTK.Graphics.OpenGL.GL.PushMatrix();
if (rect.Rotation != 0f) if (Math.Abs(rect.Rotation) > float.Epsilon)
{ {
OpenTK.Graphics.OpenGL.GL.Translate(0.5f, 0.5f, 0); OpenTK.Graphics.OpenGL.GL.Translate(0.5f, 0.5f, 0);
OpenTK.Graphics.OpenGL.GL.Rotate(-rect.Rotation, 0f, 0f, 1f); OpenTK.Graphics.OpenGL.GL.Rotate(-rect.Rotation, 0f, 0f, 1f);
@@ -1305,7 +1234,8 @@ namespace Vocaluxe.Lib.Draw
public void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float space, float height) public void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
{ {
if (rect.W == 0f || rect.H == 0f || bounds.H == 0f || bounds.W == 0f || color.A == 0f || height <= 0f) if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(bounds.H) < float.Epsilon || Math.Abs(bounds.W) < float.Epsilon ||
Math.Abs(color.A) < float.Epsilon || height <= float.Epsilon)
return; return;
if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X) if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X)
@@ -1361,7 +1291,7 @@ namespace Vocaluxe.Lib.Draw
OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Texture); OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Texture);
OpenTK.Graphics.OpenGL.GL.PushMatrix(); OpenTK.Graphics.OpenGL.GL.PushMatrix();
if (rect.Rotation != 0f) if (Math.Abs(rect.Rotation) > float.Epsilon)
{ {
OpenTK.Graphics.OpenGL.GL.Translate(0.5f, 0.5f, 0); OpenTK.Graphics.OpenGL.GL.Translate(0.5f, 0.5f, 0);
OpenTK.Graphics.OpenGL.GL.Rotate(-rect.Rotation, 0f, 0f, 1f); OpenTK.Graphics.OpenGL.GL.Rotate(-rect.Rotation, 0f, 0f, 1f);
+21 -2
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Drawing; using System.Drawing;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -27,7 +46,7 @@ namespace Vocaluxe.Lib.Draw
void MakeScreenShot(); void MakeScreenShot();
// Draw Basic Text (must be deleted later) // Draw Basic Text (must be deleted later)
void DrawText(string text, int x, int y, int h); void DrawText(string text, int x, int y, int h, int z = 0);
STexture AddTexture(string texturePath); STexture AddTexture(string texturePath);
STexture AddTexture(Bitmap bitmap); STexture AddTexture(Bitmap bitmap);
+38 -23
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Vocaluxe.Base; using Vocaluxe.Base;
@@ -7,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
@@ -47,7 +68,7 @@ namespace Vocaluxe.Lib.Input
public static bool Init() public static bool Init()
{ {
int result = -1; int result;
try try
{ {
result = hid_init(); result = hid_init();
@@ -58,10 +79,7 @@ namespace Vocaluxe.Lib.Input
return false; return false;
} }
if (result == 0) return result == 0;
return true;
return false;
} }
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_exit", CharSet = CharSet.Unicode)] [DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_exit", CharSet = CharSet.Unicode)]
@@ -69,7 +87,7 @@ namespace Vocaluxe.Lib.Input
public static bool Exit() public static bool Exit()
{ {
int result = -1; int result;
try try
{ {
result = hid_exit(); result = hid_exit();
@@ -80,10 +98,7 @@ namespace Vocaluxe.Lib.Input
return false; return false;
} }
if (result == 0) return result == 0;
return true;
return false;
} }
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_enumerate", CharSet = CharSet.Ansi)] [DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_enumerate", CharSet = CharSet.Ansi)]
@@ -150,7 +165,7 @@ namespace Vocaluxe.Lib.Input
data = new byte[length]; data = new byte[length];
IntPtr dataPtr = Marshal.AllocHGlobal(length); IntPtr dataPtr = Marshal.AllocHGlobal(length);
int result = -1; int result;
try try
{ {
result = hid_read_timeout(device, dataPtr, length, milliseconds); result = hid_read_timeout(device, dataPtr, length, milliseconds);
@@ -178,7 +193,7 @@ namespace Vocaluxe.Lib.Input
data = new byte[length]; data = new byte[length];
IntPtr dataPtr = Marshal.AllocHGlobal(length); IntPtr dataPtr = Marshal.AllocHGlobal(length);
int result = -1; int result;
try try
{ {
result = hid_read(device, dataPtr, length); result = hid_read(device, dataPtr, length);
+24 -5
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -15,10 +34,10 @@ namespace Vocaluxe.Lib.Input
interface IInput interface IInput
{ {
bool Init(); void Init();
void Close(); void Close();
bool Connect(); void Connect();
bool Disconnect(); void Disconnect();
bool IsConnected(); bool IsConnected();
void Update(); void Update();
@@ -38,7 +57,7 @@ namespace Vocaluxe.Lib.Input
{ {
get get
{ {
if (!_Timer.IsRunning && _Duration != 0f) if (!_Timer.IsRunning && Math.Abs(_Duration) > float.Epsilon)
{ {
_Timer.Start(); _Timer.Start();
return true; return true;
+34 -37
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Threading; using System.Threading;
@@ -31,15 +50,13 @@ namespace Vocaluxe.Lib.Input.WiiMote
private CGesture _Gesture; private CGesture _Gesture;
public bool Init() public void Init()
{ {
_Sync = new Object(); _Sync = new Object();
_RumbleTimer = new CRumbleTimer(); _RumbleTimer = new CRumbleTimer();
_Gesture = new CGesture(); _Gesture = new CGesture();
_Active = true; _HandlerThread = new Thread(_MainLoop) {Priority = ThreadPriority.BelowNormal};
_HandlerThread = new Thread(_MainLoop);
_HandlerThread.Priority = ThreadPriority.BelowNormal;
_KeysPool = new List<SKeyEvent>(); _KeysPool = new List<SKeyEvent>();
_CurrentKeysPool = new List<SKeyEvent>(); _CurrentKeysPool = new List<SKeyEvent>();
@@ -49,10 +66,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
_ButtonStates = new bool[11]; _ButtonStates = new bool[11];
_OldPosition = new Point(); _OldPosition = new Point();
_HandlerThread.Start();
return true;
} }
public void Close() public void Close()
@@ -60,20 +73,17 @@ namespace Vocaluxe.Lib.Input.WiiMote
_Active = false; _Active = false;
} }
public bool Connect() public void Connect()
{
if (!_Active)
{ {
if (_Active)
return;
_Active = true; _Active = true;
_HandlerThread.Start(); _HandlerThread.Start();
} }
return true;
}
public bool Disconnect() public void Disconnect()
{ {
_Active = false; _Active = false;
return true;
} }
public bool IsConnected() public bool IsConnected()
@@ -94,7 +104,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
_CurrentKeysPool.RemoveAt(0); _CurrentKeysPool.RemoveAt(0);
return true; return true;
} }
else
return false; return false;
} }
@@ -106,7 +115,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
_CurrentMousePool.RemoveAt(0); _CurrentMousePool.RemoveAt(0);
return true; return true;
} }
else
return false; return false;
} }
@@ -134,8 +142,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
} }
else else
{ {
bool startRumble = false; bool startRumble;
bool stopRumble = false; bool stopRumble;
lock (_Sync) lock (_Sync)
{ {
startRumble = _RumbleTimer.ShouldStart; startRumble = _RumbleTimer.ShouldStart;
@@ -192,13 +200,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
Point p = ws.IRState.Position; Point p = ws.IRState.Position;
p.X = 1023 - p.X; p.X = 1023 - p.X;
//key events
bool alt = false;
bool shift = false;
bool ctrl = false;
bool pressed = false;
char unicode = char.MinValue;
EGesture gesture = _Gesture.GetGesture(p); EGesture gesture = _Gesture.GetGesture(p);
bool lb = false; bool lb = false;
bool rb = gesture == EGesture.Back; bool rb = gesture == EGesture.Back;
@@ -243,9 +244,9 @@ namespace Vocaluxe.Lib.Input.WiiMote
_ButtonStates[10] = ws.ButtonState.Two; _ButtonStates[10] = ws.ButtonState.Two;
if (alt || shift || ctrl || pressed || unicode != char.MinValue || key != Keys.None) if (key != Keys.None)
{ {
SKeyEvent pool = new SKeyEvent(ESender.WiiMote, alt, shift, ctrl, pressed, unicode, key); SKeyEvent pool = new SKeyEvent(ESender.WiiMote, false, false, false, false, char.MinValue, key);
lock (_KeyCopyLock) lock (_KeyCopyLock)
{ {
@@ -254,8 +255,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
} }
//mouse events //mouse events
float reducing = 0.15f; const float reducing = 0.15f;
float factor = 1f / (1f - reducing * 2f); const float factor = 1f / (1f - reducing * 2f);
float rx = ((p.X / 1024f) - reducing) * factor; float rx = ((p.X / 1024f) - reducing) * factor;
float ry = ((p.Y / 768f) - reducing) * factor; float ry = ((p.Y / 768f) - reducing) * factor;
@@ -263,11 +264,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
int y = (int)(ry * CSettings.RenderH); int y = (int)(ry * CSettings.RenderH);
bool ld = false;
bool lbh = !lb && ws.ButtonState.A; bool lbh = !lb && ws.ButtonState.A;
bool rbh = false;
bool mb = false;
bool mbh = false;
int wheel = 0; int wheel = 0;
if (gesture == EGesture.ScrollUp) if (gesture == EGesture.ScrollUp)
@@ -280,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, alt, shift, ctrl, x, y, false, false, false, wheel, lbh, rbh, false, mbh); 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, alt, shift, ctrl, x, y, lb, ld, rb, wheel, false, false, mb, false); mpool = new SMouseEvent(ESender.WiiMote, EModifier.None, x, y, lb, false, rb, wheel, false, false, false, false);
trigger = true; trigger = true;
} }
+73 -53
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Drawing; using System.Drawing;
using System.Threading; using System.Threading;
using Vocaluxe.Base; using Vocaluxe.Base;
@@ -10,15 +29,17 @@ namespace Vocaluxe.Lib.Input.WiiMote
#region DataTypes #region DataTypes
public class CWiiMoteStatus public class CWiiMoteStatus
{ {
public SAccelCalibrationInfo AccelCalibrationInfo = new SAccelCalibrationInfo(); public SAccelCalibrationInfo AccelCalibrationInfo;
public SAccelStatus AccelState = new SAccelStatus(); public SAccelStatus AccelState;
public SButtons ButtonState = new SButtons(); public SButtons ButtonState;
public SIRState IRState = new SIRState(); public SIRState IRState;
// ReSharper disable NotAccessedField.Global
public byte Battery; public byte Battery;
// ReSharper restore NotAccessedField.Global
public bool Rumble; public bool Rumble;
@@ -49,7 +70,9 @@ namespace Vocaluxe.Lib.Input.WiiMote
{ {
public bool Active; public bool Active;
public Point Position; // X: 0-1023; Y: 0-767 public Point Position; // X: 0-1023; Y: 0-767
// ReSharper disable NotAccessedField.Global
public int Width; // 0-15 public int Width; // 0-15
// ReSharper restore NotAccessedField.Global
} }
public struct SIRState public struct SIRState
@@ -63,7 +86,9 @@ namespace Vocaluxe.Lib.Input.WiiMote
public struct SAccelStatus public struct SAccelStatus
{ {
public SPoint3 RawValues; //0-255 public SPoint3 RawValues; //0-255
// ReSharper disable NotAccessedField.Global
public SPoint3F Values; //0-3 public SPoint3F Values; //0-3
// ReSharper restore NotAccessedField.Global
} }
public struct SAccelCalibrationInfo public struct SAccelCalibrationInfo
@@ -105,7 +130,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
#region Events #region Events
public class CWiiMoteChangedEventArgs : EventArgs public class CWiiMoteChangedEventArgs : EventArgs
{ {
public CWiiMoteStatus WiiMoteState; public readonly CWiiMoteStatus WiiMoteState;
public CWiiMoteChangedEventArgs(CWiiMoteStatus ws) public CWiiMoteChangedEventArgs(CWiiMoteStatus ws)
{ {
@@ -114,11 +139,11 @@ namespace Vocaluxe.Lib.Input.WiiMote
} }
#endregion Events #endregion Events
public class CWiiMoteLib : IDisposable public sealed class CWiiMoteLib : IDisposable
{ {
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
private const ushort _VID = 0x057e; private const ushort _VID = 0x057e;
// ReSharper restore InconsistentNaming // ReSharper restore InconsistentNaming
private const ushort _PID = 0x0306; //Wiimotion private const ushort _PID = 0x0306; //Wiimotion
private const ushort _PIDPlus = 0x0330; //Wiimotion Plus private const ushort _PIDPlus = 0x0330; //Wiimotion Plus
@@ -133,9 +158,10 @@ namespace Vocaluxe.Lib.Input.WiiMote
// output commands // output commands
private enum EOutputReport : byte private enum EOutputReport : byte
{ {
// ReSharper disable InconsistentNaming // ReSharper disable UnusedMember.Local
// ReSharper disable InconsistentNaming
LEDs = 0x11, LEDs = 0x11,
// ReSharper restore InconsistentNaming // ReSharper restore InconsistentNaming
Type = 0x12, Type = 0x12,
IR = 0x13, IR = 0x13,
Status = 0x15, Status = 0x15,
@@ -144,6 +170,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
SpeakerData = 0x18, SpeakerData = 0x18,
SpeakerMute = 0x19, SpeakerMute = 0x19,
IR2 = 0x1a, IR2 = 0x1a,
// ReSharper restore UnusedMember.Local
}; };
// data handling // data handling
@@ -157,11 +184,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
private bool _Active; private bool _Active;
private bool _Error; private bool _Error;
private bool _Connected; public bool Connected { get; private set; }
public bool Connected
{
get { return _Connected; }
}
private readonly CWiiMoteStatus _WiiMoteState = new CWiiMoteStatus(); private readonly CWiiMoteStatus _WiiMoteState = new CWiiMoteStatus();
private readonly AutoResetEvent _ReadDone = new AutoResetEvent(false); private readonly AutoResetEvent _ReadDone = new AutoResetEvent(false);
@@ -170,13 +193,18 @@ namespace Vocaluxe.Lib.Input.WiiMote
#region Interface #region Interface
public CWiiMoteLib() public CWiiMoteLib()
{ {
_Connected = false; Connected = false;
_Active = true; _Active = true;
_Error = false; _Error = false;
_Reader = new Thread(_ReaderLoop); _Reader = new Thread(_ReaderLoop);
_Reader.Start(); _Reader.Start();
} }
~CWiiMoteLib()
{
Dispose(false);
}
private bool _TryConnect(ushort pid) private bool _TryConnect(ushort pid)
{ {
bool connected = CHIDApi.Open(_VID, pid, out _Handle); bool connected = CHIDApi.Open(_VID, pid, out _Handle);
@@ -191,7 +219,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
public bool Connect() public bool Connect()
{ {
_Connected = false; Connected = false;
if (_Error) if (_Error)
return false; return false;
@@ -201,7 +229,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
if (!CHIDApi.Init()) if (!CHIDApi.Init())
{ {
CLog.LogError("WiiMoteLib: Can't initialize HID API"); CLog.LogError("WiiMoteLib: Can't initialize HID API");
string msg = "Please install the Visual C++ Redistributable Packages 2008!"; const string msg = "Please install the Visual C++ Redistributable Packages 2008!";
CLog.LogError(msg); CLog.LogError(msg);
_Active = false; _Active = false;
@@ -210,25 +238,25 @@ namespace Vocaluxe.Lib.Input.WiiMote
} }
//Try WiiMotion //Try WiiMotion
_Connected = _TryConnect(_PID); Connected = _TryConnect(_PID);
//Try WiiMotion Plus //Try WiiMotion Plus
if (!_Connected) if (!Connected)
_Connected = _TryConnect(_PIDPlus); Connected = _TryConnect(_PIDPlus);
return _Connected; return Connected;
} }
public void Disconnect() public void Disconnect()
{ {
_Connected = false; Connected = false;
_Active = false; _Active = false;
CHIDApi.Exit(); CHIDApi.Exit();
} }
public void SetReportType(EInputReport type, EIRSensitivity irSensitivity, bool continuous) public void SetReportType(EInputReport type, EIRSensitivity irSensitivity, bool continuous)
{ {
if (!_Connected) if (!Connected)
return; return;
switch (type) switch (type)
@@ -256,14 +284,13 @@ namespace Vocaluxe.Lib.Input.WiiMote
_WiiMoteState.LEDState.LED3 = led3; _WiiMoteState.LEDState.LED3 = led3;
_WiiMoteState.LEDState.LED4 = led4; _WiiMoteState.LEDState.LED4 = led4;
if (!_Connected) if (!Connected)
return; return;
_ClearReport(); _ClearReport();
_Buff[0] = (byte)EOutputReport.LEDs; _Buff[0] = (byte)EOutputReport.LEDs;
_Buff[1] = (byte)( _Buff[1] = (byte)((led1 ? 0x10 : 0x00) |
(led1 ? 0x10 : 0x00) |
(led2 ? 0x20 : 0x00) | (led2 ? 0x20 : 0x00) |
(led3 ? 0x40 : 0x00) | (led3 ? 0x40 : 0x00) |
(led4 ? 0x80 : 0x00) | (led4 ? 0x80 : 0x00) |
@@ -282,11 +309,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
_WiiMoteState.LEDState.LED3, _WiiMoteState.LEDState.LED3,
_WiiMoteState.LEDState.LED4); _WiiMoteState.LEDState.LED4);
} }
public CWiiMoteStatus WiiMoteState
{
get { return _WiiMoteState; }
}
#endregion Interface #endregion Interface
#region Private stuff #region Private stuff
@@ -296,7 +318,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
{ {
Thread.Sleep(5); Thread.Sleep(5);
if (_Handle != IntPtr.Zero && _Connected) if (_Handle != IntPtr.Zero && Connected)
{ {
byte[] buff = new byte[_ReportLength]; byte[] buff = new byte[_ReportLength];
@@ -322,7 +344,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
{ {
if (buff == null) if (buff == null)
{ {
_Connected = false; Connected = false;
return false; return false;
} }
@@ -389,6 +411,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
return true; return true;
} }
/*
private byte[] _DecryptBuffer(byte[] buff) private byte[] _DecryptBuffer(byte[] buff)
{ {
for (int i = 0; i < buff.Length; i++) for (int i = 0; i < buff.Length; i++)
@@ -396,6 +419,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
return buff; return buff;
} }
*/
private void _ParseButtons(byte[] buff) private void _ParseButtons(byte[] buff)
{ {
@@ -431,14 +455,15 @@ namespace Vocaluxe.Lib.Input.WiiMote
switch (_WiiMoteState.IRState.Mode) switch (_WiiMoteState.IRState.Mode)
{ {
case EIRMode.Basic: case EIRMode.Basic:
if (_WiiMoteState.IRState.Sensors[0].Active = !(buff[6] == 0xff && buff[7] == 0xff)) _WiiMoteState.IRState.Sensors[0].Active = !(buff[6] == 0xff && buff[7] == 0xff);
if (_WiiMoteState.IRState.Sensors[0].Active)
{ {
_WiiMoteState.IRState.Sensors[0].Position.X = buff[6] | ((buff[8] >> 4) & 0x03) << 8; _WiiMoteState.IRState.Sensors[0].Position.X = buff[6] | ((buff[8] >> 4) & 0x03) << 8;
_WiiMoteState.IRState.Sensors[0].Position.Y = buff[7] | ((buff[8] >> 6) & 0x03) << 8; _WiiMoteState.IRState.Sensors[0].Position.Y = buff[7] | ((buff[8] >> 6) & 0x03) << 8;
_WiiMoteState.IRState.Sensors[0].Width = 0; _WiiMoteState.IRState.Sensors[0].Width = 0;
} }
_WiiMoteState.IRState.Sensors[1].Active = !(buff[9] == 0xff && buff[10] == 0xff);
if (_WiiMoteState.IRState.Sensors[1].Active = !(buff[9] == 0xff && buff[10] == 0xff)) if (_WiiMoteState.IRState.Sensors[1].Active)
{ {
_WiiMoteState.IRState.Sensors[1].Position.X = buff[9] | ((buff[8] >> 0) & 0x03) << 8; _WiiMoteState.IRState.Sensors[1].Position.X = buff[9] | ((buff[8] >> 0) & 0x03) << 8;
_WiiMoteState.IRState.Sensors[1].Position.Y = buff[10] | ((buff[8] >> 2) & 0x03) << 8; _WiiMoteState.IRState.Sensors[1].Position.Y = buff[10] | ((buff[8] >> 2) & 0x03) << 8;
@@ -448,13 +473,13 @@ namespace Vocaluxe.Lib.Input.WiiMote
case EIRMode.Extended: case EIRMode.Extended:
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
if (_WiiMoteState.IRState.Sensors[i].Active = !(buff[6 + i * 3] == 0xff && buff[7 + i * 3] == 0xff && buff[8 + i * 3] == 0xff)) _WiiMoteState.IRState.Sensors[i].Active = !(buff[6 + i * 3] == 0xff && buff[7 + i * 3] == 0xff && buff[8 + i * 3] == 0xff);
{ if (!_WiiMoteState.IRState.Sensors[i].Active)
continue;
_WiiMoteState.IRState.Sensors[i].Position.X = buff[6 + i * 3] | ((buff[8 + i * 3] >> 4) & 0x03) << 8; _WiiMoteState.IRState.Sensors[i].Position.X = buff[6 + i * 3] | ((buff[8 + i * 3] >> 4) & 0x03) << 8;
_WiiMoteState.IRState.Sensors[i].Position.Y = buff[7 + i * 3] | ((buff[8 + i * 3] >> 6) & 0x03) << 8; _WiiMoteState.IRState.Sensors[i].Position.Y = buff[7 + i * 3] | ((buff[8 + i * 3] >> 6) & 0x03) << 8;
_WiiMoteState.IRState.Sensors[i].Width = buff[8 + i * 3] & 0x0f; _WiiMoteState.IRState.Sensors[i].Width = buff[8 + i * 3] & 0x0f;
} }
}
break; break;
} }
@@ -485,13 +510,13 @@ namespace Vocaluxe.Lib.Input.WiiMote
if ((buff[3] & 0x08) != 0) if ((buff[3] & 0x08) != 0)
{ {
CLog.LogError("Error reading data from WiiMote: Bytes do not exist"); CLog.LogError("Error reading data from WiiMote: Bytes do not exist");
_Connected = false; Connected = false;
} }
if ((buff[3] & 0x07) != 0) if ((buff[3] & 0x07) != 0)
{ {
CLog.LogError("Error reading data from WiiMote: Attempt to read from write-only registers."); CLog.LogError("Error reading data from WiiMote: Attempt to read from write-only registers.");
_Connected = false; Connected = false;
} }
int size = (buff[3] >> 4) + 1; int size = (buff[3] >> 4) + 1;
@@ -505,12 +530,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
private byte _RumbleBit private byte _RumbleBit
{ {
get get { return (byte)(_WiiMoteState.Rumble ? 1 : 0); }
{
if (_WiiMoteState.Rumble)
return 0x1;
return 0x0;
}
} }
private bool _ReadCalibration() private bool _ReadCalibration()
@@ -630,7 +650,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
if (!_ReadDone.WaitOne(1000, false)) if (!_ReadDone.WaitOne(1000, false))
{ {
_Connected = false; Connected = false;
return null; return null;
} }
@@ -667,9 +687,9 @@ namespace Vocaluxe.Lib.Input.WiiMote
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
protected virtual void Dispose(bool disposing) private void Dispose(bool disposing)
// ReSharper restore InconsistentNaming // ReSharper restore InconsistentNaming
{ {
if (disposing) if (disposing)
{ {
+40 -36
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
@@ -40,7 +59,7 @@ namespace Vocaluxe.Lib.Playlist
public void SavePlaylist() public void SavePlaylist()
{ {
if (PlaylistFile.Length == 0) if (PlaylistFile == "")
{ {
string filename = string.Empty; string filename = string.Empty;
foreach (char chr in PlaylistName) foreach (char chr in PlaylistName)
@@ -49,7 +68,7 @@ namespace Vocaluxe.Lib.Playlist
filename += chr.ToString(); filename += chr.ToString();
} }
if (filename.Length == 0) if (filename == "")
filename = "1"; filename = "1";
int i = 0; int i = 0;
@@ -74,12 +93,6 @@ namespace Vocaluxe.Lib.Playlist
return; return;
} }
if (writer == null)
{
CLog.LogError("Error creating/opening Playlist File " + PlaylistFile);
return;
}
try try
{ {
writer.WriteStartDocument(); writer.WriteStartDocument();
@@ -95,7 +108,7 @@ namespace Vocaluxe.Lib.Playlist
CSong song = CSongs.GetSong(Songs[i].SongID); CSong song = CSongs.GetSong(Songs[i].SongID);
if (song != null) if (song != null)
{ {
writer.WriteStartElement("Song" + (i + 1).ToString()); writer.WriteStartElement("Song" + (i + 1));
writer.WriteElementString("Artist", song.Artist); writer.WriteElementString("Artist", song.Artist);
writer.WriteElementString("Title", song.Title); writer.WriteElementString("Title", song.Title);
writer.WriteElementString("GameMode", Enum.GetName(typeof(EGameMode), Songs[i].GameMode)); writer.WriteElementString("GameMode", Enum.GetName(typeof(EGameMode), Songs[i].GameMode));
@@ -124,40 +137,38 @@ namespace Vocaluxe.Lib.Playlist
return; return;
string value = String.Empty; string value = String.Empty;
if (xmlReader.GetValue("//root/Info/PlaylistName", ref value, value)) if (xmlReader.GetValue("//root/Info/PlaylistName", out value, value))
{ {
PlaylistName = value; PlaylistName = value;
Songs = new List<CPlaylistSong>(); Songs = new List<CPlaylistSong>();
List<string> songs = xmlReader.GetValues("Songs"); List<string> songs = xmlReader.GetValues("Songs");
string artist = String.Empty;
string title = String.Empty;
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
for (int i = 0; i < songs.Count; i++) foreach (string song in songs)
{ {
xmlReader.GetValue("//root/Songs/" + songs[i] + "/Artist", ref artist, String.Empty); string artist;
xmlReader.GetValue("//root/Songs/" + songs[i] + "/Title", ref title, String.Empty); string title;
xmlReader.TryGetEnumValue("//root/Songs/" + songs[i] + "/GameMode", ref gm); xmlReader.GetValue("//root/Songs/" + song + "/Artist", out artist, String.Empty);
xmlReader.GetValue("//root/Songs/" + song + "/Title", out title, String.Empty);
xmlReader.TryGetEnumValue("//root/Songs/" + song + "/GameMode", ref gm);
CPlaylistSong song = new CPlaylistSong(); CPlaylistSong playlistSong = new CPlaylistSong {SongID = -1};
song.SongID = -1;
CSong[] allSongs = CSongs.AllSongs; CSong[] allSongs = CSongs.AllSongs;
for (int s = 0; s < allSongs.Length; s++) foreach (CSong curSong in allSongs)
{ {
if (allSongs[s].Artist == artist && allSongs[s].Title == title) if (curSong.Artist != artist || curSong.Title != title)
{ continue;
song.SongID = allSongs[s].ID; playlistSong.SongID = curSong.ID;
break; break;
} }
}
if (song.SongID != -1) if (playlistSong.SongID != -1)
{ {
song.GameMode = gm; playlistSong.GameMode = gm;
Songs.Add(song); Songs.Add(playlistSong);
} }
else else
CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + PlaylistFile); CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + PlaylistFile);
@@ -169,21 +180,14 @@ namespace Vocaluxe.Lib.Playlist
public void AddSong(int songID) public void AddSong(int songID)
{ {
CPlaylistSong song = new CPlaylistSong(); CPlaylistSong song = new CPlaylistSong {SongID = songID, GameMode = CSongs.GetSong(songID).IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL};
song.SongID = songID;
if (CSongs.GetSong(songID).IsDuet)
song.GameMode = EGameMode.TR_GAMEMODE_DUET;
else
song.GameMode = EGameMode.TR_GAMEMODE_NORMAL;
Songs.Add(song); Songs.Add(song);
} }
public void AddSong(int songID, EGameMode gm) public void AddSong(int songID, EGameMode gm)
{ {
CPlaylistSong song = new CPlaylistSong(); CPlaylistSong song = new CPlaylistSong {SongID = songID, GameMode = gm};
song.SongID = songID;
song.GameMode = gm;
Songs.Add(song); Songs.Add(song);
} }
+35 -27
View File
@@ -1,4 +1,23 @@
using SlimDX.DirectSound; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using SlimDX.DirectSound;
using SlimDX.Multimedia; using SlimDX.Multimedia;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -36,15 +55,9 @@ namespace Vocaluxe.Lib.Sound
{ {
using (DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid)) using (DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid))
{ {
SRecordDevice device = new SRecordDevice(); SRecordDevice device = new SRecordDevice {Driver = dev.DriverGuid.ToString(), ID = id, Name = dev.Description, Inputs = new List<SInput>()};
device.Driver = dev.DriverGuid.ToString();
device.ID = id;
device.Name = dev.Description;
device.Inputs = new List<SInput>();
SInput inp = new SInput(); SInput inp = new SInput {Name = "Default", Channels = ds.Capabilities.Channels};
inp.Name = "Default";
inp.Channels = ds.Capabilities.Channels;
if (inp.Channels > 2) if (inp.Channels > 2)
inp.Channels = 2; //more are not supported in vocaluxe inp.Channels = 2; //more are not supported in vocaluxe
@@ -77,8 +90,8 @@ namespace Vocaluxe.Lib.Sound
if (!_Initialized) if (!_Initialized)
return false; return false;
for (int i = 0; i < _Buffer.Length; i++) foreach (CBuffer buffer in _Buffer)
_Buffer[i].Reset(); buffer.Reset();
_DeviceConfig = deviceConfig; _DeviceConfig = deviceConfig;
bool[] active = new bool[deviceConfig.Length]; bool[] active = new bool[deviceConfig.Length];
@@ -101,8 +114,7 @@ namespace Vocaluxe.Lib.Sound
{ {
if (active[i]) if (active[i])
{ {
CSoundCardSource source = new CSoundCardSource(guid[i], channels[i]); CSoundCardSource source = new CSoundCardSource(guid[i], channels[i]) {SampleRateKhz = 44.1};
source.SampleRateKhz = 44.1;
source.SampleDataReady += _OnDataReady; source.SampleDataReady += _OnDataReady;
source.Start(); source.Start();
@@ -265,8 +277,8 @@ namespace Vocaluxe.Lib.Sound
public CSoundCardSource(Guid guid, short channels) public CSoundCardSource(Guid guid, short channels)
{ {
this._Guid = guid; _Guid = guid;
this._Channels = channels; _Channels = channels;
_WaveFormat = new WaveFormat(); _WaveFormat = new WaveFormat();
SampleRateKhz = 44.1; SampleRateKhz = 44.1;
_BufferSize = 2048; _BufferSize = 2048;
@@ -317,9 +329,7 @@ namespace Vocaluxe.Lib.Sound
for (int i = 0; i < _BufferPortionCount; i++) for (int i = 0; i < _BufferPortionCount; i++)
{ {
NotificationPosition notification = new NotificationPosition(); NotificationPosition notification = new NotificationPosition {Offset = _BufferPortionCount - 1 + (_BufferPortionSize * i), Event = new AutoResetEvent(false)};
notification.Offset = _BufferPortionCount - 1 + (_BufferPortionSize * i);
notification.Event = new AutoResetEvent(false);
_Notifications.Add(notification); _Notifications.Add(notification);
} }
@@ -329,8 +339,7 @@ namespace Vocaluxe.Lib.Sound
for (int i = 0; i < _Notifications.Count; i++) for (int i = 0; i < _Notifications.Count; i++)
_WaitHandles[i] = _Notifications[i].Event; _WaitHandles[i] = _Notifications[i].Event;
_CaptureThread = new Thread(_DoCapture); _CaptureThread = new Thread(_DoCapture) {IsBackground = true};
_CaptureThread.IsBackground = true;
_Running = true; _Running = true;
_CaptureThread.Start(); _CaptureThread.Start();
@@ -354,8 +363,8 @@ namespace Vocaluxe.Lib.Sound
if (_Notifications != null) if (_Notifications != null)
{ {
for (int i = 0; i < _Notifications.Count; i++) foreach (NotificationPosition notification in _Notifications)
_Notifications[i].Event.Close(); notification.Event.Close();
_Notifications.Clear(); _Notifications.Clear();
_Notifications = null; _Notifications = null;
@@ -374,13 +383,12 @@ namespace Vocaluxe.Lib.Sound
// Buffer type must match this.waveFormat.FormatTag and this.waveFormat.BitsPerSample // Buffer type must match this.waveFormat.FormatTag and this.waveFormat.BitsPerSample
byte[] bufferPortion = new byte[bufferPortionSamples]; byte[] bufferPortion = new byte[bufferPortionSamples];
int bufferPortionIndex;
_CaptureBuffer.Start(true); _CaptureBuffer.Start(true);
while (_Running) while (_Running)
{ {
bufferPortionIndex = WaitHandle.WaitAny(_WaitHandles); int bufferPortionIndex = WaitHandle.WaitAny(_WaitHandles);
_CaptureBuffer.Read( _CaptureBuffer.Read(
bufferPortion, bufferPortion,
@@ -400,9 +408,9 @@ namespace Vocaluxe.Lib.Sound
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
protected virtual void Dispose(bool disposing) protected void Dispose(bool disposing)
// ReSharper restore InconsistentNaming // ReSharper restore InconsistentNaming
{ {
if (disposing) if (disposing)
{ {
+23 -7
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.Lib.Sound.Gstreamer; using Vocaluxe.Lib.Sound.Gstreamer;
@@ -7,10 +26,9 @@ namespace Vocaluxe.Lib.Sound
class CGstreamerAudio : IPlayback class CGstreamerAudio : IPlayback
{ {
//static float LastPosition; //static float LastPosition;
#region log
public CGstreamerAudioWrapper.LogCallback Log;
private void _LogHandler(string text) #region log
private static void _LogHandler(string text)
{ {
CLog.LogError(text); CLog.LogError(text);
} }
@@ -18,11 +36,9 @@ namespace Vocaluxe.Lib.Sound
public CGstreamerAudio() public CGstreamerAudio()
{ {
Init();
Log = _LogHandler;
//Is this really needed? CodaAnalyzer complains about it... //Is this really needed? CodaAnalyzer complains about it...
//GC.SuppressFinalize(Log); //GC.SuppressFinalize(Log);
CGstreamerAudioWrapper.SetLogCallback(Log); CGstreamerAudioWrapper.SetLogCallback(_LogHandler);
} }
public bool Init() public bool Init()
+33 -40
View File
@@ -1,4 +1,24 @@
using OpenTK.Audio; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Linq;
using OpenTK.Audio;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@@ -21,11 +41,6 @@ namespace Vocaluxe.Lib.Sound
private List<SAudioStreams> _Streams; private List<SAudioStreams> _Streams;
public COpenALPlay()
{
Init();
}
public bool Init() public bool Init()
{ {
if (_Initialized) if (_Initialized)
@@ -100,7 +115,6 @@ namespace Vocaluxe.Lib.Sound
{ {
_Decoder.Add(decoder); _Decoder.Add(decoder);
stream.Handle = _Count++; stream.Handle = _Count++;
stream.File = media;
_Streams.Add(stream); _Streams.Add(stream);
return stream.Handle; return stream.Handle;
} }
@@ -299,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)
@@ -317,15 +326,6 @@ namespace Vocaluxe.Lib.Sound
return -1; return -1;
} }
private void _EndSync(int handle, int stream, int data, IntPtr user)
{
if (_Initialized)
{
if (_AlreadyAdded(stream))
Close(stream);
}
}
private void _CloseProc(int streamID) private void _CloseProc(int streamID)
{ {
if (_Initialized) if (_Initialized)
@@ -380,7 +380,6 @@ namespace Vocaluxe.Lib.Sound
private Closeproc _Closeproc; private Closeproc _Closeproc;
private int _StreamID; private int _StreamID;
private string _FileName;
private IAudioDecoder _Decoder; private IAudioDecoder _Decoder;
private float _BytesPerSecond; private float _BytesPerSecond;
private bool _NoMoreData; private bool _NoMoreData;
@@ -422,7 +421,7 @@ namespace Vocaluxe.Lib.Sound
_Closeproc = closeProc; _Closeproc = closeProc;
_StreamID = streamID; _StreamID = streamID;
_Terminated = true; _Terminated = true;
this._CloseMutex = closeMutex; _CloseMutex = closeMutex;
} }
public float Length public float Length
@@ -487,7 +486,7 @@ namespace Vocaluxe.Lib.Sound
{ {
if (Finished) if (Finished)
_Timer.Stop(); _Timer.Stop();
//TODO: Why not use Decoder.GetPosition()?
return _CurrentTime + _Timer.ElapsedMilliseconds / 1000f; return _CurrentTime + _Timer.ElapsedMilliseconds / 1000f;
} }
} }
@@ -567,9 +566,6 @@ namespace Vocaluxe.Lib.Sound
if (!File.Exists(fileName)) if (!File.Exists(fileName))
return -1; return -1;
if (_FileOpened)
return -1;
_Decoder = new CAudioDecoderFFmpeg(); _Decoder = new CAudioDecoderFFmpeg();
_Decoder.Init(); _Decoder.Init();
@@ -590,7 +586,6 @@ namespace Vocaluxe.Lib.Sound
return -1; return -1;
} }
_FileName = fileName;
_Decoder.Open(fileName); _Decoder.Open(fileName);
_Duration = _Decoder.GetLength(); _Duration = _Decoder.GetLength();
@@ -600,9 +595,7 @@ namespace Vocaluxe.Lib.Sound
_CurrentTime = 0f; _CurrentTime = 0f;
_Timer.Reset(); _Timer.Reset();
SAudioStreams stream = new SAudioStreams(0); SAudioStreams stream = new SAudioStreams(0) {Handle = _Buffers[0]};
stream.Handle = _Buffers[0];
if (stream.Handle != 0) if (stream.Handle != 0)
{ {
@@ -615,6 +608,7 @@ namespace Vocaluxe.Lib.Sound
return stream.Handle; return stream.Handle;
} }
_Initialized = true;
return -1; return -1;
} }
@@ -739,6 +733,7 @@ namespace Vocaluxe.Lib.Sound
AL.DeleteSource(_Source); AL.DeleteSource(_Source);
AL.DeleteBuffers(_Buffers); AL.DeleteBuffers(_Buffers);
} }
_Decoder.Close();
} }
_Closeproc(_StreamID); _Closeproc(_StreamID);
@@ -773,7 +768,7 @@ namespace Vocaluxe.Lib.Sound
if (_Paused) if (_Paused)
return; return;
int queuedCount = 0; int queuedCount;
bool doit = true; bool doit = true;
AL.GetSource(_Source, ALGetSourcei.BuffersQueued, out queuedCount); AL.GetSource(_Source, ALGetSourcei.BuffersQueued, out queuedCount);
@@ -782,7 +777,7 @@ namespace Vocaluxe.Lib.Sound
{ {
AL.GetSource(_Source, ALGetSourcei.BuffersProcessed, out processedCount); AL.GetSource(_Source, ALGetSourcei.BuffersProcessed, out processedCount);
doit = false; doit = false;
Console.WriteLine("Buffers Processed on Stream " + _Source.ToString() + " = " + processedCount.ToString()); Console.WriteLine("Buffers Processed on Stream " + _Source + " = " + processedCount);
if (processedCount < 1) if (processedCount < 1)
return; return;
} }
@@ -820,7 +815,7 @@ namespace Vocaluxe.Lib.Sound
} }
int buffer = 0; int buffer;
if (!doit) if (!doit)
buffer = AL.SourceUnqueueBuffer(_Source); buffer = AL.SourceUnqueueBuffer(_Source);
else else
@@ -831,11 +826,9 @@ namespace Vocaluxe.Lib.Sound
if (buffer != 0) if (buffer != 0)
{ {
if (_Format.ChannelCount == 2) ALFormat alFormat = (_Format.ChannelCount == 2) ? ALFormat.Stereo16 : ALFormat.Mono16;
AL.BufferData(buffer, ALFormat.Stereo16, buf, buf.Length, _Format.SamplesPerSecond); AL.BufferData(buffer, alFormat, buf, buf.Length, _Format.SamplesPerSecond);
else Console.WriteLine("Write to Buffer: " + buffer);
AL.BufferData(buffer, ALFormat.Mono16, buf, buf.Length, _Format.SamplesPerSecond);
Console.WriteLine("Write to Buffer: " + buffer.ToString());
AL.SourceQueueBuffer(_Source, buffer); AL.SourceQueueBuffer(_Source, buffer);
} }
} }
-4
View File
@@ -1,4 +0,0 @@
namespace Vocaluxe.Lib.Sound
{
class COpenALRecord {}
}
+31 -31
View File
@@ -1,12 +1,32 @@
using PortAudioSharp; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.Lib.Sound.Decoder; using Vocaluxe.Lib.Sound.Decoder;
using Vocaluxe.Lib.Sound.PortAudio;
namespace Vocaluxe.Lib.Sound namespace Vocaluxe.Lib.Sound
{ {
@@ -21,11 +41,6 @@ namespace Vocaluxe.Lib.Sound
private List<SAudioStreams> _Streams; private List<SAudioStreams> _Streams;
public CPortAudioPlay()
{
Init();
}
public bool Init() public bool Init()
{ {
if (_Initialized) if (_Initialized)
@@ -85,7 +100,6 @@ namespace Vocaluxe.Lib.Sound
{ {
_Decoder.Add(decoder); _Decoder.Add(decoder);
stream.Handle = _Count++; stream.Handle = _Count++;
stream.File = media;
_Streams.Add(stream); _Streams.Add(stream);
return stream.Handle; return stream.Handle;
} }
@@ -284,12 +298,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)
@@ -302,15 +311,6 @@ namespace Vocaluxe.Lib.Sound
return -1; return -1;
} }
private void _EndSync(int handle, int stream, int data, IntPtr user)
{
if (_Initialized)
{
if (_AlreadyAdded(stream))
Close(stream);
}
}
private void _CloseProc(int streamID) private void _CloseProc(int streamID)
{ {
if (_Initialized) if (_Initialized)
@@ -354,11 +354,9 @@ namespace Vocaluxe.Lib.Sound
private static CPortAudio.SPaDeviceInfo _OutputDeviceInfo; private static CPortAudio.SPaDeviceInfo _OutputDeviceInfo;
private IntPtr _Ptr = new IntPtr(0); private IntPtr _Ptr = new IntPtr(0);
private Closeproc _Closeproc; private Closeproc _Closeproc;
private CPortAudio.PaStreamCallbackDelegate _PaStreamCallback; private CPortAudio.PaStreamCallbackDelegate _PaStreamCallback;
private int _StreamID; private int _StreamID;
private string _FileName;
private IAudioDecoder _Decoder; private IAudioDecoder _Decoder;
private float _BytesPerSecond; private float _BytesPerSecond;
private bool _NoMoreData; private bool _NoMoreData;
@@ -471,7 +469,7 @@ namespace Vocaluxe.Lib.Sound
{ {
if (Finished) if (Finished)
_SyncTimer.Pause(); _SyncTimer.Pause();
//TODO: Why not use Decoder.GetPosition()?
return _SyncTimer.Time; return _SyncTimer.Time;
} }
} }
@@ -589,7 +587,6 @@ namespace Vocaluxe.Lib.Sound
return -1; return -1;
} }
_FileName = fileName;
_Decoder.Open(fileName); _Decoder.Open(fileName);
_Duration = _Decoder.GetLength(); _Duration = _Decoder.GetLength();
@@ -606,11 +603,13 @@ namespace Vocaluxe.Lib.Sound
IntPtr data = new IntPtr(0); IntPtr data = new IntPtr(0);
CPortAudio.SPaStreamParameters outputParams = new CPortAudio.SPaStreamParameters(); CPortAudio.SPaStreamParameters outputParams = new CPortAudio.SPaStreamParameters
outputParams.ChannelCount = format.ChannelCount; {
outputParams.Device = _ApiInfo.DefaultOutputDevice; ChannelCount = format.ChannelCount,
outputParams.SampleFormat = CPortAudio.EPaSampleFormat.PaInt16; Device = _ApiInfo.DefaultOutputDevice,
outputParams.SuggestedLatency = _OutputDeviceInfo.DefaultLowOutputLatency; SampleFormat = CPortAudio.EPaSampleFormat.PaInt16,
SuggestedLatency = _OutputDeviceInfo.DefaultLowOutputLatency
};
uint bufsize = (uint)CConfig.AudioBufferSize; uint bufsize = (uint)CConfig.AudioBufferSize;
lock (_Mutex) lock (_Mutex)
@@ -782,6 +781,7 @@ namespace Vocaluxe.Lib.Sound
_Initialized = false; _Initialized = false;
} }
} }
_Decoder.Close();
} }
_Closeproc(_StreamID); _Closeproc(_StreamID);
+38 -28
View File
@@ -1,9 +1,28 @@
using System.Threading; #region license
using PortAudioSharp; // /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Threading;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.Lib.Sound.PortAudio;
namespace Vocaluxe.Lib.Sound namespace Vocaluxe.Lib.Sound
{ {
@@ -54,17 +73,10 @@ namespace Vocaluxe.Lib.Sound
CPortAudio.SPaDeviceInfo info = CPortAudio.PaGetDeviceInfo(i); CPortAudio.SPaDeviceInfo info = CPortAudio.PaGetDeviceInfo(i);
if (info.HostApi == hostAPI && info.MaxInputChannels > 0) if (info.HostApi == hostAPI && info.MaxInputChannels > 0)
{ {
SRecordDevice dev = new SRecordDevice(); SRecordDevice dev = new SRecordDevice {ID = i, Name = info.Name, Driver = info.Name + i, Inputs = new List<SInput>()};
dev.ID = i; SInput inp = new SInput {Name = "Default", Channels = info.MaxInputChannels};
dev.Name = info.Name;
dev.Driver = info.Name + i.ToString();
dev.Inputs = new List<SInput>();
SInput inp = new SInput();
inp.Name = "Default";
inp.Channels = info.MaxInputChannels;
if (inp.Channels > 2) if (inp.Channels > 2)
inp.Channels = 2; //more are not supported in vocaluxe inp.Channels = 2; //more are not supported in vocaluxe
@@ -101,19 +113,16 @@ namespace Vocaluxe.Lib.Sound
if (deviceConfig == null) if (deviceConfig == null)
return false; return false;
if (_RecHandle == null) if (_RecHandle == null || _RecHandle.Length == 0)
return false; return false;
if (_RecHandle.Length == 0) foreach (CBuffer buffer in _Buffer)
return false; buffer.Reset();
for (int i = 0; i < _Buffer.Length; i++) foreach (IntPtr handle in _RecHandle)
_Buffer[i].Reset();
for (int i = 0; i < _RecHandle.Length; i++)
{ {
int waitcount = 0; int waitcount = 0;
while (waitcount < 5 && CPortAudio.Pa_IsStreamStopped(_RecHandle[i]) == CPortAudio.EPaError.PaStreamIsNotStopped) while (waitcount < 5 && CPortAudio.Pa_IsStreamStopped(handle) == CPortAudio.EPaError.PaStreamIsNotStopped)
{ {
Thread.Sleep(1); Thread.Sleep(1);
waitcount++; waitcount++;
@@ -136,16 +145,17 @@ namespace Vocaluxe.Lib.Sound
} }
} }
bool result = true;
for (int i = 0; i < _RecHandle.Length; i++) for (int i = 0; i < _RecHandle.Length; i++)
{ {
if (active[i]) if (active[i])
{ {
CPortAudio.SPaStreamParameters inputParams = new CPortAudio.SPaStreamParameters(); CPortAudio.SPaStreamParameters inputParams = new CPortAudio.SPaStreamParameters
inputParams.ChannelCount = _DeviceConfig[i].Inputs[0].Channels; {
inputParams.Device = _DeviceConfig[i].ID; ChannelCount = _DeviceConfig[i].Inputs[0].Channels,
inputParams.SampleFormat = CPortAudio.EPaSampleFormat.PaInt16; Device = _DeviceConfig[i].ID,
inputParams.SuggestedLatency = CPortAudio.PaGetDeviceInfo(_DeviceConfig[i].ID).DefaultLowInputLatency; SampleFormat = CPortAudio.EPaSampleFormat.PaInt16,
SuggestedLatency = CPortAudio.PaGetDeviceInfo(_DeviceConfig[i].ID).DefaultLowInputLatency
};
if (_ErrorCheck("OpenStream (rec)", CPortAudio.Pa_OpenStream( if (_ErrorCheck("OpenStream (rec)", CPortAudio.Pa_OpenStream(
out _RecHandle[i], out _RecHandle[i],
@@ -162,7 +172,7 @@ namespace Vocaluxe.Lib.Sound
return false; return false;
} }
} }
return result; return true;
} }
/// <summary> /// <summary>
@@ -174,8 +184,8 @@ namespace Vocaluxe.Lib.Sound
if (!_Initialized) if (!_Initialized)
return false; return false;
for (int i = 0; i < _RecHandle.Length; i++) foreach (IntPtr handle in _RecHandle)
CPortAudio.Pa_StopStream(_RecHandle[i]); CPortAudio.Pa_StopStream(handle);
return true; return true;
} }
@@ -1,41 +0,0 @@
namespace Vocaluxe.Lib.Sound.Decoder
{
abstract class CAudioDecoder : IAudioDecoder
{
protected bool _Initialized;
public virtual void Init() {}
public virtual void Close() {}
public void Open(string fileName)
{
Open(fileName, false);
}
public virtual void Open(string fileName, bool loop) {}
public virtual SFormatInfo GetFormatInfo()
{
return new SFormatInfo();
}
public virtual float GetLength()
{
return 0f;
}
public virtual void SetPosition(float time) {}
public virtual float GetPosition()
{
return 0f;
}
public virtual void Decode(out byte[] buffer, out float timeStamp)
{
buffer = null;
timeStamp = 0f;
}
}
}
@@ -1,12 +1,30 @@
using System; #region license
using System.IO; // /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.Lib.Video.Acinerella; using Vocaluxe.Lib.Video.Acinerella;
namespace Vocaluxe.Lib.Sound.Decoder namespace Vocaluxe.Lib.Sound.Decoder
{ {
class CAudioDecoderFFmpeg : CAudioDecoder, IDisposable class CAudioDecoderFFmpeg : IAudioDecoder, IDisposable
{ {
private IntPtr _InstancePtr = IntPtr.Zero; private IntPtr _InstancePtr = IntPtr.Zero;
private IntPtr _Audiodecoder = IntPtr.Zero; private IntPtr _Audiodecoder = IntPtr.Zero;
@@ -18,17 +36,10 @@ namespace Vocaluxe.Lib.Sound.Decoder
private string _FileName; private string _FileName;
private bool _FileOpened; private bool _FileOpened;
public override void Init() public void Init() {}
{
_FileOpened = false;
_Initialized = true;
}
public override void Open(string fileName, bool loop) public void Open(string fileName)
{ {
if (!_Initialized)
return;
_FileName = fileName; _FileName = fileName;
try try
@@ -50,7 +61,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
return; return;
} }
int audioStreamIndex = -1; int audioStreamIndex;
SACDecoder audiodecoder; SACDecoder audiodecoder;
try try
{ {
@@ -70,11 +81,12 @@ namespace Vocaluxe.Lib.Sound.Decoder
return; return;
} }
_FormatInfo = new SFormatInfo(); _FormatInfo = new SFormatInfo
{
_FormatInfo.SamplesPerSecond = audiodecoder.StreamInfo.AudioInfo.SamplesPerSecond; SamplesPerSecond = audiodecoder.StreamInfo.AudioInfo.SamplesPerSecond,
_FormatInfo.BitDepth = audiodecoder.StreamInfo.AudioInfo.BitDepth; BitDepth = audiodecoder.StreamInfo.AudioInfo.BitDepth,
_FormatInfo.ChannelCount = audiodecoder.StreamInfo.AudioInfo.ChannelCount; ChannelCount = audiodecoder.StreamInfo.AudioInfo.ChannelCount
};
_CurrentTime = 0f; _CurrentTime = 0f;
@@ -86,13 +98,8 @@ namespace Vocaluxe.Lib.Sound.Decoder
_FileOpened = true; _FileOpened = true;
} }
public override void Close() public void Close()
{ {
if (!_Initialized)
return;
_Initialized = false;
if (!_FileOpened) if (!_FileOpened)
return; return;
@@ -108,25 +115,25 @@ namespace Vocaluxe.Lib.Sound.Decoder
_FileOpened = false; _FileOpened = false;
} }
public override SFormatInfo GetFormatInfo() public SFormatInfo GetFormatInfo()
{ {
if (!_Initialized && !_FileOpened) if (!_FileOpened)
return new SFormatInfo(); return new SFormatInfo();
return _FormatInfo; return _FormatInfo;
} }
public override float GetLength() public float GetLength()
{ {
if (!_Initialized && !_FileOpened) if (!_FileOpened)
return 0f; return 0f;
return _Instance.Info.Duration / 1000f; return _Instance.Info.Duration / 1000f;
} }
public override void SetPosition(float time) public void SetPosition(float time)
{ {
if (!_Initialized && !_FileOpened) if (!_FileOpened)
return; return;
try try
@@ -140,24 +147,21 @@ namespace Vocaluxe.Lib.Sound.Decoder
} }
} }
public override float GetPosition() public float GetPosition()
{ {
if (!_Initialized && !_FileOpened) return !_FileOpened ? 0f : _CurrentTime;
return 0f;
return _CurrentTime;
} }
public override void Decode(out byte[] buffer, out float timeStamp) public void Decode(out byte[] buffer, out float timeStamp)
{ {
if (!_Initialized && !_FileOpened) if (!_FileOpened)
{ {
buffer = null; buffer = null;
timeStamp = 0f; timeStamp = 0f;
return; return;
} }
int frameFinished = 0; int frameFinished;
try try
{ {
frameFinished = CAcinerella.AcGetAudioFrame(_InstancePtr, _Audiodecoder); frameFinished = CAcinerella.AcGetAudioFrame(_InstancePtr, _Audiodecoder);
@@ -173,7 +177,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
timeStamp = (float)decoder.Timecode; timeStamp = (float)decoder.Timecode;
_CurrentTime = timeStamp; _CurrentTime = timeStamp;
//Console.WriteLine(_CurrentTime.ToString("ReplacedStr:::0:::") + "ReplacedStr:::1:::" + Decoder.buffer_size.ToString()); //Console.WriteLine(_CurrentTime.ToString("#0.000") + " Buffer size: " + Decoder.buffer_size.ToString());
buffer = new byte[decoder.BufferSize]; buffer = new byte[decoder.BufferSize];
if (decoder.BufferSize > 0) if (decoder.BufferSize > 0)
@@ -186,8 +190,6 @@ namespace Vocaluxe.Lib.Sound.Decoder
timeStamp = 0f; timeStamp = 0f;
} }
public void Dispose() public void Dispose() {}
{
}
} }
} }
+20 -2
View File
@@ -1,4 +1,23 @@
namespace Vocaluxe.Lib.Sound.Decoder #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
namespace Vocaluxe.Lib.Sound.Decoder
{ {
struct SFormatInfo struct SFormatInfo
{ {
@@ -13,7 +32,6 @@
void Close(); void Close();
void Open(string fileName); void Open(string fileName);
void Open(string fileName, bool loop);
SFormatInfo GetFormatInfo(); SFormatInfo GetFormatInfo();
float GetLength(); float GetLength();
@@ -1,4 +1,23 @@
using System.Runtime.InteropServices; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Runtime.InteropServices;
namespace Vocaluxe.Lib.Sound.Gstreamer namespace Vocaluxe.Lib.Sound.Gstreamer
{ {
@@ -21,7 +40,7 @@ namespace Vocaluxe.Lib.Sound.Gstreamer
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void LogCallback(string message); public delegate void LogCallback(string message);
[DllImport(_Dll, CallingConvention=CallingConvention.Cdecl)] [DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetLogCallback(LogCallback c); public static extern void SetLogCallback(LogCallback c);
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)] [DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
+18 -3
View File
@@ -1,16 +1,31 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
namespace Vocaluxe.Lib.Sound namespace Vocaluxe.Lib.Sound
{ {
struct SAudioStreams struct SAudioStreams
{ {
public int Handle; public int Handle;
public string File;
public SAudioStreams(int stream) public SAudioStreams(int stream)
{ {
Handle = stream; Handle = stream;
File = String.Empty;
} }
} }
+22 -1
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Vocaluxe.Lib.Sound namespace Vocaluxe.Lib.Sound
@@ -27,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;
+29 -28
View File
@@ -1,35 +1,37 @@
/* #region license
* PortAudioSharp - PortAudio bindings for .NET // /*
* Copyright 2006-2011 Riccardo Gerosa and individual contributors as indicated // This file is part of Vocaluxe.
* by the @authors tag. See the copyright.txt in the distribution for a //
* full listing of individual contributors. // Vocaluxe is free software: you can redistribute it and/or modify
* // it under the terms of the GNU General Public License as published by
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software // the Free Software Foundation, either version 3 of the License, or
* and associated documentation files (the "Software"), to deal in the Software without restriction, // (at your option) any later version.
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, //
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, // Vocaluxe is distributed in the hope that it will be useful,
* subject to the following conditions: // but WITHOUT ANY WARRANTY; without even the implied warranty of
* // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* The above copyright notice and this permission notice shall be included in all copies or substantial // GNU General Public License for more details.
* portions of the Software. //
* // You should have received a copy of the GNU General Public License
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT // along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // */
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, #endregion
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace PortAudioSharp namespace Vocaluxe.Lib.Sound.PortAudio
{ {
/** /**
<summary> <summary>
PortAudio v.19 bindings for .NET PortAudio v.19 bindings for .NET
</summary> </summary>
*/ */
public partial class CPortAudio // ReSharper disable UnusedMember.Global
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable MemberCanBePrivate.Global
public static class CPortAudio
{ {
#region **** PORTAUDIO CALLBACKS **** #region **** PORTAUDIO CALLBACKS ****
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
@@ -550,10 +552,9 @@ namespace PortAudioSharp
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)] [DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
public static extern void Pa_Sleep(int msec); public static extern void Pa_Sleep(int msec);
#endregion #endregion
}
private CPortAudio() // ReSharper restore UnusedMember.Global
{ // ReSharper restore FieldCanBeMadeReadOnly.Global
// This is a static class // ReSharper restore MemberCanBePrivate.Global
}
}
} }
@@ -1,100 +0,0 @@
/*
* PortAudioSharp - PortAudio bindings for .NET
* Copyright 2006-2011 Riccardo Gerosa and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
using System;
using System.Runtime.InteropServices;
namespace PortAudioSharp
{
/// <summary> PortAudio v.19 bindings for .NET - ASIO bindings </summary>
public partial class CPortAudio
{
#region **** PORTAUDIO DATA STRUCTURES ****
[StructLayout(LayoutKind.Sequential)]
public struct SPaAsioStreamInfo
{
public ulong Size; /**< sizeof(PaAsioStreamInfo) */
public int HostApiType; /**< paASIO */
public ulong Version; /**< 1 */
public ulong Flags;
/// Support for opening only specific channels of an ASIO device.
/// If the paAsioUseChannelSelectors flag is set, channelSelectors is a
/// pointer to an array of integers specifying the device channels to use.
/// When used, the length of the channelSelectors array must match the
/// corresponding channelCount parameter to Pa_OpenStream() otherwise a
/// crash may result.
/// The values in the selectors array must specify channels within the
/// range of supported channels for the device or paInvalidChannelCount will
/// result.
private readonly IntPtr _ChannelSelectors;
}
#endregion
#region **** PORTAUDIO DEFINES ****
public const int PaAsioUseChannelSelectors = 0x01;
#endregion
#region **** PORTAUDIO FUNCTIONS ****
// /// <summary> Retrieve legal latency settings for the specificed device, in samples. </summary>
// /// <param name="device"> The global index of the device about which the query is being made. </param>
// /// <param name="minLatency"> A pointer to the location which will recieve the minimum latency value. </param>
// /// <param name="maxLatency"> A pointer to the location which will recieve the maximum latency value. </param>
// /// <param name="preferredLatency"> A pointer to the location which will recieve the preferred latency value. </param>
// /// <param name="granularity"> A pointer to the location which will recieve the granularity. This value
// /// determines which values between minLatency and maxLatency are available. ie the step size,
// /// if granularity is -1 then available latency settings are powers of two. </param>
// /// See ASIOGetBufferSize in the ASIO SDK.
// PaError PaAsio_GetAvailableLatencyValues( PaDeviceIndex device, long *minLatency, long *maxLatency,
// long *preferredLatency, long *granularity );
/// <summary> Display the ASIO control panel for the specified device. </summary>
/// <param name="device"> The global index of the device whose control panel is to be displayed. </param>
/// <param name="systemSpecific">
/// On Windows, the calling application's main window handle,
/// on Macintosh this value should be zero.
/// </param>
[DllImport("PortAudio.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern EPaError PaAsio_ShowControlPanel(int device, IntPtr systemSpecific);
// /// <summary> Retrieve a pointer to a string containing the name of the specified input channel. </summary>
// /// The string is valid until Pa_Terminate is called.
// /// The string will be no longer than 32 characters including the null terminator.
// PaError PaAsio_GetInputChannelName(PaDeviceIndex device, int channelIndex, const char** channelName );
// /// <summary> Retrieve a pointer to a string containing the name of the specified input channel. </summary>
// /// The string is valid until Pa_Terminate is called.
// /// The string will be no longer than 32 characters including the null terminator.
// PaError PaAsio_GetOutputChannelName( PaDeviceIndex device, int channelIndex, const char** channelName );
/// <summary> Set the sample rate of an open paASIO stream. </summary>
/// <param name="stream"></param>
/// The stream to operate on.
/// <param name="sampleRate"></param>
/// The new sample rate.
/// Note that this function may fail if the stream is alredy running and the
/// ASIO driver does not support switching the sample rate of a running stream.
/// <returns> paIncompatibleStreamHostApi if stream is not a paASIO stream. </returns>
[DllImport("PortAudio.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern EPaError PaAsio_SetStreamSampleRate(IntPtr stream, double sampleRate);
#endregion
}
}
+50 -20
View File
@@ -1,8 +1,28 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Vocaluxe.Lib.Video.Acinerella namespace Vocaluxe.Lib.Video.Acinerella
{ {
// ReSharper disable UnusedMember.Global
public enum EACStreamType : sbyte public enum EACStreamType : sbyte
{ {
/*The type of the media stream is not known. This kind of stream can not be /*The type of the media stream is not known. This kind of stream can not be
@@ -32,12 +52,14 @@ namespace Vocaluxe.Lib.Video.Acinerella
ACOutputBGra32 = 3 ACOutputBGra32 = 3
} }
// ReSharper disable MemberCanBePrivate.Global
// Contains information about the whole file/stream that has been opened. Default // Contains information about the whole file/stream that has been opened. Default
// values are "" for strings and -1 for integer values. // values are "" for strings and -1 for integer values.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct SACFileInfo public struct SACFileInfo
{ {
public Int64 Duration; public readonly Int64 Duration;
} }
// TAc_instance represents an Acinerella instance. Each instance can open and // TAc_instance represents an Acinerella instance. Each instance can open and
@@ -47,12 +69,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACInstance public struct SACInstance
{ {
//If true, the instance currently opened a media file //If true, the instance currently opened a media file
public bool Opened; public readonly bool Opened;
//Contains the count of streams the media file has. This value is available //Contains the count of streams the media file has. This value is available
//after calling the ac_open function. //after calling the ac_open function.
public Int32 StreamCount; public readonly Int32 StreamCount;
//Set this value to change the image output format //Set this value to change the image output format
public EACOutputFormat OutputFormat; public readonly EACOutputFormat OutputFormat;
//Contains information about the opened stream/file //Contains information about the opened stream/file
public SACFileInfo Info; public SACFileInfo Info;
} }
@@ -62,11 +84,11 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACAudioStreamInfo public struct SACAudioStreamInfo
{ {
//Samples per second. Default values are 44100 or 48000. //Samples per second. Default values are 44100 or 48000.
public Int32 SamplesPerSecond; public readonly Int32 SamplesPerSecond;
//Bits per sample. Can be 8 or 16 Bit. //Bits per sample. Can be 8 or 16 Bit.
public Int32 BitDepth; public readonly Int32 BitDepth;
//Count of channels in the audio stream. //Count of channels in the audio stream.
public Int32 ChannelCount; public readonly Int32 ChannelCount;
} }
// Contains information about an Acinerella video stream. // Contains information about an Acinerella video stream.
@@ -74,13 +96,13 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACVideoStreamInfo public struct SACVideoStreamInfo
{ {
//The width of one frame. //The width of one frame.
public Int32 FrameWidth; public readonly Int32 FrameWidth;
//The height of one frame. //The height of one frame.
public Int32 FrameHeight; public readonly Int32 FrameHeight;
//The width of one pixel. 1.07 for 4:3 format, 1,42 for the 16:9 format //The width of one pixel. 1.07 for 4:3 format, 1,42 for the 16:9 format
public float PixelAspect; public readonly float PixelAspect;
//Frames per second that should be played. //Frames per second that should be played.
public double FramesPerSecond; public readonly double FramesPerSecond;
} }
// Contains information about an Acinerella stream. // Contains information about an Acinerella stream.
@@ -88,7 +110,8 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACStreamInfo public struct SACStreamInfo
{ {
//Contains the type of the stream. //Contains the type of the stream.
public EACStreamType StreamType; public readonly EACStreamType StreamType;
//Additional info about the stream //Additional info about the stream
public SACAudioStreamInfo AudioInfo; public SACAudioStreamInfo AudioInfo;
public SACVideoStreamInfo VideoInfo; public SACVideoStreamInfo VideoInfo;
@@ -101,22 +124,22 @@ namespace Vocaluxe.Lib.Video.Acinerella
//Pointer on the Acinerella instance //Pointer on the Acinerella instance
private readonly IntPtr _ACInstancePtr; private readonly IntPtr _ACInstancePtr;
//Contains the type of the decoder. //Contains the type of the decoder.
public EACDecoderType DecType; public readonly EACDecoderType DecType;
//The timecode of the currently decoded picture in seconds. //The timecode of the currently decoded picture in seconds.
public double Timecode; public readonly double Timecode;
public double VideoClock; public readonly double VideoClock;
//Contains information about the stream the decoder is attached to. //Contains information about the stream the decoder is attached to.
public SACStreamInfo StreamInfo; public SACStreamInfo StreamInfo;
//The index of the stream the decoder is attached to. //The index of the stream the decoder is attached to.
public Int32 StreamIndex; public readonly Int32 StreamIndex;
//Pointer to the buffer which contains the data. //Pointer to the buffer which contains the data.
internal IntPtr Buffer; internal IntPtr Buffer;
//Size of the data in the buffer. //Size of the data in the buffer.
public Int32 BufferSize; public readonly Int32 BufferSize;
} }
// Contains information about an Acinerella package. // Contains information about an Acinerella package.
@@ -124,9 +147,11 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACPackage public struct SACPackage
{ {
//The stream the package belongs to. //The stream the package belongs to.
public Int32 StreamIndex; public readonly Int32 StreamIndex;
} }
// ReSharper restore MemberCanBePrivate.Global
// Callback function used to ask the application to read data. Should return // Callback function used to ask the application to read data. Should return
// the number of bytes read or an value smaller than zero if an error occured. // the number of bytes read or an value smaller than zero if an error occured.
//TAc_read_callback = function(sender: Pointer; byte[] buf, int size): integer; cdecl; //TAc_read_callback = function(sender: Pointer; byte[] buf, int size): integer; cdecl;
@@ -254,7 +279,9 @@ namespace Vocaluxe.Lib.Video.Acinerella
string filename string filename
); );
// ReSharper disable UnusedMethodReturnValue.Global
public static Int32 AcOpen2( public static Int32 AcOpen2(
// ReSharper restore UnusedMethodReturnValue.Global
IntPtr pAcInstance, IntPtr pAcInstance,
string filename string filename
) )
@@ -314,7 +341,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
[DllImport(_AcDll, EntryPoint = "ac_free_package", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] [DllImport(_AcDll, EntryPoint = "ac_free_package", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
public static extern void ac_free_package(IntPtr pAcPackage); public static extern void ac_free_package(IntPtr pAcPackage);
[DllImport(_AcDll, EntryPoint = "ac_create_video_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] [DllImport(_AcDll, EntryPoint = "ac_create_video_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern IntPtr _ac_create_video_decoder(IntPtr pAcInstance); private static extern IntPtr _ac_create_video_decoder(IntPtr pAcInstance);
@@ -405,7 +431,9 @@ namespace Vocaluxe.Lib.Video.Acinerella
[DllImport(_AcDll, EntryPoint = "ac_seek", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] [DllImport(_AcDll, EntryPoint = "ac_seek", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern Int32 _ac_seek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos); private static extern Int32 _ac_seek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos);
// ReSharper disable UnusedMethodReturnValue.Global
public static Int32 AcSeek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos) public static Int32 AcSeek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos)
// ReSharper restore UnusedMethodReturnValue.Global
{ {
lock (_Lock) lock (_Lock)
{ {
@@ -423,4 +451,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
out Int32 scoreMax out Int32 scoreMax
); );
} }
// ReSharper restore UnusedMember.Global
} }
+24 -12
View File
@@ -1,4 +1,24 @@
using System.Collections.Generic; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Collections.Generic;
using System.Linq;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace Vocaluxe.Lib.Video namespace Vocaluxe.Lib.Video
@@ -6,7 +26,7 @@ namespace Vocaluxe.Lib.Video
abstract class CVideoDecoder : IVideoDecoder abstract class CVideoDecoder : IVideoDecoder
{ {
protected List<SVideoStreams> _Streams = new List<SVideoStreams>(); protected List<SVideoStreams> _Streams = new List<SVideoStreams>();
protected bool _Initialized = false; protected bool _Initialized;
public virtual bool Init() public virtual bool Init()
{ {
@@ -38,10 +58,7 @@ namespace Vocaluxe.Lib.Video
return 0f; return 0f;
} }
public virtual bool GetFrame(int streamID, ref STexture frame, float time, ref float videoTime) public abstract bool GetFrame(int streamID, ref STexture frame, float time, out float videoTime);
{
return true;
}
public virtual bool Skip(int streamID, float start, float gap) public virtual bool Skip(int streamID, float start, float gap)
{ {
@@ -63,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)
+39 -40
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@@ -48,7 +67,6 @@ namespace Vocaluxe.Lib.Video
{ {
_Decoder.Add(decoder); _Decoder.Add(decoder);
stream.Handle = _Count++; stream.Handle = _Count++;
stream.File = videoFileName;
_Streams.Add(stream); _Streams.Add(stream);
return stream.Handle; return stream.Handle;
} }
@@ -72,14 +90,15 @@ namespace Vocaluxe.Lib.Video
return false; return false;
} }
public override bool GetFrame(int streamID, ref STexture frame, float time, ref float videoTime) public override bool GetFrame(int streamID, ref STexture frame, float time, out float videoTime)
{ {
videoTime = 0;
if (_Initialized) if (_Initialized)
{ {
lock (_MutexDecoder) lock (_MutexDecoder)
{ {
if (_AlreadyAdded(streamID)) if (_AlreadyAdded(streamID))
return _Decoder[_GetStreamIndex(streamID)].GetFrame(ref frame, time, ref videoTime); return _Decoder[_GetStreamIndex(streamID)].GetFrame(ref frame, time, out videoTime);
} }
} }
return false; return false;
@@ -212,7 +231,6 @@ namespace Vocaluxe.Lib.Video
private bool _Paused; private bool _Paused;
private bool _NoMoreFrames; private bool _NoMoreFrames;
private bool _Finished;
private bool _BeforeLoop; private bool _BeforeLoop;
private int _Width; private int _Width;
@@ -220,7 +238,6 @@ namespace Vocaluxe.Lib.Video
private float _SetTime; private float _SetTime;
private float _SetGap; private float _SetGap;
private float _SetStart; private float _SetStart;
private bool _SetLoop;
private bool _SetSkip; private bool _SetSkip;
private bool _Terminated; private bool _Terminated;
@@ -245,18 +262,11 @@ namespace Vocaluxe.Lib.Video
public float Length public float Length
{ {
get get { return _FileOpened ? _Duration : 0f; }
{
if (_FileOpened)
return _Duration;
return 0f;
}
} }
public bool Paused public bool Paused
{ {
get { return _Paused; }
set set
{ {
lock (_MutexSyncSignals) lock (_MutexSyncSignals)
@@ -270,16 +280,9 @@ namespace Vocaluxe.Lib.Video
} }
} }
public bool Loop public bool Loop { private get; set; }
{
get { return _SetLoop; }
set { _SetLoop = value; }
}
public bool Finished public bool Finished { get; private set; }
{
get { return _Finished; }
}
public bool Open(string fileName) public bool Open(string fileName)
{ {
@@ -296,15 +299,16 @@ namespace Vocaluxe.Lib.Video
return true; return true;
} }
public bool GetFrame(ref STexture frame, float time, ref float videoTime) public bool GetFrame(ref STexture frame, float time, out float videoTime)
{ {
videoTime = 0;
if (!_FileOpened) if (!_FileOpened)
return false; return false;
if (_Paused) if (_Paused)
return false; return false;
if (_SetLoop) if (Loop)
{ {
lock (_MutexSyncSignals) lock (_MutexSyncSignals)
{ {
@@ -322,7 +326,7 @@ namespace Vocaluxe.Lib.Video
return true; return true;
} }
if (_SetTime != time) if (Math.Abs(_SetTime - time) > float.Epsilon)
{ {
lock (_MutexSyncSignals) lock (_MutexSyncSignals)
{ {
@@ -344,7 +348,7 @@ namespace Vocaluxe.Lib.Video
_SetGap = gap; _SetGap = gap;
_SetSkip = true; _SetSkip = true;
_NoMoreFrames = false; _NoMoreFrames = false;
_Finished = false; Finished = false;
} }
//EventDecode.Set(); //EventDecode.Set();
return true; return true;
@@ -422,7 +426,7 @@ namespace Vocaluxe.Lib.Video
_SetSkip = false; _SetSkip = false;
_Gap = _SetGap; _Gap = _SetGap;
_Start = _SetStart; _Start = _SetStart;
_Loop = _SetLoop; _Loop = Loop;
} }
if (_Skip) if (_Skip)
@@ -442,7 +446,7 @@ namespace Vocaluxe.Lib.Video
private void _DoOpen() private void _DoOpen()
{ {
bool ok = false; bool ok;
SACInstance instance = new SACInstance(); SACInstance instance = new SACInstance();
try try
{ {
@@ -467,7 +471,7 @@ namespace Vocaluxe.Lib.Video
_Duration = instance.Info.Duration / 1000f; _Duration = instance.Info.Duration / 1000f;
int videoStreamIndex = -1; int videoStreamIndex;
SACDecoder videodecoder; SACDecoder videodecoder;
try try
{ {
@@ -522,9 +526,7 @@ namespace Vocaluxe.Lib.Video
float myTime = _Time + _VideoSkipTime; float myTime = _Time + _VideoSkipTime;
float timeDifference = myTime - _VideoDecoderTime; float timeDifference = myTime - _VideoDecoderTime;
bool dropFrame = false; bool dropFrame = timeDifference >= (framedropcount - 1) * _VideoTimeBase;
if (timeDifference >= (framedropcount - 1) * _VideoTimeBase)
dropFrame = true;
if (_Terminated) if (_Terminated)
return; return;
@@ -591,7 +593,6 @@ namespace Vocaluxe.Lib.Video
} }
else else
_NoMoreFrames = true; _NoMoreFrames = true;
return;
} }
else else
{ {
@@ -660,7 +661,7 @@ namespace Vocaluxe.Lib.Video
if (num >= 0) if (num >= 0)
{ {
if (frame.Index == -1 || _Width != frame.Width || _Height != frame.Height) if (frame.Index == -1 || _Width != (int)frame.Width || _Height != (int)frame.Height)
{ {
CDraw.RemoveTexture(ref frame); CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].Data); frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].Data);
@@ -672,12 +673,12 @@ namespace Vocaluxe.Lib.Video
{ {
_CurrentVideoTime = _FrameBuffer[num].Time; _CurrentVideoTime = _FrameBuffer[num].Time;
} }
_Finished = false; Finished = false;
} }
else else
{ {
if (_NoMoreFrames) if (_NoMoreFrames)
_Finished = true; Finished = true;
} }
} }
} }
@@ -725,8 +726,6 @@ namespace Vocaluxe.Lib.Video
} }
#endregion Threading #endregion Threading
public void Dispose() public void Dispose() {}
{
}
} }
} }
+25 -6
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.Lib.Video.Gstreamer; using Vocaluxe.Lib.Video.Gstreamer;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -8,7 +27,7 @@ namespace Vocaluxe.Lib.Video
class CVideoDecoderGstreamer : IVideoDecoder class CVideoDecoderGstreamer : IVideoDecoder
{ {
#region log #region log
public CGstreamerVideoWrapper.LogCallback Log; private CGstreamerVideoWrapper.LogCallback _Log;
private void _LogHandler(string text) private void _LogHandler(string text)
{ {
@@ -19,10 +38,10 @@ namespace Vocaluxe.Lib.Video
public bool Init() public bool Init()
{ {
bool retval = CGstreamerVideoWrapper.InitVideo(); bool retval = CGstreamerVideoWrapper.InitVideo();
Log = _LogHandler; _Log = _LogHandler;
//Really needed? CodeAnalysis complains //Really needed? CodeAnalysis complains
//GC.SuppressFinalize(Log); //GC.SuppressFinalize(Log);
CGstreamerVideoWrapper.SetVideoLogCallback(Log); CGstreamerVideoWrapper.SetVideoLogCallback(_Log);
return retval; return retval;
} }
@@ -59,7 +78,7 @@ namespace Vocaluxe.Lib.Video
return CGstreamerVideoWrapper.GetVideoLength(streamID); return CGstreamerVideoWrapper.GetVideoLength(streamID);
} }
public bool GetFrame(int streamID, ref STexture frame, float time, ref float videoTime) public bool GetFrame(int streamID, ref STexture frame, float time, out float videoTime)
{ {
SManagedFrame managedFrame = CGstreamerVideoWrapper.GetFrame(streamID, time); SManagedFrame managedFrame = CGstreamerVideoWrapper.GetFrame(streamID, time);
videoTime = managedFrame.Videotime; videoTime = managedFrame.Videotime;
@@ -102,7 +121,7 @@ namespace Vocaluxe.Lib.Video
{ {
if (data != null) if (data != null)
{ {
if (frame.Index == -1 || width != frame.Width || height != frame.Height || data.Length == 0) if (frame.Index == -1 || width != (int)frame.Width || height != (int)frame.Height || data.Length == 0)
{ {
CDraw.RemoveTexture(ref frame); CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(width, height, ref data); frame = CDraw.AddTexture(width, height, ref data);
@@ -1,21 +1,41 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Vocaluxe.Lib.Video.Gstreamer namespace Vocaluxe.Lib.Video.Gstreamer
{ {
public struct SNativeFrame public struct SNativeFrame
{ {
// ReSharper disable UnassignedField.Global
internal IntPtr Buffer; internal IntPtr Buffer;
public int Size; public int Size;
public int Width; public int Width;
public int Height; public int Height;
public float Videotime; public float Videotime;
// ReSharper restore UnassignedField.Global
} }
public struct SManagedFrame public struct SManagedFrame
{ {
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;
@@ -81,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;
+20 -4
View File
@@ -1,4 +1,22 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace Vocaluxe.Lib.Video namespace Vocaluxe.Lib.Video
@@ -6,12 +24,10 @@ namespace Vocaluxe.Lib.Video
struct SVideoStreams struct SVideoStreams
{ {
public int Handle; public int Handle;
public string File;
public SVideoStreams(int stream) public SVideoStreams(int stream)
{ {
Handle = stream; Handle = stream;
File = String.Empty;
} }
} }
@@ -25,7 +41,7 @@ namespace Vocaluxe.Lib.Video
int GetNumStreams(); int GetNumStreams();
float GetLength(int streamID); float GetLength(int streamID);
bool GetFrame(int streamID, ref STexture frame, float time, ref float videoTime); bool GetFrame(int streamID, ref STexture frame, float time, out float videoTime);
bool Skip(int streamID, float start, float gap); bool Skip(int streamID, float start, float gap);
void SetLoop(int streamID, bool loop); void SetLoop(int streamID, bool loop);
void Pause(int streamID); void Pause(int streamID);
+31 -14
View File
@@ -1,4 +1,23 @@
using AForge.Video; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using AForge.Video;
using AForge.Video.DirectShow; using AForge.Video.DirectShow;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
@@ -37,7 +56,7 @@ namespace Vocaluxe.Lib.Webcam
{ {
lock (_MutexData) lock (_MutexData)
{ {
if (frame.Index == -1 || _Width != frame.Width || _Height != frame.Height) if (frame.Index == -1 || _Width != (int)frame.Width || _Height != (int)frame.Height)
{ {
CDraw.RemoveTexture(ref frame); CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(_Width, _Height, ref _Data); frame = CDraw.AddTexture(_Width, _Height, ref _Data);
@@ -62,33 +81,29 @@ namespace Vocaluxe.Lib.Webcam
return bmp; return bmp;
} }
} }
else
return null; return null;
} }
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);
for (int i = 0; i < tmpdev.VideoCapabilities.Length; i++) foreach (VideoCapabilities capabilities in tmpdev.VideoCapabilities)
{ {
SCapabilities item = new SCapabilities SCapabilities item = new SCapabilities
{ {
Framerate = tmpdev.VideoCapabilities[i].FrameRate, Framerate = capabilities.FrameRate,
Height = tmpdev.VideoCapabilities[i].FrameSize.Height, Height = capabilities.FrameSize.Height,
Width = tmpdev.VideoCapabilities[i].FrameSize.Width Width = capabilities.FrameSize.Width
}; };
device.Capabilities.Add(item); device.Capabilities.Add(item);
} }
@@ -144,6 +159,11 @@ namespace Vocaluxe.Lib.Webcam
return _Devices.ToArray(); return _Devices.ToArray();
} }
public bool IsDeviceAvailable()
{
return _Devices.Count > 0;
}
public bool Select(SWebcamConfig config) public bool Select(SWebcamConfig config)
{ {
//Close old camera connection //Close old camera connection
@@ -155,10 +175,7 @@ namespace Vocaluxe.Lib.Webcam
return false; return false;
//No MonikerString found, try first webcam //No MonikerString found, try first webcam
if (config.MonikerString.Length == 0) _Webcam = config.MonikerString == "" ? new VideoCaptureDevice(_WebcamDevices[0].MonikerString) : new VideoCaptureDevice(config.MonikerString);
_Webcam = new VideoCaptureDevice(_WebcamDevices[0].MonikerString);
else //Found MonikerString
_Webcam = new VideoCaptureDevice(config.MonikerString);
if (_Webcam == null) if (_Webcam == null)
return false; return false;
+21 -2
View File
@@ -1,4 +1,23 @@
using System.Collections.Generic; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -6,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;
@@ -40,6 +58,7 @@ namespace Vocaluxe.Lib.Webcam
Bitmap GetBitmap(); Bitmap GetBitmap();
SWebcamConfig GetConfig(); SWebcamConfig GetConfig();
SWebcamDevice[] GetDevices(); SWebcamDevice[] GetDevices();
bool IsDeviceAvailable();
bool Select(SWebcamConfig webcamConfig); bool Select(SWebcamConfig webcamConfig);
} }
+5 -5
View File
@@ -114,7 +114,7 @@ namespace Vocaluxe
// Init Playback // Init Playback
CLog.StartBenchmark(0, "Init Playback"); CLog.StartBenchmark(0, "Init Playback");
CSound.PlaybackInit(); CSound.Init();
CLog.StopBenchmark(0, "Init Playback"); CLog.StopBenchmark(0, "Init Playback");
Application.DoEvents(); Application.DoEvents();
@@ -185,6 +185,7 @@ namespace Vocaluxe
// Init Input // Init Input
CLog.StartBenchmark(0, "Init Input"); CLog.StartBenchmark(0, "Init Input");
CInput.Init(); CInput.Init();
CInput.Connect();
CLog.StopBenchmark(0, "Init Input"); CLog.StopBenchmark(0, "Init Input");
// Init Game; // Init Game;
@@ -252,13 +253,12 @@ namespace Vocaluxe
string[] arr = args.Name.Split(new char[] {','}); string[] arr = args.Name.Split(new char[] {','});
if (arr.Length > 0) if (arr.Length > 0)
{ {
#if ARCH_X86 #if ARCH_X86
string path="x86"; string path = "x86";
#endif #endif
#if ARCH_X64 #if ARCH_X64
string path="x64"; string path = "x64";
#endif #endif
path = Path.Combine(path, arr[0] + ".dll"); path = Path.Combine(path, arr[0] + ".dll");
try try
@@ -277,7 +277,7 @@ namespace Vocaluxe
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("Cannot load assembly "+args.Name+" from "+path+": "+e); CLog.LogError("Cannot load assembly " + args.Name + " from " + path + ": " + e);
} }
} }
return null; return null;
+26 -3
View File
@@ -1,9 +1,29 @@
using System.Reflection; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden // Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind. // die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("Vocaluxe")] [assembly: AssemblyTitle("Vocaluxe")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
@@ -16,9 +36,11 @@ using System.Runtime.InteropServices;
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("da631594-f891-4994-9869-c37e626e44f9")] [assembly: Guid("da631594-f891-4994-9869-c37e626e44f9")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
@@ -28,5 +50,6 @@ using System.Runtime.InteropServices;
// Buildnummer // Buildnummer
// Revision // Revision
// //
[assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyVersion("0.3.0.78")]
[assembly: AssemblyFileVersion("0.3.0.78")]
+54 -46
View File
@@ -1,5 +1,23 @@
using System; #region license
using System.Collections.Generic; // /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -72,23 +90,14 @@ namespace Vocaluxe.Screens
_ThemeStatics = new string[] {_StaticBG, _StaticCover}; _ThemeStatics = new string[] {_StaticBG, _StaticCover};
_ThemeTexts = new string[] {_TextCurrentSong}; _ThemeTexts = new string[] {_TextCurrentSong};
List<string> buttons = new List<string>(); _ThemeButtons = new string[] {_ButtonPlay, _ButtonPause, _ButtonPrevious, _ButtonNext, _ButtonRepeat, _ButtonShowVideo, _ButtonSing, _ButtonToBackgroundVideo};
buttons.Add(_ButtonPlay);
buttons.Add(_ButtonPause);
buttons.Add(_ButtonPrevious);
buttons.Add(_ButtonNext);
buttons.Add(_ButtonRepeat);
buttons.Add(_ButtonShowVideo);
buttons.Add(_ButtonSing);
buttons.Add(_ButtonToBackgroundVideo);
_ThemeButtons = buttons.ToArray();
} }
public override void LoadTheme(string xmlPath) public override void LoadTheme(string xmlPath)
{ {
base.LoadTheme(xmlPath); base.LoadTheme(xmlPath);
_ScreenArea = Statics[_StaticBG].Rect; _ScreenArea = _Statics[_StaticBG].Rect;
} }
public override bool HandleInput(SKeyEvent keyEvent) public override bool HandleInput(SKeyEvent keyEvent)
@@ -105,21 +114,21 @@ namespace Vocaluxe.Screens
return false; return false;
case Keys.Enter: case Keys.Enter:
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
CBackgroundMusic.Next(); CBackgroundMusic.Next();
if (Buttons[_ButtonPrevious].Selected) if (_Buttons[_ButtonPrevious].Selected)
CBackgroundMusic.Previous(); CBackgroundMusic.Previous();
if (Buttons[_ButtonPlay].Selected) if (_Buttons[_ButtonPlay].Selected)
CBackgroundMusic.Play(); CBackgroundMusic.Play();
if (Buttons[_ButtonPause].Selected) if (_Buttons[_ButtonPause].Selected)
CBackgroundMusic.Pause(); CBackgroundMusic.Pause();
if (Buttons[_ButtonRepeat].Selected) if (_Buttons[_ButtonRepeat].Selected)
CBackgroundMusic.RepeatSong = !CBackgroundMusic.RepeatSong; CBackgroundMusic.RepeatSong = !CBackgroundMusic.RepeatSong;
if (Buttons[_ButtonShowVideo].Selected) if (_Buttons[_ButtonShowVideo].Selected)
_VideoPreview = !_VideoPreview; _VideoPreview = !_VideoPreview;
if (Buttons[_ButtonSing].Selected) if (_Buttons[_ButtonSing].Selected)
_StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet); _StartSong(CBackgroundMusic.SongID);
if (Buttons[_ButtonToBackgroundVideo].Selected) if (_Buttons[_ButtonToBackgroundVideo].Selected)
_VideoBackground = !_VideoBackground; _VideoBackground = !_VideoBackground;
break; break;
} }
@@ -131,23 +140,23 @@ namespace Vocaluxe.Screens
public override bool HandleMouse(SMouseEvent mouseEvent) public override bool HandleMouse(SMouseEvent mouseEvent)
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (Buttons[_ButtonNext].Selected) if (_Buttons[_ButtonNext].Selected)
CBackgroundMusic.Next(); CBackgroundMusic.Next();
if (Buttons[_ButtonPrevious].Selected) if (_Buttons[_ButtonPrevious].Selected)
CBackgroundMusic.Previous(); CBackgroundMusic.Previous();
if (Buttons[_ButtonPlay].Selected) if (_Buttons[_ButtonPlay].Selected)
CBackgroundMusic.Play(); CBackgroundMusic.Play();
if (Buttons[_ButtonPause].Selected) if (_Buttons[_ButtonPause].Selected)
CBackgroundMusic.Pause(); CBackgroundMusic.Pause();
if (Buttons[_ButtonRepeat].Selected) if (_Buttons[_ButtonRepeat].Selected)
CBackgroundMusic.RepeatSong = !CBackgroundMusic.RepeatSong; CBackgroundMusic.RepeatSong = !CBackgroundMusic.RepeatSong;
if (Buttons[_ButtonShowVideo].Selected) if (_Buttons[_ButtonShowVideo].Selected)
_VideoPreview = !_VideoPreview; _VideoPreview = !_VideoPreview;
if (Buttons[_ButtonSing].Selected) if (_Buttons[_ButtonSing].Selected)
_StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet); _StartSong(CBackgroundMusic.SongID);
if (Buttons[_ButtonToBackgroundVideo].Selected) if (_Buttons[_ButtonToBackgroundVideo].Selected)
_VideoBackground = !_VideoBackground; _VideoBackground = !_VideoBackground;
} }
else if (mouseEvent.LB) else if (mouseEvent.LB)
@@ -165,11 +174,11 @@ namespace Vocaluxe.Screens
public override bool UpdateGame() public override bool UpdateGame()
{ {
Statics[_StaticCover].Visible = !_VideoPreviewInt || !CBackgroundMusic.SongHasVideo; _Statics[_StaticCover].Visible = !_VideoPreviewInt || !CBackgroundMusic.SongHasVideo;
Buttons[_ButtonToBackgroundVideo].Pressed = _VideoBackground; _Buttons[_ButtonToBackgroundVideo].Pressed = _VideoBackground;
Buttons[_ButtonShowVideo].Pressed = _VideoPreviewInt; _Buttons[_ButtonShowVideo].Pressed = _VideoPreviewInt;
Buttons[_ButtonRepeat].Pressed = CBackgroundMusic.RepeatSong; _Buttons[_ButtonRepeat].Pressed = CBackgroundMusic.RepeatSong;
Buttons[_ButtonSing].Visible = CBackgroundMusic.CanSing && CParty.CurrentPartyModeID == -1; _Buttons[_ButtonSing].Visible = CBackgroundMusic.CanSing && CParty.CurrentPartyModeID == -1;
return true; return true;
} }
@@ -177,20 +186,20 @@ namespace Vocaluxe.Screens
{ {
if (!_Active) if (!_Active)
return false; return false;
Statics[_StaticCover].Texture = CBackgroundMusic.Cover; _Statics[_StaticCover].Texture = CBackgroundMusic.Cover;
if (CBackgroundMusic.VideoEnabled && _VideoPreview && CBackgroundMusic.SongHasVideo) if (CBackgroundMusic.VideoEnabled && _VideoPreview && CBackgroundMusic.SongHasVideo)
CDraw.DrawTexture(Statics[_StaticCover], CBackgroundMusic.GetVideoTexture(), EAspect.Crop); CDraw.DrawTexture(_Statics[_StaticCover], CBackgroundMusic.GetVideoTexture(), EAspect.Crop);
Buttons[_ButtonPause].Visible = CBackgroundMusic.Playing; _Buttons[_ButtonPause].Visible = CBackgroundMusic.IsPlaying;
Buttons[_ButtonPlay].Visible = !CBackgroundMusic.Playing; _Buttons[_ButtonPlay].Visible = !CBackgroundMusic.IsPlaying;
Texts[_TextCurrentSong].Text = CBackgroundMusic.ArtistAndTitle; _Texts[_TextCurrentSong].Text = CBackgroundMusic.ArtistAndTitle;
return base.Draw(); return base.Draw();
} }
private void _StartSong(int songNr, bool duet) private void _StartSong(int songNr)
{
if (songNr >= 0 && CSongs.SongsLoaded)
{ {
if (songNr < 0 || !CSongs.SongsLoaded)
return;
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
@@ -203,5 +212,4 @@ namespace Vocaluxe.Screens
CGraphics.FadeTo(EScreens.ScreenNames); CGraphics.FadeTo(EScreens.ScreenNames);
} }
} }
}
} }
+41 -24
View File
@@ -1,4 +1,23 @@
using Vocaluxe.Base; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace Vocaluxe.Screens namespace Vocaluxe.Screens
@@ -27,8 +46,8 @@ namespace Vocaluxe.Screens
{ {
base.LoadTheme(xmlPath); base.LoadTheme(xmlPath);
_ScreenArea = Statics[_StaticBG].Rect; _ScreenArea = _Statics[_StaticBG].Rect;
SelectSlides[_SelectSlideVolume].AddValues(new string[] _SelectSlides[_SelectSlideVolume].AddValues(new string[]
{"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"}); {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"});
} }
@@ -46,27 +65,25 @@ namespace Vocaluxe.Screens
_SaveConfig(); _SaveConfig();
return true; return true;
} }
else if (mouseEvent.Wheel > 0 && CHelper.IsInBounds(_ScreenArea, mouseEvent)) if (mouseEvent.Wheel > 0 && CHelper.IsInBounds(_ScreenArea, mouseEvent))
{ {
if (SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel >= 0) if (_SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel >= 0)
SelectSlides[_SelectSlideVolume].Selection = SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel; _SelectSlides[_SelectSlideVolume].Selection = _SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel;
else if (SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel < 0) else if (_SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel < 0)
SelectSlides[_SelectSlideVolume].Selection = 0; _SelectSlides[_SelectSlideVolume].Selection = 0;
_SaveConfig(); _SaveConfig();
return true; return true;
} }
else if (mouseEvent.Wheel < 0 && CHelper.IsInBounds(_ScreenArea, mouseEvent)) if (mouseEvent.Wheel < 0 && CHelper.IsInBounds(_ScreenArea, mouseEvent))
{ {
if (SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel < SelectSlides[_SelectSlideVolume].NumValues) if (_SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel < _SelectSlides[_SelectSlideVolume].NumValues)
SelectSlides[_SelectSlideVolume].Selection = SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel; _SelectSlides[_SelectSlideVolume].Selection = _SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel;
else if (SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel >= SelectSlides[_SelectSlideVolume].NumValues) else if (_SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel >= _SelectSlides[_SelectSlideVolume].NumValues)
SelectSlides[_SelectSlideVolume].Selection = SelectSlides[_SelectSlideVolume].NumValues - 1; _SelectSlides[_SelectSlideVolume].Selection = _SelectSlides[_SelectSlideVolume].NumValues - 1;
_SaveConfig(); _SaveConfig();
return true; return true;
} }
else if (mouseEvent.RB) return !mouseEvent.RB;
return false;
return true;
} }
public override void OnShow() public override void OnShow()
@@ -95,20 +112,20 @@ namespace Vocaluxe.Screens
{ {
case EScreens.ScreenSong: case EScreens.ScreenSong:
if (CSongs.IsInCategory) if (CSongs.IsInCategory)
CConfig.PreviewMusicVolume = SelectSlides[_SelectSlideVolume].Selection * 5; CConfig.PreviewMusicVolume = _SelectSlides[_SelectSlideVolume].Selection * 5;
else else
{ {
CConfig.BackgroundMusicVolume = SelectSlides[_SelectSlideVolume].Selection * 5; CConfig.BackgroundMusicVolume = _SelectSlides[_SelectSlideVolume].Selection * 5;
CBackgroundMusic.ApplyVolume(); CBackgroundMusic.ApplyVolume();
} }
break; break;
case EScreens.ScreenSing: case EScreens.ScreenSing:
CConfig.GameMusicVolume = SelectSlides[_SelectSlideVolume].Selection * 5; CConfig.GameMusicVolume = _SelectSlides[_SelectSlideVolume].Selection * 5;
break; break;
default: default:
CConfig.BackgroundMusicVolume = SelectSlides[_SelectSlideVolume].Selection * 5; CConfig.BackgroundMusicVolume = _SelectSlides[_SelectSlideVolume].Selection * 5;
CBackgroundMusic.ApplyVolume(); CBackgroundMusic.ApplyVolume();
break; break;
} }
@@ -121,17 +138,17 @@ namespace Vocaluxe.Screens
{ {
case EScreens.ScreenSong: case EScreens.ScreenSong:
if (CSongs.IsInCategory) if (CSongs.IsInCategory)
SelectSlides[_SelectSlideVolume].Selection = CConfig.PreviewMusicVolume / 5; _SelectSlides[_SelectSlideVolume].Selection = CConfig.PreviewMusicVolume / 5;
else else
SelectSlides[_SelectSlideVolume].Selection = CConfig.BackgroundMusicVolume / 5; _SelectSlides[_SelectSlideVolume].Selection = CConfig.BackgroundMusicVolume / 5;
break; break;
case EScreens.ScreenSing: case EScreens.ScreenSing:
SelectSlides[_SelectSlideVolume].Selection = CConfig.GameMusicVolume / 5; _SelectSlides[_SelectSlideVolume].Selection = CConfig.GameMusicVolume / 5;
break; break;
default: default:
SelectSlides[_SelectSlideVolume].Selection = CConfig.BackgroundMusicVolume / 5; _SelectSlides[_SelectSlideVolume].Selection = CConfig.BackgroundMusicVolume / 5;
break; break;
} }
} }
+40 -24
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
@@ -115,6 +134,7 @@ namespace Vocaluxe.Screens
private STexture _TexNameBrunzel; private STexture _TexNameBrunzel;
private STexture _TexNameDarkice; private STexture _TexNameDarkice;
private STexture _TexNameFlokuep; private STexture _TexNameFlokuep;
private STexture _TexNameFlamefire;
private STexture _TexNameMesand; private STexture _TexNameMesand;
private STexture _TexNameBohning; private STexture _TexNameBohning;
private STexture _TexNameBabene03; private STexture _TexNameBabene03;
@@ -133,13 +153,10 @@ namespace Vocaluxe.Screens
_ParagraphTexts = new List<CText>(); _ParagraphTexts = new List<CText>();
_Paragraphs = new List<string[]>(); _Paragraphs = new List<string[]>();
string paragraph; string paragraph = "Inspired by the achievements of UltraStar Deluxe and its variants and pursuing the goal of making " +
string[] words;
paragraph = "Inspired by the achievements of UltraStar Deluxe and its variants and pursuing the goal of making " +
"a good thing even better, we ended up rewriting the game from scratch. And a new implementation in a new " + "a good thing even better, we ended up rewriting the game from scratch. And a new implementation in a new " +
"programming language called for a new name - and VOCALUXE [ˈvoʊˈkəˈlʌks] it is!"; "programming language called for a new name - and VOCALUXE [ˈvoʊˈkəˈlʌks] it is!";
words = paragraph.Split(new char[] {' '}); string[] words = paragraph.Split(new char[] {' '});
_Paragraphs.Add(words); _Paragraphs.Add(words);
paragraph = "This first public version has already implemented many of the original features and it is fully " + paragraph = "This first public version has already implemented many of the original features and it is fully " +
@@ -177,6 +194,7 @@ namespace Vocaluxe.Screens
CDataBase.GetCreditsRessource("brunzel.png", ref _TexNameBrunzel); CDataBase.GetCreditsRessource("brunzel.png", ref _TexNameBrunzel);
CDataBase.GetCreditsRessource("Darkice.png", ref _TexNameDarkice); CDataBase.GetCreditsRessource("Darkice.png", ref _TexNameDarkice);
CDataBase.GetCreditsRessource("flokuep.png", ref _TexNameFlokuep); CDataBase.GetCreditsRessource("flokuep.png", ref _TexNameFlokuep);
CDataBase.GetCreditsRessource("flamefire.png", ref _TexNameFlamefire);
CDataBase.GetCreditsRessource("bohning.png", ref _TexNameBohning); CDataBase.GetCreditsRessource("bohning.png", ref _TexNameBohning);
CDataBase.GetCreditsRessource("mesand.png", ref _TexNameMesand); CDataBase.GetCreditsRessource("mesand.png", ref _TexNameMesand);
CDataBase.GetCreditsRessource("babene03.png", ref _TexNameBabene03); CDataBase.GetCreditsRessource("babene03.png", ref _TexNameBabene03);
@@ -185,21 +203,21 @@ namespace Vocaluxe.Screens
//Prepare Text //Prepare Text
int lastY = 280; int lastY = 280;
for (int i = 0; i < _Paragraphs.Count; i++) foreach (string[] paragraph in _Paragraphs)
{ {
string line = ""; string line = "";
for (int e = 0; e < _Paragraphs[i].Length; e++) for (int e = 0; e < paragraph.Length; e++)
{ {
if (_Paragraphs[i][e] != null) if (paragraph[e] == null)
{ continue;
string newline = line + " " + _Paragraphs[i][e]; string newLine = " " + paragraph[e];
CText text = GetNewText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line); CText text = GetNewText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line);
if (CDraw.GetTextBounds(text).Width < (CSettings.RenderW - 220)) if (CDraw.GetTextBounds(text).Width < (CSettings.RenderW - 220))
{ {
line = line + " " + _Paragraphs[i][e]; line += newLine;
//Check if all words are used //Check if all words are used
if ((e + 1) == _Paragraphs[i].Length) if ((e + 1) == paragraph.Length)
{ {
text.Text = line; text.Text = line;
_ParagraphTexts.Add(text); _ParagraphTexts.Add(text);
@@ -210,13 +228,12 @@ namespace Vocaluxe.Screens
else else
{ {
_ParagraphTexts.Add(text); _ParagraphTexts.Add(text);
line = " " + _Paragraphs[i][e]; line = newLine;
lastY += 27; lastY += 27;
} }
} }
} }
} }
}
public override void ReloadTheme(string xmlPath) {} public override void ReloadTheme(string xmlPath) {}
@@ -257,7 +274,7 @@ namespace Vocaluxe.Screens
return true; return true;
} }
public CParticleEffect GetStarParticles(int numStars, bool isRed, SRectF rect, bool bigParticles) private CParticleEffect _GetStarParticles(int numStars, bool isRed, SRectF rect, bool bigParticles)
{ {
SColorF partColor = isRed ? new SColorF(1, 0, 0, 1) : new SColorF(0.149f, 0.415f, 0.819f, 1); SColorF partColor = isRed ? new SColorF(1, 0, 0, 1) : new SColorF(0.149f, 0.415f, 0.819f, 1);
int partSize = bigParticles ? 35 : 25; int partSize = bigParticles ? 35 : 25;
@@ -274,10 +291,9 @@ namespace Vocaluxe.Screens
CStatic image = GetNewStatic(texture, new SColorF(1, 1, 1, 1), new SRectF(-1, -1, 400, 120, -4)); CStatic image = GetNewStatic(texture, new SColorF(1, 1, 1, 1), new SRectF(-1, -1, 400, 120, -4));
SRectF particleRect = new SRectF(-1, -1, partRectSize, partRectSize, -6); SRectF particleRect = new SRectF(-1, -1, partRectSize, partRectSize, -6);
SRectF imgDotRect = new SRectF(particleRect); SRectF imgDotRect = new SRectF(particleRect) {Z = -5};
imgDotRect.Z = -5;
CStatic imgDot = GetNewStatic(texDot, new SColorF(1, 1, 1, 1), imgDotRect); CStatic imgDot = GetNewStatic(texDot, new SColorF(1, 1, 1, 1), imgDotRect);
CParticleEffect particle = GetStarParticles(partCount, isRight, particleRect, bigParticles); CParticleEffect particle = _GetStarParticles(partCount, isRight, particleRect, bigParticles);
CCreditName credit = new CCreditName(image, imgDot, particle, particleOffsetX, particleOffsetY); CCreditName credit = new CCreditName(image, imgDot, particle, particleOffsetX, particleOffsetY);
@@ -305,8 +321,8 @@ namespace Vocaluxe.Screens
//Little stars for logo //Little stars for logo
int numstars = (int)(_Logo.Rect.W * 0.25f / 2f); int numstars = (int)(_Logo.Rect.W * 0.25f / 2f);
SRectF partRect = new SRectF(_Logo.Rect.X, _Logo.Rect.Y, _Logo.Rect.W, _Logo.Rect.H, -1); SRectF partRect = new SRectF(_Logo.Rect.X, _Logo.Rect.Y, _Logo.Rect.W, _Logo.Rect.H, -1);
_StarsRed = GetStarParticles(numstars, true, partRect, true); _StarsRed = _GetStarParticles(numstars, true, partRect, true);
_StarsBlue = GetStarParticles(numstars, false, partRect, true); _StarsBlue = _GetStarParticles(numstars, false, partRect, true);
//Credit names //Credit names
_CreditNames = new List<CCreditName>(); _CreditNames = new List<CCreditName>();
@@ -314,6 +330,7 @@ namespace Vocaluxe.Screens
_AddNewCreditName(_TexNameBrunzel, 502, 29, true); _AddNewCreditName(_TexNameBrunzel, 502, 29, true);
_AddNewCreditName(_TexNameDarkice, 360, 55, true); _AddNewCreditName(_TexNameDarkice, 360, 55, true);
_AddNewCreditName(_TexNameFlokuep, 214, 14, true); _AddNewCreditName(_TexNameFlokuep, 214, 14, true);
_AddNewCreditName(_TexNameFlamefire, 496, 46, true);
_AddNewCreditName(_TexNameBohning, 383, 54, false); _AddNewCreditName(_TexNameBohning, 383, 54, false);
_AddNewCreditName(_TexNameMesand, 525, 13, false); _AddNewCreditName(_TexNameMesand, 525, 13, false);
_AddNewCreditName(_TexNameBabene03, 33, 26, false); _AddNewCreditName(_TexNameBabene03, 33, 26, false);
@@ -352,8 +369,8 @@ namespace Vocaluxe.Screens
//Draw Text //Draw Text
if (_TextTimer.IsRunning) if (_TextTimer.IsRunning)
{ {
for (int i = 0; i < _ParagraphTexts.Count; i++) foreach (CText text in _ParagraphTexts)
_ParagraphTexts[i].Draw(); text.Draw();
} }
return true; return true;
} }
@@ -432,7 +449,6 @@ namespace Vocaluxe.Screens
//Start Text-Timer //Start Text-Timer
_TextTimer.Start(); _TextTimer.Start();
active = true;
} }
} }
else if (_CreditNames[i].Y <= 360f) else if (_CreditNames[i].Y <= 360f)
+52 -44
View File
@@ -1,5 +1,25 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.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;
@@ -34,41 +54,39 @@ namespace Vocaluxe.Screens
{ {
base.Init(); base.Init();
List<string> texts = new List<string>(); List<string> texts = new List<string> {_TextSongName, _TextSongMode};
texts.Add(_TextSongName);
texts.Add(_TextSongMode);
_TextNumber = new string[_NumEntrys]; _TextNumber = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++) for (int i = 0; i < _NumEntrys; i++)
{ {
_TextNumber[i] = "TextNumber" + (i + 1).ToString(); _TextNumber[i] = "TextNumber" + (i + 1);
texts.Add(_TextNumber[i]); texts.Add(_TextNumber[i]);
} }
_TextName = new string[_NumEntrys]; _TextName = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++) for (int i = 0; i < _NumEntrys; i++)
{ {
_TextName[i] = "TextName" + (i + 1).ToString(); _TextName[i] = "TextName" + (i + 1);
texts.Add(_TextName[i]); texts.Add(_TextName[i]);
} }
_TextScore = new string[_NumEntrys]; _TextScore = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++) for (int i = 0; i < _NumEntrys; i++)
{ {
_TextScore[i] = "TextScore" + (i + 1).ToString(); _TextScore[i] = "TextScore" + (i + 1);
texts.Add(_TextScore[i]); texts.Add(_TextScore[i]);
} }
_TextDate = new string[_NumEntrys]; _TextDate = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++) for (int i = 0; i < _NumEntrys; i++)
{ {
_TextDate[i] = "TextDate" + (i + 1).ToString(); _TextDate[i] = "TextDate" + (i + 1);
texts.Add(_TextDate[i]); texts.Add(_TextDate[i]);
} }
_ParticleEffectNew = new string[_NumEntrys]; _ParticleEffectNew = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++) for (int i = 0; i < _NumEntrys; i++)
_ParticleEffectNew[i] = "ParticleEffectNew" + (i + 1).ToString(); _ParticleEffectNew[i] = "ParticleEffectNew" + (i + 1);
_ThemeTexts = texts.ToArray(); _ThemeTexts = texts.ToArray();
_ThemeParticleEffects = _ParticleEffectNew; _ThemeParticleEffects = _ParticleEffectNew;
@@ -112,7 +130,7 @@ namespace Vocaluxe.Screens
public override bool HandleMouse(SMouseEvent mouseEvent) public override bool HandleMouse(SMouseEvent mouseEvent)
{ {
if (mouseEvent.LB && IsMouseOver(mouseEvent)) {} if (mouseEvent.LB && _IsMouseOver(mouseEvent)) {}
if (mouseEvent.LB) if (mouseEvent.LB)
_LeaveScreen(); _LeaveScreen();
@@ -141,34 +159,31 @@ namespace Vocaluxe.Screens
{ {
if (_Pos + p < _Scores[_Round].Count) if (_Pos + p < _Scores[_Round].Count)
{ {
Texts[_TextNumber[p]].Visible = true; _Texts[_TextNumber[p]].Visible = true;
Texts[_TextName[p]].Visible = true; _Texts[_TextName[p]].Visible = true;
Texts[_TextScore[p]].Visible = true; _Texts[_TextScore[p]].Visible = true;
Texts[_TextDate[p]].Visible = true; _Texts[_TextDate[p]].Visible = true;
Texts[_TextNumber[p]].Text = (_Pos + p + 1).ToString(); _Texts[_TextNumber[p]].Text = (_Pos + p + 1).ToString();
string name = _Scores[_Round][_Pos + p].Name; string name = _Scores[_Round][_Pos + p].Name;
name += " [" + CLanguage.Translate(Enum.GetName(typeof(EGameDifficulty), _Scores[_Round][_Pos + p].Difficulty)) + "]"; name += " [" + CLanguage.Translate(Enum.GetName(typeof(EGameDifficulty), _Scores[_Round][_Pos + p].Difficulty)) + "]";
if (_IsDuet) if (_IsDuet)
name += " (P" + (_Scores[_Round][_Pos + p].LineNr + 1).ToString() + ")"; name += " (P" + (_Scores[_Round][_Pos + p].LineNr + 1) + ")";
Texts[_TextName[p]].Text = name; _Texts[_TextName[p]].Text = name;
Texts[_TextScore[p]].Text = _Scores[_Round][_Pos + p].Score.ToString("00000"); _Texts[_TextScore[p]].Text = _Scores[_Round][_Pos + p].Score.ToString("00000");
Texts[_TextDate[p]].Text = _Scores[_Round][_Pos + p].Date; _Texts[_TextDate[p]].Text = _Scores[_Round][_Pos + p].Date;
if (_IsNewEntry(_Scores[_Round][_Pos + p].ID)) _ParticleEffects[_ParticleEffectNew[p]].Visible = _IsNewEntry(_Scores[_Round][_Pos + p].ID);
ParticleEffects[_ParticleEffectNew[p]].Visible = true;
else
ParticleEffects[_ParticleEffectNew[p]].Visible = false;
} }
else else
{ {
Texts[_TextNumber[p]].Visible = false; _Texts[_TextNumber[p]].Visible = false;
Texts[_TextName[p]].Visible = false; _Texts[_TextName[p]].Visible = false;
Texts[_TextScore[p]].Visible = false; _Texts[_TextScore[p]].Visible = false;
Texts[_TextDate[p]].Visible = false; _Texts[_TextDate[p]].Visible = false;
ParticleEffects[_ParticleEffectNew[p]].Visible = false; _ParticleEffects[_ParticleEffectNew[p]].Visible = false;
} }
} }
return true; return true;
@@ -193,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()
@@ -230,7 +239,7 @@ namespace Vocaluxe.Screens
for (int round = 0; round < points.NumRounds; round++) for (int round = 0; round < points.NumRounds; round++)
{ {
SPlayer player = points.GetPlayer(round, CGame.NumPlayer)[0]; SPlayer player = points.GetPlayer(round, CGame.NumPlayer)[0];
CDataBase.LoadScore(ref _Scores[round], player); CDataBase.LoadScore(out _Scores[round], player);
} }
} }
@@ -238,36 +247,35 @@ namespace Vocaluxe.Screens
{ {
_IsDuet = false; _IsDuet = false;
CPoints points = CGame.GetPoints(); CPoints points = CGame.GetPoints();
SPlayer player = points.GetPlayer(_Round, CGame.NumPlayer)[0];
CSong song = CGame.GetSong(_Round + 1); CSong song = CGame.GetSong(_Round + 1);
if (song == null) if (song == null)
return; return;
Texts[_TextSongName].Text = song.Artist + " - " + song.Title; _Texts[_TextSongName].Text = song.Artist + " - " + song.Title;
if (points.NumRounds > 1) if (points.NumRounds > 1)
Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")"; _Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
switch (CGame.GetGameMode(_Round)) switch (CGame.GetGameMode(_Round))
{ {
case EGameMode.TR_GAMEMODE_NORMAL: case EGameMode.TR_GAMEMODE_NORMAL:
Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL"; _Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
break; break;
case EGameMode.TR_GAMEMODE_MEDLEY: case EGameMode.TR_GAMEMODE_MEDLEY:
Texts[_TextSongMode].Text = "TR_GAMEMODE_MEDLEY"; _Texts[_TextSongMode].Text = "TR_GAMEMODE_MEDLEY";
break; break;
case EGameMode.TR_GAMEMODE_DUET: case EGameMode.TR_GAMEMODE_DUET:
Texts[_TextSongMode].Text = "TR_GAMEMODE_DUET"; _Texts[_TextSongMode].Text = "TR_GAMEMODE_DUET";
_IsDuet = true; _IsDuet = true;
break; break;
case EGameMode.TR_GAMEMODE_SHORTSONG: case EGameMode.TR_GAMEMODE_SHORTSONG:
Texts[_TextSongMode].Text = "TR_GAMEMODE_SHORTSONG"; _Texts[_TextSongMode].Text = "TR_GAMEMODE_SHORTSONG";
break; break;
default: default:
Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL"; _Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
break; break;
} }
+34 -17
View File
@@ -1,4 +1,23 @@
using System.Diagnostics; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Diagnostics;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
@@ -13,7 +32,6 @@ namespace Vocaluxe.Screens
{ {
get { return 1; } get { return 1; }
} }
private const float _WaitTime = 0.5f; //wait time before starting first video
private const string _TextStatus = "TextStatus"; private const string _TextStatus = "TextStatus";
@@ -84,10 +102,9 @@ namespace Vocaluxe.Screens
} }
} }
_SongLoaderThread = new Thread(CSongs.LoadSongs); _SongLoaderThread = new Thread(CSongs.LoadSongs) {Name = "SongLoader"};
_SongLoaderThread.Name = "SongLoader";
Texts[_TextStatus].Text = CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": 0 " + _Texts[_TextStatus].Text = CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": 0 " +
CLanguage.Translate("TR_SCREENLOAD_SONGS") + " (0 " + CLanguage.Translate("TR_SCREENLOAD_SONGS") + " (0 " +
CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")"; CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")";
@@ -110,8 +127,8 @@ namespace Vocaluxe.Screens
if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON) if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON)
{ {
for (int i = 0; i < _Intros.Length; i++) foreach (CVideoPlayer videoPlayer in _Intros)
_Intros[i].PreLoad(); videoPlayer.PreLoad();
} }
CLog.StartBenchmark(0, "Load Songs Full"); CLog.StartBenchmark(0, "Load Songs Full");
@@ -124,7 +141,7 @@ namespace Vocaluxe.Screens
{ {
CBackgroundMusic.AddOwnMusic(); CBackgroundMusic.AddOwnMusic();
if (!CBackgroundMusic.Playing) if (!CBackgroundMusic.IsPlaying)
CBackgroundMusic.Next(); CBackgroundMusic.Next();
_BGMusicStartet = true; _BGMusicStartet = true;
@@ -150,8 +167,8 @@ namespace Vocaluxe.Screens
if (CSettings.GameState == EGameState.Normal) if (CSettings.GameState == EGameState.Normal)
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
Texts[_TextStatus].Text = _Texts[_TextStatus].Text =
CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": " + CSongs.NumAllSongs.ToString() + " " + CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": " + CSongs.NumAllSongs + " " +
CLanguage.Translate("TR_SCREENLOAD_SONGS") + " (" + CSongs.NumSongsWithCoverLoaded + " " + CLanguage.Translate("TR_SCREENLOAD_SONGS") + " (" + CSongs.NumSongsWithCoverLoaded + " " +
CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")"; CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")";
@@ -160,7 +177,7 @@ namespace Vocaluxe.Screens
{ {
CBackgroundMusic.AddOwnMusic(); CBackgroundMusic.AddOwnMusic();
if (!CBackgroundMusic.Playing) if (!CBackgroundMusic.IsPlaying)
CBackgroundMusic.Next(); CBackgroundMusic.Next();
_BGMusicStartet = true; _BGMusicStartet = true;
@@ -171,12 +188,12 @@ namespace Vocaluxe.Screens
public override bool Draw() public override bool Draw()
{ {
DrawBG(); _DrawBG();
for (int i = 0; i < _Intros.Length; i++) foreach (CVideoPlayer videoPlayer in _Intros)
_Intros[i].Draw(); videoPlayer.Draw();
DrawFG(); _DrawFG();
return true; return true;
} }
@@ -186,8 +203,8 @@ namespace Vocaluxe.Screens
_Timer.Stop(); _Timer.Stop();
_Timer.Reset(); _Timer.Reset();
for (int i = 0; i < _Intros.Length; i++) foreach (CVideoPlayer videoPlayer in _Intros)
_Intros[i].Close(); videoPlayer.Close();
CBackgroundMusic.CanSing = true; CBackgroundMusic.CanSing = true;
+41 -14
View File
@@ -1,4 +1,23 @@
using System.Windows.Forms; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -53,22 +72,22 @@ namespace Vocaluxe.Screens
break; break;
case Keys.Enter: case Keys.Enter:
if (Buttons[_ButtonSing].Selected) if (_Buttons[_ButtonSing].Selected)
{ {
CParty.SetNormalGameMode(); CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
} }
if (Buttons[_ButtonParty].Selected) if (_Buttons[_ButtonParty].Selected)
CGraphics.FadeTo(EScreens.ScreenParty); CGraphics.FadeTo(EScreens.ScreenParty);
if (Buttons[_ButtonOptions].Selected) if (_Buttons[_ButtonOptions].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
if (Buttons[_ButtonProfiles].Selected) if (_Buttons[_ButtonProfiles].Selected)
CGraphics.FadeTo(EScreens.ScreenProfiles); CGraphics.FadeTo(EScreens.ScreenProfiles);
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
return false; return false;
break; break;
@@ -81,30 +100,31 @@ namespace Vocaluxe.Screens
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (Buttons[_ButtonSing].Selected) if (_Buttons[_ButtonSing].Selected)
{ {
CParty.SetNormalGameMode(); CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
} }
if (Buttons[_ButtonParty].Selected) if (_Buttons[_ButtonParty].Selected)
CGraphics.FadeTo(EScreens.ScreenParty); CGraphics.FadeTo(EScreens.ScreenParty);
if (Buttons[_ButtonOptions].Selected) if (_Buttons[_ButtonOptions].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
if (Buttons[_ButtonProfiles].Selected) if (_Buttons[_ButtonProfiles].Selected)
CGraphics.FadeTo(EScreens.ScreenProfiles); CGraphics.FadeTo(EScreens.ScreenProfiles);
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
return false; return false;
} }
return true; return true;
} }
// ReSharper disable RedundantOverridenMember
public override void OnShow() public override void OnShow()
{ {
base.OnShow(); base.OnShow();
@@ -113,6 +133,8 @@ namespace Vocaluxe.Screens
// Snowflakes.Resume(); // Snowflakes.Resume();
} }
// ReSharper restore RedundantOverridenMember
public override bool UpdateGame() public override bool UpdateGame()
{ {
return true; return true;
@@ -120,16 +142,18 @@ namespace Vocaluxe.Screens
public override bool Draw() public override bool Draw()
{ {
DrawBG(); _DrawBG();
//if (Snowflakes == null) //if (Snowflakes == null)
// Snowflakes = new CParticleEffect(300, new SColorF(1, 1, 1, 1), new SRectF(0, 0, CSettings.iRenderW, 0, 0.5f), "Snowflake", 25, EParticeType.Snow); // Snowflakes = new CParticleEffect(300, new SColorF(1, 1, 1, 1), new SRectF(0, 0, CSettings.iRenderW, 0, 0.5f), "Snowflake", 25, EParticeType.Snow);
//Snowflakes.Update(); //Snowflakes.Update();
//Snowflakes.Draw(); //Snowflakes.Draw();
DrawFG(); _DrawFG();
// ReSharper disable ConditionIsAlwaysTrueOrFalse
if (CSettings.VersionRevision != ERevision.Release) if (CSettings.VersionRevision != ERevision.Release)
// ReSharper restore ConditionIsAlwaysTrueOrFalse
{ {
CFonts.SetFont("Normal"); CFonts.SetFont("Normal");
CFonts.Style = EStyle.Normal; CFonts.Style = EStyle.Normal;
@@ -139,6 +163,7 @@ namespace Vocaluxe.Screens
return true; return true;
} }
// ReSharper disable RedundantOverridenMember
public override void OnClose() public override void OnClose()
{ {
base.OnClose(); base.OnClose();
@@ -146,5 +171,7 @@ namespace Vocaluxe.Screens
//if (Snowflakes != null) //if (Snowflakes != null)
// Snowflakes.Pause(); // Snowflakes.Pause();
} }
// ReSharper restore RedundantOverridenMember
} }
} }
+159 -280
View File
@@ -1,4 +1,23 @@
using System; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
@@ -36,37 +55,30 @@ namespace Vocaluxe.Screens
{"SelectSlideDuetPlayer1", "SelectSlideDuetPlayer2", "SelectSlideDuetPlayer3", "SelectSlideDuetPlayer4", "SelectSlideDuetPlayer5", "SelectSlideDuetPlayer6"}; {"SelectSlideDuetPlayer1", "SelectSlideDuetPlayer2", "SelectSlideDuetPlayer3", "SelectSlideDuetPlayer4", "SelectSlideDuetPlayer5", "SelectSlideDuetPlayer6"};
private readonly STexture[] _OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer]; private readonly STexture[] _OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer];
private bool _SelectingMouseActive;
private bool _SelectingKeyboardActive; private bool _SelectingKeyboardActive;
private bool _SelectingKeyboardUnendless; private bool _SelectingKeyboardUnendless;
private int _SelectingKeyboardPlayerNr; private int _SelectingKeyboardPlayerNr;
private int _SelectedPlayerNr; private int _SelectedPlayerNr;
private int[] _PlayerNr;
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
List<string> statics = new List<string>(); List<string> statics = new List<string>();
foreach (string text in _StaticPlayer) statics.AddRange(_StaticPlayerAvatar);
statics.Add(text); statics.AddRange(_StaticPlayer);
foreach (string text in _StaticPlayerAvatar)
statics.Add(text);
statics.Add(_StaticWarningMics); statics.Add(_StaticWarningMics);
statics.Add(_StaticWarningProfiles); statics.Add(_StaticWarningProfiles);
_ThemeStatics = statics.ToArray(); _ThemeStatics = statics.ToArray();
List<string> texts = new List<string>(); List<string> texts = new List<string> {_SelectSlidePlayerNumber};
texts.Add(_SelectSlidePlayerNumber);
texts.AddRange(_SelectSlideDuetPlayer); texts.AddRange(_SelectSlideDuetPlayer);
_ThemeSelectSlides = texts.ToArray(); _ThemeSelectSlides = texts.ToArray();
texts.Clear(); texts.Clear();
texts.Add(_TextWarningMics); texts.Add(_TextWarningMics);
texts.Add(_TextWarningProfiles); texts.Add(_TextWarningProfiles);
foreach (string text in _TextPlayer) texts.AddRange(_TextPlayer);
texts.Add(text);
_ThemeTexts = texts.ToArray(); _ThemeTexts = texts.ToArray();
texts.Clear(); texts.Clear();
@@ -91,15 +103,11 @@ namespace Vocaluxe.Screens
{ {
base.LoadTheme(xmlPath); base.LoadTheme(xmlPath);
_PlayerNr = new int[CSettings.MaxNumPlayer];
for (int i = 0; i < _PlayerNr.Length; i++)
_PlayerNr[i] = i;
for (int i = 0; i < CSettings.MaxNumPlayer; i++) for (int i = 0; i < CSettings.MaxNumPlayer; i++)
_OriginalPlayerAvatarTextures[i] = Statics[_StaticPlayerAvatar[i]].Texture; _OriginalPlayerAvatarTextures[i] = _Statics[_StaticPlayerAvatar[i]].Texture;
for (int i = 1; i <= CSettings.MaxNumPlayer; i++) for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
Equalizers["EqualizerPlayer" + i].ScreenHandles = true; _Equalizers["EqualizerPlayer" + i].ScreenHandles = true;
} }
public override bool HandleInput(SKeyEvent keyEvent) public override bool HandleInput(SKeyEvent keyEvent)
@@ -109,20 +117,20 @@ namespace Vocaluxe.Screens
case Keys.Add: case Keys.Add:
if (CConfig.NumPlayer + 1 <= CSettings.MaxNumPlayer) if (CConfig.NumPlayer + 1 <= CSettings.MaxNumPlayer)
{ {
SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer; _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer;
_UpdatePlayerNumber(); _UpdatePlayerNumber();
//Update Tiles-List //Update Tiles-List
NameSelections[_NameSelection].UpdateList(); _NameSelections[_NameSelection].UpdateList();
} }
break; break;
case Keys.Subtract: case Keys.Subtract:
if (CConfig.NumPlayer - 1 > 0) if (CConfig.NumPlayer - 1 > 0)
{ {
SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 2; _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 2;
_UpdatePlayerNumber(); _UpdatePlayerNumber();
//Update Tiles-List //Update Tiles-List
NameSelections[_NameSelection].UpdateList(); _NameSelections[_NameSelection].UpdateList();
} }
break; break;
@@ -138,7 +146,7 @@ namespace Vocaluxe.Screens
_SelectingKeyboardPlayerNr++; _SelectingKeyboardPlayerNr++;
else else
_SelectingKeyboardPlayerNr = 1; _SelectingKeyboardPlayerNr = 1;
NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr); _NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
} }
break; break;
} }
@@ -146,203 +154,128 @@ namespace Vocaluxe.Screens
if (_SelectingKeyboardActive) if (_SelectingKeyboardActive)
{ {
//Handle left/right/up/down //Handle left/right/up/down
NameSelections[_NameSelection].HandleInput(keyEvent); _NameSelections[_NameSelection].HandleInput(keyEvent);
int numberPressed = -1;
bool resetSelection = false;
switch (keyEvent.Key) switch (keyEvent.Key)
{ {
case Keys.Enter: case Keys.Enter:
//Check, if a player is selected //Check, if a player is selected
if (NameSelections[_NameSelection].Selection > -1) if (_NameSelections[_NameSelection].Selection > -1)
{ {
_SelectedPlayerNr = NameSelections[_NameSelection].Selection; _SelectedPlayerNr = _NameSelections[_NameSelection].Selection;
//Update Game-infos with new player //Update Game-infos with new player
CGame.Player[_SelectingKeyboardPlayerNr - 1].Name = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; CGame.Players[_SelectingKeyboardPlayerNr - 1].ProfileID = _SelectedPlayerNr;
CGame.Player[_SelectingKeyboardPlayerNr - 1].Difficulty = CProfiles.Profiles[_SelectedPlayerNr].Difficulty;
CGame.Player[_SelectingKeyboardPlayerNr - 1].ProfileID = _SelectedPlayerNr;
//Update config for default players. //Update config for default players.
CConfig.Players[_SelectingKeyboardPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; CConfig.Players[_SelectingKeyboardPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.SaveConfig(); CConfig.SaveConfig();
//Update texture and name //Update texture and name
Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture; _Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture;
Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; _Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning //Update profile-warning
_CheckPlayers(); _CheckPlayers();
//Update Tiles-List //Update Tiles-List
NameSelections[_NameSelection].UpdateList(); _NameSelections[_NameSelection].UpdateList();
SetInteractionToButton(Buttons[_ButtonStart]); _SetInteractionToButton(_Buttons[_ButtonStart]);
} }
//Started selecting with 'P' //Started selecting with 'P'
if (_SelectingKeyboardUnendless) if (_SelectingKeyboardUnendless)
{ {
if (_SelectingKeyboardPlayerNr == CGame.NumPlayer) if (_SelectingKeyboardPlayerNr == CGame.NumPlayer)
{ resetSelection = true;
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else else
{ {
_SelectingKeyboardPlayerNr++; _SelectingKeyboardPlayerNr++;
NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr); _NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
} }
} }
else else
{ resetSelection = true;
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
break; break;
case Keys.D1: case Keys.D1:
case Keys.NumPad1: case Keys.NumPad1:
if (_SelectingKeyboardPlayerNr == 1) numberPressed = 1;
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 1;
NameSelections[_NameSelection].KeyboardSelection(true, 1);
}
_SelectingKeyboardUnendless = false;
break; break;
case Keys.D2: case Keys.D2:
case Keys.NumPad2: case Keys.NumPad2:
if (_SelectingKeyboardPlayerNr == 2) numberPressed = 2;
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 2;
NameSelections[_NameSelection].KeyboardSelection(true, 2);
}
_SelectingKeyboardUnendless = false;
break; break;
case Keys.D3: case Keys.D3:
case Keys.NumPad3: case Keys.NumPad3:
if (_SelectingKeyboardPlayerNr == 3) numberPressed = 3;
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 3;
NameSelections[_NameSelection].KeyboardSelection(true, 3);
}
_SelectingKeyboardUnendless = false;
break; break;
case Keys.D4: case Keys.D4:
case Keys.NumPad4: case Keys.NumPad4:
if (_SelectingKeyboardPlayerNr == 4) numberPressed = 4;
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 4;
NameSelections[_NameSelection].KeyboardSelection(true, 4);
}
_SelectingKeyboardUnendless = false;
break; break;
case Keys.D5: case Keys.D5:
case Keys.NumPad5: case Keys.NumPad5:
if (_SelectingKeyboardPlayerNr == 5) numberPressed = 5;
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 5;
NameSelections[_NameSelection].KeyboardSelection(true, 5);
}
_SelectingKeyboardUnendless = false;
break; break;
case Keys.D6: case Keys.D6:
case Keys.NumPad6: case Keys.NumPad6:
if (_SelectingKeyboardPlayerNr == 6) numberPressed = 6;
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 6;
NameSelections[_NameSelection].KeyboardSelection(true, 6);
}
_SelectingKeyboardUnendless = false;
break; break;
case Keys.Escape: case Keys.Escape:
//Reset all values resetSelection = true;
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
_SelectingKeyboardUnendless = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
break; break;
case Keys.Delete: case Keys.Delete:
//Delete profile-selection //Delete profile-selection
CGame.Player[_SelectingKeyboardPlayerNr - 1].ProfileID = -1; CGame.Players[_SelectingKeyboardPlayerNr - 1].ProfileID = -1;
CGame.Player[_SelectingKeyboardPlayerNr - 1].Name = String.Empty;
CGame.Player[_SelectingKeyboardPlayerNr - 1].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
//Update config for default players. //Update config for default players.
CConfig.Players[_SelectingKeyboardPlayerNr - 1] = String.Empty; CConfig.Players[_SelectingKeyboardPlayerNr - 1] = String.Empty;
CConfig.SaveConfig(); CConfig.SaveConfig();
//Update texture and name //Update texture and name
Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = _OriginalPlayerAvatarTextures[_SelectingKeyboardPlayerNr - 1]; _Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = _OriginalPlayerAvatarTextures[_SelectingKeyboardPlayerNr - 1];
Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + _SelectingKeyboardPlayerNr.ToString(); _Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CProfiles.GetPlayerName(-1, _SelectingKeyboardPlayerNr);
//Update profile-warning //Update profile-warning
_CheckPlayers(); _CheckPlayers();
//Reset all values //Reset all values
_SelectingKeyboardPlayerNr = 0; _SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false; _SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1); _NameSelections[_NameSelection].KeyboardSelection(false, -1);
//Update Tiles-List //Update Tiles-List
NameSelections[_NameSelection].UpdateList(); _NameSelections[_NameSelection].UpdateList();
break; break;
case Keys.F10: case Keys.F10:
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
{ {
if (SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]].Selection == 0) CSelectSlide selectSlideDuetPart = _SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]];
SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]].Selection = 1; selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2;
else
SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]].Selection = 0;
//Reset all values //Reset all values
_SelectingKeyboardPlayerNr = 0; _SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false; _SelectingKeyboardActive = false;
_SelectingKeyboardUnendless = false; _SelectingKeyboardUnendless = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1); _NameSelections[_NameSelection].KeyboardSelection(false, -1);
SetInteractionToButton(Buttons[_ButtonStart]); _SetInteractionToButton(_Buttons[_ButtonStart]);
} }
break; break;
} }
if (numberPressed > 0 || resetSelection)
{
if (numberPressed == _SelectingKeyboardPlayerNr || resetSelection)
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
_NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else if (numberPressed <= CConfig.NumPlayer)
{
_SelectingKeyboardPlayerNr = numberPressed;
_NameSelections[_NameSelection].KeyboardSelection(true, numberPressed);
}
_SelectingKeyboardUnendless = false;
}
} }
//Normal Keyboard handling //Normal Keyboard handling
else else
{ {
base.HandleInput(keyEvent); base.HandleInput(keyEvent);
bool processed = false;
switch (keyEvent.Key) switch (keyEvent.Key)
{ {
case Keys.Escape: case Keys.Escape:
@@ -352,17 +285,10 @@ namespace Vocaluxe.Screens
case Keys.Enter: case Keys.Enter:
if (!processed && Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
{
processed = true;
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
} else
if (!processed /* && Buttons[ButtonStart].Selected */)
{
processed = true;
_StartSong(); _StartSong();
}
break; break;
@@ -395,15 +321,16 @@ namespace Vocaluxe.Screens
case Keys.NumPad6: case Keys.NumPad6:
_SelectingKeyboardPlayerNr = 6; _SelectingKeyboardPlayerNr = 6;
break; break;
default:
_UpdatePlayerNumber();
break;
} }
if (!processed)
_UpdatePlayerNumber();
if (_SelectingKeyboardPlayerNr > 0 && _SelectingKeyboardPlayerNr <= CConfig.NumPlayer) if (_SelectingKeyboardPlayerNr > 0 && _SelectingKeyboardPlayerNr <= CConfig.NumPlayer)
{ {
_SelectingKeyboardActive = true; _SelectingKeyboardActive = true;
NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr); _NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
} }
} }
@@ -415,23 +342,20 @@ namespace Vocaluxe.Screens
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
//Check if LeftButton is hold and Select-Mode inactive //Check if LeftButton is hold and Select-Mode inactive
if (mouseEvent.LBH && !_SelectingMouseActive) if (mouseEvent.LBH && _SelectedPlayerNr < 0)
{ {
//Save mouse-coords //Save mouse-coords
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y; _OldMouseY = mouseEvent.Y;
//Check if mouse if over tile //Check if mouse if over tile
if (NameSelections[_NameSelection].IsOverTile(mouseEvent)) if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{ {
//Get player-number of tile //Get player-number of tile
_SelectedPlayerNr = NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
if (_SelectedPlayerNr != -1) if (_SelectedPlayerNr != -1)
{ {
//Activate mouse-selecting
_SelectingMouseActive = true;
//Update of Drag/Drop-Texture //Update of Drag/Drop-Texture
CStatic selectedPlayer = NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent); CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
_ChooseAvatarStatic.Visible = true; _ChooseAvatarStatic.Visible = true;
_ChooseAvatarStatic.Rect = selectedPlayer.Rect; _ChooseAvatarStatic.Rect = selectedPlayer.Rect;
_ChooseAvatarStatic.Rect.Z = CSettings.ZNear; _ChooseAvatarStatic.Rect.Z = CSettings.ZNear;
@@ -442,7 +366,7 @@ namespace Vocaluxe.Screens
} }
//Check if LeftButton is hold and Select-Mode active //Check if LeftButton is hold and Select-Mode active
if (mouseEvent.LBH && _SelectingMouseActive) if (mouseEvent.LBH && _SelectedPlayerNr >= 0)
{ {
//Update coords for Drag/Drop-Texture //Update coords for Drag/Drop-Texture
_ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX; _ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX;
@@ -450,67 +374,47 @@ namespace Vocaluxe.Screens
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y; _OldMouseY = mouseEvent.Y;
} }
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "ReplacedStr:::0:::" of Avatar // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
else if (_SelectingMouseActive) else if (_SelectedPlayerNr >= 0)
{
//Check if really a player was selected
if (_SelectedPlayerNr != -1)
{ {
//Foreach Drop-Area //Foreach Drop-Area
for (int i = 0; i < _StaticPlayer.Length; i++) for (int i = 0; i < _StaticPlayer.Length; i++)
{ {
//Check first, if area is "ReplacedStr:::1:::" //Check first, if area is "Active"
if (Statics[_StaticPlayer[i]].Visible) if (!_Statics[_StaticPlayer[i]].Visible)
{ continue;
//Check if Mouse is in area //Check if Mouse is in area
if (CHelper.IsInBounds(Statics[_StaticPlayer[i]].Rect, mouseEvent)) if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent))
{ {
//Update Game-infos with new player //Update Game-infos with new player
CGame.Player[i].Name = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; CGame.Players[i].ProfileID = _SelectedPlayerNr;
CGame.Player[i].Difficulty = CProfiles.Profiles[_SelectedPlayerNr].Difficulty;
CGame.Player[i].ProfileID = _SelectedPlayerNr;
//Update config for default players. //Update config for default players.
CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.SaveConfig(); CConfig.SaveConfig();
//Update texture and name //Update texture and name
Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture; _Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture;
Texts[_TextPlayer[i]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; _Texts[_TextPlayer[i]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning //Update profile-warning
_CheckPlayers(); _CheckPlayers();
//Update Tiles-List //Update Tiles-List
NameSelections[_NameSelection].UpdateList(); _NameSelections[_NameSelection].UpdateList();
}
} }
} }
_SelectedPlayerNr = -1; _SelectedPlayerNr = -1;
}
//Reset variables //Reset variables
_SelectingMouseActive = false;
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
} }
if (mouseEvent.LB && IsMouseOver(mouseEvent)) {} if (mouseEvent.LB && _IsMouseOver(mouseEvent))
if (mouseEvent.LB && IsMouseOver(mouseEvent))
{ {
bool processed = false; if (_Buttons[_ButtonBack].Selected)
if (!processed && Buttons[_ButtonBack].Selected)
{
processed = true;
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
} else if (_Buttons[_ButtonStart].Selected)
if (!processed && Buttons[_ButtonStart].Selected)
{
processed = true;
_StartSong(); _StartSong();
} else
if (!processed)
_UpdatePlayerNumber(); _UpdatePlayerNumber();
//Update Tiles-List //Update Tiles-List
NameSelections[_NameSelection].UpdateList(); _NameSelections[_NameSelection].UpdateList();
} }
if (mouseEvent.RB) if (mouseEvent.RB)
@@ -519,21 +423,19 @@ namespace Vocaluxe.Screens
//Remove profile-selection //Remove profile-selection
for (int i = 0; i < CConfig.NumPlayer; i++) for (int i = 0; i < CConfig.NumPlayer; i++)
{ {
if (CHelper.IsInBounds(Statics[_StaticPlayer[i]].Rect, mouseEvent)) if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent))
{ {
CGame.Player[i].ProfileID = -1; CGame.Players[i].ProfileID = -1;
CGame.Player[i].Name = String.Empty;
CGame.Player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
//Update config for default players. //Update config for default players.
CConfig.Players[i] = String.Empty; CConfig.Players[i] = String.Empty;
CConfig.SaveConfig(); CConfig.SaveConfig();
//Update texture and name //Update texture and name
Statics[_StaticPlayerAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i]; _Statics[_StaticPlayerAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i];
Texts[_TextPlayer[i]].Text = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + (i + 1).ToString(); _Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(-1, i + 1);
//Update profile-warning //Update profile-warning
_CheckPlayers(); _CheckPlayers();
//Update Tiles-List //Update Tiles-List
NameSelections[_NameSelection].UpdateList(); _NameSelections[_NameSelection].UpdateList();
exit = false; exit = false;
} }
} }
@@ -544,10 +446,10 @@ namespace Vocaluxe.Screens
//Check mouse-wheel for scrolling //Check mouse-wheel for scrolling
if (mouseEvent.Wheel != 0) if (mouseEvent.Wheel != 0)
{ {
if (CHelper.IsInBounds(NameSelections[_NameSelection].Rect, mouseEvent)) if (CHelper.IsInBounds(_NameSelections[_NameSelection].Rect, mouseEvent))
{ {
int offset = NameSelections[_NameSelection].Offset + mouseEvent.Wheel; int offset = _NameSelections[_NameSelection].Offset + mouseEvent.Wheel;
NameSelections[_NameSelection].UpdateList(offset); _NameSelections[_NameSelection].UpdateList(offset);
} }
} }
return true; return true;
@@ -558,7 +460,7 @@ namespace Vocaluxe.Screens
for (int i = 1; i <= CGame.NumPlayer; i++) for (int i = 1; i <= CGame.NumPlayer; i++)
{ {
CSound.AnalyzeBuffer(i - 1); CSound.AnalyzeBuffer(i - 1);
Equalizers["EqualizerPlayer" + i].Update(CSound.ToneWeigth(i - 1)); _Equalizers["EqualizerPlayer" + i].Update(CSound.ToneWeigth(i - 1));
} }
return true; return true;
} }
@@ -568,7 +470,7 @@ namespace Vocaluxe.Screens
base.OnShow(); base.OnShow();
CSound.RecordStart(); CSound.RecordStart();
NameSelections[_NameSelection].Init(); _NameSelections[_NameSelection].Init();
_UpdateSlides(); _UpdateSlides();
_UpdatePlayerNumber(); _UpdatePlayerNumber();
@@ -577,34 +479,23 @@ namespace Vocaluxe.Screens
for (int i = 0; i < CSettings.MaxNumPlayer; i++) for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{ {
//Update texture and name _Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.IsProfileIDValid(CGame.Players[i].ProfileID) ?
if (CConfig.Players[i].Length > 0) CProfiles.Profiles[CGame.Players[i].ProfileID].Avatar.Texture :
{ _OriginalPlayerAvatarTextures[i];
if (CGame.Player[i].ProfileID > -1 && CProfiles.NumProfiles > CGame.Player[i].ProfileID) _Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID, i + 1);
{
Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.Profiles[CGame.Player[i].ProfileID].Avatar.Texture;
Texts[_TextPlayer[i]].Text = CProfiles.Profiles[CGame.Player[i].ProfileID].PlayerName;
}
}
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
{ {
SelectSlides[_SelectSlideDuetPlayer[i]].Clear(); _SelectSlides[_SelectSlideDuetPlayer[i]].Clear();
if (i + 1 <= CGame.NumPlayer) _SelectSlides[_SelectSlideDuetPlayer[i]].Visible = i + 1 <= CGame.NumPlayer;
SelectSlides[_SelectSlideDuetPlayer[i]].Visible = true; _SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart1);
else _SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart2);
SelectSlides[_SelectSlideDuetPlayer[i]].Visible = false; _SelectSlides[_SelectSlideDuetPlayer[i]].Selection = i % 2;
SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart1);
SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart2);
if ((i + 1) % 2 == 0)
SelectSlides[_SelectSlideDuetPlayer[i]].Selection = 1;
else
SelectSlides[_SelectSlideDuetPlayer[i]].Selection = 0;
} }
else else
SelectSlides[_SelectSlideDuetPlayer[i]].Visible = false; _SelectSlides[_SelectSlideDuetPlayer[i]].Visible = false;
} }
SetInteractionToButton(Buttons[_ButtonStart]); _SetInteractionToButton(_Buttons[_ButtonStart]);
} }
public override void OnClose() public override void OnClose()
@@ -620,7 +511,7 @@ namespace Vocaluxe.Screens
if (_ChooseAvatarStatic.Visible) if (_ChooseAvatarStatic.Visible)
_ChooseAvatarStatic.Draw(); _ChooseAvatarStatic.Draw();
for (int i = 1; i <= CGame.NumPlayer; i++) for (int i = 1; i <= CGame.NumPlayer; i++)
Equalizers["EqualizerPlayer" + i].Draw(); _Equalizers["EqualizerPlayer" + i].Draw();
return true; return true;
} }
@@ -628,20 +519,8 @@ namespace Vocaluxe.Screens
{ {
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
{ {
if (CGame.Player[i].ProfileID < 0)
{
CGame.Player[i].Name = "Player " + (i + 1).ToString();
CGame.Player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
CGame.Player[i].ProfileID = -1;
}
else
{
//Just a work-around for not crashing the game
if (CGame.Player[i].Name == null)
CGame.Player[i].Name = "";
}
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
CGame.Player[i].LineNr = SelectSlides[_SelectSlideDuetPlayer[i]].Selection; CGame.Players[i].LineNr = _SelectSlides[_SelectSlideDuetPlayer[i]].Selection;
} }
CGraphics.FadeTo(EScreens.ScreenSing); CGraphics.FadeTo(EScreens.ScreenSing);
@@ -649,36 +528,36 @@ namespace Vocaluxe.Screens
private void _UpdateSlides() private void _UpdateSlides()
{ {
SelectSlides[_SelectSlidePlayerNumber].Clear(); _SelectSlides[_SelectSlidePlayerNumber].Clear();
for (int i = 1; i <= CSettings.MaxNumPlayer; i++) for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
SelectSlides[_SelectSlidePlayerNumber].AddValue(CLanguage.Translate("TR_SCREENNAMES_" + i + "PLAYER")); _SelectSlides[_SelectSlidePlayerNumber].AddValue(CLanguage.Translate("TR_SCREENNAMES_" + i + "PLAYER"));
SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 1; _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 1;
} }
private void _UpdatePlayerNumber() private void _UpdatePlayerNumber()
{ {
CConfig.NumPlayer = SelectSlides[_SelectSlidePlayerNumber].Selection + 1; CConfig.NumPlayer = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1;
CGame.NumPlayer = SelectSlides[_SelectSlidePlayerNumber].Selection + 1; CGame.NumPlayer = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1;
for (int i = 1; i <= CSettings.MaxNumPlayer; i++) for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
{ {
if (i <= CGame.NumPlayer) if (i <= CGame.NumPlayer)
{ {
Statics["StaticPlayer" + i].Visible = true; _Statics["StaticPlayer" + i].Visible = true;
Statics["StaticPlayerAvatar" + i].Visible = true; _Statics["StaticPlayerAvatar" + i].Visible = true;
Texts["TextPlayer" + i].Visible = true; _Texts["TextPlayer" + i].Visible = true;
if (Texts["TextPlayer" + i].Text.Length == 0) if (_Texts["TextPlayer" + i].Text == "")
Texts["TextPlayer" + i].Text = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + i.ToString(); _Texts["TextPlayer" + i].Text = CProfiles.GetPlayerName(-1, i);
Equalizers["EqualizerPlayer" + i].Visible = true; _Equalizers["EqualizerPlayer" + i].Visible = true;
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
SelectSlides["SelectSlideDuetPlayer" + i].Visible = true; _SelectSlides["SelectSlideDuetPlayer" + i].Visible = true;
} }
else else
{ {
Statics["StaticPlayer" + i].Visible = false; _Statics["StaticPlayer" + i].Visible = false;
Statics["StaticPlayerAvatar" + i].Visible = false; _Statics["StaticPlayerAvatar" + i].Visible = false;
Texts["TextPlayer" + i].Visible = false; _Texts["TextPlayer" + i].Visible = false;
Equalizers["EqualizerPlayer" + i].Visible = false; _Equalizers["EqualizerPlayer" + i].Visible = false;
SelectSlides["SelectSlideDuetPlayer" + i].Visible = false; _SelectSlides["SelectSlideDuetPlayer" + i].Visible = false;
} }
} }
CConfig.SaveConfig(); CConfig.SaveConfig();
@@ -696,8 +575,8 @@ namespace Vocaluxe.Screens
} }
if (playerWithoutMicro.Count > 0) if (playerWithoutMicro.Count > 0)
{ {
Statics[_StaticWarningMics].Visible = true; _Statics[_StaticWarningMics].Visible = true;
Texts[_TextWarningMics].Visible = true; _Texts[_TextWarningMics].Visible = true;
if (playerWithoutMicro.Count > 1) if (playerWithoutMicro.Count > 1)
{ {
@@ -707,20 +586,20 @@ namespace Vocaluxe.Screens
if (playerWithoutMicro.Count - 1 == i) if (playerWithoutMicro.Count - 1 == i)
playerNums += playerWithoutMicro[i].ToString(); playerNums += playerWithoutMicro[i].ToString();
else if (playerWithoutMicro.Count - 2 == i) else if (playerWithoutMicro.Count - 2 == i)
playerNums += playerWithoutMicro[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " "; playerNums += playerWithoutMicro[i] + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
else else
playerNums += playerWithoutMicro[i].ToString() + ", "; playerNums += playerWithoutMicro[i] + ", ";
} }
Texts[_TextWarningMics].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_PL").Replace("%v", playerNums); _Texts[_TextWarningMics].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_PL").Replace("%v", playerNums);
} }
else else
Texts[_TextWarningMics].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_SG").Replace("%v", playerWithoutMicro[0].ToString()); _Texts[_TextWarningMics].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_SG").Replace("%v", playerWithoutMicro[0].ToString());
} }
else else
{ {
Statics[_StaticWarningMics].Visible = false; _Statics[_StaticWarningMics].Visible = false;
Texts[_TextWarningMics].Visible = false; _Texts[_TextWarningMics].Visible = false;
} }
} }
@@ -729,14 +608,14 @@ namespace Vocaluxe.Screens
List<int> playerWithoutProfile = new List<int>(); List<int> playerWithoutProfile = new List<int>();
for (int player = 0; player < CConfig.NumPlayer; player++) for (int player = 0; player < CConfig.NumPlayer; player++)
{ {
if (CGame.Player[player].ProfileID < 0) if (CGame.Players[player].ProfileID < 0)
playerWithoutProfile.Add(player + 1); playerWithoutProfile.Add(player + 1);
} }
if (playerWithoutProfile.Count > 0) if (playerWithoutProfile.Count > 0)
{ {
Statics[_StaticWarningProfiles].Visible = true; _Statics[_StaticWarningProfiles].Visible = true;
Texts[_TextWarningProfiles].Visible = true; _Texts[_TextWarningProfiles].Visible = true;
if (playerWithoutProfile.Count > 1) if (playerWithoutProfile.Count > 1)
{ {
@@ -746,20 +625,20 @@ namespace Vocaluxe.Screens
if (playerWithoutProfile.Count - 1 == i) if (playerWithoutProfile.Count - 1 == i)
playerNums += playerWithoutProfile[i].ToString(); playerNums += playerWithoutProfile[i].ToString();
else if (playerWithoutProfile.Count - 2 == i) else if (playerWithoutProfile.Count - 2 == i)
playerNums += playerWithoutProfile[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " "; playerNums += playerWithoutProfile[i] + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
else else
playerNums += playerWithoutProfile[i].ToString() + ", "; playerNums += playerWithoutProfile[i] + ", ";
} }
Texts[_TextWarningProfiles].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_PROFILES_PL").Replace("%v", playerNums); _Texts[_TextWarningProfiles].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_PROFILES_PL").Replace("%v", playerNums);
} }
else else
Texts[_TextWarningProfiles].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_PROFILES_SG").Replace("%v", playerWithoutProfile[0].ToString()); _Texts[_TextWarningProfiles].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_PROFILES_SG").Replace("%v", playerWithoutProfile[0].ToString());
} }
else else
{ {
Statics[_StaticWarningProfiles].Visible = false; _Statics[_StaticWarningProfiles].Visible = false;
Texts[_TextWarningProfiles].Visible = false; _Texts[_TextWarningProfiles].Visible = false;
} }
} }
} }
+33 -14
View File
@@ -1,4 +1,23 @@
using System.Windows.Forms; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -46,22 +65,22 @@ namespace Vocaluxe.Screens
break; break;
case Keys.Enter: case Keys.Enter:
if (Buttons[_ButtonOptionsGame].Selected) if (_Buttons[_ButtonOptionsGame].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsGame); CGraphics.FadeTo(EScreens.ScreenOptionsGame);
if (Buttons[_ButtonOptionsSound].Selected) if (_Buttons[_ButtonOptionsSound].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsSound); CGraphics.FadeTo(EScreens.ScreenOptionsSound);
if (Buttons[_ButtonOptionsRecord].Selected) if (_Buttons[_ButtonOptionsRecord].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsRecord); CGraphics.FadeTo(EScreens.ScreenOptionsRecord);
if (Buttons[_ButtonOptionsVideo].Selected) if (_Buttons[_ButtonOptionsVideo].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsVideo); CGraphics.FadeTo(EScreens.ScreenOptionsVideo);
if (Buttons[_ButtonOptionsLyrics].Selected) if (_Buttons[_ButtonOptionsLyrics].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsLyrics); CGraphics.FadeTo(EScreens.ScreenOptionsLyrics);
if (Buttons[_ButtonOptionsTheme].Selected) if (_Buttons[_ButtonOptionsTheme].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsTheme); CGraphics.FadeTo(EScreens.ScreenOptionsTheme);
break; break;
@@ -74,24 +93,24 @@ namespace Vocaluxe.Screens
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (Buttons[_ButtonOptionsGame].Selected) if (_Buttons[_ButtonOptionsGame].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsGame); CGraphics.FadeTo(EScreens.ScreenOptionsGame);
if (Buttons[_ButtonOptionsSound].Selected) if (_Buttons[_ButtonOptionsSound].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsSound); CGraphics.FadeTo(EScreens.ScreenOptionsSound);
if (Buttons[_ButtonOptionsRecord].Selected) if (_Buttons[_ButtonOptionsRecord].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsRecord); CGraphics.FadeTo(EScreens.ScreenOptionsRecord);
if (Buttons[_ButtonOptionsVideo].Selected) if (_Buttons[_ButtonOptionsVideo].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsVideo); CGraphics.FadeTo(EScreens.ScreenOptionsVideo);
if (Buttons[_ButtonOptionsLyrics].Selected) if (_Buttons[_ButtonOptionsLyrics].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsLyrics); CGraphics.FadeTo(EScreens.ScreenOptionsLyrics);
if (Buttons[_ButtonOptionsTheme].Selected) if (_Buttons[_ButtonOptionsTheme].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsTheme); CGraphics.FadeTo(EScreens.ScreenOptionsTheme);
} }
+36 -17
View File
@@ -1,4 +1,23 @@
using System.Windows.Forms; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -33,14 +52,14 @@ namespace Vocaluxe.Screens
{ {
base.LoadTheme(xmlPath); base.LoadTheme(xmlPath);
SelectSlides[_SelectSlideLanguage].AddValues(CLanguage.GetLanguageNames()); _SelectSlides[_SelectSlideLanguage].AddValues(CLanguage.GetLanguageNames());
SelectSlides[_SelectSlideLanguage].Selection = CLanguage.LanguageId; _SelectSlides[_SelectSlideLanguage].Selection = CLanguage.LanguageId;
SelectSlides[_SelectSlideDebugLevel].SetValues<EDebugLevel>((int)CConfig.DebugLevel); _SelectSlides[_SelectSlideDebugLevel].SetValues<EDebugLevel>((int)CConfig.DebugLevel);
SelectSlides[_SelectSlideSongMenu].SetValues<ESongMenu>((int)CConfig.SongMenu); _SelectSlides[_SelectSlideSongMenu].SetValues<ESongMenu>((int)CConfig.SongMenu);
SelectSlides[_SelectSlideSongSorting].SetValues<ESongSorting>((int)CConfig.SongSorting); _SelectSlides[_SelectSlideSongSorting].SetValues<ESongSorting>((int)CConfig.SongSorting);
SelectSlides[_SelectSlideTabs].SetValues<EOffOn>((int)CConfig.Tabs); _SelectSlides[_SelectSlideTabs].SetValues<EOffOn>((int)CConfig.Tabs);
SelectSlides[_SelectSlideTimerMode].SetValues<ETimerMode>((int)CConfig.TimerMode); _SelectSlides[_SelectSlideTimerMode].SetValues<ETimerMode>((int)CConfig.TimerMode);
} }
public override bool HandleInput(SKeyEvent keyEvent) public override bool HandleInput(SKeyEvent keyEvent)
@@ -63,7 +82,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.Enter: case Keys.Enter:
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
{ {
_SaveConfig(); _SaveConfig();
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
@@ -92,10 +111,10 @@ namespace Vocaluxe.Screens
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
_SaveConfig(); _SaveConfig();
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
return true; return true;
@@ -114,13 +133,13 @@ namespace Vocaluxe.Screens
private void _SaveConfig() private void _SaveConfig()
{ {
CLanguage.LanguageId = SelectSlides[_SelectSlideLanguage].Selection; CLanguage.LanguageId = _SelectSlides[_SelectSlideLanguage].Selection;
CConfig.Language = CLanguage.GetLanguageName(CLanguage.LanguageId); CConfig.Language = CLanguage.GetLanguageName(CLanguage.LanguageId);
CConfig.DebugLevel = (EDebugLevel)SelectSlides[_SelectSlideDebugLevel].Selection; CConfig.DebugLevel = (EDebugLevel)_SelectSlides[_SelectSlideDebugLevel].Selection;
CConfig.SongMenu = (ESongMenu)SelectSlides[_SelectSlideSongMenu].Selection; CConfig.SongMenu = (ESongMenu)_SelectSlides[_SelectSlideSongMenu].Selection;
CConfig.SongSorting = (ESongSorting)SelectSlides[_SelectSlideSongSorting].Selection; CConfig.SongSorting = (ESongSorting)_SelectSlides[_SelectSlideSongSorting].Selection;
CConfig.Tabs = (EOffOn)SelectSlides[_SelectSlideTabs].Selection; CConfig.Tabs = (EOffOn)_SelectSlides[_SelectSlideTabs].Selection;
CConfig.TimerMode = (ETimerMode)SelectSlides[_SelectSlideTimerMode].Selection; CConfig.TimerMode = (ETimerMode)_SelectSlides[_SelectSlideTimerMode].Selection;
CConfig.SaveConfig(); CConfig.SaveConfig();
+27 -8
View File
@@ -1,4 +1,23 @@
using System.Windows.Forms; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -28,8 +47,8 @@ namespace Vocaluxe.Screens
public override void LoadTheme(string xmlPath) public override void LoadTheme(string xmlPath)
{ {
base.LoadTheme(xmlPath); base.LoadTheme(xmlPath);
SelectSlides[_SelectSlideLyricStyle].SetValues<ELyricStyle>((int)CConfig.LyricStyle); _SelectSlides[_SelectSlideLyricStyle].SetValues<ELyricStyle>((int)CConfig.LyricStyle);
SelectSlides[_SelectSlideLyricsOnTop].SetValues<EOffOn>((int)CConfig.LyricsOnTop); _SelectSlides[_SelectSlideLyricsOnTop].SetValues<EOffOn>((int)CConfig.LyricsOnTop);
} }
public override bool HandleInput(SKeyEvent keyEvent) public override bool HandleInput(SKeyEvent keyEvent)
@@ -53,7 +72,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.Enter: case Keys.Enter:
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
{ {
_SaveConfig(); _SaveConfig();
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
@@ -81,10 +100,10 @@ namespace Vocaluxe.Screens
_SaveConfig(); _SaveConfig();
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
_SaveConfig(); _SaveConfig();
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
return true; return true;
@@ -103,8 +122,8 @@ namespace Vocaluxe.Screens
private void _SaveConfig() private void _SaveConfig()
{ {
CConfig.LyricsOnTop = (EOffOn)SelectSlides[_SelectSlideLyricsOnTop].Selection; CConfig.LyricsOnTop = (EOffOn)_SelectSlides[_SelectSlideLyricsOnTop].Selection;
CConfig.LyricStyle = (ELyricStyle)SelectSlides[_SelectSlideLyricStyle].Selection; CConfig.LyricStyle = (ELyricStyle)_SelectSlides[_SelectSlideLyricStyle].Selection;
CConfig.SaveConfig(); CConfig.SaveConfig();
} }
} }
+100 -82
View File
@@ -1,4 +1,23 @@
using System.Collections.Generic; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
@@ -56,8 +75,7 @@ namespace Vocaluxe.Screens
{ {
base.Init(); base.Init();
List<string> values = new List<string>(); List<string> values = new List<string> {_StaticWarning};
values.Add(_StaticWarning);
values.AddRange(_StaticEnergyChannel); values.AddRange(_StaticEnergyChannel);
_ThemeStatics = values.ToArray(); _ThemeStatics = values.ToArray();
@@ -75,31 +93,31 @@ namespace Vocaluxe.Screens
if (max > 7) if (max > 7)
max = 7; max = 7;
SelectSlides[_SelectSlideRecordChannel1].NumVisible = max; _SelectSlides[_SelectSlideRecordChannel1].NumVisible = max;
SelectSlides[_SelectSlideRecordChannel2].NumVisible = max; _SelectSlides[_SelectSlideRecordChannel2].NumVisible = max;
SelectSlides[_SelectSlideRecordChannel1].AddValue(CLanguage.Translate("TR_CONFIG_OFF")); _SelectSlides[_SelectSlideRecordChannel1].AddValue(CLanguage.Translate("TR_CONFIG_OFF"));
SelectSlides[_SelectSlideRecordChannel2].AddValue(CLanguage.Translate("TR_CONFIG_OFF")); _SelectSlides[_SelectSlideRecordChannel2].AddValue(CLanguage.Translate("TR_CONFIG_OFF"));
for (int i = 1; i <= CSettings.MaxNumPlayer; i++) for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
{ {
SelectSlides[_SelectSlideRecordChannel1].AddValue(i.ToString()); _SelectSlides[_SelectSlideRecordChannel1].AddValue(i.ToString());
SelectSlides[_SelectSlideRecordChannel2].AddValue(i.ToString()); _SelectSlides[_SelectSlideRecordChannel2].AddValue(i.ToString());
} }
for (int i = 0; i < 26; i++) for (int i = 0; i < 26; i++)
SelectSlides[_SelectSlideDelay].AddValue((i * 20).ToString() + " ms"); _SelectSlides[_SelectSlideDelay].AddValue((i * 20) + " ms");
_ChannelEnergy = new float[_StaticEnergyChannel.Length]; _ChannelEnergy = new float[_StaticEnergyChannel.Length];
for (int i = 0; i < _ChannelEnergy.Length; i++) for (int i = 0; i < _ChannelEnergy.Length; i++)
{ {
Statics[_StaticEnergyChannel[i]].Visible = false; _Statics[_StaticEnergyChannel[i]].Visible = false;
_ChannelEnergy[i] = 0f; _ChannelEnergy[i] = 0f;
} }
Equalizers[_EqualizerChannel1].ScreenHandles = true; _Equalizers[_EqualizerChannel1].ScreenHandles = true;
Equalizers[_EqualizerChannel2].ScreenHandles = true; _Equalizers[_EqualizerChannel2].ScreenHandles = true;
} }
public override bool HandleInput(SKeyEvent keyEvent) public override bool HandleInput(SKeyEvent keyEvent)
@@ -123,13 +141,13 @@ namespace Vocaluxe.Screens
break; break;
case Keys.Enter: case Keys.Enter:
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
{ {
_SaveMicConfig(); _SaveMicConfig();
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
if (Buttons[_ButtonDelayTest].Selected) if (_Buttons[_ButtonDelayTest].Selected)
_TestDelay(); _TestDelay();
break; break;
@@ -139,32 +157,32 @@ namespace Vocaluxe.Screens
break; break;
case Keys.Left: case Keys.Left:
if (SelectSlides[_SelectSlideRecordDevices].Selected) if (_SelectSlides[_SelectSlideRecordDevices].Selected)
_OnDeviceEvent(); _OnDeviceEvent();
if (SelectSlides[_SelectSlideRecordInputs].Selected) if (_SelectSlides[_SelectSlideRecordInputs].Selected)
_OnInputEvent(); _OnInputEvent();
if (SelectSlides[_SelectSlideRecordChannel1].Selected || if (_SelectSlides[_SelectSlideRecordChannel1].Selected ||
SelectSlides[_SelectSlideRecordChannel2].Selected) _SelectSlides[_SelectSlideRecordChannel2].Selected)
_SetMicConfig(); _SetMicConfig();
if (SelectSlides[_SelectSlideDelay].Selected) if (_SelectSlides[_SelectSlideDelay].Selected)
_SaveDelayConfig(); _SaveDelayConfig();
break; break;
case Keys.Right: case Keys.Right:
if (SelectSlides[_SelectSlideRecordDevices].Selected) if (_SelectSlides[_SelectSlideRecordDevices].Selected)
_OnDeviceEvent(); _OnDeviceEvent();
if (SelectSlides[_SelectSlideRecordInputs].Selected) if (_SelectSlides[_SelectSlideRecordInputs].Selected)
_OnInputEvent(); _OnInputEvent();
if (SelectSlides[_SelectSlideRecordChannel1].Selected || if (_SelectSlides[_SelectSlideRecordChannel1].Selected ||
SelectSlides[_SelectSlideRecordChannel2].Selected) _SelectSlides[_SelectSlideRecordChannel2].Selected)
_SetMicConfig(); _SetMicConfig();
if (SelectSlides[_SelectSlideDelay].Selected) if (_SelectSlides[_SelectSlideDelay].Selected)
_SaveDelayConfig(); _SaveDelayConfig();
break; break;
} }
@@ -182,28 +200,28 @@ namespace Vocaluxe.Screens
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (SelectSlides[_SelectSlideRecordDevices].Selected) if (_SelectSlides[_SelectSlideRecordDevices].Selected)
_OnDeviceEvent(); _OnDeviceEvent();
if (SelectSlides[_SelectSlideRecordInputs].Selected) if (_SelectSlides[_SelectSlideRecordInputs].Selected)
_OnInputEvent(); _OnInputEvent();
if (SelectSlides[_SelectSlideRecordChannel1].Selected || if (_SelectSlides[_SelectSlideRecordChannel1].Selected ||
SelectSlides[_SelectSlideRecordChannel2].Selected) _SelectSlides[_SelectSlideRecordChannel2].Selected)
_SetMicConfig(); _SetMicConfig();
if (SelectSlides[_SelectSlideDelay].Selected) if (_SelectSlides[_SelectSlideDelay].Selected)
_SaveDelayConfig(); _SaveDelayConfig();
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
{ {
_SaveMicConfig(); _SaveMicConfig();
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
if (Buttons[_ButtonDelayTest].Selected) if (_Buttons[_ButtonDelayTest].Selected)
_TestDelay(); _TestDelay();
} }
return true; return true;
@@ -230,10 +248,10 @@ namespace Vocaluxe.Screens
{ {
int player = 0; int player = 0;
if (i == 0) if (i == 0)
player = SelectSlides[_SelectSlideRecordChannel1].Selection; player = _SelectSlides[_SelectSlideRecordChannel1].Selection;
if (i == 1) if (i == 1)
player = SelectSlides[_SelectSlideRecordChannel2].Selection; player = _SelectSlides[_SelectSlideRecordChannel2].Selection;
if (_DelayTest[i].Timer.ElapsedMilliseconds > _MaxDelayTime * 1000f || player == 0) if (_DelayTest[i].Timer.ElapsedMilliseconds > _MaxDelayTime * 1000f || player == 0)
{ {
@@ -250,39 +268,39 @@ namespace Vocaluxe.Screens
} }
} }
} }
Texts[_TextDelayChannel1].Text = _DelayTest[0].Delay.ToString("000") + " ms"; _Texts[_TextDelayChannel1].Text = _DelayTest[0].Delay.ToString("000") + " ms";
Texts[_TextDelayChannel2].Text = _DelayTest[1].Delay.ToString("000") + " ms"; _Texts[_TextDelayChannel2].Text = _DelayTest[1].Delay.ToString("000") + " ms";
} }
if (_CheckMicConfig()) if (_CheckMicConfig())
{ {
_ChannelEnergy[0] = 0f; _ChannelEnergy[0] = 0f;
int player = SelectSlides[_SelectSlideRecordChannel1].Selection; int player = _SelectSlides[_SelectSlideRecordChannel1].Selection;
if (player > 0) if (player > 0)
{ {
_ChannelEnergy[0] = CSound.RecordGetMaxVolume(player - 1); _ChannelEnergy[0] = CSound.RecordGetMaxVolume(player - 1);
Equalizers[_EqualizerChannel1].Update(CSound.ToneWeigth(player - 1)); _Equalizers[_EqualizerChannel1].Update(CSound.ToneWeigth(player - 1));
} }
else else
Equalizers[_EqualizerChannel1].Reset(); _Equalizers[_EqualizerChannel1].Reset();
_ChannelEnergy[1] = 0f; _ChannelEnergy[1] = 0f;
player = SelectSlides[_SelectSlideRecordChannel2].Selection; player = _SelectSlides[_SelectSlideRecordChannel2].Selection;
if (player > 0) if (player > 0)
{ {
_ChannelEnergy[1] = CSound.RecordGetMaxVolume(player - 1); _ChannelEnergy[1] = CSound.RecordGetMaxVolume(player - 1);
Equalizers[_EqualizerChannel2].Update(CSound.ToneWeigth(player - 1)); _Equalizers[_EqualizerChannel2].Update(CSound.ToneWeigth(player - 1));
} }
else else
Equalizers[_EqualizerChannel2].Reset(); _Equalizers[_EqualizerChannel2].Reset();
} }
else else
{ {
for (int i = 0; i < _ChannelEnergy.Length; i++) for (int i = 0; i < _ChannelEnergy.Length; i++)
_ChannelEnergy[i] = 0f; _ChannelEnergy[i] = 0f;
Equalizers[_EqualizerChannel1].Reset(); _Equalizers[_EqualizerChannel1].Reset();
Equalizers[_EqualizerChannel2].Reset(); _Equalizers[_EqualizerChannel2].Reset();
} }
return true; return true;
@@ -292,8 +310,8 @@ namespace Vocaluxe.Screens
{ {
base.OnShow(); base.OnShow();
SelectSlides[_SelectSlideRecordDevices].Clear(); _SelectSlides[_SelectSlideRecordDevices].Clear();
SelectSlides[_SelectSlideRecordInputs].Clear(); _SelectSlides[_SelectSlideRecordInputs].Clear();
for (int i = 0; i < _ChannelEnergy.Length; i++) for (int i = 0; i < _ChannelEnergy.Length; i++)
_ChannelEnergy[i] = 0f; _ChannelEnergy[i] = 0f;
@@ -309,20 +327,20 @@ namespace Vocaluxe.Screens
_GetFirstConfiguredRecordDevice(ref _DeviceNr, ref _InputNr); _GetFirstConfiguredRecordDevice(ref _DeviceNr, ref _InputNr);
for (int dev = 0; dev < _Devices.Length; dev++) for (int dev = 0; dev < _Devices.Length; dev++)
SelectSlides[_SelectSlideRecordDevices].AddValue(_Devices[dev].Name); _SelectSlides[_SelectSlideRecordDevices].AddValue(_Devices[dev].Name);
SelectSlides[_SelectSlideRecordDevices].Selection = _DeviceNr; _SelectSlides[_SelectSlideRecordDevices].Selection = _DeviceNr;
for (int inp = 0; inp < _Devices[0].Inputs.Count; inp++) for (int inp = 0; inp < _Devices[0].Inputs.Count; inp++)
SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[0].Inputs[inp].Name); _SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[0].Inputs[inp].Name);
SelectSlides[_SelectSlideRecordInputs].Selection = _InputNr; _SelectSlides[_SelectSlideRecordInputs].Selection = _InputNr;
_UpdateChannels(); _UpdateChannels();
} }
SelectSlides[_SelectSlideRecordChannel1].Visible = _Devices != null; _SelectSlides[_SelectSlideRecordChannel1].Visible = _Devices != null;
SelectSlides[_SelectSlideRecordChannel2].Visible = _Devices != null; _SelectSlides[_SelectSlideRecordChannel2].Visible = _Devices != null;
Statics[_StaticWarning].Visible = false; _Statics[_StaticWarning].Visible = false;
Texts[_TextWarning].Visible = false; _Texts[_TextWarning].Visible = false;
_DelayTest = null; _DelayTest = null;
if (_Devices != null) if (_Devices != null)
@@ -335,7 +353,7 @@ namespace Vocaluxe.Screens
} }
} }
SelectSlides[_SelectSlideDelay].Selection = CConfig.MicDelay / 20; _SelectSlides[_SelectSlideDelay].Selection = CConfig.MicDelay / 20;
_DelayTestRunning = false; _DelayTestRunning = false;
_DelaySound = -1; _DelaySound = -1;
@@ -349,38 +367,38 @@ namespace Vocaluxe.Screens
public override bool Draw() public override bool Draw()
{ {
DrawBG(); _DrawBG();
if (!_CheckMicConfig()) if (!_CheckMicConfig())
{ {
Statics[_StaticWarning].Visible = true; _Statics[_StaticWarning].Visible = true;
Texts[_TextWarning].Visible = true; _Texts[_TextWarning].Visible = true;
} }
else else
{ {
Statics[_StaticWarning].Visible = false; _Statics[_StaticWarning].Visible = false;
Texts[_TextWarning].Visible = false; _Texts[_TextWarning].Visible = false;
} }
for (int i = 0; i < _StaticEnergyChannel.Length; i++) for (int i = 0; i < _StaticEnergyChannel.Length; i++)
{ {
if (_ChannelEnergy[i] > 0f) if (_ChannelEnergy[i] > 0f)
{ {
SRectF rect = new SRectF(Statics[_StaticEnergyChannel[i]].Rect.X, SRectF rect = new SRectF(_Statics[_StaticEnergyChannel[i]].Rect.X,
Statics[_StaticEnergyChannel[i]].Rect.Y, _Statics[_StaticEnergyChannel[i]].Rect.Y,
Statics[_StaticEnergyChannel[i]].Rect.W * _ChannelEnergy[i], _Statics[_StaticEnergyChannel[i]].Rect.W * _ChannelEnergy[i],
Statics[_StaticEnergyChannel[i]].Rect.H, _Statics[_StaticEnergyChannel[i]].Rect.H,
Statics[_StaticEnergyChannel[i]].Rect.Z); _Statics[_StaticEnergyChannel[i]].Rect.Z);
CDraw.DrawTexture(Statics[_StaticEnergyChannel[i]].Texture, Statics[_StaticEnergyChannel[i]].Rect, CDraw.DrawTexture(_Statics[_StaticEnergyChannel[i]].Texture, _Statics[_StaticEnergyChannel[i]].Rect,
new SColorF(1f, 1f, 1f, 1f), rect); new SColorF(1f, 1f, 1f, 1f), rect);
} }
} }
Equalizers[_EqualizerChannel1].Draw(); _Equalizers[_EqualizerChannel1].Draw();
Equalizers[_EqualizerChannel2].Draw(); _Equalizers[_EqualizerChannel2].Draw();
DrawFG(); _DrawFG();
return true; return true;
} }
@@ -396,25 +414,25 @@ namespace Vocaluxe.Screens
private void _OnDeviceEvent() private void _OnDeviceEvent()
{ {
if (SelectSlides[_SelectSlideRecordDevices].Selection != _DeviceNr) if (_SelectSlides[_SelectSlideRecordDevices].Selection != _DeviceNr)
{ {
SelectSlides[_SelectSlideRecordInputs].Clear(); _SelectSlides[_SelectSlideRecordInputs].Clear();
_DeviceNr = SelectSlides[_SelectSlideRecordDevices].Selection; _DeviceNr = _SelectSlides[_SelectSlideRecordDevices].Selection;
_InputNr = 0; _InputNr = 0;
for (int inp = 0; inp < _Devices[_DeviceNr].Inputs.Count; inp++) for (int inp = 0; inp < _Devices[_DeviceNr].Inputs.Count; inp++)
SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[_DeviceNr].Inputs[inp].Name); _SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[_DeviceNr].Inputs[inp].Name);
_InputNr = 0; _InputNr = 0;
SelectSlides[_SelectSlideRecordInputs].Selection = 0; _SelectSlides[_SelectSlideRecordInputs].Selection = 0;
_UpdateChannels(); _UpdateChannels();
} }
} }
private void _OnInputEvent() private void _OnInputEvent()
{ {
if (SelectSlides[_SelectSlideRecordInputs].Selection != _InputNr) if (_SelectSlides[_SelectSlideRecordInputs].Selection != _InputNr)
{ {
_InputNr = SelectSlides[_SelectSlideRecordInputs].Selection; _InputNr = _SelectSlides[_SelectSlideRecordInputs].Selection;
_UpdateChannels(); _UpdateChannels();
} }
@@ -422,7 +440,7 @@ namespace Vocaluxe.Screens
private void _SaveDelayConfig() private void _SaveDelayConfig()
{ {
CConfig.MicDelay = SelectSlides[_SelectSlideDelay].Selection * 20; CConfig.MicDelay = _SelectSlides[_SelectSlideDelay].Selection * 20;
CConfig.SaveConfig(); CConfig.SaveConfig();
} }
@@ -470,15 +488,15 @@ namespace Vocaluxe.Screens
if (_DeviceNr < 0) if (_DeviceNr < 0)
return; return;
SInput input = _Devices[_DeviceNr].Inputs[_InputNr]; SInput input = _Devices[_DeviceNr].Inputs[_InputNr];
input.PlayerChannel1 = SelectSlides[_SelectSlideRecordChannel1].Selection; input.PlayerChannel1 = _SelectSlides[_SelectSlideRecordChannel1].Selection;
input.PlayerChannel2 = SelectSlides[_SelectSlideRecordChannel2].Selection; input.PlayerChannel2 = _SelectSlides[_SelectSlideRecordChannel2].Selection;
_Devices[_DeviceNr].Inputs[_InputNr] = input; _Devices[_DeviceNr].Inputs[_InputNr] = input;
} }
private void _UpdateChannels() private void _UpdateChannels()
{ {
SelectSlides[_SelectSlideRecordChannel1].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel1; _SelectSlides[_SelectSlideRecordChannel1].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel1;
SelectSlides[_SelectSlideRecordChannel2].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel2; _SelectSlides[_SelectSlideRecordChannel2].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel2;
_SaveMicConfig(); _SaveMicConfig();
} }
+40 -23
View File
@@ -1,4 +1,23 @@
using System.Windows.Forms; #region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -21,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()
{ {
@@ -35,18 +53,18 @@ namespace Vocaluxe.Screens
public override void LoadTheme(string xmlPath) public override void LoadTheme(string xmlPath)
{ {
base.LoadTheme(xmlPath); base.LoadTheme(xmlPath);
SelectSlides[_SelectSlideBackgroundMusic].SetValues<EOffOn>((int)CConfig.BackgroundMusic); _SelectSlides[_SelectSlideBackgroundMusic].SetValues<EOffOn>((int)CConfig.BackgroundMusic);
SelectSlides[_SelectSlideBackgroundMusicVolume].AddValues(new string[] _SelectSlides[_SelectSlideBackgroundMusicVolume].AddValues(new string[]
{"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"}); {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"});
SelectSlides[_SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5; _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5;
SelectSlides[_SelectSlideBackgroundMusicSource].SetValues<EBackgroundMusicSource>((int)CConfig.BackgroundMusicSource); _SelectSlides[_SelectSlideBackgroundMusicSource].SetValues<EBackgroundMusicSource>((int)CConfig.BackgroundMusicSource);
SelectSlides[_SelectSlideBackgroundMusicSource].Selection = (int)CConfig.BackgroundMusicSource; _SelectSlides[_SelectSlideBackgroundMusicSource].Selection = (int)CConfig.BackgroundMusicSource;
SelectSlides[_SelectSlidePreviewMusicVolume].AddValues(new string[] _SelectSlides[_SelectSlidePreviewMusicVolume].AddValues(new string[]
{"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"}); {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"});
SelectSlides[_SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5; _SelectSlides[_SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5;
SelectSlides[_SelectSlideGameMusicVolume].AddValues(new string[] _SelectSlides[_SelectSlideGameMusicVolume].AddValues(new string[]
{"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"}); {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"});
SelectSlides[_SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5; _SelectSlides[_SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5;
} }
public override bool HandleInput(SKeyEvent keyEvent) public override bool HandleInput(SKeyEvent keyEvent)
@@ -70,7 +88,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.Enter: case Keys.Enter:
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
{ {
_SaveConfig(); _SaveConfig();
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
@@ -98,10 +116,10 @@ namespace Vocaluxe.Screens
_SaveConfig(); _SaveConfig();
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
if (mouseEvent.LB && IsMouseOver(mouseEvent)) if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
_SaveConfig(); _SaveConfig();
if (Buttons[_ButtonExit].Selected) if (_Buttons[_ButtonExit].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
return true; return true;
@@ -110,7 +128,7 @@ namespace Vocaluxe.Screens
public override bool UpdateGame() public override bool UpdateGame()
{ {
if (_BackgroundMusicVolume != CConfig.BackgroundMusicVolume) if (_BackgroundMusicVolume != CConfig.BackgroundMusicVolume)
SelectSlides[_SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5; _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5;
return true; return true;
} }
@@ -123,22 +141,21 @@ 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;
SelectSlides[_SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5; _SelectSlides[_SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5;
} }
private void _SaveConfig() private void _SaveConfig()
{ {
CConfig.GameMusicVolume = SelectSlides[_SelectSlideGameMusicVolume].Selection * 5; CConfig.GameMusicVolume = _SelectSlides[_SelectSlideGameMusicVolume].Selection * 5;
CConfig.PreviewMusicVolume = SelectSlides[_SelectSlidePreviewMusicVolume].Selection * 5; CConfig.PreviewMusicVolume = _SelectSlides[_SelectSlidePreviewMusicVolume].Selection * 5;
CConfig.SaveConfig(); CConfig.SaveConfig();
EOffOn newOffOn = (EOffOn)SelectSlides[_SelectSlideBackgroundMusic].Selection; EOffOn newOffOn = (EOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection;
EBackgroundMusicSource newSource = (EBackgroundMusicSource)SelectSlides[_SelectSlideBackgroundMusicSource].Selection; EBackgroundMusicSource newSource = (EBackgroundMusicSource)_SelectSlides[_SelectSlideBackgroundMusicSource].Selection;
float newVolume = SelectSlides[_SelectSlideBackgroundMusicVolume].Selection * 5; float newVolume = _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection * 5;
CBackgroundMusic.CheckAndApplyConfig(newOffOn, newSource, newVolume); CBackgroundMusic.CheckAndApplyConfig(newOffOn, newSource, newVolume);
} }
Loaded 100 of 152 files, more files were not shown because too many files have changed in this diff. Show more