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
+7702 -6889

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_SONGS">Loaded songs</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_DUET">Duet</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_SONGS">Geladene Songs</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_DUET">Duett</string>
<string name="TR_GAMEMODE_MEDLEY">Medley</string>
+32 -2
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<ScreenSing>
<ScreenVersion>6</ScreenVersion>
<ScreenVersion>7</ScreenVersion>
<Background1>
<!--<Type>: Background type: None, Color, Texture, Video-->
<Type>None</Type>
@@ -988,6 +988,36 @@
<!-- <Space>: Reflection Space-->
<!-- <Height>: Reflection Height-->
</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>
<!--<X>, <Y>: Text position-->
<X>1214</X>
@@ -2771,4 +2801,4 @@
</BarPositions>
</SingBars>
</ScreenSing>
</root>
</root>
+1 -1
View File
@@ -1844,7 +1844,7 @@
<!--<Font>: Text font name-->
<Font>Outline</Font>
<!--<Text>: Nothing or translation tag-->
<Text />
<Text>%a - %t</Text>
<!--<Reflection> If exists:-->
<!-- <Space>: Reflection Space-->
<!-- <Height>: Reflection Height-->
@@ -1,5 +1,11 @@
ScreenSing
+++++++++
Version 7
Add:
<TextMedleyCountdown> !text-position and size will be overwritten by vocaluxe!
+++++++++
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.Linq;
namespace VocaluxeLib.PartyModes.Challenge
{
@@ -8,7 +28,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private readonly Random _Rand;
private readonly int _NumPlayer;
public List<CCombination> Rounds;
public readonly List<CCombination> Rounds;
public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce)
{
@@ -41,7 +61,7 @@ namespace VocaluxeLib.PartyModes.Challenge
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);
for (int i = 0; i < _NumPlayer; i++)
@@ -53,12 +73,7 @@ namespace VocaluxeLib.PartyModes.Challenge
numPlayed[playerIndex]++;
}
int max = 0;
foreach (int p in numPlayed)
{
if (p > max)
max = p;
}
int max = numPlayed.Max();
int num = Rounds[0].Player.Count;
List<int> result = new List<int>();
@@ -131,43 +146,26 @@ namespace VocaluxeLib.PartyModes.Challenge
_Rand = rand;
}
public CCombination GetNextCombination(List<int> playerNrDemand)
public CCombination GetNextCombination(IEnumerable<int> playerNrDemand)
{
if (_Combs.Count == 0)
_Create();
CCombination combs = new CCombination();
if (_NumPlayer == _NumMics)
return _Combs[0];
//filter against PlayerNrDemand
List<CCombination> combsFiltered = new List<CCombination>();
if (playerNrDemand != null)
{
for (int i = 0; i < _Combs.Count; i++)
{
if (_Combs[i].IsAvailableAll(playerNrDemand))
combsFiltered.Add(_Combs[i]);
}
}
combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableAll(playerNrDemand)));
//1st fallback
if (playerNrDemand != null && combsFiltered.Count == 0)
{
for (int i = 0; i < _Combs.Count; i++)
{
if (_Combs[i].IsAvailableSomeone(playerNrDemand))
combsFiltered.Add(_Combs[i]);
}
}
combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableSomeone(playerNrDemand)));
//2nd fallback
if (combsFiltered.Count == 0)
{
for (int i = 0; i < _Combs.Count; i++)
combsFiltered.Add(_Combs[i]);
}
combsFiltered.AddRange(_Combs);
int num = combsFiltered.Count;
int rand = _Rand.Next(num);
@@ -203,7 +201,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public class CCombination
{
public List<int> Player;
public readonly List<int> Player;
public CCombination()
{
@@ -212,28 +210,17 @@ namespace VocaluxeLib.PartyModes.Challenge
public bool IsAvailable(int playerIndex)
{
foreach (int p in Player)
{
if (p == playerIndex)
return true;
}
return false;
return Player.Any(p => p == playerIndex);
}
public bool IsAvailableAll(List<int> playerIndices)
public bool IsAvailableAll(IEnumerable<int> playerIndices)
{
bool result = true;
foreach (int p in playerIndices)
result &= IsAvailable(p);
return result;
return playerIndices.All(IsAvailable);
}
public bool IsAvailableSomeone(List<int> playerIndices)
public bool IsAvailableSomeone(IEnumerable<int> playerIndices)
{
bool result = false;
foreach (int p in playerIndices)
result |= IsAvailable(p);
return result;
return playerIndices.Any(IsAvailable);
}
}
}
@@ -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.Collections.Generic;
using System.Runtime.InteropServices;
@@ -39,17 +58,15 @@ namespace VocaluxeLib.PartyModes.Challenge
public int Position;
public int PlayerID;
public int NumPlayed;
public int NumRounds;
public int NumWon;
public int NumSingPoints;
public int NumGamePoints;
public int CompareTo(object obj)
{
if (obj is CResultTableRow)
CResultTableRow row = obj as CResultTableRow;
if (row != null)
{
CResultTableRow row = (CResultTableRow)obj;
int res = row.NumGamePoints.CompareTo(NumGamePoints);
if (res == 0)
{
@@ -82,8 +99,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public struct SFromScreenNames
{
public bool FadeToConfig;
public bool FadeToMain;
public bool FadeBack;
public List<int> ProfileIDs;
}
@@ -162,14 +178,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_ToScreenNames = new SDataToScreenNames();
_ToScreenMain = new SDataToScreenMain();
_GameData = new SData();
_GameData.NumPlayer = 4;
_GameData.NumPlayerAtOnce = 2;
_GameData.NumRounds = 2;
_GameData.CurrentRoundNr = 1;
_GameData.ProfileIDs = new List<int>();
_GameData.CatSongIndices = null;
_GameData.Results = null;
_GameData = new SData {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 2, CurrentRoundNr = 1, ProfileIDs = new List<int>(), CatSongIndices = null, Results = null};
}
public override bool Init()
@@ -192,7 +201,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public override void DataFromScreen(string screenName, Object data)
{
SDataFromScreen dataFrom = new SDataFromScreen();
SDataFromScreen dataFrom;
switch (screenName)
{
case "PartyScreenChallengeConfig":
@@ -217,7 +226,7 @@ namespace VocaluxeLib.PartyModes.Challenge
try
{
dataFrom = (SDataFromScreen)data;
if (dataFrom.ScreenNames.FadeToConfig)
if (dataFrom.ScreenNames.FadeBack)
_Stage = EStage.NotStarted;
else
{
@@ -352,10 +361,11 @@ namespace VocaluxeLib.PartyModes.Challenge
return _ScreenSongOptions;
}
// ReSharper disable RedundantAssignment
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)
{
@@ -372,7 +382,9 @@ namespace VocaluxeLib.PartyModes.Challenge
screenSongOptions = _ScreenSongOptions;
}
// ReSharper disable RedundantAssignment
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{
if (_GameData.CatSongIndices != null && categoryIndex != -1)
{
@@ -440,40 +452,29 @@ namespace VocaluxeLib.PartyModes.Challenge
public override void SongSelected(int songID)
{
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
const EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
CBase.Game.Reset();
CBase.Game.ClearSongs();
CBase.Game.AddSong(songID, gm);
CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce);
SPlayer[] player = CBase.Game.GetPlayer();
SPlayer[] player = CBase.Game.GetPlayers();
if (player == null)
return;
if (player.Length < _GameData.NumPlayerAtOnce)
return;
SProfile[] profiles = CBase.Profiles.GetProfiles();
CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1);
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
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);
@@ -568,13 +569,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{
for (int i = 0; i < _GameData.NumPlayer; i++)
{
CResultTableRow row = new CResultTableRow();
row.PlayerID = _GameData.ProfileIDs[i];
row.NumPlayed = 0;
row.NumRounds = 0;
row.NumWon = 0;
row.NumSingPoints = 0;
row.NumGamePoints = 0;
CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0};
_GameData.ResultTable.Add(row);
}
@@ -587,7 +582,7 @@ namespace VocaluxeLib.PartyModes.Challenge
}
else
{
SPlayer[] results = CBase.Game.GetPlayer();
SPlayer[] results = CBase.Game.GetPlayers();
if (results == null)
return;
@@ -611,18 +606,16 @@ namespace VocaluxeLib.PartyModes.Challenge
}
}
if (index != -1)
{
CResultTableRow row = _GameData.ResultTable[index];
if (index == -1)
continue;
CResultTableRow row = _GameData.ResultTable[index];
row.NumPlayed++;
row.NumWon += points[i].Won;
row.NumRounds += 1;
row.NumSingPoints += points[i].SingPoints;
row.NumGamePoints += points[i].GamePoints;
row.NumPlayed++;
row.NumWon += points[i].Won;
row.NumSingPoints += points[i].SingPoints;
row.NumGamePoints += points[i].GamePoints;
_GameData.ResultTable[index] = row;
}
_GameData.ResultTable[index] = row;
}
}
@@ -632,13 +625,13 @@ namespace VocaluxeLib.PartyModes.Challenge
int pos = 1;
int lastPoints = 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++;
_GameData.ResultTable[i].Position = pos;
lastPoints = _GameData.ResultTable[i].NumGamePoints;
lastSingPoints = _GameData.ResultTable[i].NumSingPoints;
resultRow.Position = pos;
lastPoints = resultRow.NumGamePoints;
lastSingPoints = resultRow.NumSingPoints;
}
}
@@ -647,15 +640,11 @@ namespace VocaluxeLib.PartyModes.Challenge
List<SStats> result = new List<SStats>();
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
{
SStats stat = new SStats();
stat.ProfileID = results[i].ProfileID;
stat.SingPoints = (int)Math.Round(results[i].Points);
stat.Won = 0;
stat.GamePoints = 0;
SStats stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0};
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 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.Windows.Forms;
using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.Challenge
{
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeConfig : CMenuParty
// ReSharper restore UnusedMember.Global
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
@@ -32,20 +53,15 @@ namespace VocaluxeLib.PartyModes.Challenge
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
_Data = new SDataFromScreen();
SFromScreenConfig config = new SFromScreenConfig();
config.NumPlayer = 4;
config.NumPlayerAtOnce = 2;
config.NumRounds = 12;
SFromScreenConfig config = new SFromScreenConfig {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 12};
_Data.ScreenConfig = config;
}
public override void DataToScreen(object receivedData)
{
SDataToScreenConfig config = new SDataToScreenConfig();
try
{
config = (SDataToScreenConfig)receivedData;
SDataToScreenConfig config = (SDataToScreenConfig)receivedData;
_Data.ScreenConfig.NumPlayer = config.NumPlayer;
_Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce;
_Data.ScreenConfig.NumRounds = config.NumRounds;
@@ -73,10 +89,10 @@ namespace VocaluxeLib.PartyModes.Challenge
case Keys.Enter:
_UpdateSlides();
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
break;
@@ -96,13 +112,13 @@ namespace VocaluxeLib.PartyModes.Challenge
{
base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
_UpdateSlides();
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
}
@@ -139,10 +155,10 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _RebuildSlides()
{
// build num player slide (min player ... max player);
SelectSlides[_SelectSlideNumPlayers].Clear();
_SelectSlides[_SelectSlideNumPlayers].Clear();
for (int i = _PartyMode.GetMinPlayer(); i <= _PartyMode.GetMaxPlayer(); i++)
SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString());
SelectSlides[_SelectSlideNumPlayers].Selection = _Data.ScreenConfig.NumPlayer - _PartyMode.GetMinPlayer();
_SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString());
_SelectSlides[_SelectSlideNumPlayers].Selection = _Data.ScreenConfig.NumPlayer - _PartyMode.GetMinPlayer();
_UpdateMicsAtOnce();
_SetRoundSteps();
@@ -153,9 +169,9 @@ namespace VocaluxeLib.PartyModes.Challenge
{
int player = _Data.ScreenConfig.NumPlayer;
int mics = _Data.ScreenConfig.NumPlayerAtOnce;
_Data.ScreenConfig.NumPlayer = SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumPlayerAtOnce = SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumRounds = (SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps;
_Data.ScreenConfig.NumPlayer = _SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumPlayerAtOnce = _SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumRounds = (_SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps;
_UpdateMicsAtOnce();
_SetRoundSteps();
@@ -182,19 +198,19 @@ namespace VocaluxeLib.PartyModes.Challenge
_Data.ScreenConfig.NumPlayerAtOnce = maxNum;
// build mics at once slide
SelectSlides[_SelectSlideNumMics].Clear();
_SelectSlides[_SelectSlideNumMics].Clear();
for (int i = 1; i <= maxNum; i++)
SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
SelectSlides[_SelectSlideNumMics].Selection = _Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
_SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
_SelectSlides[_SelectSlideNumMics].Selection = _Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
}
private void _UpdateSlideRounds()
{
// build num rounds slide
SelectSlides[_SelectSlideNumRounds].Clear();
_SelectSlides[_SelectSlideNumRounds].Clear();
for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString());
SelectSlides[_SelectSlideNumRounds].Selection = _Data.ScreenConfig.NumRounds / _RoundSteps - 1;
_SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString());
_SelectSlides[_SelectSlideNumRounds].Selection = _Data.ScreenConfig.NumRounds / _RoundSteps - 1;
}
private void _SetRoundSteps()
@@ -208,10 +224,7 @@ namespace VocaluxeLib.PartyModes.Challenge
int res = _Data.ScreenConfig.NumPlayer / _Data.ScreenConfig.NumPlayerAtOnce;
int mod = _Data.ScreenConfig.NumPlayer % _Data.ScreenConfig.NumPlayerAtOnce;
if (mod == 0)
_RoundSteps = res;
else
_RoundSteps = _Data.ScreenConfig.NumPlayer;
_RoundSteps = mod == 0 ? res : _Data.ScreenConfig.NumPlayer;
}
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.Collections.Generic;
using System.Windows.Forms;
@@ -22,7 +41,9 @@ namespace VocaluxeLib.PartyModes.Challenge
public List<CText> TextScores;
}
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMain : CMenuParty
// ReSharper restore UnusedMember.Global
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
@@ -72,13 +93,12 @@ namespace VocaluxeLib.PartyModes.Challenge
private SRectF _PlayerTableScrollArea;
private int _RoundsTableOffset;
private int _PlayerTableOffset;
private int _NumPlayerVisible = 10;
private const int _NumPlayerVisible = 10;
private int _NumRoundsVisible = 3;
public CPartyScreenChallengeMain()
{
_Data = new SDataFromScreen();
_Data.ScreenMain = new SFromScreenMain();
_Data = new SDataFromScreen {ScreenMain = new SFromScreenMain()};
}
public override void Init()
@@ -87,11 +107,15 @@ namespace VocaluxeLib.PartyModes.Challenge
_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
};
_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};
}
@@ -107,20 +131,18 @@ namespace VocaluxeLib.PartyModes.Challenge
for (int i = 0; i < _PartyMode.GetMaxPlayer(); i++)
{
_NextPlayerTexts.Add(GetNewText(Texts[_TextNextPlayer]));
AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]);
_NextPlayerStatics.Add(GetNewStatic(Statics[_StaticNextPlayer]));
AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]);
_NextPlayerTexts.Add(GetNewText(_Texts[_TextNextPlayer]));
_AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]);
_NextPlayerStatics.Add(GetNewStatic(_Statics[_StaticNextPlayer]));
_AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]);
}
}
public override void DataToScreen(object receivedData)
{
SDataToScreenMain data = new SDataToScreenMain();
try
{
data = (SDataToScreenMain)receivedData;
SDataToScreenMain data = (SDataToScreenMain)receivedData;
_GameState = data;
}
catch (Exception e)
@@ -154,26 +176,26 @@ namespace VocaluxeLib.PartyModes.Challenge
case Keys.Enter:
if (!_ExitPopupVisible)
{
if (Buttons[_ButtonNextRound].Selected)
if (_Buttons[_ButtonNextRound].Selected)
_NextRound();
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
if (_Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
_Back();
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
if (_Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
_ShowPopup(true);
if (Buttons[_ButtonPlayerScrollUp].Selected)
if (_Buttons[_ButtonPlayerScrollUp].Selected)
_ScrollPlayerTable(-1);
if (Buttons[_ButtonPlayerScrollDown].Selected)
if (_Buttons[_ButtonPlayerScrollDown].Selected)
_ScrollPlayerTable(1);
if (Buttons[_ButtonRoundsScrollUp].Selected)
if (_Buttons[_ButtonRoundsScrollUp].Selected)
_ScrollRoundsTable(-1);
if (Buttons[_ButtonRoundsScrollDown].Selected)
if (_Buttons[_ButtonRoundsScrollDown].Selected)
_ScrollRoundsTable(1);
}
else
{
if (Buttons[_ButtonPopupYes].Selected)
if (_Buttons[_ButtonPopupYes].Selected)
_EndParty();
if (Buttons[_ButtonPopupNo].Selected)
if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false);
}
break;
@@ -186,30 +208,30 @@ namespace VocaluxeLib.PartyModes.Challenge
{
base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
if (!_ExitPopupVisible)
{
if (Buttons[_ButtonNextRound].Selected)
if (_Buttons[_ButtonNextRound].Selected)
_NextRound();
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
if (_Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
_Back();
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
if (_Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
_ShowPopup(true);
if (Buttons[_ButtonPlayerScrollUp].Selected)
if (_Buttons[_ButtonPlayerScrollUp].Selected)
_ScrollPlayerTable(-1);
if (Buttons[_ButtonPlayerScrollDown].Selected)
if (_Buttons[_ButtonPlayerScrollDown].Selected)
_ScrollPlayerTable(1);
if (Buttons[_ButtonRoundsScrollUp].Selected)
if (_Buttons[_ButtonRoundsScrollUp].Selected)
_ScrollRoundsTable(-1);
if (Buttons[_ButtonRoundsScrollDown].Selected)
if (_Buttons[_ButtonRoundsScrollDown].Selected)
_ScrollRoundsTable(1);
}
else
{
if (Buttons[_ButtonPopupYes].Selected)
if (_Buttons[_ButtonPopupYes].Selected)
_EndParty();
if (Buttons[_ButtonPopupNo].Selected)
if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false);
}
}
@@ -256,29 +278,29 @@ namespace VocaluxeLib.PartyModes.Challenge
if (_GameState.CurrentRoundNr == 1)
{
Buttons[_ButtonBack].Visible = true;
Buttons[_ButtonExit].Visible = false;
_Buttons[_ButtonBack].Visible = true;
_Buttons[_ButtonExit].Visible = false;
}
else
{
Buttons[_ButtonBack].Visible = false;
Buttons[_ButtonExit].Visible = true;
_Buttons[_ButtonBack].Visible = false;
_Buttons[_ButtonExit].Visible = true;
}
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{
Buttons[_ButtonNextRound].Visible = true;
Texts[_TextFinishMessage].Visible = false;
Texts[_TextFinishPlayerWin].Visible = false;
SetInteractionToButton(Buttons[_ButtonNextRound]);
_Buttons[_ButtonNextRound].Visible = true;
_Texts[_TextFinishMessage].Visible = false;
_Texts[_TextFinishPlayerWin].Visible = false;
_SetInteractionToButton(_Buttons[_ButtonNextRound]);
}
else
{
Buttons[_ButtonNextRound].Visible = false;
Texts[_TextFinishMessage].Visible = true;
Texts[_TextFinishPlayerWin].Visible = true;
Texts[_TextFinishPlayerWin].Text = _GetPlayerWinString();
SetInteractionToButton(Buttons[_ButtonExit]);
_Buttons[_ButtonNextRound].Visible = false;
_Texts[_TextFinishMessage].Visible = true;
_Texts[_TextFinishPlayerWin].Visible = true;
_Texts[_TextFinishPlayerWin].Text = _GetPlayerWinString();
_SetInteractionToButton(_Buttons[_ButtonExit]);
}
_ShowPopup(false);
@@ -311,13 +333,13 @@ namespace VocaluxeLib.PartyModes.Challenge
{
_ExitPopupVisible = visible;
Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
_Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
_Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
_Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
_Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
if (_ExitPopupVisible)
SetInteractionToButton(Buttons[_ButtonPopupNo]);
_SetInteractionToButton(_Buttons[_ButtonPopupNo]);
}
private void _Back()
@@ -329,9 +351,9 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdateNextPlayerPositions()
{
float x = CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2;
float staticY = 590;
float textY = 550;
float x = (float)CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2;
const float staticY = 590;
const float textY = 550;
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{
//static
@@ -339,11 +361,11 @@ namespace VocaluxeLib.PartyModes.Challenge
_NextPlayerStatics[i].Rect.Y = staticY;
_NextPlayerStatics[i].Visible = true;
//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].Visible = true;
x += Statics[_StaticNextPlayer].Rect.W + 15;
x += _Statics[_StaticNextPlayer].Rect.W + 15;
}
for (int i = _GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
{
@@ -356,7 +378,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{
Texts[_TextNextPlayerMessage].Visible = true;
_Texts[_TextNextPlayerMessage].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{
@@ -368,7 +390,7 @@ namespace VocaluxeLib.PartyModes.Challenge
}
else
{
Texts[_TextNextPlayerMessage].Visible = false;
_Texts[_TextNextPlayerMessage].Visible = false;
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{
_NextPlayerStatics[i].Visible = false;
@@ -383,30 +405,28 @@ namespace VocaluxeLib.PartyModes.Challenge
_RoundsTable = new List<CRoundsTableRow>();
for (int i = 0; i < 5; i++)
{
CRoundsTableRow rtr = new CRoundsTableRow();
rtr.TextPlayer = new List<CText>();
rtr.TextScores = new List<CText>();
CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()};
_RoundsTable.Add(rtr);
}
//Create statics and texts for rounds
for (int round = 0; round < _RoundsTable.Count; round++)
foreach (CRoundsTableRow roundRow in _RoundsTable)
{
//Round-number
CText text = GetNewText(Texts[_TextRoundNumber]);
AddText(text);
_RoundsTable[round].Number = text;
CText text = GetNewText(_Texts[_TextRoundNumber]);
_AddText(text);
roundRow.Number = text;
for (int row = 0; row < 2; row++)
{
for (int column = 0; column < 3; column++)
{
//Player
text = GetNewText(Texts[_TextRoundPlayer]);
AddText(text);
_RoundsTable[round].TextPlayer.Add(text);
text = GetNewText(_Texts[_TextRoundPlayer]);
_AddText(text);
roundRow.TextPlayer.Add(text);
//Score
text = GetNewText(Texts[_TextRoundScore]);
AddText(text);
_RoundsTable[round].TextScores.Add(text);
text = GetNewText(_Texts[_TextRoundScore]);
_AddText(text);
roundRow.TextScores.Add(text);
}
}
}
@@ -416,30 +436,27 @@ namespace VocaluxeLib.PartyModes.Challenge
{
_RoundsTableScrollArea = new SRectF();
int numPlayerInOneRow = 3;
if (_GameState.NumPlayerAtOnce <= numPlayerInOneRow)
_NumRoundsVisible = 5;
else
_NumRoundsVisible = 3;
const int numPlayerInOneRow = 3;
_NumRoundsVisible = _GameState.NumPlayerAtOnce <= numPlayerInOneRow ? 5 : 3;
if (_NumRoundsVisible > _GameState.Combs.Count)
_NumRoundsVisible = _GameState.Combs.Count;
float numberX = Texts[_TextRoundNumber].X;
float numberY = Texts[_TextRoundNumber].Y;
float numberX = _Texts[_TextRoundNumber].X;
float numberY = _Texts[_TextRoundNumber].Y;
_RoundsTableScrollArea.X = numberX;
_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
for (int round = 0; round < _RoundsTable.Count; round++)
foreach (CRoundsTableRow roundRow in _RoundsTable)
{
//Round-number
_RoundsTable[round].Number.X = numberX;
_RoundsTable[round].Number.Y = numberY;
roundRow.Number.X = numberX;
roundRow.Number.Y = numberY;
int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow));
for (int row = 0; row < numInnerRows; row++)
{
@@ -453,17 +470,17 @@ namespace VocaluxeLib.PartyModes.Challenge
for (int column = row * numPlayerInOneRow; column < num; column++)
{
//Player
float x = numberX + 15 + (CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) +
((CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2;
float maxw = ((CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5;
_RoundsTable[round].TextPlayer[column].X = x;
_RoundsTable[round].TextPlayer[column].Y = numberY;
_RoundsTable[round].TextPlayer[column].MaxWidth = maxw;
float x = numberX + 15 + (CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) +
((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2;
float maxw = ((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5;
roundRow.TextPlayer[column].X = x;
roundRow.TextPlayer[column].Y = numberY;
roundRow.TextPlayer[column].MaxWidth = maxw;
//Score
_RoundsTable[round].TextScores[column] = _RoundsTable[round].TextScores[column];
_RoundsTable[round].TextScores[column].X = x;
_RoundsTable[round].TextScores[column].Y = numberY + delta;
_RoundsTable[round].TextScores[column].MaxWidth = maxw;
roundRow.TextScores[column] = roundRow.TextScores[column];
roundRow.TextScores[column].X = x;
roundRow.TextScores[column].Y = numberY + delta;
roundRow.TextScores[column].MaxWidth = maxw;
}
numberY = numberY + delta + delta;
}
@@ -484,7 +501,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_RoundsTable[i].Number.Visible = true;
_RoundsTable[i].TextPlayer[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]];
_RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset)
@@ -509,32 +526,30 @@ namespace VocaluxeLib.PartyModes.Challenge
}
}
Buttons[_ButtonRoundsScrollUp].Visible = _RoundsTableOffset > 0;
Buttons[_ButtonRoundsScrollDown].Visible = _GameState.Combs.Count - _NumRoundsVisible - _RoundsTableOffset > 0;
_Buttons[_ButtonRoundsScrollUp].Visible = _RoundsTableOffset > 0;
_Buttons[_ButtonRoundsScrollDown].Visible = _GameState.Combs.Count - _NumRoundsVisible - _RoundsTableOffset > 0;
}
private void _BuildPlayerTable()
{
_PlayerTableScrollArea = new SRectF();
_PlayerTableScrollArea.X = Texts[_TextPosition].X;
_PlayerTableScrollArea.Y = Texts[_TextPosition].Y;
_PlayerTableScrollArea.W = Texts[_TextGamePoints].X - Texts[_TextPosition].X;
_PlayerTableScrollArea = new SRectF {X = _Texts[_TextPosition].X, Y = _Texts[_TextPosition].Y, W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X};
_PlayerTable = new List<STableRow>();
float delta = Texts[_TextPosition].Height * 1.2f;
float delta = _Texts[_TextPosition].Height * 1.2f;
float h = 0;
for (int i = 0; i < 10; i++)
{
STableRow row = new STableRow();
row.Pos = GetNewText(Texts[_TextPosition]);
row.Name = GetNewText(Texts[_TextPlayerName]);
row.Rounds = GetNewText(Texts[_TextNumPlayed]);
row.Won = GetNewText(Texts[_TextWon]);
row.SingPoints = GetNewText(Texts[_TextSingPoints]);
row.GamePoints = GetNewText(Texts[_TextGamePoints]);
STableRow row = new STableRow
{
Pos = GetNewText(_Texts[_TextPosition]),
Name = GetNewText(_Texts[_TextPlayerName]),
Rounds = GetNewText(_Texts[_TextNumPlayed]),
Won = GetNewText(_Texts[_TextWon]),
SingPoints = GetNewText(_Texts[_TextSingPoints]),
GamePoints = GetNewText(_Texts[_TextGamePoints])
};
row.Pos.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.GamePoints.Y += delta * (i + 1);
row.Pos.Text = (i + 1).ToString() + ".";
row.Pos.Text = (i + 1) + ".";
row.Pos.Visible = false;
row.Name.Visible = false;
@@ -552,12 +567,12 @@ namespace VocaluxeLib.PartyModes.Challenge
row.SingPoints.Visible = false;
row.GamePoints.Visible = false;
AddText(row.Pos);
AddText(row.Name);
AddText(row.Rounds);
AddText(row.Won);
AddText(row.SingPoints);
AddText(row.GamePoints);
_AddText(row.Pos);
_AddText(row.Name);
_AddText(row.Rounds);
_AddText(row.Won);
_AddText(row.SingPoints);
_AddText(row.GamePoints);
_PlayerTable.Add(row);
@@ -583,9 +598,9 @@ namespace VocaluxeLib.PartyModes.Challenge
row.SingPoints.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.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumRounds.ToString();
row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString();
row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString();
row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString();
row.GamePoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumGamePoints.ToString();
@@ -601,8 +616,8 @@ namespace VocaluxeLib.PartyModes.Challenge
}
}
Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0;
Buttons[_ButtonPlayerScrollDown].Visible = _GameState.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0;
_Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0;
_Buttons[_ButtonPlayerScrollDown].Visible = _GameState.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0;
}
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.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.Challenge
{
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeNames : CMenuParty
// ReSharper restore UnusedMember.Global
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
@@ -22,7 +44,6 @@ namespace VocaluxeLib.PartyModes.Challenge
private List<CButton> _PlayerDestinationButtons;
//PlayerDestinationButtons-Option
private const int _PlayerDestinationButtonsNumH = 3;
private const int _PlayerDestinationButtonsNumW = 4;
private const int _PlayerDestinationButtonsFirstX = 900;
private const int _PlayerDestinationButtonsFirstY = 105;
private const int _PlayerDestinationButtonsSpaceH = 15;
@@ -35,7 +56,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private const int _PlayerChooseButtonsFirstY = 105;
private const int _PlayerChooseButtonsSpaceH = 15;
private const int _PlayerChooseButtonsSpaceW = 25;
private int _PlayerChooseButtonsOffset = 0;
private const int _PlayerChooseButtonsOffset = 0;
private CStatic _ChooseAvatarStatic;
private bool _SelectingMouseActive;
@@ -65,27 +86,19 @@ namespace VocaluxeLib.PartyModes.Challenge
_Data.ScreenNames.ProfileIDs = new List<int>();
List<string> buttons = new List<string>();
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose};
_Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames();
names.FadeToConfig = false;
names.FadeToMain = false;
names.ProfileIDs = new List<int>();
SFromScreenNames names = new SFromScreenNames {FadeBack = false, ProfileIDs = new List<int>()};
_Data.ScreenNames = names;
}
public override void DataToScreen(object receivedData)
{
SDataToScreenNames config = new SDataToScreenNames();
try
{
config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDs = config.ProfileIDs;
if (_Data.ScreenNames.ProfileIDs == null)
_Data.ScreenNames.ProfileIDs = new List<int>();
SDataToScreenNames config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDs = config.ProfileIDs ?? new List<int>();
_NumPlayer = config.NumPlayer;
@@ -113,10 +126,10 @@ namespace VocaluxeLib.PartyModes.Challenge
break;
case Keys.Enter:
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
if (!_OnAdd())
@@ -218,12 +231,12 @@ namespace VocaluxeLib.PartyModes.Challenge
_ChooseAvatarStatic.Visible = false;
}
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
if (!_OnAdd())
@@ -268,13 +281,13 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _AddButtonPlayerDestination()
{
Buttons[_ButtonPlayerDestination].Visible = false;
_Buttons[_ButtonPlayerDestination].Visible = false;
_PlayerDestinationButtons = new List<CButton>();
int row = 0;
int column = 0;
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.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW);
_PlayerDestinationButtons.Add(b);
@@ -286,24 +299,22 @@ namespace VocaluxeLib.PartyModes.Challenge
}
b.Visible = true;
b.Enabled = false;
AddButton(b);
_AddButton(b);
}
}
private void _AddButtonPlayerChoose()
{
Buttons[_ButtonPlayerChoose].Visible = false;
_Buttons[_ButtonPlayerChoose].Visible = false;
_PlayerChooseButtons = new List<CPlayerChooseButton>();
int row = 0;
int column = 0;
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.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW);
CPlayerChooseButton pcb = new CPlayerChooseButton();
pcb.Button = b;
pcb.ProfileID = -1;
CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1};
_PlayerChooseButtons.Add(pcb);
column++;
if (column >= _PlayerChooseButtonsNumH)
@@ -313,7 +324,7 @@ namespace VocaluxeLib.PartyModes.Challenge
}
b.Visible = true;
b.Enabled = false;
AddButton(b);
_AddButton(b);
}
}
@@ -329,7 +340,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdateButtonPlayerChoose(int offset)
{
int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
const int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
if (offset < 0)
offset = 0;
@@ -341,8 +352,10 @@ namespace VocaluxeLib.PartyModes.Challenge
{
_PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose];
_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.SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.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.SelColor = new SColorF(1, 1, 1, 1);
_PlayerChooseButtons[i].Button.Enabled = true;
@@ -351,10 +364,10 @@ namespace VocaluxeLib.PartyModes.Challenge
{
_PlayerChooseButtons[i].ProfileID = -1;
_PlayerChooseButtons[i].Button.Text.Text = String.Empty;
_PlayerChooseButtons[i].Button.Texture = Buttons[_ButtonPlayerChoose].Texture;
_PlayerChooseButtons[i].Button.SelTexture = Buttons[_ButtonPlayerChoose].SelTexture;
_PlayerChooseButtons[i].Button.Color = Buttons[_ButtonPlayerChoose].Color;
_PlayerChooseButtons[i].Button.SelColor = Buttons[_ButtonPlayerChoose].SelColor;
_PlayerChooseButtons[i].Button.Texture = _Buttons[_ButtonPlayerChoose].Texture;
_PlayerChooseButtons[i].Button.SelTexture = _Buttons[_ButtonPlayerChoose].SelTexture;
_PlayerChooseButtons[i].Button.Color = _Buttons[_ButtonPlayerChoose].Color;
_PlayerChooseButtons[i].Button.SelColor = _Buttons[_ButtonPlayerChoose].SelColor;
_PlayerChooseButtons[i].Button.Enabled = false;
}
}
@@ -369,19 +382,7 @@ namespace VocaluxeLib.PartyModes.Challenge
bool visible = false;
//Show profile only if active
if (CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON)
{
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;
}
}
}
visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != i);
if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(i);
}
@@ -418,10 +419,10 @@ namespace VocaluxeLib.PartyModes.Challenge
}
else
{
_PlayerDestinationButtons[i].Color = Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i].SelColor = Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i].Texture = Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i].SelTexture = Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i].Color = _Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i].SelColor = _Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i].Texture = _Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i].SelTexture = _Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i].Text.Text = String.Empty;
_PlayerDestinationButtons[i].Enabled = false;
}
@@ -432,72 +433,63 @@ namespace VocaluxeLib.PartyModes.Challenge
{
if (_Data.ScreenNames.ProfileIDs.Count == _NumPlayer)
{
Buttons[_ButtonNext].Visible = true;
SetInteractionToButton(Buttons[_ButtonNext]);
_Buttons[_ButtonNext].Visible = true;
_SetInteractionToButton(_Buttons[_ButtonNext]);
}
else
Buttons[_ButtonNext].Visible = false;
_Buttons[_ButtonNext].Visible = false;
}
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 (_Data.ScreenNames.ProfileIDs.Count < _NumPlayer)
{
_Data.ScreenNames.ProfileIDs.Add(_PlayerChooseButtons[i].ProfileID);
int added = _Data.ScreenNames.ProfileIDs.Count - 1;
_UpdateButtonNext();
//Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List
_UpdateButtonPlayerChoose();
CheckInteraction();
return true;
}
}
if (!button.Button.Selected || button.ProfileID == -1 || _Data.ScreenNames.ProfileIDs.Count >= _NumPlayer)
continue;
_Data.ScreenNames.ProfileIDs.Add(button.ProfileID);
int added = _Data.ScreenNames.ProfileIDs.Count - 1;
_UpdateButtonNext();
//Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[button.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[button.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[button.ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List
_UpdateButtonPlayerChoose();
_CheckInteraction();
return true;
}
return false;
}
private bool _OnRemove()
private void _OnRemove()
{
for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
{
if (_PlayerDestinationButtons[i].Selected)
{
if ((i + 1) <= _Data.ScreenNames.ProfileIDs.Count)
{
_Data.ScreenNames.ProfileIDs.RemoveAt(i);
_UpdateButtonNext();
_UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose();
CheckInteraction();
return true;
}
}
if (!_PlayerDestinationButtons[i].Selected)
continue;
if ((i + 1) > _Data.ScreenNames.ProfileIDs.Count)
continue;
_Data.ScreenNames.ProfileIDs.RemoveAt(i);
_UpdateButtonNext();
_UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose();
_CheckInteraction();
return;
}
return false;
}
private void _Back()
{
_Data.ScreenNames.FadeToConfig = true;
_Data.ScreenNames.FadeToMain = false;
_Data.ScreenNames.FadeBack = true;
_PartyMode.DataFromScreen(ThemeName, _Data);
}
private void _Next()
{
_Data.ScreenNames.FadeToConfig = false;
_Data.ScreenNames.FadeToMain = true;
_Data.ScreenNames.FadeBack = false;
_PartyMode.DataFromScreen(ThemeName, _Data);
}
}
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.Linq;
namespace VocaluxeLib.PartyModes.ChallengeMedley
{
@@ -8,7 +28,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private readonly Random _Rand;
private readonly int _NumPlayer;
public List<CCombination> Rounds;
public readonly List<CCombination> Rounds;
public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce)
{
@@ -53,12 +73,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
numPlayed[playerIndex]++;
}
int max = 0;
foreach (int p in numPlayed)
{
if (p > max)
max = p;
}
int max = numPlayed.Max();
int num = Rounds[0].Player.Count;
List<int> result = new List<int>();
@@ -136,38 +151,21 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
if (_Combs.Count == 0)
_Create();
CCombination combs = new CCombination();
if (_NumPlayer == _NumMics)
return _Combs[0];
//filter against PlayerNrDemand
List<CCombination> combsFiltered = new List<CCombination>();
if (playerNrDemand != null)
{
for (int i = 0; i < _Combs.Count; i++)
{
if (_Combs[i].IsAvailableAll(playerNrDemand))
combsFiltered.Add(_Combs[i]);
}
}
combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableAll(playerNrDemand)));
//1st fallback
if (playerNrDemand != null && combsFiltered.Count == 0)
{
for (int i = 0; i < _Combs.Count; i++)
{
if (_Combs[i].IsAvailableSomeone(playerNrDemand))
combsFiltered.Add(_Combs[i]);
}
}
combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableSomeone(playerNrDemand)));
//2nd fallback
if (combsFiltered.Count == 0)
{
for (int i = 0; i < _Combs.Count; i++)
combsFiltered.Add(_Combs[i]);
}
combsFiltered.AddRange(_Combs);
int num = combsFiltered.Count;
int rand = _Rand.Next(num);
@@ -203,7 +201,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public class CCombination
{
public List<int> Player;
public readonly List<int> Player;
public CCombination()
{
@@ -212,28 +210,17 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public bool IsAvailable(int playerIndex)
{
foreach (int p in Player)
{
if (p == playerIndex)
return true;
}
return false;
return Player.Any(p => p == playerIndex);
}
public bool IsAvailableAll(List<int> playerIndices)
public bool IsAvailableAll(IEnumerable<int> playerIndices)
{
bool result = true;
foreach (int p in playerIndices)
result &= IsAvailable(p);
return result;
return playerIndices.All(IsAvailable);
}
public bool IsAvailableSomeone(List<int> playerIndices)
public bool IsAvailableSomeone(IEnumerable<int> playerIndices)
{
bool result = false;
foreach (int p in playerIndices)
result |= IsAvailable(p);
return result;
return playerIndices.Any(IsAvailable);
}
}
}
@@ -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.Collections.Generic;
using System.Runtime.InteropServices;
@@ -40,17 +59,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public int Position;
public int PlayerID;
public int NumPlayed;
public int NumRounds;
public int NumWon;
public int NumSingPoints;
public int NumGamePoints;
public int CompareTo(object obj)
{
if (obj is CResultTableRow)
CResultTableRow row = obj as CResultTableRow;
if (row != null)
{
CResultTableRow row = (CResultTableRow)obj;
int res = row.NumGamePoints.CompareTo(NumGamePoints);
if (res == 0)
{
@@ -84,7 +101,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public struct SFromScreenNames
{
public bool FadeToConfig;
public bool FadeToMain;
public List<int> ProfileIDs;
}
@@ -164,14 +180,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ToScreenNames = new SDataToScreenNames();
_ToScreenMain = new SDataToScreenMain();
_GameData = new SData();
_GameData.NumPlayer = 4;
_GameData.NumPlayerAtOnce = 2;
_GameData.NumRounds = 2;
_GameData.CurrentRoundNr = 1;
_GameData.ProfileIDs = new List<int>();
_GameData.CatSongIndices = null;
_GameData.Results = null;
_GameData = new SData {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 2, CurrentRoundNr = 1, ProfileIDs = new List<int>(), CatSongIndices = null, Results = null};
}
public override bool Init()
@@ -197,7 +206,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public override void DataFromScreen(string screenName, Object data)
{
SDataFromScreen dataFrom = new SDataFromScreen();
SDataFromScreen dataFrom;
switch (screenName)
{
case "PartyScreenChallengeMedleyConfig":
@@ -357,10 +366,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
return _ScreenSongOptions;
}
// ReSharper disable RedundantAssignment
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)
{
@@ -377,7 +387,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
screenSongOptions = _ScreenSongOptions;
}
// ReSharper disable RedundantAssignment
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{
if (_GameData.CatSongIndices != null && categoryIndex != -1)
{
@@ -470,33 +482,22 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
#region PlayerNames
CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce);
SPlayer[] player = CBase.Game.GetPlayer();
SPlayer[] player = CBase.Game.GetPlayers();
if (player == null)
return false;
if (player.Length < _GameData.NumPlayerAtOnce)
return false;
SProfile[] profiles = CBase.Profiles.GetProfiles();
CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1);
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
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
@@ -504,8 +505,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
if (CBase.Songs.GetNumVisibleSongs() < _NumSongs)
CBase.Songs.ResetPartySongSung();
EGameMode gm = EGameMode.TR_GAMEMODE_MEDLEY;
List<int> iDs = new List<int>();
const EGameMode gm = EGameMode.TR_GAMEMODE_MEDLEY;
List<int> ids = new List<int>();
CSong[] visSongs = CBase.Songs.GetSongsNotSung();
if (visSongs == null)
@@ -520,11 +521,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
foreach (EGameMode mode in visSongs[i].AvailableGameModes)
{
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.Graphics.FadeTo(EScreens.ScreenParty);
@@ -532,12 +533,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
}
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.Songs.AddPartySongSung(songID);
iDs.Remove(songID);
ids.Remove(songID);
s++;
}
return true;
@@ -616,13 +617,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
for (int i = 0; i < _GameData.NumPlayer; i++)
{
CResultTableRow row = new CResultTableRow();
row.PlayerID = _GameData.ProfileIDs[i];
row.NumPlayed = 0;
row.NumRounds = 0;
row.NumWon = 0;
row.NumSingPoints = 0;
row.NumGamePoints = 0;
CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0};
_GameData.ResultTable.Add(row);
}
@@ -682,7 +677,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
row.NumPlayed++;
row.NumWon += points[i].Won;
row.NumRounds += 1;
row.NumSingPoints += points[i].SingPoints;
row.NumGamePoints += points[i].GamePoints;
@@ -697,13 +691,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
int pos = 1;
int lastPoints = 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++;
_GameData.ResultTable[i].Position = pos;
lastPoints = _GameData.ResultTable[i].NumGamePoints;
lastSingPoints = _GameData.ResultTable[i].NumSingPoints;
resultRow.Position = pos;
lastPoints = resultRow.NumGamePoints;
lastSingPoints = resultRow.NumSingPoints;
}
}
@@ -712,15 +706,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
List<SStats> result = new List<SStats>();
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
{
SStats stat = new SStats();
stat.ProfileID = results[i].ProfileID;
stat.SingPoints = (int)Math.Round(results[i].Points);
stat.Won = 0;
stat.GamePoints = 0;
SStats stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0};
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 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.Windows.Forms;
using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.ChallengeMedley
{
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMedleyConfig : CMenuParty
// ReSharper restore UnusedMember.Global
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
@@ -32,20 +53,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
_Data = new SDataFromScreen();
SFromScreenConfig config = new SFromScreenConfig();
config.NumPlayer = 4;
config.NumPlayerAtOnce = 2;
config.NumRounds = 12;
SFromScreenConfig config = new SFromScreenConfig {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 12};
_Data.ScreenConfig = config;
}
public override void DataToScreen(object receivedData)
{
SDataToScreenConfig config = new SDataToScreenConfig();
try
{
config = (SDataToScreenConfig)receivedData;
SDataToScreenConfig config = (SDataToScreenConfig)receivedData;
_Data.ScreenConfig.NumPlayer = config.NumPlayer;
_Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce;
_Data.ScreenConfig.NumRounds = config.NumRounds;
@@ -73,10 +89,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
case Keys.Enter:
_UpdateSlides();
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
break;
@@ -96,13 +112,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
_UpdateSlides();
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
}
@@ -139,10 +155,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _RebuildSlides()
{
// build num player slide (min player ... max player);
SelectSlides[_SelectSlideNumPlayers].Clear();
_SelectSlides[_SelectSlideNumPlayers].Clear();
for (int i = _PartyMode.GetMinPlayer(); i <= _PartyMode.GetMaxPlayer(); i++)
SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString());
SelectSlides[_SelectSlideNumPlayers].Selection = _Data.ScreenConfig.NumPlayer - _PartyMode.GetMinPlayer();
_SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString());
_SelectSlides[_SelectSlideNumPlayers].Selection = _Data.ScreenConfig.NumPlayer - _PartyMode.GetMinPlayer();
_UpdateMicsAtOnce();
_SetRoundSteps();
@@ -153,9 +169,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
int player = _Data.ScreenConfig.NumPlayer;
int mics = _Data.ScreenConfig.NumPlayerAtOnce;
_Data.ScreenConfig.NumPlayer = SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumPlayerAtOnce = SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumRounds = (SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps;
_Data.ScreenConfig.NumPlayer = _SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumPlayerAtOnce = _SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.GetMinPlayer();
_Data.ScreenConfig.NumRounds = (_SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps;
_UpdateMicsAtOnce();
_SetRoundSteps();
@@ -182,19 +198,19 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_Data.ScreenConfig.NumPlayerAtOnce = maxNum;
// build mics at once slide
SelectSlides[_SelectSlideNumMics].Clear();
_SelectSlides[_SelectSlideNumMics].Clear();
for (int i = 1; i <= maxNum; i++)
SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
SelectSlides[_SelectSlideNumMics].Selection = _Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
_SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
_SelectSlides[_SelectSlideNumMics].Selection = _Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
}
private void _UpdateSlideRounds()
{
// build num rounds slide
SelectSlides[_SelectSlideNumRounds].Clear();
_SelectSlides[_SelectSlideNumRounds].Clear();
for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString());
SelectSlides[_SelectSlideNumRounds].Selection = _Data.ScreenConfig.NumRounds / _RoundSteps - 1;
_SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString());
_SelectSlides[_SelectSlideNumRounds].Selection = _Data.ScreenConfig.NumRounds / _RoundSteps - 1;
}
private void _SetRoundSteps()
@@ -208,10 +224,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
int res = _Data.ScreenConfig.NumPlayer / _Data.ScreenConfig.NumPlayerAtOnce;
int mod = _Data.ScreenConfig.NumPlayer % _Data.ScreenConfig.NumPlayerAtOnce;
if (mod == 0)
_RoundSteps = res;
else
_RoundSteps = _Data.ScreenConfig.NumPlayer;
_RoundSteps = mod == 0 ? res : _Data.ScreenConfig.NumPlayer;
}
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.Collections.Generic;
using System.Windows.Forms;
@@ -22,7 +41,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public List<CText> TextScores;
}
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMedleyMain : CMenuParty
// ReSharper restore UnusedMember.Global
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
@@ -72,13 +93,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private SRectF _PlayerTableScrollArea;
private int _RoundsTableOffset;
private int _PlayerTableOffset;
private int _NumPlayerVisible = 10;
private const int _NumPlayerVisible = 10;
private int _NumRoundsVisible = 3;
public CPartyScreenChallengeMedleyMain()
{
_Data = new SDataFromScreen();
_Data.ScreenMain = new SFromScreenMain();
_Data = new SDataFromScreen {ScreenMain = new SFromScreenMain()};
}
public override void Init()
@@ -87,11 +107,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_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
};
_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};
}
@@ -107,20 +131,18 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
for (int i = 0; i < _PartyMode.GetMaxPlayer(); i++)
{
_NextPlayerTexts.Add(GetNewText(Texts[_TextNextPlayer]));
AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]);
_NextPlayerStatics.Add(GetNewStatic(Statics[_StaticNextPlayer]));
AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]);
_NextPlayerTexts.Add(GetNewText(_Texts[_TextNextPlayer]));
_AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]);
_NextPlayerStatics.Add(GetNewStatic(_Statics[_StaticNextPlayer]));
_AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]);
}
}
public override void DataToScreen(object receivedData)
{
SDataToScreenMain data = new SDataToScreenMain();
try
{
data = (SDataToScreenMain)receivedData;
SDataToScreenMain data = (SDataToScreenMain)receivedData;
_GameState = data;
}
catch (Exception e)
@@ -154,26 +176,26 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
case Keys.Enter:
if (!_ExitPopupVisible)
{
if (Buttons[_ButtonNextRound].Selected)
if (_Buttons[_ButtonNextRound].Selected)
_NextRound();
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
if (_Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
_Back();
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
if (_Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
_ShowPopup(true);
if (Buttons[_ButtonPlayerScrollUp].Selected)
if (_Buttons[_ButtonPlayerScrollUp].Selected)
_ScrollPlayerTable(-1);
if (Buttons[_ButtonPlayerScrollDown].Selected)
if (_Buttons[_ButtonPlayerScrollDown].Selected)
_ScrollPlayerTable(1);
if (Buttons[_ButtonRoundsScrollUp].Selected)
if (_Buttons[_ButtonRoundsScrollUp].Selected)
_ScrollRoundsTable(-1);
if (Buttons[_ButtonRoundsScrollDown].Selected)
if (_Buttons[_ButtonRoundsScrollDown].Selected)
_ScrollRoundsTable(1);
}
else
{
if (Buttons[_ButtonPopupYes].Selected)
if (_Buttons[_ButtonPopupYes].Selected)
_EndParty();
if (Buttons[_ButtonPopupNo].Selected)
if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false);
}
break;
@@ -186,30 +208,30 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
if (!_ExitPopupVisible)
{
if (Buttons[_ButtonNextRound].Selected)
if (_Buttons[_ButtonNextRound].Selected)
_NextRound();
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
if (_Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
_Back();
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
if (_Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
_ShowPopup(true);
if (Buttons[_ButtonPlayerScrollUp].Selected)
if (_Buttons[_ButtonPlayerScrollUp].Selected)
_ScrollPlayerTable(-1);
if (Buttons[_ButtonPlayerScrollDown].Selected)
if (_Buttons[_ButtonPlayerScrollDown].Selected)
_ScrollPlayerTable(1);
if (Buttons[_ButtonRoundsScrollUp].Selected)
if (_Buttons[_ButtonRoundsScrollUp].Selected)
_ScrollRoundsTable(-1);
if (Buttons[_ButtonRoundsScrollDown].Selected)
if (_Buttons[_ButtonRoundsScrollDown].Selected)
_ScrollRoundsTable(1);
}
else
{
if (Buttons[_ButtonPopupYes].Selected)
if (_Buttons[_ButtonPopupYes].Selected)
_EndParty();
if (Buttons[_ButtonPopupNo].Selected)
if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false);
}
}
@@ -256,29 +278,29 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
if (_GameState.CurrentRoundNr == 1)
{
Buttons[_ButtonBack].Visible = true;
Buttons[_ButtonExit].Visible = false;
_Buttons[_ButtonBack].Visible = true;
_Buttons[_ButtonExit].Visible = false;
}
else
{
Buttons[_ButtonBack].Visible = false;
Buttons[_ButtonExit].Visible = true;
_Buttons[_ButtonBack].Visible = false;
_Buttons[_ButtonExit].Visible = true;
}
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{
Buttons[_ButtonNextRound].Visible = true;
Texts[_TextFinishMessage].Visible = false;
Texts[_TextFinishPlayerWin].Visible = false;
SetInteractionToButton(Buttons[_ButtonNextRound]);
_Buttons[_ButtonNextRound].Visible = true;
_Texts[_TextFinishMessage].Visible = false;
_Texts[_TextFinishPlayerWin].Visible = false;
_SetInteractionToButton(_Buttons[_ButtonNextRound]);
}
else
{
Buttons[_ButtonNextRound].Visible = false;
Texts[_TextFinishMessage].Visible = true;
Texts[_TextFinishPlayerWin].Visible = true;
Texts[_TextFinishPlayerWin].Text = _GetPlayerWinString();
SetInteractionToButton(Buttons[_ButtonExit]);
_Buttons[_ButtonNextRound].Visible = false;
_Texts[_TextFinishMessage].Visible = true;
_Texts[_TextFinishPlayerWin].Visible = true;
_Texts[_TextFinishPlayerWin].Text = _GetPlayerWinString();
_SetInteractionToButton(_Buttons[_ButtonExit]);
}
_ShowPopup(false);
@@ -311,13 +333,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
_ExitPopupVisible = visible;
Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
_Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
_Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
_Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
_Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
if (_ExitPopupVisible)
SetInteractionToButton(Buttons[_ButtonPopupNo]);
_SetInteractionToButton(_Buttons[_ButtonPopupNo]);
}
private void _Back()
@@ -329,9 +351,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateNextPlayerPositions()
{
float x = CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2;
float staticY = 590;
float textY = 550;
float x = (float)CBase.Settings.GetRenderW() / 2 - ((_GameState.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_GameState.NumPlayerAtOnce - 1) * 15)) / 2;
const float staticY = 590;
const float textY = 550;
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{
//static
@@ -339,11 +361,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_NextPlayerStatics[i].Rect.Y = staticY;
_NextPlayerStatics[i].Visible = true;
//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].Visible = true;
x += Statics[_StaticNextPlayer].Rect.W + 15;
x += _Statics[_StaticNextPlayer].Rect.W + 15;
}
for (int i = _GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
{
@@ -356,7 +378,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{
Texts[_TextNextPlayerMessage].Visible = true;
_Texts[_TextNextPlayerMessage].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{
@@ -368,7 +390,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
}
else
{
Texts[_TextNextPlayerMessage].Visible = false;
_Texts[_TextNextPlayerMessage].Visible = false;
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{
_NextPlayerStatics[i].Visible = false;
@@ -383,30 +405,28 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_RoundsTable = new List<CRoundsTableRow>();
for (int i = 0; i < 5; i++)
{
CRoundsTableRow rtr = new CRoundsTableRow();
rtr.TextPlayer = new List<CText>();
rtr.TextScores = new List<CText>();
CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()};
_RoundsTable.Add(rtr);
}
//Create statics and texts for rounds
for (int round = 0; round < _RoundsTable.Count; round++)
foreach (CRoundsTableRow roundRow in _RoundsTable)
{
//Round-number
CText text = GetNewText(Texts[_TextRoundNumber]);
AddText(text);
_RoundsTable[round].Number = text;
CText text = GetNewText(_Texts[_TextRoundNumber]);
_AddText(text);
roundRow.Number = text;
for (int row = 0; row < 2; row++)
{
for (int column = 0; column < 3; column++)
{
//Player
text = GetNewText(Texts[_TextRoundPlayer]);
AddText(text);
_RoundsTable[round].TextPlayer.Add(text);
text = GetNewText(_Texts[_TextRoundPlayer]);
_AddText(text);
roundRow.TextPlayer.Add(text);
//Score
text = GetNewText(Texts[_TextRoundScore]);
AddText(text);
_RoundsTable[round].TextScores.Add(text);
text = GetNewText(_Texts[_TextRoundScore]);
_AddText(text);
roundRow.TextScores.Add(text);
}
}
}
@@ -416,30 +436,27 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
_RoundsTableScrollArea = new SRectF();
int numPlayerInOneRow = 3;
if (_GameState.NumPlayerAtOnce <= numPlayerInOneRow)
_NumRoundsVisible = 5;
else
_NumRoundsVisible = 3;
const int numPlayerInOneRow = 3;
_NumRoundsVisible = _GameState.NumPlayerAtOnce <= numPlayerInOneRow ? 5 : 3;
if (_NumRoundsVisible > _GameState.Combs.Count)
_NumRoundsVisible = _GameState.Combs.Count;
float numberX = Texts[_TextRoundNumber].X;
float numberY = Texts[_TextRoundNumber].Y;
float numberX = _Texts[_TextRoundNumber].X;
float numberY = _Texts[_TextRoundNumber].Y;
_RoundsTableScrollArea.X = numberX;
_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
for (int round = 0; round < _RoundsTable.Count; round++)
foreach (CRoundsTableRow roundRow in _RoundsTable)
{
//Round-number
_RoundsTable[round].Number.X = numberX;
_RoundsTable[round].Number.Y = numberY;
roundRow.Number.X = numberX;
roundRow.Number.Y = numberY;
int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow));
for (int row = 0; row < numInnerRows; row++)
{
@@ -453,17 +470,17 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
for (int column = row * numPlayerInOneRow; column < num; column++)
{
//Player
float x = numberX + 15 + (CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) +
((CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2;
float maxw = ((CBase.Settings.GetRenderW() - Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5;
_RoundsTable[round].TextPlayer[column].X = x;
_RoundsTable[round].TextPlayer[column].Y = numberY;
_RoundsTable[round].TextPlayer[column].MaxWidth = maxw;
float x = numberX + 15 + (CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) +
((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2;
float maxw = ((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5;
roundRow.TextPlayer[column].X = x;
roundRow.TextPlayer[column].Y = numberY;
roundRow.TextPlayer[column].MaxWidth = maxw;
//Score
_RoundsTable[round].TextScores[column] = _RoundsTable[round].TextScores[column];
_RoundsTable[round].TextScores[column].X = x;
_RoundsTable[round].TextScores[column].Y = numberY + delta;
_RoundsTable[round].TextScores[column].MaxWidth = maxw;
roundRow.TextScores[column] = roundRow.TextScores[column];
roundRow.TextScores[column].X = x;
roundRow.TextScores[column].Y = numberY + delta;
roundRow.TextScores[column].MaxWidth = maxw;
}
numberY = numberY + delta + delta;
}
@@ -484,7 +501,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_RoundsTable[i].Number.Visible = true;
_RoundsTable[i].TextPlayer[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]];
_RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset)
@@ -509,32 +526,30 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
}
}
Buttons[_ButtonRoundsScrollUp].Visible = _RoundsTableOffset > 0;
Buttons[_ButtonRoundsScrollDown].Visible = _GameState.Combs.Count - _NumRoundsVisible - _RoundsTableOffset > 0;
_Buttons[_ButtonRoundsScrollUp].Visible = _RoundsTableOffset > 0;
_Buttons[_ButtonRoundsScrollDown].Visible = _GameState.Combs.Count - _NumRoundsVisible - _RoundsTableOffset > 0;
}
private void _BuildPlayerTable()
{
_PlayerTableScrollArea = new SRectF();
_PlayerTableScrollArea.X = Texts[_TextPosition].X;
_PlayerTableScrollArea.Y = Texts[_TextPosition].Y;
_PlayerTableScrollArea.W = Texts[_TextGamePoints].X - Texts[_TextPosition].X;
_PlayerTableScrollArea = new SRectF {X = _Texts[_TextPosition].X, Y = _Texts[_TextPosition].Y, W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X};
_PlayerTable = new List<STableRow>();
float delta = Texts[_TextPosition].Height * 1.2f;
float delta = _Texts[_TextPosition].Height * 1.2f;
float h = 0;
for (int i = 0; i < 10; i++)
{
STableRow row = new STableRow();
row.Pos = GetNewText(Texts[_TextPosition]);
row.Name = GetNewText(Texts[_TextPlayerName]);
row.Rounds = GetNewText(Texts[_TextNumPlayed]);
row.Won = GetNewText(Texts[_TextWon]);
row.SingPoints = GetNewText(Texts[_TextSingPoints]);
row.GamePoints = GetNewText(Texts[_TextGamePoints]);
STableRow row = new STableRow
{
Pos = GetNewText(_Texts[_TextPosition]),
Name = GetNewText(_Texts[_TextPlayerName]),
Rounds = GetNewText(_Texts[_TextNumPlayed]),
Won = GetNewText(_Texts[_TextWon]),
SingPoints = GetNewText(_Texts[_TextSingPoints]),
GamePoints = GetNewText(_Texts[_TextGamePoints])
};
row.Pos.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.GamePoints.Y += delta * (i + 1);
row.Pos.Text = (i + 1).ToString() + ".";
row.Pos.Text = (i + 1) + ".";
row.Pos.Visible = false;
row.Name.Visible = false;
@@ -552,12 +567,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
row.SingPoints.Visible = false;
row.GamePoints.Visible = false;
AddText(row.Pos);
AddText(row.Name);
AddText(row.Rounds);
AddText(row.Won);
AddText(row.SingPoints);
AddText(row.GamePoints);
_AddText(row.Pos);
_AddText(row.Name);
_AddText(row.Rounds);
_AddText(row.Won);
_AddText(row.SingPoints);
_AddText(row.GamePoints);
_PlayerTable.Add(row);
@@ -583,9 +598,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
row.SingPoints.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.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumRounds.ToString();
row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString();
row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString();
row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString();
row.GamePoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumGamePoints.ToString();
@@ -601,8 +616,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
}
}
Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0;
Buttons[_ButtonPlayerScrollDown].Visible = _GameState.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0;
_Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0;
_Buttons[_ButtonPlayerScrollDown].Visible = _GameState.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0;
}
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.Collections.Generic;
using System.Windows.Forms;
@@ -5,7 +24,9 @@ using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.ChallengeMedley
{
// ReSharper disable UnusedMember.Global
public class CPartyScreenChallengeMedleyNames : CMenuParty
// ReSharper restore UnusedMember.Global
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
@@ -22,7 +43,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private List<CButton> _PlayerDestinationButtons;
//PlayerDestinationButtons-Option
private const int _PlayerDestinationButtonsNumH = 3;
private const int _PlayerDestinationButtonsNumW = 4;
private const int _PlayerDestinationButtonsFirstX = 900;
private const int _PlayerDestinationButtonsFirstY = 105;
private const int _PlayerDestinationButtonsSpaceH = 15;
@@ -35,7 +55,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private const int _PlayerChooseButtonsFirstY = 105;
private const int _PlayerChooseButtonsSpaceH = 15;
private const int _PlayerChooseButtonsSpaceW = 25;
private int _PlayerChooseButtonsOffset = 0;
private const int _PlayerChooseButtonsOffset = 0;
private CStatic _ChooseAvatarStatic;
private bool _SelectingMouseActive;
@@ -65,27 +85,19 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_Data.ScreenNames.ProfileIDs = new List<int>();
List<string> buttons = new List<string>();
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose};
_Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames();
names.FadeToConfig = false;
names.FadeToMain = false;
names.ProfileIDs = new List<int>();
SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, ProfileIDs = new List<int>()};
_Data.ScreenNames = names;
}
public override void DataToScreen(object receivedData)
{
SDataToScreenNames config = new SDataToScreenNames();
try
{
config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDs = config.ProfileIDs;
if (_Data.ScreenNames.ProfileIDs == null)
_Data.ScreenNames.ProfileIDs = new List<int>();
SDataToScreenNames config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDs = config.ProfileIDs ?? new List<int>();
_NumPlayer = config.NumPlayer;
@@ -113,10 +125,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
break;
case Keys.Enter:
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
if (!_OnAdd())
@@ -218,12 +230,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ChooseAvatarStatic.Visible = false;
}
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
if (!_OnAdd())
@@ -268,13 +280,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _AddButtonPlayerDestination()
{
Buttons[_ButtonPlayerDestination].Visible = false;
_Buttons[_ButtonPlayerDestination].Visible = false;
_PlayerDestinationButtons = new List<CButton>();
int row = 0;
int column = 0;
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.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW);
_PlayerDestinationButtons.Add(b);
@@ -286,24 +298,22 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
}
b.Visible = true;
b.Enabled = false;
AddButton(b);
_AddButton(b);
}
}
private void _AddButtonPlayerChoose()
{
Buttons[_ButtonPlayerChoose].Visible = false;
_Buttons[_ButtonPlayerChoose].Visible = false;
_PlayerChooseButtons = new List<CPlayerChooseButton>();
int row = 0;
int column = 0;
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.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW);
CPlayerChooseButton pcb = new CPlayerChooseButton();
pcb.Button = b;
pcb.ProfileID = -1;
CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1};
_PlayerChooseButtons.Add(pcb);
column++;
if (column >= _PlayerChooseButtonsNumH)
@@ -313,7 +323,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
}
b.Visible = true;
b.Enabled = false;
AddButton(b);
_AddButton(b);
}
}
@@ -329,7 +339,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateButtonPlayerChoose(int offset)
{
int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
const int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
if (offset < 0)
offset = 0;
@@ -341,8 +351,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
_PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose];
_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.SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.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.SelColor = new SColorF(1, 1, 1, 1);
_PlayerChooseButtons[i].Button.Enabled = true;
@@ -351,10 +363,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
_PlayerChooseButtons[i].ProfileID = -1;
_PlayerChooseButtons[i].Button.Text.Text = String.Empty;
_PlayerChooseButtons[i].Button.Texture = Buttons[_ButtonPlayerChoose].Texture;
_PlayerChooseButtons[i].Button.SelTexture = Buttons[_ButtonPlayerChoose].SelTexture;
_PlayerChooseButtons[i].Button.Color = Buttons[_ButtonPlayerChoose].Color;
_PlayerChooseButtons[i].Button.SelColor = Buttons[_ButtonPlayerChoose].SelColor;
_PlayerChooseButtons[i].Button.Texture = _Buttons[_ButtonPlayerChoose].Texture;
_PlayerChooseButtons[i].Button.SelTexture = _Buttons[_ButtonPlayerChoose].SelTexture;
_PlayerChooseButtons[i].Button.Color = _Buttons[_ButtonPlayerChoose].Color;
_PlayerChooseButtons[i].Button.SelColor = _Buttons[_ButtonPlayerChoose].SelColor;
_PlayerChooseButtons[i].Button.Enabled = false;
}
}
@@ -418,10 +430,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
}
else
{
_PlayerDestinationButtons[i].Color = Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i].SelColor = Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i].Texture = Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i].SelTexture = Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i].Color = _Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i].SelColor = _Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i].Texture = _Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i].SelTexture = _Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i].Text.Text = String.Empty;
_PlayerDestinationButtons[i].Enabled = false;
}
@@ -432,34 +444,34 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
if (_Data.ScreenNames.ProfileIDs.Count == _NumPlayer)
{
Buttons[_ButtonNext].Visible = true;
SetInteractionToButton(Buttons[_ButtonNext]);
_Buttons[_ButtonNext].Visible = true;
_SetInteractionToButton(_Buttons[_ButtonNext]);
}
else
Buttons[_ButtonNext].Visible = false;
_Buttons[_ButtonNext].Visible = false;
}
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)
{
_Data.ScreenNames.ProfileIDs.Add(_PlayerChooseButtons[i].ProfileID);
_Data.ScreenNames.ProfileIDs.Add(chooseButton.ProfileID);
int added = _Data.ScreenNames.ProfileIDs.Count - 1;
_UpdateButtonNext();
//Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName;
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List
_UpdateButtonPlayerChoose();
CheckInteraction();
_CheckInteraction();
return true;
}
}
@@ -479,7 +491,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_UpdateButtonNext();
_UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose();
CheckInteraction();
_CheckInteraction();
return true;
}
}
@@ -490,14 +502,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _Back()
{
_Data.ScreenNames.FadeToConfig = true;
_Data.ScreenNames.FadeToMain = false;
_PartyMode.DataFromScreen(ThemeName, _Data);
}
private void _Next()
{
_Data.ScreenNames.FadeToConfig = false;
_Data.ScreenNames.FadeToMain = true;
_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.Collections.Generic;
using System.Runtime.InteropServices;
@@ -33,7 +52,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public int PointsTeam1;
public int PointsTeam2;
public int Winner;
public bool Finished = false;
public bool Finished;
}
#region Communication
@@ -62,8 +81,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
public int CurrentRoundNr;
public int Team;
public int NumPlayerTeam1;
public int NumPlayerTeam2;
public int NumFields;
public List<CRound> Rounds;
public List<int> Songs;
@@ -96,7 +113,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public struct SFromScreenNames
{
public bool FadeToConfig;
public bool FadeToMain;
public List<int> ProfileIDsTeam1;
public List<int> ProfileIDsTeam2;
}
@@ -184,24 +200,26 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ToScreenNames = new SDataToScreenNames();
_ToScreenMain = new SDataToScreenMain();
_GameData = new SData();
_GameData.NumFields = 9;
_GameData.NumPlayerTeam1 = 2;
_GameData.NumPlayerTeam2 = 2;
_GameData.ProfileIDsTeam1 = new List<int>();
_GameData.ProfileIDsTeam2 = new List<int>();
_GameData.PlayerTeam1 = new List<int>();
_GameData.PlayerTeam2 = new List<int>();
_GameData.CurrentRoundNr = 0;
_GameData.SingRoundNr = 0;
_GameData.SongSource = ESongSource.TR_ALLSONGS;
_GameData.PlaylistID = 0;
_GameData.CategoryID = 0;
_GameData.GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL;
_GameData.Rounds = new List<CRound>();
_GameData.Songs = new List<int>();
_GameData.NumJokerRandom = new int[2];
_GameData.NumJokerRetry = new int[2];
_GameData = new SData
{
NumFields = 9,
NumPlayerTeam1 = 2,
NumPlayerTeam2 = 2,
ProfileIDsTeam1 = new List<int>(),
ProfileIDsTeam2 = new List<int>(),
PlayerTeam1 = new List<int>(),
PlayerTeam2 = new List<int>(),
CurrentRoundNr = 0,
SingRoundNr = 0,
SongSource = ESongSource.TR_ALLSONGS,
PlaylistID = 0,
CategoryID = 0,
GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL,
Rounds = new List<CRound>(),
Songs = new List<int>(),
NumJokerRandom = new int[2],
NumJokerRetry = new int[2]
};
}
public override bool Init()
@@ -262,10 +280,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Stage = EStage.NotStarted;
else
{
if (CBase.Game.GetRandom(100) < 50)
_GameData.Team = 0;
else
_GameData.Team = 1;
_GameData.Team = CBase.Game.GetRandom(100) < 50 ? 0 : 1;
_GameData.ProfileIDsTeam1 = dataFrom.ScreenNames.ProfileIDsTeam1;
_GameData.ProfileIDsTeam2 = dataFrom.ScreenNames.ProfileIDsTeam2;
_Stage = EStage.Names;
@@ -358,15 +373,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen);
if (screen != null)
{
if (_GameData.Team == 1)
_GameData.Team = 0;
else
_GameData.Team = 1;
_GameData.Team = _GameData.Team == 1 ? 0 : 1;
CBase.Songs.ResetPartySongSung();
_GameData.CurrentRoundNr = 1;
_ToScreenMain.CurrentRoundNr = 1;
_ToScreenMain.NumPlayerTeam1 = _GameData.NumPlayerTeam1;
_ToScreenMain.NumPlayerTeam2 = _GameData.NumPlayerTeam2;
_ToScreenMain.NumFields = _GameData.NumFields;
_ToScreenMain.ProfileIDsTeam1 = _GameData.ProfileIDsTeam1;
_ToScreenMain.ProfileIDsTeam2 = _GameData.ProfileIDsTeam2;
@@ -391,15 +401,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen);
if (screen != null)
{
if (_GameData.Team == 1)
_GameData.Team = 0;
else
_GameData.Team = 1;
_GameData.Team = _GameData.Team == 1 ? 0 : 1;
_UpdateSongList();
_UpdatePlayerList();
_ToScreenMain.CurrentRoundNr = _GameData.CurrentRoundNr;
_ToScreenMain.NumPlayerTeam1 = _GameData.NumPlayerTeam1;
_ToScreenMain.NumPlayerTeam2 = _GameData.NumPlayerTeam2;
_ToScreenMain.NumFields = _GameData.NumFields;
_ToScreenMain.ProfileIDsTeam1 = _GameData.ProfileIDsTeam1;
_ToScreenMain.ProfileIDsTeam2 = _GameData.ProfileIDsTeam2;
@@ -437,12 +442,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
return _ScreenSongOptions;
}
// ReSharper disable RedundantAssignment
public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{
screenSongOptions = _ScreenSongOptions;
}
// ReSharper disable RedundantAssignment
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{
screenSongOptions = _ScreenSongOptions;
}
@@ -522,99 +531,101 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _PreparePlayerList(int team)
{
if (team == 0)
switch (team)
{
_GameData.PlayerTeam1 = new List<int>();
_GameData.PlayerTeam2 = new List<int>();
case 0:
{
_GameData.PlayerTeam1 = new List<int>();
_GameData.PlayerTeam2 = new List<int>();
//Prepare Player-IDs
List<int> iDs1 = new List<int>();
List<int> iDs2 = new List<int>();
int num = 0;
int random = 0;
//Add IDs to team-list
while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && iDs1.Count == 0 &&
_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && iDs2.Count == 0)
{
if (iDs1.Count == 0)
{
for (int i = 0; i < _GameData.NumPlayerTeam1; i++)
iDs1.Add(i);
//Prepare Player-IDs
List<int> ids1 = new List<int>();
List<int> ids2 = new List<int>();
//Add IDs to team-list
while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && ids1.Count == 0 &&
_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && ids2.Count == 0)
{
if (ids1.Count == 0)
{
for (int i = 0; i < _GameData.NumPlayerTeam1; i++)
ids1.Add(i);
}
if (ids2.Count == 0)
{
for (int i = 0; i < _GameData.NumPlayerTeam2; i++)
ids2.Add(i);
}
int num;
int random;
if (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0])
{
random = CBase.Game.GetRandom((ids1.Count - 1) * 10);
num = (int)Math.Round((double)random / 10);
if (num >= ids1.Count)
num = ids1.Count - 1;
_GameData.PlayerTeam1.Add(ids1[num]);
ids1.RemoveAt(num);
}
if (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1])
{
random = CBase.Game.GetRandom((ids2.Count - 1) * 20);
num = (int)Math.Round((double)random / 20);
if (num >= ids2.Count)
num = ids2.Count - 1;
_GameData.PlayerTeam2.Add(ids2[num]);
ids2.RemoveAt(num);
}
}
}
if (iDs2.Count == 0)
break;
case 1:
{
for (int i = 0; i < _GameData.NumPlayerTeam2; i++)
iDs2.Add(i);
//Prepare Player-IDs
List<int> ids = new List<int>();
//Add IDs to team-list
while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && ids.Count == 0)
{
if (ids.Count == 0)
{
for (int i = 0; i < _GameData.NumPlayerTeam1; i++)
ids.Add(i);
}
if (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0])
{
int random = CBase.Game.GetRandom((ids.Count - 1) * 10);
int num = (int)Math.Round((double)random / 10);
if (num >= ids.Count)
num = ids.Count - 1;
_GameData.PlayerTeam1.Add(ids[num]);
ids.RemoveAt(num);
}
}
}
if (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0])
break;
case 2:
{
random = CBase.Game.GetRandom((iDs1.Count - 1) * 10);
num = (int)Math.Round((double)random / 10);
if (num >= iDs1.Count)
num = iDs1.Count - 1;
_GameData.PlayerTeam1.Add(iDs1[num]);
iDs1.RemoveAt(num);
//Prepare Player-IDs
List<int> ids = new List<int>();
//Add IDs to team-list
while (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && ids.Count == 0)
{
if (ids.Count == 0)
{
for (int i = 0; i < _GameData.NumPlayerTeam2; i++)
ids.Add(i);
}
if (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1])
{
int random = CBase.Game.GetRandom((ids.Count - 1) * 20);
int num = (int)Math.Round((double)random / 20);
if (num >= ids.Count)
num = ids.Count - 1;
_GameData.PlayerTeam2.Add(ids[num]);
ids.RemoveAt(num);
}
}
}
if (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1])
{
random = CBase.Game.GetRandom((iDs2.Count - 1) * 20);
num = (int)Math.Round((double)random / 20);
if (num >= iDs2.Count)
num = iDs2.Count - 1;
_GameData.PlayerTeam2.Add(iDs2[num]);
iDs2.RemoveAt(num);
}
}
}
else if (team == 1)
{
//Prepare Player-IDs
List<int> iDs = new List<int>();
int num = 0;
int random = 0;
//Add IDs to team-list
while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && iDs.Count == 0)
{
if (iDs.Count == 0)
{
for (int i = 0; i < _GameData.NumPlayerTeam1; i++)
iDs.Add(i);
}
if (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0])
{
random = CBase.Game.GetRandom((iDs.Count - 1) * 10);
num = (int)Math.Round((double)random / 10);
if (num >= iDs.Count)
num = iDs.Count - 1;
_GameData.PlayerTeam1.Add(iDs[num]);
iDs.RemoveAt(num);
}
}
}
else if (team == 2)
{
//Prepare Player-IDs
List<int> iDs = new List<int>();
int num = 0;
int random = 0;
//Add IDs to team-list
while (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && iDs.Count == 0)
{
if (iDs.Count == 0)
{
for (int i = 0; i < _GameData.NumPlayerTeam2; i++)
iDs.Add(i);
}
if (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1])
{
random = CBase.Game.GetRandom((iDs.Count - 1) * 20);
num = (int)Math.Round((double)random / 20);
if (num >= iDs.Count)
num = iDs.Count - 1;
_GameData.PlayerTeam2.Add(iDs[num]);
iDs.RemoveAt(num);
}
}
break;
}
}
@@ -707,7 +718,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
CBase.Game.SetNumPlayer(2);
SPlayer[] player = CBase.Game.GetPlayer();
SPlayer[] player = CBase.Game.GetPlayers();
if (player == null)
return;
@@ -721,8 +732,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
for (int i = 0; i < 2; i++)
{
//default values
player[i].Name = "foobar";
player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
player[i].ProfileID = -1;
}
@@ -731,24 +740,18 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
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];
if (isDuet)
player[0].LineNr = 0;
}
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];
if (isDuet)
player[1].LineNr = 1;
}
SongSelected(r.SongID);
}
else
return;
}
private void _SetNumJokers()
@@ -783,7 +786,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (!_GameData.Rounds[_GameData.SingRoundNr].Finished)
_GameData.CurrentRoundNr++;
SPlayer[] results = CBase.Game.GetPlayer();
SPlayer[] results = CBase.Game.GetPlayers();
if (results == null)
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.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.TicTacToe
{
// ReSharper disable UnusedMember.Global
public class CPartyScreenTicTacToeConfig : CMenuParty
// ReSharper restore UnusedMember.Global
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
@@ -31,28 +54,31 @@ namespace VocaluxeLib.PartyModes.TicTacToe
base.Init();
_ThemeSelectSlides = new string[]
{_SelectSlideNumPlayerTeam1, _SelectSlideNumPlayerTeam2, _SelectSlideNumFields, _SelectSlideSongSource, _SelectSlidePlaylist, _SelectSlideCategory, _SelectSlideGameMode};
{
_SelectSlideNumPlayerTeam1, _SelectSlideNumPlayerTeam2, _SelectSlideNumFields, _SelectSlideSongSource, _SelectSlidePlaylist, _SelectSlideCategory,
_SelectSlideGameMode
};
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
_Data = new SDataFromScreen();
SFromScreenConfig config = new SFromScreenConfig();
config.PlaylistID = 0;
config.NumFields = 9;
config.NumPlayerTeam1 = 2;
config.NumPlayerTeam2 = 2;
config.GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL;
config.CategoryID = 0;
config.SongSource = ESongSource.TR_ALLSONGS;
SFromScreenConfig config = new SFromScreenConfig
{
PlaylistID = 0,
NumFields = 9,
NumPlayerTeam1 = 2,
NumPlayerTeam2 = 2,
GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL,
CategoryID = 0,
SongSource = ESongSource.TR_ALLSONGS
};
_Data.ScreenConfig = config;
}
public override void DataToScreen(object receivedData)
{
SDataToScreenConfig config = new SDataToScreenConfig();
try
{
config = (SDataToScreenConfig)receivedData;
SDataToScreenConfig config = (SDataToScreenConfig)receivedData;
_Data.ScreenConfig.NumFields = config.NumFields;
_Data.ScreenConfig.NumPlayerTeam1 = config.NumPlayerTeam1;
_Data.ScreenConfig.NumPlayerTeam2 = config.NumPlayerTeam2;
@@ -84,10 +110,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case Keys.Enter:
_UpdateSlides();
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
break;
@@ -107,13 +133,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
_UpdateSlides();
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
}
@@ -136,7 +162,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public override bool UpdateGame()
{
Buttons[_ButtonNext].Visible = _ConfigOk;
_Buttons[_ButtonNext].Visible = _ConfigOk;
return true;
}
@@ -149,72 +175,72 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _FillSlides()
{
// 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++)
SelectSlides[_SelectSlideNumPlayerTeam1].AddValue(i.ToString());
SelectSlides[_SelectSlideNumPlayerTeam1].Selection = _Data.ScreenConfig.NumPlayerTeam1 - (_PartyMode.GetMinPlayer() / 2);
_SelectSlides[_SelectSlideNumPlayerTeam1].AddValue(i.ToString());
_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++)
SelectSlides[_SelectSlideNumPlayerTeam2].AddValue(i.ToString());
SelectSlides[_SelectSlideNumPlayerTeam2].Selection = _Data.ScreenConfig.NumPlayerTeam2 - (_PartyMode.GetMinPlayer() / 2);
_SelectSlides[_SelectSlideNumPlayerTeam2].AddValue(i.ToString());
_SelectSlides[_SelectSlideNumPlayerTeam2].Selection = _Data.ScreenConfig.NumPlayerTeam2 - (_PartyMode.GetMinPlayer() / 2);
SelectSlides[_SelectSlideNumFields].Clear();
SelectSlides[_SelectSlideNumFields].AddValue("9");
SelectSlides[_SelectSlideNumFields].AddValue("16");
SelectSlides[_SelectSlideNumFields].AddValue("25");
_SelectSlides[_SelectSlideNumFields].Clear();
_SelectSlides[_SelectSlideNumFields].AddValue("9");
_SelectSlides[_SelectSlideNumFields].AddValue("16");
_SelectSlides[_SelectSlideNumFields].AddValue("25");
if (_Data.ScreenConfig.NumFields == 9)
SelectSlides[_SelectSlideNumFields].Selection = 0;
_SelectSlides[_SelectSlideNumFields].Selection = 0;
else if (_Data.ScreenConfig.NumFields == 16)
SelectSlides[_SelectSlideNumFields].Selection = 1;
_SelectSlides[_SelectSlideNumFields].Selection = 1;
else if (_Data.ScreenConfig.NumFields == 25)
SelectSlides[_SelectSlideNumFields].Selection = 2;
_SelectSlides[_SelectSlideNumFields].Selection = 2;
SelectSlides[_SelectSlideSongSource].Clear();
SelectSlides[_SelectSlideSongSource].SetValues<ESongSource>((int)_Data.ScreenConfig.SongSource);
_SelectSlides[_SelectSlideSongSource].Clear();
_SelectSlides[_SelectSlideSongSource].SetValues<ESongSource>((int)_Data.ScreenConfig.SongSource);
string[] playlists = CBase.Playlist.GetPlaylistNames();
SelectSlides[_SelectSlidePlaylist].Clear();
for (int i = 0; i < playlists.Length; i++)
List<string> playlists = CBase.Playlist.GetPlaylistNames();
_SelectSlides[_SelectSlidePlaylist].Clear();
for (int i = 0; i < playlists.Count; i++)
{
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].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST;
_SelectSlides[_SelectSlidePlaylist].Selection = _Data.ScreenConfig.PlaylistID;
_SelectSlides[_SelectSlidePlaylist].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST;
string[] categories = new string[CBase.Songs.GetNumCategories()];
for (int i = 0; i < CBase.Songs.GetNumCategories(); i++)
categories[i] = CBase.Songs.GetCategory(i).Name;
SelectSlides[_SelectSlideCategory].Clear();
_SelectSlides[_SelectSlideCategory].Clear();
for (int i = 0; i < categories.Length; i++)
{
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].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY;
_SelectSlides[_SelectSlideCategory].Selection = _Data.ScreenConfig.CategoryID;
_SelectSlides[_SelectSlideCategory].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY;
SelectSlides[_SelectSlideGameMode].Visible = true;
SelectSlides[_SelectSlideGameMode].SetValues<EPartyGameMode>((int)_Data.ScreenConfig.GameMode);
_SelectSlides[_SelectSlideGameMode].Visible = true;
_SelectSlides[_SelectSlideGameMode].SetValues<EPartyGameMode>((int)_Data.ScreenConfig.GameMode);
}
private void _UpdateSlides()
{
_Data.ScreenConfig.NumPlayerTeam1 = SelectSlides[_SelectSlideNumPlayerTeam1].Selection + (_PartyMode.GetMinPlayer() / 2);
_Data.ScreenConfig.NumPlayerTeam2 = SelectSlides[_SelectSlideNumPlayerTeam2].Selection + (_PartyMode.GetMinPlayer() / 2);
_Data.ScreenConfig.NumPlayerTeam1 = _SelectSlides[_SelectSlideNumPlayerTeam1].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;
else if (SelectSlides[_SelectSlideNumFields].Selection == 1)
else if (_SelectSlides[_SelectSlideNumFields].Selection == 1)
_Data.ScreenConfig.NumFields = 16;
else if (SelectSlides[_SelectSlideNumFields].Selection == 2)
else if (_SelectSlides[_SelectSlideNumFields].Selection == 2)
_Data.ScreenConfig.NumFields = 25;
_Data.ScreenConfig.SongSource = (ESongSource)SelectSlides[_SelectSlideSongSource].Selection;
_Data.ScreenConfig.PlaylistID = SelectSlides[_SelectSlidePlaylist].Selection;
_Data.ScreenConfig.CategoryID = SelectSlides[_SelectSlideCategory].Selection;
_Data.ScreenConfig.GameMode = (EPartyGameMode)SelectSlides[_SelectSlideGameMode].Selection;
_Data.ScreenConfig.SongSource = (ESongSource)_SelectSlides[_SelectSlideSongSource].Selection;
_Data.ScreenConfig.PlaylistID = _SelectSlides[_SelectSlidePlaylist].Selection;
_Data.ScreenConfig.CategoryID = _SelectSlides[_SelectSlideCategory].Selection;
_Data.ScreenConfig.GameMode = (EPartyGameMode)_SelectSlides[_SelectSlideGameMode].Selection;
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++)
{
int id = CBase.Playlist.GetPlaylistSong(_Data.ScreenConfig.PlaylistID, i).SongID;
foreach (EGameMode mode in CBase.Songs.GetSongByID(id).AvailableGameModes)
{
if (mode == gm)
{
_ConfigOk = true;
break;
}
}
_ConfigOk = CBase.Songs.GetSongByID(id).AvailableGameModes.Any(mode => mode == gm);
if (_ConfigOk)
break;
}
@@ -271,14 +290,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ConfigOk = false;
for (int i = 0; i < CBase.Songs.NumSongsInCategory(_Data.ScreenConfig.CategoryID); i++)
{
foreach (EGameMode mode in CBase.Songs.GetVisibleSong(i).AvailableGameModes)
{
if (mode == gm)
{
_ConfigOk = true;
break;
}
}
_ConfigOk = CBase.Songs.GetVisibleSong(i).AvailableGameModes.Any(mode => mode == gm);
if (_ConfigOk)
break;
}
@@ -296,14 +308,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
for (int i = 0; i < CBase.Songs.GetNumSongs(); i++)
{
foreach (EGameMode mode in CBase.Songs.GetSongByID(i).AvailableGameModes)
{
if (mode == gm)
{
_ConfigOk = true;
break;
}
}
_ConfigOk = CBase.Songs.GetSongByID(i).AvailableGameModes.Any(mode => mode == gm);
if (_ConfigOk)
break;
}
@@ -311,8 +316,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
else
_ConfigOk = false;
}
SelectSlides[_SelectSlideCategory].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY;
SelectSlides[_SelectSlidePlaylist].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST;
_SelectSlides[_SelectSlideCategory].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY;
_SelectSlides[_SelectSlidePlaylist].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST;
}
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.Collections.Generic;
using System.Windows.Forms;
@@ -60,7 +79,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private List<CField> _Fields;
private float _FieldFirstX = 25;
private float _FieldFirstY = 25;
private int _FieldSpace = 10;
private const int _FieldSpace = 10;
private float _FieldSize = 100;
private int _PreviewStream = -1;
@@ -74,7 +93,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
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[]
{
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonField, _ButtonJokerRandomT1, _ButtonJokerRandomT2, _ButtonJokerRetryT1,
@@ -102,16 +122,14 @@ namespace VocaluxeLib.PartyModes.TicTacToe
base.LoadTheme(xmlPath);
_CreateFields();
Buttons[_ButtonField].Visible = false;
_Buttons[_ButtonField].Visible = false;
}
public override void DataToScreen(object receivedData)
{
SDataToScreenMain config = new SDataToScreenMain();
try
{
config = (SDataToScreenMain)receivedData;
SDataToScreenMain config = (SDataToScreenMain)receivedData;
_GameData = config;
}
catch (Exception e)
@@ -147,11 +165,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case Keys.Enter:
if (!_ExitPopupVisible)
{
if (Buttons[_ButtonNextRound].Selected)
if (_Buttons[_ButtonNextRound].Selected)
_NextRound();
if (Buttons[_ButtonBack].Selected && _GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
if (_Buttons[_ButtonBack].Selected && _GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
_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);
else if (_Status == EStatus.None)
_EndParty();
@@ -178,21 +196,21 @@ namespace VocaluxeLib.PartyModes.TicTacToe
}
if (_Status == EStatus.FieldSelected)
{
if (Buttons[_ButtonJokerRandomT1].Selected)
if (_Buttons[_ButtonJokerRandomT1].Selected)
_UseJoker(0, 0);
if (Buttons[_ButtonJokerRandomT2].Selected)
if (_Buttons[_ButtonJokerRandomT2].Selected)
_UseJoker(1, 0);
if (Buttons[_ButtonJokerRetryT1].Selected)
if (_Buttons[_ButtonJokerRetryT1].Selected)
_UseJoker(0, 1);
if (Buttons[_ButtonJokerRetryT2].Selected)
if (_Buttons[_ButtonJokerRetryT2].Selected)
_UseJoker(1, 1);
}
}
else
{
if (Buttons[_ButtonPopupYes].Selected)
if (_Buttons[_ButtonPopupYes].Selected)
_EndParty();
if (Buttons[_ButtonPopupNo].Selected)
if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false);
}
break;
@@ -205,15 +223,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
if (!_ExitPopupVisible)
{
if (Buttons[_ButtonNextRound].Selected)
if (_Buttons[_ButtonNextRound].Selected)
_NextRound();
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
{
if (_Status == EStatus.None)
_EndParty();
@@ -243,21 +261,21 @@ namespace VocaluxeLib.PartyModes.TicTacToe
}
if (_Status == EStatus.FieldSelected)
{
if (Buttons[_ButtonJokerRandomT1].Selected)
if (_Buttons[_ButtonJokerRandomT1].Selected)
_UseJoker(0, 0);
if (Buttons[_ButtonJokerRandomT2].Selected)
if (_Buttons[_ButtonJokerRandomT2].Selected)
_UseJoker(1, 0);
if (Buttons[_ButtonJokerRetryT1].Selected)
if (_Buttons[_ButtonJokerRetryT1].Selected)
_UseJoker(0, 1);
if (Buttons[_ButtonJokerRetryT2].Selected)
if (_Buttons[_ButtonJokerRetryT2].Selected)
_UseJoker(1, 1);
}
}
else
{
if (Buttons[_ButtonPopupYes].Selected)
if (_Buttons[_ButtonPopupYes].Selected)
_EndParty();
if (Buttons[_ButtonPopupNo].Selected)
if (_Buttons[_ButtonPopupNo].Selected)
_ShowPopup(false);
}
}
@@ -292,15 +310,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
_BuildWinnerPossibilities();
_SelectedField = -1;
Buttons[_ButtonBack].Visible = true;
Buttons[_ButtonExit].Visible = false;
SetInteractionToButton(Buttons[_ButtonBack]);
_Buttons[_ButtonBack].Visible = true;
_Buttons[_ButtonExit].Visible = false;
_SetInteractionToButton(_Buttons[_ButtonBack]);
}
else
{
Buttons[_ButtonBack].Visible = false;
Buttons[_ButtonExit].Visible = true;
SetInteractionToButton(Buttons[_ButtonExit]);
_Buttons[_ButtonBack].Visible = false;
_Buttons[_ButtonExit].Visible = true;
_SetInteractionToButton(_Buttons[_ButtonExit]);
}
_Status = EStatus.FieldChoosing;
@@ -312,37 +330,37 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (_GameData.CurrentRoundNr <= _GameData.NumFields && winner == 0)
{
_UpdateTeamChoosingMessage();
Texts[_TextNextPlayerT1].Visible = false;
Texts[_TextNextPlayerT2].Visible = false;
Texts[_TextNextPlayerNameT1].Visible = false;
Texts[_TextNextPlayerNameT2].Visible = false;
Statics[_StaticAvatarT1].Visible = false;
Statics[_StaticAvatarT2].Visible = false;
Buttons[_ButtonJokerRandomT1].Visible = false;
Buttons[_ButtonJokerRandomT2].Visible = false;
Buttons[_ButtonJokerRetryT1].Visible = false;
Buttons[_ButtonJokerRetryT2].Visible = false;
Buttons[_ButtonNextRound].Visible = false;
Texts[_TextFinishMessage].Visible = false;
_Texts[_TextNextPlayerT1].Visible = false;
_Texts[_TextNextPlayerT2].Visible = false;
_Texts[_TextNextPlayerNameT1].Visible = false;
_Texts[_TextNextPlayerNameT2].Visible = false;
_Statics[_StaticAvatarT1].Visible = false;
_Statics[_StaticAvatarT2].Visible = false;
_Buttons[_ButtonJokerRandomT1].Visible = false;
_Buttons[_ButtonJokerRandomT2].Visible = false;
_Buttons[_ButtonJokerRetryT1].Visible = false;
_Buttons[_ButtonJokerRetryT2].Visible = false;
_Buttons[_ButtonNextRound].Visible = false;
_Texts[_TextFinishMessage].Visible = false;
}
else
{
_Status = EStatus.None;
Buttons[_ButtonNextRound].Visible = false;
Texts[_TextFinishMessage].Visible = true;
Texts[_TextTeamChoosing].Visible = false;
_Buttons[_ButtonNextRound].Visible = false;
_Texts[_TextFinishMessage].Visible = true;
_Texts[_TextTeamChoosing].Visible = false;
if (winner > 0)
{
Texts[_TextFinishMessage].Color = CBase.Theme.GetPlayerColor(winner);
Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_WINNER", _PartyModeID) + " " + CBase.Language.Translate("TR_TEAM", _PartyModeID) + " " +
winner;
_Texts[_TextFinishMessage].Color = CBase.Theme.GetPlayerColor(winner);
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_WINNER", _PartyModeID) + " " + CBase.Language.Translate("TR_TEAM", _PartyModeID) + " " +
winner;
}
else
{
Texts[_TextFinishMessage].Color = new SColorF(1, 1, 1, 1);
Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", _PartyModeID);
_Texts[_TextFinishMessage].Color = new SColorF(1, 1, 1, 1);
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", _PartyModeID);
}
SetInteractionToButton(Buttons[_ButtonExit]);
_SetInteractionToButton(_Buttons[_ButtonExit]);
}
_ShowPopup(false);
@@ -370,11 +388,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
for (int i = 0; i < 25; i++)
{
CField f = new CField();
f.Button = GetNewButton(Buttons[_ButtonField]);
CField f = new CField {Button = GetNewButton(_Buttons[_ButtonField])};
f.Button.Visible = false;
f.Content = new CRound();
AddButton(f.Button);
_AddButton(f.Button);
_Fields.Add(f);
}
}
@@ -382,13 +399,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateFields()
{
int numOneRow = (int)Math.Sqrt(_GameData.NumFields);
float fieldSizeY = (CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow;
float fieldSizeX = (CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow;
if (fieldSizeX < fieldSizeY)
_FieldSize = fieldSizeX;
else
_FieldSize = fieldSizeY;
_FieldFirstX = CBase.Settings.GetRenderW() / 2 - (numOneRow * _FieldSize + (numOneRow - 1) * _FieldSpace) / 2;
float fieldSizeY = ((float)CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow;
float fieldSizeX = ((float)CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow;
_FieldSize = Math.Min(fieldSizeX, fieldSizeY);
_FieldFirstX = (float)CBase.Settings.GetRenderW() / 2 - (numOneRow * _FieldSize + (numOneRow - 1) * _FieldSpace) / 2;
_FieldFirstY = 140 + (CBase.Settings.GetRenderH() - 140) / 2 - (numOneRow * _FieldSize + numOneRow * _FieldSpace) / 2;
int row = 0;
int column = 0;
@@ -428,9 +442,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
for (int i = 0; i < _GameData.Rounds.Count; i++)
{
_Fields[i].Button.Enabled = true;
_Fields[i].Button.Texture = Buttons[_ButtonField].Texture;
_Fields[i].Button.Color = Buttons[_ButtonField].Color;
_Fields[i].Button.SelColor = Buttons[_ButtonField].SelColor;
_Fields[i].Button.Texture = _Buttons[_ButtonField].Texture;
_Fields[i].Button.Color = _Buttons[_ButtonField].Color;
_Fields[i].Button.SelColor = _Buttons[_ButtonField].SelColor;
_Fields[i].Content = _GameData.Rounds[i];
if (_Fields[i].Content.Finished)
{
@@ -495,25 +509,25 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_GameData.Rounds[_SelectedField].SingerTeam2 = singerTeam2;
_UpdateFieldContents();
Texts[_TextNextPlayerT1].Visible = true;
Texts[_TextNextPlayerT2].Visible = true;
Texts[_TextNextPlayerNameT1].Visible = true;
Texts[_TextNextPlayerNameT2].Visible = true;
_Texts[_TextNextPlayerT1].Visible = true;
_Texts[_TextNextPlayerT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Visible = true;
_Texts[_TextNextPlayerNameT2].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles();
Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName;
Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName;
Statics[_StaticAvatarT1].Visible = true;
Statics[_StaticAvatarT2].Visible = true;
Statics[_StaticAvatarT1].Texture = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].Avatar.Texture;
Statics[_StaticAvatarT2].Texture = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].Avatar.Texture;
_Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName;
_Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName;
_Statics[_StaticAvatarT1].Visible = true;
_Statics[_StaticAvatarT2].Visible = true;
_Statics[_StaticAvatarT1].Texture = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].Avatar.Texture;
_Statics[_StaticAvatarT2].Texture = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].Avatar.Texture;
_UpdateJokerButtons();
Buttons[_ButtonNextRound].Visible = true;
Buttons[_ButtonExit].Visible = true;
Buttons[_ButtonBack].Visible = false;
_Buttons[_ButtonNextRound].Visible = true;
_Buttons[_ButtonExit].Visible = true;
_Buttons[_ButtonBack].Visible = false;
SetInteractionToButton(Buttons[_ButtonNextRound]);
_SetInteractionToButton(_Buttons[_ButtonNextRound]);
}
private void _FieldSelectedAgain()
@@ -534,25 +548,25 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_GameData.Rounds[_SelectedField].SingerTeam2 = _GameData.Rounds[_OldSelectedField].SingerTeam2;
_UpdateFieldContents();
Texts[_TextNextPlayerT1].Visible = true;
Texts[_TextNextPlayerT2].Visible = true;
Texts[_TextNextPlayerNameT1].Visible = true;
Texts[_TextNextPlayerNameT2].Visible = true;
_Texts[_TextNextPlayerT1].Visible = true;
_Texts[_TextNextPlayerT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Visible = true;
_Texts[_TextNextPlayerNameT2].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles();
Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName;
Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName;
Statics[_StaticAvatarT1].Visible = true;
Statics[_StaticAvatarT2].Visible = true;
Statics[_StaticAvatarT1].Texture = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].Avatar.Texture;
Statics[_StaticAvatarT2].Texture = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].Avatar.Texture;
_Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName;
_Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName;
_Statics[_StaticAvatarT1].Visible = true;
_Statics[_StaticAvatarT2].Visible = true;
_Statics[_StaticAvatarT1].Texture = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].Avatar.Texture;
_Statics[_StaticAvatarT2].Texture = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].Avatar.Texture;
_UpdateJokerButtons();
Buttons[_ButtonNextRound].Visible = true;
Buttons[_ButtonExit].Visible = true;
Buttons[_ButtonBack].Visible = false;
_Buttons[_ButtonNextRound].Visible = true;
_Buttons[_ButtonExit].Visible = true;
_Buttons[_ButtonBack].Visible = false;
SetInteractionToButton(Buttons[_ButtonNextRound]);
_SetInteractionToButton(_Buttons[_ButtonNextRound]);
}
private void _UseJoker(int teamNr, int jokerNum)
@@ -590,29 +604,29 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateTeamChoosingMessage()
{
Texts[_TextTeamChoosing].Color = CBase.Theme.GetPlayerColor(_GameData.Team + 1);
Texts[_TextTeamChoosing].Text = CBase.Language.Translate("TR_TEAM", _PartyModeID) + " " + (_GameData.Team + 1) + "! " +
CBase.Language.Translate("TR_SCREENMAIN_TEAM_CHOOSE", _PartyModeID);
_Texts[_TextTeamChoosing].Color = CBase.Theme.GetPlayerColor(_GameData.Team + 1);
_Texts[_TextTeamChoosing].Text = CBase.Language.Translate("TR_TEAM", _PartyModeID) + " " + (_GameData.Team + 1) + "! " +
CBase.Language.Translate("TR_SCREENMAIN_TEAM_CHOOSE", _PartyModeID);
if (_Status == EStatus.JokerRetry || _Status == EStatus.FieldChoosing)
Texts[_TextTeamChoosing].Visible = true;
_Texts[_TextTeamChoosing].Visible = true;
else
Texts[_TextTeamChoosing].Visible = false;
_Texts[_TextTeamChoosing].Visible = false;
}
private void _UpdateJokerButtons()
{
Buttons[_ButtonJokerRandomT1].Visible = true;
Buttons[_ButtonJokerRandomT2].Visible = true;
Buttons[_ButtonJokerRandomT1].Text.Text = _GameData.NumJokerRandom[0].ToString();
Buttons[_ButtonJokerRandomT2].Text.Text = _GameData.NumJokerRandom[1].ToString();
Buttons[_ButtonJokerRandomT1].Enabled = _GameData.NumJokerRandom[0] > 0;
Buttons[_ButtonJokerRandomT2].Enabled = _GameData.NumJokerRandom[1] > 0;
Buttons[_ButtonJokerRetryT1].Visible = true;
Buttons[_ButtonJokerRetryT2].Visible = true;
Buttons[_ButtonJokerRetryT1].Text.Text = _GameData.NumJokerRetry[0].ToString();
Buttons[_ButtonJokerRetryT2].Text.Text = _GameData.NumJokerRetry[1].ToString();
Buttons[_ButtonJokerRetryT1].Enabled = _GameData.NumJokerRetry[0] > 0;
Buttons[_ButtonJokerRetryT2].Enabled = _GameData.NumJokerRetry[1] > 0;
_Buttons[_ButtonJokerRandomT1].Visible = true;
_Buttons[_ButtonJokerRandomT2].Visible = true;
_Buttons[_ButtonJokerRandomT1].Text.Text = _GameData.NumJokerRandom[0].ToString();
_Buttons[_ButtonJokerRandomT2].Text.Text = _GameData.NumJokerRandom[1].ToString();
_Buttons[_ButtonJokerRandomT1].Enabled = _GameData.NumJokerRandom[0] > 0;
_Buttons[_ButtonJokerRandomT2].Enabled = _GameData.NumJokerRandom[1] > 0;
_Buttons[_ButtonJokerRetryT1].Visible = true;
_Buttons[_ButtonJokerRetryT2].Visible = true;
_Buttons[_ButtonJokerRetryT1].Text.Text = _GameData.NumJokerRetry[0].ToString();
_Buttons[_ButtonJokerRetryT2].Text.Text = _GameData.NumJokerRetry[1].ToString();
_Buttons[_ButtonJokerRetryT1].Enabled = _GameData.NumJokerRetry[0] > 0;
_Buttons[_ButtonJokerRetryT2].Enabled = _GameData.NumJokerRetry[1] > 0;
}
private void _NextRound()
@@ -638,13 +652,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
_ExitPopupVisible = visible;
Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
_Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
_Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
_Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
_Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
if (_ExitPopupVisible)
SetInteractionToButton(Buttons[_ButtonPopupNo]);
_SetInteractionToButton(_Buttons[_ButtonPopupNo]);
}
private void _Back()
@@ -696,14 +710,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (_Fields[_Possibilities[i, j]].Content.Winner > 0)
check.Add(_Fields[_Possibilities[i, j]].Content.Winner);
}
if (check.Count == _Possibilities.GetLength(1))
{
//Check for winner
if (check.Contains(1) && !check.Contains(2))
return 1;
else if (check.Contains(2) && !check.Contains(1))
return 2;
}
if (check.Count != _Possibilities.GetLength(1))
continue;
//Check for winner
if (check.Contains(1) && !check.Contains(2))
return 1;
if (check.Contains(2) && !check.Contains(1))
return 2;
}
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.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.TicTacToe
{
// ReSharper disable UnusedMember.Global
public class CPartyScreenTicTacToeNames : CMenuParty
// ReSharper restore UnusedMember.Global
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
@@ -24,7 +46,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private List<CButton> _PlayerDestinationButtons;
//PlayerDestinationButtons-Option
private const int _PlayerDestinationButtonsNumH = 10;
private const int _PlayerDestinationButtonsNumW = 2;
private const int _PlayerDestinationButtonsFirstX = 58;
private const int _PlayerDestinationButtonsFirstY = 380;
private const int _PlayerDestinationButtonsSpaceH = 15;
@@ -69,25 +90,18 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Data.ScreenNames.ProfileIDsTeam1 = new List<int>();
_Data.ScreenNames.ProfileIDsTeam2 = new List<int>();
List<string> buttons = new List<string>();
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose, _ButtonPlayerChooseScrollUp, _ButtonPlayerChooseScrollDown};
_Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames();
names.FadeToConfig = false;
names.FadeToMain = false;
names.ProfileIDsTeam1 = new List<int>();
names.ProfileIDsTeam2 = new List<int>();
SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, ProfileIDsTeam1 = new List<int>(), ProfileIDsTeam2 = new List<int>()};
_Data.ScreenNames = names;
}
public override void DataToScreen(object receivedData)
{
SDataToScreenNames config = new SDataToScreenNames();
try
{
config = (SDataToScreenNames)receivedData;
SDataToScreenNames config = (SDataToScreenNames)receivedData;
_Data.ScreenNames.ProfileIDsTeam1 = config.ProfileIDsTeam1;
_Data.ScreenNames.ProfileIDsTeam2 = config.ProfileIDsTeam2;
if (_Data.ScreenNames.ProfileIDsTeam1 == null)
@@ -124,16 +138,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
break;
case Keys.Enter:
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
if (Buttons[_ButtonPlayerChooseScrollUp].Selected)
if (_Buttons[_ButtonPlayerChooseScrollUp].Selected)
_Scroll(-1);
if (Buttons[_ButtonPlayerChooseScrollDown].Selected)
if (_Buttons[_ButtonPlayerChooseScrollDown].Selected)
_Scroll(1);
if (!_OnAdd())
@@ -159,18 +173,18 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y;
//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)
{
//Activate mouse-selecting
_SelectingMouseActive = true;
//Update of Drag/Drop-Texture
_ChooseAvatarStatic.Visible = true;
_ChooseAvatarStatic.Rect = _PlayerChooseButtons[i].Button.Rect;
_ChooseAvatarStatic.Rect = chooseButton.Button.Rect;
_ChooseAvatarStatic.Rect.Z = -100;
_ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
_ChooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].Avatar.Texture;
@@ -191,8 +205,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
return true;
}
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
else if (_SelectingMouseActive)
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
if (_SelectingMouseActive)
{
//Check if really a player was selected
if (_SelectedPlayerNr != -1)
@@ -255,22 +269,22 @@ namespace VocaluxeLib.PartyModes.TicTacToe
return true;
}
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
if (Buttons[_ButtonBack].Selected)
if (_Buttons[_ButtonBack].Selected)
_Back();
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
_Next();
if (Buttons[_ButtonPlayerChooseScrollUp].Selected)
if (_Buttons[_ButtonPlayerChooseScrollUp].Selected)
_Scroll(-1);
if (Buttons[_ButtonPlayerChooseScrollDown].Selected)
if (_Buttons[_ButtonPlayerChooseScrollDown].Selected)
_Scroll(1);
}
if (mouseEvent.LD && IsMouseOver(mouseEvent))
if (mouseEvent.LD && _IsMouseOver(mouseEvent))
{
if (!_OnAdd())
_OnRemove();
@@ -328,13 +342,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _AddButtonPlayerDestination()
{
Buttons[_ButtonPlayerDestination].Visible = false;
_Buttons[_ButtonPlayerDestination].Visible = false;
_PlayerDestinationButtons = new List<CButton>();
int row = 0;
int column = 0;
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.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW);
_PlayerDestinationButtons.Add(b);
@@ -346,24 +360,22 @@ namespace VocaluxeLib.PartyModes.TicTacToe
}
b.Visible = true;
b.Enabled = false;
AddButton(b);
_AddButton(b);
}
}
private void _AddButtonPlayerChoose()
{
Buttons[_ButtonPlayerChoose].Visible = false;
_Buttons[_ButtonPlayerChoose].Visible = false;
_PlayerChooseButtons = new List<CPlayerChooseButton>();
int row = 0;
int column = 0;
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.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW);
CPlayerChooseButton pcb = new CPlayerChooseButton();
pcb.Button = b;
pcb.ProfileID = -1;
CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1};
_PlayerChooseButtons.Add(pcb);
column++;
if (column >= _PlayerChooseButtonsNumH)
@@ -373,7 +385,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
}
b.Visible = true;
b.Enabled = false;
AddButton(b);
_AddButton(b);
}
}
@@ -385,14 +397,14 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset - 1);
else
_UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset);
Buttons[_ButtonPlayerChooseScrollUp].Enabled = _PlayerChooseButtonsOffset > 0;
Buttons[_ButtonPlayerChooseScrollDown].Enabled = _PlayerChooseButtonsVisibleProfiles.Count >
_PlayerChooseButtons.Count + _PlayerChooseButtonsOffset * _PlayerChooseButtonsNumH;
_Buttons[_ButtonPlayerChooseScrollUp].Enabled = _PlayerChooseButtonsOffset > 0;
_Buttons[_ButtonPlayerChooseScrollDown].Enabled = _PlayerChooseButtonsVisibleProfiles.Count >
_PlayerChooseButtons.Count + _PlayerChooseButtonsOffset * _PlayerChooseButtonsNumH;
}
private void _UpdateButtonPlayerChoose(int offset)
{
int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
const int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
if (offset < 0)
offset = 0;
@@ -404,8 +416,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
_PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose];
_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.SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.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.SelColor = new SColorF(1, 1, 1, 1);
_PlayerChooseButtons[i].Button.Enabled = true;
@@ -414,10 +428,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
_PlayerChooseButtons[i].ProfileID = -1;
_PlayerChooseButtons[i].Button.Text.Text = String.Empty;
_PlayerChooseButtons[i].Button.Texture = Buttons[_ButtonPlayerChoose].Texture;
_PlayerChooseButtons[i].Button.SelTexture = Buttons[_ButtonPlayerChoose].SelTexture;
_PlayerChooseButtons[i].Button.Color = Buttons[_ButtonPlayerChoose].Color;
_PlayerChooseButtons[i].Button.SelColor = Buttons[_ButtonPlayerChoose].SelColor;
_PlayerChooseButtons[i].Button.Texture = _Buttons[_ButtonPlayerChoose].Texture;
_PlayerChooseButtons[i].Button.SelTexture = _Buttons[_ButtonPlayerChoose].SelTexture;
_PlayerChooseButtons[i].Button.Color = _Buttons[_ButtonPlayerChoose].Color;
_PlayerChooseButtons[i].Button.SelColor = _Buttons[_ButtonPlayerChoose].SelColor;
_PlayerChooseButtons[i].Button.Enabled = false;
}
}
@@ -432,29 +446,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
bool visible = false;
//Show profile only if active
if (CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON)
{
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;
}
}
}
visible = _Data.ScreenNames.ProfileIDsTeam1.All(t => t != i) && _Data.ScreenNames.ProfileIDsTeam2.All(t => t != i);
if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(i);
}
@@ -504,10 +496,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
}
else
{
_PlayerDestinationButtons[i].Color = Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i].SelColor = Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i].Texture = Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i].SelTexture = Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i].Color = _Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i].SelColor = _Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i].Texture = _Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i].SelTexture = _Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i].Text.Text = String.Empty;
_PlayerDestinationButtons[i].Enabled = false;
}
@@ -528,10 +520,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
}
else
{
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Color = Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelColor = Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Texture = Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelTexture = Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Color = _Buttons[_ButtonPlayerDestination].Color;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelColor = _Buttons[_ButtonPlayerDestination].SelColor;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Texture = _Buttons[_ButtonPlayerDestination].Texture;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelTexture = _Buttons[_ButtonPlayerDestination].SelTexture;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Text.Text = String.Empty;
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Enabled = false;
}
@@ -542,53 +534,50 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
if (_Data.ScreenNames.ProfileIDsTeam1.Count == _NumPlayerTeam1 && _Data.ScreenNames.ProfileIDsTeam2.Count == _NumPlayerTeam2)
{
Buttons[_ButtonNext].Visible = true;
SetInteractionToButton(Buttons[_ButtonNext]);
_Buttons[_ButtonNext].Visible = true;
_SetInteractionToButton(_Buttons[_ButtonNext]);
}
else
Buttons[_ButtonNext].Visible = false;
_Buttons[_ButtonNext].Visible = false;
}
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);
int added = _Data.ScreenNames.ProfileIDsTeam1.Count - 1;
_UpdateButtonNext();
//Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List
_UpdateButtonPlayerChoose();
CheckInteraction();
return true;
}
else if (_Data.ScreenNames.ProfileIDsTeam2.Count < _NumPlayerTeam2)
{
_Data.ScreenNames.ProfileIDsTeam2.Add(_PlayerChooseButtons[i].ProfileID);
int added = (_Data.ScreenNames.ProfileIDsTeam2.Count - 1) + _PlayerDestinationButtonsNumH;
_UpdateButtonNext();
//Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List
_UpdateButtonPlayerChoose();
CheckInteraction();
return true;
}
_Data.ScreenNames.ProfileIDsTeam1.Add(chooseButton.ProfileID);
int added = _Data.ScreenNames.ProfileIDsTeam1.Count - 1;
_UpdateButtonNext();
//Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List
_UpdateButtonPlayerChoose();
_CheckInteraction();
return true;
}
if (_Data.ScreenNames.ProfileIDsTeam2.Count < _NumPlayerTeam2)
{
_Data.ScreenNames.ProfileIDsTeam2.Add(chooseButton.ProfileID);
int added = (_Data.ScreenNames.ProfileIDsTeam2.Count - 1) + _PlayerDestinationButtonsNumH;
_UpdateButtonNext();
//Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List
_UpdateButtonPlayerChoose();
_CheckInteraction();
return true;
}
}
return false;
@@ -606,7 +595,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_UpdateButtonNext();
_UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose();
CheckInteraction();
_CheckInteraction();
return true;
}
}
@@ -621,7 +610,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_UpdateButtonNext();
_UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose();
CheckInteraction();
_CheckInteraction();
return true;
}
}
@@ -632,14 +621,12 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _Back()
{
_Data.ScreenNames.FadeToConfig = true;
_Data.ScreenNames.FadeToMain = false;
_PartyMode.DataFromScreen(ThemeName, _Data);
}
private void _Next()
{
_Data.ScreenNames.FadeToConfig = false;
_Data.ScreenNames.FadeToMain = true;
_PartyMode.DataFromScreen(ThemeName, _Data);
}
}
Binary file not shown.
File renamed without changes.
+48 -43
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.Diagnostics;
using System.IO;
using System.Linq;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
@@ -26,7 +46,6 @@ namespace Vocaluxe.Base
private static bool _OwnMusicAdded;
private static bool _BackgroundMusicAdded;
private static bool _Playing;
private static bool _Disabled;
private static bool _CanSing;
private static bool _RepeatSong;
@@ -88,19 +107,15 @@ namespace Vocaluxe.Base
get { return File.Exists(_CurrentPlaylistElement.VideoFilePath); }
}
public static bool Playing
{
get { return _Playing; }
}
public static bool IsPlaying { get; private set; }
public static string ArtistAndTitle
{
get
{
if (_CurrentPlaylistElement.Artist.Length > 0 && _CurrentPlaylistElement.Title.Length > 0)
if (_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)
_VideoEnabled = true;
_Playing = false;
IsPlaying = false;
}
public static void Play()
{
if (_Playing)
if (IsPlaying)
return;
if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
@@ -142,22 +157,19 @@ namespace Vocaluxe.Base
CSound.Play(_CurrentMusicStream);
if (_VideoEnabled && _Video != -1)
CVideo.VdResume(_Video);
_Playing = true;
IsPlaying = true;
}
else
Next();
if (!_IsBackgroundFile(_CurrentPlaylistElement))
_CanSing = true;
else
_CanSing = false;
_CanSing = !_IsBackgroundFile(_CurrentPlaylistElement);
}
}
}
public static void Stop()
{
if (!_Playing)
if (!IsPlaying)
return;
if (_VideoEnabled && _Video != -1)
@@ -170,12 +182,12 @@ namespace Vocaluxe.Base
_CurrentMusicStream = -1;
_CurrentPlaylistElement = new CPlaylistElement();
_Playing = false;
IsPlaying = false;
}
public static void Pause()
{
if (!_Playing)
if (!IsPlaying)
return;
if (_VideoEnabled && _Video != -1)
@@ -184,7 +196,7 @@ namespace Vocaluxe.Base
CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap);
}
CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
_Playing = false;
IsPlaying = false;
}
public static void Update()
@@ -192,24 +204,24 @@ namespace Vocaluxe.Base
if (_AllFileNames.Count > 0 && _CurrentMusicStream != -1)
{
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);
else //End-Tag found
timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream);
bool finished = CSound.IsFinished(_CurrentMusicStream);
if (_Playing && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished))
if (IsPlaying && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished))
{
if (_RepeatSong)
{
//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);
else
CSound.SetPosition(_CurrentMusicStream, 0);
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);
else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
@@ -250,7 +262,7 @@ namespace Vocaluxe.Base
CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume);
//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);
if (_VideoEnabled)
@@ -266,17 +278,16 @@ namespace Vocaluxe.Base
{
if (_PreviousFileNames.Count > 0 && _PreviousMusicIndex >= 0)
{
float pos = CSound.GetPosition(_CurrentMusicStream);
if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f)
{
//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);
else
CSound.SetPosition(_CurrentMusicStream, 0);
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);
else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
@@ -302,13 +313,13 @@ namespace Vocaluxe.Base
else if (_CurrentMusicStream != -1)
{
//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);
else
CSound.SetPosition(_CurrentMusicStream, 0);
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);
else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
@@ -345,7 +356,7 @@ namespace Vocaluxe.Base
_NotPlayedFileNames.AddRange(_BGMusicFileNames);
}
if (Playing && !_IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0)
if (IsPlaying && !_IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0)
Next();
_OwnMusicAdded = false;
@@ -370,7 +381,7 @@ namespace Vocaluxe.Base
AddOwnMusic();
_BackgroundMusicAdded = false;
if (Playing && _IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0)
if (IsPlaying && _IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0)
Next();
}
}
@@ -415,7 +426,7 @@ namespace Vocaluxe.Base
Pause();
}
if (CConfig.BackgroundMusicVolume != newVolume)
if (Math.Abs(CConfig.BackgroundMusicVolume - newVolume) > 0.01)
{
CConfig.BackgroundMusicVolume = (int)newVolume;
ApplyVolume();
@@ -441,7 +452,6 @@ namespace Vocaluxe.Base
CVideo.VdClose(_Video);
CDraw.RemoveTexture(ref _CurrentVideoTexture);
_Video = -1;
return;
}
}
else
@@ -452,8 +462,8 @@ namespace Vocaluxe.Base
{
if (_Video != -1)
{
float vtime = 0f;
CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), ref vtime);
float vtime;
CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), out vtime);
if (_FadeTimer.ElapsedMilliseconds <= 3000L)
_CurrentVideoTexture.Color.A = _FadeTimer.ElapsedMilliseconds / 3000f;
else
@@ -468,12 +478,7 @@ namespace Vocaluxe.Base
private static bool _IsBackgroundFile(CPlaylistElement element)
{
foreach (CPlaylistElement elements in _BGMusicFileNames)
{
if (elements.MusicFilePath == element.MusicFilePath)
return true;
}
return false;
return _BGMusicFileNames.Any(elements => elements.MusicFilePath == element.MusicFilePath);
}
private static void _LoadVideo()
@@ -481,7 +486,7 @@ namespace Vocaluxe.Base
if (_Video == -1)
{
_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);
else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
+101 -77
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.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
@@ -32,7 +52,7 @@ namespace Vocaluxe.Base
public static int ScreenH = 576;
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 FullScreen = EOffOn.TR_CONFIG_ON;
@@ -56,8 +76,8 @@ namespace Vocaluxe.Base
public static EPlaybackLib PlayBackLib = EPlaybackLib.Gstreamer;
public static ERecordLib RecordLib = ERecordLib.PortAudio;
public static EBufferSize AudioBufferSize = EBufferSize.B2048;
public static int AudioLatency = 0;
public static int BackgroundMusicVolume = 30;
public static int AudioLatency;
private static int _BackgroundMusicVolume = 30;
public static EOffOn BackgroundMusic = EOffOn.TR_CONFIG_ON;
public static EBackgroundMusicSource BackgroundMusicSource = EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC;
public static EOffOn BackgroundMusicUseStart = EOffOn.TR_CONFIG_ON;
@@ -65,7 +85,7 @@ namespace Vocaluxe.Base
public static int GameMusicVolume = 80;
// 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 ESongSorting SongSorting = ESongSorting.TR_CONFIG_ARTIST;
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 string Language = "English";
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)
@@ -98,6 +118,20 @@ namespace Vocaluxe.Base
//Variables to save old values for commandline-parameters
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()
{
@@ -113,17 +147,14 @@ namespace Vocaluxe.Base
if (!File.Exists(CSettings.FileConfig))
SaveConfig();
LoadConfig();
_LoadConfig();
}
public static bool LoadConfig()
private static void _LoadConfig()
{
CXMLReader xmlReader = CXMLReader.OpenFile(CSettings.FileConfig);
if (xmlReader == null)
return false;
string value = string.Empty;
return;
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/ScreenH", ref ScreenH);
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.TryGetEnumValue("//root/Graphics/VSync", ref VSync);
xmlReader.TryGetEnumValue("//root/Graphics/FullScreen", ref FullScreen);
@@ -143,9 +174,9 @@ namespace Vocaluxe.Base
#endregion Graphics
#region Theme
xmlReader.GetValue("//root/Theme/Name", ref Theme, Theme);
xmlReader.GetValue("//root/Theme/Skin", ref Skin, Skin);
xmlReader.GetValue("//root/Theme/Cover", ref CoverTheme, CoverTheme);
xmlReader.GetValue("//root/Theme/Name", out Theme, Theme);
xmlReader.GetValue("//root/Theme/Skin", out Skin, Skin);
xmlReader.GetValue("//root/Theme/Cover", out CoverTheme, CoverTheme);
xmlReader.TryGetEnumValue("//root/Theme/DrawNoteLines", ref DrawNoteLines);
xmlReader.TryGetEnumValue("//root/Theme/DrawToneHelper", ref DrawToneHelper);
xmlReader.TryGetEnumValue("//root/Theme/TimerLook", ref TimerLook);
@@ -163,7 +194,7 @@ namespace Vocaluxe.Base
xmlReader.TryGetIntValueRange("//root/Sound/AudioLatency", ref AudioLatency, -500, 500);
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/BackgroundMusicUseStart", ref BackgroundMusicUseStart);
xmlReader.TryGetIntValueRange("//root/Sound/PreviewMusicVolume", ref PreviewMusicVolume);
@@ -172,9 +203,9 @@ namespace Vocaluxe.Base
#region Game
// Songfolder
value = string.Empty;
string value = string.Empty;
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)
SongFolder.Clear();
@@ -191,7 +222,7 @@ namespace Vocaluxe.Base
xmlReader.TryGetEnumValue("//root/Game/TimerMode", ref TimerMode);
xmlReader.TryGetIntValue("//root/Game/NumPlayer", ref NumPlayer);
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.TryGetFloatValue("//root/Game/MinLineBreakTime", ref MinLineBreakTime);
@@ -212,7 +243,7 @@ namespace Vocaluxe.Base
//Read players from config
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
#region Video
@@ -224,7 +255,7 @@ namespace Vocaluxe.Base
xmlReader.TryGetEnumValue("//root/Video/WebcamLib", ref WebcamLib);
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/Width", ref WebcamConfig.Width);
xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Height", ref WebcamConfig.Height);
@@ -232,21 +263,18 @@ namespace Vocaluxe.Base
#region Record
MicConfig = new SMicConfig[CSettings.MaxNumPlayer];
value = string.Empty;
for (int p = 1; p <= CSettings.MaxNumPlayer; p++)
{
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.ToString() + "/DeviceDriver", ref MicConfig[p - 1].DeviceDriver, String.Empty);
xmlReader.GetValue("//root/Record/MicConfig" + p.ToString() + "/InputName", ref MicConfig[p - 1].InputName, String.Empty);
xmlReader.TryGetIntValue("//root/Record/MicConfig" + p.ToString() + "/Channel", ref MicConfig[p - 1].Channel);
xmlReader.GetValue("//root/Record/MicConfig" + p + "/DeviceName", out MicConfig[p - 1].DeviceName, String.Empty);
xmlReader.GetValue("//root/Record/MicConfig" + p + "/DeviceDriver", out MicConfig[p - 1].DeviceDriver, String.Empty);
xmlReader.GetValue("//root/Record/MicConfig" + p + "/InputName", out MicConfig[p - 1].InputName, String.Empty);
xmlReader.TryGetIntValue("//root/Record/MicConfig" + p + "/Channel", ref MicConfig[p - 1].Channel);
}
xmlReader.TryGetIntValueRange("//root/Record/MicDelay", ref MicDelay, 0, 500);
MicDelay = (int)(20 * Math.Round(MicDelay / 20.0));
#endregion Record
return true;
}
public static bool SaveConfig()
@@ -302,8 +330,8 @@ namespace Vocaluxe.Base
writer.WriteComment("AAMode: " + CHelper.ListStrings(Enum.GetNames(typeof(EAntiAliasingModes))));
writer.WriteElementString("AAMode", Enum.GetName(typeof(EAntiAliasingModes), AAMode));
writer.WriteComment("Colors: " + CHelper.ListStrings(Enum.GetNames(typeof(EColorDeep))));
writer.WriteElementString("Colors", Enum.GetName(typeof(EColorDeep), Colors));
writer.WriteComment("Colors: " + CHelper.ListStrings(Enum.GetNames(typeof(EColorDepth))));
writer.WriteElementString("Colors", Enum.GetName(typeof(EColorDepth), ColorDepth));
writer.WriteComment("MaxFPS should be between 1..200");
writer.WriteElementString("MaxFPS", MaxFPS.ToString("#"));
@@ -407,14 +435,14 @@ namespace Vocaluxe.Base
//Write "old" song-folders to config.
writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ...");
for (int i = 0; i < _SongFolderOld.Count; i++)
writer.WriteElementString("SongFolder" + (i + 1).ToString(), _SongFolderOld[i]);
writer.WriteElementString("SongFolder" + (i + 1), _SongFolderOld[i]);
}
else
{
//Write "normal" song-folders to config.
writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ...");
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))));
@@ -432,7 +460,7 @@ namespace Vocaluxe.Base
writer.WriteComment("TimerMode: " + CHelper.ListStrings(Enum.GetNames(typeof(ETimerMode))));
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.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.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");
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();
@@ -491,9 +519,9 @@ namespace Vocaluxe.Base
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("DeviceDriver", MicConfig[p - 1].DeviceDriver);
@@ -566,21 +594,30 @@ namespace Vocaluxe.Base
if (devices == null)
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++)
{
if (devices[dev].Inputs[inp].PlayerChannel1 == player || devices[dev].Inputs[inp].PlayerChannel2 == player)
return true;
}
if (devices[dev].Inputs[inp].PlayerChannel1 == player || devices[dev].Inputs[inp].PlayerChannel2 == player)
return true;
}
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>
/// Try to assign automatically player 1 and 2 to usb-mics.
/// </summary>
@@ -595,7 +632,7 @@ namespace Vocaluxe.Base
for (int dev = 0; dev < devices.Length; dev++)
{
//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.
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++)
{
//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.
if (devices[dev].Inputs.Count >= 1)
@@ -661,30 +698,25 @@ namespace Vocaluxe.Base
/// <param name="args">Parameters</param>
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
string arguments = string.Empty;
foreach (string arg in args)
arguments += arg + " ";
string arguments = args.Aggregate(string.Empty, (current, arg) => current + (arg + " "));
args = spliterParam.Split(arguments);
foreach (string text in args)
{
Regex spliterVal = new Regex(@"ReplacedStr:::2:::", RegexOptions.IgnoreCase);
//Array for parts of an arg
string[] parts;
Regex spliterVal = new Regex(@"\s", RegexOptions.IgnoreCase);
//split arg with Spilter-Regex and save in parts
parts = spliterVal.Split(text, 2);
string[] parts = spliterVal.Split(text, 2);
switch (parts.Length)
{
//Only found a parameter
case 1:
if (!Regex.IsMatch(parts[0], @"ReplacedStr:::3:::") && parts[0].Length > 0)
if (parts[0] != "")
{
//Add parameter
_Params.Add(parts[0]);
@@ -697,7 +729,7 @@ namespace Vocaluxe.Base
//Found parameter and value
case 2:
if (!Regex.IsMatch(parts[0], @"ReplacedStr:::5:::") && parts[0].Length > 0)
if (parts[0] != "")
{
//Add parameter
_Params.Add(parts[0]);
@@ -793,11 +825,7 @@ namespace Vocaluxe.Base
if (value.Contains(chars[i].ToString()))
return false;
}
if (Path.GetFileName(value).Length == 0)
return false;
if (!Path.HasExtension(value))
return false;
return true;
return !String.IsNullOrEmpty(Path.GetFileName(value)) && Path.HasExtension(value);
}
/// <summary>
@@ -805,22 +833,18 @@ namespace Vocaluxe.Base
/// </summary>
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++)
CGame.Players[j].ProfileID = -1;
if (Players[j] == "")
continue;
for (int i = 0; i < CProfiles.Profiles.Length; i++)
{
if (Players[j].Length > 0)
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
CGame.Player[j].Name = CProfiles.Profiles[i].PlayerName;
CGame.Player[j].Difficulty = CProfiles.Profiles[i].Difficulty;
CGame.Player[j].ProfileID = i;
}
//Update Game-infos with player
CGame.Players[j].ProfileID = i;
}
else
CGame.Player[j].ProfileID = -1;
}
}
}
+71 -65
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.IO;
using System.Linq;
using System.Text;
using System.Xml;
using VocaluxeLib.Menu;
@@ -97,18 +117,12 @@ namespace Vocaluxe.Base
/// <summary>
/// Returns true if a cover with the given name exists.
/// </summary>
public static bool CoverExists(string name)
private static bool _CoverExists(string name)
{
STexture cov = _NoCover;
lock (_MutexCover)
{
foreach (SCover cover in _Cover)
{
if (cover.Name == name)
return true;
}
return _Cover.Any(cover => cover.Name == name);
}
return false;
}
/// <summary>
@@ -149,8 +163,8 @@ namespace Vocaluxe.Base
{
_CoverThemes.Clear();
string path = CSettings.FolderCover;
List<string> files = CHelper.ListFiles(path, "*.xml", false);
const string path = CSettings.FolderCover;
List<string> files = CHelper.ListFiles(path, "*.xml");
foreach (string file in files)
{
@@ -160,10 +174,10 @@ namespace Vocaluxe.Base
{
SCoverTheme coverTheme = new SCoverTheme();
xmlReader.GetValue("//root/Info/Name", ref coverTheme.Name, String.Empty);
xmlReader.GetValue("//root/Info/Folder", ref coverTheme.Folder, String.Empty);
xmlReader.GetValue("//root/Info/Name", out coverTheme.Name, 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;
@@ -178,69 +192,61 @@ namespace Vocaluxe.Base
/// </summary>
private static void _LoadCover(string coverThemeName)
{
SCoverTheme coverTheme = new SCoverTheme();
SCoverTheme coverTheme = _CoverTheme(coverThemeName);
coverTheme = _CoverTheme(coverThemeName);
if (coverTheme.Name == "")
return;
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderCover, coverTheme.File));
if (coverTheme.Name.Length > 0)
if (xmlReader != null)
{
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderCover, coverTheme.File));
if (xmlReader != null)
lock (_MutexCover)
{
lock (_MutexCover)
{
_Cover.Clear();
List<string> cover = xmlReader.GetValues("Cover");
for (int i = 0; i < cover.Count; i++)
{
SCover sk = new SCover();
string name = String.Empty;
string value = String.Empty;
xmlReader.GetValue("//root/Cover/" + cover[i] + "/Name", ref name, String.Empty);
xmlReader.GetValue("//root/Cover/" + cover[i] + "/Path", ref value, String.Empty);
sk.Name = name;
sk.Value = Path.Combine(coverTheme.Folder, value);
if (File.Exists(Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, value))))
sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, value)));
else
sk.Texture = _NoCover;
_Cover.Add(sk);
if (sk.Name == "NoCover")
_NoCover = sk.Texture;
}
}
}
List<string> files = new List<string>();
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.FolderCover, coverTheme.Folder), "*.png", true, true));
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.FolderCover, coverTheme.Folder), "*.jpg", true, true));
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.FolderCover, coverTheme.Folder), "*.jpeg", true, true));
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.FolderCover, coverTheme.Folder), "*.bmp", true, true));
foreach (string file in files)
{
string name = Path.GetFileNameWithoutExtension(file);
if (!CoverExists(name))
_Cover.Clear();
List<string> cover = xmlReader.GetValues("Cover");
foreach (string coverName in cover)
{
SCover sk = new SCover();
string value = String.Empty;
string name;
string value;
xmlReader.GetValue("//root/Cover/" + coverName + "/Name", out name, String.Empty);
xmlReader.GetValue("//root/Cover/" + coverName + "/Path", out value, String.Empty);
sk.Name = name;
sk.Value = Path.Combine(coverTheme.Folder, Path.GetFileName(file));
sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.FolderCover, sk.Value));
sk.Value = Path.Combine(coverTheme.Folder, value);
sk.Texture = File.Exists(Path.Combine(CSettings.FolderCover, sk.Value))
? CDraw.AddTexture(Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, value))) : _NoCover;
_Cover.Add(sk);
if (sk.Name == "NoCover")
_NoCover = sk.Texture;
}
}
}
List<string> files = new List<string>();
string path = Path.Combine(CSettings.FolderCover, coverTheme.Folder);
files.AddRange(CHelper.ListFiles(path, "*.png", true, true));
files.AddRange(CHelper.ListFiles(path, "*.jpg", true, true));
files.AddRange(CHelper.ListFiles(path, "*.jpeg", true, true));
files.AddRange(CHelper.ListFiles(path, "*.bmp", true, true));
foreach (string file in files)
{
string name = Path.GetFileNameWithoutExtension(file);
if (_CoverExists(name))
continue;
// ReSharper disable AssignNullToNotNullAttribute
SCover sk = new SCover {Name = name, Value = Path.Combine(coverTheme.Folder, Path.GetFileName(file))};
// ReSharper restore AssignNullToNotNullAttribute
sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.FolderCover, sk.Value));
_Cover.Add(sk);
}
}
}
}
+89 -138
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.Data;
using System.Drawing;
@@ -51,19 +70,9 @@ namespace Vocaluxe.Base
}
#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)
{
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())
{
connection.ConnectionString = "Data Source=" + filePath;
@@ -80,7 +89,7 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection))
{
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;
}
}
@@ -104,42 +113,30 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection))
{
int dataBaseSongID = _GetDataBaseSongID(player, command);
int result = _AddScore(player, command, dataBaseSongID);
return result;
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);
}
}
}
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;
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 " +
"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("@PlayerName", DbType.String, 0).Value = player.Name;
command.Parameters.Add("@Score", DbType.Int32, 0).Value = (int)Math.Round(player.Points);
command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = player.LineNr;
command.Parameters.Add("@Date", DbType.Int64, 0).Value = player.DateTicks;
command.Parameters.Add("@PlayerName", DbType.String, 0).Value = playerName;
command.Parameters.Add("@Score", DbType.Int32, 0).Value = score;
command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = lineNr;
command.Parameters.Add("@Date", DbType.Int64, 0).Value = date;
command.Parameters.Add("@Medley", DbType.Int32, 0).Value = medley;
command.Parameters.Add("@Duet", DbType.Int32, 0).Value = duet;
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;
try
@@ -155,22 +152,19 @@ namespace Vocaluxe.Base
}
if (reader != null)
{
reader.Dispose();
reader = null;
}
command.CommandText = "INSERT INTO Scores (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("@PlayerName", DbType.String, 0).Value = player.Name;
command.Parameters.Add("@Score", DbType.Int32, 0).Value = (int)Math.Round(player.Points);
command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = player.LineNr;
command.Parameters.Add("@Date", DbType.Int64, 0).Value = player.DateTicks;
command.Parameters.Add("@PlayerName", DbType.String, 0).Value = playerName;
command.Parameters.Add("@Score", DbType.Int32, 0).Value = score;
command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = lineNr;
command.Parameters.Add("@Date", DbType.Int64, 0).Value = date;
command.Parameters.Add("@Medley", DbType.Int32, 0).Value = medley;
command.Parameters.Add("@Duet", DbType.Int32, 0).Value = duet;
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();
//Read last insert line
@@ -189,7 +183,7 @@ namespace Vocaluxe.Base
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())
{
@@ -236,13 +230,15 @@ namespace Vocaluxe.Base
{
while (reader.Read())
{
SScores score = new SScores();
score.Name = reader.GetString(0);
score.Score = reader.GetInt32(1);
score.Date = new DateTime(reader.GetInt64(2)).ToString("dd/MM/yyyy");
score.Difficulty = (EGameDifficulty)reader.GetInt32(3);
score.LineNr = reader.GetInt32(4);
score.ID = reader.GetInt32(5);
SScores score = new SScores
{
Name = reader.GetString(0),
Score = reader.GetInt32(1),
Date = new DateTime(reader.GetInt64(2)).ToString("dd/MM/yyyy"),
Difficulty = (EGameDifficulty)reader.GetInt32(3),
LineNr = reader.GetInt32(4),
ID = reader.GetInt32(5)
};
scores.Add(score);
}
@@ -263,26 +259,6 @@ namespace Vocaluxe.Base
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)
{
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
@@ -298,35 +274,29 @@ namespace Vocaluxe.Base
reader.Dispose();
return id;
}
else
{
if (reader != null)
reader.Close();
if (reader != null)
reader.Close();
command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " +
"VALUES (@title, @artist, @numplayed)";
command.Parameters.Add("@title", DbType.String, 0).Value = title;
command.Parameters.Add("@artist", DbType.String, 0).Value = artist;
command.Parameters.Add("@numplayed", DbType.Int32, 0).Value = defNumPlayed;
command.ExecuteNonQuery();
command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " +
"VALUES (@title, @artist, @numplayed)";
command.Parameters.Add("@title", DbType.String, 0).Value = title;
command.Parameters.Add("@artist", DbType.String, 0).Value = artist;
command.Parameters.Add("@numplayed", DbType.Int32, 0).Value = defNumPlayed;
command.ExecuteNonQuery();
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
command.Parameters.Add("@title", DbType.String, 0).Value = title;
command.Parameters.Add("@artist", DbType.String, 0).Value = artist;
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
command.Parameters.Add("@title", DbType.String, 0).Value = title;
command.Parameters.Add("@artist", DbType.String, 0).Value = artist;
reader = command.ExecuteReader();
if (reader != null)
{
reader.Read();
int id = reader.GetInt32(0);
reader.Dispose();
return id;
}
}
reader = command.ExecuteReader();
if (reader != null)
{
reader.Read();
int id = reader.GetInt32(0);
reader.Dispose();
return id;
}
return -1;
}
@@ -355,7 +325,7 @@ namespace Vocaluxe.Base
command.CommandText = "SELECT Artist, Title, NumPlayed FROM Songs WHERE [id] = @id";
command.Parameters.Add("@id", DbType.String, 0).Value = songID;
SQLiteDataReader reader = null;
SQLiteDataReader reader;
try
{
reader = command.ExecuteReader();
@@ -391,7 +361,7 @@ namespace Vocaluxe.Base
{
_CreateOrConvert(oldDBFilePath);
_CreateOrConvert(_HighscoreFilePath);
_ImportData(oldDBFilePath, _HighscoreFilePath);
_ImportData(oldDBFilePath);
File.Delete(oldDBFilePath);
}
@@ -497,11 +467,10 @@ namespace Vocaluxe.Base
return false;
}
SQLiteDataReader reader = null;
using (SQLiteCommand command = new SQLiteCommand(connection))
{
command.CommandText = "PRAGMA user_version";
reader = command.ExecuteReader();
SQLiteDataReader reader = command.ExecuteReader();
reader.Read();
int version = reader.GetInt32(0);
@@ -617,24 +586,14 @@ namespace Vocaluxe.Base
List<SData> scores = new List<SData>();
List<SData> songs = new List<SData>();
SQLiteDataReader reader = null;
command.CommandText = "SELECT id, PlayerName, Date FROM Scores";
try
{
reader = command.ExecuteReader();
}
catch (Exception)
{
throw;
}
SQLiteDataReader reader = command.ExecuteReader();
if (reader != null && reader.HasRows)
{
while (reader.Read())
{
SData data = new SData();
data.Id = reader.GetInt32(0);
data.Str1 = reader.GetString(1);
SData data = new SData {Id = reader.GetInt32(0), Str1 = reader.GetString(1)};
Int64 ticks = 0;
try
@@ -658,10 +617,7 @@ namespace Vocaluxe.Base
{
while (reader.Read())
{
SData data = new SData();
data.Id = reader.GetInt32(0);
data.Str1 = reader.GetString(1);
data.Str2 = reader.GetString(2);
SData data = new SData {Id = reader.GetInt32(0), Str1 = reader.GetString(1), Str2 = reader.GetString(2)};
songs.Add(data);
}
}
@@ -792,21 +748,13 @@ namespace Vocaluxe.Base
while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW)
{
SData data = new SData();
data.Id = Sqlite3.sqlite3_column_int(stmt, 0);
SData data = new SData {Id = Sqlite3.sqlite3_column_int(stmt, 0)};
byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1);
if (bytes != null)
data.Str1 = utf8.GetString(Encoding.Convert(cp1252, utf8, bytes));
else
data.Str1 = "Someone";
data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone";
bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 2);
if (bytes != null)
data.Str2 = utf8.GetString(Encoding.Convert(cp1252, utf8, bytes));
else
data.Str2 = "Someone";
data.Str2 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone";
songs.Add(data);
}
@@ -830,15 +778,10 @@ namespace Vocaluxe.Base
while (Sqlite3.sqlite3_step(stmt) == Sqlite3.SQLITE_ROW)
{
SData data = new SData();
data.Id = Sqlite3.sqlite3_column_int(stmt, 0);
SData data = new SData {Id = Sqlite3.sqlite3_column_int(stmt, 0)};
byte[] bytes = Sqlite3.sqlite3_column_rawbytes(stmt, 1);
if (bytes != null)
data.Str1 = utf8.GetString(Encoding.Convert(cp1252, utf8, bytes));
else
data.Str1 = "Someone";
data.Str1 = bytes != null ? utf8.GetString(Encoding.Convert(cp1252, utf8, bytes)) : "Someone";
if (dateExists)
data.Ticks = _UnixTimeToTicks(Sqlite3.sqlite3_column_int(stmt, 2));
@@ -915,7 +858,7 @@ namespace Vocaluxe.Base
return true;
}
private static bool _ImportData(string sourceDBPath, string destinationDBPath)
private static bool _ImportData(string sourceDBPath)
{
#region open db
using (SQLiteConnection connSource = new SQLiteConnection())
@@ -935,11 +878,9 @@ namespace Vocaluxe.Base
using (SQLiteCommand cmdSource = new SQLiteCommand(connSource))
{
SQLiteDataReader source;
#region import table 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)
return false;
@@ -987,8 +928,7 @@ namespace Vocaluxe.Base
if (_ConnectionCover == null)
{
_ConnectionCover = new SQLiteConnection();
_ConnectionCover.ConnectionString = "Data Source=" + _CoverFilePath;
_ConnectionCover = new SQLiteConnection {ConnectionString = "Data Source=" + _CoverFilePath};
_ConnectionCover.Open();
}
@@ -1247,6 +1187,13 @@ namespace Vocaluxe.Base
reader.Read();
byte[] data = _GetBytes(reader);
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!
/*
private static bool _AddImageToCreditsDB(String imagePath)
{
bool result = false;
@@ -1332,6 +1280,7 @@ namespace Vocaluxe.Base
return result;
}
*/
private static bool _InitCreditsRessourcesDB()
{
@@ -1387,6 +1336,7 @@ namespace Vocaluxe.Base
return true;
}
/*
private static void _CreateCreditsRessourcesDB()
{
using (SQLiteConnection connection = new SQLiteConnection())
@@ -1421,16 +1371,17 @@ namespace Vocaluxe.Base
}
}
}
*/
#endregion CreditsRessources
private static byte[] _GetBytes(SQLiteDataReader reader)
{
const int chunkSize = 2 * 1024;
byte[] buffer = new byte[chunkSize];
long bytesRead;
long fieldOffset = 0;
using (MemoryStream stream = new MemoryStream())
{
long bytesRead;
while ((bytesRead = reader.GetBytes(0, fieldOffset, buffer, 0, buffer.Length)) > 0)
{
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.IO;
using System.Windows.Forms;
@@ -255,7 +274,7 @@ namespace Vocaluxe.Base
if (rect.Height <= 0f)
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),
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.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
@@ -20,15 +40,14 @@ namespace Vocaluxe.Base
}
public STexture Texture;
public char Chr;
public int Width;
public readonly int Width;
public CGlyph(char chr, float maxHigh)
{
_Sizeh = maxHigh;
float outline = CFonts.Outline;
TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix;
const TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix;
float factor = _GetFactor(chr, flags);
CFonts.Height = Sizeh * factor;
@@ -91,7 +110,6 @@ namespace Vocaluxe.Base
* */
Texture = CDraw.AddTexture(bmp);
//bmp.Save("test.png", ImageFormat.Png);
Chr = chr;
Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width);
g.Dispose();
}
@@ -139,7 +157,7 @@ namespace Vocaluxe.Base
private FontFamily _Family;
private readonly float _Sizeh;
public string FilePath;
public readonly string FilePath;
public CFont(string file)
{
@@ -322,37 +340,17 @@ namespace Vocaluxe.Base
public static float Height
{
get { return _Height; }
set
{
if (value < 0f)
_Height = 0f;
else
_Height = value;
}
set { _Height = value < 0f ? 0f : value; }
}
public static float 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
{
get { return _Fonts[_CurrentFont].OutlineColor; }
set
{
SFont font = _Fonts[_CurrentFont];
font.OutlineColor = value;
}
}
public static void Init()
@@ -412,7 +410,7 @@ namespace Vocaluxe.Base
if (h <= 0f)
return;
if (text.Length == 0)
if (text == "")
return;
Height = h;
@@ -431,7 +429,7 @@ namespace Vocaluxe.Base
if (h <= 0f)
return;
if (text.Length == 0)
if (text == "")
return;
Height = h;
@@ -450,7 +448,7 @@ namespace Vocaluxe.Base
if (h <= 0f)
return;
if (text.Length == 0)
if (text == "")
return;
Height = h;
@@ -506,7 +504,7 @@ namespace Vocaluxe.Base
public static void SetFont(string fontName)
{
int index = -1;
int index;
if (PartyModeID != -1)
{
@@ -551,77 +549,63 @@ namespace Vocaluxe.Base
public static float GetTextWidth(string text)
{
float dx = 0;
CFont font = _GetCurrentFont();
foreach (char chr in text)
dx += font.GetWidth(chr);
return dx;
return text.Sum(chr => font.GetWidth(chr));
}
public static float GetTextHeight(string text)
{
//return TextRenderer.MeasureText(text, GetFont()).Height;
float h = 0f;
CFont font = _GetCurrentFont();
foreach (char chr in text)
{
float hh = font.GetHeight(chr);
if (hh > h)
h = hh;
}
return h;
return text == "" ? 0 : text.Select(font.GetHeight).Max();
}
private static void _LoadFontFiles(CXMLReader xmlReader, string fontFolder, string themeName = "", int partyModeId = -1)
{
string value = string.Empty;
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();
sf.Folder = value;
sf.IsThemeFont = themeName.Length > 0;
sf.ThemeName = themeName;
sf.PartyModeID = partyModeId;
SFont sf = new SFont {Folder = value, IsThemeFont = themeName != "", ThemeName = themeName, PartyModeID = partyModeId};
bool ok = true;
string name = String.Empty;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Name", ref name, value);
string name;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i + "/Name", out name, value);
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;
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
CFont f = new CFont(value);
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;
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
f = new CFont(value);
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;
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
f = new CFont(value);
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;
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
f = new CFont(value);
sf.BoldItalic = f;
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);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/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.ToString() + "/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 + "/OutlineColorR", ref sf.OutlineColor.R);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i + "/OutlineColorG", ref sf.OutlineColor.G);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i + "/OutlineColorB", ref sf.OutlineColor.B);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i + "/OutlineColorA", ref sf.OutlineColor.A);
if (ok)
_Fonts.Add(sf);
@@ -630,11 +614,11 @@ namespace Vocaluxe.Base
string fontTypes;
if (partyModeId >= 0)
fontTypes = "theme fonts for party mode";
else if (themeName.Length > 0)
else if (themeName != "")
fontTypes = "theme fonts for theme \"" + themeName + "\"";
else
fontTypes = "basic fonts";
CLog.LogError("Error loading " + fontTypes + ": Error in Font" + i.ToString());
CLog.LogError("Error loading " + fontTypes + ": Error in Font" + i);
}
i++;
}
@@ -696,7 +680,7 @@ namespace Vocaluxe.Base
setStart = true;
}
writer.WriteStartElement("Font" + fontNr.ToString());
writer.WriteStartElement("Font" + fontNr);
writer.WriteElementString("Name", _Fonts[index].Name);
writer.WriteElementString("Folder", _Fonts[index].Folder);
@@ -746,7 +730,7 @@ namespace Vocaluxe.Base
private static int _GetFontIndex(string themeName, string fontName)
{
if (themeName.Length == 0 || fontName.Length == 0)
if (themeName == "" || fontName == "")
return -1;
for (int i = 0; i < _Fonts.Count; i++)
@@ -760,7 +744,7 @@ namespace Vocaluxe.Base
private static int _GetFontIndexParty(int partyModeID, string fontName)
{
if (partyModeID == -1 || fontName.Length == 0)
if (partyModeID == -1 || fontName == "")
return -1;
for (int i = 0; i < _Fonts.Count; i++)
@@ -774,7 +758,7 @@ namespace Vocaluxe.Base
private static void _BuildGlyphs()
{
string text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890";
const string text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890";
for (int i = 0; i < _Fonts.Count; i++)
{
+147 -155
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 Vocaluxe.GameModes;
using VocaluxeLib.Menu;
@@ -10,14 +29,8 @@ namespace Vocaluxe.Base
static class CGame
{
private static IGameMode _GameMode;
private static SPlayer[] _Player;
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 readonly Random _Rand = new Random();
@@ -39,36 +52,21 @@ namespace Vocaluxe.Base
return 0f;
}
public static int CurrentBeat
{
get { return _CurrentBeat; }
}
public static int CurrentBeat { get; private set; }
public static float Beat
{
get { return _Beat; }
}
public static float Beat { get; private set; }
public static float MidBeatD
{
get { return _MidBeatD; }
}
public static float MidBeatD { get; private set; }
public static int ActBeatD
{
get { return _CurrentBeatD; }
}
public static int ActBeatD { get; private set; }
public static SPlayer[] Player
{
get { return _Player; }
}
public static SPlayer[] Players { get; private set; }
public static void Init()
{
_GameMode = new CGameModeNormal();
_GameMode.Init();
_Player = new SPlayer[CSettings.MaxNumPlayer];
Players = new SPlayer[CSettings.MaxNumPlayer];
ResetPlayer();
CConfig.UsePlayers();
@@ -117,12 +115,12 @@ namespace Vocaluxe.Base
public static void Start()
{
_GameMode.Start(_Player);
_GameMode.Start(Players);
}
public static void NextRound()
{
_GameMode.NextRound(_Player);
_GameMode.NextRound(Players);
}
public static bool IsFinished()
@@ -177,63 +175,61 @@ namespace Vocaluxe.Base
public static void ResetPlayer()
{
for (int i = 0; i < _Player.Length; i++)
for (int i = 0; i < Players.Length; i++)
{
_Player[i].Points = 0f;
_Player[i].PointsLineBonus = 0f;
_Player[i].PointsGoldenNotes = 0f;
_Player[i].LineNr = 0;
_Player[i].NoteDiff = 0;
_Player[i].SingLine = new List<CLine>();
_Player[i].CurrentLine = -1;
_Player[i].CurrentNote = -1;
_Player[i].SongID = -1;
_Player[i].Medley = false;
_Player[i].Duet = false;
_Player[i].ShortSong = false;
_Player[i].DateTicks = DateTime.Now.Ticks;
_Player[i].SongFinished = false;
Players[i].Points = 0f;
Players[i].PointsLineBonus = 0f;
Players[i].PointsGoldenNotes = 0f;
Players[i].LineNr = 0;
Players[i].NoteDiff = 0;
Players[i].SingLine = new List<CLine>();
Players[i].CurrentLine = -1;
Players[i].CurrentNote = -1;
Players[i].SongID = -1;
Players[i].Medley = false;
Players[i].Duet = false;
Players[i].ShortSong = false;
Players[i].DateTicks = DateTime.Now.Ticks;
Players[i].SongFinished = false;
}
_OldBeatD = -100;
_Beat = -100;
_CurrentBeat = -100;
_CurrentBeatD = -100;
Beat = -100;
CurrentBeat = -100;
ActBeatD = -100;
}
public static void UpdatePoints(float time)
{
bool debugHit = false;
CSong song = _GameMode.GetSong();
if (song == null)
return;
float b = GetBeatFromTime(time, song.BPM, song.Gap);
if (b <= _Beat)
if (b <= Beat)
return;
_Beat = b;
_CurrentBeat = (int)Math.Floor(_Beat);
Beat = b;
CurrentBeat = (int)Math.Floor(Beat);
_MidBeatD = -0.5f + GetBeatFromTime(time, song.BPM, song.Gap + CConfig.MicDelay / 1000f);
_CurrentBeatD = (int)Math.Floor(_MidBeatD);
MidBeatD = -0.5f + GetBeatFromTime(time, song.BPM, song.Gap + CConfig.MicDelay / 1000f);
ActBeatD = (int)Math.Floor(MidBeatD);
for (int p = 0; p < _NumPlayer; p++)
CSound.AnalyzeBuffer(p);
if (_OldBeatD >= _CurrentBeatD)
if (_OldBeatD >= ActBeatD)
return;
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) ||
(_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;
for (int j = 0; j < lines.Length; j++)
@@ -245,125 +241,121 @@ namespace Vocaluxe.Base
}
}
if (line >= 0)
if (line < 0)
continue;
if (line != Players[p].CurrentLine)
Players[p].CurrentNote = -1;
Players[p].CurrentLine = line;
while (Players[p].SingLine.Count <= line)
Players[p].SingLine.Add(new CLine());
CNote[] notes = lines[line].Notes;
int note = -1;
for (int j = 0; j < notes.Length; j++)
{
if (line != _Player[p].CurrentLine)
_Player[p].CurrentNote = -1;
_Player[p].CurrentLine = line;
while (_Player[p].SingLine.Count <= line)
_Player[p].SingLine.Add(new CLine());
CNote[] notes = lines[line].Notes;
int note = -1;
for (int j = 0; j < notes.Length; j++)
if (beat >= notes[j].StartBeat && beat <= notes[j].EndBeat)
{
if (beat >= notes[j].StartBeat && beat <= notes[j].EndBeat)
note = j;
break;
}
}
if (note >= 0)
{
Players[p].CurrentNote = note;
if (line == lines.Length - 1)
{
if (note == lines[line].NoteCount - 1)
{
note = j;
break;
if (notes[note].EndBeat == beat)
Players[p].SongFinished = true;
}
}
if (note >= 0)
if (notes[note].PointsForBeat > 0 && CSound.RecordToneValid(p))
{
_Player[p].CurrentNote = note;
int tone = notes[note].Tone;
int tonePlayer = CSound.RecordGetTone(p);
if (line == lines.Length - 1)
while (tonePlayer - tone > 6)
tonePlayer -= 12;
while (tonePlayer - tone < -6)
tonePlayer += 12;
Players[p].NoteDiff = Math.Abs(tone - tonePlayer);
bool hit = Players[p].NoteDiff <= (2 - (int)CProfiles.GetDifficulty(Players[p].ProfileID));
if (hit)
{
if (note == lines[line].NoteCount - 1)
// valid
//CSound.RecordSetTone(p, Tone);
double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat /
song.Notes.GetVoice(Players[p].LineNr).Points;
if (notes[note].NoteType == ENoteType.Golden)
Players[p].PointsGoldenNotes += points;
Players[p].Points += points;
// update player notes (sung notes)
if (Players[p].SingLine[line].NoteCount > 0)
{
if (notes[note].EndBeat == beat)
_Player[p].SongFinished = true;
}
}
if (notes[note].PointsForBeat > 0 && (CSound.RecordToneValid(p) || debugHit))
{
int tone = notes[note].Tone;
int tonePlayer = CSound.RecordGetTone(p);
while (tonePlayer - tone > 6)
tonePlayer -= 12;
while (tonePlayer - tone < -6)
tonePlayer += 12;
if (debugHit)
tonePlayer = tone;
_Player[p].NoteDiff = Math.Abs(tone - tonePlayer);
bool hit = _Player[p].NoteDiff <= (2 - (int)_Player[p].Difficulty);
if (hit)
{
// valid
//CSound.RecordSetTone(p, Tone);
double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat /
song.Notes.GetLines(_Player[p].LineNr).Points;
if (notes[note].NoteType == ENoteType.Golden)
_Player[p].PointsGoldenNotes += points;
_Player[p].Points += points;
// update player notes (sung notes)
if (_Player[p].SingLine[line].NoteCount > 0)
{
CNote nt = _Player[p].SingLine[line].LastNote;
if (notes[note].StartBeat == beat || nt.EndBeat + 1 != beat || nt.Tone != tone || !nt.Hit)
_Player[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType));
else
_Player[p].SingLine[line].IncLastNoteLength();
}
CNote lastNote = Players[p].SingLine[line].LastNote;
if (notes[note].StartBeat == beat || lastNote.EndBeat + 1 != beat || lastNote.Tone != tone || !lastNote.Hit)
Players[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType));
else
_Player[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType));
_Player[p].SingLine[line].LastNote.IsPerfect(notes[note]);
_Player[p].SingLine[line].IsPerfect(lines[line]);
Players[p].SingLine[line].IncLastNoteLength();
}
else
{
if (_Player[p].SingLine[line].NoteCount > 0)
{
CNote nt = _Player[p].SingLine[line].LastNote;
if (nt.Tone == tonePlayer && nt.EndBeat + 1 == beat && !nt.Hit)
_Player[p].SingLine[line].IncLastNoteLength();
else
_Player[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle));
}
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, tone, String.Empty, true, notes[note].NoteType));
Players[p].SingLine[line].LastNote.IsPerfect(notes[note]);
Players[p].SingLine[line].IsPerfect(lines[line]);
}
// Line Bonus
int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(_Player[p].LineNr);
if (note == lines[line].NoteCount - 1 && numLinesWithPoints > 0)
else
{
if (notes[note].EndBeat == beat && lines[line].Points > 0f)
if (Players[p].SingLine[line].NoteCount > 0)
{
double factor = _Player[p].SingLine[line].Points / (double)lines[line].Points;
if (factor < 0.4)
factor = 0.0;
else if (factor > 0.9)
factor = 1.0;
CNote lastNote = Players[p].SingLine[line].LastNote;
if (lastNote.Tone == tonePlayer && lastNote.EndBeat + 1 == beat && !lastNote.Hit)
Players[p].SingLine[line].IncLastNoteLength();
else
{
factor -= 0.4;
factor *= 2;
factor *= factor;
}
double points = CSettings.LinebonusScore * factor * 1f / numLinesWithPoints;
_Player[p].Points += points;
_Player[p].PointsLineBonus += points;
Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle));
}
else
Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle));
}
}
// Line Bonus
int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(Players[p].LineNr);
if (note == lines[line].NoteCount - 1 && numLinesWithPoints > 0)
{
if (notes[note].EndBeat == beat && lines[line].Points > 0f)
{
double factor = Players[p].SingLine[line].Points / (double)lines[line].Points;
if (factor < 0.4)
factor = 0.0;
else if (factor > 0.9)
factor = 1.0;
else
{
factor -= 0.4;
factor *= 2;
factor *= factor;
}
double points = CSettings.LinebonusScore * factor * 1f / numLinesWithPoints;
Players[p].Points += points;
Players[p].PointsLineBonus += points;
}
}
}
}
}
_OldBeatD = _CurrentBeatD;
_OldBeatD = ActBeatD;
}
}
}
+82 -151
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.Diagnostics;
using System.Drawing;
@@ -9,14 +28,6 @@ using VocaluxeLib.PartyModes;
namespace Vocaluxe.Base
{
enum EPopupScreens
{
PopupPlayerControl = 0,
PopupVolumeControl = 1,
NoPopup = -1
}
class CCursor
{
private readonly Stopwatch _CursorFadingTimer;
@@ -103,7 +114,7 @@ namespace Vocaluxe.Base
if (Math.Abs(_Cursor.Rect.X - x) > CSettings.MouseMoveDiffMin ||
Math.Abs(_Cursor.Rect.Y - y) > CSettings.MouseMoveDiffMin)
{
if (_CursorTargetAlpha == 0f)
if (_CursorTargetAlpha < 0.01)
_Fade(1f, 0.2f);
_Movetimer.Reset();
@@ -254,41 +265,41 @@ namespace Vocaluxe.Base
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();
_PopupScreens[i].LoadTheme(CTheme.GetThemeScreensPath(-1));
popup.Init();
popup.LoadTheme(CTheme.GetThemeScreensPath(-1));
}
}
public static void ReloadTheme()
{
_ReloadCursor();
for (int i = 0; i < _Screens.Count; i++)
_Screens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1));
foreach (IMenu screen in _Screens)
screen.ReloadTheme(CTheme.GetThemeScreensPath(-1));
for (int i = 0; i < _PopupScreens.Count; i++)
_PopupScreens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1));
foreach (IMenu popup in _PopupScreens)
popup.ReloadTheme(CTheme.GetThemeScreensPath(-1));
}
public static void ReloadSkin()
{
_ReloadCursor();
for (int i = 0; i < _Screens.Count; i++)
_Screens[i].ReloadTextures();
foreach (IMenu menu in _Screens)
menu.ReloadTextures();
for (int i = 0; i < _PopupScreens.Count; i++)
_PopupScreens[i].ReloadTextures();
foreach (IMenu menu in _PopupScreens)
menu.ReloadTextures();
}
public static void SaveTheme()
{
CTheme.SaveTheme();
for (int i = 0; i < _Screens.Count; i++)
_Screens[i].SaveTheme();
foreach (IMenu screen in _Screens)
screen.SaveTheme();
for (int i = 0; i < _PopupScreens.Count; i++)
_PopupScreens[i].SaveTheme();
foreach (IMenu popup in _PopupScreens)
popup.SaveTheme();
}
public static void InitFirstScreen()
@@ -393,7 +404,7 @@ namespace Vocaluxe.Base
GC.Collect();
_CurrentScreen = _NextScreen;
_NextScreen = EScreens.ScreenNull;
if (CBackgroundMusic.Playing)
if (CBackgroundMusic.IsPlaying)
CBackgroundMusic.Play();
_Screens[(int)_CurrentScreen].OnShowFinish();
_Screens[(int)_CurrentScreen].ProcessMouseMove(_Cursor.X, _Cursor.Y);
@@ -425,8 +436,8 @@ namespace Vocaluxe.Base
_OldScreen = _Screens[(int)_CurrentScreen];
}
for (int i = 0; i < _PopupScreens.Count; i++)
_PopupScreens[i].Draw();
foreach (IMenu popup in _PopupScreens)
popup.Draw();
_Cursor.Draw();
_DrawDebugInfos();
@@ -499,7 +510,7 @@ namespace Vocaluxe.Base
bool resume = true;
bool eventsAvailable = false;
bool eventsAvailable;
bool inputEventsAvailable = CInput.PollKeyEvent(ref inputKeyEvent);
while ((eventsAvailable = keys.PollEvent(ref keyEvent)) || inputEventsAvailable)
@@ -524,15 +535,15 @@ namespace Vocaluxe.Base
if (popupPlayerControlAllowed && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
{
if (keyEvent.Key == Keys.MediaNextTrack)
CMain.BackgroundMusic.Next();
CBackgroundMusic.Next();
else if (keyEvent.Key == Keys.MediaPreviousTrack)
CMain.BackgroundMusic.Previous();
CBackgroundMusic.Previous();
else if (keyEvent.Key == Keys.MediaPlayPause)
{
if (CMain.BackgroundMusic.IsPlaying())
CMain.BackgroundMusic.Pause();
if (CBackgroundMusic.IsPlaying)
CBackgroundMusic.Pause();
else
CMain.BackgroundMusic.Play();
CBackgroundMusic.Play();
}
}
@@ -582,7 +593,7 @@ namespace Vocaluxe.Base
_VolumePopupTimer.Start();
}
CMain.BackgroundMusic.ApplyVolume();
CBackgroundMusic.ApplyVolume();
}
if (keyEvent.ModShift && (keyEvent.Key == Keys.F1))
@@ -727,125 +738,46 @@ namespace Vocaluxe.Base
private static void _DrawDebugInfos()
{
string txt = String.Empty;
if (CConfig.DebugLevel == EDebugLevel.TR_CONFIG_OFF)
return;
List<String> debugOutput = new List<string> {CTime.GetFPS().ToString("FPS: 000")};
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);
debugOutput.Add((memory / 1000000L).ToString(CLanguage.Translate("TR_DEBUG_MEMORY") + ": 00000 MB"));
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2)
{
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"));
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"));
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3)
{
debugOutput.Add(CSongs.NumSongsWithCoverLoaded.ToString(CLanguage.Translate("TR_DEBUG_SONGS") + ": 00000"));
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 dy = 0;
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_ONLY_FPS)
float y = 0;
foreach (string txt in debugOutput)
{
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));
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), y, 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)
{
long memory = GC.GetTotalMemory(false);
txt = (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)
{
txt = CSound.RecordGetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 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;
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)
{
txt = 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)
{
txt = _Cursor.X.ToString(CLanguage.Translate("TR_DEBUG_MOUSE") + " : (0000/") + _Cursor.Y.ToString("0000)");
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;
y += rect.Height;
}
}
@@ -853,10 +785,9 @@ namespace Vocaluxe.Base
{
_Cursor.UnloadTextures();
if (CTheme.Cursor.Color.Length > 0)
if (CTheme.Cursor.Color != "")
{
SColorF color;
color = CTheme.GetColor(CTheme.Cursor.Color, -1);
SColorF color = CTheme.GetColor(CTheme.Cursor.Color, -1);
CTheme.Cursor.R = color.R;
CTheme.Cursor.G = color.G;
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 VocaluxeLib.Menu;
@@ -21,14 +40,14 @@ namespace Vocaluxe.Base
_Input = null;
}
public static bool Connect()
public static void Connect()
{
return _Input.Connect();
_Input.Connect();
}
public static bool Disconnect()
public static void Disconnect()
{
return _Input.Disconnect();
_Input.Disconnect();
}
public static bool IsConnected()
+42 -34
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.IO;
using System.Text;
@@ -44,7 +63,7 @@ namespace Vocaluxe.Base
return _Languages[lang].Name;
}
public static string[] GetLanguageNames()
public static IEnumerable<string> GetLanguageNames()
{
string[] languages = new string[_Languages.Count];
@@ -89,12 +108,7 @@ namespace Vocaluxe.Base
return -1;
}
public static string Translate(string keyWord)
{
return Translate(keyWord, -1);
}
public static string Translate(string keyWord, int partyModeID)
public static string Translate(string keyWord, int partyModeID = -1)
{
if (keyWord == null)
return "Error";
@@ -162,24 +176,23 @@ namespace Vocaluxe.Base
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>();
List<string> names = xmlReader.GetAttributes("resources", "name");
string value = string.Empty;
IEnumerable<string> names = xmlReader.GetAttributes("resources", "name");
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);
}
catch (Exception e)
{
CLog.LogError("Error reading language file " + xmlReader.FileName + ": " + e.Message);
return false;
}
texts.Add(name, value);
}
catch (Exception e)
{
CLog.LogError("Error reading language file " + xmlReader.FileName + ": " + e.Message);
return false;
}
}
return true;
@@ -192,39 +205,34 @@ namespace Vocaluxe.Base
return false;
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);
if (nr == -1)
return true;
SPartyLanguage lang = new SPartyLanguage();
lang.PartyModeID = partyModeID;
if (!_LoadLanguageEntries(xmlReader, ref lang.Texts))
SPartyLanguage lang = new SPartyLanguage {PartyModeID = partyModeID};
if (!_LoadLanguageEntries(xmlReader, out lang.Texts))
return false;
_Languages[nr].PartyModeTexts.Add(lang);
return true;
}
else
{
CLog.LogError("Error reading Party Language File " + file);
return false;
}
CLog.LogError("Error reading Party Language File " + file);
return false;
}
private static void _LoadLanguageFile(string fileName)
{
SLanguage lang = new SLanguage();
lang.LanguageFilePath = Path.Combine(CSettings.FolderLanguages, fileName);
SLanguage lang = new SLanguage {LanguageFilePath = Path.Combine(CSettings.FolderLanguages, fileName)};
CXMLReader xmlReader = CXMLReader.OpenFile(lang.LanguageFilePath);
if (xmlReader == null)
return;
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;
@@ -233,7 +241,7 @@ namespace Vocaluxe.Base
lang.PartyModeTexts = new List<SPartyLanguage>();
_LoadLanguageEntries(xmlReader, ref lang.Texts);
_LoadLanguageEntries(xmlReader, out lang.Texts);
_Languages.Add(lang);
}
+34 -17
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.IO;
using System.Text;
@@ -17,6 +36,15 @@ namespace Vocaluxe.Base
_LogFileName = fileName;
}
private void _Open()
{
_LogFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, _LogFileName), false, Encoding.UTF8);
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
_LogFile.WriteLine("----------------------------------------");
_LogFile.WriteLine();
}
public void Close()
{
if (_LogFile == null)
@@ -34,21 +62,10 @@ namespace Vocaluxe.Base
if (_LogFile == null)
_Open();
try
{
_LogFile.WriteLine(text);
_LogFile.Flush();
}
catch (Exception) {}
}
private void _Open()
{
_LogFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, _LogFileName), false, Encoding.UTF8);
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
_LogFile.WriteLine("----------------------------------------");
_LogFile.WriteLine();
// ReSharper disable PossibleNullReferenceException
_LogFile.WriteLine(text);
// ReSharper restore PossibleNullReferenceException
_LogFile.Flush();
}
public void Dispose()
@@ -139,7 +156,7 @@ namespace Vocaluxe.Base
space += " ";
float ms;
if (Stopwatch.IsHighResolution && _NanosecPerTick != 0.0)
if (Stopwatch.IsHighResolution && _NanosecPerTick > 0)
ms = (float)((_NanosecPerTick * _BenchmarkTimer[benchmarkNr].ElapsedTicks) / (1000.0 * 1000.0));
else
ms = _BenchmarkTimer[benchmarkNr].ElapsedMilliseconds;
+61 -50
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.Drawing;
using VocaluxeLib.Menu;
@@ -8,31 +27,30 @@ namespace Vocaluxe.Base
{
static class CMain
{
public static IConfig Config = new CBconfig();
public static ISettings Settings = new CBsettings();
public static ITheme Theme = new CBtheme();
public static IHelper Helper = new CBhelper();
public static IBackgroundMusic BackgroundMusic = new CBbackgroundMusic();
public static IDrawing Draw = new CBdraw();
public static IGraphics Graphics = new CBGraphics();
public static ILog Log = new CBlog();
public static IFonts Fonts = new CBfonts();
public static ILanguage Language = new CBlanguage();
public static IGame Game = new CBGame();
public static IProfiles Profiles = new CBprofiles();
public static IRecording Record = new CBrecord();
public static ISongs Songs = new CBsongs();
public static IVideo Video = new CBvideo();
public static ISound Sound = new CBsound();
public static ICover Cover = new CBcover();
public static IDataBase DataBase = new CBdataBase();
public static IInputs Input = new CBinputs();
public static IPlaylist Playlist = new CBplaylist();
private static readonly IConfig _Config = new CBconfig();
private static readonly ISettings _Settings = new CBsettings();
private static readonly ITheme _Theme = new CBtheme();
private static readonly IBackgroundMusic _BackgroundMusic = new CBbackgroundMusic();
private static readonly IDrawing _Draw = new CBdraw();
private static readonly IGraphics _Graphics = new CBGraphics();
private static readonly ILog _Log = new CBlog();
private static readonly IFonts _Fonts = new CBfonts();
private static readonly ILanguage _Language = new CBlanguage();
private static readonly IGame _Game = new CBGame();
private static readonly IProfiles _Profiles = new CBprofiles();
private static readonly IRecording _Record = new CBrecord();
private static readonly ISongs _Songs = new CBsongs();
private static readonly IVideo _Video = new CBvideo();
private static readonly ISound _Sound = new CBsound();
private static readonly ICover _Cover = new CBcover();
private static readonly IDataBase _DataBase = new CBdataBase();
private static readonly IInputs _Input = new CBinputs();
private static readonly IPlaylist _Playlist = new CBplaylist();
public static void Init()
{
CBase.Assign(Config, Settings, Theme, Helper, Log, BackgroundMusic, Draw, Graphics, Fonts, Language,
Game, Profiles, Record, Songs, Video, Sound, Cover, DataBase, Input, Playlist);
CBase.Assign(_Config, _Settings, _Theme, _Log, _BackgroundMusic, _Draw, _Graphics, _Fonts, _Language,
_Game, _Profiles, _Record, _Songs, _Video, _Sound, _Cover, _DataBase, _Input, _Playlist);
}
}
@@ -40,14 +58,7 @@ namespace Vocaluxe.Base
{
public void SetBackgroundMusicVolume(int newVolume)
{
if (newVolume < 0)
CConfig.BackgroundMusicVolume = 0;
else if (newVolume > 100)
CConfig.BackgroundMusicVolume = 100;
else
CConfig.BackgroundMusicVolume = newVolume;
CConfig.SaveConfig();
CConfig.BackgroundMusicVolume = newVolume;
}
public int GetBackgroundMusicVolume()
@@ -95,7 +106,7 @@ namespace Vocaluxe.Base
return CConfig.CoverSize;
}
public List<string> GetSongFolder()
public IEnumerable<string> GetSongFolder()
{
return CConfig.SongFolder;
}
@@ -122,15 +133,7 @@ namespace Vocaluxe.Base
public int GetMaxNumMics()
{
int max = 0;
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
if (CConfig.IsMicConfig(i + 1))
max = i + 1;
else
break;
}
return max;
return CConfig.GetMaxNumMics();
}
}
@@ -275,8 +278,6 @@ namespace Vocaluxe.Base
}
}
class CBhelper : IHelper {}
class CBbackgroundMusic : IBackgroundMusic
{
public bool IsDisabled()
@@ -286,7 +287,7 @@ namespace Vocaluxe.Base
public bool IsPlaying()
{
return CBackgroundMusic.Playing;
return CBackgroundMusic.IsPlaying;
}
public bool SongHasVideo()
@@ -477,9 +478,9 @@ namespace Vocaluxe.Base
CGame.NumPlayer = numPlayer;
}
public SPlayer[] GetPlayer()
public SPlayer[] GetPlayers()
{
return CGame.Player;
return CGame.Players;
}
public CPoints GetPoints()
@@ -539,6 +540,16 @@ namespace Vocaluxe.Base
{
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
@@ -667,9 +678,9 @@ namespace Vocaluxe.Base
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)
@@ -767,9 +778,9 @@ namespace Vocaluxe.Base
CPlaylists.SetPlaylistName(playlistID, name);
}
public string[] GetPlaylistNames()
public List<string> GetPlaylistNames()
{
return CPlaylists.GetPlaylistNames();
return CPlaylists.PlaylistNames;
}
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
{
@@ -7,7 +26,7 @@ namespace Vocaluxe.Base
public event EventHandler ObjectChanged = delegate { };
protected bool _Changed = true;
protected void _NotifyObservers()
private void _NotifyObservers()
{
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.Collections.Generic;
using System.IO;
@@ -48,9 +67,7 @@ namespace Vocaluxe.Base
_IDs.Enqueue(i);
//add dummy normal game mode and set it as default
SPartyMode pm = new SPartyMode();
pm.PartyMode = new CPartyModeNone();
pm.ScreenFiles = new List<string>();
SPartyMode pm = new SPartyMode {PartyMode = new CPartyModeNone(), ScreenFiles = new List<string>()};
pm.PartyMode.Initialize();
pm.PartyModeID = _IDs.Dequeue();
_NormalGameModeID = pm.PartyModeID;
@@ -81,33 +98,33 @@ namespace Vocaluxe.Base
{
List<SPartyModeInfos> infos = new List<SPartyModeInfos>();
int[] usedKeys = new int[_PartyModes.Count];
_PartyModes.Keys.CopyTo(usedKeys, 0);
int[] pmIDs = new int[_PartyModes.Count];
_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();
_PartyModes.TryGetValue(usedKeys[i], out mode);
SPartyMode mode;
_PartyModes.TryGetValue(pmID, out mode);
if (mode.PartyMode != null)
{
SPartyModeInfos info = new SPartyModeInfos();
info.Author = mode.Author;
info.Description = mode.Description;
info.Name = mode.Name;
info.PartyModeID = mode.PartyModeID;
info.Playable = mode.NoErrors;
info.VersionMajor = mode.PartyModeVersionMajor;
info.VersionMinor = mode.PartyModeVersionMinor;
info.TargetAudience = mode.TargetAudience;
info.MaxPlayers = mode.PartyMode.GetMaxPlayer();
info.MinPlayers = mode.PartyMode.GetMinPlayer();
info.MaxTeams = mode.PartyMode.GetMaxTeams();
info.MinTeams = mode.PartyMode.GetMinTeams();
SPartyModeInfos info = new SPartyModeInfos
{
Author = mode.Author,
Description = mode.Description,
Name = mode.Name,
PartyModeID = mode.PartyModeID,
Playable = mode.NoErrors,
VersionMajor = mode.PartyModeVersionMajor,
VersionMinor = mode.PartyModeVersionMinor,
TargetAudience = mode.TargetAudience,
MaxPlayers = mode.PartyMode.GetMaxPlayer(),
MinPlayers = mode.PartyMode.GetMinPlayer(),
MaxTeams = mode.PartyMode.GetMaxTeams(),
MinTeams = mode.PartyMode.GetMinTeams()
};
infos.Add(info);
}
@@ -125,7 +142,7 @@ namespace Vocaluxe.Base
public static void SetPartyMode(int partyModeID)
{
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();
}
@@ -213,10 +230,7 @@ namespace Vocaluxe.Base
private static SPartyMode _LoadPartyMode(string file)
{
SPartyMode pm = new SPartyMode();
pm.PartyModeID = _IDs.Dequeue();
pm.ScreenFiles = new List<string>();
pm.NoErrors = false;
SPartyMode pm = new SPartyMode {PartyModeID = _IDs.Dequeue(), ScreenFiles = new List<string>(), NoErrors = false};
CXMLReader xmlReader = CXMLReader.OpenFile(file);
@@ -227,15 +241,15 @@ namespace Vocaluxe.Base
bool loaded = true;
loaded &= xmlReader.TryGetIntValue("//root/PartyModeSystemVersion", ref pm.PartyModeSystemVersion);
loaded &= xmlReader.GetValue("//root/Info/Name", ref pm.Name, "ERROR Name");
loaded &= xmlReader.GetValue("//root/Info/Description", ref pm.Description, "ERROR Description");
loaded &= xmlReader.GetValue("//root/Info/Author", ref pm.Author, "ERROR Author");
loaded &= xmlReader.GetValue("//root/Info/Folder", ref pm.Folder, "ERROR Folder");
loaded &= xmlReader.GetValue("//root/Info/PartyModeFile", ref pm.PartyModeFile, "ERROR PartyModeFile");
loaded &= xmlReader.GetValue("//root/Info/Name", out pm.Name, "ERROR Name");
loaded &= xmlReader.GetValue("//root/Info/Description", out pm.Description, "ERROR Description");
loaded &= xmlReader.GetValue("//root/Info/Author", out pm.Author, "ERROR Author");
loaded &= xmlReader.GetValue("//root/Info/Folder", out pm.Folder, "ERROR Folder");
loaded &= xmlReader.GetValue("//root/Info/PartyModeFile", out pm.PartyModeFile, "ERROR PartyModeFile");
loaded &= xmlReader.GetInnerValues("PartyScreens", ref pm.ScreenFiles);
loaded &= xmlReader.TryGetIntValue("//root/Info/PartyModeVersionMajor", ref pm.PartyModeVersionMajor);
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)
{
@@ -324,14 +338,12 @@ namespace Vocaluxe.Base
private static Assembly _CompileFiles(string[] files)
{
if (files == null)
return null;
if (files.Length == 0)
if (files == null || files.Length == 0)
return null;
CompilerParameters compilerParams = new CompilerParameters();
compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");
compilerParams.ReferencedAssemblies.Add("System.Core.dll");
compilerParams.ReferencedAssemblies.Add("VocaluxeLib.dll");
compilerParams.GenerateInMemory = true;
#if DEBUG
@@ -340,7 +352,7 @@ namespace Vocaluxe.Base
using (CodeDomProvider cdp = CodeDomProvider.CreateProvider("CSharp"))
{
CompilerResults compileResult = null;
CompilerResults compileResult;
try
{
@@ -374,7 +386,7 @@ namespace Vocaluxe.Base
return null;
}
CMenuParty screen = null;
CMenuParty screen;
try
{
screen = (CMenuParty)instance;
+49 -43
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.IO;
using System.Text;
@@ -17,14 +36,14 @@ namespace Vocaluxe.Base
get { return _Playlists.ToArray(); }
}
public static string[] PlaylistNames
public static List<string> PlaylistNames
{
get
{
List<string> names = new List<string>();
for (int i = 0; i < _Playlists.Count; i++)
names.Add(_Playlists[i].PlaylistName);
return names.ToArray();
return names;
}
}
@@ -75,16 +94,6 @@ namespace Vocaluxe.Base
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)
{
if (playlistID >= _Playlists.Count || playlistID < 0)
@@ -97,7 +106,7 @@ namespace Vocaluxe.Base
{
if (playlistID < 0 || playlistID >= _Playlists.Count)
return;
if (_Playlists[playlistID].PlaylistFile.Length > 0)
if (_Playlists[playlistID].PlaylistFile != "")
{
try
{
@@ -120,8 +129,7 @@ namespace Vocaluxe.Base
public static int NewPlaylist()
{
CPlaylistFile pl = new CPlaylistFile();
pl.PlaylistName = "New Playlist";
CPlaylistFile pl = new CPlaylistFile {PlaylistName = "New Playlist"};
_Playlists.Add(pl);
return _Playlists.Count - 1;
}
@@ -209,7 +217,7 @@ namespace Vocaluxe.Base
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)
@@ -219,44 +227,42 @@ namespace Vocaluxe.Base
if (!File.Exists(file))
return null;
StreamReader sr;
try
{
StreamReader sr;
using (sr = new StreamReader(file, Encoding.Default, true))
{
int pos = -1;
string line;
while ((line = sr.ReadLine()) != null)
{
pos = line.IndexOf(":");
if (pos > 0)
int pos = line.IndexOf(":", StringComparison.Ordinal);
if (pos <= 0)
continue;
//Name or comment
if (line[0] == '#')
{
//Name or comment
if (line[0] == '#')
string identifier = line.Substring(1, pos - 1).Trim();
string value = line.Substring(pos + 1, line.Length - pos - 1).Trim();
if (identifier.ToUpper() == "NAME")
pl.PlaylistName = value;
}
//Song
else
{
string artist = line.Substring(0, pos - 1).Trim();
string title = line.Substring(pos + 1, line.Length - pos - 1).Trim();
bool found = false;
foreach (CSong song in allSongs)
{
string identifier = line.Substring(1, pos - 1).Trim();
string value = line.Substring(pos + 1, line.Length - pos - 1).Trim();
if (identifier.ToUpper() == "NAME")
pl.PlaylistName = value;
}
//Song
else
{
string artist = line.Substring(0, pos - 1).Trim();
string title = line.Substring(pos + 1, line.Length - pos - 1).Trim();
bool found = false;
for (int s = 0; s < allSongs.Length; s++)
if (song.Artist == artist && song.Title == title)
{
if (allSongs[s].Artist == artist && allSongs[s].Title == title)
{
pl.AddSong(allSongs[s].ID);
found = true;
break;
}
pl.AddSong(song.ID);
found = true;
break;
}
if (!found)
CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + file);
}
if (!found)
CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + file);
}
}
}
+113 -92
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.IO;
using System.Text;
@@ -43,25 +62,27 @@ namespace Vocaluxe.Base
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();
profile.PlayerName = String.Empty;
profile.Difficulty = EGameDifficulty.TR_CONFIG_EASY;
profile.Avatar = new SAvatar(-1);
profile.GuestProfile = EOffOn.TR_CONFIG_OFF;
profile.Active = EOffOn.TR_CONFIG_ON;
if (fileName.Length > 0)
profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName);
else
profile.ProfileFile = String.Empty;
SProfile profile = new SProfile
{
PlayerName = String.Empty,
Difficulty = EGameDifficulty.TR_CONFIG_EASY,
Avatar = new SAvatar(-1),
GuestProfile = EOffOn.TR_CONFIG_OFF,
Active = EOffOn.TR_CONFIG_ON,
ProfileFile = fileName != "" ? Path.Combine(CSettings.FolderProfiles, fileName) : String.Empty
};
if (File.Exists(profile.ProfileFile))
return -1;
@@ -110,133 +131,119 @@ namespace Vocaluxe.Base
if (tex.Index != -1)
{
SAvatar avatar = new SAvatar();
avatar.Texture = tex;
avatar.FileName = Path.GetFileName(file);
SAvatar avatar = new SAvatar {Texture = tex, FileName = Path.GetFileName(file)};
_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;
SProfile profile = _Profiles[profileNr];
SProfile profile = _Profiles[profileID];
profile.PlayerName += chr;
_Profiles[profileNr] = profile;
_Profiles[profileID] = profile;
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 _Profiles[profileNr].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)
SProfile profile = _Profiles[profileID];
if (profile.PlayerName != "")
profile.PlayerName = profile.PlayerName.Remove(profile.PlayerName.Length - 1);
_Profiles[profileNr] = profile;
_Profiles[profileID] = profile;
return profile.PlayerName;
}
public static EGameDifficulty GetDifficulty(int profileNr)
public static bool IsProfileIDValid(int profileID)
{
if (profileNr < 0 || profileNr >= _Profiles.Count)
return EGameDifficulty.TR_CONFIG_NORMAL;
return _Profiles[profileNr].Difficulty;
return profileID >= 0 && profileID < _Profiles.Count;
}
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;
SProfile profile = _Profiles[profileNr];
SProfile profile = _Profiles[profileID];
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 EOffOn.TR_CONFIG_OFF;
return _Profiles[profileNr].GuestProfile;
return IsProfileIDValid(profileID) ? _Profiles[profileID].GuestProfile : EOffOn.TR_CONFIG_OFF;
}
public static EOffOn GetActive(int profileNr)
public static EOffOn GetActive(int profileID)
{
if (profileNr < 0 || profileNr >= _Profiles.Count)
return EOffOn.TR_CONFIG_OFF;
return _Profiles[profileNr].Active;
return IsProfileIDValid(profileID) ? _Profiles[profileID].Active : EOffOn.TR_CONFIG_OFF;
}
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;
SProfile profile = _Profiles[profileNr];
SProfile profile = _Profiles[profileID];
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;
SProfile profile = _Profiles[profileNr];
SProfile profile = _Profiles[profileID];
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 _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 _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;
SProfile profile = _Profiles[profileNr];
SProfile profile = _Profiles[profileID];
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;
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;
}
@@ -245,20 +252,36 @@ namespace Vocaluxe.Base
public static void DeleteProfile(int profileID)
{
if (profileID < 0 || profileID >= _Profiles.Count)
if (!IsProfileIDValid(profileID))
return;
if (_Profiles[profileID].ProfileFile.Length > 0)
if (_Profiles[profileID].ProfileFile == "")
return;
try
{
try
//Check if profile saved in config
for (int i = 0; i < CConfig.Players.Length; i++)
{
File.Delete(_Profiles[profileID].ProfileFile);
_Profiles.RemoveAt(profileID);
if (CConfig.Players[i] == _Profiles[profileID].ProfileFile)
{
CConfig.Players[i] = string.Empty;
CConfig.SaveConfig();
}
}
catch (Exception)
File.Delete(_Profiles[profileID].ProfileFile);
_Profiles.RemoveAt(profileID);
//Check if profile is selected in game
for (int i = 0; i < CGame.Players.Length; i++)
{
CLog.LogError("Can't delete Profile File " + _Profiles[profileID].ProfileFile + ".xml");
if (CGame.Players[i].ProfileID > profileID)
CGame.Players[i].ProfileID--;
else if (CGame.Players[i].ProfileID == profileID)
CGame.Players[i].ProfileID = -1;
}
}
catch (Exception)
{
CLog.LogError("Can't delete Profile File " + _Profiles[profileID].ProfileFile + ".xml");
}
}
private static void _SortProfilesByName()
@@ -268,7 +291,7 @@ namespace Vocaluxe.Base
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
@@ -284,10 +307,10 @@ namespace Vocaluxe.Base
private static void _SaveProfile(int profileID)
{
if (profileID < 0 || profileID >= _Profiles.Count)
if (!IsProfileIDValid(profileID))
return;
if (_Profiles[profileID].ProfileFile.Length == 0)
if (_Profiles[profileID].ProfileFile == "")
{
string filename = string.Empty;
foreach (char chr in _Profiles[profileID].PlayerName)
@@ -296,7 +319,7 @@ namespace Vocaluxe.Base
filename += chr.ToString();
}
if (filename.Length == 0)
if (filename == "")
filename = "1";
int i = 0;
@@ -343,21 +366,19 @@ namespace Vocaluxe.Base
finally
{
writer.Close();
writer = null;
}
}
private static void _LoadProfile(string fileName)
{
SProfile profile = new SProfile();
profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName);
SProfile profile = new SProfile {ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName)};
CXMLReader xmlReader = CXMLReader.OpenFile(profile.ProfileFile);
if (xmlReader == null)
return;
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;
@@ -365,7 +386,7 @@ namespace Vocaluxe.Base
xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref profile.Difficulty);
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.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.IO;
using System.Reflection;
using VocaluxeLib.Menu;
namespace Vocaluxe.Base
{
enum ERevision
{
// ReSharper disable UnusedMember.Global
Alpha,
Beta,
RC,
Release
// ReSharper restore UnusedMember.Global
}
static class CSettings
{
#if ARCH_X86
public const String Arch = "x86";
private const String _Arch = "x86";
#endif
#if ARCH_X64
public const String Arch = "x64";
private const String _Arch = "x64";
#endif
public static EGameState GameState = EGameState.Start;
public const string ProgramName = "Vocaluxe";
public const string ProgramCodeName = "Shining Heaven";
//Adjusting of programName and version now in the assembly config.
//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 int Build = 78; // Increase on every published version! Never Reset!
public const int DatabaseHighscoreVersion = 2;
public const int DatabaseCoverVersion = 1;
public const int DatabaseCreditsRessourcesVersion = 1;
public static int RenderW = 1280;
public static int RenderH = 720;
public const int RenderW = 1280;
public const int RenderH = 720;
public const int ZNear = -100;
public const int ZFar = 100;
public static bool IsFullScreen = false;
public static int VertexBufferElements = 10000;
public static bool IsFullScreen;
public const int VertexBufferElements = 10000;
public const string Icon = "Vocaluxe.ico";
public const string Logo = "Logo.png";
public const string FallbackLanguage = "English";
public const string BassRegistration = "Registration.xml";
public static string FileConfig = "Config.xml";
public const string FileCover = "Cover.xml";
public const string FileFonts = "Fonts.xml";
public const string FileOldHighscoreDB = "Ultrastar.db";
@@ -70,7 +88,6 @@ namespace Vocaluxe.Base
public const string FolderGraphics = "Graphics";
public const string FolderFonts = "Fonts";
public const string FolderThemes = "Themes";
public const string FolderSkins = "Skins";
public const string FolderThemeFonts = "Fonts";
public const string FolderScreens = "Screens";
public static string FolderProfiles = "Profiles";
@@ -109,11 +126,11 @@ namespace Vocaluxe.Base
public const int MedleyMinSeriesLength = 3;
public const float MedleyMinDuration = 40f;
public static bool TabNavigation = false;
public const bool TabNavigation = false;
public const float BackgroundMusicFadeTime = 0.5f;
public static List<string> MusicFileTypes = new List<string>
public static readonly List<string> MusicFileTypes = new List<string>
{
"*.mp3",
"*.wma",
@@ -121,14 +138,32 @@ namespace Vocaluxe.Base
"*.wav"
};
public static string GetVersionText()
private static AssemblyName _Assembly
{
string version = "v" + VersionMajor.ToString() + "." +
VersionMinor.ToString() + "." +
VersionSub.ToString() + " (" + Arch + ")";
get { return Assembly.GetExecutingAssembly().GetName(); }
}
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)
version += " " + GetVersionStatus() + String.Format(" ({0:0000)}", Build);
// ReSharper restore ConditionIsAlwaysTrueOrFalse
version += " " + _GetVersionStatus() + String.Format(" ({0:0000)}", _Assembly.Version.Revision);
return version;
}
@@ -137,17 +172,21 @@ namespace Vocaluxe.Base
{
string version = ProgramName;
if (ProgramCodeName.Length > 0)
version += " \"" + ProgramCodeName + "\"";
// ReSharper disable ConditionIsAlwaysTrueOrFalse
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)
// ReSharper restore ConditionIsAlwaysTrueOrFalse
result = Enum.GetName(typeof(ERevision), VersionRevision);
return result;
@@ -170,16 +209,7 @@ namespace Vocaluxe.Base
public static void CreateFolders()
{
List<string> folders = new List<string>();
folders.Add(FolderCover);
folders.Add(FolderFonts);
folders.Add(FolderProfiles);
folders.Add(FolderSongs);
folders.Add(FolderScreenshots);
folders.Add(FolderBackgroundMusic);
folders.Add(FolderSounds);
folders.Add(FolderPlaylists);
List<string> folders = new List<string> {FolderCover, FolderFonts, FolderProfiles, FolderSongs, FolderScreenshots, FolderBackgroundMusic, FolderSounds, FolderPlaylists};
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.Text;
using VocaluxeLib.Menu;
@@ -79,7 +98,7 @@ namespace Vocaluxe.Base
int noCategoryIndex = -1;
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)
{
@@ -135,7 +154,7 @@ namespace Vocaluxe.Base
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
{
string year = CSongs.Sorter.SortedSongs[i].SortString;
if (year.Length > 0)
if (year != "")
{
year = year.Substring(0, 3);
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.Linq;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
@@ -65,7 +85,7 @@ namespace Vocaluxe.Base
_FilteredSongs.Clear();
string[] searchStrings = null;
if (_SearchString.Length > 0)
if (_SearchString != "")
searchStrings = _SearchString.ToUpper().Split(new char[] {' '});
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();
bool contains = true;
foreach (string str in searchStrings)
contains &= search.Contains(str);
if (contains)
if (searchStrings.All(search.Contains))
_FilteredSongs.Add(song);
}
}
+49 -43
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.Reflection;
using VocaluxeLib.Menu;
@@ -31,11 +50,10 @@ namespace Vocaluxe.Base
get { return _IgnoreArticles; }
set
{
if (value != _IgnoreArticles)
{
_IgnoreArticles = value;
_SetChanged();
}
if (value == _IgnoreArticles)
return;
_IgnoreArticles = value;
_SetChanged();
}
}
@@ -44,11 +62,10 @@ namespace Vocaluxe.Base
get { return _SongSorting; }
set
{
if (value != _SongSorting)
{
_SongSorting = value;
_SetChanged();
}
if (value == _SongSorting)
return;
_SongSorting = value;
_SetChanged();
}
}
@@ -69,51 +86,46 @@ namespace Vocaluxe.Base
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 (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
{
res = CSongs.Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].ArtistSorting.ToUpper());
if (res == 0)
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].ArtistSorting, CSongs.Songs[s2.SongID].ArtistSorting, StringComparison.OrdinalIgnoreCase);
return res != 0 ? res : String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.OrdinalIgnoreCase);
}
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;
}
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 (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
return CSongs.Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].TitleSorting.ToUpper());
else
return CSongs.Songs[s1.SongID].Title.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Title.ToUpper());
return _IgnoreArticles == EOffOn.TR_CONFIG_ON
? String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.OrdinalIgnoreCase) :
String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.OrdinalIgnoreCase);
}
return res;
}
private List<SSongPointer> _CreateSortList(string fieldName)
{
FieldInfo field = null;
bool isString = false;
List<SSongPointer> sortList = new List<SSongPointer>();
if (fieldName.Length == 0)
CSongs.Filter.FilteredSongs.ForEach((song) => sortList.Add(new SSongPointer(song.ID, "")));
if (fieldName == "")
CSongs.Filter.FilteredSongs.ForEach(song => sortList.Add(new SSongPointer(song.ID, "")));
else
{
field = typeof(CSong).GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
isString = field.FieldType == typeof(string);
FieldInfo field = typeof(CSong).GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
if (field == null)
{
CLog.LogError("Unknow sorting field: " + fieldName);
return _CreateSortList("");
}
bool isString = field.FieldType == typeof(string);
if (!isString && field.FieldType != typeof(List<String>))
throw new Exception("Unkown sort field type");
foreach (CSong song in CSongs.Filter.FilteredSongs)
@@ -128,7 +140,7 @@ namespace Vocaluxe.Base
sortList.Add(new SSongPointer(song.ID, ""));
else
{
foreach (String sortString in (List<String>)value)
foreach (String sortString in values)
sortList.Add(new SSongPointer(song.ID, sortString));
}
}
@@ -155,16 +167,10 @@ namespace Vocaluxe.Base
break;
case ESongSorting.TR_CONFIG_ARTIST_LETTER:
case ESongSorting.TR_CONFIG_ARTIST:
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
fieldName = "ArtistSorting";
else
fieldName = "Artist";
fieldName = _IgnoreArticles == EOffOn.TR_CONFIG_ON ? "ArtistSorting" : "Artist";
break;
case ESongSorting.TR_CONFIG_TITLE_LETTER:
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
fieldName = "TitleSorting";
else
fieldName = "Title";
fieldName = _IgnoreArticles == EOffOn.TR_CONFIG_ON ? "TitleSorting" : "Title";
break;
case ESongSorting.TR_CONFIG_YEAR:
case ESongSorting.TR_CONFIG_DECADE:
+37 -40
View File
@@ -1,8 +1,26 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
#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.Linq;
using System.Threading;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
@@ -10,16 +28,16 @@ namespace Vocaluxe.Base
{
public struct SSongPointer
{
public int SongID;
public readonly int SongID;
public string SortString;
public int CatIndex;
public bool Visible;
public bool PartyHidden;
public SSongPointer(int iD, string sortString)
public SSongPointer(int id, string sortString)
{
SongID = iD;
SongID = id;
SortString = sortString;
CatIndex = -1;
Visible = false;
@@ -38,13 +56,11 @@ namespace Vocaluxe.Base
private static int _CatIndex = -1;
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();
public static CSongSorter Sorter = new CSongSorter();
public static CSongCategorizer Categorizer = new CSongCategorizer();
private static Thread _CoverLoaderThread = null;
private static Thread _CoverLoaderThread;
public static List<CSong> Songs
{
@@ -73,16 +89,7 @@ namespace Vocaluxe.Base
public static int NumVisibleSongs
{
get
{
int result = 0;
foreach (SSongPointer sp in Sorter.SortedSongs)
{
if (sp.Visible)
result++;
}
return result;
}
get { return Sorter.SortedSongs.Count(sp => sp.Visible); }
}
public static int NumCategories
@@ -187,18 +194,12 @@ namespace Vocaluxe.Base
{
if ((Categorizer.Categories.Count > 0) && (_CatIndex >= 0) && (Categorizer.Categories.Count > _CatIndex))
return Categorizer.Categories[_CatIndex].Name;
else
return String.Empty;
return String.Empty;
}
public static CSong GetSong(int songID)
{
foreach (CSong song in _Songs)
{
if (song.ID == songID)
return song;
}
return null;
return _Songs.FirstOrDefault(song => song.ID == songID);
}
public static void AddPartySongSung(int songID)
@@ -394,7 +395,7 @@ namespace Vocaluxe.Base
if (song != null)
{
song.ID = _Songs.Count;
if(song.ReadNotes())
if (song.ReadNotes())
_Songs.Add(song);
}
}
@@ -427,14 +428,10 @@ namespace Vocaluxe.Base
if (!SongsLoaded || CoverLoaded)
return;
if (_CoverLoaderThread == null)
{
_CoverLoaderThread = new Thread(new ThreadStart(_LoadCover));
_CoverLoaderThread.Name = "CoverLoader";
_CoverLoaderThread.Priority = ThreadPriority.BelowNormal;
_CoverLoaderThread.IsBackground = true;
_CoverLoaderThread.Start();
}
if (_CoverLoaderThread != null)
return;
_CoverLoaderThread = new Thread(_LoadCover) {Name = "CoverLoader", Priority = ThreadPriority.BelowNormal, IsBackground = true};
_CoverLoaderThread.Start();
/*
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.IO;
using Vocaluxe.Lib.Sound;
@@ -16,7 +35,7 @@ namespace Vocaluxe.Base
#region Playback
private static IPlayback _Playback;
public static bool PlaybackInit()
public static bool Init()
{
switch (CConfig.PlayBackLib)
{
@@ -36,7 +55,7 @@ namespace Vocaluxe.Base
_Playback = new CPortAudioPlay();
break;
}
return true;
return _Playback.Init();
}
public static void SetGlobalVolume(float volume)
@@ -164,7 +183,7 @@ namespace Vocaluxe.Base
break;
}
if (file.Length == 0)
if (file == "")
return -1;
int stream = Load(file);
@@ -467,16 +486,19 @@ namespace Vocaluxe.Base
_MaxVolume = volume;
}
if (_MaxVolume >= 0.02f)
_AnalyzeByAutocorrelation(true);
else
_AnalyzeByAutocorrelation(false);
_AnalyzeByAutocorrelation(_MaxVolume >= 0.02f);
}
catch (Exception) {}
}
private void _AnalyzeByAutocorrelation(bool valid)
{
if (!valid)
{
_ToneValid = false;
return;
}
const double halftoneBase = 1.05946309436; // 2^(1/12) -> HalftoneBase^12 = 2 (one octave)
// prepare to analyze
@@ -506,7 +528,7 @@ namespace Vocaluxe.Base
weigth[toneIndex] = (float)curWeight;
}
if (valid && maxWeight - minWeight > 0.01)
if (maxWeight - minWeight > 0.01)
{
for (int i = 0; i < weigth.Length; i++)
_ToneWeigth[i] = weigth[i];
@@ -594,7 +616,7 @@ namespace Vocaluxe.Base
float dt = Time;
float diff = _ExternTime.Time - dt;
float diff = et - dt;
if (Math.Abs(diff) > 0.05f)
{
_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.IO;
using System.Text;
@@ -115,7 +134,7 @@ namespace Vocaluxe.Base
}
}
public static SCursor Cursor = new SCursor();
public static SCursor Cursor;
#endregion Vars
#region Theme and Skin loading and writing
@@ -147,7 +166,7 @@ namespace Vocaluxe.Base
if (xmlReader == null)
return false;
string value = String.Empty;
string value;
// load skins/textures
@@ -157,7 +176,7 @@ namespace Vocaluxe.Base
{
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];
sk.Value = value;
sk.VideoIndex = -1;
@@ -177,10 +196,8 @@ namespace Vocaluxe.Base
{
try
{
xmlReader.GetValue("//root/Videos/" + _Skins[skinIndex].VideoList[i].Name, ref value, String.Empty);
SSkinElement sk = new SSkinElement();
sk.Name = _Skins[skinIndex].VideoList[i].Name;
sk.Value = value;
xmlReader.GetValue("//root/Videos/" + _Skins[skinIndex].VideoList[i].Name, out value, String.Empty);
SSkinElement sk = new SSkinElement {Name = _Skins[skinIndex].VideoList[i].Name, Value = value};
sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[skinIndex].Path, sk.Value));
CVideo.VdSetLoop(sk.VideoIndex, true);
CVideo.VdPause(sk.VideoIndex);
@@ -248,7 +265,7 @@ namespace Vocaluxe.Base
{
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;
}
@@ -387,7 +404,7 @@ namespace Vocaluxe.Base
_Themes.Clear();
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)
AddTheme(Path.Combine(path, file), -1);
@@ -406,11 +423,11 @@ namespace Vocaluxe.Base
if (version == _ThemeSystemVersion)
{
xmlReader.GetValue("//root/Info/Name", ref theme.Name, String.Empty);
if (theme.Name.Length > 0)
xmlReader.GetValue("//root/Info/Name", out theme.Name, String.Empty);
if (theme.Name != "")
{
xmlReader.GetValue("//root/Info/Author", ref theme.Author, String.Empty);
xmlReader.GetValue("//root/Info/SkinFolder", ref theme.SkinFolder, String.Empty);
xmlReader.GetValue("//root/Info/Author", out theme.Author, String.Empty);
xmlReader.GetValue("//root/Info/SkinFolder", out theme.SkinFolder, String.Empty);
xmlReader.TryGetIntValue("//root/Info/ThemeVersionMajor", ref theme.ThemeVersionMajor);
xmlReader.TryGetIntValue("//root/Info/ThemeVersionMinor", ref theme.ThemeVersionMinor);
theme.Path = Path.GetDirectoryName(filePath);
@@ -428,7 +445,7 @@ namespace Vocaluxe.Base
else
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);
}
return true;
@@ -451,14 +468,14 @@ namespace Vocaluxe.Base
{
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;
}
STheme theme = _Themes[themeIndex];
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)
{
@@ -473,10 +490,10 @@ namespace Vocaluxe.Base
if (version == _SkinSystemVersion)
{
xmlReader.GetValue("//root/Info/Name", ref skin.Name, String.Empty);
if (skin.Name.Length > 0)
xmlReader.GetValue("//root/Info/Name", out skin.Name, String.Empty);
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/SkinVersionMinor", ref skin.SkinVersionMinor);
@@ -489,9 +506,7 @@ namespace Vocaluxe.Base
List<string> names = xmlReader.GetValues("Skins");
foreach (string str in names)
{
SSkinElement sk = new SSkinElement();
sk.Name = str;
sk.Value = String.Empty;
SSkinElement sk = new SSkinElement {Name = str, Value = String.Empty};
skin.SkinList[str] = sk;
}
@@ -499,9 +514,7 @@ namespace Vocaluxe.Base
names = xmlReader.GetValues("Videos");
foreach (string str in names)
{
SSkinElement sk = new SSkinElement();
sk.Name = str;
sk.Value = String.Empty;
SSkinElement sk = new SSkinElement {Name = str, Value = String.Empty};
skin.VideoList.Add(sk);
}
_Skins.Add(skin);
@@ -515,7 +528,7 @@ namespace Vocaluxe.Base
else
msg += "the file is for newer program versions! ";
msg += "Current SkinSystemVersion is " + _SkinSystemVersion.ToString();
msg += "Current SkinSystemVersion is " + _SkinSystemVersion;
CLog.LogError(msg);
}
}
@@ -529,7 +542,7 @@ namespace Vocaluxe.Base
{
if (partyModeID != -1 && _Skins[i].PartyModeID == partyModeID)
return i;
else if (partyModeID == -1 && _Skins[i].Name == CConfig.Skin)
if (partyModeID == -1 && _Skins[i].Name == CConfig.Skin)
return i;
}
@@ -542,7 +555,7 @@ namespace Vocaluxe.Base
{
if (partyModeID != -1 && _Themes[i].PartyModeID == partyModeID)
return i;
else if (partyModeID == -1 && _Themes[i].Name == CConfig.Theme)
if (partyModeID == -1 && _Themes[i].Name == CConfig.Theme)
return i;
}
@@ -578,22 +591,12 @@ namespace Vocaluxe.Base
return _GetSkinFileName(skinName, GetSkinIndex(partyModeID), true);
}
private static string _GetSkinFileName(string skinName, int skinIndex)
{
return _GetSkinFileName(skinName, skinIndex, false);
}
private static string _GetSkinFileName(string skinName, int skinIndex, bool returnPath)
private static string _GetSkinFileName(string skinName, int skinIndex, bool returnPath = false)
{
foreach (SSkinElement sk in _Skins[skinIndex].SkinList.Values)
{
if (sk.Name == skinName)
{
if (!returnPath)
return sk.Value;
else
return Path.Combine(_Skins[skinIndex].Path, sk.Value);
}
return !returnPath ? sk.Value : Path.Combine(_Skins[skinIndex].Path, sk.Value);
}
CLog.LogError("Can't find Skin Element \"" + skinName);
@@ -616,7 +619,7 @@ namespace Vocaluxe.Base
sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, partyModeID));
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;
return sk.Texture;
}
@@ -676,22 +679,12 @@ namespace Vocaluxe.Base
return _GetVideoFileName(videoName, GetSkinIndex(partyModeID), true);
}
private static string _GetVideoFileName(string videoName, int skinIndex)
{
return _GetVideoFileName(videoName, skinIndex, false);
}
private static string _GetVideoFileName(string videoName, int skinIndex, bool returnPath)
private static string _GetVideoFileName(string videoName, int skinIndex, bool returnPath = false)
{
foreach (SSkinElement sk in _Skins[skinIndex].VideoList)
{
if (sk.Name == videoName)
{
if (!returnPath)
return sk.Value;
else
return Path.Combine(_Skins[skinIndex].Path, sk.Value);
}
return !returnPath ? sk.Value : Path.Combine(_Skins[skinIndex].Path, sk.Value);
}
CLog.LogError("Can't find Video Element \"" + videoName);
@@ -710,14 +703,13 @@ namespace Vocaluxe.Base
float value = 0f;
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.ToString() + "/G", ref color.G);
xmlReader.TryGetFloatValue("//root/Colors/Player" + i.ToString() + "/B", ref color.B);
xmlReader.TryGetFloatValue("//root/Colors/Player" + i.ToString() + "/A", ref color.A);
xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/G", ref color.G);
xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/B", ref color.B);
xmlReader.TryGetFloatValue("//root/Colors/Player" + i + "/A", ref color.A);
playerColors.Add(color);
i++;
@@ -729,8 +721,7 @@ namespace Vocaluxe.Base
List<string> names = xmlReader.GetValues("ColorSchemes");
foreach (string str in names)
{
SColorScheme scheme = new SColorScheme();
scheme.Name = str;
SColorScheme scheme = new SColorScheme {Name = str};
xmlReader.TryGetFloatValue("//root/ColorSchemes/" + str + "/R", ref scheme.Color.R);
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)
{
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/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);
Cursor.R = color.R;
@@ -780,7 +771,7 @@ namespace Vocaluxe.Base
writer.WriteStartElement("Colors");
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("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("H", Cursor.H.ToString("#0.000"));
if (Cursor.Color.Length > 0)
if (Cursor.Color != "")
writer.WriteElementString("Color", Cursor.Color);
else
{
+50 -62
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.Diagnostics;
using System.Windows.Forms;
@@ -40,21 +59,17 @@ namespace Vocaluxe.Base
long ticks = _Stopwatch.ElapsedTicks;
if (Stopwatch.IsHighResolution && ticks != 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();
if (ms > 0)
_Fps = 1 / ms;
return _Fps * 1000f;
}
public static double GetFPS()
@@ -136,17 +151,12 @@ namespace Vocaluxe.Base
{
_CheckModifiers();
bool repeat = false;
if (_Keys == e.KeyCode)
repeat = true;
bool repeat = _Keys == e.KeyCode;
if (!_Timer.IsRunning || (_Timer.ElapsedMilliseconds > 75) || !repeat)
{
_Keys = e.KeyCode;
if (repeat)
_Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, _Char, _Keys);
else
_Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, Char.MinValue, _Keys);
_Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, repeat ? _Char : Char.MinValue, _Keys);
}
}
@@ -159,7 +169,9 @@ namespace Vocaluxe.Base
_KeyPressed = true;
}
// ReSharper disable UnusedParameter.Global
public void KeyUp(KeyEventArgs e)
// ReSharper restore UnusedParameter.Global
{
_CheckModifiers();
_KeyPressed = false;
@@ -173,8 +185,7 @@ namespace Vocaluxe.Base
_Del(0);
return true;
}
else
return false;
return false;
}
public void CopyEvents()
@@ -193,54 +204,34 @@ namespace Vocaluxe.Base
private readonly List<SMouseEvent> _EventsPool;
private readonly List<SMouseEvent> _CurrentPool;
private int _X;
private int _Y;
private readonly Object _CopyLock = new Object();
private bool _ModAlt;
private bool _ModCtrl;
private bool _ModShift;
private EModifier _Mod;
private readonly Stopwatch _Timer;
public int X
{
get { return _X; }
}
public int Y
{
get { return _Y; }
}
public bool Visible = false;
public bool Visible;
public CMouse()
{
_ModAlt = false;
_ModCtrl = false;
_ModShift = false;
_EventsPool = new List<SMouseEvent>();
_CurrentPool = new List<SMouseEvent>();
_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());
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)
{
_EventsPool.Add(pool);
}
_X = x;
_Y = y;
}
private void _Del(int index)
@@ -251,30 +242,28 @@ namespace Vocaluxe.Base
private void _CheckModifiers()
{
Keys keys = Control.ModifierKeys;
_Mod = EModifier.None;
_ModShift = (keys & Keys.Shift) == Keys.Shift;
_ModAlt = (keys & Keys.Alt) == Keys.Alt;
_ModCtrl = (keys & Keys.Control) == Keys.Control;
if ((keys & Keys.Shift) != 0)
_Mod |= EModifier.Shift;
if ((keys & Keys.Alt) != 0)
_Mod |= EModifier.Alt;
if ((keys & Keys.Control) != 0)
_Mod |= EModifier.Ctrl;
}
public void MouseMove(MouseEventArgs e)
{
_CheckModifiers();
_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);
_Add(e.X, e.Y, false, false, false, 0, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, false, e.Button == MouseButtons.Middle);
}
public void MouseWheel(MouseEventArgs e)
{
_CheckModifiers();
_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);
_Add(e.X, e.Y, false, false, false, e.Delta, false, false, false, false);
}
public void MouseDown(MouseEventArgs e)
{
_CheckModifiers();
bool lb = e.Button == MouseButtons.Left;
bool ld = false;
if (lb)
@@ -293,11 +282,13 @@ namespace Vocaluxe.Base
else
_Timer.Reset();
_Add(_ModAlt, _ModShift, _ModCtrl, e.X, e.Y, lb, ld, e.Button == MouseButtons.Right, e.Delta, false, false,
e.Button == MouseButtons.Middle, false);
_Add(e.X, e.Y, lb, ld, e.Button == MouseButtons.Right, e.Delta, false, false,
e.Button == MouseButtons.Middle, false);
}
// ReSharper disable UnusedParameter.Global
public void MouseUp(MouseEventArgs e)
// ReSharper restore UnusedParameter.Global
{
//CheckModifiers();
//Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, e.Delta);
@@ -305,14 +296,11 @@ namespace Vocaluxe.Base
public bool PollEvent(ref SMouseEvent mouseEvent)
{
if (_CurrentPool.Count > 0)
{
mouseEvent = _CurrentPool[0];
_Del(0);
return true;
}
else
if (_CurrentPool.Count <= 0)
return false;
mouseEvent = _CurrentPool[0];
_Del(0);
return true;
}
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 Vocaluxe.Lib.Video;
using VocaluxeLib.Menu;
@@ -61,9 +80,9 @@ namespace Vocaluxe.Base
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)
@@ -157,9 +176,8 @@ namespace Vocaluxe.Base
float videoTime = _VideoTimer.ElapsedMilliseconds / 1000f;
_Finished = CVideo.VdFinished(_VideoStream);
STexture tex = new STexture(-1);
tex.Height = 0f;
CVideo.VdGetFrame(_VideoStream, ref tex, videoTime, ref videoTime);
STexture tex = new STexture(-1) {Height = 0f};
CVideo.VdGetFrame(_VideoStream, ref tex, videoTime, out videoTime);
if (tex.Height > 0)
{
@@ -169,7 +187,7 @@ namespace Vocaluxe.Base
}
RectangleF bounds = new RectangleF(0f, 0f, CSettings.RenderW, CSettings.RenderH);
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));
}
@@ -179,8 +197,8 @@ namespace Vocaluxe.Base
float videoTime = 0f;
while (_VideoTexture.Index == -1 && videoTime < 1f)
{
float dummy = 0f;
CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, ref dummy);
float dummy;
CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, out dummy);
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 VocaluxeLib.Menu;
@@ -67,5 +86,10 @@ namespace Vocaluxe.Base
{
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.IO;
using System.Windows.Forms;
@@ -52,6 +71,18 @@ namespace Vocaluxe
Show();
}
public override sealed string Text
{
get { return base.Text; }
set { base.Text = value; }
}
public override sealed Color BackColor
{
get { return base.BackColor; }
set { base.BackColor = value; }
}
protected override void OnPaint(PaintEventArgs e) {}
protected override void OnPaintBackground(PaintEventArgs e)
+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 VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
@@ -7,8 +26,8 @@ namespace Vocaluxe.GameModes
{
struct SSongQueque
{
public int SongID;
public EGameMode GameMode;
public readonly int SongID;
public readonly EGameMode GameMode;
public SSongQueque(int songID, EGameMode gameMode)
{
@@ -19,10 +38,9 @@ namespace Vocaluxe.GameModes
abstract class CGameMode : IGameMode
{
protected bool _Initialized = false;
protected List<SSongQueque> _SongQueque;
protected int _CurrentSong;
protected CPoints _Points;
private List<SSongQueque> _SongQueque;
private int _CurrentSong;
private CPoints _Points;
#region Implementation
public virtual void Init()
@@ -181,7 +199,7 @@ namespace Vocaluxe.GameModes
song.Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap;
// 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;
}
@@ -216,7 +234,5 @@ namespace Vocaluxe.GameModes
return _Points;
}
#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
class CGameModeNormal : CGameMode
{
public override void Init()
{
base.Init();
_Initialized = true;
}
}
class CGameModeNormal : CGameMode {}
}
+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;
namespace Vocaluxe.GameModes
+19 -9
View File
@@ -1,12 +1,22 @@
// Diese Datei wird von der Codeanalyse zur Wartung der SuppressMessage-
// Attribute verwendet, die auf dieses Projekt angewendet werden.
// Unterdrückungen auf Projektebene haben entweder kein Ziel oder
// erhalten ein spezifisches Ziel mit Namespace-, Typ-, Memberbereich usw.
//
// Wenn Sie dieser Datei eine Unterdrückung hinzufügen möchten, klicken Sie mit der
// rechten Maustaste auf die Meldung in der Fehlerliste, zeigen Sie auf
// "Meldung(en) unterdrücken", und klicken Sie auf "In Projektunterdrückungsdatei".
// Sie müssen dieser Datei nicht manuell Unterdrückungen hinzufügen.
#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.CodeAnalysis;
[assembly:
+280 -318
View File
@@ -126,19 +126,21 @@ namespace Vocaluxe.Lib.Draw
ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH);
_SizeBeforeMinimize = ClientSize;
_PresentParameters = new PresentParameters();
_PresentParameters.Windowed = true;
_PresentParameters.SwapEffect = SwapEffect.Discard;
_PresentParameters.BackBufferHeight = CConfig.ScreenH;
_PresentParameters.BackBufferWidth = CConfig.ScreenW;
_PresentParameters.BackBufferFormat = _D3D.Adapters.DefaultAdapter.CurrentDisplayMode.Format;
_PresentParameters.Multisample = MultisampleType.None;
_PresentParameters.MultisampleQuality = 0;
_PresentParameters = new PresentParameters
{
Windowed = true,
SwapEffect = SwapEffect.Discard,
BackBufferHeight = CConfig.ScreenH,
BackBufferWidth = CConfig.ScreenW,
BackBufferFormat = _D3D.Adapters.DefaultAdapter.CurrentDisplayMode.Format,
Multisample = MultisampleType.None,
MultisampleQuality = 0
};
//Apply antialiasing and check if antialiasing mode is supported
#region Antialiasing
int quality = 1;
int quality;
MultisampleType msType;
switch (CConfig.AAMode)
{
@@ -174,18 +176,11 @@ namespace Vocaluxe.Lib.Draw
#endregion Antialiasing
//Apply the VSync configuration
if (CConfig.VSync == EOffOn.TR_CONFIG_ON)
_PresentParameters.PresentationInterval = PresentInterval.Default;
else
_PresentParameters.PresentationInterval = PresentInterval.Immediate;
_PresentParameters.PresentationInterval = CConfig.VSync == EOffOn.TR_CONFIG_ON ? PresentInterval.Default : PresentInterval.Immediate;
//GMA 950 graphics devices can only process vertices in software mode
Capabilities caps = _D3D.GetDeviceCaps(_D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware);
CreateFlags flags = CreateFlags.None;
if ((caps.DeviceCaps & DeviceCaps.HWTransformAndLight) != 0)
flags = CreateFlags.HardwareVertexProcessing;
else
flags = CreateFlags.SoftwareVertexProcessing;
CreateFlags flags = (caps.DeviceCaps & DeviceCaps.HWTransformAndLight) != 0 ? CreateFlags.HardwareVertexProcessing : CreateFlags.SoftwareVertexProcessing;
//Check if Pow2 textures are needed
_NonPowerOf2TextureSupported = true;
@@ -290,7 +285,7 @@ namespace Vocaluxe.Lib.Draw
_PresentParameters.BackBufferHeight = ClientSize.Height;
ClearScreen();
//To set new PresentParameters the device has to be resetted
Reset();
_Reset();
//All configurations got flushed due to Reset(), so apply them again
Init();
@@ -417,82 +412,80 @@ namespace Vocaluxe.Lib.Draw
/// <returns>True if it succeeded else false</returns>
public bool Init()
{
if (!_Device.Disposed)
{
Text = CSettings.GetFullVersionText();
SlimDX.Matrix translate = SlimDX.Matrix.Translation(new Vector3(-CSettings.RenderW / 2, CSettings.RenderH / 2, 0));
SlimDX.Matrix projection = SlimDX.Matrix.OrthoOffCenterLH(-CSettings.RenderW / 2, CSettings.RenderW / 2, -CSettings.RenderH / 2, CSettings.RenderH / 2,
CSettings.ZNear, CSettings.ZFar);
_VertexBuffer = new VertexBuffer(_Device, CSettings.VertexBufferElements * (4 * Marshal.SizeOf(typeof(STexturedColoredVertex))), Usage.WriteOnly | Usage.Dynamic,
VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default);
if (_Device.SetStreamSource(0, _VertexBuffer, 0, Marshal.SizeOf(typeof(STexturedColoredVertex))).IsFailure)
CLog.LogError("Failed to set stream source");
_Device.VertexDeclaration = STexturedColoredVertex.GetDeclaration(_Device);
if (_Device.SetTransform(TransformState.Projection, projection).IsFailure)
CLog.LogError("Failed to set orthogonal matrix");
if (_Device.SetTransform(TransformState.World, translate).IsFailure)
CLog.LogError("Failed to set translation matrix");
if (_Device.SetRenderState(RenderState.CullMode, Cull.None).IsFailure)
CLog.LogError("Failed to set cull mode");
if (_Device.SetRenderState(RenderState.AlphaBlendEnable, true).IsFailure)
CLog.LogError("Failed to enable alpha blending");
if (_Device.SetRenderState(RenderState.Lighting, false).IsFailure)
CLog.LogError("Failed to disable lighting");
if (_Device.SetRenderState(RenderState.DestinationBlend, SlimDX.Direct3D9.Blend.InverseSourceAlpha).IsFailure)
CLog.LogError("Failed to set destination blend");
if (_Device.SetRenderState(RenderState.SourceBlend, SlimDX.Direct3D9.Blend.SourceAlpha).IsFailure)
CLog.LogError("Failed to set source blend");
if (_PresentParameters.Multisample != MultisampleType.None)
{
if (_Device.SetRenderState(RenderState.MultisampleAntialias, true).IsFailure)
CLog.LogError("Failed to set antialiasing");
}
if (_Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear).IsFailure)
CLog.LogError("Failed to set min filter");
if (_Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear).IsFailure)
CLog.LogError("Failed to set mag filter");
if (_Device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Linear).IsFailure)
CLog.LogError("Failed to set mip filter");
if (_Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Clamp).IsFailure)
CLog.LogError("Failed to set clamping on u");
if (_Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Clamp).IsFailure)
CLog.LogError("Failed to set claming on v");
if (_Device.SetTextureStageState(0, TextureStage.AlphaArg1, TextureArgument.Texture).IsFailure)
CLog.LogError("Failed to set alpha argument 1");
if (_Device.SetTextureStageState(0, TextureStage.AlphaArg2, TextureArgument.Diffuse).IsFailure)
CLog.LogError("Failed to set alpha argument 2");
if (_Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate).IsFailure)
CLog.LogError("Failed to set alpha operation");
Int16[] indices = new Int16[6];
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 0;
indices[4] = 2;
indices[5] = 3;
_IndexBuffer = new IndexBuffer(_Device, 6 * sizeof(Int16), Usage.WriteOnly, Pool.Managed, true);
DataStream stream = _IndexBuffer.Lock(0, 0, LockFlags.Discard);
stream.WriteRange(indices);
_IndexBuffer.Unlock();
_Device.Indices = _IndexBuffer;
//This creates a new white texture and adds it to the texture pool
//This texture is used for the DrawRect method
using (Bitmap blankMap = new Bitmap(1, 1))
{
Graphics g = Graphics.FromImage(blankMap);
g.Clear(Color.White);
g.Dispose();
_BlankTexture = AddTexture(blankMap);
}
return true;
}
else
if (_Device.Disposed)
return false;
Text = CSettings.GetFullVersionText();
SlimDX.Matrix translate = SlimDX.Matrix.Translation(new Vector3(-(float)CSettings.RenderW / 2, (float)CSettings.RenderH / 2, 0));
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);
_VertexBuffer = new VertexBuffer(_Device, CSettings.VertexBufferElements * (4 * Marshal.SizeOf(typeof(STexturedColoredVertex))), Usage.WriteOnly | Usage.Dynamic,
VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default);
if (_Device.SetStreamSource(0, _VertexBuffer, 0, Marshal.SizeOf(typeof(STexturedColoredVertex))).IsFailure)
CLog.LogError("Failed to set stream source");
_Device.VertexDeclaration = STexturedColoredVertex.GetDeclaration(_Device);
if (_Device.SetTransform(TransformState.Projection, projection).IsFailure)
CLog.LogError("Failed to set orthogonal matrix");
if (_Device.SetTransform(TransformState.World, translate).IsFailure)
CLog.LogError("Failed to set translation matrix");
if (_Device.SetRenderState(RenderState.CullMode, Cull.None).IsFailure)
CLog.LogError("Failed to set cull mode");
if (_Device.SetRenderState(RenderState.AlphaBlendEnable, true).IsFailure)
CLog.LogError("Failed to enable alpha blending");
if (_Device.SetRenderState(RenderState.Lighting, false).IsFailure)
CLog.LogError("Failed to disable lighting");
if (_Device.SetRenderState(RenderState.DestinationBlend, SlimDX.Direct3D9.Blend.InverseSourceAlpha).IsFailure)
CLog.LogError("Failed to set destination blend");
if (_Device.SetRenderState(RenderState.SourceBlend, SlimDX.Direct3D9.Blend.SourceAlpha).IsFailure)
CLog.LogError("Failed to set source blend");
if (_PresentParameters.Multisample != MultisampleType.None)
{
if (_Device.SetRenderState(RenderState.MultisampleAntialias, true).IsFailure)
CLog.LogError("Failed to set antialiasing");
}
if (_Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear).IsFailure)
CLog.LogError("Failed to set min filter");
if (_Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear).IsFailure)
CLog.LogError("Failed to set mag filter");
if (_Device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Linear).IsFailure)
CLog.LogError("Failed to set mip filter");
if (_Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Clamp).IsFailure)
CLog.LogError("Failed to set clamping on u");
if (_Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Clamp).IsFailure)
CLog.LogError("Failed to set claming on v");
if (_Device.SetTextureStageState(0, TextureStage.AlphaArg1, TextureArgument.Texture).IsFailure)
CLog.LogError("Failed to set alpha argument 1");
if (_Device.SetTextureStageState(0, TextureStage.AlphaArg2, TextureArgument.Diffuse).IsFailure)
CLog.LogError("Failed to set alpha argument 2");
if (_Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate).IsFailure)
CLog.LogError("Failed to set alpha operation");
Int16[] indices = new Int16[6];
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 0;
indices[4] = 2;
indices[5] = 3;
_IndexBuffer = new IndexBuffer(_Device, 6 * sizeof(Int16), Usage.WriteOnly, Pool.Managed, true);
DataStream stream = _IndexBuffer.Lock(0, 0, LockFlags.Discard);
stream.WriteRange(indices);
_IndexBuffer.Unlock();
_Device.Indices = _IndexBuffer;
//This creates a new white texture and adds it to the texture pool
//This texture is used for the DrawRect method
using (Bitmap blankMap = new Bitmap(1, 1))
{
Graphics g = Graphics.FromImage(blankMap);
g.Clear(Color.White);
g.Dispose();
_BlankTexture = AddTexture(blankMap);
}
return true;
}
/// <summary>
@@ -511,61 +504,57 @@ namespace Vocaluxe.Lib.Draw
}
//Resize window if aspect ratio is incorrect
if (_W / (float)_H != CSettings.GetRenderAspect())
if (Math.Abs(_W / (float)_H - CSettings.GetRenderAspect()) > 0.01)
_DoResize();
while (_Run)
{
Application.DoEvents();
if (_Run)
//Clear the previous Frame
ClearScreen();
//We want to begin drawing
if (_Device.BeginScene().IsFailure)
CLog.LogError("Failed to begin scene");
_CheckQueque();
_Run = _Run && CGraphics.Draw();
_RenderVertexBuffer();
//We finished drawing the frame
if (_Device.EndScene().IsFailure)
CLog.LogError("Failed to end scene");
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
try
{
//Clear the previous Frame
ClearScreen();
//We want to begin drawing
if (_Device.BeginScene().IsFailure)
CLog.LogError("Failed to begin scene");
_CheckQueque();
_Run = _Run && CGraphics.Draw();
_RenderVertexBuffer();
//We finished drawing the frame
if (_Device.EndScene().IsFailure)
CLog.LogError("Failed to end scene");
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
try
{
//Now push the frame to the Viewport
_Device.Present();
}
catch (Direct3D9Exception)
{
//In Direct3D devices can get lost.
//This happens for example when opening the Task Manager in Vista/Windows 7 or if a UAC message is opening
//We need to reset the device to get it to workable state again
//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)
{
Reset();
Init();
}
}
//Apply fullscreen mode
if (CSettings.IsFullScreen != _Fullscreen)
{
if (!_Fullscreen)
_EnterFullScreen();
else
_LeaveFullScreen();
}
if (CTime.IsRunning())
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
if (delay >= 1 && CConfig.VSync == EOffOn.TR_CONFIG_OFF)
Thread.Sleep(delay);
//Calculate the FPS Rate and restart the timer after a frame
CTime.CalculateFPS();
CTime.Restart();
//Now push the frame to the Viewport
_Device.Present();
}
catch (Direct3D9Exception)
{
//In Direct3D devices can get lost.
//This happens for example when opening the Task Manager in Vista/Windows 7 or if a UAC message is opening
//We need to reset the device to get it to workable state again
//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)
{
_Reset();
Init();
}
}
//Apply fullscreen mode
if (CSettings.IsFullScreen != _Fullscreen)
{
if (!_Fullscreen)
_EnterFullScreen();
else
_LeaveFullScreen();
}
if (CTime.IsRunning())
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
if (delay >= 1 && CConfig.VSync == EOffOn.TR_CONFIG_OFF)
Thread.Sleep(delay);
//Calculate the FPS Rate and restart the timer after a frame
CTime.CalculateFPS();
CTime.Restart();
}
Close();
}
@@ -573,7 +562,7 @@ namespace Vocaluxe.Lib.Draw
/// <summary>
/// Resets the device, all objects in the Direct3D default pool get flushed and need to be recreated
/// </summary>
public void Reset()
private void _Reset()
{
//Dispose all objects in the default pool, those need to be recreated
STexturedColoredVertex.GetDeclaration(_Device).Dispose();
@@ -670,31 +659,30 @@ namespace Vocaluxe.Lib.Draw
/// </summary>
private void _RenderVertexBuffer()
{
if (_Vertices.Count > 0)
{
//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);
stream.WriteRange(_Vertices.ToArray());
_VertexBuffer.Unlock();
stream.Dispose();
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
DataStream stream = _VertexBuffer.Lock(0, _Vertices.Count * Marshal.SizeOf(typeof(STexturedColoredVertex)), LockFlags.Discard);
stream.WriteRange(_Vertices.ToArray());
_VertexBuffer.Unlock();
stream.Dispose();
for (int i = 0; i < _Vertices.Count; i += 4)
{
//Apply rotation
if (_Device.SetTransform(TransformState.World, _VerticesRotationMatrices.Dequeue()).IsFailure)
CLog.LogError("Failed to set world transformation");
//Apply texture
if (_Device.SetTexture(0, _VerticesTextures.Dequeue()).IsFailure)
CLog.LogError("Failed to set texture");
//Draw 2 triangles from vertexbuffer
if (_Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, i, 0, 4, 0, 2).IsFailure)
CLog.LogError("Failed to draw quad");
}
//Clear the queues for the next frame
_Vertices.Clear();
_VerticesTextures.Clear();
_VerticesRotationMatrices.Clear();
for (int i = 0; i < _Vertices.Count; i += 4)
{
//Apply rotation
if (_Device.SetTransform(TransformState.World, _VerticesRotationMatrices.Dequeue()).IsFailure)
CLog.LogError("Failed to set world transformation");
//Apply texture
if (_Device.SetTexture(0, _VerticesTextures.Dequeue()).IsFailure)
CLog.LogError("Failed to set texture");
//Draw 2 triangles from vertexbuffer
if (_Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, i, 0, 4, 0, 2).IsFailure)
CLog.LogError("Failed to draw quad");
}
//Clear the queues for the next frame
_Vertices.Clear();
_VerticesTextures.Clear();
_VerticesRotationMatrices.Clear();
}
#endregion main stuff
@@ -744,7 +732,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="texture">The texture in which the frame is copied to</param>
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);
texture = CopyScreen();
@@ -762,7 +750,7 @@ namespace Vocaluxe.Lib.Draw
/// </summary>
public void MakeScreenShot()
{
string file = "Screenshot_";
const string file = "Screenshot_";
string path = Path.Combine(Environment.CurrentDirectory, CSettings.FolderScreenshots);
int i = 0;
@@ -794,7 +782,7 @@ namespace Vocaluxe.Lib.Draw
/// <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)
{
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);
}
@@ -805,20 +793,8 @@ namespace Vocaluxe.Lib.Draw
/// <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>
public void DrawText(string text, int x, int y, int h)
{
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)
/// <param name="z">The text's z-position</param>
public void DrawText(string text, int x, int y, int h, int z = 0)
{
CFonts.DrawText(text, h, x, y, z, new SColorF(1f, 1f, 1f, 1f));
}
@@ -871,7 +847,7 @@ namespace Vocaluxe.Lib.Draw
STexture s;
try
{
s = AddTexture(bmp, texturePath);
s = AddTexture(bmp);
}
finally
{
@@ -887,9 +863,8 @@ namespace Vocaluxe.Lib.Draw
/// Adds a texture and stores it in the Vram
/// </summary>
/// <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>
public STexture AddTexture(Bitmap bmp, string texturePath)
public STexture AddTexture(Bitmap bmp)
{
if (bmp.Height == 0 || bmp.Width == 0)
return new STexture(-1);
@@ -919,29 +894,35 @@ namespace Vocaluxe.Lib.Draw
int w = bmp.Width;
int h = bmp.Height;
float ratio = (float)w / h;
int newW = w;
int newH = h;
if (w > maxSize && w > h)
{
h = (int)Math.Round((float)maxSize / bmp.Width * bmp.Height);
w = maxSize;
}
if (h > maxSize)
{
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);
newW = maxSize;
else if (h > maxSize)
newH = maxSize;
else if (w > h)
newW = (int)_CheckForNextPowerOf2(w);
else
newH = (int)_CheckForNextPowerOf2(h);
Bitmap bmp2 = null;
byte[] data;
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
bmp2 = new Bitmap(w, h);
//Scale the texture
@@ -965,22 +946,9 @@ namespace Vocaluxe.Lib.Draw
bmp2.Dispose();
}
if (data == null)
return new STexture(-1);
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)
{
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)
{
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.Width = w;
@@ -1125,8 +1090,7 @@ namespace Vocaluxe.Lib.Draw
s.UnlockRectangle();
return true; */
}
else
return false;
return false;
}
#endregion updating
@@ -1325,36 +1289,35 @@ namespace Vocaluxe.Lib.Draw
/// <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)
{
if (_TextureExists(ref texture))
{
if (_D3DTextures[texture.Index] == null)
return;
if (!_TextureExists(ref texture))
return;
if (_D3DTextures[texture.Index] == null)
return;
float x1 = 0f + begin * texture.WidthRatio;
float x2 = texture.WidthRatio * end;
float y1 = 0f;
float y2 = texture.HeightRatio;
float x1 = 0f + begin * texture.WidthRatio;
float x2 = texture.WidthRatio * end;
const float y1 = 0f;
float y2 = texture.HeightRatio;
float rx1 = rect.X + begin * rect.W;
float rx2 = rect.X + end * rect.W;
float ry1 = rect.Y;
float ry2 = rect.Y + rect.H;
float rx1 = rect.X + begin * rect.W;
float rx2 = rect.X + end * rect.W;
float ry1 = rect.Y;
float ry2 = rect.Y + rect.H;
//Align the pixels because Direct3D expects the pixels to be the left top corner
rx1 -= 0.5f;
ry1 -= 0.5f;
rx2 -= 0.5f;
ry2 -= 0.5f;
//Align the pixels because Direct3D expects the pixels to be the left top corner
rx1 -= 0.5f;
ry1 -= 0.5f;
rx2 -= 0.5f;
ry2 -= 0.5f;
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
STexturedColoredVertex[] vert = new STexturedColoredVertex[4];
vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb());
vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), 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));
}
STexturedColoredVertex[] vert = new STexturedColoredVertex[4];
vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb());
vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), 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));
}
/// <summary>
@@ -1368,76 +1331,76 @@ namespace Vocaluxe.Lib.Draw
/// <param name="height">The height of the reflection</param>
public void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
{
if (!_TextureExists(ref texture))
return;
if (_D3DTextures[texture.Index] == null)
return;
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;
if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X)
return;
if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y)
return;
if (height > bounds.H)
height = bounds.H;
if (_TextureExists(ref texture))
{
if (_D3DTextures[texture.Index] == null)
return;
float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio;
float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
if (rect.W == 0f || rect.H == 0f || bounds.H == 0f || bounds.W == 0f || color.A == 0f || height <= 0f)
return;
if (x1 < 0)
x1 = 0f;
if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X)
return;
if (x2 > texture.WidthRatio)
x2 = texture.WidthRatio;
if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y)
return;
if (y1 < 0)
y1 = 0f;
if (height > bounds.H)
height = bounds.H;
if (_TextureExists(ref texture))
{
float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio;
float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
if (x1 < 0)
x1 = 0f;
if (x2 > texture.WidthRatio)
x2 = texture.WidthRatio;
if (y1 < 0)
y1 = 0f;
if (y2 > texture.HeightRatio)
y2 = texture.HeightRatio;
if (y2 > texture.HeightRatio)
y2 = texture.HeightRatio;
float rx1 = rect.X;
float rx2 = rect.X + rect.W;
float ry1 = rect.Y + rect.H + space;
float ry2 = rect.Y + rect.H + space + height;
float rx1 = rect.X;
float rx2 = rect.X + rect.W;
float ry1 = rect.Y + rect.H + space;
float ry2 = rect.Y + rect.H + space + height;
if (rx1 < bounds.X)
rx1 = bounds.X;
if (rx1 < bounds.X)
rx1 = bounds.X;
if (rx2 > bounds.X + bounds.W)
rx2 = bounds.X + bounds.W;
if (rx2 > bounds.X + bounds.W)
rx2 = bounds.X + bounds.W;
if (ry1 < bounds.Y + space)
ry1 = bounds.Y + space;
if (ry1 < bounds.Y + space)
ry1 = bounds.Y + space;
if (ry2 > bounds.Y + bounds.H + space + height)
ry2 = bounds.Y + bounds.H + space + height;
if (ry2 > bounds.Y + bounds.H + space + height)
ry2 = bounds.Y + bounds.H + space + height;
//Align the pixels because Direct3D expects the pixels to be the left top corner
rx1 -= 0.5f;
ry1 -= 0.5f;
rx2 -= 0.5f;
ry2 -= 0.5f;
//Align the pixels because Direct3D expects the pixels to be the left top corner
rx1 -= 0.5f;
ry1 -= 0.5f;
rx2 -= 0.5f;
ry2 -= 0.5f;
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
Color transparent = Color.FromArgb(0, (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
Color transparent = Color.FromArgb(0, (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
STexturedColoredVertex[] vert = new STexturedColoredVertex[4];
vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), transparent.ToArgb());
vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), transparent.ToArgb());
vert[3] = new STexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
_AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
}
STexturedColoredVertex[] vert = new STexturedColoredVertex[4];
vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), transparent.ToArgb());
vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), transparent.ToArgb());
vert[3] = new STexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
_AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
}
}
#endregion drawing
@@ -1484,20 +1447,17 @@ namespace Vocaluxe.Lib.Draw
/// <returns>The next power of two</returns>
private float _CheckForNextPowerOf2(float n)
{
if (!_NonPowerOf2TextureSupported)
{
if (n < 0)
throw new ArgumentOutOfRangeException("n", "Must be positive.");
return (float)Math.Pow(2, Math.Ceiling(Math.Log(n, 2)));
}
else
if (_NonPowerOf2TextureSupported)
return n;
if (n < 0)
throw new ArgumentOutOfRangeException("n", "Must be positive.");
return (float)Math.Pow(2, Math.Ceiling(Math.Log(n, 2)));
}
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));
if (rot != 0)
SlimDX.Matrix originTranslation = SlimDX.Matrix.Translation(new Vector3(-(float)CSettings.RenderW / 2, (float)CSettings.RenderH / 2, 0));
if (Math.Abs(rot) > float.Epsilon)
{
float rotation = rot * (float)Math.PI / 180;
float centerX = (rx1 + rx2) / 2f;
@@ -1519,10 +1479,10 @@ namespace Vocaluxe.Lib.Draw
#endregion utility
#region TexturedColoredVertex
public struct STexturedColoredVertex
private struct STexturedColoredVertex
{
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, sizeof(float) * 3, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
@@ -1530,21 +1490,23 @@ namespace Vocaluxe.Lib.Draw
VertexElement.VertexDeclarationEnd
};
public Vector3 Position;
public Vector2 Texture;
public int Color;
// ReSharper disable NotAccessedField.Local
private Vector3 _Position;
private Vector2 _Texture;
private int _Color;
// ReSharper restore NotAccessedField.Local
public STexturedColoredVertex(Vector3 position, Vector2 texture, int color)
{
Position = position;
Texture = texture;
Color = color;
_Position = position;
_Texture = texture;
_Color = color;
}
public static VertexDeclaration GetDeclaration(Device device)
{
if (_Declaration == null || _Declaration.Disposed)
_Declaration = new VertexDeclaration(device, Elements);
_Declaration = new VertexDeclaration(device, _Elements);
return _Declaration;
}
+26 -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.ComponentModel;
using System.Drawing;
@@ -300,7 +319,7 @@ namespace Vocaluxe.Lib.Draw
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);
texture = CopyScreen();
@@ -311,7 +330,7 @@ namespace Vocaluxe.Lib.Draw
public void MakeScreenShot()
{
string file = "Screenshot_";
const string file = "Screenshot_";
string path = Path.Combine(Environment.CurrentDirectory, CSettings.FolderScreenshots);
int i = 0;
@@ -327,13 +346,7 @@ namespace Vocaluxe.Lib.Draw
}
// Draw Basic Text
public void DrawText(string text, int x, int y, int h)
{
DrawText(text, x, y, h, 0f);
}
// Draw Basic Text
public void DrawText(string text, int x, int y, float h, float z)
public void DrawText(string text, int x, int y, int h, int z = 0)
{
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);
_Bitmaps.Add(bmp2);
STexture texture = new STexture();
texture.Index = _Bitmaps.Count - 1;
texture.Width = bmp.Width;
texture.Height = bmp.Height;
STexture texture = new STexture {Index = _Bitmaps.Count - 1, Width = bmp.Width, Height = bmp.Height, Color = new SColorF(1f, 1f, 1f, 1f)};
// Add to Texture List
texture.Color = new SColorF(1f, 1f, 1f, 1f);
texture.Rect = new SRectF(0f, 0f, texture.Width, texture.Height, 0f);
texture.TexturePath = String.Empty;
@@ -437,7 +444,7 @@ namespace Vocaluxe.Lib.Draw
if ((texture.Index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > texture.Index))
{
BitmapData bmpData = _Bitmaps[texture.Index].LockBits(new Rectangle(0, 0, _Bitmaps[texture.Index].Width, _Bitmaps[texture.Index].Height),
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
_Bitmaps[texture.Index].UnlockBits(bmpData);
}
@@ -499,12 +506,7 @@ namespace Vocaluxe.Lib.Draw
using (Graphics g = Graphics.FromImage(newBitmap))
{
ColorMatrix cm = new ColorMatrix();
cm.Matrix33 = color.A;
cm.Matrix00 = color.R;
cm.Matrix11 = color.G;
cm.Matrix22 = color.B;
cm.Matrix44 = 1;
ColorMatrix cm = new ColorMatrix {Matrix33 = color.A, Matrix00 = color.R, Matrix11 = color.G, Matrix22 = color.B, Matrix44 = 1};
using (ImageAttributes ia = new ImageAttributes())
{
+72 -142
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 OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -70,14 +88,12 @@ namespace Vocaluxe.Lib.Draw
//Check AA Mode
CConfig.AAMode = (EAntiAliasingModes)_CheckAntiAliasingMode((int)CConfig.AAMode);
ColorFormat cf = new ColorFormat(32);
GraphicsMode gm;
CConfig.ColorDepth = (EColorDepth)_CheckColorDepth((int)CConfig.ColorDepth);
bool ok = false;
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);
if (_Control.GraphicsMode != null)
ok = true;
@@ -121,127 +137,60 @@ namespace Vocaluxe.Lib.Draw
#region Helpers
private int _CheckAntiAliasingMode(int setValue)
{
int result = 0;
GraphicsMode mode = null;
bool done = false;
int samples = 0;
while (!done && (result <= 32))
if (setValue > 32)
setValue = 32;
while (samples <= setValue)
{
GraphicsMode mode;
try
{
mode = new GraphicsMode(16, 0, 0, result);
mode = new GraphicsMode(16, 0, 0, samples);
}
catch (Exception)
{
done = true;
result /= 2;
if (result == 1)
result = 0;
break;
}
if (mode != null)
{
try
{
if (mode.Samples == result)
{
if (result == 0)
result = 2;
else
result *= 2;
}
else
{
done = true;
result /= 2;
if (result == 1)
result = 0;
}
}
catch (Exception)
{
done = true;
result /= 2;
if (result == 1)
result = 0;
}
}
if (mode.Samples != samples)
break;
if (samples == 0)
samples = 2;
else
{
done = true;
result /= 2;
if (result == 1)
result = 0;
}
samples *= 2;
}
if (result > 64)
result = 32;
if (setValue < result)
return setValue;
else
return result;
if (samples == 2)
return 0;
return samples / 2;
}
private int _CheckColorDeep(int setValue)
private int _CheckColorDepth(int setValue)
{
int result = 8;
GraphicsMode mode = null;
bool done = false;
int result = 16;
while (!done && (result <= 32))
if (setValue > 32)
setValue = 32;
while (result <= setValue)
{
GraphicsMode mode;
try
{
mode = new GraphicsMode(result, 0, 0, 0);
}
catch (Exception)
{
done = true;
result -= 8;
if (result == 0)
result = 8;
}
if (mode != null)
{
try
{
if (mode.ColorFormat == result)
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;
break;
}
if (mode.ColorFormat != result)
break;
result += 8;
}
if (result > 32)
result = 32;
if (setValue < result)
return setValue;
else
return result;
return result - 8;
}
private void _ToggleFullScreen()
@@ -571,7 +520,7 @@ namespace Vocaluxe.Lib.Draw
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);
texture = CopyScreen();
@@ -589,7 +538,7 @@ namespace Vocaluxe.Lib.Draw
public void MakeScreenShot()
{
string file = "Screenshot_";
const string file = "Screenshot_";
string path = Path.Combine(Environment.CurrentDirectory, CSettings.FolderScreenshots);
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) {}
// Draw Basic Text (must be deleted later)
public void DrawText(string text, int x, int y, int h)
{
DrawText(text, x, y, h, 0f);
}
public void DrawText(string text, int x, int y, float h, float z)
public void DrawText(string text, int x, int y, int h, int z = 0)
{
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);
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.Rotate(-rect.Rotation, 0f, 0f, 1f);
@@ -710,7 +654,7 @@ namespace Vocaluxe.Lib.Draw
}
try
{
return AddTexture(bmp, texturePath);
return AddTexture(bmp);
}
finally
{
@@ -722,11 +666,6 @@ namespace Vocaluxe.Lib.Draw
}
public STexture AddTexture(Bitmap bmp)
{
return AddTexture(bmp, String.Empty);
}
public STexture AddTexture(Bitmap bmp, string texturePath)
{
STexture texture = new STexture(-1);
@@ -971,11 +910,8 @@ namespace Vocaluxe.Lib.Draw
public STexture QuequeTexture(int w, int h, ref byte[] data)
{
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.Width = w;
@@ -1057,29 +993,21 @@ namespace Vocaluxe.Lib.Draw
{
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);
IntPtr buffer = OpenTK.Graphics.OpenGL.GL.MapBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, OpenTK.Graphics.OpenGL.BufferAccess.WriteOnly);
Marshal.Copy(data, 0, buffer, data.Length);
IntPtr buffer = OpenTK.Graphics.OpenGL.GL.MapBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, OpenTK.Graphics.OpenGL.BufferAccess.WriteOnly);
Marshal.Copy(data, 0, buffer, data.Length);
OpenTK.Graphics.OpenGL.GL.UnmapBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer);
OpenTK.Graphics.OpenGL.GL.UnmapBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer);
OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID);
OpenTK.Graphics.OpenGL.GL.TexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, IntPtr.Zero);
OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, texture.ID);
OpenTK.Graphics.OpenGL.GL.TexSubImage2D(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0, 0, 0, (int)texture.Width, (int)texture.Height,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte, IntPtr.Zero);
OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0);
OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, 0);
OpenTK.Graphics.OpenGL.GL.BindTexture(OpenTK.Graphics.OpenGL.TextureTarget.Texture2D, 0);
OpenTK.Graphics.OpenGL.GL.BindBuffer(OpenTK.Graphics.OpenGL.BufferTarget.PixelUnpackBuffer, 0);
return true;
}
catch (Exception)
{
throw;
//_UsePBO = false;
}
return true;
}
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)
{
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;
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.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.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)
{
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;
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.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.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 VocaluxeLib.Menu;
@@ -27,7 +46,7 @@ namespace Vocaluxe.Lib.Draw
void MakeScreenShot();
// 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(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 Vocaluxe.Base;
@@ -7,17 +26,19 @@ namespace Vocaluxe.Lib.Input
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SHIDDeviceInfo
{
[MarshalAs(UnmanagedType.LPTStr)] public String Path;
public ushort VendorString;
public ushort ProductID;
public String SerialNumber;
public ushort ReleaseNumber;
public String ManufacturerString;
public String ProductString;
public ushort UsagePage;
public ushort Usage;
public int InterfaceNumber;
// ReSharper disable MemberCanBePrivate.Global
[MarshalAs(UnmanagedType.LPTStr)] public readonly String Path;
public readonly ushort VendorString;
public readonly ushort ProductID;
public readonly String SerialNumber;
public readonly ushort ReleaseNumber;
public readonly String ManufacturerString;
public readonly String ProductString;
public readonly ushort UsagePage;
public readonly ushort Usage;
public readonly int InterfaceNumber;
internal IntPtr Next;
// ReSharper restore MemberCanBePrivate.Global
}
public static class CHIDApi
@@ -47,7 +68,7 @@ namespace Vocaluxe.Lib.Input
public static bool Init()
{
int result = -1;
int result;
try
{
result = hid_init();
@@ -58,10 +79,7 @@ namespace Vocaluxe.Lib.Input
return false;
}
if (result == 0)
return true;
return false;
return result == 0;
}
[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()
{
int result = -1;
int result;
try
{
result = hid_exit();
@@ -80,10 +98,7 @@ namespace Vocaluxe.Lib.Input
return false;
}
if (result == 0)
return true;
return false;
return result == 0;
}
[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];
IntPtr dataPtr = Marshal.AllocHGlobal(length);
int result = -1;
int result;
try
{
result = hid_read_timeout(device, dataPtr, length, milliseconds);
@@ -178,7 +193,7 @@ namespace Vocaluxe.Lib.Input
data = new byte[length];
IntPtr dataPtr = Marshal.AllocHGlobal(length);
int result = -1;
int result;
try
{
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.Drawing;
using VocaluxeLib.Menu;
@@ -15,10 +34,10 @@ namespace Vocaluxe.Lib.Input
interface IInput
{
bool Init();
void Init();
void Close();
bool Connect();
bool Disconnect();
void Connect();
void Disconnect();
bool IsConnected();
void Update();
@@ -38,7 +57,7 @@ namespace Vocaluxe.Lib.Input
{
get
{
if (!_Timer.IsRunning && _Duration != 0f)
if (!_Timer.IsRunning && Math.Abs(_Duration) > float.Epsilon)
{
_Timer.Start();
return true;
+38 -41
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.Drawing;
using System.Threading;
@@ -31,15 +50,13 @@ namespace Vocaluxe.Lib.Input.WiiMote
private CGesture _Gesture;
public bool Init()
public void Init()
{
_Sync = new Object();
_RumbleTimer = new CRumbleTimer();
_Gesture = new CGesture();
_Active = true;
_HandlerThread = new Thread(_MainLoop);
_HandlerThread.Priority = ThreadPriority.BelowNormal;
_HandlerThread = new Thread(_MainLoop) {Priority = ThreadPriority.BelowNormal};
_KeysPool = new List<SKeyEvent>();
_CurrentKeysPool = new List<SKeyEvent>();
@@ -49,10 +66,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
_ButtonStates = new bool[11];
_OldPosition = new Point();
_HandlerThread.Start();
return true;
}
public void Close()
@@ -60,20 +73,17 @@ namespace Vocaluxe.Lib.Input.WiiMote
_Active = false;
}
public bool Connect()
public void Connect()
{
if (!_Active)
{
_Active = true;
_HandlerThread.Start();
}
return true;
if (_Active)
return;
_Active = true;
_HandlerThread.Start();
}
public bool Disconnect()
public void Disconnect()
{
_Active = false;
return true;
}
public bool IsConnected()
@@ -94,8 +104,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
_CurrentKeysPool.RemoveAt(0);
return true;
}
else
return false;
return false;
}
public bool PollMouseEvent(ref SMouseEvent mouseEvent)
@@ -106,8 +115,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
_CurrentMousePool.RemoveAt(0);
return true;
}
else
return false;
return false;
}
public void SetRumble(float duration)
@@ -134,8 +142,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
}
else
{
bool startRumble = false;
bool stopRumble = false;
bool startRumble;
bool stopRumble;
lock (_Sync)
{
startRumble = _RumbleTimer.ShouldStart;
@@ -192,13 +200,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
Point p = ws.IRState.Position;
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);
bool lb = false;
bool rb = gesture == EGesture.Back;
@@ -243,9 +244,9 @@ namespace Vocaluxe.Lib.Input.WiiMote
_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)
{
@@ -254,8 +255,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
}
//mouse events
float reducing = 0.15f;
float factor = 1f / (1f - reducing * 2f);
const float reducing = 0.15f;
const float factor = 1f / (1f - reducing * 2f);
float rx = ((p.X / 1024f) - reducing) * factor;
float ry = ((p.Y / 768f) - reducing) * factor;
@@ -263,11 +264,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
int y = (int)(ry * CSettings.RenderH);
bool ld = false;
bool lbh = !lb && ws.ButtonState.A;
bool rbh = false;
bool mb = false;
bool mbh = false;
int wheel = 0;
if (gesture == EGesture.ScrollUp)
@@ -280,12 +277,12 @@ namespace Vocaluxe.Lib.Input.WiiMote
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;
}
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;
}
+80 -60
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.Threading;
using Vocaluxe.Base;
@@ -10,15 +29,17 @@ namespace Vocaluxe.Lib.Input.WiiMote
#region DataTypes
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;
// ReSharper restore NotAccessedField.Global
public bool Rumble;
@@ -49,7 +70,9 @@ namespace Vocaluxe.Lib.Input.WiiMote
{
public bool Active;
public Point Position; // X: 0-1023; Y: 0-767
// ReSharper disable NotAccessedField.Global
public int Width; // 0-15
// ReSharper restore NotAccessedField.Global
}
public struct SIRState
@@ -63,7 +86,9 @@ namespace Vocaluxe.Lib.Input.WiiMote
public struct SAccelStatus
{
public SPoint3 RawValues; //0-255
// ReSharper disable NotAccessedField.Global
public SPoint3F Values; //0-3
// ReSharper restore NotAccessedField.Global
}
public struct SAccelCalibrationInfo
@@ -105,7 +130,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
#region Events
public class CWiiMoteChangedEventArgs : EventArgs
{
public CWiiMoteStatus WiiMoteState;
public readonly CWiiMoteStatus WiiMoteState;
public CWiiMoteChangedEventArgs(CWiiMoteStatus ws)
{
@@ -114,11 +139,11 @@ namespace Vocaluxe.Lib.Input.WiiMote
}
#endregion Events
public class CWiiMoteLib : IDisposable
public sealed class CWiiMoteLib : IDisposable
{
// ReSharper disable InconsistentNaming
// ReSharper disable InconsistentNaming
private const ushort _VID = 0x057e;
// ReSharper restore InconsistentNaming
// ReSharper restore InconsistentNaming
private const ushort _PID = 0x0306; //Wiimotion
private const ushort _PIDPlus = 0x0330; //Wiimotion Plus
@@ -133,9 +158,10 @@ namespace Vocaluxe.Lib.Input.WiiMote
// output commands
private enum EOutputReport : byte
{
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Local
// ReSharper disable InconsistentNaming
LEDs = 0x11,
// ReSharper restore InconsistentNaming
// ReSharper restore InconsistentNaming
Type = 0x12,
IR = 0x13,
Status = 0x15,
@@ -144,6 +170,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
SpeakerData = 0x18,
SpeakerMute = 0x19,
IR2 = 0x1a,
// ReSharper restore UnusedMember.Local
};
// data handling
@@ -157,11 +184,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
private bool _Active;
private bool _Error;
private bool _Connected;
public bool Connected
{
get { return _Connected; }
}
public bool Connected { get; private set; }
private readonly CWiiMoteStatus _WiiMoteState = new CWiiMoteStatus();
private readonly AutoResetEvent _ReadDone = new AutoResetEvent(false);
@@ -170,13 +193,18 @@ namespace Vocaluxe.Lib.Input.WiiMote
#region Interface
public CWiiMoteLib()
{
_Connected = false;
Connected = false;
_Active = true;
_Error = false;
_Reader = new Thread(_ReaderLoop);
_Reader.Start();
}
~CWiiMoteLib()
{
Dispose(false);
}
private bool _TryConnect(ushort pid)
{
bool connected = CHIDApi.Open(_VID, pid, out _Handle);
@@ -191,7 +219,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
public bool Connect()
{
_Connected = false;
Connected = false;
if (_Error)
return false;
@@ -201,7 +229,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
if (!CHIDApi.Init())
{
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);
_Active = false;
@@ -210,25 +238,25 @@ namespace Vocaluxe.Lib.Input.WiiMote
}
//Try WiiMotion
_Connected = _TryConnect(_PID);
Connected = _TryConnect(_PID);
//Try WiiMotion Plus
if (!_Connected)
_Connected = _TryConnect(_PIDPlus);
if (!Connected)
Connected = _TryConnect(_PIDPlus);
return _Connected;
return Connected;
}
public void Disconnect()
{
_Connected = false;
Connected = false;
_Active = false;
CHIDApi.Exit();
}
public void SetReportType(EInputReport type, EIRSensitivity irSensitivity, bool continuous)
{
if (!_Connected)
if (!Connected)
return;
switch (type)
@@ -256,18 +284,17 @@ namespace Vocaluxe.Lib.Input.WiiMote
_WiiMoteState.LEDState.LED3 = led3;
_WiiMoteState.LEDState.LED4 = led4;
if (!_Connected)
if (!Connected)
return;
_ClearReport();
_Buff[0] = (byte)EOutputReport.LEDs;
_Buff[1] = (byte)(
(led1 ? 0x10 : 0x00) |
(led2 ? 0x20 : 0x00) |
(led3 ? 0x40 : 0x00) |
(led4 ? 0x80 : 0x00) |
_RumbleBit);
_Buff[1] = (byte)((led1 ? 0x10 : 0x00) |
(led2 ? 0x20 : 0x00) |
(led3 ? 0x40 : 0x00) |
(led4 ? 0x80 : 0x00) |
_RumbleBit);
CHIDApi.Write(_Handle, _Buff);
}
@@ -282,11 +309,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
_WiiMoteState.LEDState.LED3,
_WiiMoteState.LEDState.LED4);
}
public CWiiMoteStatus WiiMoteState
{
get { return _WiiMoteState; }
}
#endregion Interface
#region Private stuff
@@ -296,7 +318,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
{
Thread.Sleep(5);
if (_Handle != IntPtr.Zero && _Connected)
if (_Handle != IntPtr.Zero && Connected)
{
byte[] buff = new byte[_ReportLength];
@@ -322,7 +344,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
{
if (buff == null)
{
_Connected = false;
Connected = false;
return false;
}
@@ -389,6 +411,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
return true;
}
/*
private byte[] _DecryptBuffer(byte[] buff)
{
for (int i = 0; i < buff.Length; i++)
@@ -396,6 +419,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
return buff;
}
*/
private void _ParseButtons(byte[] buff)
{
@@ -431,14 +455,15 @@ namespace Vocaluxe.Lib.Input.WiiMote
switch (_WiiMoteState.IRState.Mode)
{
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.Y = buff[7] | ((buff[8] >> 6) & 0x03) << 8;
_WiiMoteState.IRState.Sensors[0].Width = 0;
}
if (_WiiMoteState.IRState.Sensors[1].Active = !(buff[9] == 0xff && buff[10] == 0xff))
_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.Y = buff[10] | ((buff[8] >> 2) & 0x03) << 8;
@@ -448,12 +473,12 @@ namespace Vocaluxe.Lib.Input.WiiMote
case EIRMode.Extended:
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].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].Width = buff[8 + i * 3] & 0x0f;
}
_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.Y = buff[7 + i * 3] | ((buff[8 + i * 3] >> 6) & 0x03) << 8;
_WiiMoteState.IRState.Sensors[i].Width = buff[8 + i * 3] & 0x0f;
}
break;
}
@@ -485,13 +510,13 @@ namespace Vocaluxe.Lib.Input.WiiMote
if ((buff[3] & 0x08) != 0)
{
CLog.LogError("Error reading data from WiiMote: Bytes do not exist");
_Connected = false;
Connected = false;
}
if ((buff[3] & 0x07) != 0)
{
CLog.LogError("Error reading data from WiiMote: Attempt to read from write-only registers.");
_Connected = false;
Connected = false;
}
int size = (buff[3] >> 4) + 1;
@@ -505,12 +530,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
private byte _RumbleBit
{
get
{
if (_WiiMoteState.Rumble)
return 0x1;
return 0x0;
}
get { return (byte)(_WiiMoteState.Rumble ? 1 : 0); }
}
private bool _ReadCalibration()
@@ -630,7 +650,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
if (!_ReadDone.WaitOne(1000, false))
{
_Connected = false;
Connected = false;
return null;
}
@@ -667,9 +687,9 @@ namespace Vocaluxe.Lib.Input.WiiMote
GC.SuppressFinalize(this);
}
// ReSharper disable InconsistentNaming
protected virtual void Dispose(bool disposing)
// ReSharper restore InconsistentNaming
// ReSharper disable InconsistentNaming
private void Dispose(bool disposing)
// ReSharper restore InconsistentNaming
{
if (disposing)
{
+41 -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.IO;
using System.Text;
@@ -40,7 +59,7 @@ namespace Vocaluxe.Lib.Playlist
public void SavePlaylist()
{
if (PlaylistFile.Length == 0)
if (PlaylistFile == "")
{
string filename = string.Empty;
foreach (char chr in PlaylistName)
@@ -49,7 +68,7 @@ namespace Vocaluxe.Lib.Playlist
filename += chr.ToString();
}
if (filename.Length == 0)
if (filename == "")
filename = "1";
int i = 0;
@@ -74,12 +93,6 @@ namespace Vocaluxe.Lib.Playlist
return;
}
if (writer == null)
{
CLog.LogError("Error creating/opening Playlist File " + PlaylistFile);
return;
}
try
{
writer.WriteStartDocument();
@@ -95,7 +108,7 @@ namespace Vocaluxe.Lib.Playlist
CSong song = CSongs.GetSong(Songs[i].SongID);
if (song != null)
{
writer.WriteStartElement("Song" + (i + 1).ToString());
writer.WriteStartElement("Song" + (i + 1));
writer.WriteElementString("Artist", song.Artist);
writer.WriteElementString("Title", song.Title);
writer.WriteElementString("GameMode", Enum.GetName(typeof(EGameMode), Songs[i].GameMode));
@@ -124,40 +137,38 @@ namespace Vocaluxe.Lib.Playlist
return;
string value = String.Empty;
if (xmlReader.GetValue("//root/Info/PlaylistName", ref value, value))
if (xmlReader.GetValue("//root/Info/PlaylistName", out value, value))
{
PlaylistName = value;
Songs = new List<CPlaylistSong>();
List<string> songs = xmlReader.GetValues("Songs");
string artist = String.Empty;
string title = String.Empty;
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);
xmlReader.GetValue("//root/Songs/" + songs[i] + "/Title", ref title, String.Empty);
xmlReader.TryGetEnumValue("//root/Songs/" + songs[i] + "/GameMode", ref gm);
string artist;
string title;
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();
song.SongID = -1;
CPlaylistSong playlistSong = new CPlaylistSong {SongID = -1};
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)
{
song.SongID = allSongs[s].ID;
break;
}
if (curSong.Artist != artist || curSong.Title != title)
continue;
playlistSong.SongID = curSong.ID;
break;
}
if (song.SongID != -1)
if (playlistSong.SongID != -1)
{
song.GameMode = gm;
Songs.Add(song);
playlistSong.GameMode = gm;
Songs.Add(playlistSong);
}
else
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)
{
CPlaylistSong song = new CPlaylistSong();
song.SongID = songID;
if (CSongs.GetSong(songID).IsDuet)
song.GameMode = EGameMode.TR_GAMEMODE_DUET;
else
song.GameMode = EGameMode.TR_GAMEMODE_NORMAL;
CPlaylistSong song = new CPlaylistSong {SongID = songID, GameMode = CSongs.GetSong(songID).IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL};
Songs.Add(song);
}
public void AddSong(int songID, EGameMode gm)
{
CPlaylistSong song = new CPlaylistSong();
song.SongID = songID;
song.GameMode = gm;
CPlaylistSong song = new CPlaylistSong {SongID = songID, GameMode = gm};
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 System;
using System.Collections.Generic;
@@ -36,15 +55,9 @@ namespace Vocaluxe.Lib.Sound
{
using (DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid))
{
SRecordDevice device = new SRecordDevice();
device.Driver = dev.DriverGuid.ToString();
device.ID = id;
device.Name = dev.Description;
device.Inputs = new List<SInput>();
SRecordDevice device = new SRecordDevice {Driver = dev.DriverGuid.ToString(), ID = id, Name = dev.Description, Inputs = new List<SInput>()};
SInput inp = new SInput();
inp.Name = "Default";
inp.Channels = ds.Capabilities.Channels;
SInput inp = new SInput {Name = "Default", Channels = ds.Capabilities.Channels};
if (inp.Channels > 2)
inp.Channels = 2; //more are not supported in vocaluxe
@@ -77,8 +90,8 @@ namespace Vocaluxe.Lib.Sound
if (!_Initialized)
return false;
for (int i = 0; i < _Buffer.Length; i++)
_Buffer[i].Reset();
foreach (CBuffer buffer in _Buffer)
buffer.Reset();
_DeviceConfig = deviceConfig;
bool[] active = new bool[deviceConfig.Length];
@@ -101,8 +114,7 @@ namespace Vocaluxe.Lib.Sound
{
if (active[i])
{
CSoundCardSource source = new CSoundCardSource(guid[i], channels[i]);
source.SampleRateKhz = 44.1;
CSoundCardSource source = new CSoundCardSource(guid[i], channels[i]) {SampleRateKhz = 44.1};
source.SampleDataReady += _OnDataReady;
source.Start();
@@ -265,8 +277,8 @@ namespace Vocaluxe.Lib.Sound
public CSoundCardSource(Guid guid, short channels)
{
this._Guid = guid;
this._Channels = channels;
_Guid = guid;
_Channels = channels;
_WaveFormat = new WaveFormat();
SampleRateKhz = 44.1;
_BufferSize = 2048;
@@ -317,9 +329,7 @@ namespace Vocaluxe.Lib.Sound
for (int i = 0; i < _BufferPortionCount; i++)
{
NotificationPosition notification = new NotificationPosition();
notification.Offset = _BufferPortionCount - 1 + (_BufferPortionSize * i);
notification.Event = new AutoResetEvent(false);
NotificationPosition notification = new NotificationPosition {Offset = _BufferPortionCount - 1 + (_BufferPortionSize * i), Event = new AutoResetEvent(false)};
_Notifications.Add(notification);
}
@@ -329,8 +339,7 @@ namespace Vocaluxe.Lib.Sound
for (int i = 0; i < _Notifications.Count; i++)
_WaitHandles[i] = _Notifications[i].Event;
_CaptureThread = new Thread(_DoCapture);
_CaptureThread.IsBackground = true;
_CaptureThread = new Thread(_DoCapture) {IsBackground = true};
_Running = true;
_CaptureThread.Start();
@@ -354,8 +363,8 @@ namespace Vocaluxe.Lib.Sound
if (_Notifications != null)
{
for (int i = 0; i < _Notifications.Count; i++)
_Notifications[i].Event.Close();
foreach (NotificationPosition notification in _Notifications)
notification.Event.Close();
_Notifications.Clear();
_Notifications = null;
@@ -374,13 +383,12 @@ namespace Vocaluxe.Lib.Sound
// Buffer type must match this.waveFormat.FormatTag and this.waveFormat.BitsPerSample
byte[] bufferPortion = new byte[bufferPortionSamples];
int bufferPortionIndex;
_CaptureBuffer.Start(true);
while (_Running)
{
bufferPortionIndex = WaitHandle.WaitAny(_WaitHandles);
int bufferPortionIndex = WaitHandle.WaitAny(_WaitHandles);
_CaptureBuffer.Read(
bufferPortion,
@@ -400,9 +408,9 @@ namespace Vocaluxe.Lib.Sound
GC.SuppressFinalize(this);
}
// ReSharper disable InconsistentNaming
protected virtual void Dispose(bool disposing)
// ReSharper restore InconsistentNaming
// ReSharper disable InconsistentNaming
protected void Dispose(bool disposing)
// ReSharper restore InconsistentNaming
{
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.Lib.Sound.Gstreamer;
@@ -7,10 +26,9 @@ namespace Vocaluxe.Lib.Sound
class CGstreamerAudio : IPlayback
{
//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);
}
@@ -18,11 +36,9 @@ namespace Vocaluxe.Lib.Sound
public CGstreamerAudio()
{
Init();
Log = _LogHandler;
//Is this really needed? CodaAnalyzer complains about it...
//GC.SuppressFinalize(Log);
CGstreamerAudioWrapper.SetLogCallback(Log);
CGstreamerAudioWrapper.SetLogCallback(_LogHandler);
}
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.Collections.Generic;
using System.Diagnostics;
@@ -21,11 +41,6 @@ namespace Vocaluxe.Lib.Sound
private List<SAudioStreams> _Streams;
public COpenALPlay()
{
Init();
}
public bool Init()
{
if (_Initialized)
@@ -100,7 +115,6 @@ namespace Vocaluxe.Lib.Sound
{
_Decoder.Add(decoder);
stream.Handle = _Count++;
stream.File = media;
_Streams.Add(stream);
return stream.Handle;
}
@@ -299,12 +313,7 @@ namespace Vocaluxe.Lib.Sound
private bool _AlreadyAdded(int stream)
{
foreach (SAudioStreams st in _Streams)
{
if (st.Handle == stream)
return true;
}
return false;
return _Streams.Any(st => st.Handle == stream);
}
private int _GetStreamIndex(int stream)
@@ -317,15 +326,6 @@ namespace Vocaluxe.Lib.Sound
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)
{
if (_Initialized)
@@ -380,7 +380,6 @@ namespace Vocaluxe.Lib.Sound
private Closeproc _Closeproc;
private int _StreamID;
private string _FileName;
private IAudioDecoder _Decoder;
private float _BytesPerSecond;
private bool _NoMoreData;
@@ -422,7 +421,7 @@ namespace Vocaluxe.Lib.Sound
_Closeproc = closeProc;
_StreamID = streamID;
_Terminated = true;
this._CloseMutex = closeMutex;
_CloseMutex = closeMutex;
}
public float Length
@@ -487,7 +486,7 @@ namespace Vocaluxe.Lib.Sound
{
if (Finished)
_Timer.Stop();
//TODO: Why not use Decoder.GetPosition()?
return _CurrentTime + _Timer.ElapsedMilliseconds / 1000f;
}
}
@@ -567,9 +566,6 @@ namespace Vocaluxe.Lib.Sound
if (!File.Exists(fileName))
return -1;
if (_FileOpened)
return -1;
_Decoder = new CAudioDecoderFFmpeg();
_Decoder.Init();
@@ -590,7 +586,6 @@ namespace Vocaluxe.Lib.Sound
return -1;
}
_FileName = fileName;
_Decoder.Open(fileName);
_Duration = _Decoder.GetLength();
@@ -600,9 +595,7 @@ namespace Vocaluxe.Lib.Sound
_CurrentTime = 0f;
_Timer.Reset();
SAudioStreams stream = new SAudioStreams(0);
stream.Handle = _Buffers[0];
SAudioStreams stream = new SAudioStreams(0) {Handle = _Buffers[0]};
if (stream.Handle != 0)
{
@@ -615,6 +608,7 @@ namespace Vocaluxe.Lib.Sound
return stream.Handle;
}
_Initialized = true;
return -1;
}
@@ -739,6 +733,7 @@ namespace Vocaluxe.Lib.Sound
AL.DeleteSource(_Source);
AL.DeleteBuffers(_Buffers);
}
_Decoder.Close();
}
_Closeproc(_StreamID);
@@ -773,7 +768,7 @@ namespace Vocaluxe.Lib.Sound
if (_Paused)
return;
int queuedCount = 0;
int queuedCount;
bool doit = true;
AL.GetSource(_Source, ALGetSourcei.BuffersQueued, out queuedCount);
@@ -782,7 +777,7 @@ namespace Vocaluxe.Lib.Sound
{
AL.GetSource(_Source, ALGetSourcei.BuffersProcessed, out processedCount);
doit = false;
Console.WriteLine("Buffers Processed on Stream " + _Source.ToString() + " = " + processedCount.ToString());
Console.WriteLine("Buffers Processed on Stream " + _Source + " = " + processedCount);
if (processedCount < 1)
return;
}
@@ -820,7 +815,7 @@ namespace Vocaluxe.Lib.Sound
}
int buffer = 0;
int buffer;
if (!doit)
buffer = AL.SourceUnqueueBuffer(_Source);
else
@@ -831,11 +826,9 @@ namespace Vocaluxe.Lib.Sound
if (buffer != 0)
{
if (_Format.ChannelCount == 2)
AL.BufferData(buffer, ALFormat.Stereo16, buf, buf.Length, _Format.SamplesPerSecond);
else
AL.BufferData(buffer, ALFormat.Mono16, buf, buf.Length, _Format.SamplesPerSecond);
Console.WriteLine("Write to Buffer: " + buffer.ToString());
ALFormat alFormat = (_Format.ChannelCount == 2) ? ALFormat.Stereo16 : ALFormat.Mono16;
AL.BufferData(buffer, alFormat, buf, buf.Length, _Format.SamplesPerSecond);
Console.WriteLine("Write to Buffer: " + 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.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using Vocaluxe.Base;
using Vocaluxe.Lib.Sound.Decoder;
using Vocaluxe.Lib.Sound.PortAudio;
namespace Vocaluxe.Lib.Sound
{
@@ -21,11 +41,6 @@ namespace Vocaluxe.Lib.Sound
private List<SAudioStreams> _Streams;
public CPortAudioPlay()
{
Init();
}
public bool Init()
{
if (_Initialized)
@@ -85,7 +100,6 @@ namespace Vocaluxe.Lib.Sound
{
_Decoder.Add(decoder);
stream.Handle = _Count++;
stream.File = media;
_Streams.Add(stream);
return stream.Handle;
}
@@ -284,12 +298,7 @@ namespace Vocaluxe.Lib.Sound
private bool _AlreadyAdded(int stream)
{
foreach (SAudioStreams st in _Streams)
{
if (st.Handle == stream)
return true;
}
return false;
return _Streams.Any(st => st.Handle == stream);
}
private int _GetStreamIndex(int stream)
@@ -302,15 +311,6 @@ namespace Vocaluxe.Lib.Sound
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)
{
if (_Initialized)
@@ -354,11 +354,9 @@ namespace Vocaluxe.Lib.Sound
private static CPortAudio.SPaDeviceInfo _OutputDeviceInfo;
private IntPtr _Ptr = new IntPtr(0);
private Closeproc _Closeproc;
private CPortAudio.PaStreamCallbackDelegate _PaStreamCallback;
private int _StreamID;
private string _FileName;
private IAudioDecoder _Decoder;
private float _BytesPerSecond;
private bool _NoMoreData;
@@ -471,7 +469,7 @@ namespace Vocaluxe.Lib.Sound
{
if (Finished)
_SyncTimer.Pause();
//TODO: Why not use Decoder.GetPosition()?
return _SyncTimer.Time;
}
}
@@ -589,7 +587,6 @@ namespace Vocaluxe.Lib.Sound
return -1;
}
_FileName = fileName;
_Decoder.Open(fileName);
_Duration = _Decoder.GetLength();
@@ -606,11 +603,13 @@ namespace Vocaluxe.Lib.Sound
IntPtr data = new IntPtr(0);
CPortAudio.SPaStreamParameters outputParams = new CPortAudio.SPaStreamParameters();
outputParams.ChannelCount = format.ChannelCount;
outputParams.Device = _ApiInfo.DefaultOutputDevice;
outputParams.SampleFormat = CPortAudio.EPaSampleFormat.PaInt16;
outputParams.SuggestedLatency = _OutputDeviceInfo.DefaultLowOutputLatency;
CPortAudio.SPaStreamParameters outputParams = new CPortAudio.SPaStreamParameters
{
ChannelCount = format.ChannelCount,
Device = _ApiInfo.DefaultOutputDevice,
SampleFormat = CPortAudio.EPaSampleFormat.PaInt16,
SuggestedLatency = _OutputDeviceInfo.DefaultLowOutputLatency
};
uint bufsize = (uint)CConfig.AudioBufferSize;
lock (_Mutex)
@@ -782,6 +781,7 @@ namespace Vocaluxe.Lib.Sound
_Initialized = false;
}
}
_Decoder.Close();
}
_Closeproc(_StreamID);
+38 -28
View File
@@ -1,9 +1,28 @@
using System.Threading;
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.Threading;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Vocaluxe.Base;
using Vocaluxe.Lib.Sound.PortAudio;
namespace Vocaluxe.Lib.Sound
{
@@ -54,17 +73,10 @@ namespace Vocaluxe.Lib.Sound
CPortAudio.SPaDeviceInfo info = CPortAudio.PaGetDeviceInfo(i);
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;
dev.Name = info.Name;
dev.Driver = info.Name + i.ToString();
dev.Inputs = new List<SInput>();
SInput inp = new SInput {Name = "Default", Channels = info.MaxInputChannels};
SInput inp = new SInput();
inp.Name = "Default";
inp.Channels = info.MaxInputChannels;
if (inp.Channels > 2)
inp.Channels = 2; //more are not supported in vocaluxe
@@ -101,19 +113,16 @@ namespace Vocaluxe.Lib.Sound
if (deviceConfig == null)
return false;
if (_RecHandle == null)
if (_RecHandle == null || _RecHandle.Length == 0)
return false;
if (_RecHandle.Length == 0)
return false;
foreach (CBuffer buffer in _Buffer)
buffer.Reset();
for (int i = 0; i < _Buffer.Length; i++)
_Buffer[i].Reset();
for (int i = 0; i < _RecHandle.Length; i++)
foreach (IntPtr handle in _RecHandle)
{
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);
waitcount++;
@@ -136,16 +145,17 @@ namespace Vocaluxe.Lib.Sound
}
}
bool result = true;
for (int i = 0; i < _RecHandle.Length; i++)
{
if (active[i])
{
CPortAudio.SPaStreamParameters inputParams = new CPortAudio.SPaStreamParameters();
inputParams.ChannelCount = _DeviceConfig[i].Inputs[0].Channels;
inputParams.Device = _DeviceConfig[i].ID;
inputParams.SampleFormat = CPortAudio.EPaSampleFormat.PaInt16;
inputParams.SuggestedLatency = CPortAudio.PaGetDeviceInfo(_DeviceConfig[i].ID).DefaultLowInputLatency;
CPortAudio.SPaStreamParameters inputParams = new CPortAudio.SPaStreamParameters
{
ChannelCount = _DeviceConfig[i].Inputs[0].Channels,
Device = _DeviceConfig[i].ID,
SampleFormat = CPortAudio.EPaSampleFormat.PaInt16,
SuggestedLatency = CPortAudio.PaGetDeviceInfo(_DeviceConfig[i].ID).DefaultLowInputLatency
};
if (_ErrorCheck("OpenStream (rec)", CPortAudio.Pa_OpenStream(
out _RecHandle[i],
@@ -162,7 +172,7 @@ namespace Vocaluxe.Lib.Sound
return false;
}
}
return result;
return true;
}
/// <summary>
@@ -174,8 +184,8 @@ namespace Vocaluxe.Lib.Sound
if (!_Initialized)
return false;
for (int i = 0; i < _RecHandle.Length; i++)
CPortAudio.Pa_StopStream(_RecHandle[i]);
foreach (IntPtr handle in _RecHandle)
CPortAudio.Pa_StopStream(handle);
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;
using System.IO;
#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 Vocaluxe.Base;
using Vocaluxe.Lib.Video.Acinerella;
namespace Vocaluxe.Lib.Sound.Decoder
{
class CAudioDecoderFFmpeg : CAudioDecoder, IDisposable
class CAudioDecoderFFmpeg : IAudioDecoder, IDisposable
{
private IntPtr _InstancePtr = IntPtr.Zero;
private IntPtr _Audiodecoder = IntPtr.Zero;
@@ -18,17 +36,10 @@ namespace Vocaluxe.Lib.Sound.Decoder
private string _FileName;
private bool _FileOpened;
public override void Init()
{
_FileOpened = false;
_Initialized = true;
}
public void Init() {}
public override void Open(string fileName, bool loop)
public void Open(string fileName)
{
if (!_Initialized)
return;
_FileName = fileName;
try
@@ -42,7 +53,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
CLog.LogError("Error opening audio file: " + _FileName);
return;
}
if (!_Instance.Opened)
{
@@ -50,7 +61,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
return;
}
int audioStreamIndex = -1;
int audioStreamIndex;
SACDecoder audiodecoder;
try
{
@@ -70,11 +81,12 @@ namespace Vocaluxe.Lib.Sound.Decoder
return;
}
_FormatInfo = new SFormatInfo();
_FormatInfo.SamplesPerSecond = audiodecoder.StreamInfo.AudioInfo.SamplesPerSecond;
_FormatInfo.BitDepth = audiodecoder.StreamInfo.AudioInfo.BitDepth;
_FormatInfo.ChannelCount = audiodecoder.StreamInfo.AudioInfo.ChannelCount;
_FormatInfo = new SFormatInfo
{
SamplesPerSecond = audiodecoder.StreamInfo.AudioInfo.SamplesPerSecond,
BitDepth = audiodecoder.StreamInfo.AudioInfo.BitDepth,
ChannelCount = audiodecoder.StreamInfo.AudioInfo.ChannelCount
};
_CurrentTime = 0f;
@@ -86,13 +98,8 @@ namespace Vocaluxe.Lib.Sound.Decoder
_FileOpened = true;
}
public override void Close()
public void Close()
{
if (!_Initialized)
return;
_Initialized = false;
if (!_FileOpened)
return;
@@ -108,25 +115,25 @@ namespace Vocaluxe.Lib.Sound.Decoder
_FileOpened = false;
}
public override SFormatInfo GetFormatInfo()
public SFormatInfo GetFormatInfo()
{
if (!_Initialized && !_FileOpened)
if (!_FileOpened)
return new SFormatInfo();
return _FormatInfo;
}
public override float GetLength()
public float GetLength()
{
if (!_Initialized && !_FileOpened)
if (!_FileOpened)
return 0f;
return _Instance.Info.Duration / 1000f;
}
public override void SetPosition(float time)
public void SetPosition(float time)
{
if (!_Initialized && !_FileOpened)
if (!_FileOpened)
return;
try
@@ -140,24 +147,21 @@ namespace Vocaluxe.Lib.Sound.Decoder
}
}
public override float GetPosition()
public float GetPosition()
{
if (!_Initialized && !_FileOpened)
return 0f;
return _CurrentTime;
return !_FileOpened ? 0f : _CurrentTime;
}
public override void Decode(out byte[] buffer, out float timeStamp)
public void Decode(out byte[] buffer, out float timeStamp)
{
if (!_Initialized && !_FileOpened)
if (!_FileOpened)
{
buffer = null;
timeStamp = 0f;
return;
}
int frameFinished = 0;
int frameFinished;
try
{
frameFinished = CAcinerella.AcGetAudioFrame(_InstancePtr, _Audiodecoder);
@@ -173,7 +177,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
timeStamp = (float)decoder.Timecode;
_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];
if (decoder.BufferSize > 0)
@@ -186,8 +190,6 @@ namespace Vocaluxe.Lib.Sound.Decoder
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
{
@@ -13,7 +32,6 @@
void Close();
void Open(string fileName);
void Open(string fileName, bool loop);
SFormatInfo GetFormatInfo();
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
{
@@ -21,7 +40,7 @@ namespace Vocaluxe.Lib.Sound.Gstreamer
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void LogCallback(string message);
[DllImport(_Dll, CallingConvention=CallingConvention.Cdecl)]
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetLogCallback(LogCallback c);
[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
{
struct SAudioStreams
{
public int Handle;
public string File;
public SAudioStreams(int 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;
namespace Vocaluxe.Lib.Sound
@@ -27,7 +46,9 @@ namespace Vocaluxe.Lib.Sound
public string InputName;
public int Channel;
// ReSharper disable UnusedParameter.Local
public SMicConfig(int dummy)
// ReSharper restore UnusedParameter.Local
{
DeviceName = String.Empty;
DeviceDriver = String.Empty;
+29 -28
View File
@@ -1,35 +1,37 @@
/*
* 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.
*/
#region license
// /*
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// */
#endregion
using System;
using System.Runtime.InteropServices;
namespace PortAudioSharp
namespace Vocaluxe.Lib.Sound.PortAudio
{
/**
<summary>
PortAudio v.19 bindings for .NET
</summary>
*/
public partial class CPortAudio
// ReSharper disable UnusedMember.Global
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable MemberCanBePrivate.Global
public static class CPortAudio
{
#region **** PORTAUDIO CALLBACKS ****
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
@@ -550,10 +552,9 @@ namespace PortAudioSharp
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
public static extern void Pa_Sleep(int msec);
#endregion
private CPortAudio()
{
// This is a static class
}
}
// ReSharper restore UnusedMember.Global
// ReSharper restore FieldCanBeMadeReadOnly.Global
// 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;
namespace Vocaluxe.Lib.Video.Acinerella
{
// ReSharper disable UnusedMember.Global
public enum EACStreamType : sbyte
{
/*The type of the media stream is not known. This kind of stream can not be
@@ -32,12 +52,14 @@ namespace Vocaluxe.Lib.Video.Acinerella
ACOutputBGra32 = 3
}
// ReSharper disable MemberCanBePrivate.Global
// Contains information about the whole file/stream that has been opened. Default
// values are "" for strings and -1 for integer values.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct SACFileInfo
{
public Int64 Duration;
public readonly Int64 Duration;
}
// TAc_instance represents an Acinerella instance. Each instance can open and
@@ -47,12 +69,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACInstance
{
//If true, the instance currently opened a media file
public bool Opened;
public readonly bool Opened;
//Contains the count of streams the media file has. This value is available
//after calling the ac_open function.
public Int32 StreamCount;
public readonly Int32 StreamCount;
//Set this value to change the image output format
public EACOutputFormat OutputFormat;
public readonly EACOutputFormat OutputFormat;
//Contains information about the opened stream/file
public SACFileInfo Info;
}
@@ -62,11 +84,11 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACAudioStreamInfo
{
//Samples per second. Default values are 44100 or 48000.
public Int32 SamplesPerSecond;
public readonly Int32 SamplesPerSecond;
//Bits per sample. Can be 8 or 16 Bit.
public Int32 BitDepth;
public readonly Int32 BitDepth;
//Count of channels in the audio stream.
public Int32 ChannelCount;
public readonly Int32 ChannelCount;
}
// Contains information about an Acinerella video stream.
@@ -74,13 +96,13 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACVideoStreamInfo
{
//The width of one frame.
public Int32 FrameWidth;
public readonly Int32 FrameWidth;
//The height of one frame.
public Int32 FrameHeight;
public readonly Int32 FrameHeight;
//The width of one pixel. 1.07 for 4:3 format, 1,42 for the 16:9 format
public float PixelAspect;
public readonly float PixelAspect;
//Frames per second that should be played.
public double FramesPerSecond;
public readonly double FramesPerSecond;
}
// Contains information about an Acinerella stream.
@@ -88,7 +110,8 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACStreamInfo
{
//Contains the type of the stream.
public EACStreamType StreamType;
public readonly EACStreamType StreamType;
//Additional info about the stream
public SACAudioStreamInfo AudioInfo;
public SACVideoStreamInfo VideoInfo;
@@ -101,22 +124,22 @@ namespace Vocaluxe.Lib.Video.Acinerella
//Pointer on the Acinerella instance
private readonly IntPtr _ACInstancePtr;
//Contains the type of the decoder.
public EACDecoderType DecType;
public readonly EACDecoderType DecType;
//The timecode of the currently decoded picture in seconds.
public double Timecode;
public readonly double Timecode;
public double VideoClock;
public readonly double VideoClock;
//Contains information about the stream the decoder is attached to.
public SACStreamInfo StreamInfo;
//The index of the stream the decoder is attached to.
public Int32 StreamIndex;
public readonly Int32 StreamIndex;
//Pointer to the buffer which contains the data.
internal IntPtr Buffer;
//Size of the data in the buffer.
public Int32 BufferSize;
public readonly Int32 BufferSize;
}
// Contains information about an Acinerella package.
@@ -124,9 +147,11 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct SACPackage
{
//The stream the package belongs to.
public Int32 StreamIndex;
public readonly Int32 StreamIndex;
}
// ReSharper restore MemberCanBePrivate.Global
// Callback function used to ask the application to read data. Should return
// the number of bytes read or an value smaller than zero if an error occured.
//TAc_read_callback = function(sender: Pointer; byte[] buf, int size): integer; cdecl;
@@ -254,7 +279,9 @@ namespace Vocaluxe.Lib.Video.Acinerella
string filename
);
// ReSharper disable UnusedMethodReturnValue.Global
public static Int32 AcOpen2(
// ReSharper restore UnusedMethodReturnValue.Global
IntPtr pAcInstance,
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)]
public static extern void ac_free_package(IntPtr pAcPackage);
[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);
@@ -405,7 +431,9 @@ namespace Vocaluxe.Lib.Video.Acinerella
[DllImport(_AcDll, EntryPoint = "ac_seek", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern Int32 _ac_seek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos);
// ReSharper disable UnusedMethodReturnValue.Global
public static Int32 AcSeek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos)
// ReSharper restore UnusedMethodReturnValue.Global
{
lock (_Lock)
{
@@ -423,4 +451,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
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;
namespace Vocaluxe.Lib.Video
@@ -6,7 +26,7 @@ namespace Vocaluxe.Lib.Video
abstract class CVideoDecoder : IVideoDecoder
{
protected List<SVideoStreams> _Streams = new List<SVideoStreams>();
protected bool _Initialized = false;
protected bool _Initialized;
public virtual bool Init()
{
@@ -38,10 +58,7 @@ namespace Vocaluxe.Lib.Video
return 0f;
}
public virtual bool GetFrame(int streamID, ref STexture frame, float time, ref float videoTime)
{
return true;
}
public abstract bool GetFrame(int streamID, ref STexture frame, float time, out float videoTime);
public virtual bool Skip(int streamID, float start, float gap)
{
@@ -63,12 +80,7 @@ namespace Vocaluxe.Lib.Video
protected bool _AlreadyAdded(int streamID)
{
foreach (SVideoStreams st in _Streams)
{
if (st.Handle == streamID)
return true;
}
return false;
return _Streams.Any(st => st.Handle == 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.Diagnostics;
using System.IO;
@@ -48,7 +67,6 @@ namespace Vocaluxe.Lib.Video
{
_Decoder.Add(decoder);
stream.Handle = _Count++;
stream.File = videoFileName;
_Streams.Add(stream);
return stream.Handle;
}
@@ -72,14 +90,15 @@ namespace Vocaluxe.Lib.Video
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)
{
lock (_MutexDecoder)
{
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;
@@ -212,7 +231,6 @@ namespace Vocaluxe.Lib.Video
private bool _Paused;
private bool _NoMoreFrames;
private bool _Finished;
private bool _BeforeLoop;
private int _Width;
@@ -220,7 +238,6 @@ namespace Vocaluxe.Lib.Video
private float _SetTime;
private float _SetGap;
private float _SetStart;
private bool _SetLoop;
private bool _SetSkip;
private bool _Terminated;
@@ -245,18 +262,11 @@ namespace Vocaluxe.Lib.Video
public float Length
{
get
{
if (_FileOpened)
return _Duration;
return 0f;
}
get { return _FileOpened ? _Duration : 0f; }
}
public bool Paused
{
get { return _Paused; }
set
{
lock (_MutexSyncSignals)
@@ -270,16 +280,9 @@ namespace Vocaluxe.Lib.Video
}
}
public bool Loop
{
get { return _SetLoop; }
set { _SetLoop = value; }
}
public bool Loop { private get; set; }
public bool Finished
{
get { return _Finished; }
}
public bool Finished { get; private set; }
public bool Open(string fileName)
{
@@ -296,15 +299,16 @@ namespace Vocaluxe.Lib.Video
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)
return false;
if (_Paused)
return false;
if (_SetLoop)
if (Loop)
{
lock (_MutexSyncSignals)
{
@@ -322,7 +326,7 @@ namespace Vocaluxe.Lib.Video
return true;
}
if (_SetTime != time)
if (Math.Abs(_SetTime - time) > float.Epsilon)
{
lock (_MutexSyncSignals)
{
@@ -344,7 +348,7 @@ namespace Vocaluxe.Lib.Video
_SetGap = gap;
_SetSkip = true;
_NoMoreFrames = false;
_Finished = false;
Finished = false;
}
//EventDecode.Set();
return true;
@@ -422,7 +426,7 @@ namespace Vocaluxe.Lib.Video
_SetSkip = false;
_Gap = _SetGap;
_Start = _SetStart;
_Loop = _SetLoop;
_Loop = Loop;
}
if (_Skip)
@@ -442,7 +446,7 @@ namespace Vocaluxe.Lib.Video
private void _DoOpen()
{
bool ok = false;
bool ok;
SACInstance instance = new SACInstance();
try
{
@@ -467,7 +471,7 @@ namespace Vocaluxe.Lib.Video
_Duration = instance.Info.Duration / 1000f;
int videoStreamIndex = -1;
int videoStreamIndex;
SACDecoder videodecoder;
try
{
@@ -522,9 +526,7 @@ namespace Vocaluxe.Lib.Video
float myTime = _Time + _VideoSkipTime;
float timeDifference = myTime - _VideoDecoderTime;
bool dropFrame = false;
if (timeDifference >= (framedropcount - 1) * _VideoTimeBase)
dropFrame = true;
bool dropFrame = timeDifference >= (framedropcount - 1) * _VideoTimeBase;
if (_Terminated)
return;
@@ -591,7 +593,6 @@ namespace Vocaluxe.Lib.Video
}
else
_NoMoreFrames = true;
return;
}
else
{
@@ -660,7 +661,7 @@ namespace Vocaluxe.Lib.Video
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);
frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].Data);
@@ -672,12 +673,12 @@ namespace Vocaluxe.Lib.Video
{
_CurrentVideoTime = _FrameBuffer[num].Time;
}
_Finished = false;
Finished = false;
}
else
{
if (_NoMoreFrames)
_Finished = true;
Finished = true;
}
}
}
@@ -725,8 +726,6 @@ namespace Vocaluxe.Lib.Video
}
#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.Lib.Video.Gstreamer;
using VocaluxeLib.Menu;
@@ -8,7 +27,7 @@ namespace Vocaluxe.Lib.Video
class CVideoDecoderGstreamer : IVideoDecoder
{
#region log
public CGstreamerVideoWrapper.LogCallback Log;
private CGstreamerVideoWrapper.LogCallback _Log;
private void _LogHandler(string text)
{
@@ -19,10 +38,10 @@ namespace Vocaluxe.Lib.Video
public bool Init()
{
bool retval = CGstreamerVideoWrapper.InitVideo();
Log = _LogHandler;
_Log = _LogHandler;
//Really needed? CodeAnalysis complains
//GC.SuppressFinalize(Log);
CGstreamerVideoWrapper.SetVideoLogCallback(Log);
CGstreamerVideoWrapper.SetVideoLogCallback(_Log);
return retval;
}
@@ -59,7 +78,7 @@ namespace Vocaluxe.Lib.Video
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);
videoTime = managedFrame.Videotime;
@@ -102,7 +121,7 @@ namespace Vocaluxe.Lib.Video
{
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);
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;
namespace Vocaluxe.Lib.Video.Gstreamer
{
public struct SNativeFrame
{
// ReSharper disable UnassignedField.Global
internal IntPtr Buffer;
public int Size;
public int Width;
public int Height;
public float Videotime;
// ReSharper restore UnassignedField.Global
}
public struct SManagedFrame
{
public byte[] Buffer;
public int Size;
public int Width;
public int Height;
public float Videotime;
@@ -81,7 +101,6 @@ namespace Vocaluxe.Lib.Video.Gstreamer
SManagedFrame m;
m.Buffer = buffer;
m.Height = f.Height;
m.Size = f.Size;
m.Videotime = f.Videotime;
m.Width = f.Width;
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;
namespace Vocaluxe.Lib.Video
@@ -6,12 +24,10 @@ namespace Vocaluxe.Lib.Video
struct SVideoStreams
{
public int Handle;
public string File;
public SVideoStreams(int stream)
{
Handle = stream;
File = String.Empty;
}
}
@@ -25,7 +41,7 @@ namespace Vocaluxe.Lib.Video
int GetNumStreams();
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);
void SetLoop(int streamID, bool loop);
void Pause(int streamID);
+32 -15
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 System.Collections.Generic;
using System.Drawing;
@@ -37,7 +56,7 @@ namespace Vocaluxe.Lib.Webcam
{
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);
frame = CDraw.AddTexture(_Width, _Height, ref _Data);
@@ -62,33 +81,29 @@ namespace Vocaluxe.Lib.Webcam
return bmp;
}
}
else
return null;
return null;
}
public bool Init()
{
_WebcamDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
int num = 0;
foreach (FilterInfo info in _WebcamDevices)
{
SWebcamDevice device = new SWebcamDevice
{
ID = num,
Name = info.Name,
MonikerString = info.MonikerString,
Capabilities = new List<SCapabilities>()
};
num++;
VideoCaptureDevice tmpdev = new VideoCaptureDevice(info.MonikerString);
for (int i = 0; i < tmpdev.VideoCapabilities.Length; i++)
foreach (VideoCapabilities capabilities in tmpdev.VideoCapabilities)
{
SCapabilities item = new SCapabilities
{
Framerate = tmpdev.VideoCapabilities[i].FrameRate,
Height = tmpdev.VideoCapabilities[i].FrameSize.Height,
Width = tmpdev.VideoCapabilities[i].FrameSize.Width
Framerate = capabilities.FrameRate,
Height = capabilities.FrameSize.Height,
Width = capabilities.FrameSize.Width
};
device.Capabilities.Add(item);
}
@@ -144,6 +159,11 @@ namespace Vocaluxe.Lib.Webcam
return _Devices.ToArray();
}
public bool IsDeviceAvailable()
{
return _Devices.Count > 0;
}
public bool Select(SWebcamConfig config)
{
//Close old camera connection
@@ -155,10 +175,7 @@ namespace Vocaluxe.Lib.Webcam
return false;
//No MonikerString found, try first webcam
if (config.MonikerString.Length == 0)
_Webcam = new VideoCaptureDevice(_WebcamDevices[0].MonikerString);
else //Found MonikerString
_Webcam = new VideoCaptureDevice(config.MonikerString);
_Webcam = config.MonikerString == "" ? new VideoCaptureDevice(_WebcamDevices[0].MonikerString) : new VideoCaptureDevice(config.MonikerString);
if (_Webcam == null)
return false;
+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 VocaluxeLib.Menu;
@@ -6,7 +25,6 @@ namespace Vocaluxe.Lib.Webcam
{
struct SWebcamDevice
{
public int ID;
public string Name;
public string MonikerString;
public List<SCapabilities> Capabilities;
@@ -40,6 +58,7 @@ namespace Vocaluxe.Lib.Webcam
Bitmap GetBitmap();
SWebcamConfig GetConfig();
SWebcamDevice[] GetDevices();
bool IsDeviceAvailable();
bool Select(SWebcamConfig webcamConfig);
}
+5 -5
View File
@@ -114,7 +114,7 @@ namespace Vocaluxe
// Init Playback
CLog.StartBenchmark(0, "Init Playback");
CSound.PlaybackInit();
CSound.Init();
CLog.StopBenchmark(0, "Init Playback");
Application.DoEvents();
@@ -185,6 +185,7 @@ namespace Vocaluxe
// Init Input
CLog.StartBenchmark(0, "Init Input");
CInput.Init();
CInput.Connect();
CLog.StopBenchmark(0, "Init Input");
// Init Game;
@@ -252,13 +253,12 @@ namespace Vocaluxe
string[] arr = args.Name.Split(new char[] {','});
if (arr.Length > 0)
{
#if ARCH_X86
string path="x86";
string path = "x86";
#endif
#if ARCH_X64
string path="x64";
string path = "x64";
#endif
path = Path.Combine(path, arr[0] + ".dll");
try
@@ -277,7 +277,7 @@ namespace Vocaluxe
}
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;
+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;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("Vocaluxe")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
@@ -16,9 +36,11 @@ using System.Runtime.InteropServices;
// 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
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// 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")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
@@ -28,5 +50,6 @@ using System.Runtime.InteropServices;
// Buildnummer
// 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")]
+61 -53
View File
@@ -1,5 +1,23 @@
using System;
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;
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
@@ -72,23 +90,14 @@ namespace Vocaluxe.Screens
_ThemeStatics = new string[] {_StaticBG, _StaticCover};
_ThemeTexts = new string[] {_TextCurrentSong};
List<string> buttons = new List<string>();
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();
_ThemeButtons = new string[] {_ButtonPlay, _ButtonPause, _ButtonPrevious, _ButtonNext, _ButtonRepeat, _ButtonShowVideo, _ButtonSing, _ButtonToBackgroundVideo};
}
public override void LoadTheme(string xmlPath)
{
base.LoadTheme(xmlPath);
_ScreenArea = Statics[_StaticBG].Rect;
_ScreenArea = _Statics[_StaticBG].Rect;
}
public override bool HandleInput(SKeyEvent keyEvent)
@@ -105,21 +114,21 @@ namespace Vocaluxe.Screens
return false;
case Keys.Enter:
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
CBackgroundMusic.Next();
if (Buttons[_ButtonPrevious].Selected)
if (_Buttons[_ButtonPrevious].Selected)
CBackgroundMusic.Previous();
if (Buttons[_ButtonPlay].Selected)
if (_Buttons[_ButtonPlay].Selected)
CBackgroundMusic.Play();
if (Buttons[_ButtonPause].Selected)
if (_Buttons[_ButtonPause].Selected)
CBackgroundMusic.Pause();
if (Buttons[_ButtonRepeat].Selected)
if (_Buttons[_ButtonRepeat].Selected)
CBackgroundMusic.RepeatSong = !CBackgroundMusic.RepeatSong;
if (Buttons[_ButtonShowVideo].Selected)
if (_Buttons[_ButtonShowVideo].Selected)
_VideoPreview = !_VideoPreview;
if (Buttons[_ButtonSing].Selected)
_StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet);
if (Buttons[_ButtonToBackgroundVideo].Selected)
if (_Buttons[_ButtonSing].Selected)
_StartSong(CBackgroundMusic.SongID);
if (_Buttons[_ButtonToBackgroundVideo].Selected)
_VideoBackground = !_VideoBackground;
break;
}
@@ -131,23 +140,23 @@ namespace Vocaluxe.Screens
public override bool HandleMouse(SMouseEvent mouseEvent)
{
base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
if (Buttons[_ButtonNext].Selected)
if (_Buttons[_ButtonNext].Selected)
CBackgroundMusic.Next();
if (Buttons[_ButtonPrevious].Selected)
if (_Buttons[_ButtonPrevious].Selected)
CBackgroundMusic.Previous();
if (Buttons[_ButtonPlay].Selected)
if (_Buttons[_ButtonPlay].Selected)
CBackgroundMusic.Play();
if (Buttons[_ButtonPause].Selected)
if (_Buttons[_ButtonPause].Selected)
CBackgroundMusic.Pause();
if (Buttons[_ButtonRepeat].Selected)
if (_Buttons[_ButtonRepeat].Selected)
CBackgroundMusic.RepeatSong = !CBackgroundMusic.RepeatSong;
if (Buttons[_ButtonShowVideo].Selected)
if (_Buttons[_ButtonShowVideo].Selected)
_VideoPreview = !_VideoPreview;
if (Buttons[_ButtonSing].Selected)
_StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet);
if (Buttons[_ButtonToBackgroundVideo].Selected)
if (_Buttons[_ButtonSing].Selected)
_StartSong(CBackgroundMusic.SongID);
if (_Buttons[_ButtonToBackgroundVideo].Selected)
_VideoBackground = !_VideoBackground;
}
else if (mouseEvent.LB)
@@ -165,11 +174,11 @@ namespace Vocaluxe.Screens
public override bool UpdateGame()
{
Statics[_StaticCover].Visible = !_VideoPreviewInt || !CBackgroundMusic.SongHasVideo;
Buttons[_ButtonToBackgroundVideo].Pressed = _VideoBackground;
Buttons[_ButtonShowVideo].Pressed = _VideoPreviewInt;
Buttons[_ButtonRepeat].Pressed = CBackgroundMusic.RepeatSong;
Buttons[_ButtonSing].Visible = CBackgroundMusic.CanSing && CParty.CurrentPartyModeID == -1;
_Statics[_StaticCover].Visible = !_VideoPreviewInt || !CBackgroundMusic.SongHasVideo;
_Buttons[_ButtonToBackgroundVideo].Pressed = _VideoBackground;
_Buttons[_ButtonShowVideo].Pressed = _VideoPreviewInt;
_Buttons[_ButtonRepeat].Pressed = CBackgroundMusic.RepeatSong;
_Buttons[_ButtonSing].Visible = CBackgroundMusic.CanSing && CParty.CurrentPartyModeID == -1;
return true;
}
@@ -177,31 +186,30 @@ namespace Vocaluxe.Screens
{
if (!_Active)
return false;
Statics[_StaticCover].Texture = CBackgroundMusic.Cover;
_Statics[_StaticCover].Texture = CBackgroundMusic.Cover;
if (CBackgroundMusic.VideoEnabled && _VideoPreview && CBackgroundMusic.SongHasVideo)
CDraw.DrawTexture(Statics[_StaticCover], CBackgroundMusic.GetVideoTexture(), EAspect.Crop);
Buttons[_ButtonPause].Visible = CBackgroundMusic.Playing;
Buttons[_ButtonPlay].Visible = !CBackgroundMusic.Playing;
Texts[_TextCurrentSong].Text = CBackgroundMusic.ArtistAndTitle;
CDraw.DrawTexture(_Statics[_StaticCover], CBackgroundMusic.GetVideoTexture(), EAspect.Crop);
_Buttons[_ButtonPause].Visible = CBackgroundMusic.IsPlaying;
_Buttons[_ButtonPlay].Visible = !CBackgroundMusic.IsPlaying;
_Texts[_TextCurrentSong].Text = CBackgroundMusic.ArtistAndTitle;
return base.Draw();
}
private void _StartSong(int songNr, bool duet)
private void _StartSong(int songNr)
{
if (songNr >= 0 && CSongs.SongsLoaded)
{
CGame.Reset();
CGame.ClearSongs();
if (songNr < 0 || !CSongs.SongsLoaded)
return;
CGame.Reset();
CGame.ClearSongs();
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
if (CSongs.AllSongs[songNr].IsDuet)
gm = EGameMode.TR_GAMEMODE_DUET;
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
if (CSongs.AllSongs[songNr].IsDuet)
gm = EGameMode.TR_GAMEMODE_DUET;
CGame.AddSong(songNr, gm);
CGame.AddSong(songNr, gm);
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;
namespace Vocaluxe.Screens
@@ -27,8 +46,8 @@ namespace Vocaluxe.Screens
{
base.LoadTheme(xmlPath);
_ScreenArea = Statics[_StaticBG].Rect;
SelectSlides[_SelectSlideVolume].AddValues(new string[]
_ScreenArea = _Statics[_StaticBG].Rect;
_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"});
}
@@ -46,27 +65,25 @@ namespace Vocaluxe.Screens
_SaveConfig();
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)
SelectSlides[_SelectSlideVolume].Selection = SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel;
else if (SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel < 0)
SelectSlides[_SelectSlideVolume].Selection = 0;
if (_SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel >= 0)
_SelectSlides[_SelectSlideVolume].Selection = _SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel;
else if (_SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel < 0)
_SelectSlides[_SelectSlideVolume].Selection = 0;
_SaveConfig();
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)
SelectSlides[_SelectSlideVolume].Selection = SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel;
else if (SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel >= SelectSlides[_SelectSlideVolume].NumValues)
SelectSlides[_SelectSlideVolume].Selection = SelectSlides[_SelectSlideVolume].NumValues - 1;
if (_SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel < _SelectSlides[_SelectSlideVolume].NumValues)
_SelectSlides[_SelectSlideVolume].Selection = _SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel;
else if (_SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel >= _SelectSlides[_SelectSlideVolume].NumValues)
_SelectSlides[_SelectSlideVolume].Selection = _SelectSlides[_SelectSlideVolume].NumValues - 1;
_SaveConfig();
return true;
}
else if (mouseEvent.RB)
return false;
return true;
return !mouseEvent.RB;
}
public override void OnShow()
@@ -95,20 +112,20 @@ namespace Vocaluxe.Screens
{
case EScreens.ScreenSong:
if (CSongs.IsInCategory)
CConfig.PreviewMusicVolume = SelectSlides[_SelectSlideVolume].Selection * 5;
CConfig.PreviewMusicVolume = _SelectSlides[_SelectSlideVolume].Selection * 5;
else
{
CConfig.BackgroundMusicVolume = SelectSlides[_SelectSlideVolume].Selection * 5;
CConfig.BackgroundMusicVolume = _SelectSlides[_SelectSlideVolume].Selection * 5;
CBackgroundMusic.ApplyVolume();
}
break;
case EScreens.ScreenSing:
CConfig.GameMusicVolume = SelectSlides[_SelectSlideVolume].Selection * 5;
CConfig.GameMusicVolume = _SelectSlides[_SelectSlideVolume].Selection * 5;
break;
default:
CConfig.BackgroundMusicVolume = SelectSlides[_SelectSlideVolume].Selection * 5;
CConfig.BackgroundMusicVolume = _SelectSlides[_SelectSlideVolume].Selection * 5;
CBackgroundMusic.ApplyVolume();
break;
}
@@ -121,17 +138,17 @@ namespace Vocaluxe.Screens
{
case EScreens.ScreenSong:
if (CSongs.IsInCategory)
SelectSlides[_SelectSlideVolume].Selection = CConfig.PreviewMusicVolume / 5;
_SelectSlides[_SelectSlideVolume].Selection = CConfig.PreviewMusicVolume / 5;
else
SelectSlides[_SelectSlideVolume].Selection = CConfig.BackgroundMusicVolume / 5;
_SelectSlides[_SelectSlideVolume].Selection = CConfig.BackgroundMusicVolume / 5;
break;
case EScreens.ScreenSing:
SelectSlides[_SelectSlideVolume].Selection = CConfig.GameMusicVolume / 5;
_SelectSlides[_SelectSlideVolume].Selection = CConfig.GameMusicVolume / 5;
break;
default:
SelectSlides[_SelectSlideVolume].Selection = CConfig.BackgroundMusicVolume / 5;
_SelectSlides[_SelectSlideVolume].Selection = CConfig.BackgroundMusicVolume / 5;
break;
}
}
+53 -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.Diagnostics;
using System.Windows.Forms;
@@ -115,6 +134,7 @@ namespace Vocaluxe.Screens
private STexture _TexNameBrunzel;
private STexture _TexNameDarkice;
private STexture _TexNameFlokuep;
private STexture _TexNameFlamefire;
private STexture _TexNameMesand;
private STexture _TexNameBohning;
private STexture _TexNameBabene03;
@@ -133,13 +153,10 @@ namespace Vocaluxe.Screens
_ParagraphTexts = new List<CText>();
_Paragraphs = new List<string[]>();
string paragraph;
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 " +
"programming language called for a new name - and VOCALUXE [ˈvoʊˈkəˈlʌks] it is!";
words = paragraph.Split(new char[] {' '});
string 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 " +
"programming language called for a new name - and VOCALUXE [ˈvoʊˈkəˈlʌks] it is!";
string[] words = paragraph.Split(new char[] {' '});
_Paragraphs.Add(words);
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("Darkice.png", ref _TexNameDarkice);
CDataBase.GetCreditsRessource("flokuep.png", ref _TexNameFlokuep);
CDataBase.GetCreditsRessource("flamefire.png", ref _TexNameFlamefire);
CDataBase.GetCreditsRessource("bohning.png", ref _TexNameBohning);
CDataBase.GetCreditsRessource("mesand.png", ref _TexNameMesand);
CDataBase.GetCreditsRessource("babene03.png", ref _TexNameBabene03);
@@ -185,35 +203,34 @@ namespace Vocaluxe.Screens
//Prepare Text
int lastY = 280;
for (int i = 0; i < _Paragraphs.Count; i++)
foreach (string[] paragraph in _Paragraphs)
{
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 = " " + paragraph[e];
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))
{
string newline = line + " " + _Paragraphs[i][e];
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))
{
line = line + " " + _Paragraphs[i][e];
line += newLine;
//Check if all words are used
if ((e + 1) == _Paragraphs[i].Length)
{
text.Text = line;
_ParagraphTexts.Add(text);
line = "";
lastY += 40;
}
}
else
//Check if all words are used
if ((e + 1) == paragraph.Length)
{
text.Text = line;
_ParagraphTexts.Add(text);
line = " " + _Paragraphs[i][e];
lastY += 27;
line = "";
lastY += 40;
}
}
else
{
_ParagraphTexts.Add(text);
line = newLine;
lastY += 27;
}
}
}
}
@@ -257,7 +274,7 @@ namespace Vocaluxe.Screens
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);
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));
SRectF particleRect = new SRectF(-1, -1, partRectSize, partRectSize, -6);
SRectF imgDotRect = new SRectF(particleRect);
imgDotRect.Z = -5;
SRectF imgDotRect = new SRectF(particleRect) {Z = -5};
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);
@@ -305,8 +321,8 @@ namespace Vocaluxe.Screens
//Little stars for logo
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);
_StarsRed = GetStarParticles(numstars, true, partRect, true);
_StarsBlue = GetStarParticles(numstars, false, partRect, true);
_StarsRed = _GetStarParticles(numstars, true, partRect, true);
_StarsBlue = _GetStarParticles(numstars, false, partRect, true);
//Credit names
_CreditNames = new List<CCreditName>();
@@ -314,6 +330,7 @@ namespace Vocaluxe.Screens
_AddNewCreditName(_TexNameBrunzel, 502, 29, true);
_AddNewCreditName(_TexNameDarkice, 360, 55, true);
_AddNewCreditName(_TexNameFlokuep, 214, 14, true);
_AddNewCreditName(_TexNameFlamefire, 496, 46, true);
_AddNewCreditName(_TexNameBohning, 383, 54, false);
_AddNewCreditName(_TexNameMesand, 525, 13, false);
_AddNewCreditName(_TexNameBabene03, 33, 26, false);
@@ -352,8 +369,8 @@ namespace Vocaluxe.Screens
//Draw Text
if (_TextTimer.IsRunning)
{
for (int i = 0; i < _ParagraphTexts.Count; i++)
_ParagraphTexts[i].Draw();
foreach (CText text in _ParagraphTexts)
text.Draw();
}
return true;
}
@@ -432,7 +449,6 @@ namespace Vocaluxe.Screens
//Start Text-Timer
_TextTimer.Start();
active = true;
}
}
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.Linq;
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
@@ -34,41 +54,39 @@ namespace Vocaluxe.Screens
{
base.Init();
List<string> texts = new List<string>();
texts.Add(_TextSongName);
texts.Add(_TextSongMode);
List<string> texts = new List<string> {_TextSongName, _TextSongMode};
_TextNumber = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++)
{
_TextNumber[i] = "TextNumber" + (i + 1).ToString();
_TextNumber[i] = "TextNumber" + (i + 1);
texts.Add(_TextNumber[i]);
}
_TextName = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++)
{
_TextName[i] = "TextName" + (i + 1).ToString();
_TextName[i] = "TextName" + (i + 1);
texts.Add(_TextName[i]);
}
_TextScore = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++)
{
_TextScore[i] = "TextScore" + (i + 1).ToString();
_TextScore[i] = "TextScore" + (i + 1);
texts.Add(_TextScore[i]);
}
_TextDate = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++)
{
_TextDate[i] = "TextDate" + (i + 1).ToString();
_TextDate[i] = "TextDate" + (i + 1);
texts.Add(_TextDate[i]);
}
_ParticleEffectNew = new string[_NumEntrys];
for (int i = 0; i < _NumEntrys; i++)
_ParticleEffectNew[i] = "ParticleEffectNew" + (i + 1).ToString();
_ParticleEffectNew[i] = "ParticleEffectNew" + (i + 1);
_ThemeTexts = texts.ToArray();
_ThemeParticleEffects = _ParticleEffectNew;
@@ -112,7 +130,7 @@ namespace Vocaluxe.Screens
public override bool HandleMouse(SMouseEvent mouseEvent)
{
if (mouseEvent.LB && IsMouseOver(mouseEvent)) {}
if (mouseEvent.LB && _IsMouseOver(mouseEvent)) {}
if (mouseEvent.LB)
_LeaveScreen();
@@ -141,34 +159,31 @@ namespace Vocaluxe.Screens
{
if (_Pos + p < _Scores[_Round].Count)
{
Texts[_TextNumber[p]].Visible = true;
Texts[_TextName[p]].Visible = true;
Texts[_TextScore[p]].Visible = true;
Texts[_TextDate[p]].Visible = true;
_Texts[_TextNumber[p]].Visible = true;
_Texts[_TextName[p]].Visible = true;
_Texts[_TextScore[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;
name += " [" + CLanguage.Translate(Enum.GetName(typeof(EGameDifficulty), _Scores[_Round][_Pos + p].Difficulty)) + "]";
if (_IsDuet)
name += " (P" + (_Scores[_Round][_Pos + p].LineNr + 1).ToString() + ")";
Texts[_TextName[p]].Text = name;
name += " (P" + (_Scores[_Round][_Pos + p].LineNr + 1) + ")";
_Texts[_TextName[p]].Text = name;
Texts[_TextScore[p]].Text = _Scores[_Round][_Pos + p].Score.ToString("00000");
Texts[_TextDate[p]].Text = _Scores[_Round][_Pos + p].Date;
_Texts[_TextScore[p]].Text = _Scores[_Round][_Pos + p].Score.ToString("00000");
_Texts[_TextDate[p]].Text = _Scores[_Round][_Pos + p].Date;
if (_IsNewEntry(_Scores[_Round][_Pos + p].ID))
ParticleEffects[_ParticleEffectNew[p]].Visible = true;
else
ParticleEffects[_ParticleEffectNew[p]].Visible = false;
_ParticleEffects[_ParticleEffectNew[p]].Visible = _IsNewEntry(_Scores[_Round][_Pos + p].ID);
}
else
{
Texts[_TextNumber[p]].Visible = false;
Texts[_TextName[p]].Visible = false;
Texts[_TextScore[p]].Visible = false;
Texts[_TextDate[p]].Visible = false;
ParticleEffects[_ParticleEffectNew[p]].Visible = false;
_Texts[_TextNumber[p]].Visible = false;
_Texts[_TextName[p]].Visible = false;
_Texts[_TextScore[p]].Visible = false;
_Texts[_TextDate[p]].Visible = false;
_ParticleEffects[_ParticleEffectNew[p]].Visible = false;
}
}
return true;
@@ -193,13 +208,7 @@ namespace Vocaluxe.Screens
private bool _IsNewEntry(int id)
{
for (int i = 0; i < _NewEntryIDs.Count; i++)
{
if (_NewEntryIDs[i] == id)
return true;
}
return false;
return _NewEntryIDs.Any(t => t == id);
}
private void _AddScoresToDB()
@@ -230,7 +239,7 @@ namespace Vocaluxe.Screens
for (int round = 0; round < points.NumRounds; round++)
{
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;
CPoints points = CGame.GetPoints();
SPlayer player = points.GetPlayer(_Round, CGame.NumPlayer)[0];
CSong song = CGame.GetSong(_Round + 1);
if (song == null)
return;
Texts[_TextSongName].Text = song.Artist + " - " + song.Title;
_Texts[_TextSongName].Text = song.Artist + " - " + song.Title;
if (points.NumRounds > 1)
Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
_Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
switch (CGame.GetGameMode(_Round))
{
case EGameMode.TR_GAMEMODE_NORMAL:
Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
_Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
break;
case EGameMode.TR_GAMEMODE_MEDLEY:
Texts[_TextSongMode].Text = "TR_GAMEMODE_MEDLEY";
_Texts[_TextSongMode].Text = "TR_GAMEMODE_MEDLEY";
break;
case EGameMode.TR_GAMEMODE_DUET:
Texts[_TextSongMode].Text = "TR_GAMEMODE_DUET";
_Texts[_TextSongMode].Text = "TR_GAMEMODE_DUET";
_IsDuet = true;
break;
case EGameMode.TR_GAMEMODE_SHORTSONG:
Texts[_TextSongMode].Text = "TR_GAMEMODE_SHORTSONG";
_Texts[_TextSongMode].Text = "TR_GAMEMODE_SHORTSONG";
break;
default:
Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
_Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
break;
}
+36 -19
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.Windows.Forms;
using Vocaluxe.Base;
@@ -13,7 +32,6 @@ namespace Vocaluxe.Screens
{
get { return 1; }
}
private const float _WaitTime = 0.5f; //wait time before starting first video
private const string _TextStatus = "TextStatus";
@@ -84,12 +102,11 @@ namespace Vocaluxe.Screens
}
}
_SongLoaderThread = new Thread(CSongs.LoadSongs);
_SongLoaderThread.Name = "SongLoader";
_SongLoaderThread = new Thread(CSongs.LoadSongs) {Name = "SongLoader"};
Texts[_TextStatus].Text = CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": 0 " +
CLanguage.Translate("TR_SCREENLOAD_SONGS") + " (0 " +
CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")";
_Texts[_TextStatus].Text = CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": 0 " +
CLanguage.Translate("TR_SCREENLOAD_SONGS") + " (0 " +
CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")";
_SkipIntro = false;
_CurrentIntroVideoNr = -1;
@@ -110,8 +127,8 @@ namespace Vocaluxe.Screens
if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON)
{
for (int i = 0; i < _Intros.Length; i++)
_Intros[i].PreLoad();
foreach (CVideoPlayer videoPlayer in _Intros)
videoPlayer.PreLoad();
}
CLog.StartBenchmark(0, "Load Songs Full");
@@ -124,7 +141,7 @@ namespace Vocaluxe.Screens
{
CBackgroundMusic.AddOwnMusic();
if (!CBackgroundMusic.Playing)
if (!CBackgroundMusic.IsPlaying)
CBackgroundMusic.Next();
_BGMusicStartet = true;
@@ -150,8 +167,8 @@ namespace Vocaluxe.Screens
if (CSettings.GameState == EGameState.Normal)
CGraphics.FadeTo(EScreens.ScreenMain);
Texts[_TextStatus].Text =
CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": " + CSongs.NumAllSongs.ToString() + " " +
_Texts[_TextStatus].Text =
CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": " + CSongs.NumAllSongs + " " +
CLanguage.Translate("TR_SCREENLOAD_SONGS") + " (" + CSongs.NumSongsWithCoverLoaded + " " +
CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")";
@@ -160,7 +177,7 @@ namespace Vocaluxe.Screens
{
CBackgroundMusic.AddOwnMusic();
if (!CBackgroundMusic.Playing)
if (!CBackgroundMusic.IsPlaying)
CBackgroundMusic.Next();
_BGMusicStartet = true;
@@ -171,12 +188,12 @@ namespace Vocaluxe.Screens
public override bool Draw()
{
DrawBG();
_DrawBG();
for (int i = 0; i < _Intros.Length; i++)
_Intros[i].Draw();
foreach (CVideoPlayer videoPlayer in _Intros)
videoPlayer.Draw();
DrawFG();
_DrawFG();
return true;
}
@@ -186,8 +203,8 @@ namespace Vocaluxe.Screens
_Timer.Stop();
_Timer.Reset();
for (int i = 0; i < _Intros.Length; i++)
_Intros[i].Close();
foreach (CVideoPlayer videoPlayer in _Intros)
videoPlayer.Close();
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 VocaluxeLib.Menu;
@@ -53,22 +72,22 @@ namespace Vocaluxe.Screens
break;
case Keys.Enter:
if (Buttons[_ButtonSing].Selected)
if (_Buttons[_ButtonSing].Selected)
{
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong);
}
if (Buttons[_ButtonParty].Selected)
if (_Buttons[_ButtonParty].Selected)
CGraphics.FadeTo(EScreens.ScreenParty);
if (Buttons[_ButtonOptions].Selected)
if (_Buttons[_ButtonOptions].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions);
if (Buttons[_ButtonProfiles].Selected)
if (_Buttons[_ButtonProfiles].Selected)
CGraphics.FadeTo(EScreens.ScreenProfiles);
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
return false;
break;
@@ -81,30 +100,31 @@ namespace Vocaluxe.Screens
{
base.HandleMouse(mouseEvent);
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
if (Buttons[_ButtonSing].Selected)
if (_Buttons[_ButtonSing].Selected)
{
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong);
}
if (Buttons[_ButtonParty].Selected)
if (_Buttons[_ButtonParty].Selected)
CGraphics.FadeTo(EScreens.ScreenParty);
if (Buttons[_ButtonOptions].Selected)
if (_Buttons[_ButtonOptions].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions);
if (Buttons[_ButtonProfiles].Selected)
if (_Buttons[_ButtonProfiles].Selected)
CGraphics.FadeTo(EScreens.ScreenProfiles);
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
return false;
}
return true;
}
// ReSharper disable RedundantOverridenMember
public override void OnShow()
{
base.OnShow();
@@ -113,6 +133,8 @@ namespace Vocaluxe.Screens
// Snowflakes.Resume();
}
// ReSharper restore RedundantOverridenMember
public override bool UpdateGame()
{
return true;
@@ -120,16 +142,18 @@ namespace Vocaluxe.Screens
public override bool Draw()
{
DrawBG();
_DrawBG();
//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.Update();
//Snowflakes.Draw();
DrawFG();
_DrawFG();
// ReSharper disable ConditionIsAlwaysTrueOrFalse
if (CSettings.VersionRevision != ERevision.Release)
// ReSharper restore ConditionIsAlwaysTrueOrFalse
{
CFonts.SetFont("Normal");
CFonts.Style = EStyle.Normal;
@@ -139,6 +163,7 @@ namespace Vocaluxe.Screens
return true;
}
// ReSharper disable RedundantOverridenMember
public override void OnClose()
{
base.OnClose();
@@ -146,5 +171,7 @@ namespace Vocaluxe.Screens
//if (Snowflakes != null)
// Snowflakes.Pause();
}
// ReSharper restore RedundantOverridenMember
}
}
+171 -292
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.Windows.Forms;
using Vocaluxe.Base;
@@ -36,37 +55,30 @@ namespace Vocaluxe.Screens
{"SelectSlideDuetPlayer1", "SelectSlideDuetPlayer2", "SelectSlideDuetPlayer3", "SelectSlideDuetPlayer4", "SelectSlideDuetPlayer5", "SelectSlideDuetPlayer6"};
private readonly STexture[] _OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer];
private bool _SelectingMouseActive;
private bool _SelectingKeyboardActive;
private bool _SelectingKeyboardUnendless;
private int _SelectingKeyboardPlayerNr;
private int _SelectedPlayerNr;
private int[] _PlayerNr;
public override void Init()
{
base.Init();
List<string> statics = new List<string>();
foreach (string text in _StaticPlayer)
statics.Add(text);
foreach (string text in _StaticPlayerAvatar)
statics.Add(text);
statics.AddRange(_StaticPlayerAvatar);
statics.AddRange(_StaticPlayer);
statics.Add(_StaticWarningMics);
statics.Add(_StaticWarningProfiles);
_ThemeStatics = statics.ToArray();
List<string> texts = new List<string>();
texts.Add(_SelectSlidePlayerNumber);
List<string> texts = new List<string> {_SelectSlidePlayerNumber};
texts.AddRange(_SelectSlideDuetPlayer);
_ThemeSelectSlides = texts.ToArray();
texts.Clear();
texts.Add(_TextWarningMics);
texts.Add(_TextWarningProfiles);
foreach (string text in _TextPlayer)
texts.Add(text);
texts.AddRange(_TextPlayer);
_ThemeTexts = texts.ToArray();
texts.Clear();
@@ -91,15 +103,11 @@ namespace Vocaluxe.Screens
{
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++)
_OriginalPlayerAvatarTextures[i] = Statics[_StaticPlayerAvatar[i]].Texture;
_OriginalPlayerAvatarTextures[i] = _Statics[_StaticPlayerAvatar[i]].Texture;
for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
Equalizers["EqualizerPlayer" + i].ScreenHandles = true;
_Equalizers["EqualizerPlayer" + i].ScreenHandles = true;
}
public override bool HandleInput(SKeyEvent keyEvent)
@@ -109,20 +117,20 @@ namespace Vocaluxe.Screens
case Keys.Add:
if (CConfig.NumPlayer + 1 <= CSettings.MaxNumPlayer)
{
SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer;
_SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer;
_UpdatePlayerNumber();
//Update Tiles-List
NameSelections[_NameSelection].UpdateList();
_NameSelections[_NameSelection].UpdateList();
}
break;
case Keys.Subtract:
if (CConfig.NumPlayer - 1 > 0)
{
SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 2;
_SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 2;
_UpdatePlayerNumber();
//Update Tiles-List
NameSelections[_NameSelection].UpdateList();
_NameSelections[_NameSelection].UpdateList();
}
break;
@@ -138,7 +146,7 @@ namespace Vocaluxe.Screens
_SelectingKeyboardPlayerNr++;
else
_SelectingKeyboardPlayerNr = 1;
NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
_NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
}
break;
}
@@ -146,203 +154,128 @@ namespace Vocaluxe.Screens
if (_SelectingKeyboardActive)
{
//Handle left/right/up/down
NameSelections[_NameSelection].HandleInput(keyEvent);
_NameSelections[_NameSelection].HandleInput(keyEvent);
int numberPressed = -1;
bool resetSelection = false;
switch (keyEvent.Key)
{
case Keys.Enter:
//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
CGame.Player[_SelectingKeyboardPlayerNr - 1].Name = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
CGame.Player[_SelectingKeyboardPlayerNr - 1].Difficulty = CProfiles.Profiles[_SelectedPlayerNr].Difficulty;
CGame.Player[_SelectingKeyboardPlayerNr - 1].ProfileID = _SelectedPlayerNr;
CGame.Players[_SelectingKeyboardPlayerNr - 1].ProfileID = _SelectedPlayerNr;
//Update config for default players.
CConfig.Players[_SelectingKeyboardPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.SaveConfig();
//Update texture and name
Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture;
Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
_Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture;
_Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
NameSelections[_NameSelection].UpdateList();
SetInteractionToButton(Buttons[_ButtonStart]);
_NameSelections[_NameSelection].UpdateList();
_SetInteractionToButton(_Buttons[_ButtonStart]);
}
//Started selecting with 'P'
if (_SelectingKeyboardUnendless)
{
if (_SelectingKeyboardPlayerNr == CGame.NumPlayer)
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
resetSelection = true;
else
{
_SelectingKeyboardPlayerNr++;
NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
_NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
}
}
else
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
resetSelection = true;
break;
case Keys.D1:
case Keys.NumPad1:
if (_SelectingKeyboardPlayerNr == 1)
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 1;
NameSelections[_NameSelection].KeyboardSelection(true, 1);
}
_SelectingKeyboardUnendless = false;
numberPressed = 1;
break;
case Keys.D2:
case Keys.NumPad2:
if (_SelectingKeyboardPlayerNr == 2)
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 2;
NameSelections[_NameSelection].KeyboardSelection(true, 2);
}
_SelectingKeyboardUnendless = false;
numberPressed = 2;
break;
case Keys.D3:
case Keys.NumPad3:
if (_SelectingKeyboardPlayerNr == 3)
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 3;
NameSelections[_NameSelection].KeyboardSelection(true, 3);
}
_SelectingKeyboardUnendless = false;
numberPressed = 3;
break;
case Keys.D4:
case Keys.NumPad4:
if (_SelectingKeyboardPlayerNr == 4)
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 4;
NameSelections[_NameSelection].KeyboardSelection(true, 4);
}
_SelectingKeyboardUnendless = false;
numberPressed = 4;
break;
case Keys.D5:
case Keys.NumPad5:
if (_SelectingKeyboardPlayerNr == 5)
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 5;
NameSelections[_NameSelection].KeyboardSelection(true, 5);
}
_SelectingKeyboardUnendless = false;
numberPressed = 5;
break;
case Keys.D6:
case Keys.NumPad6:
if (_SelectingKeyboardPlayerNr == 6)
{
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
}
else
{
_SelectingKeyboardPlayerNr = 6;
NameSelections[_NameSelection].KeyboardSelection(true, 6);
}
_SelectingKeyboardUnendless = false;
numberPressed = 6;
break;
case Keys.Escape:
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
_SelectingKeyboardUnendless = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
resetSelection = true;
break;
case Keys.Delete:
//Delete profile-selection
CGame.Player[_SelectingKeyboardPlayerNr - 1].ProfileID = -1;
CGame.Player[_SelectingKeyboardPlayerNr - 1].Name = String.Empty;
CGame.Player[_SelectingKeyboardPlayerNr - 1].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
CGame.Players[_SelectingKeyboardPlayerNr - 1].ProfileID = -1;
//Update config for default players.
CConfig.Players[_SelectingKeyboardPlayerNr - 1] = String.Empty;
CConfig.SaveConfig();
//Update texture and name
Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = _OriginalPlayerAvatarTextures[_SelectingKeyboardPlayerNr - 1];
Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + _SelectingKeyboardPlayerNr.ToString();
_Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = _OriginalPlayerAvatarTextures[_SelectingKeyboardPlayerNr - 1];
_Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CProfiles.GetPlayerName(-1, _SelectingKeyboardPlayerNr);
//Update profile-warning
_CheckPlayers();
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
_NameSelections[_NameSelection].KeyboardSelection(false, -1);
//Update Tiles-List
NameSelections[_NameSelection].UpdateList();
_NameSelections[_NameSelection].UpdateList();
break;
case Keys.F10:
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
{
if (SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]].Selection == 0)
SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]].Selection = 1;
else
SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]].Selection = 0;
CSelectSlide selectSlideDuetPart = _SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]];
selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2;
//Reset all values
_SelectingKeyboardPlayerNr = 0;
_SelectingKeyboardActive = false;
_SelectingKeyboardUnendless = false;
NameSelections[_NameSelection].KeyboardSelection(false, -1);
SetInteractionToButton(Buttons[_ButtonStart]);
_NameSelections[_NameSelection].KeyboardSelection(false, -1);
_SetInteractionToButton(_Buttons[_ButtonStart]);
}
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
else
{
base.HandleInput(keyEvent);
bool processed = false;
switch (keyEvent.Key)
{
case Keys.Escape:
@@ -352,17 +285,10 @@ namespace Vocaluxe.Screens
case Keys.Enter:
if (!processed && Buttons[_ButtonBack].Selected)
{
processed = true;
if (_Buttons[_ButtonBack].Selected)
CGraphics.FadeTo(EScreens.ScreenSong);
}
if (!processed /* && Buttons[ButtonStart].Selected */)
{
processed = true;
else
_StartSong();
}
break;
@@ -395,15 +321,16 @@ namespace Vocaluxe.Screens
case Keys.NumPad6:
_SelectingKeyboardPlayerNr = 6;
break;
default:
_UpdatePlayerNumber();
break;
}
if (!processed)
_UpdatePlayerNumber();
if (_SelectingKeyboardPlayerNr > 0 && _SelectingKeyboardPlayerNr <= CConfig.NumPlayer)
{
_SelectingKeyboardActive = true;
NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
_NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
}
}
@@ -415,23 +342,20 @@ namespace Vocaluxe.Screens
base.HandleMouse(mouseEvent);
//Check if LeftButton is hold and Select-Mode inactive
if (mouseEvent.LBH && !_SelectingMouseActive)
if (mouseEvent.LBH && _SelectedPlayerNr < 0)
{
//Save mouse-coords
_OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y;
//Check if mouse if over tile
if (NameSelections[_NameSelection].IsOverTile(mouseEvent))
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{
//Get player-number of tile
_SelectedPlayerNr = NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
_SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
if (_SelectedPlayerNr != -1)
{
//Activate mouse-selecting
_SelectingMouseActive = true;
//Update of Drag/Drop-Texture
CStatic selectedPlayer = NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
_ChooseAvatarStatic.Visible = true;
_ChooseAvatarStatic.Rect = selectedPlayer.Rect;
_ChooseAvatarStatic.Rect.Z = CSettings.ZNear;
@@ -442,7 +366,7 @@ namespace Vocaluxe.Screens
}
//Check if LeftButton is hold and Select-Mode active
if (mouseEvent.LBH && _SelectingMouseActive)
if (mouseEvent.LBH && _SelectedPlayerNr >= 0)
{
//Update coords for Drag/Drop-Texture
_ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX;
@@ -450,67 +374,47 @@ namespace Vocaluxe.Screens
_OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y;
}
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "ReplacedStr:::0:::" of Avatar
else if (_SelectingMouseActive)
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
else if (_SelectedPlayerNr >= 0)
{
//Check if really a player was selected
if (_SelectedPlayerNr != -1)
//Foreach Drop-Area
for (int i = 0; i < _StaticPlayer.Length; i++)
{
//Foreach Drop-Area
for (int i = 0; i < _StaticPlayer.Length; i++)
//Check first, if area is "Active"
if (!_Statics[_StaticPlayer[i]].Visible)
continue;
//Check if Mouse is in area
if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent))
{
//Check first, if area is "ReplacedStr:::1:::"
if (Statics[_StaticPlayer[i]].Visible)
{
//Check if Mouse is in area
if (CHelper.IsInBounds(Statics[_StaticPlayer[i]].Rect, mouseEvent))
{
//Update Game-infos with new player
CGame.Player[i].Name = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
CGame.Player[i].Difficulty = CProfiles.Profiles[_SelectedPlayerNr].Difficulty;
CGame.Player[i].ProfileID = _SelectedPlayerNr;
//Update config for default players.
CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.SaveConfig();
//Update texture and name
Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture;
Texts[_TextPlayer[i]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
NameSelections[_NameSelection].UpdateList();
}
}
//Update Game-infos with new player
CGame.Players[i].ProfileID = _SelectedPlayerNr;
//Update config for default players.
CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture;
_Texts[_TextPlayer[i]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
_NameSelections[_NameSelection].UpdateList();
}
_SelectedPlayerNr = -1;
}
_SelectedPlayerNr = -1;
//Reset variables
_SelectingMouseActive = false;
_ChooseAvatarStatic.Visible = false;
}
if (mouseEvent.LB && IsMouseOver(mouseEvent)) {}
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
bool processed = false;
if (!processed && Buttons[_ButtonBack].Selected)
{
processed = true;
if (_Buttons[_ButtonBack].Selected)
CGraphics.FadeTo(EScreens.ScreenSong);
}
if (!processed && Buttons[_ButtonStart].Selected)
{
processed = true;
else if (_Buttons[_ButtonStart].Selected)
_StartSong();
}
if (!processed)
else
_UpdatePlayerNumber();
//Update Tiles-List
NameSelections[_NameSelection].UpdateList();
_NameSelections[_NameSelection].UpdateList();
}
if (mouseEvent.RB)
@@ -519,21 +423,19 @@ namespace Vocaluxe.Screens
//Remove profile-selection
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.Player[i].Name = String.Empty;
CGame.Player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
CGame.Players[i].ProfileID = -1;
//Update config for default players.
CConfig.Players[i] = String.Empty;
CConfig.SaveConfig();
//Update texture and name
Statics[_StaticPlayerAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i];
Texts[_TextPlayer[i]].Text = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + (i + 1).ToString();
_Statics[_StaticPlayerAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i];
_Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(-1, i + 1);
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
NameSelections[_NameSelection].UpdateList();
_NameSelections[_NameSelection].UpdateList();
exit = false;
}
}
@@ -544,10 +446,10 @@ namespace Vocaluxe.Screens
//Check mouse-wheel for scrolling
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;
NameSelections[_NameSelection].UpdateList(offset);
int offset = _NameSelections[_NameSelection].Offset + mouseEvent.Wheel;
_NameSelections[_NameSelection].UpdateList(offset);
}
}
return true;
@@ -558,7 +460,7 @@ namespace Vocaluxe.Screens
for (int i = 1; i <= CGame.NumPlayer; i++)
{
CSound.AnalyzeBuffer(i - 1);
Equalizers["EqualizerPlayer" + i].Update(CSound.ToneWeigth(i - 1));
_Equalizers["EqualizerPlayer" + i].Update(CSound.ToneWeigth(i - 1));
}
return true;
}
@@ -568,7 +470,7 @@ namespace Vocaluxe.Screens
base.OnShow();
CSound.RecordStart();
NameSelections[_NameSelection].Init();
_NameSelections[_NameSelection].Init();
_UpdateSlides();
_UpdatePlayerNumber();
@@ -577,34 +479,23 @@ namespace Vocaluxe.Screens
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
//Update texture and name
if (CConfig.Players[i].Length > 0)
{
if (CGame.Player[i].ProfileID > -1 && CProfiles.NumProfiles > CGame.Player[i].ProfileID)
{
Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.Profiles[CGame.Player[i].ProfileID].Avatar.Texture;
Texts[_TextPlayer[i]].Text = CProfiles.Profiles[CGame.Player[i].ProfileID].PlayerName;
}
}
_Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.IsProfileIDValid(CGame.Players[i].ProfileID) ?
CProfiles.Profiles[CGame.Players[i].ProfileID].Avatar.Texture :
_OriginalPlayerAvatarTextures[i];
_Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID, i + 1);
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
{
SelectSlides[_SelectSlideDuetPlayer[i]].Clear();
if (i + 1 <= CGame.NumPlayer)
SelectSlides[_SelectSlideDuetPlayer[i]].Visible = true;
else
SelectSlides[_SelectSlideDuetPlayer[i]].Visible = false;
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;
_SelectSlides[_SelectSlideDuetPlayer[i]].Clear();
_SelectSlides[_SelectSlideDuetPlayer[i]].Visible = i + 1 <= CGame.NumPlayer;
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart1);
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart2);
_SelectSlides[_SelectSlideDuetPlayer[i]].Selection = i % 2;
}
else
SelectSlides[_SelectSlideDuetPlayer[i]].Visible = false;
_SelectSlides[_SelectSlideDuetPlayer[i]].Visible = false;
}
SetInteractionToButton(Buttons[_ButtonStart]);
_SetInteractionToButton(_Buttons[_ButtonStart]);
}
public override void OnClose()
@@ -620,7 +511,7 @@ namespace Vocaluxe.Screens
if (_ChooseAvatarStatic.Visible)
_ChooseAvatarStatic.Draw();
for (int i = 1; i <= CGame.NumPlayer; i++)
Equalizers["EqualizerPlayer" + i].Draw();
_Equalizers["EqualizerPlayer" + i].Draw();
return true;
}
@@ -628,20 +519,8 @@ namespace Vocaluxe.Screens
{
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)
CGame.Player[i].LineNr = SelectSlides[_SelectSlideDuetPlayer[i]].Selection;
CGame.Players[i].LineNr = _SelectSlides[_SelectSlideDuetPlayer[i]].Selection;
}
CGraphics.FadeTo(EScreens.ScreenSing);
@@ -649,36 +528,36 @@ namespace Vocaluxe.Screens
private void _UpdateSlides()
{
SelectSlides[_SelectSlidePlayerNumber].Clear();
_SelectSlides[_SelectSlidePlayerNumber].Clear();
for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
SelectSlides[_SelectSlidePlayerNumber].AddValue(CLanguage.Translate("TR_SCREENNAMES_" + i + "PLAYER"));
SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 1;
_SelectSlides[_SelectSlidePlayerNumber].AddValue(CLanguage.Translate("TR_SCREENNAMES_" + i + "PLAYER"));
_SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 1;
}
private void _UpdatePlayerNumber()
{
CConfig.NumPlayer = SelectSlides[_SelectSlidePlayerNumber].Selection + 1;
CGame.NumPlayer = SelectSlides[_SelectSlidePlayerNumber].Selection + 1;
CConfig.NumPlayer = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1;
CGame.NumPlayer = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1;
for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
{
if (i <= CGame.NumPlayer)
{
Statics["StaticPlayer" + i].Visible = true;
Statics["StaticPlayerAvatar" + i].Visible = true;
Texts["TextPlayer" + i].Visible = true;
if (Texts["TextPlayer" + i].Text.Length == 0)
Texts["TextPlayer" + i].Text = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + i.ToString();
Equalizers["EqualizerPlayer" + i].Visible = true;
_Statics["StaticPlayer" + i].Visible = true;
_Statics["StaticPlayerAvatar" + i].Visible = true;
_Texts["TextPlayer" + i].Visible = true;
if (_Texts["TextPlayer" + i].Text == "")
_Texts["TextPlayer" + i].Text = CProfiles.GetPlayerName(-1, i);
_Equalizers["EqualizerPlayer" + i].Visible = true;
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
SelectSlides["SelectSlideDuetPlayer" + i].Visible = true;
_SelectSlides["SelectSlideDuetPlayer" + i].Visible = true;
}
else
{
Statics["StaticPlayer" + i].Visible = false;
Statics["StaticPlayerAvatar" + i].Visible = false;
Texts["TextPlayer" + i].Visible = false;
Equalizers["EqualizerPlayer" + i].Visible = false;
SelectSlides["SelectSlideDuetPlayer" + i].Visible = false;
_Statics["StaticPlayer" + i].Visible = false;
_Statics["StaticPlayerAvatar" + i].Visible = false;
_Texts["TextPlayer" + i].Visible = false;
_Equalizers["EqualizerPlayer" + i].Visible = false;
_SelectSlides["SelectSlideDuetPlayer" + i].Visible = false;
}
}
CConfig.SaveConfig();
@@ -696,8 +575,8 @@ namespace Vocaluxe.Screens
}
if (playerWithoutMicro.Count > 0)
{
Statics[_StaticWarningMics].Visible = true;
Texts[_TextWarningMics].Visible = true;
_Statics[_StaticWarningMics].Visible = true;
_Texts[_TextWarningMics].Visible = true;
if (playerWithoutMicro.Count > 1)
{
@@ -707,20 +586,20 @@ namespace Vocaluxe.Screens
if (playerWithoutMicro.Count - 1 == i)
playerNums += playerWithoutMicro[i].ToString();
else if (playerWithoutMicro.Count - 2 == i)
playerNums += playerWithoutMicro[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
playerNums += playerWithoutMicro[i] + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
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
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
{
Statics[_StaticWarningMics].Visible = false;
Texts[_TextWarningMics].Visible = false;
_Statics[_StaticWarningMics].Visible = false;
_Texts[_TextWarningMics].Visible = false;
}
}
@@ -729,14 +608,14 @@ namespace Vocaluxe.Screens
List<int> playerWithoutProfile = new List<int>();
for (int player = 0; player < CConfig.NumPlayer; player++)
{
if (CGame.Player[player].ProfileID < 0)
if (CGame.Players[player].ProfileID < 0)
playerWithoutProfile.Add(player + 1);
}
if (playerWithoutProfile.Count > 0)
{
Statics[_StaticWarningProfiles].Visible = true;
Texts[_TextWarningProfiles].Visible = true;
_Statics[_StaticWarningProfiles].Visible = true;
_Texts[_TextWarningProfiles].Visible = true;
if (playerWithoutProfile.Count > 1)
{
@@ -746,20 +625,20 @@ namespace Vocaluxe.Screens
if (playerWithoutProfile.Count - 1 == i)
playerNums += playerWithoutProfile[i].ToString();
else if (playerWithoutProfile.Count - 2 == i)
playerNums += playerWithoutProfile[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
playerNums += playerWithoutProfile[i] + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
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
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
{
Statics[_StaticWarningProfiles].Visible = false;
Texts[_TextWarningProfiles].Visible = false;
_Statics[_StaticWarningProfiles].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 VocaluxeLib.Menu;
@@ -46,22 +65,22 @@ namespace Vocaluxe.Screens
break;
case Keys.Enter:
if (Buttons[_ButtonOptionsGame].Selected)
if (_Buttons[_ButtonOptionsGame].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsGame);
if (Buttons[_ButtonOptionsSound].Selected)
if (_Buttons[_ButtonOptionsSound].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsSound);
if (Buttons[_ButtonOptionsRecord].Selected)
if (_Buttons[_ButtonOptionsRecord].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsRecord);
if (Buttons[_ButtonOptionsVideo].Selected)
if (_Buttons[_ButtonOptionsVideo].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsVideo);
if (Buttons[_ButtonOptionsLyrics].Selected)
if (_Buttons[_ButtonOptionsLyrics].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsLyrics);
if (Buttons[_ButtonOptionsTheme].Selected)
if (_Buttons[_ButtonOptionsTheme].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsTheme);
break;
@@ -74,24 +93,24 @@ namespace Vocaluxe.Screens
{
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);
if (Buttons[_ButtonOptionsSound].Selected)
if (_Buttons[_ButtonOptionsSound].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsSound);
if (Buttons[_ButtonOptionsRecord].Selected)
if (_Buttons[_ButtonOptionsRecord].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsRecord);
if (Buttons[_ButtonOptionsVideo].Selected)
if (_Buttons[_ButtonOptionsVideo].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsVideo);
if (Buttons[_ButtonOptionsLyrics].Selected)
if (_Buttons[_ButtonOptionsLyrics].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsLyrics);
if (Buttons[_ButtonOptionsTheme].Selected)
if (_Buttons[_ButtonOptionsTheme].Selected)
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 VocaluxeLib.Menu;
@@ -33,14 +52,14 @@ namespace Vocaluxe.Screens
{
base.LoadTheme(xmlPath);
SelectSlides[_SelectSlideLanguage].AddValues(CLanguage.GetLanguageNames());
SelectSlides[_SelectSlideLanguage].Selection = CLanguage.LanguageId;
_SelectSlides[_SelectSlideLanguage].AddValues(CLanguage.GetLanguageNames());
_SelectSlides[_SelectSlideLanguage].Selection = CLanguage.LanguageId;
SelectSlides[_SelectSlideDebugLevel].SetValues<EDebugLevel>((int)CConfig.DebugLevel);
SelectSlides[_SelectSlideSongMenu].SetValues<ESongMenu>((int)CConfig.SongMenu);
SelectSlides[_SelectSlideSongSorting].SetValues<ESongSorting>((int)CConfig.SongSorting);
SelectSlides[_SelectSlideTabs].SetValues<EOffOn>((int)CConfig.Tabs);
SelectSlides[_SelectSlideTimerMode].SetValues<ETimerMode>((int)CConfig.TimerMode);
_SelectSlides[_SelectSlideDebugLevel].SetValues<EDebugLevel>((int)CConfig.DebugLevel);
_SelectSlides[_SelectSlideSongMenu].SetValues<ESongMenu>((int)CConfig.SongMenu);
_SelectSlides[_SelectSlideSongSorting].SetValues<ESongSorting>((int)CConfig.SongSorting);
_SelectSlides[_SelectSlideTabs].SetValues<EOffOn>((int)CConfig.Tabs);
_SelectSlides[_SelectSlideTimerMode].SetValues<ETimerMode>((int)CConfig.TimerMode);
}
public override bool HandleInput(SKeyEvent keyEvent)
@@ -63,7 +82,7 @@ namespace Vocaluxe.Screens
break;
case Keys.Enter:
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
{
_SaveConfig();
CGraphics.FadeTo(EScreens.ScreenOptions);
@@ -92,10 +111,10 @@ namespace Vocaluxe.Screens
CGraphics.FadeTo(EScreens.ScreenOptions);
}
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
_SaveConfig();
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions);
}
return true;
@@ -114,13 +133,13 @@ namespace Vocaluxe.Screens
private void _SaveConfig()
{
CLanguage.LanguageId = SelectSlides[_SelectSlideLanguage].Selection;
CLanguage.LanguageId = _SelectSlides[_SelectSlideLanguage].Selection;
CConfig.Language = CLanguage.GetLanguageName(CLanguage.LanguageId);
CConfig.DebugLevel = (EDebugLevel)SelectSlides[_SelectSlideDebugLevel].Selection;
CConfig.SongMenu = (ESongMenu)SelectSlides[_SelectSlideSongMenu].Selection;
CConfig.SongSorting = (ESongSorting)SelectSlides[_SelectSlideSongSorting].Selection;
CConfig.Tabs = (EOffOn)SelectSlides[_SelectSlideTabs].Selection;
CConfig.TimerMode = (ETimerMode)SelectSlides[_SelectSlideTimerMode].Selection;
CConfig.DebugLevel = (EDebugLevel)_SelectSlides[_SelectSlideDebugLevel].Selection;
CConfig.SongMenu = (ESongMenu)_SelectSlides[_SelectSlideSongMenu].Selection;
CConfig.SongSorting = (ESongSorting)_SelectSlides[_SelectSlideSongSorting].Selection;
CConfig.Tabs = (EOffOn)_SelectSlides[_SelectSlideTabs].Selection;
CConfig.TimerMode = (ETimerMode)_SelectSlides[_SelectSlideTimerMode].Selection;
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 VocaluxeLib.Menu;
@@ -28,8 +47,8 @@ namespace Vocaluxe.Screens
public override void LoadTheme(string xmlPath)
{
base.LoadTheme(xmlPath);
SelectSlides[_SelectSlideLyricStyle].SetValues<ELyricStyle>((int)CConfig.LyricStyle);
SelectSlides[_SelectSlideLyricsOnTop].SetValues<EOffOn>((int)CConfig.LyricsOnTop);
_SelectSlides[_SelectSlideLyricStyle].SetValues<ELyricStyle>((int)CConfig.LyricStyle);
_SelectSlides[_SelectSlideLyricsOnTop].SetValues<EOffOn>((int)CConfig.LyricsOnTop);
}
public override bool HandleInput(SKeyEvent keyEvent)
@@ -53,7 +72,7 @@ namespace Vocaluxe.Screens
break;
case Keys.Enter:
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
{
_SaveConfig();
CGraphics.FadeTo(EScreens.ScreenOptions);
@@ -81,10 +100,10 @@ namespace Vocaluxe.Screens
_SaveConfig();
CGraphics.FadeTo(EScreens.ScreenOptions);
}
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
_SaveConfig();
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions);
}
return true;
@@ -103,8 +122,8 @@ namespace Vocaluxe.Screens
private void _SaveConfig()
{
CConfig.LyricsOnTop = (EOffOn)SelectSlides[_SelectSlideLyricsOnTop].Selection;
CConfig.LyricStyle = (ELyricStyle)SelectSlides[_SelectSlideLyricStyle].Selection;
CConfig.LyricsOnTop = (EOffOn)_SelectSlides[_SelectSlideLyricsOnTop].Selection;
CConfig.LyricStyle = (ELyricStyle)_SelectSlides[_SelectSlideLyricStyle].Selection;
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.Windows.Forms;
using Vocaluxe.Base;
@@ -56,8 +75,7 @@ namespace Vocaluxe.Screens
{
base.Init();
List<string> values = new List<string>();
values.Add(_StaticWarning);
List<string> values = new List<string> {_StaticWarning};
values.AddRange(_StaticEnergyChannel);
_ThemeStatics = values.ToArray();
@@ -75,31 +93,31 @@ namespace Vocaluxe.Screens
if (max > 7)
max = 7;
SelectSlides[_SelectSlideRecordChannel1].NumVisible = max;
SelectSlides[_SelectSlideRecordChannel2].NumVisible = max;
_SelectSlides[_SelectSlideRecordChannel1].NumVisible = max;
_SelectSlides[_SelectSlideRecordChannel2].NumVisible = max;
SelectSlides[_SelectSlideRecordChannel1].AddValue(CLanguage.Translate("TR_CONFIG_OFF"));
SelectSlides[_SelectSlideRecordChannel2].AddValue(CLanguage.Translate("TR_CONFIG_OFF"));
_SelectSlides[_SelectSlideRecordChannel1].AddValue(CLanguage.Translate("TR_CONFIG_OFF"));
_SelectSlides[_SelectSlideRecordChannel2].AddValue(CLanguage.Translate("TR_CONFIG_OFF"));
for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
{
SelectSlides[_SelectSlideRecordChannel1].AddValue(i.ToString());
SelectSlides[_SelectSlideRecordChannel2].AddValue(i.ToString());
_SelectSlides[_SelectSlideRecordChannel1].AddValue(i.ToString());
_SelectSlides[_SelectSlideRecordChannel2].AddValue(i.ToString());
}
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];
for (int i = 0; i < _ChannelEnergy.Length; i++)
{
Statics[_StaticEnergyChannel[i]].Visible = false;
_Statics[_StaticEnergyChannel[i]].Visible = false;
_ChannelEnergy[i] = 0f;
}
Equalizers[_EqualizerChannel1].ScreenHandles = true;
Equalizers[_EqualizerChannel2].ScreenHandles = true;
_Equalizers[_EqualizerChannel1].ScreenHandles = true;
_Equalizers[_EqualizerChannel2].ScreenHandles = true;
}
public override bool HandleInput(SKeyEvent keyEvent)
@@ -123,13 +141,13 @@ namespace Vocaluxe.Screens
break;
case Keys.Enter:
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
{
_SaveMicConfig();
CGraphics.FadeTo(EScreens.ScreenOptions);
}
if (Buttons[_ButtonDelayTest].Selected)
if (_Buttons[_ButtonDelayTest].Selected)
_TestDelay();
break;
@@ -139,32 +157,32 @@ namespace Vocaluxe.Screens
break;
case Keys.Left:
if (SelectSlides[_SelectSlideRecordDevices].Selected)
if (_SelectSlides[_SelectSlideRecordDevices].Selected)
_OnDeviceEvent();
if (SelectSlides[_SelectSlideRecordInputs].Selected)
if (_SelectSlides[_SelectSlideRecordInputs].Selected)
_OnInputEvent();
if (SelectSlides[_SelectSlideRecordChannel1].Selected ||
SelectSlides[_SelectSlideRecordChannel2].Selected)
if (_SelectSlides[_SelectSlideRecordChannel1].Selected ||
_SelectSlides[_SelectSlideRecordChannel2].Selected)
_SetMicConfig();
if (SelectSlides[_SelectSlideDelay].Selected)
if (_SelectSlides[_SelectSlideDelay].Selected)
_SaveDelayConfig();
break;
case Keys.Right:
if (SelectSlides[_SelectSlideRecordDevices].Selected)
if (_SelectSlides[_SelectSlideRecordDevices].Selected)
_OnDeviceEvent();
if (SelectSlides[_SelectSlideRecordInputs].Selected)
if (_SelectSlides[_SelectSlideRecordInputs].Selected)
_OnInputEvent();
if (SelectSlides[_SelectSlideRecordChannel1].Selected ||
SelectSlides[_SelectSlideRecordChannel2].Selected)
if (_SelectSlides[_SelectSlideRecordChannel1].Selected ||
_SelectSlides[_SelectSlideRecordChannel2].Selected)
_SetMicConfig();
if (SelectSlides[_SelectSlideDelay].Selected)
if (_SelectSlides[_SelectSlideDelay].Selected)
_SaveDelayConfig();
break;
}
@@ -182,28 +200,28 @@ namespace Vocaluxe.Screens
CGraphics.FadeTo(EScreens.ScreenOptions);
}
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
if (SelectSlides[_SelectSlideRecordDevices].Selected)
if (_SelectSlides[_SelectSlideRecordDevices].Selected)
_OnDeviceEvent();
if (SelectSlides[_SelectSlideRecordInputs].Selected)
if (_SelectSlides[_SelectSlideRecordInputs].Selected)
_OnInputEvent();
if (SelectSlides[_SelectSlideRecordChannel1].Selected ||
SelectSlides[_SelectSlideRecordChannel2].Selected)
if (_SelectSlides[_SelectSlideRecordChannel1].Selected ||
_SelectSlides[_SelectSlideRecordChannel2].Selected)
_SetMicConfig();
if (SelectSlides[_SelectSlideDelay].Selected)
if (_SelectSlides[_SelectSlideDelay].Selected)
_SaveDelayConfig();
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
{
_SaveMicConfig();
CGraphics.FadeTo(EScreens.ScreenOptions);
}
if (Buttons[_ButtonDelayTest].Selected)
if (_Buttons[_ButtonDelayTest].Selected)
_TestDelay();
}
return true;
@@ -230,10 +248,10 @@ namespace Vocaluxe.Screens
{
int player = 0;
if (i == 0)
player = SelectSlides[_SelectSlideRecordChannel1].Selection;
player = _SelectSlides[_SelectSlideRecordChannel1].Selection;
if (i == 1)
player = SelectSlides[_SelectSlideRecordChannel2].Selection;
player = _SelectSlides[_SelectSlideRecordChannel2].Selection;
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[_TextDelayChannel2].Text = _DelayTest[1].Delay.ToString("000") + " ms";
_Texts[_TextDelayChannel1].Text = _DelayTest[0].Delay.ToString("000") + " ms";
_Texts[_TextDelayChannel2].Text = _DelayTest[1].Delay.ToString("000") + " ms";
}
if (_CheckMicConfig())
{
_ChannelEnergy[0] = 0f;
int player = SelectSlides[_SelectSlideRecordChannel1].Selection;
int player = _SelectSlides[_SelectSlideRecordChannel1].Selection;
if (player > 0)
{
_ChannelEnergy[0] = CSound.RecordGetMaxVolume(player - 1);
Equalizers[_EqualizerChannel1].Update(CSound.ToneWeigth(player - 1));
_Equalizers[_EqualizerChannel1].Update(CSound.ToneWeigth(player - 1));
}
else
Equalizers[_EqualizerChannel1].Reset();
_Equalizers[_EqualizerChannel1].Reset();
_ChannelEnergy[1] = 0f;
player = SelectSlides[_SelectSlideRecordChannel2].Selection;
player = _SelectSlides[_SelectSlideRecordChannel2].Selection;
if (player > 0)
{
_ChannelEnergy[1] = CSound.RecordGetMaxVolume(player - 1);
Equalizers[_EqualizerChannel2].Update(CSound.ToneWeigth(player - 1));
_Equalizers[_EqualizerChannel2].Update(CSound.ToneWeigth(player - 1));
}
else
Equalizers[_EqualizerChannel2].Reset();
_Equalizers[_EqualizerChannel2].Reset();
}
else
{
for (int i = 0; i < _ChannelEnergy.Length; i++)
_ChannelEnergy[i] = 0f;
Equalizers[_EqualizerChannel1].Reset();
Equalizers[_EqualizerChannel2].Reset();
_Equalizers[_EqualizerChannel1].Reset();
_Equalizers[_EqualizerChannel2].Reset();
}
return true;
@@ -292,8 +310,8 @@ namespace Vocaluxe.Screens
{
base.OnShow();
SelectSlides[_SelectSlideRecordDevices].Clear();
SelectSlides[_SelectSlideRecordInputs].Clear();
_SelectSlides[_SelectSlideRecordDevices].Clear();
_SelectSlides[_SelectSlideRecordInputs].Clear();
for (int i = 0; i < _ChannelEnergy.Length; i++)
_ChannelEnergy[i] = 0f;
@@ -309,20 +327,20 @@ namespace Vocaluxe.Screens
_GetFirstConfiguredRecordDevice(ref _DeviceNr, ref _InputNr);
for (int dev = 0; dev < _Devices.Length; dev++)
SelectSlides[_SelectSlideRecordDevices].AddValue(_Devices[dev].Name);
SelectSlides[_SelectSlideRecordDevices].Selection = _DeviceNr;
_SelectSlides[_SelectSlideRecordDevices].AddValue(_Devices[dev].Name);
_SelectSlides[_SelectSlideRecordDevices].Selection = _DeviceNr;
for (int inp = 0; inp < _Devices[0].Inputs.Count; inp++)
SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[0].Inputs[inp].Name);
SelectSlides[_SelectSlideRecordInputs].Selection = _InputNr;
_SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[0].Inputs[inp].Name);
_SelectSlides[_SelectSlideRecordInputs].Selection = _InputNr;
_UpdateChannels();
}
SelectSlides[_SelectSlideRecordChannel1].Visible = _Devices != null;
SelectSlides[_SelectSlideRecordChannel2].Visible = _Devices != null;
_SelectSlides[_SelectSlideRecordChannel1].Visible = _Devices != null;
_SelectSlides[_SelectSlideRecordChannel2].Visible = _Devices != null;
Statics[_StaticWarning].Visible = false;
Texts[_TextWarning].Visible = false;
_Statics[_StaticWarning].Visible = false;
_Texts[_TextWarning].Visible = false;
_DelayTest = 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;
_DelaySound = -1;
@@ -349,38 +367,38 @@ namespace Vocaluxe.Screens
public override bool Draw()
{
DrawBG();
_DrawBG();
if (!_CheckMicConfig())
{
Statics[_StaticWarning].Visible = true;
Texts[_TextWarning].Visible = true;
_Statics[_StaticWarning].Visible = true;
_Texts[_TextWarning].Visible = true;
}
else
{
Statics[_StaticWarning].Visible = false;
Texts[_TextWarning].Visible = false;
_Statics[_StaticWarning].Visible = false;
_Texts[_TextWarning].Visible = false;
}
for (int i = 0; i < _StaticEnergyChannel.Length; i++)
{
if (_ChannelEnergy[i] > 0f)
{
SRectF rect = new SRectF(Statics[_StaticEnergyChannel[i]].Rect.X,
Statics[_StaticEnergyChannel[i]].Rect.Y,
Statics[_StaticEnergyChannel[i]].Rect.W * _ChannelEnergy[i],
Statics[_StaticEnergyChannel[i]].Rect.H,
Statics[_StaticEnergyChannel[i]].Rect.Z);
SRectF rect = new SRectF(_Statics[_StaticEnergyChannel[i]].Rect.X,
_Statics[_StaticEnergyChannel[i]].Rect.Y,
_Statics[_StaticEnergyChannel[i]].Rect.W * _ChannelEnergy[i],
_Statics[_StaticEnergyChannel[i]].Rect.H,
_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);
}
}
Equalizers[_EqualizerChannel1].Draw();
Equalizers[_EqualizerChannel2].Draw();
_Equalizers[_EqualizerChannel1].Draw();
_Equalizers[_EqualizerChannel2].Draw();
DrawFG();
_DrawFG();
return true;
}
@@ -396,25 +414,25 @@ namespace Vocaluxe.Screens
private void _OnDeviceEvent()
{
if (SelectSlides[_SelectSlideRecordDevices].Selection != _DeviceNr)
if (_SelectSlides[_SelectSlideRecordDevices].Selection != _DeviceNr)
{
SelectSlides[_SelectSlideRecordInputs].Clear();
_DeviceNr = SelectSlides[_SelectSlideRecordDevices].Selection;
_SelectSlides[_SelectSlideRecordInputs].Clear();
_DeviceNr = _SelectSlides[_SelectSlideRecordDevices].Selection;
_InputNr = 0;
for (int inp = 0; inp < _Devices[_DeviceNr].Inputs.Count; inp++)
SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[_DeviceNr].Inputs[inp].Name);
_SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[_DeviceNr].Inputs[inp].Name);
_InputNr = 0;
SelectSlides[_SelectSlideRecordInputs].Selection = 0;
_SelectSlides[_SelectSlideRecordInputs].Selection = 0;
_UpdateChannels();
}
}
private void _OnInputEvent()
{
if (SelectSlides[_SelectSlideRecordInputs].Selection != _InputNr)
if (_SelectSlides[_SelectSlideRecordInputs].Selection != _InputNr)
{
_InputNr = SelectSlides[_SelectSlideRecordInputs].Selection;
_InputNr = _SelectSlides[_SelectSlideRecordInputs].Selection;
_UpdateChannels();
}
@@ -422,7 +440,7 @@ namespace Vocaluxe.Screens
private void _SaveDelayConfig()
{
CConfig.MicDelay = SelectSlides[_SelectSlideDelay].Selection * 20;
CConfig.MicDelay = _SelectSlides[_SelectSlideDelay].Selection * 20;
CConfig.SaveConfig();
}
@@ -470,15 +488,15 @@ namespace Vocaluxe.Screens
if (_DeviceNr < 0)
return;
SInput input = _Devices[_DeviceNr].Inputs[_InputNr];
input.PlayerChannel1 = SelectSlides[_SelectSlideRecordChannel1].Selection;
input.PlayerChannel2 = SelectSlides[_SelectSlideRecordChannel2].Selection;
input.PlayerChannel1 = _SelectSlides[_SelectSlideRecordChannel1].Selection;
input.PlayerChannel2 = _SelectSlides[_SelectSlideRecordChannel2].Selection;
_Devices[_DeviceNr].Inputs[_InputNr] = input;
}
private void _UpdateChannels()
{
SelectSlides[_SelectSlideRecordChannel1].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel1;
SelectSlides[_SelectSlideRecordChannel2].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel2;
_SelectSlides[_SelectSlideRecordChannel1].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel1;
_SelectSlides[_SelectSlideRecordChannel2].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel2;
_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 VocaluxeLib.Menu;
@@ -21,7 +40,6 @@ namespace Vocaluxe.Screens
private const string _ButtonExit = "ButtonExit";
private int _BackgroundMusicVolume;
private EOffOn _BackgroundMusic;
public override void Init()
{
@@ -35,18 +53,18 @@ namespace Vocaluxe.Screens
public override void LoadTheme(string xmlPath)
{
base.LoadTheme(xmlPath);
SelectSlides[_SelectSlideBackgroundMusic].SetValues<EOffOn>((int)CConfig.BackgroundMusic);
SelectSlides[_SelectSlideBackgroundMusicVolume].AddValues(new string[]
_SelectSlides[_SelectSlideBackgroundMusic].SetValues<EOffOn>((int)CConfig.BackgroundMusic);
_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"});
SelectSlides[_SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5;
SelectSlides[_SelectSlideBackgroundMusicSource].SetValues<EBackgroundMusicSource>((int)CConfig.BackgroundMusicSource);
SelectSlides[_SelectSlideBackgroundMusicSource].Selection = (int)CConfig.BackgroundMusicSource;
SelectSlides[_SelectSlidePreviewMusicVolume].AddValues(new string[]
_SelectSlides[_SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5;
_SelectSlides[_SelectSlideBackgroundMusicSource].SetValues<EBackgroundMusicSource>((int)CConfig.BackgroundMusicSource);
_SelectSlides[_SelectSlideBackgroundMusicSource].Selection = (int)CConfig.BackgroundMusicSource;
_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"});
SelectSlides[_SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5;
SelectSlides[_SelectSlideGameMusicVolume].AddValues(new string[]
_SelectSlides[_SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5;
_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"});
SelectSlides[_SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5;
_SelectSlides[_SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5;
}
public override bool HandleInput(SKeyEvent keyEvent)
@@ -70,7 +88,7 @@ namespace Vocaluxe.Screens
break;
case Keys.Enter:
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
{
_SaveConfig();
CGraphics.FadeTo(EScreens.ScreenOptions);
@@ -98,10 +116,10 @@ namespace Vocaluxe.Screens
_SaveConfig();
CGraphics.FadeTo(EScreens.ScreenOptions);
}
if (mouseEvent.LB && IsMouseOver(mouseEvent))
if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{
_SaveConfig();
if (Buttons[_ButtonExit].Selected)
if (_Buttons[_ButtonExit].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions);
}
return true;
@@ -110,7 +128,7 @@ namespace Vocaluxe.Screens
public override bool UpdateGame()
{
if (_BackgroundMusicVolume != CConfig.BackgroundMusicVolume)
SelectSlides[_SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5;
_SelectSlides[_SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5;
return true;
}
@@ -123,22 +141,21 @@ namespace Vocaluxe.Screens
public override void OnShow()
{
base.OnShow();
_BackgroundMusic = CConfig.BackgroundMusic;
_BackgroundMusicVolume = CConfig.BackgroundMusicVolume;
SelectSlides[_SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5;
SelectSlides[_SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5;
_SelectSlides[_SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5;
_SelectSlides[_SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5;
}
private void _SaveConfig()
{
CConfig.GameMusicVolume = SelectSlides[_SelectSlideGameMusicVolume].Selection * 5;
CConfig.PreviewMusicVolume = SelectSlides[_SelectSlidePreviewMusicVolume].Selection * 5;
CConfig.GameMusicVolume = _SelectSlides[_SelectSlideGameMusicVolume].Selection * 5;
CConfig.PreviewMusicVolume = _SelectSlides[_SelectSlidePreviewMusicVolume].Selection * 5;
CConfig.SaveConfig();
EOffOn newOffOn = (EOffOn)SelectSlides[_SelectSlideBackgroundMusic].Selection;
EBackgroundMusicSource newSource = (EBackgroundMusicSource)SelectSlides[_SelectSlideBackgroundMusicSource].Selection;
float newVolume = SelectSlides[_SelectSlideBackgroundMusicVolume].Selection * 5;
EOffOn newOffOn = (EOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection;
EBackgroundMusicSource newSource = (EBackgroundMusicSource)_SelectSlides[_SelectSlideBackgroundMusicSource].Selection;
float newVolume = _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection * 5;
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