Merge branch 'Code_cleanup' into develop
This commit is contained in:
commit
1d89cec7bf
154 files changed
+15727
-15575
No files matched your search
@@ -37,3 +37,4 @@ Output/Songs
|
||||
/PartyModes/*/*/*.dll
|
||||
|
||||
*.Cache
|
||||
/Output/x86/gstreamer/GstreamerHelper.dll
|
||||
@@ -27,13 +27,13 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugWin|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<PlatformToolset>v110_xp</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugWin|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<PlatformToolset>v110_xp</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWin|Win32'" Label="Configuration">
|
||||
@@ -149,11 +149,13 @@
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;GSTREAMERHELPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
<Author>brunzel</Author>
|
||||
<Description>TR_PARTYMODE_DESCRIPTION</Description>
|
||||
<Folder>Challenge</Folder>
|
||||
<PartyModeFile>PartyModeChallenge</PartyModeFile>
|
||||
<PartyModeFile>CPartyModeChallenge</PartyModeFile>
|
||||
<PartyModeVersionMajor>0</PartyModeVersionMajor>
|
||||
<PartyModeVersionMinor>1</PartyModeVersionMinor>
|
||||
<TargetAudience>TR_PARTYMODE_AUDIENCE</TargetAudience>
|
||||
</Info>
|
||||
<PartyScreens>
|
||||
<ScreenFile>PartyScreenChallengeMain</ScreenFile>
|
||||
<ScreenFile>PartyScreenChallengeConfig</ScreenFile>
|
||||
<ScreenFile>PartyScreenChallengeNames</ScreenFile>
|
||||
<ScreenFile>CPartyScreenChallengeMain</ScreenFile>
|
||||
<ScreenFile>CPartyScreenChallengeConfig</ScreenFile>
|
||||
<ScreenFile>CPartyScreenChallengeNames</ScreenFile>
|
||||
</PartyScreens>
|
||||
</root>
|
||||
@@ -6,14 +6,14 @@
|
||||
<Author>brunzel</Author>
|
||||
<Description>TR_PARTYMODE_DESCRIPTION</Description>
|
||||
<Folder>ChallengeMedley</Folder>
|
||||
<PartyModeFile>PartyModeChallengeMedley</PartyModeFile>
|
||||
<PartyModeFile>CPartyModeChallengeMedley</PartyModeFile>
|
||||
<PartyModeVersionMajor>0</PartyModeVersionMajor>
|
||||
<PartyModeVersionMinor>1</PartyModeVersionMinor>
|
||||
<TargetAudience>TR_PARTYMODE_AUDIENCE</TargetAudience>
|
||||
</Info>
|
||||
<PartyScreens>
|
||||
<ScreenFile>PartyScreenChallengeMedleyMain</ScreenFile>
|
||||
<ScreenFile>PartyScreenChallengeMedleyConfig</ScreenFile>
|
||||
<ScreenFile>PartyScreenChallengeMedleyNames</ScreenFile>
|
||||
<ScreenFile>CPartyScreenChallengeMedleyMain</ScreenFile>
|
||||
<ScreenFile>CPartyScreenChallengeMedleyConfig</ScreenFile>
|
||||
<ScreenFile>CPartyScreenChallengeMedleyNames</ScreenFile>
|
||||
</PartyScreens>
|
||||
</root>
|
||||
@@ -6,14 +6,14 @@
|
||||
<Author>flokuep</Author>
|
||||
<Description>TR_PARTYMODE_DESCRIPTION</Description>
|
||||
<Folder>TicTacToe</Folder>
|
||||
<PartyModeFile>PartyModeTicTacToe</PartyModeFile>
|
||||
<PartyModeFile>CPartyModeTicTacToe</PartyModeFile>
|
||||
<PartyModeVersionMajor>0</PartyModeVersionMajor>
|
||||
<PartyModeVersionMinor>1</PartyModeVersionMinor>
|
||||
<TargetAudience>TR_PARTYMODE_AUDIENCE</TargetAudience>
|
||||
</Info>
|
||||
<PartyScreens>
|
||||
<ScreenFile>PartyScreenTicTacToeMain</ScreenFile>
|
||||
<ScreenFile>PartyScreenTicTacToeConfig</ScreenFile>
|
||||
<ScreenFile>PartyScreenTicTacToeNames</ScreenFile>
|
||||
<ScreenFile>CPartyScreenTicTacToeMain</ScreenFile>
|
||||
<ScreenFile>CPartyScreenTicTacToeConfig</ScreenFile>
|
||||
<ScreenFile>CPartyScreenTicTacToeNames</ScreenFile>
|
||||
</PartyScreens>
|
||||
</root>
|
||||
@@ -82,7 +82,7 @@
|
||||
<!--<Font>: Text font name-->
|
||||
<Font>Outline</Font>
|
||||
<!--<Text>: Nothing or translation tag-->
|
||||
<Text>TR_SCREENCONFIG_NUMPLAYERT1</Text>
|
||||
<Text>TR_SCREENCONFIG_NUMPLAYERST1</Text>
|
||||
<!--<Reflection> If exists:-->
|
||||
<!-- <Space>: Reflection Space-->
|
||||
<!-- <Height>: Reflection Height-->
|
||||
@@ -111,7 +111,7 @@
|
||||
<!--<Font>: Text font name-->
|
||||
<Font>Outline</Font>
|
||||
<!--<Text>: Nothing or translation tag-->
|
||||
<Text>TR_SCREENCONFIG_NUMPLAYERT2</Text>
|
||||
<Text>TR_SCREENCONFIG_NUMPLAYERST2</Text>
|
||||
<!--<Reflection> If exists:-->
|
||||
<!-- <Space>: Reflection Space-->
|
||||
<!-- <Height>: Reflection Height-->
|
||||
|
||||
+188
-188
@@ -11,30 +11,30 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
#region Communication
|
||||
|
||||
#region ToScreen
|
||||
public struct DataToScreenConfig
|
||||
public struct SDataToScreenConfig
|
||||
{
|
||||
public int NumPlayer;
|
||||
public int NumPlayerAtOnce;
|
||||
public int NumRounds;
|
||||
}
|
||||
|
||||
public struct DataToScreenNames
|
||||
public struct SDataToScreenNames
|
||||
{
|
||||
public int NumPlayer;
|
||||
public List<int> ProfileIDs;
|
||||
}
|
||||
|
||||
public struct DataToScreenMain
|
||||
public struct SDataToScreenMain
|
||||
{
|
||||
public int CurrentRoundNr;
|
||||
public int NumPlayerAtOnce;
|
||||
public List<Combination> Combs;
|
||||
public List<CCombination> Combs;
|
||||
public int[,] Results;
|
||||
public List<ResultTableRow> ResultTable;
|
||||
public List<CResultTableRow> ResultTable;
|
||||
public List<int> ProfileIDs;
|
||||
}
|
||||
|
||||
public class ResultTableRow : IComparable
|
||||
public class CResultTableRow : IComparable
|
||||
{
|
||||
public int Position;
|
||||
public int PlayerID;
|
||||
@@ -46,9 +46,9 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (obj is ResultTableRow)
|
||||
if (obj is CResultTableRow)
|
||||
{
|
||||
ResultTableRow row = (ResultTableRow)obj;
|
||||
CResultTableRow row = (CResultTableRow)obj;
|
||||
|
||||
int res = row.NumGamePoints.CompareTo(NumGamePoints);
|
||||
if (res == 0)
|
||||
@@ -66,28 +66,28 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
#endregion ToScreen
|
||||
|
||||
#region FromScreen
|
||||
public struct DataFromScreen
|
||||
public struct SDataFromScreen
|
||||
{
|
||||
public FromScreenConfig ScreenConfig;
|
||||
public FromScreenNames ScreenNames;
|
||||
public FromScreenMain ScreenMain;
|
||||
public SFromScreenConfig ScreenConfig;
|
||||
public SFromScreenNames ScreenNames;
|
||||
public SFromScreenMain ScreenMain;
|
||||
}
|
||||
|
||||
public struct FromScreenConfig
|
||||
public struct SFromScreenConfig
|
||||
{
|
||||
public int NumPlayer;
|
||||
public int NumPlayerAtOnce;
|
||||
public int NumRounds;
|
||||
}
|
||||
|
||||
public struct FromScreenNames
|
||||
public struct SFromScreenNames
|
||||
{
|
||||
public bool FadeToConfig;
|
||||
public bool FadeToMain;
|
||||
public List<int> ProfileIDs;
|
||||
}
|
||||
|
||||
public struct FromScreenMain
|
||||
public struct SFromScreenMain
|
||||
{
|
||||
public bool FadeToSongSelection;
|
||||
public bool FadeToNameSelection;
|
||||
@@ -96,13 +96,13 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
#endregion Communication
|
||||
|
||||
public sealed class PartyModeChallenge : CPartyMode
|
||||
public sealed class CPartyModeChallenge : CPartyMode
|
||||
{
|
||||
private const int MaxPlayer = 12;
|
||||
private const int MinPlayer = 1;
|
||||
private const int MaxTeams = 0;
|
||||
private const int MinTeams = 0;
|
||||
private const int MaxNumRounds = 100;
|
||||
private const int _MaxPlayer = 12;
|
||||
private const int _MinPlayer = 1;
|
||||
private const int _MaxTeams = 0;
|
||||
private const int _MinTeams = 0;
|
||||
private const int _MaxNumRounds = 100;
|
||||
|
||||
private enum EStage
|
||||
{
|
||||
@@ -113,15 +113,15 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
Singing
|
||||
}
|
||||
|
||||
private struct Data
|
||||
private struct SData
|
||||
{
|
||||
public int NumPlayer;
|
||||
public int NumPlayerAtOnce;
|
||||
public int NumRounds;
|
||||
public List<int> ProfileIDs;
|
||||
|
||||
public ChallengeRounds Rounds;
|
||||
public List<ResultTableRow> ResultTable;
|
||||
public CChallengeRounds Rounds;
|
||||
public List<CResultTableRow> ResultTable;
|
||||
public int[,] Results;
|
||||
|
||||
public int CurrentRoundNr;
|
||||
@@ -129,7 +129,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
public int[] CatSongIndices;
|
||||
}
|
||||
|
||||
private struct Stats
|
||||
private struct SStats
|
||||
{
|
||||
public int ProfileID;
|
||||
public int SingPoints;
|
||||
@@ -137,14 +137,14 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
public int Won;
|
||||
}
|
||||
|
||||
private DataToScreenConfig ToScreenConfig;
|
||||
private DataToScreenNames ToScreenNames;
|
||||
private DataToScreenMain ToScreenMain;
|
||||
private SDataToScreenConfig _ToScreenConfig;
|
||||
private SDataToScreenNames _ToScreenNames;
|
||||
private SDataToScreenMain _ToScreenMain;
|
||||
|
||||
private Data GameData;
|
||||
private SData _GameData;
|
||||
private EStage _Stage;
|
||||
|
||||
public PartyModeChallenge()
|
||||
public CPartyModeChallenge()
|
||||
{
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;
|
||||
_ScreenSongOptions.Selection.PartyMode = true;
|
||||
@@ -158,18 +158,18 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
_Stage = EStage.NotStarted;
|
||||
|
||||
ToScreenConfig = new DataToScreenConfig();
|
||||
ToScreenNames = new DataToScreenNames();
|
||||
ToScreenMain = new DataToScreenMain();
|
||||
_ToScreenConfig = new SDataToScreenConfig();
|
||||
_ToScreenNames = new SDataToScreenNames();
|
||||
_ToScreenMain = new SDataToScreenMain();
|
||||
|
||||
GameData = new Data();
|
||||
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();
|
||||
_GameData.NumPlayer = 4;
|
||||
_GameData.NumPlayerAtOnce = 2;
|
||||
_GameData.NumRounds = 2;
|
||||
_GameData.CurrentRoundNr = 1;
|
||||
_GameData.ProfileIDs = new List<int>();
|
||||
_GameData.CatSongIndices = null;
|
||||
_GameData.Results = null;
|
||||
}
|
||||
|
||||
public override bool Init()
|
||||
@@ -184,44 +184,44 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
if (CBase.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE)
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
|
||||
|
||||
ToScreenMain.ResultTable = new List<ResultTableRow>();
|
||||
GameData.ResultTable = new List<ResultTableRow>();
|
||||
_ToScreenMain.ResultTable = new List<CResultTableRow>();
|
||||
_GameData.ResultTable = new List<CResultTableRow>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void DataFromScreen(string ScreenName, Object Data)
|
||||
public override void DataFromScreen(string screenName, Object data)
|
||||
{
|
||||
DataFromScreen data = new DataFromScreen();
|
||||
switch (ScreenName)
|
||||
SDataFromScreen dataFrom = new SDataFromScreen();
|
||||
switch (screenName)
|
||||
{
|
||||
case "PartyScreenChallengeConfig":
|
||||
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
GameData.NumPlayer = data.ScreenConfig.NumPlayer;
|
||||
GameData.NumPlayerAtOnce = data.ScreenConfig.NumPlayerAtOnce;
|
||||
GameData.NumRounds = data.ScreenConfig.NumRounds;
|
||||
dataFrom = (SDataFromScreen)data;
|
||||
_GameData.NumPlayer = dataFrom.ScreenConfig.NumPlayer;
|
||||
_GameData.NumPlayerAtOnce = dataFrom.ScreenConfig.NumPlayerAtOnce;
|
||||
_GameData.NumRounds = dataFrom.ScreenConfig.NumRounds;
|
||||
|
||||
_Stage = EStage.Config;
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + screenName + ". " + e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PartyScreenChallengeNames":
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
if (data.ScreenNames.FadeToConfig)
|
||||
dataFrom = (SDataFromScreen)data;
|
||||
if (dataFrom.ScreenNames.FadeToConfig)
|
||||
_Stage = EStage.NotStarted;
|
||||
else
|
||||
{
|
||||
GameData.ProfileIDs = data.ScreenNames.ProfileIDs;
|
||||
_GameData.ProfileIDs = dataFrom.ScreenNames.ProfileIDs;
|
||||
_Stage = EStage.Names;
|
||||
}
|
||||
|
||||
@@ -229,33 +229,33 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + screenName + ". " + e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PartyScreenChallengeMain":
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
if (data.ScreenMain.FadeToSongSelection)
|
||||
dataFrom = (SDataFromScreen)data;
|
||||
if (dataFrom.ScreenMain.FadeToSongSelection)
|
||||
_Stage = EStage.Singing;
|
||||
if (data.ScreenMain.FadeToNameSelection)
|
||||
if (dataFrom.ScreenMain.FadeToNameSelection)
|
||||
_Stage = EStage.Config;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + screenName + ". " + e.Message);
|
||||
}
|
||||
|
||||
|
||||
if (_Stage == EStage.Singing)
|
||||
StartNextRound();
|
||||
_StartNextRound();
|
||||
if (_Stage == EStage.Config)
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
break;
|
||||
|
||||
default:
|
||||
CBase.Log.LogError("Error in party mode challenge. Wrong screen is sending: " + ScreenName);
|
||||
CBase.Log.LogError("Error in party mode challenge. Wrong screen is sending: " + screenName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -269,68 +269,68 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;*/
|
||||
}
|
||||
|
||||
public override CMenuParty GetNextPartyScreen(out EScreens AlternativeScreen)
|
||||
public override CMenuParty GetNextPartyScreen(out EScreens alternativeScreen)
|
||||
{
|
||||
CMenuParty Screen = null;
|
||||
AlternativeScreen = EScreens.ScreenSong;
|
||||
CMenuParty screen = null;
|
||||
alternativeScreen = EScreens.ScreenSong;
|
||||
|
||||
switch (_Stage)
|
||||
{
|
||||
case EStage.NotStarted:
|
||||
_Screens.TryGetValue("PartyScreenChallengeConfig", out Screen);
|
||||
if (_Screens != null)
|
||||
_Screens.TryGetValue("CPartyScreenChallengeConfig", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
ToScreenConfig.NumPlayer = GameData.NumPlayer;
|
||||
ToScreenConfig.NumPlayerAtOnce = GameData.NumPlayerAtOnce;
|
||||
ToScreenConfig.NumRounds = GameData.NumRounds;
|
||||
Screen.DataToScreen(ToScreenConfig);
|
||||
_ToScreenConfig.NumPlayer = _GameData.NumPlayer;
|
||||
_ToScreenConfig.NumPlayerAtOnce = _GameData.NumPlayerAtOnce;
|
||||
_ToScreenConfig.NumRounds = _GameData.NumRounds;
|
||||
screen.DataToScreen(_ToScreenConfig);
|
||||
}
|
||||
break;
|
||||
case EStage.Config:
|
||||
_Screens.TryGetValue("PartyScreenChallengeNames", out Screen);
|
||||
if (_Screens != null)
|
||||
_Screens.TryGetValue("CPartyScreenChallengeNames", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
ToScreenNames.NumPlayer = GameData.NumPlayer;
|
||||
ToScreenNames.ProfileIDs = GameData.ProfileIDs;
|
||||
Screen.DataToScreen(ToScreenNames);
|
||||
_ToScreenNames.NumPlayer = _GameData.NumPlayer;
|
||||
_ToScreenNames.ProfileIDs = _GameData.ProfileIDs;
|
||||
screen.DataToScreen(_ToScreenNames);
|
||||
}
|
||||
break;
|
||||
case EStage.Names:
|
||||
_Screens.TryGetValue("PartyScreenChallengeMain", out Screen);
|
||||
if (_Screens != null)
|
||||
_Screens.TryGetValue("CPartyScreenChallengeMain", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
CBase.Songs.ResetPartySongSung();
|
||||
ToScreenMain.ResultTable = new List<ResultTableRow>();
|
||||
GameData.ResultTable = new List<ResultTableRow>();
|
||||
GameData.Rounds = new ChallengeRounds(GameData.NumRounds, GameData.NumPlayer, GameData.NumPlayerAtOnce);
|
||||
GameData.CurrentRoundNr = 1;
|
||||
ToScreenMain.CurrentRoundNr = 1;
|
||||
ToScreenMain.NumPlayerAtOnce = GameData.NumPlayerAtOnce;
|
||||
ToScreenMain.Combs = GameData.Rounds.Rounds;
|
||||
ToScreenMain.ProfileIDs = GameData.ProfileIDs;
|
||||
UpdateScores();
|
||||
ToScreenMain.ResultTable = GameData.ResultTable;
|
||||
ToScreenMain.Results = GameData.Results;
|
||||
Screen.DataToScreen(ToScreenMain);
|
||||
_ToScreenMain.ResultTable = new List<CResultTableRow>();
|
||||
_GameData.ResultTable = new List<CResultTableRow>();
|
||||
_GameData.Rounds = new CChallengeRounds(_GameData.NumRounds, _GameData.NumPlayer, _GameData.NumPlayerAtOnce);
|
||||
_GameData.CurrentRoundNr = 1;
|
||||
_ToScreenMain.CurrentRoundNr = 1;
|
||||
_ToScreenMain.NumPlayerAtOnce = _GameData.NumPlayerAtOnce;
|
||||
_ToScreenMain.Combs = _GameData.Rounds.Rounds;
|
||||
_ToScreenMain.ProfileIDs = _GameData.ProfileIDs;
|
||||
_UpdateScores();
|
||||
_ToScreenMain.ResultTable = _GameData.ResultTable;
|
||||
_ToScreenMain.Results = _GameData.Results;
|
||||
screen.DataToScreen(_ToScreenMain);
|
||||
}
|
||||
break;
|
||||
case EStage.Main:
|
||||
//nothing to do
|
||||
break;
|
||||
case EStage.Singing:
|
||||
_Screens.TryGetValue("PartyScreenChallengeMain", out Screen);
|
||||
if (_Screens != null)
|
||||
_Screens.TryGetValue("CPartyScreenChallengeMain", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
UpdateScores();
|
||||
ToScreenMain.CurrentRoundNr = GameData.CurrentRoundNr;
|
||||
ToScreenMain.Combs = GameData.Rounds.Rounds;
|
||||
ToScreenMain.Results = GameData.Results;
|
||||
Screen.DataToScreen(ToScreenMain);
|
||||
_UpdateScores();
|
||||
_ToScreenMain.CurrentRoundNr = _GameData.CurrentRoundNr;
|
||||
_ToScreenMain.Combs = _GameData.Rounds.Rounds;
|
||||
_ToScreenMain.Results = _GameData.Results;
|
||||
screen.DataToScreen(_ToScreenMain);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Screen;
|
||||
return screen;
|
||||
}
|
||||
|
||||
public override EScreens GetStartScreen()
|
||||
@@ -343,7 +343,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
return EScreens.ScreenPartyDummy;
|
||||
}
|
||||
|
||||
public override ScreenSongOptions GetScreenSongOptions()
|
||||
public override SScreenSongOptions GetScreenSongOptions()
|
||||
{
|
||||
_ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting();
|
||||
_ScreenSongOptions.Sorting.Tabs = CBase.Config.GetTabs();
|
||||
@@ -352,112 +352,112 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
return _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void OnSongChange(int SongIndex, ref ScreenSongOptions ScreenSongOptions)
|
||||
public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
|
||||
{
|
||||
if (_ScreenSongOptions.Selection.SongIndex != -1)
|
||||
_ScreenSongOptions.Selection.SongIndex = -1;
|
||||
|
||||
if (_ScreenSongOptions.Selection.SelectNextRandomSong && SongIndex != -1)
|
||||
if (_ScreenSongOptions.Selection.SelectNextRandomSong && songIndex != -1)
|
||||
{
|
||||
_ScreenSongOptions.Selection.SelectNextRandomSong = false;
|
||||
CreateCatSongIndices();
|
||||
_CreateCatSongIndices();
|
||||
|
||||
if (GameData.CatSongIndices != null)
|
||||
if (_GameData.CatSongIndices != null)
|
||||
{
|
||||
if (GameData.CatSongIndices[CBase.Songs.GetCurrentCategoryIndex()] == -1)
|
||||
GameData.CatSongIndices[CBase.Songs.GetCurrentCategoryIndex()] = SongIndex;
|
||||
if (_GameData.CatSongIndices[CBase.Songs.GetCurrentCategoryIndex()] == -1)
|
||||
_GameData.CatSongIndices[CBase.Songs.GetCurrentCategoryIndex()] = songIndex;
|
||||
}
|
||||
}
|
||||
|
||||
ScreenSongOptions = _ScreenSongOptions;
|
||||
screenSongOptions = _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void OnCategoryChange(int CategoryIndex, ref ScreenSongOptions ScreenSongOptions)
|
||||
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
|
||||
{
|
||||
if (GameData.CatSongIndices != null && CategoryIndex != -1)
|
||||
if (_GameData.CatSongIndices != null && categoryIndex != -1)
|
||||
{
|
||||
if (GameData.CatSongIndices[CategoryIndex] == -1)
|
||||
if (_GameData.CatSongIndices[categoryIndex] == -1)
|
||||
_ScreenSongOptions.Selection.SelectNextRandomSong = true;
|
||||
else
|
||||
_ScreenSongOptions.Selection.SongIndex = GameData.CatSongIndices[CategoryIndex];
|
||||
_ScreenSongOptions.Selection.SongIndex = _GameData.CatSongIndices[categoryIndex];
|
||||
}
|
||||
|
||||
if (GameData.CatSongIndices == null && CategoryIndex != -1)
|
||||
if (_GameData.CatSongIndices == null && categoryIndex != -1)
|
||||
_ScreenSongOptions.Selection.SelectNextRandomSong = true;
|
||||
|
||||
if (CategoryIndex == -1)
|
||||
if (categoryIndex == -1)
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;
|
||||
|
||||
if (_ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF || CategoryIndex != -1)
|
||||
if (_ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF || categoryIndex != -1)
|
||||
_ScreenSongOptions.Selection.RandomOnly = true;
|
||||
|
||||
ScreenSongOptions = _ScreenSongOptions;
|
||||
screenSongOptions = _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void SetSearchString(string SearchString, bool Visible)
|
||||
public override void SetSearchString(string searchString, bool visible)
|
||||
{
|
||||
_ScreenSongOptions.Sorting.SearchString = SearchString;
|
||||
_ScreenSongOptions.Sorting.SearchActive = Visible;
|
||||
_ScreenSongOptions.Sorting.SearchString = searchString;
|
||||
_ScreenSongOptions.Sorting.SearchActive = visible;
|
||||
}
|
||||
|
||||
public override int GetMaxPlayer()
|
||||
{
|
||||
return MaxPlayer;
|
||||
return _MaxPlayer;
|
||||
}
|
||||
|
||||
public override int GetMinPlayer()
|
||||
{
|
||||
return MinPlayer;
|
||||
return _MinPlayer;
|
||||
}
|
||||
|
||||
public override int GetMaxTeams()
|
||||
{
|
||||
return MaxTeams;
|
||||
return _MaxTeams;
|
||||
}
|
||||
|
||||
public override int GetMinTeams()
|
||||
{
|
||||
return MinTeams;
|
||||
return _MinTeams;
|
||||
}
|
||||
|
||||
public override int GetMaxNumRounds()
|
||||
{
|
||||
return MaxNumRounds;
|
||||
return _MaxNumRounds;
|
||||
}
|
||||
|
||||
public override void JokerUsed(int TeamNr)
|
||||
public override void JokerUsed(int teamNr)
|
||||
{
|
||||
if (_ScreenSongOptions.Selection.NumJokers == null)
|
||||
return;
|
||||
|
||||
if (TeamNr >= _ScreenSongOptions.Selection.NumJokers.Length)
|
||||
if (teamNr >= _ScreenSongOptions.Selection.NumJokers.Length)
|
||||
return;
|
||||
|
||||
_ScreenSongOptions.Selection.NumJokers[TeamNr]--;
|
||||
_ScreenSongOptions.Selection.NumJokers[teamNr]--;
|
||||
_ScreenSongOptions.Selection.RandomOnly = true;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
|
||||
}
|
||||
|
||||
public override void SongSelected(int SongID)
|
||||
public override void SongSelected(int songID)
|
||||
{
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
CBase.Game.Reset();
|
||||
CBase.Game.ClearSongs();
|
||||
CBase.Game.AddSong(SongID, gm);
|
||||
CBase.Game.SetNumPlayer(GameData.NumPlayerAtOnce);
|
||||
CBase.Game.AddSong(songID, gm);
|
||||
CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce);
|
||||
|
||||
SPlayer[] player = CBase.Game.GetPlayer();
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (player.Length < GameData.NumPlayerAtOnce)
|
||||
if (player.Length < _GameData.NumPlayerAtOnce)
|
||||
return;
|
||||
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
Combination c = GameData.Rounds.GetRound(GameData.CurrentRoundNr - 1);
|
||||
CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1);
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//default values
|
||||
player[i].Name = "foobar";
|
||||
@@ -467,38 +467,38 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
//try to fill with the right data
|
||||
if (c != null)
|
||||
{
|
||||
if (GameData.ProfileIDs[c.Player[i]] < profiles.Length)
|
||||
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].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]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CBase.Songs.AddPartySongSung(SongID);
|
||||
CBase.Songs.AddPartySongSung(songID);
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenSing);
|
||||
}
|
||||
|
||||
public override void LeavingHighscore()
|
||||
{
|
||||
GameData.CurrentRoundNr++;
|
||||
_GameData.CurrentRoundNr++;
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
|
||||
private void StartNextRound()
|
||||
private void _StartNextRound()
|
||||
{
|
||||
_ScreenSongOptions.Selection.RandomOnly = _ScreenSongOptions.Sorting.Tabs != EOffOn.TR_CONFIG_ON;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON;
|
||||
SetNumJokers();
|
||||
SetTeamNames();
|
||||
GameData.CatSongIndices = null;
|
||||
_SetNumJokers();
|
||||
_SetTeamNames();
|
||||
_GameData.CatSongIndices = null;
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenSong);
|
||||
}
|
||||
|
||||
private void SetNumJokers()
|
||||
private void _SetNumJokers()
|
||||
{
|
||||
switch (GameData.NumPlayerAtOnce)
|
||||
switch (_GameData.NumPlayerAtOnce)
|
||||
{
|
||||
case 1:
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] {10};
|
||||
@@ -529,7 +529,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTeamNames()
|
||||
private void _SetTeamNames()
|
||||
{
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
@@ -539,21 +539,21 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameData.NumPlayerAtOnce < 1 || GameData.ProfileIDs.Count < GameData.NumPlayerAtOnce || profiles.Length < GameData.NumPlayerAtOnce)
|
||||
if (_GameData.NumPlayerAtOnce < 1 || _GameData.ProfileIDs.Count < _GameData.NumPlayerAtOnce || profiles.Length < _GameData.NumPlayerAtOnce)
|
||||
{
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"};
|
||||
return;
|
||||
}
|
||||
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[GameData.NumPlayerAtOnce];
|
||||
Combination c = GameData.Rounds.GetRound(GameData.CurrentRoundNr - 1);
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[_GameData.NumPlayerAtOnce];
|
||||
CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1);
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
if (c != null)
|
||||
{
|
||||
if (GameData.ProfileIDs[c.Player[i]] < profiles.Length)
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = profiles[GameData.ProfileIDs[c.Player[i]]].PlayerName;
|
||||
if (_GameData.ProfileIDs[c.Player[i]] < profiles.Length)
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = profiles[_GameData.ProfileIDs[c.Player[i]]].PlayerName;
|
||||
else
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = "foobar";
|
||||
}
|
||||
@@ -562,27 +562,27 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateScores()
|
||||
private void _UpdateScores()
|
||||
{
|
||||
if (GameData.ResultTable.Count == 0)
|
||||
if (_GameData.ResultTable.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < GameData.NumPlayer; i++)
|
||||
for (int i = 0; i < _GameData.NumPlayer; i++)
|
||||
{
|
||||
ResultTableRow row = new ResultTableRow();
|
||||
row.PlayerID = GameData.ProfileIDs[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;
|
||||
GameData.ResultTable.Add(row);
|
||||
_GameData.ResultTable.Add(row);
|
||||
}
|
||||
|
||||
GameData.Results = new int[GameData.NumRounds,GameData.NumPlayerAtOnce];
|
||||
for (int i = 0; i < GameData.NumRounds; i++)
|
||||
_GameData.Results = new int[_GameData.NumRounds,_GameData.NumPlayerAtOnce];
|
||||
for (int i = 0; i < _GameData.NumRounds; i++)
|
||||
{
|
||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
||||
GameData.Results[i, j] = 0;
|
||||
for (int j = 0; j < _GameData.NumPlayerAtOnce; j++)
|
||||
_GameData.Results[i, j] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -591,20 +591,20 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
if (results == null)
|
||||
return;
|
||||
|
||||
if (results.Length < GameData.NumPlayerAtOnce)
|
||||
if (results.Length < _GameData.NumPlayerAtOnce)
|
||||
return;
|
||||
|
||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
||||
GameData.Results[GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points);
|
||||
for (int j = 0; j < _GameData.NumPlayerAtOnce; j++)
|
||||
_GameData.Results[_GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points);
|
||||
|
||||
List<Stats> points = GetPointsForPlayer(results);
|
||||
List<SStats> points = _GetPointsForPlayer(results);
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
int index = -1;
|
||||
for (int j = 0; j < GameData.ResultTable.Count; j++)
|
||||
for (int j = 0; j < _GameData.ResultTable.Count; j++)
|
||||
{
|
||||
if (points[i].ProfileID == GameData.ResultTable[j].PlayerID)
|
||||
if (points[i].ProfileID == _GameData.ResultTable[j].PlayerID)
|
||||
{
|
||||
index = j;
|
||||
break;
|
||||
@@ -613,7 +613,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
ResultTableRow row = GameData.ResultTable[index];
|
||||
CResultTableRow row = _GameData.ResultTable[index];
|
||||
|
||||
row.NumPlayed++;
|
||||
row.NumWon += points[i].Won;
|
||||
@@ -621,41 +621,41 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
row.NumSingPoints += points[i].SingPoints;
|
||||
row.NumGamePoints += points[i].GamePoints;
|
||||
|
||||
GameData.ResultTable[index] = row;
|
||||
_GameData.ResultTable[index] = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameData.ResultTable.Sort();
|
||||
_GameData.ResultTable.Sort();
|
||||
|
||||
//Update position-number
|
||||
int pos = 1;
|
||||
int lastPoints = 0;
|
||||
int lastSingPoints = 0;
|
||||
for (int i = 0; i < GameData.ResultTable.Count; i++)
|
||||
for (int i = 0; i < _GameData.ResultTable.Count; i++)
|
||||
{
|
||||
if (lastPoints > GameData.ResultTable[i].NumGamePoints || lastSingPoints > GameData.ResultTable[i].NumSingPoints)
|
||||
if (lastPoints > _GameData.ResultTable[i].NumGamePoints || lastSingPoints > _GameData.ResultTable[i].NumSingPoints)
|
||||
pos++;
|
||||
GameData.ResultTable[i].Position = pos;
|
||||
lastPoints = GameData.ResultTable[i].NumGamePoints;
|
||||
lastSingPoints = GameData.ResultTable[i].NumSingPoints;
|
||||
_GameData.ResultTable[i].Position = pos;
|
||||
lastPoints = _GameData.ResultTable[i].NumGamePoints;
|
||||
lastSingPoints = _GameData.ResultTable[i].NumSingPoints;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Stats> GetPointsForPlayer(SPlayer[] Results)
|
||||
private List<SStats> _GetPointsForPlayer(SPlayer[] results)
|
||||
{
|
||||
List<Stats> result = new List<Stats>();
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
List<SStats> result = new List<SStats>();
|
||||
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
Stats stat = new Stats();
|
||||
stat.ProfileID = Results[i].ProfileID;
|
||||
stat.SingPoints = (int)Math.Round(Results[i].Points);
|
||||
SStats stat = new SStats();
|
||||
stat.ProfileID = results[i].ProfileID;
|
||||
stat.SingPoints = (int)Math.Round(results[i].Points);
|
||||
stat.Won = 0;
|
||||
stat.GamePoints = 0;
|
||||
result.Add(stat);
|
||||
}
|
||||
|
||||
result.Sort(delegate(Stats s1, Stats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); });
|
||||
result.Sort(delegate(SStats s1, SStats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); });
|
||||
|
||||
int current = result[result.Count - 1].SingPoints;
|
||||
int points = result.Count;
|
||||
@@ -663,7 +663,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
for (int i = result.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Stats res = result[i];
|
||||
SStats res = result[i];
|
||||
|
||||
if (i < result.Count - 1)
|
||||
{
|
||||
@@ -695,17 +695,17 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
return result;
|
||||
}
|
||||
|
||||
private void CreateCatSongIndices()
|
||||
private void _CreateCatSongIndices()
|
||||
{
|
||||
if (GameData.CatSongIndices == null && CBase.Songs.GetNumCategories() > 0 && _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON)
|
||||
if (_GameData.CatSongIndices == null && CBase.Songs.GetNumCategories() > 0 && _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
GameData.CatSongIndices = new int[CBase.Songs.GetNumCategories()];
|
||||
for (int i = 0; i < GameData.CatSongIndices.Length; i++)
|
||||
GameData.CatSongIndices[i] = -1;
|
||||
_GameData.CatSongIndices = new int[CBase.Songs.GetNumCategories()];
|
||||
for (int i = 0; i < _GameData.CatSongIndices.Length; i++)
|
||||
_GameData.CatSongIndices[i] = -1;
|
||||
}
|
||||
|
||||
if (CBase.Songs.GetNumCategories() == 0 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF)
|
||||
GameData.CatSongIndices = null;
|
||||
_GameData.CatSongIndices = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
public class CPartyScreenChallengeConfig : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string _SelectSlideNumPlayers = "SelectSlideNumPlayers";
|
||||
private const string _SelectSlideNumMics = "SelectSlideNumMics";
|
||||
private const string _SelectSlideNumRounds = "SelectSlideNumRounds";
|
||||
private const string _ButtonNext = "ButtonNext";
|
||||
private const string _ButtonBack = "ButtonBack";
|
||||
|
||||
private int _MaxNumMics = 2;
|
||||
private int _MaxNumRounds = 100;
|
||||
private int _RoundSteps = 1;
|
||||
|
||||
private SDataFromScreen _Data;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeSelectSlides = new string[] {_SelectSlideNumPlayers, _SelectSlideNumMics, _SelectSlideNumRounds};
|
||||
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
|
||||
|
||||
_Data = new SDataFromScreen();
|
||||
SFromScreenConfig config = new SFromScreenConfig();
|
||||
config.NumPlayer = 4;
|
||||
config.NumPlayerAtOnce = 2;
|
||||
config.NumRounds = 12;
|
||||
_Data.ScreenConfig = config;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object receivedData)
|
||||
{
|
||||
SDataToScreenConfig config = new SDataToScreenConfig();
|
||||
|
||||
try
|
||||
{
|
||||
config = (SDataToScreenConfig)receivedData;
|
||||
_Data.ScreenConfig.NumPlayer = config.NumPlayer;
|
||||
_Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce;
|
||||
_Data.ScreenConfig.NumRounds = config.NumRounds;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge config. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
_Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
_UpdateSlides();
|
||||
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
_UpdateSlides();
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
_UpdateSlides();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
_UpdateSlides();
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
_Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
_MaxNumMics = CBase.Config.GetMaxNumMics();
|
||||
if (_MaxNumMics > 6)
|
||||
_MaxNumMics = 6;
|
||||
|
||||
_MaxNumRounds = _PartyMode.GetMaxNumRounds();
|
||||
|
||||
_RebuildSlides();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _RebuildSlides()
|
||||
{
|
||||
// build num player slide (min player ... max player);
|
||||
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();
|
||||
|
||||
_UpdateMicsAtOnce();
|
||||
_SetRoundSteps();
|
||||
_UpdateSlideRounds();
|
||||
}
|
||||
|
||||
private void _UpdateSlides()
|
||||
{
|
||||
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;
|
||||
|
||||
_UpdateMicsAtOnce();
|
||||
_SetRoundSteps();
|
||||
|
||||
if (player != _Data.ScreenConfig.NumPlayer || mics != _Data.ScreenConfig.NumPlayerAtOnce)
|
||||
{
|
||||
int num = CHelper.CombinationCount(_Data.ScreenConfig.NumPlayer, _Data.ScreenConfig.NumPlayerAtOnce);
|
||||
while (num > _MaxNumRounds)
|
||||
num -= _RoundSteps;
|
||||
_Data.ScreenConfig.NumRounds = num;
|
||||
}
|
||||
|
||||
_UpdateSlideRounds();
|
||||
}
|
||||
|
||||
private void _UpdateMicsAtOnce()
|
||||
{
|
||||
//Data.ScreenConfig.NumPlayerAtOnce
|
||||
int maxNum = _MaxNumMics;
|
||||
if (_Data.ScreenConfig.NumPlayer < _MaxNumMics)
|
||||
maxNum = _Data.ScreenConfig.NumPlayer;
|
||||
|
||||
if (_Data.ScreenConfig.NumPlayerAtOnce > maxNum)
|
||||
_Data.ScreenConfig.NumPlayerAtOnce = maxNum;
|
||||
|
||||
// build mics at once slide
|
||||
SelectSlides[_SelectSlideNumMics].Clear();
|
||||
for (int i = 1; i <= maxNum; i++)
|
||||
SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
|
||||
SelectSlides[_SelectSlideNumMics].Selection = _Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
|
||||
}
|
||||
|
||||
private void _UpdateSlideRounds()
|
||||
{
|
||||
// build num rounds slide
|
||||
SelectSlides[_SelectSlideNumRounds].Clear();
|
||||
for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
|
||||
SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString());
|
||||
SelectSlides[_SelectSlideNumRounds].Selection = _Data.ScreenConfig.NumRounds / _RoundSteps - 1;
|
||||
}
|
||||
|
||||
private void _SetRoundSteps()
|
||||
{
|
||||
if (_Data.ScreenConfig.NumPlayerAtOnce < 1 || _Data.ScreenConfig.NumPlayer < 1 || _Data.ScreenConfig.NumPlayerAtOnce > _Data.ScreenConfig.NumPlayer)
|
||||
{
|
||||
_RoundSteps = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private void _Back()
|
||||
{
|
||||
_FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void _Next()
|
||||
{
|
||||
_PartyMode.DataFromScreen(ThemeName, _Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,660 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
struct STableRow
|
||||
{
|
||||
public CText Pos;
|
||||
public CText Name;
|
||||
public CText Rounds;
|
||||
public CText Won;
|
||||
public CText SingPoints;
|
||||
public CText GamePoints;
|
||||
}
|
||||
|
||||
class CRoundsTableRow
|
||||
{
|
||||
public CText Number;
|
||||
public List<CText> TextPlayer;
|
||||
public List<CText> TextScores;
|
||||
}
|
||||
|
||||
public class CPartyScreenChallengeMain : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string _TextPosition = "TextPosition";
|
||||
private const string _TextPlayerName = "TextPlayerName";
|
||||
private const string _TextNumPlayed = "TextNumPlayed";
|
||||
private const string _TextWon = "TextWon";
|
||||
private const string _TextSingPoints = "TextSingPoints";
|
||||
private const string _TextGamePoints = "TextGamePoints";
|
||||
private const string _TextNextPlayer = "TextNextPlayer";
|
||||
private const string _TextPopupReallyExit = "TextPopupReallyExit";
|
||||
private const string _TextRoundPlayer = "TextRoundPlayer";
|
||||
private const string _TextRoundScore = "TextRoundScore";
|
||||
private const string _TextRoundNumber = "TextRoundNumber";
|
||||
private const string _TextFinishMessage = "TextFinishMessage";
|
||||
private const string _TextFinishPlayerWin = "TextFinishPlayerWin";
|
||||
private const string _TextNextPlayerMessage = "TextNextPlayerMessage";
|
||||
|
||||
private const string _ButtonNextRound = "ButtonNextRound";
|
||||
private const string _ButtonBack = "ButtonBack";
|
||||
private const string _ButtonExit = "ButtonExit";
|
||||
private const string _ButtonPopupYes = "ButtonPopupYes";
|
||||
private const string _ButtonPopupNo = "ButtonPopupNo";
|
||||
private const string _ButtonPlayerScrollUp = "ButtonPlayerScrollUp";
|
||||
private const string _ButtonPlayerScrollDown = "ButtonPlayerScrollDown";
|
||||
private const string _ButtonRoundsScrollUp = "ButtonRoundsScrollUp";
|
||||
private const string _ButtonRoundsScrollDown = "ButtonRoundsScrollDown";
|
||||
|
||||
private const string _StaticPopupBG = "StaticPopupBG";
|
||||
private const string _StaticNextPlayer = "StaticNextPlayer";
|
||||
|
||||
private bool _ExitPopupVisible;
|
||||
|
||||
private SDataFromScreen _Data;
|
||||
private SDataToScreenMain _GameState;
|
||||
private List<STableRow> _PlayerTable;
|
||||
private List<CRoundsTableRow> _RoundsTable;
|
||||
|
||||
private List<CText> _NextPlayerTexts;
|
||||
private List<CStatic> _NextPlayerStatics;
|
||||
|
||||
private SRectF _RoundsTableScrollArea;
|
||||
private SRectF _PlayerTableScrollArea;
|
||||
private int _RoundsTableOffset;
|
||||
private int _PlayerTableOffset;
|
||||
private int _NumPlayerVisible = 10;
|
||||
private int _NumRoundsVisible = 3;
|
||||
|
||||
public CPartyScreenChallengeMain()
|
||||
{
|
||||
_Data = new SDataFromScreen();
|
||||
_Data.ScreenMain = new SFromScreenMain();
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeTexts = new string[]
|
||||
{
|
||||
_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};
|
||||
_ThemeStatics = new string[] {_StaticPopupBG, _StaticNextPlayer};
|
||||
}
|
||||
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
base.LoadTheme(xmlPath);
|
||||
|
||||
_GameState = new SDataToScreenMain();
|
||||
_BuildPlayerTable();
|
||||
_CreateRoundsTable();
|
||||
_NextPlayerTexts = new List<CText>();
|
||||
_NextPlayerStatics = new List<CStatic>();
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DataToScreen(object receivedData)
|
||||
{
|
||||
SDataToScreenMain data = new SDataToScreenMain();
|
||||
|
||||
try
|
||||
{
|
||||
data = (SDataToScreenMain)receivedData;
|
||||
_GameState = data;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge main. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_GameState.CurrentRoundNr == 1)
|
||||
_Back();
|
||||
else
|
||||
_ShowPopup(true);
|
||||
}
|
||||
else
|
||||
_ShowPopup(false);
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[_ButtonNextRound].Selected)
|
||||
_NextRound();
|
||||
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
|
||||
_Back();
|
||||
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
|
||||
_ShowPopup(true);
|
||||
if (Buttons[_ButtonPlayerScrollUp].Selected)
|
||||
_ScrollPlayerTable(-1);
|
||||
if (Buttons[_ButtonPlayerScrollDown].Selected)
|
||||
_ScrollPlayerTable(1);
|
||||
if (Buttons[_ButtonRoundsScrollUp].Selected)
|
||||
_ScrollRoundsTable(-1);
|
||||
if (Buttons[_ButtonRoundsScrollDown].Selected)
|
||||
_ScrollRoundsTable(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[_ButtonPopupYes].Selected)
|
||||
_EndParty();
|
||||
if (Buttons[_ButtonPopupNo].Selected)
|
||||
_ShowPopup(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[_ButtonNextRound].Selected)
|
||||
_NextRound();
|
||||
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
|
||||
_Back();
|
||||
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
|
||||
_ShowPopup(true);
|
||||
if (Buttons[_ButtonPlayerScrollUp].Selected)
|
||||
_ScrollPlayerTable(-1);
|
||||
if (Buttons[_ButtonPlayerScrollDown].Selected)
|
||||
_ScrollPlayerTable(1);
|
||||
if (Buttons[_ButtonRoundsScrollUp].Selected)
|
||||
_ScrollRoundsTable(-1);
|
||||
if (Buttons[_ButtonRoundsScrollDown].Selected)
|
||||
_ScrollRoundsTable(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[_ButtonPopupYes].Selected)
|
||||
_EndParty();
|
||||
if (Buttons[_ButtonPopupNo].Selected)
|
||||
_ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
{
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_GameState.CurrentRoundNr == 1)
|
||||
_Back();
|
||||
else
|
||||
_ShowPopup(true);
|
||||
}
|
||||
else
|
||||
_ShowPopup(false);
|
||||
}
|
||||
|
||||
if (mouseEvent.Wheel != 0)
|
||||
{
|
||||
if (CHelper.IsInBounds(_RoundsTableScrollArea, mouseEvent))
|
||||
_ScrollRoundsTable(mouseEvent.Wheel);
|
||||
if (CHelper.IsInBounds(_PlayerTableScrollArea, mouseEvent))
|
||||
_ScrollPlayerTable(mouseEvent.Wheel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
_PlayerTableOffset = 0;
|
||||
_RoundsTableOffset = 0;
|
||||
|
||||
_UpdatePlayerTable();
|
||||
_UpdateNextPlayerPositions();
|
||||
_UpdateNextPlayerContents();
|
||||
if (_GameState.CurrentRoundNr == 1)
|
||||
_BuildRoundsTable();
|
||||
else
|
||||
_ScrollRoundsTable(_GameState.CurrentRoundNr - 2);
|
||||
_UpdateRoundsTable();
|
||||
|
||||
if (_GameState.CurrentRoundNr == 1)
|
||||
{
|
||||
Buttons[_ButtonBack].Visible = true;
|
||||
Buttons[_ButtonExit].Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
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]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[_ButtonNextRound].Visible = false;
|
||||
Texts[_TextFinishMessage].Visible = true;
|
||||
Texts[_TextFinishPlayerWin].Visible = true;
|
||||
Texts[_TextFinishPlayerWin].Text = _GetPlayerWinString();
|
||||
SetInteractionToButton(Buttons[_ButtonExit]);
|
||||
}
|
||||
|
||||
_ShowPopup(false);
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _NextRound()
|
||||
{
|
||||
_Data.ScreenMain.FadeToNameSelection = false;
|
||||
_Data.ScreenMain.FadeToSongSelection = true;
|
||||
_PartyMode.DataFromScreen(ThemeName, _Data);
|
||||
}
|
||||
|
||||
private void _EndParty()
|
||||
{
|
||||
_FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void _ShowPopup(bool visible)
|
||||
{
|
||||
_ExitPopupVisible = visible;
|
||||
|
||||
Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
|
||||
Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
|
||||
Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
|
||||
Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
|
||||
|
||||
if (_ExitPopupVisible)
|
||||
SetInteractionToButton(Buttons[_ButtonPopupNo]);
|
||||
}
|
||||
|
||||
private void _Back()
|
||||
{
|
||||
_Data.ScreenMain.FadeToNameSelection = true;
|
||||
_Data.ScreenMain.FadeToSongSelection = false;
|
||||
_PartyMode.DataFromScreen(ThemeName, _Data);
|
||||
}
|
||||
|
||||
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;
|
||||
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//static
|
||||
_NextPlayerStatics[i].Rect.X = x;
|
||||
_NextPlayerStatics[i].Rect.Y = staticY;
|
||||
_NextPlayerStatics[i].Visible = true;
|
||||
//text
|
||||
_NextPlayerTexts[i].X = x + Statics[_StaticNextPlayer].Rect.W / 2;
|
||||
_NextPlayerTexts[i].Y = textY;
|
||||
_NextPlayerTexts[i].Visible = true;
|
||||
|
||||
x += Statics[_StaticNextPlayer].Rect.W + 15;
|
||||
}
|
||||
for (int i = _GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
|
||||
{
|
||||
_NextPlayerStatics[i].Visible = false;
|
||||
_NextPlayerTexts[i].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateNextPlayerContents()
|
||||
{
|
||||
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
|
||||
{
|
||||
Texts[_TextNextPlayerMessage].Visible = true;
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
int pid = _GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i];
|
||||
_NextPlayerStatics[i].Texture = profiles[_GameState.ProfileIDs[pid]].Avatar.Texture;
|
||||
_NextPlayerTexts[i].Text = profiles[_GameState.ProfileIDs[pid]].PlayerName;
|
||||
_NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Texts[_TextNextPlayerMessage].Visible = false;
|
||||
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
_NextPlayerStatics[i].Visible = false;
|
||||
_NextPlayerTexts[i].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _CreateRoundsTable()
|
||||
{
|
||||
//Create lists
|
||||
_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>();
|
||||
_RoundsTable.Add(rtr);
|
||||
}
|
||||
//Create statics and texts for rounds
|
||||
for (int round = 0; round < _RoundsTable.Count; round++)
|
||||
{
|
||||
//Round-number
|
||||
CText text = GetNewText(Texts[_TextRoundNumber]);
|
||||
AddText(text);
|
||||
_RoundsTable[round].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);
|
||||
//Score
|
||||
text = GetNewText(Texts[_TextRoundScore]);
|
||||
AddText(text);
|
||||
_RoundsTable[round].TextScores.Add(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _BuildRoundsTable()
|
||||
{
|
||||
_RoundsTableScrollArea = new SRectF();
|
||||
|
||||
int numPlayerInOneRow = 3;
|
||||
if (_GameState.NumPlayerAtOnce <= numPlayerInOneRow)
|
||||
_NumRoundsVisible = 5;
|
||||
else
|
||||
_NumRoundsVisible = 3;
|
||||
|
||||
if (_NumRoundsVisible > _GameState.Combs.Count)
|
||||
_NumRoundsVisible = _GameState.Combs.Count;
|
||||
|
||||
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;
|
||||
|
||||
float delta = Texts[_TextRoundNumber].Height;
|
||||
|
||||
//Update statics and texts for rounds
|
||||
for (int round = 0; round < _RoundsTable.Count; round++)
|
||||
{
|
||||
//Round-number
|
||||
_RoundsTable[round].Number.X = numberX;
|
||||
_RoundsTable[round].Number.Y = numberY;
|
||||
int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow));
|
||||
for (int row = 0; row < numInnerRows; row++)
|
||||
{
|
||||
int num = (row + 1) * numPlayerInOneRow;
|
||||
int numPlayerInThisRow = numPlayerInOneRow;
|
||||
if (num > _GameState.NumPlayerAtOnce)
|
||||
{
|
||||
num = _GameState.NumPlayerAtOnce;
|
||||
numPlayerInThisRow = _GameState.NumPlayerAtOnce - (row * numPlayerInOneRow);
|
||||
}
|
||||
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;
|
||||
//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;
|
||||
}
|
||||
numberY = numberY + delta + delta;
|
||||
}
|
||||
numberY = numberY + delta / 2;
|
||||
}
|
||||
_RoundsTableScrollArea.H = numberY - _RoundsTableScrollArea.Y;
|
||||
}
|
||||
|
||||
private void _UpdateRoundsTable()
|
||||
{
|
||||
SProfile[] profile = CBase.Profiles.GetProfiles();
|
||||
for (int i = 0; i < _RoundsTable.Count; i++)
|
||||
{
|
||||
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
if (_GameState.Combs.Count > i + _RoundsTableOffset && _GameState.Combs[i + _RoundsTableOffset].Player.Count > p)
|
||||
{
|
||||
_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() + ")";
|
||||
int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]];
|
||||
_RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
|
||||
if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset)
|
||||
_RoundsTable[i].TextScores[p].Text = _GameState.Results[i + _RoundsTableOffset, p].ToString();
|
||||
else
|
||||
_RoundsTable[i].TextScores[p].Text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
_RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
if (_GameState.Combs.Count < i + _RoundsTableOffset || i + 1 > _NumRoundsVisible)
|
||||
{
|
||||
_RoundsTable[i].Number.Visible = false;
|
||||
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
_RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
_RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
_PlayerTable = new List<STableRow>();
|
||||
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]);
|
||||
|
||||
row.Pos.Y += delta * (i + 1);
|
||||
row.Name.Y += delta * (i + 1);
|
||||
row.Rounds.Y += delta * (i + 1);
|
||||
row.Won.Y += delta * (i + 1);
|
||||
row.SingPoints.Y += delta * (i + 1);
|
||||
row.GamePoints.Y += delta * (i + 1);
|
||||
|
||||
row.Pos.Text = (i + 1).ToString() + ".";
|
||||
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
row.Rounds.Visible = false;
|
||||
row.Won.Visible = false;
|
||||
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);
|
||||
|
||||
_PlayerTable.Add(row);
|
||||
|
||||
h = delta * (i + 1);
|
||||
}
|
||||
_PlayerTableScrollArea.H = h + delta;
|
||||
}
|
||||
|
||||
private void _UpdatePlayerTable()
|
||||
{
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < _PlayerTable.Count; i++)
|
||||
{
|
||||
STableRow row = _PlayerTable[i];
|
||||
|
||||
if (i + _PlayerTableOffset < _GameState.ResultTable.Count)
|
||||
{
|
||||
row.Pos.Visible = true;
|
||||
row.Name.Visible = true;
|
||||
row.Rounds.Visible = true;
|
||||
row.Won.Visible = true;
|
||||
row.SingPoints.Visible = true;
|
||||
row.GamePoints.Visible = true;
|
||||
|
||||
row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position.ToString() + ".";
|
||||
row.Name.Text = profiles[_GameState.ResultTable[i + _PlayerTableOffset].PlayerID].PlayerName;
|
||||
row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumRounds.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();
|
||||
}
|
||||
else
|
||||
{
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
row.Rounds.Visible = false;
|
||||
row.Won.Visible = false;
|
||||
row.SingPoints.Visible = false;
|
||||
row.GamePoints.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0;
|
||||
Buttons[_ButtonPlayerScrollDown].Visible = _GameState.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0;
|
||||
}
|
||||
|
||||
private void _ScrollPlayerTable(int offset)
|
||||
{
|
||||
if (_GameState.ProfileIDs.Count <= _NumPlayerVisible)
|
||||
_PlayerTableOffset = 0;
|
||||
else if (offset < 0 && _PlayerTableOffset + offset >= 0)
|
||||
_PlayerTableOffset += offset;
|
||||
else if (offset < 0 && _PlayerTableOffset + offset < 0)
|
||||
_PlayerTableOffset = 0;
|
||||
else if (offset > 0 && _PlayerTableOffset + offset <= _GameState.ProfileIDs.Count - _NumPlayerVisible)
|
||||
_PlayerTableOffset += offset;
|
||||
else if (offset > 0 && _PlayerTableOffset + offset > _GameState.ProfileIDs.Count - _NumPlayerVisible)
|
||||
_PlayerTableOffset = _GameState.ProfileIDs.Count - _NumPlayerVisible;
|
||||
|
||||
_UpdatePlayerTable();
|
||||
}
|
||||
|
||||
private void _ScrollRoundsTable(int offset)
|
||||
{
|
||||
if (_GameState.Combs.Count <= _NumRoundsVisible)
|
||||
_RoundsTableOffset = 0;
|
||||
else if (offset < 0 && _RoundsTableOffset + offset >= 0)
|
||||
_RoundsTableOffset += offset;
|
||||
else if (offset < 0 && _RoundsTableOffset + offset < 0)
|
||||
_RoundsTableOffset = 0;
|
||||
else if (offset > 0 && _RoundsTableOffset + offset <= _GameState.Combs.Count - _NumRoundsVisible)
|
||||
_RoundsTableOffset += offset;
|
||||
else if (offset > 0 && _RoundsTableOffset + offset > _GameState.Combs.Count - _NumRoundsVisible)
|
||||
_RoundsTableOffset = _GameState.Combs.Count - _NumRoundsVisible;
|
||||
|
||||
_UpdateRoundsTable();
|
||||
}
|
||||
|
||||
private string _GetPlayerWinString()
|
||||
{
|
||||
string s = "";
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < _GameState.ResultTable.Count; i++)
|
||||
{
|
||||
if (_GameState.ResultTable[i].Position == 1)
|
||||
{
|
||||
if (i > 0)
|
||||
s += ", ";
|
||||
s += profiles[_GameState.ResultTable[i].PlayerID].PlayerName;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,504 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
public class CPartyScreenChallengeNames : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string _ButtonNext = "ButtonNext";
|
||||
private const string _ButtonBack = "ButtonBack";
|
||||
private const string _ButtonPlayerDestination = "ButtonPlayerDestination";
|
||||
private const string _ButtonPlayerChoose = "ButtonPlayerChoose";
|
||||
|
||||
private List<CPlayerChooseButton> _PlayerChooseButtons;
|
||||
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;
|
||||
private const int _PlayerDestinationButtonsSpaceW = 25;
|
||||
//PlayerChooseButtons-Option
|
||||
private List<int> _PlayerChooseButtonsVisibleProfiles;
|
||||
private const int _PlayerChooseButtonsNumH = 7;
|
||||
private const int _PlayerChooseButtonsNumW = 4;
|
||||
private const int _PlayerChooseButtonsFirstX = 52;
|
||||
private const int _PlayerChooseButtonsFirstY = 105;
|
||||
private const int _PlayerChooseButtonsSpaceH = 15;
|
||||
private const int _PlayerChooseButtonsSpaceW = 25;
|
||||
private int _PlayerChooseButtonsOffset = 0;
|
||||
|
||||
private CStatic _ChooseAvatarStatic;
|
||||
private bool _SelectingMouseActive;
|
||||
private int _OldMouseX;
|
||||
private int _OldMouseY;
|
||||
private int _SelectedPlayerNr = -1;
|
||||
private bool _ButtonsAdded;
|
||||
|
||||
private int _NumPlayer = 4;
|
||||
|
||||
private SDataFromScreen _Data;
|
||||
|
||||
private class CPlayerChooseButton
|
||||
{
|
||||
public CButton Button;
|
||||
public int ProfileID;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ChooseAvatarStatic = GetNewStatic();
|
||||
_ChooseAvatarStatic.Visible = false;
|
||||
|
||||
_PlayerChooseButtonsVisibleProfiles = new List<int>();
|
||||
|
||||
_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>();
|
||||
_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>();
|
||||
|
||||
_NumPlayer = config.NumPlayer;
|
||||
|
||||
while (_Data.ScreenNames.ProfileIDs.Count > _NumPlayer)
|
||||
_Data.ScreenNames.ProfileIDs.RemoveAt(_Data.ScreenNames.ProfileIDs.Count - 1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge names. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
_Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
|
||||
if (!_OnAdd())
|
||||
_OnRemove();
|
||||
break;
|
||||
|
||||
case Keys.Delete:
|
||||
_OnRemove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
/*
|
||||
//Check if LeftButton is hold and Select-Mode inactive
|
||||
if (MouseEvent.LBH && !SelectingMouseActive)
|
||||
{
|
||||
//Save mouse-coords
|
||||
OldMouseX = MouseEvent.X;
|
||||
OldMouseY = MouseEvent.Y;
|
||||
//Check if mouse if over tile
|
||||
for (int i = 0; i < PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
if (PlayerChooseButtons[i].Button.Selected)
|
||||
{
|
||||
SelectedPlayerNr = PlayerChooseButtons[i].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.Z = -100;
|
||||
chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
|
||||
chooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[SelectedPlayerNr].Avatar.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode active
|
||||
if (mouseEvent.LBH && _SelectingMouseActive)
|
||||
{
|
||||
//Update coords for Drag/Drop-Texture
|
||||
_ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX;
|
||||
_ChooseAvatarStatic.Rect.Y += mouseEvent.Y - _OldMouseY;
|
||||
_OldMouseX = mouseEvent.X;
|
||||
_OldMouseY = mouseEvent.Y;
|
||||
}
|
||||
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
|
||||
else if (_SelectingMouseActive)
|
||||
{
|
||||
//Check if really a player was selected
|
||||
if (_SelectedPlayerNr != -1)
|
||||
{
|
||||
//Foreach Drop-Area
|
||||
for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
//Check first, if area is "active"
|
||||
if (_PlayerDestinationButtons[i].Visible)
|
||||
{
|
||||
//Check if Mouse is in area
|
||||
if (CHelper.IsInBounds(_PlayerDestinationButtons[i].Rect, mouseEvent))
|
||||
{
|
||||
int added = -1;
|
||||
//Add Player-ID to list.
|
||||
if (_Data.ScreenNames.ProfileIDs.Count < (i + 1))
|
||||
{
|
||||
_Data.ScreenNames.ProfileIDs.Add(_SelectedPlayerNr);
|
||||
added = _Data.ScreenNames.ProfileIDs.Count - 1;
|
||||
}
|
||||
else if (_Data.ScreenNames.ProfileIDs.Count >= (i + 1))
|
||||
{
|
||||
_Data.ScreenNames.ProfileIDs[i] = _SelectedPlayerNr;
|
||||
added = i;
|
||||
}
|
||||
_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 = _ChooseAvatarStatic.Texture;
|
||||
_PlayerDestinationButtons[added].SelTexture = _ChooseAvatarStatic.Texture;
|
||||
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].PlayerName;
|
||||
//Update Tiles-List
|
||||
_UpdateButtonPlayerChoose();
|
||||
}
|
||||
}
|
||||
}
|
||||
_SelectedPlayerNr = -1;
|
||||
}
|
||||
//Reset variables
|
||||
_SelectingMouseActive = false;
|
||||
_ChooseAvatarStatic.Visible = false;
|
||||
}
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
|
||||
if (!_OnAdd())
|
||||
_OnRemove();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
_Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
if (!_ButtonsAdded)
|
||||
{
|
||||
_AddButtonPlayerDestination();
|
||||
_AddButtonPlayerChoose();
|
||||
_ButtonsAdded = true;
|
||||
}
|
||||
|
||||
_UpdateButtonPlayerDestination();
|
||||
_UpdateButtonPlayerChoose();
|
||||
|
||||
_UpdateButtonNext();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
if (_ChooseAvatarStatic.Visible)
|
||||
_ChooseAvatarStatic.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _AddButtonPlayerDestination()
|
||||
{
|
||||
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]);
|
||||
b.Rect.X = _PlayerDestinationButtonsFirstX + column * (b.Rect.W + _PlayerDestinationButtonsSpaceH);
|
||||
b.Rect.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW);
|
||||
_PlayerDestinationButtons.Add(b);
|
||||
column++;
|
||||
if (column >= _PlayerDestinationButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void _AddButtonPlayerChoose()
|
||||
{
|
||||
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]);
|
||||
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;
|
||||
_PlayerChooseButtons.Add(pcb);
|
||||
column++;
|
||||
if (column >= _PlayerChooseButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateButtonPlayerChoose()
|
||||
{
|
||||
_UpdateVisibleProfiles();
|
||||
if ((_PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH) * (_PlayerChooseButtonsOffset + 1) - _PlayerChooseButtonsVisibleProfiles.Count >=
|
||||
(_PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH) * _PlayerChooseButtonsOffset)
|
||||
_UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset - 1);
|
||||
else
|
||||
_UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset);
|
||||
}
|
||||
|
||||
private void _UpdateButtonPlayerChoose(int offset)
|
||||
{
|
||||
int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
|
||||
if (offset < 0)
|
||||
offset = 0;
|
||||
|
||||
if (numButtonPlayerChoose * (offset + 1) - _PlayerChooseButtonsVisibleProfiles.Count <= numButtonPlayerChoose)
|
||||
{
|
||||
for (int i = 0; i < numButtonPlayerChoose; i++)
|
||||
{
|
||||
if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count)
|
||||
{
|
||||
_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.Color = new SColorF(1, 1, 1, 0.6f);
|
||||
_PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1);
|
||||
_PlayerChooseButtons[i].Button.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_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.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateVisibleProfiles()
|
||||
{
|
||||
_PlayerChooseButtonsVisibleProfiles.Clear();
|
||||
for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (visible)
|
||||
_PlayerChooseButtonsVisibleProfiles.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateButtonPlayerDestination()
|
||||
{
|
||||
for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
if (_NumPlayer > i)
|
||||
{
|
||||
_PlayerDestinationButtons[i].Visible = true;
|
||||
_PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_PlayerDestinationButtons[i].Visible = false;
|
||||
_PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _NumPlayer; i++)
|
||||
{
|
||||
if (i < _Data.ScreenNames.ProfileIDs.Count)
|
||||
{
|
||||
if (_Data.ScreenNames.ProfileIDs[i] != -1)
|
||||
{
|
||||
_PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
_PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1);
|
||||
_PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture;
|
||||
_PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture;
|
||||
_PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].PlayerName;
|
||||
_PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
}
|
||||
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].Text.Text = String.Empty;
|
||||
_PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateButtonNext()
|
||||
{
|
||||
if (_Data.ScreenNames.ProfileIDs.Count == _NumPlayer)
|
||||
{
|
||||
Buttons[_ButtonNext].Visible = true;
|
||||
SetInteractionToButton(Buttons[_ButtonNext]);
|
||||
}
|
||||
else
|
||||
Buttons[_ButtonNext].Visible = false;
|
||||
}
|
||||
|
||||
private bool _OnAdd()
|
||||
{
|
||||
for (int i = 0; i < _PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool _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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,58 +3,58 @@ using System.Collections.Generic;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
public class ChallengeRounds
|
||||
public class CChallengeRounds
|
||||
{
|
||||
private readonly Random _Rand;
|
||||
private readonly int _NumPlayer;
|
||||
|
||||
public List<Combination> Rounds;
|
||||
public List<CCombination> Rounds;
|
||||
|
||||
public ChallengeRounds(int NumRounds, int NumPlayer, int NumPlayerAtOnce)
|
||||
public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce)
|
||||
{
|
||||
Rounds = new List<Combination>();
|
||||
Rounds = new List<CCombination>();
|
||||
_Rand = new Random(DateTime.Now.Millisecond);
|
||||
|
||||
if (NumPlayerAtOnce < 1 || NumRounds < 1 || NumPlayer == 0)
|
||||
if (numPlayerAtOnce < 1 || numRounds < 1 || numPlayer == 0)
|
||||
_NumPlayer = 0;
|
||||
else
|
||||
{
|
||||
_NumPlayer = NumPlayer;
|
||||
BuildRounds(NumRounds, NumPlayerAtOnce, _Rand);
|
||||
_NumPlayer = numPlayer;
|
||||
_BuildRounds(numRounds, numPlayerAtOnce, _Rand);
|
||||
}
|
||||
}
|
||||
|
||||
public Combination GetRound(int RoundNr)
|
||||
public CCombination GetRound(int roundNr)
|
||||
{
|
||||
if (RoundNr >= Rounds.Count || _NumPlayer == 0 || Rounds.Count == 0)
|
||||
if (roundNr >= Rounds.Count || _NumPlayer == 0 || Rounds.Count == 0)
|
||||
return null;
|
||||
|
||||
return Rounds[RoundNr];
|
||||
return Rounds[roundNr];
|
||||
}
|
||||
|
||||
private void BuildRounds(int NumRounds, int NumPlayerAtOnce, Random Rand)
|
||||
private void _BuildRounds(int numRounds, int numPlayerAtOnce, Random rand)
|
||||
{
|
||||
Combinations Combinations = new Combinations(_NumPlayer, NumPlayerAtOnce, Rand);
|
||||
Rounds.Add(Combinations.GetNextCombination(null));
|
||||
CCombinations combinations = new CCombinations(_NumPlayer, numPlayerAtOnce, rand);
|
||||
Rounds.Add(combinations.GetNextCombination(null));
|
||||
|
||||
for (int i = 1; i < NumRounds; i++)
|
||||
Rounds.Add(Combinations.GetNextCombination(GetPlayerDemand(i)));
|
||||
for (int i = 1; i < numRounds; i++)
|
||||
Rounds.Add(combinations.GetNextCombination(_GetPlayerDemand(i)));
|
||||
}
|
||||
|
||||
private List<int> GetPlayerDemand(int RoundIndex)
|
||||
private List<int> _GetPlayerDemand(int roundIndex)
|
||||
{
|
||||
List<int> NumPlayed = new List<int>(_NumPlayer);
|
||||
List<int> numPlayed = new List<int>(_NumPlayer);
|
||||
for (int i = 0; i < _NumPlayer; i++)
|
||||
NumPlayed.Add(0);
|
||||
numPlayed.Add(0);
|
||||
|
||||
for (int i = 0; i < RoundIndex; i++)
|
||||
for (int i = 0; i < roundIndex; i++)
|
||||
{
|
||||
foreach (int PlayerIndex in Rounds[i].Player)
|
||||
NumPlayed[PlayerIndex]++;
|
||||
foreach (int playerIndex in Rounds[i].Player)
|
||||
numPlayed[playerIndex]++;
|
||||
}
|
||||
|
||||
int max = 0;
|
||||
foreach (int p in NumPlayed)
|
||||
foreach (int p in numPlayed)
|
||||
{
|
||||
if (p > max)
|
||||
max = p;
|
||||
@@ -65,20 +65,20 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
List<int> other = new List<int>();
|
||||
List<int> last = new List<int>();
|
||||
|
||||
for (int i = 0; i < NumPlayed.Count; i++)
|
||||
for (int i = 0; i < numPlayed.Count; i++)
|
||||
{
|
||||
if (RoundIndex == 0 || NumPlayed[i] < max)
|
||||
if (roundIndex == 0 || numPlayed[i] < max)
|
||||
{
|
||||
if (RoundIndex == 0 || RoundIndex > 0 && NumPlayed[i] < max && !Rounds[RoundIndex - 1].IsAvailable(i))
|
||||
if (roundIndex == 0 || roundIndex > 0 && numPlayed[i] < max && !Rounds[roundIndex - 1].IsAvailable(i))
|
||||
result.Add(i);
|
||||
else if (NumPlayed[i] < max)
|
||||
else if (numPlayed[i] < max)
|
||||
other.Add(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RoundIndex > 0)
|
||||
if (roundIndex > 0)
|
||||
{
|
||||
if (!Rounds[RoundIndex - 1].IsAvailable(i))
|
||||
if (!Rounds[roundIndex - 1].IsAvailable(i))
|
||||
other.Add(i);
|
||||
else
|
||||
last.Add(i);
|
||||
@@ -116,48 +116,48 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
}
|
||||
}
|
||||
|
||||
class Combinations
|
||||
class CCombinations
|
||||
{
|
||||
private readonly List<Combination> _Combs;
|
||||
private readonly List<CCombination> _Combs;
|
||||
private readonly Random _Rand;
|
||||
private readonly int _NumPlayer;
|
||||
private readonly int _NumMics;
|
||||
|
||||
public Combinations(int NumPlayer, int NumMics, Random Rand)
|
||||
public CCombinations(int numPlayer, int numMics, Random rand)
|
||||
{
|
||||
_Combs = new List<Combination>();
|
||||
_NumMics = NumMics;
|
||||
_NumPlayer = NumPlayer;
|
||||
_Rand = Rand;
|
||||
_Combs = new List<CCombination>();
|
||||
_NumMics = numMics;
|
||||
_NumPlayer = numPlayer;
|
||||
_Rand = rand;
|
||||
}
|
||||
|
||||
public Combination GetNextCombination(List<int> PlayerNrDemand)
|
||||
public CCombination GetNextCombination(List<int> playerNrDemand)
|
||||
{
|
||||
if (_Combs.Count == 0)
|
||||
Create();
|
||||
_Create();
|
||||
|
||||
Combination combs = new Combination();
|
||||
CCombination combs = new CCombination();
|
||||
|
||||
if (_NumPlayer == _NumMics)
|
||||
return _Combs[0];
|
||||
|
||||
//filter against PlayerNrDemand
|
||||
List<Combination> combsFiltered = new List<Combination>();
|
||||
if (PlayerNrDemand != null)
|
||||
List<CCombination> combsFiltered = new List<CCombination>();
|
||||
if (playerNrDemand != null)
|
||||
{
|
||||
for (int i = 0; i < _Combs.Count; i++)
|
||||
{
|
||||
if (_Combs[i].IsAvailableAll(PlayerNrDemand))
|
||||
if (_Combs[i].IsAvailableAll(playerNrDemand))
|
||||
combsFiltered.Add(_Combs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//1st fallback
|
||||
if (PlayerNrDemand != null && combsFiltered.Count == 0)
|
||||
if (playerNrDemand != null && combsFiltered.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < _Combs.Count; i++)
|
||||
{
|
||||
if (_Combs[i].IsAvailableSomeone(PlayerNrDemand))
|
||||
if (_Combs[i].IsAvailableSomeone(playerNrDemand))
|
||||
combsFiltered.Add(_Combs[i]);
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
int num = combsFiltered.Count;
|
||||
int rand = _Rand.Next(num);
|
||||
Combination c = new Combination();
|
||||
CCombination c = new CCombination();
|
||||
for (int i = 0; i < combsFiltered[rand].Player.Count; i++)
|
||||
c.Player.Add(combsFiltered[rand].Player[i]);
|
||||
_Combs.Remove(combsFiltered[rand]);
|
||||
@@ -179,7 +179,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
return combsFiltered[rand];
|
||||
}
|
||||
|
||||
private void Create()
|
||||
private void _Create()
|
||||
{
|
||||
_Combs.Clear();
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
for (int i = 1; i <= num; i++)
|
||||
{
|
||||
Combination c = new Combination();
|
||||
CCombination c = new CCombination();
|
||||
|
||||
for (int j = 0; j < _NumPlayer; j++)
|
||||
{
|
||||
@@ -201,37 +201,37 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
}
|
||||
}
|
||||
|
||||
public class Combination
|
||||
public class CCombination
|
||||
{
|
||||
public List<int> Player;
|
||||
|
||||
public Combination()
|
||||
public CCombination()
|
||||
{
|
||||
Player = new List<int>();
|
||||
}
|
||||
|
||||
public bool IsAvailable(int PlayerIndex)
|
||||
public bool IsAvailable(int playerIndex)
|
||||
{
|
||||
foreach (int p in Player)
|
||||
{
|
||||
if (p == PlayerIndex)
|
||||
if (p == playerIndex)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsAvailableAll(List<int> PlayerIndices)
|
||||
public bool IsAvailableAll(List<int> playerIndices)
|
||||
{
|
||||
bool result = true;
|
||||
foreach (int p in PlayerIndices)
|
||||
foreach (int p in playerIndices)
|
||||
result &= IsAvailable(p);
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool IsAvailableSomeone(List<int> PlayerIndices)
|
||||
public bool IsAvailableSomeone(List<int> playerIndices)
|
||||
{
|
||||
bool result = false;
|
||||
foreach (int p in PlayerIndices)
|
||||
foreach (int p in playerIndices)
|
||||
result |= IsAvailable(p);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -109,10 +109,10 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="ChallengeRounds.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="PartyModeChallenge.cs" />
|
||||
<Compile Include="PartyScreenChallengeConfig.cs" />
|
||||
<Compile Include="PartyScreenChallengeMain.cs" />
|
||||
<Compile Include="PartyScreenChallengeNames.cs" />
|
||||
<Compile Include="CPartyModeChallenge.cs" />
|
||||
<Compile Include="CPartyScreenChallengeConfig.cs" />
|
||||
<Compile Include="CPartyScreenChallengeMain.cs" />
|
||||
<Compile Include="CPartyScreenChallengeNames.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VocaluxeLib\VocaluxeLib.csproj">
|
||||
@@ -123,10 +123,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.XML" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
public class PartyScreenChallengeConfig : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string SelectSlideNumPlayers = "SelectSlideNumPlayers";
|
||||
private const string SelectSlideNumMics = "SelectSlideNumMics";
|
||||
private const string SelectSlideNumRounds = "SelectSlideNumRounds";
|
||||
private const string ButtonNext = "ButtonNext";
|
||||
private const string ButtonBack = "ButtonBack";
|
||||
|
||||
private int _MaxNumMics = 2;
|
||||
private int _MaxNumRounds = 100;
|
||||
private int _RoundSteps = 1;
|
||||
|
||||
private DataFromScreen Data;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeSelectSlides = new string[] {SelectSlideNumPlayers, SelectSlideNumMics, SelectSlideNumRounds};
|
||||
_ThemeButtons = new string[] {ButtonNext, ButtonBack};
|
||||
|
||||
Data = new DataFromScreen();
|
||||
FromScreenConfig config = new FromScreenConfig();
|
||||
config.NumPlayer = 4;
|
||||
config.NumPlayerAtOnce = 2;
|
||||
config.NumRounds = 12;
|
||||
Data.ScreenConfig = config;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenConfig config = new DataToScreenConfig();
|
||||
|
||||
try
|
||||
{
|
||||
config = (DataToScreenConfig)ReceivedData;
|
||||
Data.ScreenConfig.NumPlayer = config.NumPlayer;
|
||||
Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce;
|
||||
Data.ScreenConfig.NumRounds = config.NumRounds;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge config. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
UpdateSlides();
|
||||
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
UpdateSlides();
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
UpdateSlides();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
UpdateSlides();
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
_MaxNumMics = CBase.Config.GetMaxNumMics();
|
||||
if (_MaxNumMics > 6)
|
||||
_MaxNumMics = 6;
|
||||
|
||||
_MaxNumRounds = _PartyMode.GetMaxNumRounds();
|
||||
|
||||
RebuildSlides();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void RebuildSlides()
|
||||
{
|
||||
// build num player slide (min player ... max player);
|
||||
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();
|
||||
|
||||
UpdateMicsAtOnce();
|
||||
SetRoundSteps();
|
||||
UpdateSlideRounds();
|
||||
}
|
||||
|
||||
private void UpdateSlides()
|
||||
{
|
||||
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;
|
||||
|
||||
UpdateMicsAtOnce();
|
||||
SetRoundSteps();
|
||||
|
||||
if (player != Data.ScreenConfig.NumPlayer || mics != Data.ScreenConfig.NumPlayerAtOnce)
|
||||
{
|
||||
int num = CHelper.nCk(Data.ScreenConfig.NumPlayer, Data.ScreenConfig.NumPlayerAtOnce);
|
||||
while (num > _MaxNumRounds)
|
||||
num -= _RoundSteps;
|
||||
Data.ScreenConfig.NumRounds = num;
|
||||
}
|
||||
|
||||
UpdateSlideRounds();
|
||||
}
|
||||
|
||||
private void UpdateMicsAtOnce()
|
||||
{
|
||||
//Data.ScreenConfig.NumPlayerAtOnce
|
||||
int MaxNum = _MaxNumMics;
|
||||
if (Data.ScreenConfig.NumPlayer < _MaxNumMics)
|
||||
MaxNum = Data.ScreenConfig.NumPlayer;
|
||||
|
||||
if (Data.ScreenConfig.NumPlayerAtOnce > MaxNum)
|
||||
Data.ScreenConfig.NumPlayerAtOnce = MaxNum;
|
||||
|
||||
// build mics at once slide
|
||||
SelectSlides[SelectSlideNumMics].Clear();
|
||||
for (int i = 1; i <= MaxNum; i++)
|
||||
SelectSlides[SelectSlideNumMics].AddValue(i.ToString());
|
||||
SelectSlides[SelectSlideNumMics].Selection = Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
|
||||
}
|
||||
|
||||
private void UpdateSlideRounds()
|
||||
{
|
||||
// build num rounds slide
|
||||
SelectSlides[SelectSlideNumRounds].Clear();
|
||||
for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
|
||||
SelectSlides[SelectSlideNumRounds].AddValue(i.ToString());
|
||||
SelectSlides[SelectSlideNumRounds].Selection = Data.ScreenConfig.NumRounds / _RoundSteps - 1;
|
||||
}
|
||||
|
||||
private void SetRoundSteps()
|
||||
{
|
||||
if (Data.ScreenConfig.NumPlayerAtOnce < 1 || Data.ScreenConfig.NumPlayer < 1 || Data.ScreenConfig.NumPlayerAtOnce > Data.ScreenConfig.NumPlayer)
|
||||
{
|
||||
_RoundSteps = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private void Back()
|
||||
{
|
||||
FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void Next()
|
||||
{
|
||||
_PartyMode.DataFromScreen(ThemeName, Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,660 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
struct TableRow
|
||||
{
|
||||
public CText Pos;
|
||||
public CText Name;
|
||||
public CText Rounds;
|
||||
public CText Won;
|
||||
public CText SingPoints;
|
||||
public CText GamePoints;
|
||||
}
|
||||
|
||||
class RoundsTableRow
|
||||
{
|
||||
public CText Number;
|
||||
public List<CText> TextPlayer;
|
||||
public List<CText> TextScores;
|
||||
}
|
||||
|
||||
public class PartyScreenChallengeMain : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string TextPosition = "TextPosition";
|
||||
private const string TextPlayerName = "TextPlayerName";
|
||||
private const string TextNumPlayed = "TextNumPlayed";
|
||||
private const string TextWon = "TextWon";
|
||||
private const string TextSingPoints = "TextSingPoints";
|
||||
private const string TextGamePoints = "TextGamePoints";
|
||||
private const string TextNextPlayer = "TextNextPlayer";
|
||||
private const string TextPopupReallyExit = "TextPopupReallyExit";
|
||||
private const string TextRoundPlayer = "TextRoundPlayer";
|
||||
private const string TextRoundScore = "TextRoundScore";
|
||||
private const string TextRoundNumber = "TextRoundNumber";
|
||||
private const string TextFinishMessage = "TextFinishMessage";
|
||||
private const string TextFinishPlayerWin = "TextFinishPlayerWin";
|
||||
private const string TextNextPlayerMessage = "TextNextPlayerMessage";
|
||||
|
||||
private const string ButtonNextRound = "ButtonNextRound";
|
||||
private const string ButtonBack = "ButtonBack";
|
||||
private const string ButtonExit = "ButtonExit";
|
||||
private const string ButtonPopupYes = "ButtonPopupYes";
|
||||
private const string ButtonPopupNo = "ButtonPopupNo";
|
||||
private const string ButtonPlayerScrollUp = "ButtonPlayerScrollUp";
|
||||
private const string ButtonPlayerScrollDown = "ButtonPlayerScrollDown";
|
||||
private const string ButtonRoundsScrollUp = "ButtonRoundsScrollUp";
|
||||
private const string ButtonRoundsScrollDown = "ButtonRoundsScrollDown";
|
||||
|
||||
private const string StaticPopupBG = "StaticPopupBG";
|
||||
private const string StaticNextPlayer = "StaticNextPlayer";
|
||||
|
||||
private bool ExitPopupVisible;
|
||||
|
||||
private DataFromScreen Data;
|
||||
private DataToScreenMain GameState;
|
||||
private List<TableRow> PlayerTable;
|
||||
private List<RoundsTableRow> RoundsTable;
|
||||
|
||||
private List<CText> NextPlayerTexts;
|
||||
private List<CStatic> NextPlayerStatics;
|
||||
|
||||
private SRectF RoundsTableScrollArea;
|
||||
private SRectF PlayerTableScrollArea;
|
||||
private int RoundsTableOffset;
|
||||
private int PlayerTableOffset;
|
||||
private int NumPlayerVisible = 10;
|
||||
private int NumRoundsVisible = 3;
|
||||
|
||||
public PartyScreenChallengeMain()
|
||||
{
|
||||
Data = new DataFromScreen();
|
||||
Data.ScreenMain = new FromScreenMain();
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeTexts = new string[]
|
||||
{
|
||||
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};
|
||||
_ThemeStatics = new string[] {StaticPopupBG, StaticNextPlayer};
|
||||
}
|
||||
|
||||
public override void LoadTheme(string XmlPath)
|
||||
{
|
||||
base.LoadTheme(XmlPath);
|
||||
|
||||
GameState = new DataToScreenMain();
|
||||
BuildPlayerTable();
|
||||
CreateRoundsTable();
|
||||
NextPlayerTexts = new List<CText>();
|
||||
NextPlayerStatics = new List<CStatic>();
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenMain data = new DataToScreenMain();
|
||||
|
||||
try
|
||||
{
|
||||
data = (DataToScreenMain)ReceivedData;
|
||||
GameState = data;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge main. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
else
|
||||
ShowPopup(true);
|
||||
}
|
||||
else
|
||||
ShowPopup(false);
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[ButtonNextRound].Selected)
|
||||
NextRound();
|
||||
if (Buttons[ButtonBack].Selected && GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
if (Buttons[ButtonExit].Selected && GameState.CurrentRoundNr > 1)
|
||||
ShowPopup(true);
|
||||
if (Buttons[ButtonPlayerScrollUp].Selected)
|
||||
ScrollPlayerTable(-1);
|
||||
if (Buttons[ButtonPlayerScrollDown].Selected)
|
||||
ScrollPlayerTable(1);
|
||||
if (Buttons[ButtonRoundsScrollUp].Selected)
|
||||
ScrollRoundsTable(-1);
|
||||
if (Buttons[ButtonRoundsScrollDown].Selected)
|
||||
ScrollRoundsTable(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[ButtonPopupYes].Selected)
|
||||
EndParty();
|
||||
if (Buttons[ButtonPopupNo].Selected)
|
||||
ShowPopup(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[ButtonNextRound].Selected)
|
||||
NextRound();
|
||||
if (Buttons[ButtonBack].Selected && GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
if (Buttons[ButtonExit].Selected && GameState.CurrentRoundNr > 1)
|
||||
ShowPopup(true);
|
||||
if (Buttons[ButtonPlayerScrollUp].Selected)
|
||||
ScrollPlayerTable(-1);
|
||||
if (Buttons[ButtonPlayerScrollDown].Selected)
|
||||
ScrollPlayerTable(1);
|
||||
if (Buttons[ButtonRoundsScrollUp].Selected)
|
||||
ScrollRoundsTable(-1);
|
||||
if (Buttons[ButtonRoundsScrollDown].Selected)
|
||||
ScrollRoundsTable(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[ButtonPopupYes].Selected)
|
||||
EndParty();
|
||||
if (Buttons[ButtonPopupNo].Selected)
|
||||
ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
{
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
else
|
||||
ShowPopup(true);
|
||||
}
|
||||
else
|
||||
ShowPopup(false);
|
||||
}
|
||||
|
||||
if (mouseEvent.Wheel != 0)
|
||||
{
|
||||
if (CHelper.IsInBounds(RoundsTableScrollArea, mouseEvent))
|
||||
ScrollRoundsTable(mouseEvent.Wheel);
|
||||
if (CHelper.IsInBounds(PlayerTableScrollArea, mouseEvent))
|
||||
ScrollPlayerTable(mouseEvent.Wheel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
PlayerTableOffset = 0;
|
||||
RoundsTableOffset = 0;
|
||||
|
||||
UpdatePlayerTable();
|
||||
UpdateNextPlayerPositions();
|
||||
UpdateNextPlayerContents();
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
BuildRoundsTable();
|
||||
else
|
||||
ScrollRoundsTable(GameState.CurrentRoundNr - 2);
|
||||
UpdateRoundsTable();
|
||||
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
{
|
||||
Buttons[ButtonBack].Visible = true;
|
||||
Buttons[ButtonExit].Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
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]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[ButtonNextRound].Visible = false;
|
||||
Texts[TextFinishMessage].Visible = true;
|
||||
Texts[TextFinishPlayerWin].Visible = true;
|
||||
Texts[TextFinishPlayerWin].Text = GetPlayerWinString();
|
||||
SetInteractionToButton(Buttons[ButtonExit]);
|
||||
}
|
||||
|
||||
ShowPopup(false);
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void NextRound()
|
||||
{
|
||||
Data.ScreenMain.FadeToNameSelection = false;
|
||||
Data.ScreenMain.FadeToSongSelection = true;
|
||||
_PartyMode.DataFromScreen(ThemeName, Data);
|
||||
}
|
||||
|
||||
private void EndParty()
|
||||
{
|
||||
FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void ShowPopup(bool Visible)
|
||||
{
|
||||
ExitPopupVisible = Visible;
|
||||
|
||||
Statics[StaticPopupBG].Visible = ExitPopupVisible;
|
||||
Texts[TextPopupReallyExit].Visible = ExitPopupVisible;
|
||||
Buttons[ButtonPopupYes].Visible = ExitPopupVisible;
|
||||
Buttons[ButtonPopupNo].Visible = ExitPopupVisible;
|
||||
|
||||
if (ExitPopupVisible)
|
||||
SetInteractionToButton(Buttons[ButtonPopupNo]);
|
||||
}
|
||||
|
||||
private void Back()
|
||||
{
|
||||
Data.ScreenMain.FadeToNameSelection = true;
|
||||
Data.ScreenMain.FadeToSongSelection = false;
|
||||
_PartyMode.DataFromScreen(ThemeName, Data);
|
||||
}
|
||||
|
||||
private void UpdateNextPlayerPositions()
|
||||
{
|
||||
float x = CBase.Settings.GetRenderW() / 2 - ((GameState.NumPlayerAtOnce * Statics[StaticNextPlayer].Rect.W) + ((GameState.NumPlayerAtOnce - 1) * 15)) / 2;
|
||||
float static_y = 590;
|
||||
float text_y = 550;
|
||||
for (int i = 0; i < GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//static
|
||||
NextPlayerStatics[i].Rect.X = x;
|
||||
NextPlayerStatics[i].Rect.Y = static_y;
|
||||
NextPlayerStatics[i].Visible = true;
|
||||
//text
|
||||
NextPlayerTexts[i].X = x + Statics[StaticNextPlayer].Rect.W / 2;
|
||||
NextPlayerTexts[i].Y = text_y;
|
||||
NextPlayerTexts[i].Visible = true;
|
||||
|
||||
x += Statics[StaticNextPlayer].Rect.W + 15;
|
||||
}
|
||||
for (int i = GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
|
||||
{
|
||||
NextPlayerStatics[i].Visible = false;
|
||||
NextPlayerTexts[i].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateNextPlayerContents()
|
||||
{
|
||||
if (GameState.CurrentRoundNr <= GameState.Combs.Count)
|
||||
{
|
||||
Texts[TextNextPlayerMessage].Visible = true;
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
for (int i = 0; i < GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
int pid = GameState.Combs[GameState.CurrentRoundNr - 1].Player[i];
|
||||
NextPlayerStatics[i].Texture = profiles[GameState.ProfileIDs[pid]].Avatar.Texture;
|
||||
NextPlayerTexts[i].Text = profiles[GameState.ProfileIDs[pid]].PlayerName;
|
||||
NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Texts[TextNextPlayerMessage].Visible = false;
|
||||
for (int i = 0; i < GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
NextPlayerStatics[i].Visible = false;
|
||||
NextPlayerTexts[i].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateRoundsTable()
|
||||
{
|
||||
//Create lists
|
||||
RoundsTable = new List<RoundsTableRow>();
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RoundsTableRow rtr = new RoundsTableRow();
|
||||
rtr.TextPlayer = new List<CText>();
|
||||
rtr.TextScores = new List<CText>();
|
||||
RoundsTable.Add(rtr);
|
||||
}
|
||||
//Create statics and texts for rounds
|
||||
for (int round = 0; round < RoundsTable.Count; round++)
|
||||
{
|
||||
//Round-number
|
||||
CText text = GetNewText(Texts[TextRoundNumber]);
|
||||
AddText(text);
|
||||
RoundsTable[round].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);
|
||||
//Score
|
||||
text = GetNewText(Texts[TextRoundScore]);
|
||||
AddText(text);
|
||||
RoundsTable[round].TextScores.Add(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildRoundsTable()
|
||||
{
|
||||
RoundsTableScrollArea = new SRectF();
|
||||
|
||||
int NumPlayerInOneRow = 3;
|
||||
if (GameState.NumPlayerAtOnce <= NumPlayerInOneRow)
|
||||
NumRoundsVisible = 5;
|
||||
else
|
||||
NumRoundsVisible = 3;
|
||||
|
||||
if (NumRoundsVisible > GameState.Combs.Count)
|
||||
NumRoundsVisible = GameState.Combs.Count;
|
||||
|
||||
float x = Texts[TextRoundNumber].X;
|
||||
float y = Texts[TextRoundNumber].Y;
|
||||
|
||||
RoundsTableScrollArea.X = x;
|
||||
RoundsTableScrollArea.Y = y;
|
||||
RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - Texts[TextRoundNumber].X - 20;
|
||||
|
||||
float delta = Texts[TextRoundNumber].Height;
|
||||
|
||||
//Update statics and texts for rounds
|
||||
for (int round = 0; round < RoundsTable.Count; round++)
|
||||
{
|
||||
//Round-number
|
||||
RoundsTable[round].Number.X = x;
|
||||
RoundsTable[round].Number.Y = y;
|
||||
int NumInnerRows = (int)Math.Ceiling(GameState.NumPlayerAtOnce / ((double)NumPlayerInOneRow));
|
||||
for (int row = 0; row < NumInnerRows; row++)
|
||||
{
|
||||
int num = (row + 1) * NumPlayerInOneRow;
|
||||
int NumPlayerInThisRow = NumPlayerInOneRow;
|
||||
if (num > GameState.NumPlayerAtOnce)
|
||||
{
|
||||
num = GameState.NumPlayerAtOnce;
|
||||
NumPlayerInThisRow = GameState.NumPlayerAtOnce - (row * NumPlayerInOneRow);
|
||||
}
|
||||
for (int column = row * NumPlayerInOneRow; column < num; column++)
|
||||
{
|
||||
//Player
|
||||
float _x = x + 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 = y;
|
||||
RoundsTable[round].TextPlayer[column].MaxWidth = maxw;
|
||||
//Score
|
||||
RoundsTable[round].TextScores[column] = RoundsTable[round].TextScores[column];
|
||||
RoundsTable[round].TextScores[column].X = _x;
|
||||
RoundsTable[round].TextScores[column].Y = y + delta;
|
||||
RoundsTable[round].TextScores[column].MaxWidth = maxw;
|
||||
}
|
||||
y = y + delta + delta;
|
||||
}
|
||||
y = y + delta / 2;
|
||||
}
|
||||
RoundsTableScrollArea.H = y - RoundsTableScrollArea.Y;
|
||||
}
|
||||
|
||||
private void UpdateRoundsTable()
|
||||
{
|
||||
SProfile[] profile = CBase.Profiles.GetProfiles();
|
||||
for (int i = 0; i < RoundsTable.Count; i++)
|
||||
{
|
||||
for (int p = 0; p < RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
if (GameState.Combs.Count > i + RoundsTableOffset && GameState.Combs[i + RoundsTableOffset].Player.Count > p)
|
||||
{
|
||||
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() + ")";
|
||||
int pID = GameState.ProfileIDs[GameState.Combs[i + RoundsTableOffset].Player[p]];
|
||||
RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
|
||||
if ((GameState.CurrentRoundNr - 1) > i + RoundsTableOffset)
|
||||
RoundsTable[i].TextScores[p].Text = GameState.Results[i + RoundsTableOffset, p].ToString();
|
||||
else
|
||||
RoundsTable[i].TextScores[p].Text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
if (GameState.Combs.Count < i + RoundsTableOffset || i + 1 > NumRoundsVisible)
|
||||
{
|
||||
RoundsTable[i].Number.Visible = false;
|
||||
for (int p = 0; p < RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
PlayerTable = new List<TableRow>();
|
||||
float delta = Texts[TextPosition].Height * 1.2f;
|
||||
|
||||
float h = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
TableRow row = new TableRow();
|
||||
|
||||
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]);
|
||||
|
||||
row.Pos.Y += delta * (i + 1);
|
||||
row.Name.Y += delta * (i + 1);
|
||||
row.Rounds.Y += delta * (i + 1);
|
||||
row.Won.Y += delta * (i + 1);
|
||||
row.SingPoints.Y += delta * (i + 1);
|
||||
row.GamePoints.Y += delta * (i + 1);
|
||||
|
||||
row.Pos.Text = (i + 1).ToString() + ".";
|
||||
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
row.Rounds.Visible = false;
|
||||
row.Won.Visible = false;
|
||||
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);
|
||||
|
||||
PlayerTable.Add(row);
|
||||
|
||||
h = delta * (i + 1);
|
||||
}
|
||||
PlayerTableScrollArea.H = h + delta;
|
||||
}
|
||||
|
||||
private void UpdatePlayerTable()
|
||||
{
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < PlayerTable.Count; i++)
|
||||
{
|
||||
TableRow row = PlayerTable[i];
|
||||
|
||||
if (i + PlayerTableOffset < GameState.ResultTable.Count)
|
||||
{
|
||||
row.Pos.Visible = true;
|
||||
row.Name.Visible = true;
|
||||
row.Rounds.Visible = true;
|
||||
row.Won.Visible = true;
|
||||
row.SingPoints.Visible = true;
|
||||
row.GamePoints.Visible = true;
|
||||
|
||||
row.Pos.Text = GameState.ResultTable[i + PlayerTableOffset].Position.ToString() + ".";
|
||||
row.Name.Text = profiles[GameState.ResultTable[i + PlayerTableOffset].PlayerID].PlayerName;
|
||||
row.Rounds.Text = GameState.ResultTable[i + PlayerTableOffset].NumRounds.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();
|
||||
}
|
||||
else
|
||||
{
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
row.Rounds.Visible = false;
|
||||
row.Won.Visible = false;
|
||||
row.SingPoints.Visible = false;
|
||||
row.GamePoints.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
Buttons[ButtonPlayerScrollUp].Visible = PlayerTableOffset > 0;
|
||||
Buttons[ButtonPlayerScrollDown].Visible = GameState.ProfileIDs.Count - NumPlayerVisible - PlayerTableOffset > 0;
|
||||
}
|
||||
|
||||
private void ScrollPlayerTable(int Offset)
|
||||
{
|
||||
if (GameState.ProfileIDs.Count <= NumPlayerVisible)
|
||||
PlayerTableOffset = 0;
|
||||
else if (Offset < 0 && PlayerTableOffset + Offset >= 0)
|
||||
PlayerTableOffset += Offset;
|
||||
else if (Offset < 0 && PlayerTableOffset + Offset < 0)
|
||||
PlayerTableOffset = 0;
|
||||
else if (Offset > 0 && PlayerTableOffset + Offset <= GameState.ProfileIDs.Count - NumPlayerVisible)
|
||||
PlayerTableOffset += Offset;
|
||||
else if (Offset > 0 && PlayerTableOffset + Offset > GameState.ProfileIDs.Count - NumPlayerVisible)
|
||||
PlayerTableOffset = GameState.ProfileIDs.Count - NumPlayerVisible;
|
||||
|
||||
UpdatePlayerTable();
|
||||
}
|
||||
|
||||
private void ScrollRoundsTable(int Offset)
|
||||
{
|
||||
if (GameState.Combs.Count <= NumRoundsVisible)
|
||||
RoundsTableOffset = 0;
|
||||
else if (Offset < 0 && RoundsTableOffset + Offset >= 0)
|
||||
RoundsTableOffset += Offset;
|
||||
else if (Offset < 0 && RoundsTableOffset + Offset < 0)
|
||||
RoundsTableOffset = 0;
|
||||
else if (Offset > 0 && RoundsTableOffset + Offset <= GameState.Combs.Count - NumRoundsVisible)
|
||||
RoundsTableOffset += Offset;
|
||||
else if (Offset > 0 && RoundsTableOffset + Offset > GameState.Combs.Count - NumRoundsVisible)
|
||||
RoundsTableOffset = GameState.Combs.Count - NumRoundsVisible;
|
||||
|
||||
UpdateRoundsTable();
|
||||
}
|
||||
|
||||
private string GetPlayerWinString()
|
||||
{
|
||||
string s = "";
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < GameState.ResultTable.Count; i++)
|
||||
{
|
||||
if (GameState.ResultTable[i].Position == 1)
|
||||
{
|
||||
if (i > 0)
|
||||
s += ", ";
|
||||
s += profiles[GameState.ResultTable[i].PlayerID].PlayerName;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,504 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
public class PartyScreenChallengeNames : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string ButtonNext = "ButtonNext";
|
||||
private const string ButtonBack = "ButtonBack";
|
||||
private const string ButtonPlayerDestination = "ButtonPlayerDestination";
|
||||
private const string ButtonPlayerChoose = "ButtonPlayerChoose";
|
||||
|
||||
private List<CPlayerChooseButton> PlayerChooseButtons;
|
||||
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;
|
||||
private const int PlayerDestinationButtonsSpaceW = 25;
|
||||
//PlayerChooseButtons-Option
|
||||
private List<int> PlayerChooseButtonsVisibleProfiles;
|
||||
private const int PlayerChooseButtonsNumH = 7;
|
||||
private const int PlayerChooseButtonsNumW = 4;
|
||||
private const int PlayerChooseButtonsFirstX = 52;
|
||||
private const int PlayerChooseButtonsFirstY = 105;
|
||||
private const int PlayerChooseButtonsSpaceH = 15;
|
||||
private const int PlayerChooseButtonsSpaceW = 25;
|
||||
private int PlayerChooseButtonsOffset = 0;
|
||||
|
||||
private CStatic chooseAvatarStatic;
|
||||
private bool SelectingMouseActive;
|
||||
private int OldMouseX;
|
||||
private int OldMouseY;
|
||||
private int SelectedPlayerNr = -1;
|
||||
private bool ButtonsAdded;
|
||||
|
||||
private int NumPlayer = 4;
|
||||
|
||||
private DataFromScreen Data;
|
||||
|
||||
private class CPlayerChooseButton
|
||||
{
|
||||
public CButton Button;
|
||||
public int ProfileID;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
chooseAvatarStatic = GetNewStatic();
|
||||
chooseAvatarStatic.Visible = false;
|
||||
|
||||
PlayerChooseButtonsVisibleProfiles = new List<int>();
|
||||
|
||||
Data.ScreenNames.ProfileIDs = new List<int>();
|
||||
|
||||
List<string> buttons = new List<string>();
|
||||
_ThemeButtons = new string[] {ButtonBack, ButtonNext, ButtonPlayerDestination, ButtonPlayerChoose};
|
||||
|
||||
Data = new DataFromScreen();
|
||||
FromScreenNames names = new FromScreenNames();
|
||||
names.FadeToConfig = false;
|
||||
names.FadeToMain = false;
|
||||
names.ProfileIDs = new List<int>();
|
||||
Data.ScreenNames = names;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenNames config = new DataToScreenNames();
|
||||
|
||||
try
|
||||
{
|
||||
config = (DataToScreenNames)ReceivedData;
|
||||
Data.ScreenNames.ProfileIDs = config.ProfileIDs;
|
||||
if (Data.ScreenNames.ProfileIDs == null)
|
||||
Data.ScreenNames.ProfileIDs = new List<int>();
|
||||
|
||||
NumPlayer = config.NumPlayer;
|
||||
|
||||
while (Data.ScreenNames.ProfileIDs.Count > NumPlayer)
|
||||
Data.ScreenNames.ProfileIDs.RemoveAt(Data.ScreenNames.ProfileIDs.Count - 1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge names. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
|
||||
if (!OnAdd())
|
||||
OnRemove();
|
||||
break;
|
||||
|
||||
case Keys.Delete:
|
||||
OnRemove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
/*
|
||||
//Check if LeftButton is hold and Select-Mode inactive
|
||||
if (MouseEvent.LBH && !SelectingMouseActive)
|
||||
{
|
||||
//Save mouse-coords
|
||||
OldMouseX = MouseEvent.X;
|
||||
OldMouseY = MouseEvent.Y;
|
||||
//Check if mouse if over tile
|
||||
for (int i = 0; i < PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
if (PlayerChooseButtons[i].Button.Selected)
|
||||
{
|
||||
SelectedPlayerNr = PlayerChooseButtons[i].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.Z = -100;
|
||||
chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
|
||||
chooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[SelectedPlayerNr].Avatar.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode active
|
||||
if (mouseEvent.LBH && SelectingMouseActive)
|
||||
{
|
||||
//Update coords for Drag/Drop-Texture
|
||||
chooseAvatarStatic.Rect.X += mouseEvent.X - OldMouseX;
|
||||
chooseAvatarStatic.Rect.Y += mouseEvent.Y - OldMouseY;
|
||||
OldMouseX = mouseEvent.X;
|
||||
OldMouseY = mouseEvent.Y;
|
||||
}
|
||||
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
|
||||
else if (SelectingMouseActive)
|
||||
{
|
||||
//Check if really a player was selected
|
||||
if (SelectedPlayerNr != -1)
|
||||
{
|
||||
//Foreach Drop-Area
|
||||
for (int i = 0; i < PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
//Check first, if area is "active"
|
||||
if (PlayerDestinationButtons[i].Visible)
|
||||
{
|
||||
//Check if Mouse is in area
|
||||
if (CHelper.IsInBounds(PlayerDestinationButtons[i].Rect, mouseEvent))
|
||||
{
|
||||
int added = -1;
|
||||
//Add Player-ID to list.
|
||||
if (Data.ScreenNames.ProfileIDs.Count < (i + 1))
|
||||
{
|
||||
Data.ScreenNames.ProfileIDs.Add(SelectedPlayerNr);
|
||||
added = Data.ScreenNames.ProfileIDs.Count - 1;
|
||||
}
|
||||
else if (Data.ScreenNames.ProfileIDs.Count >= (i + 1))
|
||||
{
|
||||
Data.ScreenNames.ProfileIDs[i] = SelectedPlayerNr;
|
||||
added = i;
|
||||
}
|
||||
UpdateButtonNext();
|
||||
//Update texture and name
|
||||
PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerDestinationButtons[added].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[added].Texture = chooseAvatarStatic.Texture;
|
||||
PlayerDestinationButtons[added].STexture = chooseAvatarStatic.Texture;
|
||||
PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[SelectedPlayerNr].PlayerName;
|
||||
//Update Tiles-List
|
||||
UpdateButtonPlayerChoose();
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectedPlayerNr = -1;
|
||||
}
|
||||
//Reset variables
|
||||
SelectingMouseActive = false;
|
||||
chooseAvatarStatic.Visible = false;
|
||||
}
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
|
||||
if (!OnAdd())
|
||||
OnRemove();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
if (!ButtonsAdded)
|
||||
{
|
||||
AddButtonPlayerDestination();
|
||||
AddButtonPlayerChoose();
|
||||
ButtonsAdded = true;
|
||||
}
|
||||
|
||||
UpdateButtonPlayerDestination();
|
||||
UpdateButtonPlayerChoose();
|
||||
|
||||
UpdateButtonNext();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
if (chooseAvatarStatic.Visible)
|
||||
chooseAvatarStatic.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AddButtonPlayerDestination()
|
||||
{
|
||||
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]);
|
||||
b.Rect.X = PlayerDestinationButtonsFirstX + column * (b.Rect.W + PlayerDestinationButtonsSpaceH);
|
||||
b.Rect.Y = PlayerDestinationButtonsFirstY + row * (b.Rect.H + PlayerDestinationButtonsSpaceW);
|
||||
PlayerDestinationButtons.Add(b);
|
||||
column++;
|
||||
if (column >= PlayerDestinationButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButtonPlayerChoose()
|
||||
{
|
||||
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]);
|
||||
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;
|
||||
PlayerChooseButtons.Add(pcb);
|
||||
column++;
|
||||
if (column >= PlayerChooseButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerChoose()
|
||||
{
|
||||
UpdateVisibleProfiles();
|
||||
if ((PlayerChooseButtonsNumW * PlayerChooseButtonsNumH) * (PlayerChooseButtonsOffset + 1) - PlayerChooseButtonsVisibleProfiles.Count >=
|
||||
(PlayerChooseButtonsNumW * PlayerChooseButtonsNumH) * PlayerChooseButtonsOffset)
|
||||
UpdateButtonPlayerChoose(PlayerChooseButtonsOffset - 1);
|
||||
else
|
||||
UpdateButtonPlayerChoose(PlayerChooseButtonsOffset);
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerChoose(int Offset)
|
||||
{
|
||||
int NumButtonPlayerChoose = PlayerChooseButtonsNumW * PlayerChooseButtonsNumH;
|
||||
if (Offset < 0)
|
||||
Offset = 0;
|
||||
|
||||
if (NumButtonPlayerChoose * (Offset + 1) - PlayerChooseButtonsVisibleProfiles.Count <= NumButtonPlayerChoose)
|
||||
{
|
||||
for (int i = 0; i < NumButtonPlayerChoose; i++)
|
||||
{
|
||||
if ((i + Offset * NumButtonPlayerChoose) < PlayerChooseButtonsVisibleProfiles.Count)
|
||||
{
|
||||
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.STexture = CBase.Profiles.GetProfiles()[PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose]].Avatar.Texture;
|
||||
PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerChooseButtons[i].Button.SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerChooseButtons[i].Button.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerChooseButtons[i].ProfileID = -1;
|
||||
PlayerChooseButtons[i].Button.Text.Text = String.Empty;
|
||||
PlayerChooseButtons[i].Button.Texture = Buttons[ButtonPlayerChoose].Texture;
|
||||
PlayerChooseButtons[i].Button.STexture = Buttons[ButtonPlayerChoose].STexture;
|
||||
PlayerChooseButtons[i].Button.Color = Buttons[ButtonPlayerChoose].Color;
|
||||
PlayerChooseButtons[i].Button.SColor = Buttons[ButtonPlayerChoose].SColor;
|
||||
PlayerChooseButtons[i].Button.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateVisibleProfiles()
|
||||
{
|
||||
PlayerChooseButtonsVisibleProfiles.Clear();
|
||||
for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (visible)
|
||||
PlayerChooseButtonsVisibleProfiles.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerDestination()
|
||||
{
|
||||
for (int i = 0; i < PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
if (NumPlayer > i)
|
||||
{
|
||||
PlayerDestinationButtons[i].Visible = true;
|
||||
PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerDestinationButtons[i].Visible = false;
|
||||
PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < NumPlayer; i++)
|
||||
{
|
||||
if (i < Data.ScreenNames.ProfileIDs.Count)
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDs[i] != -1)
|
||||
{
|
||||
PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerDestinationButtons[i].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].Avatar.Texture;
|
||||
PlayerDestinationButtons[i].STexture = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].Avatar.Texture;
|
||||
PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].PlayerName;
|
||||
PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerDestinationButtons[i].Color = Buttons[ButtonPlayerDestination].Color;
|
||||
PlayerDestinationButtons[i].SColor = Buttons[ButtonPlayerDestination].SColor;
|
||||
PlayerDestinationButtons[i].Texture = Buttons[ButtonPlayerDestination].Texture;
|
||||
PlayerDestinationButtons[i].STexture = Buttons[ButtonPlayerDestination].STexture;
|
||||
PlayerDestinationButtons[i].Text.Text = String.Empty;
|
||||
PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonNext()
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDs.Count == NumPlayer)
|
||||
{
|
||||
Buttons[ButtonNext].Visible = true;
|
||||
SetInteractionToButton(Buttons[ButtonNext]);
|
||||
}
|
||||
else
|
||||
Buttons[ButtonNext].Visible = false;
|
||||
}
|
||||
|
||||
private bool OnAdd()
|
||||
{
|
||||
for (int i = 0; i < PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
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].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[PlayerChooseButtons[i].ProfileID].Avatar.Texture;
|
||||
PlayerDestinationButtons[added].STexture = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+54
-54
@@ -3,58 +3,58 @@ using System.Collections.Generic;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
{
|
||||
public class ChallengeRounds
|
||||
public class CChallengeRounds
|
||||
{
|
||||
private readonly Random _Rand;
|
||||
private readonly int _NumPlayer;
|
||||
|
||||
public List<Combination> Rounds;
|
||||
public List<CCombination> Rounds;
|
||||
|
||||
public ChallengeRounds(int NumRounds, int NumPlayer, int NumPlayerAtOnce)
|
||||
public CChallengeRounds(int numRounds, int numPlayer, int numPlayerAtOnce)
|
||||
{
|
||||
Rounds = new List<Combination>();
|
||||
Rounds = new List<CCombination>();
|
||||
_Rand = new Random(DateTime.Now.Millisecond);
|
||||
|
||||
if (NumPlayerAtOnce < 1 || NumRounds < 1 || NumPlayer == 0)
|
||||
if (numPlayerAtOnce < 1 || numRounds < 1 || numPlayer == 0)
|
||||
_NumPlayer = 0;
|
||||
else
|
||||
{
|
||||
_NumPlayer = NumPlayer;
|
||||
BuildRounds(NumRounds, NumPlayerAtOnce, _Rand);
|
||||
_NumPlayer = numPlayer;
|
||||
_BuildRounds(numRounds, numPlayerAtOnce, _Rand);
|
||||
}
|
||||
}
|
||||
|
||||
public Combination GetRound(int RoundNr)
|
||||
public CCombination GetRound(int roundNr)
|
||||
{
|
||||
if (RoundNr >= Rounds.Count || _NumPlayer == 0 || Rounds.Count == 0)
|
||||
if (roundNr >= Rounds.Count || _NumPlayer == 0 || Rounds.Count == 0)
|
||||
return null;
|
||||
|
||||
return Rounds[RoundNr];
|
||||
return Rounds[roundNr];
|
||||
}
|
||||
|
||||
private void BuildRounds(int NumRounds, int NumPlayerAtOnce, Random Rand)
|
||||
private void _BuildRounds(int numRounds, int numPlayerAtOnce, Random rand)
|
||||
{
|
||||
Combinations Combinations = new Combinations(_NumPlayer, NumPlayerAtOnce, Rand);
|
||||
Rounds.Add(Combinations.GetNextCombination(null));
|
||||
CCombinations combinations = new CCombinations(_NumPlayer, numPlayerAtOnce, rand);
|
||||
Rounds.Add(combinations.GetNextCombination(null));
|
||||
|
||||
for (int i = 1; i < NumRounds; i++)
|
||||
Rounds.Add(Combinations.GetNextCombination(GetPlayerDemand(i)));
|
||||
for (int i = 1; i < numRounds; i++)
|
||||
Rounds.Add(combinations.GetNextCombination(_GetPlayerDemand(i)));
|
||||
}
|
||||
|
||||
private List<int> GetPlayerDemand(int RoundIndex)
|
||||
private List<int> _GetPlayerDemand(int roundIndex)
|
||||
{
|
||||
List<int> NumPlayed = new List<int>(_NumPlayer);
|
||||
List<int> numPlayed = new List<int>(_NumPlayer);
|
||||
for (int i = 0; i < _NumPlayer; i++)
|
||||
NumPlayed.Add(0);
|
||||
numPlayed.Add(0);
|
||||
|
||||
for (int i = 0; i < RoundIndex; i++)
|
||||
for (int i = 0; i < roundIndex; i++)
|
||||
{
|
||||
foreach (int PlayerIndex in Rounds[i].Player)
|
||||
NumPlayed[PlayerIndex]++;
|
||||
foreach (int playerIndex in Rounds[i].Player)
|
||||
numPlayed[playerIndex]++;
|
||||
}
|
||||
|
||||
int max = 0;
|
||||
foreach (int p in NumPlayed)
|
||||
foreach (int p in numPlayed)
|
||||
{
|
||||
if (p > max)
|
||||
max = p;
|
||||
@@ -65,20 +65,20 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
List<int> other = new List<int>();
|
||||
List<int> last = new List<int>();
|
||||
|
||||
for (int i = 0; i < NumPlayed.Count; i++)
|
||||
for (int i = 0; i < numPlayed.Count; i++)
|
||||
{
|
||||
if (RoundIndex == 0 || NumPlayed[i] < max)
|
||||
if (roundIndex == 0 || numPlayed[i] < max)
|
||||
{
|
||||
if (RoundIndex == 0 || RoundIndex > 0 && NumPlayed[i] < max && !Rounds[RoundIndex - 1].IsAvailable(i))
|
||||
if (roundIndex == 0 || roundIndex > 0 && numPlayed[i] < max && !Rounds[roundIndex - 1].IsAvailable(i))
|
||||
result.Add(i);
|
||||
else if (NumPlayed[i] < max)
|
||||
else if (numPlayed[i] < max)
|
||||
other.Add(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RoundIndex > 0)
|
||||
if (roundIndex > 0)
|
||||
{
|
||||
if (!Rounds[RoundIndex - 1].IsAvailable(i))
|
||||
if (!Rounds[roundIndex - 1].IsAvailable(i))
|
||||
other.Add(i);
|
||||
else
|
||||
last.Add(i);
|
||||
@@ -116,48 +116,48 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
}
|
||||
}
|
||||
|
||||
class Combinations
|
||||
class CCombinations
|
||||
{
|
||||
private readonly List<Combination> _Combs;
|
||||
private readonly List<CCombination> _Combs;
|
||||
private readonly Random _Rand;
|
||||
private readonly int _NumPlayer;
|
||||
private readonly int _NumMics;
|
||||
|
||||
public Combinations(int NumPlayer, int NumMics, Random Rand)
|
||||
public CCombinations(int numPlayer, int numMics, Random rand)
|
||||
{
|
||||
_Combs = new List<Combination>();
|
||||
_NumMics = NumMics;
|
||||
_NumPlayer = NumPlayer;
|
||||
_Rand = Rand;
|
||||
_Combs = new List<CCombination>();
|
||||
_NumMics = numMics;
|
||||
_NumPlayer = numPlayer;
|
||||
_Rand = rand;
|
||||
}
|
||||
|
||||
public Combination GetNextCombination(List<int> PlayerNrDemand)
|
||||
public CCombination GetNextCombination(List<int> playerNrDemand)
|
||||
{
|
||||
if (_Combs.Count == 0)
|
||||
Create();
|
||||
_Create();
|
||||
|
||||
Combination combs = new Combination();
|
||||
CCombination combs = new CCombination();
|
||||
|
||||
if (_NumPlayer == _NumMics)
|
||||
return _Combs[0];
|
||||
|
||||
//filter against PlayerNrDemand
|
||||
List<Combination> combsFiltered = new List<Combination>();
|
||||
if (PlayerNrDemand != null)
|
||||
List<CCombination> combsFiltered = new List<CCombination>();
|
||||
if (playerNrDemand != null)
|
||||
{
|
||||
for (int i = 0; i < _Combs.Count; i++)
|
||||
{
|
||||
if (_Combs[i].IsAvailableAll(PlayerNrDemand))
|
||||
if (_Combs[i].IsAvailableAll(playerNrDemand))
|
||||
combsFiltered.Add(_Combs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//1st fallback
|
||||
if (PlayerNrDemand != null && combsFiltered.Count == 0)
|
||||
if (playerNrDemand != null && combsFiltered.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < _Combs.Count; i++)
|
||||
{
|
||||
if (_Combs[i].IsAvailableSomeone(PlayerNrDemand))
|
||||
if (_Combs[i].IsAvailableSomeone(playerNrDemand))
|
||||
combsFiltered.Add(_Combs[i]);
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
|
||||
int num = combsFiltered.Count;
|
||||
int rand = _Rand.Next(num);
|
||||
Combination c = new Combination();
|
||||
CCombination c = new CCombination();
|
||||
for (int i = 0; i < combsFiltered[rand].Player.Count; i++)
|
||||
c.Player.Add(combsFiltered[rand].Player[i]);
|
||||
_Combs.Remove(combsFiltered[rand]);
|
||||
@@ -179,7 +179,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
return combsFiltered[rand];
|
||||
}
|
||||
|
||||
private void Create()
|
||||
private void _Create()
|
||||
{
|
||||
_Combs.Clear();
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
|
||||
for (int i = 1; i <= num; i++)
|
||||
{
|
||||
Combination c = new Combination();
|
||||
CCombination c = new CCombination();
|
||||
|
||||
for (int j = 0; j < _NumPlayer; j++)
|
||||
{
|
||||
@@ -201,37 +201,37 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
}
|
||||
}
|
||||
|
||||
public class Combination
|
||||
public class CCombination
|
||||
{
|
||||
public List<int> Player;
|
||||
|
||||
public Combination()
|
||||
public CCombination()
|
||||
{
|
||||
Player = new List<int>();
|
||||
}
|
||||
|
||||
public bool IsAvailable(int PlayerIndex)
|
||||
public bool IsAvailable(int playerIndex)
|
||||
{
|
||||
foreach (int p in Player)
|
||||
{
|
||||
if (p == PlayerIndex)
|
||||
if (p == playerIndex)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsAvailableAll(List<int> PlayerIndices)
|
||||
public bool IsAvailableAll(List<int> playerIndices)
|
||||
{
|
||||
bool result = true;
|
||||
foreach (int p in PlayerIndices)
|
||||
foreach (int p in playerIndices)
|
||||
result &= IsAvailable(p);
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool IsAvailableSomeone(List<int> PlayerIndices)
|
||||
public bool IsAvailableSomeone(List<int> playerIndices)
|
||||
{
|
||||
bool result = false;
|
||||
foreach (int p in PlayerIndices)
|
||||
foreach (int p in playerIndices)
|
||||
result |= IsAvailable(p);
|
||||
return result;
|
||||
}
|
||||
+212
-212
@@ -12,30 +12,30 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
#region Communication
|
||||
|
||||
#region ToScreen
|
||||
public struct DataToScreenConfig
|
||||
public struct SDataToScreenConfig
|
||||
{
|
||||
public int NumPlayer;
|
||||
public int NumPlayerAtOnce;
|
||||
public int NumRounds;
|
||||
}
|
||||
|
||||
public struct DataToScreenNames
|
||||
public struct SDataToScreenNames
|
||||
{
|
||||
public int NumPlayer;
|
||||
public List<int> ProfileIDs;
|
||||
}
|
||||
|
||||
public struct DataToScreenMain
|
||||
public struct SDataToScreenMain
|
||||
{
|
||||
public int CurrentRoundNr;
|
||||
public int NumPlayerAtOnce;
|
||||
public List<Combination> Combs;
|
||||
public List<CCombination> Combs;
|
||||
public int[,] Results;
|
||||
public List<ResultTableRow> ResultTable;
|
||||
public List<CResultTableRow> ResultTable;
|
||||
public List<int> ProfileIDs;
|
||||
}
|
||||
|
||||
public class ResultTableRow : IComparable
|
||||
public class CResultTableRow : IComparable
|
||||
{
|
||||
public int Position;
|
||||
public int PlayerID;
|
||||
@@ -47,9 +47,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (obj is ResultTableRow)
|
||||
if (obj is CResultTableRow)
|
||||
{
|
||||
ResultTableRow row = (ResultTableRow)obj;
|
||||
CResultTableRow row = (CResultTableRow)obj;
|
||||
|
||||
int res = row.NumGamePoints.CompareTo(NumGamePoints);
|
||||
if (res == 0)
|
||||
@@ -67,28 +67,28 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
#endregion ToScreen
|
||||
|
||||
#region FromScreen
|
||||
public struct DataFromScreen
|
||||
public struct SDataFromScreen
|
||||
{
|
||||
public FromScreenConfig ScreenConfig;
|
||||
public FromScreenNames ScreenNames;
|
||||
public FromScreenMain ScreenMain;
|
||||
public SFromScreenConfig ScreenConfig;
|
||||
public SFromScreenNames ScreenNames;
|
||||
public SFromScreenMain ScreenMain;
|
||||
}
|
||||
|
||||
public struct FromScreenConfig
|
||||
public struct SFromScreenConfig
|
||||
{
|
||||
public int NumPlayer;
|
||||
public int NumPlayerAtOnce;
|
||||
public int NumRounds;
|
||||
}
|
||||
|
||||
public struct FromScreenNames
|
||||
public struct SFromScreenNames
|
||||
{
|
||||
public bool FadeToConfig;
|
||||
public bool FadeToMain;
|
||||
public List<int> ProfileIDs;
|
||||
}
|
||||
|
||||
public struct FromScreenMain
|
||||
public struct SFromScreenMain
|
||||
{
|
||||
public bool FadeToSongSelection;
|
||||
public bool FadeToNameSelection;
|
||||
@@ -97,14 +97,14 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
|
||||
#endregion Communication
|
||||
|
||||
public sealed class PartyModeChallengeMedley : CPartyMode
|
||||
public sealed class CPartyModeChallengeMedley : CPartyMode
|
||||
{
|
||||
private const int MaxPlayer = 12;
|
||||
private const int MinPlayer = 1;
|
||||
private const int MaxTeams = 0;
|
||||
private const int MinTeams = 0;
|
||||
private const int MaxNumRounds = 100;
|
||||
private const int NumSongs = 5;
|
||||
private const int _MaxPlayer = 12;
|
||||
private const int _MinPlayer = 1;
|
||||
private const int _MaxTeams = 0;
|
||||
private const int _MinTeams = 0;
|
||||
private const int _MaxNumRounds = 100;
|
||||
private const int _NumSongs = 5;
|
||||
|
||||
private enum EStage
|
||||
{
|
||||
@@ -115,15 +115,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
Singing
|
||||
}
|
||||
|
||||
private struct Data
|
||||
private struct SData
|
||||
{
|
||||
public int NumPlayer;
|
||||
public int NumPlayerAtOnce;
|
||||
public int NumRounds;
|
||||
public List<int> ProfileIDs;
|
||||
|
||||
public ChallengeRounds Rounds;
|
||||
public List<ResultTableRow> ResultTable;
|
||||
public CChallengeRounds Rounds;
|
||||
public List<CResultTableRow> ResultTable;
|
||||
public int[,] Results;
|
||||
|
||||
public int CurrentRoundNr;
|
||||
@@ -131,7 +131,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
public int[] CatSongIndices;
|
||||
}
|
||||
|
||||
private struct Stats
|
||||
private struct SStats
|
||||
{
|
||||
public int ProfileID;
|
||||
public int SingPoints;
|
||||
@@ -139,14 +139,14 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
public int Won;
|
||||
}
|
||||
|
||||
private DataToScreenConfig ToScreenConfig;
|
||||
private DataToScreenNames ToScreenNames;
|
||||
private DataToScreenMain ToScreenMain;
|
||||
private SDataToScreenConfig _ToScreenConfig;
|
||||
private SDataToScreenNames _ToScreenNames;
|
||||
private SDataToScreenMain _ToScreenMain;
|
||||
|
||||
private Data GameData;
|
||||
private SData _GameData;
|
||||
private EStage _Stage;
|
||||
|
||||
public PartyModeChallengeMedley()
|
||||
public CPartyModeChallengeMedley()
|
||||
{
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;
|
||||
_ScreenSongOptions.Selection.PartyMode = true;
|
||||
@@ -160,18 +160,18 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
|
||||
_Stage = EStage.NotStarted;
|
||||
|
||||
ToScreenConfig = new DataToScreenConfig();
|
||||
ToScreenNames = new DataToScreenNames();
|
||||
ToScreenMain = new DataToScreenMain();
|
||||
_ToScreenConfig = new SDataToScreenConfig();
|
||||
_ToScreenNames = new SDataToScreenNames();
|
||||
_ToScreenMain = new SDataToScreenMain();
|
||||
|
||||
GameData = new Data();
|
||||
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();
|
||||
_GameData.NumPlayer = 4;
|
||||
_GameData.NumPlayerAtOnce = 2;
|
||||
_GameData.NumRounds = 2;
|
||||
_GameData.CurrentRoundNr = 1;
|
||||
_GameData.ProfileIDs = new List<int>();
|
||||
_GameData.CatSongIndices = null;
|
||||
_GameData.Results = null;
|
||||
}
|
||||
|
||||
public override bool Init()
|
||||
@@ -186,8 +186,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
if (CBase.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE)
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
|
||||
|
||||
ToScreenMain.ResultTable = new List<ResultTableRow>();
|
||||
GameData.ResultTable = new List<ResultTableRow>();
|
||||
_ToScreenMain.ResultTable = new List<CResultTableRow>();
|
||||
_GameData.ResultTable = new List<CResultTableRow>();
|
||||
|
||||
CBase.Songs.SortSongs(ESongSorting.TR_CONFIG_NONE, EOffOn.TR_CONFIG_OFF, EOffOn.TR_CONFIG_OFF, String.Empty, EDuetOptions.NoDuets);
|
||||
CBase.Songs.SetCategory(0);
|
||||
@@ -195,38 +195,38 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void DataFromScreen(string ScreenName, Object Data)
|
||||
public override void DataFromScreen(string screenName, Object data)
|
||||
{
|
||||
DataFromScreen data = new DataFromScreen();
|
||||
switch (ScreenName)
|
||||
SDataFromScreen dataFrom = new SDataFromScreen();
|
||||
switch (screenName)
|
||||
{
|
||||
case "PartyScreenChallengeMedleyConfig":
|
||||
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
GameData.NumPlayer = data.ScreenConfig.NumPlayer;
|
||||
GameData.NumPlayerAtOnce = data.ScreenConfig.NumPlayerAtOnce;
|
||||
GameData.NumRounds = data.ScreenConfig.NumRounds;
|
||||
dataFrom = (SDataFromScreen)data;
|
||||
_GameData.NumPlayer = dataFrom.ScreenConfig.NumPlayer;
|
||||
_GameData.NumPlayerAtOnce = dataFrom.ScreenConfig.NumPlayerAtOnce;
|
||||
_GameData.NumRounds = dataFrom.ScreenConfig.NumRounds;
|
||||
|
||||
_Stage = EStage.Config;
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + screenName + ". " + e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PartyScreenChallengeMedleyNames":
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
if (data.ScreenNames.FadeToConfig)
|
||||
dataFrom = (SDataFromScreen)data;
|
||||
if (dataFrom.ScreenNames.FadeToConfig)
|
||||
_Stage = EStage.NotStarted;
|
||||
else
|
||||
{
|
||||
GameData.ProfileIDs = data.ScreenNames.ProfileIDs;
|
||||
_GameData.ProfileIDs = dataFrom.ScreenNames.ProfileIDs;
|
||||
_Stage = EStage.Names;
|
||||
}
|
||||
|
||||
@@ -234,33 +234,33 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + screenName + ". " + e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PartyScreenChallengeMedleyMain":
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
if (data.ScreenMain.FadeToSongSelection)
|
||||
dataFrom = (SDataFromScreen)data;
|
||||
if (dataFrom.ScreenMain.FadeToSongSelection)
|
||||
_Stage = EStage.Singing;
|
||||
if (data.ScreenMain.FadeToNameSelection)
|
||||
if (dataFrom.ScreenMain.FadeToNameSelection)
|
||||
_Stage = EStage.Config;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
CBase.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + screenName + ". " + e.Message);
|
||||
}
|
||||
|
||||
|
||||
if (_Stage == EStage.Singing)
|
||||
StartNextRound();
|
||||
_StartNextRound();
|
||||
if (_Stage == EStage.Config)
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
break;
|
||||
|
||||
default:
|
||||
CBase.Log.LogError("Error in party mode challenge. Wrong screen is sending: " + ScreenName);
|
||||
CBase.Log.LogError("Error in party mode challenge. Wrong screen is sending: " + screenName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -274,68 +274,68 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;*/
|
||||
}
|
||||
|
||||
public override CMenuParty GetNextPartyScreen(out EScreens AlternativeScreen)
|
||||
public override CMenuParty GetNextPartyScreen(out EScreens alternativeScreen)
|
||||
{
|
||||
CMenuParty Screen = null;
|
||||
AlternativeScreen = EScreens.ScreenSong;
|
||||
CMenuParty screen = null;
|
||||
alternativeScreen = EScreens.ScreenSong;
|
||||
|
||||
switch (_Stage)
|
||||
{
|
||||
case EStage.NotStarted:
|
||||
_Screens.TryGetValue("PartyScreenChallengeMedleyConfig", out Screen);
|
||||
if (_Screens != null)
|
||||
_Screens.TryGetValue("CPartyScreenChallengeMedleyConfig", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
ToScreenConfig.NumPlayer = GameData.NumPlayer;
|
||||
ToScreenConfig.NumPlayerAtOnce = GameData.NumPlayerAtOnce;
|
||||
ToScreenConfig.NumRounds = GameData.NumRounds;
|
||||
Screen.DataToScreen(ToScreenConfig);
|
||||
_ToScreenConfig.NumPlayer = _GameData.NumPlayer;
|
||||
_ToScreenConfig.NumPlayerAtOnce = _GameData.NumPlayerAtOnce;
|
||||
_ToScreenConfig.NumRounds = _GameData.NumRounds;
|
||||
screen.DataToScreen(_ToScreenConfig);
|
||||
}
|
||||
break;
|
||||
case EStage.Config:
|
||||
_Screens.TryGetValue("PartyScreenChallengeMedleyNames", out Screen);
|
||||
if (_Screens != null)
|
||||
_Screens.TryGetValue("CPartyScreenChallengeMedleyNames", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
ToScreenNames.NumPlayer = GameData.NumPlayer;
|
||||
ToScreenNames.ProfileIDs = GameData.ProfileIDs;
|
||||
Screen.DataToScreen(ToScreenNames);
|
||||
_ToScreenNames.NumPlayer = _GameData.NumPlayer;
|
||||
_ToScreenNames.ProfileIDs = _GameData.ProfileIDs;
|
||||
screen.DataToScreen(_ToScreenNames);
|
||||
}
|
||||
break;
|
||||
case EStage.Names:
|
||||
_Screens.TryGetValue("PartyScreenChallengeMedleyMain", out Screen);
|
||||
if (_Screens != null)
|
||||
_Screens.TryGetValue("CPartyScreenChallengeMedleyMain", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
CBase.Songs.ResetPartySongSung();
|
||||
ToScreenMain.ResultTable = new List<ResultTableRow>();
|
||||
GameData.ResultTable = new List<ResultTableRow>();
|
||||
GameData.Rounds = new ChallengeRounds(GameData.NumRounds, GameData.NumPlayer, GameData.NumPlayerAtOnce);
|
||||
GameData.CurrentRoundNr = 1;
|
||||
ToScreenMain.CurrentRoundNr = 1;
|
||||
ToScreenMain.NumPlayerAtOnce = GameData.NumPlayerAtOnce;
|
||||
ToScreenMain.Combs = GameData.Rounds.Rounds;
|
||||
ToScreenMain.ProfileIDs = GameData.ProfileIDs;
|
||||
UpdateScores();
|
||||
ToScreenMain.ResultTable = GameData.ResultTable;
|
||||
ToScreenMain.Results = GameData.Results;
|
||||
Screen.DataToScreen(ToScreenMain);
|
||||
_ToScreenMain.ResultTable = new List<CResultTableRow>();
|
||||
_GameData.ResultTable = new List<CResultTableRow>();
|
||||
_GameData.Rounds = new CChallengeRounds(_GameData.NumRounds, _GameData.NumPlayer, _GameData.NumPlayerAtOnce);
|
||||
_GameData.CurrentRoundNr = 1;
|
||||
_ToScreenMain.CurrentRoundNr = 1;
|
||||
_ToScreenMain.NumPlayerAtOnce = _GameData.NumPlayerAtOnce;
|
||||
_ToScreenMain.Combs = _GameData.Rounds.Rounds;
|
||||
_ToScreenMain.ProfileIDs = _GameData.ProfileIDs;
|
||||
_UpdateScores();
|
||||
_ToScreenMain.ResultTable = _GameData.ResultTable;
|
||||
_ToScreenMain.Results = _GameData.Results;
|
||||
screen.DataToScreen(_ToScreenMain);
|
||||
}
|
||||
break;
|
||||
case EStage.Main:
|
||||
//nothing to do
|
||||
break;
|
||||
case EStage.Singing:
|
||||
_Screens.TryGetValue("PartyScreenChallengeMedleyMain", out Screen);
|
||||
if (_Screens != null)
|
||||
_Screens.TryGetValue("CPartyScreenChallengeMedleyMain", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
UpdateScores();
|
||||
ToScreenMain.CurrentRoundNr = GameData.CurrentRoundNr;
|
||||
ToScreenMain.Combs = GameData.Rounds.Rounds;
|
||||
ToScreenMain.Results = GameData.Results;
|
||||
Screen.DataToScreen(ToScreenMain);
|
||||
_UpdateScores();
|
||||
_ToScreenMain.CurrentRoundNr = _GameData.CurrentRoundNr;
|
||||
_ToScreenMain.Combs = _GameData.Rounds.Rounds;
|
||||
_ToScreenMain.Results = _GameData.Results;
|
||||
screen.DataToScreen(_ToScreenMain);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Screen;
|
||||
return screen;
|
||||
}
|
||||
|
||||
public override EScreens GetStartScreen()
|
||||
@@ -348,7 +348,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
return EScreens.ScreenPartyDummy;
|
||||
}
|
||||
|
||||
public override ScreenSongOptions GetScreenSongOptions()
|
||||
public override SScreenSongOptions GetScreenSongOptions()
|
||||
{
|
||||
_ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting();
|
||||
_ScreenSongOptions.Sorting.Tabs = CBase.Config.GetTabs();
|
||||
@@ -357,130 +357,130 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
return _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void OnSongChange(int SongIndex, ref ScreenSongOptions ScreenSongOptions)
|
||||
public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
|
||||
{
|
||||
if (_ScreenSongOptions.Selection.SongIndex != -1)
|
||||
_ScreenSongOptions.Selection.SongIndex = -1;
|
||||
|
||||
if (_ScreenSongOptions.Selection.SelectNextRandomSong && SongIndex != -1)
|
||||
if (_ScreenSongOptions.Selection.SelectNextRandomSong && songIndex != -1)
|
||||
{
|
||||
_ScreenSongOptions.Selection.SelectNextRandomSong = false;
|
||||
CreateCatSongIndices();
|
||||
_CreateCatSongIndices();
|
||||
|
||||
if (GameData.CatSongIndices != null)
|
||||
if (_GameData.CatSongIndices != null)
|
||||
{
|
||||
if (GameData.CatSongIndices[CBase.Songs.GetCurrentCategoryIndex()] == -1)
|
||||
GameData.CatSongIndices[CBase.Songs.GetCurrentCategoryIndex()] = SongIndex;
|
||||
if (_GameData.CatSongIndices[CBase.Songs.GetCurrentCategoryIndex()] == -1)
|
||||
_GameData.CatSongIndices[CBase.Songs.GetCurrentCategoryIndex()] = songIndex;
|
||||
}
|
||||
}
|
||||
|
||||
ScreenSongOptions = _ScreenSongOptions;
|
||||
screenSongOptions = _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void OnCategoryChange(int CategoryIndex, ref ScreenSongOptions ScreenSongOptions)
|
||||
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
|
||||
{
|
||||
if (GameData.CatSongIndices != null && CategoryIndex != -1)
|
||||
if (_GameData.CatSongIndices != null && categoryIndex != -1)
|
||||
{
|
||||
if (GameData.CatSongIndices[CategoryIndex] == -1)
|
||||
if (_GameData.CatSongIndices[categoryIndex] == -1)
|
||||
_ScreenSongOptions.Selection.SelectNextRandomSong = true;
|
||||
else
|
||||
_ScreenSongOptions.Selection.SongIndex = GameData.CatSongIndices[CategoryIndex];
|
||||
_ScreenSongOptions.Selection.SongIndex = _GameData.CatSongIndices[categoryIndex];
|
||||
}
|
||||
|
||||
if (GameData.CatSongIndices == null && CategoryIndex != -1)
|
||||
if (_GameData.CatSongIndices == null && categoryIndex != -1)
|
||||
_ScreenSongOptions.Selection.SelectNextRandomSong = true;
|
||||
|
||||
if (CategoryIndex == -1)
|
||||
if (categoryIndex == -1)
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;
|
||||
|
||||
if (_ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF || CategoryIndex != -1)
|
||||
if (_ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF || categoryIndex != -1)
|
||||
_ScreenSongOptions.Selection.RandomOnly = true;
|
||||
|
||||
ScreenSongOptions = _ScreenSongOptions;
|
||||
screenSongOptions = _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void SetSearchString(string SearchString, bool Visible)
|
||||
public override void SetSearchString(string searchString, bool visible)
|
||||
{
|
||||
_ScreenSongOptions.Sorting.SearchString = SearchString;
|
||||
_ScreenSongOptions.Sorting.SearchActive = Visible;
|
||||
_ScreenSongOptions.Sorting.SearchString = searchString;
|
||||
_ScreenSongOptions.Sorting.SearchActive = visible;
|
||||
}
|
||||
|
||||
public override int GetMaxPlayer()
|
||||
{
|
||||
return MaxPlayer;
|
||||
return _MaxPlayer;
|
||||
}
|
||||
|
||||
public override int GetMinPlayer()
|
||||
{
|
||||
return MinPlayer;
|
||||
return _MinPlayer;
|
||||
}
|
||||
|
||||
public override int GetMaxTeams()
|
||||
{
|
||||
return MaxTeams;
|
||||
return _MaxTeams;
|
||||
}
|
||||
|
||||
public override int GetMinTeams()
|
||||
{
|
||||
return MinTeams;
|
||||
return _MinTeams;
|
||||
}
|
||||
|
||||
public override int GetMaxNumRounds()
|
||||
{
|
||||
return MaxNumRounds;
|
||||
return _MaxNumRounds;
|
||||
}
|
||||
|
||||
public override void JokerUsed(int TeamNr)
|
||||
public override void JokerUsed(int teamNr)
|
||||
{
|
||||
if (_ScreenSongOptions.Selection.NumJokers == null)
|
||||
return;
|
||||
|
||||
if (TeamNr >= _ScreenSongOptions.Selection.NumJokers.Length)
|
||||
if (teamNr >= _ScreenSongOptions.Selection.NumJokers.Length)
|
||||
return;
|
||||
|
||||
_ScreenSongOptions.Selection.NumJokers[TeamNr]--;
|
||||
_ScreenSongOptions.Selection.NumJokers[teamNr]--;
|
||||
_ScreenSongOptions.Selection.RandomOnly = true;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
|
||||
}
|
||||
|
||||
public override void SongSelected(int SongID) {}
|
||||
public override void SongSelected(int songID) {}
|
||||
|
||||
public override void LeavingHighscore()
|
||||
{
|
||||
GameData.CurrentRoundNr++;
|
||||
_GameData.CurrentRoundNr++;
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
|
||||
private void StartNextRound()
|
||||
private void _StartNextRound()
|
||||
{
|
||||
_ScreenSongOptions.Selection.RandomOnly = _ScreenSongOptions.Sorting.Tabs != EOffOn.TR_CONFIG_ON;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON;
|
||||
SetNumJokers();
|
||||
SetTeamNames();
|
||||
GameData.CatSongIndices = null;
|
||||
_SetNumJokers();
|
||||
_SetTeamNames();
|
||||
_GameData.CatSongIndices = null;
|
||||
|
||||
if (RandomizeSongs())
|
||||
if (_RandomizeSongs())
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenSing);
|
||||
}
|
||||
|
||||
private bool RandomizeSongs()
|
||||
private bool _RandomizeSongs()
|
||||
{
|
||||
CBase.Game.Reset();
|
||||
CBase.Game.ClearSongs();
|
||||
|
||||
#region PlayerNames
|
||||
CBase.Game.SetNumPlayer(GameData.NumPlayerAtOnce);
|
||||
CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce);
|
||||
SPlayer[] player = CBase.Game.GetPlayer();
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
if (player.Length < GameData.NumPlayerAtOnce)
|
||||
if (player.Length < _GameData.NumPlayerAtOnce)
|
||||
return false;
|
||||
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
Combination c = GameData.Rounds.GetRound(GameData.CurrentRoundNr - 1);
|
||||
CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1);
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//default values
|
||||
player[i].Name = "foobar";
|
||||
@@ -490,63 +490,63 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
//try to fill with the right data
|
||||
if (c != null)
|
||||
{
|
||||
if (GameData.ProfileIDs[c.Player[i]] < profiles.Length)
|
||||
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].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]];
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion PlayerNames
|
||||
|
||||
#region SongQueque
|
||||
if (CBase.Songs.GetNumVisibleSongs() < NumSongs)
|
||||
if (CBase.Songs.GetNumVisibleSongs() < _NumSongs)
|
||||
CBase.Songs.ResetPartySongSung();
|
||||
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_MEDLEY;
|
||||
List<int> IDs = new List<int>();
|
||||
List<int> iDs = new List<int>();
|
||||
|
||||
CSong[] VisSongs = CBase.Songs.GetSongsNotSung();
|
||||
if (VisSongs == null)
|
||||
CSong[] visSongs = CBase.Songs.GetSongsNotSung();
|
||||
if (visSongs == null)
|
||||
{
|
||||
CBase.Log.LogError("PartyChallengeMedleyMode Error: There are no songs!");
|
||||
CBase.Log.LogError("CPartyChallengeMedleyMode Error: There are no songs!");
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenParty);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < VisSongs.Length; i++)
|
||||
for (int i = 0; i < visSongs.Length; i++)
|
||||
{
|
||||
foreach (EGameMode mode in VisSongs[i].AvailableGameModes)
|
||||
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("PartyChallengeMedleyMode Error: There are no medley songs!");
|
||||
CBase.Log.LogError("CPartyChallengeMedleyMode Error: There are no medley songs!");
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenParty);
|
||||
return false;
|
||||
}
|
||||
|
||||
int s = 0;
|
||||
while (s < NumSongs && IDs.Count > 0)
|
||||
while (s < _NumSongs && iDs.Count > 0)
|
||||
{
|
||||
int SongID = IDs[CBase.Game.GetRandom(IDs.Count)];
|
||||
CBase.Game.AddSong(SongID, gm);
|
||||
CBase.Songs.AddPartySongSung(SongID);
|
||||
IDs.Remove(SongID);
|
||||
int songID = iDs[CBase.Game.GetRandom(iDs.Count)];
|
||||
CBase.Game.AddSong(songID, gm);
|
||||
CBase.Songs.AddPartySongSung(songID);
|
||||
iDs.Remove(songID);
|
||||
s++;
|
||||
}
|
||||
return true;
|
||||
#endregion SongQueque
|
||||
}
|
||||
|
||||
private void SetNumJokers()
|
||||
private void _SetNumJokers()
|
||||
{
|
||||
switch (GameData.NumPlayerAtOnce)
|
||||
switch (_GameData.NumPlayerAtOnce)
|
||||
{
|
||||
case 1:
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] {10};
|
||||
@@ -577,7 +577,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTeamNames()
|
||||
private void _SetTeamNames()
|
||||
{
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
@@ -587,21 +587,21 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameData.NumPlayerAtOnce < 1 || GameData.ProfileIDs.Count < GameData.NumPlayerAtOnce || profiles.Length < GameData.NumPlayerAtOnce)
|
||||
if (_GameData.NumPlayerAtOnce < 1 || _GameData.ProfileIDs.Count < _GameData.NumPlayerAtOnce || profiles.Length < _GameData.NumPlayerAtOnce)
|
||||
{
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"};
|
||||
return;
|
||||
}
|
||||
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[GameData.NumPlayerAtOnce];
|
||||
Combination c = GameData.Rounds.GetRound(GameData.CurrentRoundNr - 1);
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[_GameData.NumPlayerAtOnce];
|
||||
CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1);
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
if (c != null)
|
||||
{
|
||||
if (GameData.ProfileIDs[c.Player[i]] < profiles.Length)
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = profiles[GameData.ProfileIDs[c.Player[i]]].PlayerName;
|
||||
if (_GameData.ProfileIDs[c.Player[i]] < profiles.Length)
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = profiles[_GameData.ProfileIDs[c.Player[i]]].PlayerName;
|
||||
else
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = "foobar";
|
||||
}
|
||||
@@ -610,66 +610,66 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateScores()
|
||||
private void _UpdateScores()
|
||||
{
|
||||
if (GameData.ResultTable.Count == 0)
|
||||
if (_GameData.ResultTable.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < GameData.NumPlayer; i++)
|
||||
for (int i = 0; i < _GameData.NumPlayer; i++)
|
||||
{
|
||||
ResultTableRow row = new ResultTableRow();
|
||||
row.PlayerID = GameData.ProfileIDs[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;
|
||||
GameData.ResultTable.Add(row);
|
||||
_GameData.ResultTable.Add(row);
|
||||
}
|
||||
|
||||
GameData.Results = new int[GameData.NumRounds,GameData.NumPlayerAtOnce];
|
||||
for (int i = 0; i < GameData.NumRounds; i++)
|
||||
_GameData.Results = new int[_GameData.NumRounds,_GameData.NumPlayerAtOnce];
|
||||
for (int i = 0; i < _GameData.NumRounds; i++)
|
||||
{
|
||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
||||
GameData.Results[i, j] = 0;
|
||||
for (int j = 0; j < _GameData.NumPlayerAtOnce; j++)
|
||||
_GameData.Results[i, j] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CPoints GamePoints = CBase.Game.GetPoints();
|
||||
if (GamePoints == null || GamePoints.NumPlayer < GameData.NumPlayerAtOnce)
|
||||
CPoints gamePoints = CBase.Game.GetPoints();
|
||||
if (gamePoints == null || gamePoints.NumPlayer < _GameData.NumPlayerAtOnce)
|
||||
return;
|
||||
|
||||
SPlayer[] results = GamePoints.GetPlayer(0, GameData.NumPlayerAtOnce);
|
||||
SPlayer[] results = gamePoints.GetPlayer(0, _GameData.NumPlayerAtOnce);
|
||||
if (results == null)
|
||||
return;
|
||||
|
||||
if (results.Length < GameData.NumPlayerAtOnce)
|
||||
if (results.Length < _GameData.NumPlayerAtOnce)
|
||||
return;
|
||||
|
||||
if (GamePoints.NumRounds == 0)
|
||||
if (gamePoints.NumRounds == 0)
|
||||
return;
|
||||
|
||||
for (int i = 1; i < GamePoints.NumRounds; i++)
|
||||
for (int i = 1; i < gamePoints.NumRounds; i++)
|
||||
{
|
||||
SPlayer[] temp = GamePoints.GetPlayer(i, GameData.NumPlayerAtOnce);
|
||||
for (int p = 0; p < GameData.NumPlayerAtOnce; p++)
|
||||
SPlayer[] temp = gamePoints.GetPlayer(i, _GameData.NumPlayerAtOnce);
|
||||
for (int p = 0; p < _GameData.NumPlayerAtOnce; p++)
|
||||
results[p].Points += temp[p].Points;
|
||||
}
|
||||
|
||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
||||
for (int j = 0; j < _GameData.NumPlayerAtOnce; j++)
|
||||
{
|
||||
results[j].Points = results[j].Points / GamePoints.NumRounds;
|
||||
GameData.Results[GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points);
|
||||
results[j].Points = results[j].Points / gamePoints.NumRounds;
|
||||
_GameData.Results[_GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points);
|
||||
}
|
||||
|
||||
List<Stats> points = GetPointsForPlayer(results);
|
||||
List<SStats> points = _GetPointsForPlayer(results);
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
int index = -1;
|
||||
for (int j = 0; j < GameData.ResultTable.Count; j++)
|
||||
for (int j = 0; j < _GameData.ResultTable.Count; j++)
|
||||
{
|
||||
if (points[i].ProfileID == GameData.ResultTable[j].PlayerID)
|
||||
if (points[i].ProfileID == _GameData.ResultTable[j].PlayerID)
|
||||
{
|
||||
index = j;
|
||||
break;
|
||||
@@ -678,7 +678,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
ResultTableRow row = GameData.ResultTable[index];
|
||||
CResultTableRow row = _GameData.ResultTable[index];
|
||||
|
||||
row.NumPlayed++;
|
||||
row.NumWon += points[i].Won;
|
||||
@@ -686,41 +686,41 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
row.NumSingPoints += points[i].SingPoints;
|
||||
row.NumGamePoints += points[i].GamePoints;
|
||||
|
||||
GameData.ResultTable[index] = row;
|
||||
_GameData.ResultTable[index] = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameData.ResultTable.Sort();
|
||||
_GameData.ResultTable.Sort();
|
||||
|
||||
//Update position-number
|
||||
int pos = 1;
|
||||
int lastPoints = 0;
|
||||
int lastSingPoints = 0;
|
||||
for (int i = 0; i < GameData.ResultTable.Count; i++)
|
||||
for (int i = 0; i < _GameData.ResultTable.Count; i++)
|
||||
{
|
||||
if (lastPoints > GameData.ResultTable[i].NumGamePoints || lastSingPoints > GameData.ResultTable[i].NumSingPoints)
|
||||
if (lastPoints > _GameData.ResultTable[i].NumGamePoints || lastSingPoints > _GameData.ResultTable[i].NumSingPoints)
|
||||
pos++;
|
||||
GameData.ResultTable[i].Position = pos;
|
||||
lastPoints = GameData.ResultTable[i].NumGamePoints;
|
||||
lastSingPoints = GameData.ResultTable[i].NumSingPoints;
|
||||
_GameData.ResultTable[i].Position = pos;
|
||||
lastPoints = _GameData.ResultTable[i].NumGamePoints;
|
||||
lastSingPoints = _GameData.ResultTable[i].NumSingPoints;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Stats> GetPointsForPlayer(SPlayer[] Results)
|
||||
private List<SStats> _GetPointsForPlayer(SPlayer[] results)
|
||||
{
|
||||
List<Stats> result = new List<Stats>();
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
List<SStats> result = new List<SStats>();
|
||||
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
Stats stat = new Stats();
|
||||
stat.ProfileID = Results[i].ProfileID;
|
||||
stat.SingPoints = (int)Math.Round(Results[i].Points);
|
||||
SStats stat = new SStats();
|
||||
stat.ProfileID = results[i].ProfileID;
|
||||
stat.SingPoints = (int)Math.Round(results[i].Points);
|
||||
stat.Won = 0;
|
||||
stat.GamePoints = 0;
|
||||
result.Add(stat);
|
||||
}
|
||||
|
||||
result.Sort(delegate(Stats s1, Stats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); });
|
||||
result.Sort(delegate(SStats s1, SStats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); });
|
||||
|
||||
int current = result[result.Count - 1].SingPoints;
|
||||
int points = result.Count;
|
||||
@@ -728,7 +728,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
|
||||
for (int i = result.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Stats res = result[i];
|
||||
SStats res = result[i];
|
||||
|
||||
if (i < result.Count - 1)
|
||||
{
|
||||
@@ -760,17 +760,17 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
return result;
|
||||
}
|
||||
|
||||
private void CreateCatSongIndices()
|
||||
private void _CreateCatSongIndices()
|
||||
{
|
||||
if (GameData.CatSongIndices == null && CBase.Songs.GetNumCategories() > 0 && _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON)
|
||||
if (_GameData.CatSongIndices == null && CBase.Songs.GetNumCategories() > 0 && _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
GameData.CatSongIndices = new int[CBase.Songs.GetNumCategories()];
|
||||
for (int i = 0; i < GameData.CatSongIndices.Length; i++)
|
||||
GameData.CatSongIndices[i] = -1;
|
||||
_GameData.CatSongIndices = new int[CBase.Songs.GetNumCategories()];
|
||||
for (int i = 0; i < _GameData.CatSongIndices.Length; i++)
|
||||
_GameData.CatSongIndices[i] = -1;
|
||||
}
|
||||
|
||||
if (CBase.Songs.GetNumCategories() == 0 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF)
|
||||
GameData.CatSongIndices = null;
|
||||
_GameData.CatSongIndices = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
{
|
||||
public class CPartyScreenChallengeMedleyConfig : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string _SelectSlideNumPlayers = "SelectSlideNumPlayers";
|
||||
private const string _SelectSlideNumMics = "SelectSlideNumMics";
|
||||
private const string _SelectSlideNumRounds = "SelectSlideNumRounds";
|
||||
private const string _ButtonNext = "ButtonNext";
|
||||
private const string _ButtonBack = "ButtonBack";
|
||||
|
||||
private int _MaxNumMics = 2;
|
||||
private int _MaxNumRounds = 100;
|
||||
private int _RoundSteps = 1;
|
||||
|
||||
private SDataFromScreen _Data;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeSelectSlides = new string[] {_SelectSlideNumPlayers, _SelectSlideNumMics, _SelectSlideNumRounds};
|
||||
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
|
||||
|
||||
_Data = new SDataFromScreen();
|
||||
SFromScreenConfig config = new SFromScreenConfig();
|
||||
config.NumPlayer = 4;
|
||||
config.NumPlayerAtOnce = 2;
|
||||
config.NumRounds = 12;
|
||||
_Data.ScreenConfig = config;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object receivedData)
|
||||
{
|
||||
SDataToScreenConfig config = new SDataToScreenConfig();
|
||||
|
||||
try
|
||||
{
|
||||
config = (SDataToScreenConfig)receivedData;
|
||||
_Data.ScreenConfig.NumPlayer = config.NumPlayer;
|
||||
_Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce;
|
||||
_Data.ScreenConfig.NumRounds = config.NumRounds;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge config. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
_Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
_UpdateSlides();
|
||||
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
_UpdateSlides();
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
_UpdateSlides();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
_UpdateSlides();
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
_Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
_MaxNumMics = CBase.Config.GetMaxNumMics();
|
||||
if (_MaxNumMics > 6)
|
||||
_MaxNumMics = 6;
|
||||
|
||||
_MaxNumRounds = _PartyMode.GetMaxNumRounds();
|
||||
|
||||
_RebuildSlides();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _RebuildSlides()
|
||||
{
|
||||
// build num player slide (min player ... max player);
|
||||
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();
|
||||
|
||||
_UpdateMicsAtOnce();
|
||||
_SetRoundSteps();
|
||||
_UpdateSlideRounds();
|
||||
}
|
||||
|
||||
private void _UpdateSlides()
|
||||
{
|
||||
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;
|
||||
|
||||
_UpdateMicsAtOnce();
|
||||
_SetRoundSteps();
|
||||
|
||||
if (player != _Data.ScreenConfig.NumPlayer || mics != _Data.ScreenConfig.NumPlayerAtOnce)
|
||||
{
|
||||
int num = CHelper.CombinationCount(_Data.ScreenConfig.NumPlayer, _Data.ScreenConfig.NumPlayerAtOnce);
|
||||
while (num > _MaxNumRounds)
|
||||
num -= _RoundSteps;
|
||||
_Data.ScreenConfig.NumRounds = num;
|
||||
}
|
||||
|
||||
_UpdateSlideRounds();
|
||||
}
|
||||
|
||||
private void _UpdateMicsAtOnce()
|
||||
{
|
||||
//Data.ScreenConfig.NumPlayerAtOnce
|
||||
int maxNum = _MaxNumMics;
|
||||
if (_Data.ScreenConfig.NumPlayer < _MaxNumMics)
|
||||
maxNum = _Data.ScreenConfig.NumPlayer;
|
||||
|
||||
if (_Data.ScreenConfig.NumPlayerAtOnce > maxNum)
|
||||
_Data.ScreenConfig.NumPlayerAtOnce = maxNum;
|
||||
|
||||
// build mics at once slide
|
||||
SelectSlides[_SelectSlideNumMics].Clear();
|
||||
for (int i = 1; i <= maxNum; i++)
|
||||
SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
|
||||
SelectSlides[_SelectSlideNumMics].Selection = _Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
|
||||
}
|
||||
|
||||
private void _UpdateSlideRounds()
|
||||
{
|
||||
// build num rounds slide
|
||||
SelectSlides[_SelectSlideNumRounds].Clear();
|
||||
for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
|
||||
SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString());
|
||||
SelectSlides[_SelectSlideNumRounds].Selection = _Data.ScreenConfig.NumRounds / _RoundSteps - 1;
|
||||
}
|
||||
|
||||
private void _SetRoundSteps()
|
||||
{
|
||||
if (_Data.ScreenConfig.NumPlayerAtOnce < 1 || _Data.ScreenConfig.NumPlayer < 1 || _Data.ScreenConfig.NumPlayerAtOnce > _Data.ScreenConfig.NumPlayer)
|
||||
{
|
||||
_RoundSteps = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private void _Back()
|
||||
{
|
||||
_FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void _Next()
|
||||
{
|
||||
_PartyMode.DataFromScreen(ThemeName, _Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,660 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
{
|
||||
struct STableRow
|
||||
{
|
||||
public CText Pos;
|
||||
public CText Name;
|
||||
public CText Rounds;
|
||||
public CText Won;
|
||||
public CText SingPoints;
|
||||
public CText GamePoints;
|
||||
}
|
||||
|
||||
class CRoundsTableRow
|
||||
{
|
||||
public CText Number;
|
||||
public List<CText> TextPlayer;
|
||||
public List<CText> TextScores;
|
||||
}
|
||||
|
||||
public class CPartyScreenChallengeMedleyMain : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string _TextPosition = "TextPosition";
|
||||
private const string _TextPlayerName = "TextPlayerName";
|
||||
private const string _TextNumPlayed = "TextNumPlayed";
|
||||
private const string _TextWon = "TextWon";
|
||||
private const string _TextSingPoints = "TextSingPoints";
|
||||
private const string _TextGamePoints = "TextGamePoints";
|
||||
private const string _TextNextPlayer = "TextNextPlayer";
|
||||
private const string _TextPopupReallyExit = "TextPopupReallyExit";
|
||||
private const string _TextRoundPlayer = "TextRoundPlayer";
|
||||
private const string _TextRoundScore = "TextRoundScore";
|
||||
private const string _TextRoundNumber = "TextRoundNumber";
|
||||
private const string _TextFinishMessage = "TextFinishMessage";
|
||||
private const string _TextFinishPlayerWin = "TextFinishPlayerWin";
|
||||
private const string _TextNextPlayerMessage = "TextNextPlayerMessage";
|
||||
|
||||
private const string _ButtonNextRound = "ButtonNextRound";
|
||||
private const string _ButtonBack = "ButtonBack";
|
||||
private const string _ButtonExit = "ButtonExit";
|
||||
private const string _ButtonPopupYes = "ButtonPopupYes";
|
||||
private const string _ButtonPopupNo = "ButtonPopupNo";
|
||||
private const string _ButtonPlayerScrollUp = "ButtonPlayerScrollUp";
|
||||
private const string _ButtonPlayerScrollDown = "ButtonPlayerScrollDown";
|
||||
private const string _ButtonRoundsScrollUp = "ButtonRoundsScrollUp";
|
||||
private const string _ButtonRoundsScrollDown = "ButtonRoundsScrollDown";
|
||||
|
||||
private const string _StaticPopupBG = "StaticPopupBG";
|
||||
private const string _StaticNextPlayer = "StaticNextPlayer";
|
||||
|
||||
private bool _ExitPopupVisible;
|
||||
|
||||
private SDataFromScreen _Data;
|
||||
private SDataToScreenMain _GameState;
|
||||
private List<STableRow> _PlayerTable;
|
||||
private List<CRoundsTableRow> _RoundsTable;
|
||||
|
||||
private List<CText> _NextPlayerTexts;
|
||||
private List<CStatic> _NextPlayerStatics;
|
||||
|
||||
private SRectF _RoundsTableScrollArea;
|
||||
private SRectF _PlayerTableScrollArea;
|
||||
private int _RoundsTableOffset;
|
||||
private int _PlayerTableOffset;
|
||||
private int _NumPlayerVisible = 10;
|
||||
private int _NumRoundsVisible = 3;
|
||||
|
||||
public CPartyScreenChallengeMedleyMain()
|
||||
{
|
||||
_Data = new SDataFromScreen();
|
||||
_Data.ScreenMain = new SFromScreenMain();
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeTexts = new string[]
|
||||
{
|
||||
_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};
|
||||
_ThemeStatics = new string[] {_StaticPopupBG, _StaticNextPlayer};
|
||||
}
|
||||
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
base.LoadTheme(xmlPath);
|
||||
|
||||
_GameState = new SDataToScreenMain();
|
||||
_BuildPlayerTable();
|
||||
_CreateRoundsTable();
|
||||
_NextPlayerTexts = new List<CText>();
|
||||
_NextPlayerStatics = new List<CStatic>();
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DataToScreen(object receivedData)
|
||||
{
|
||||
SDataToScreenMain data = new SDataToScreenMain();
|
||||
|
||||
try
|
||||
{
|
||||
data = (SDataToScreenMain)receivedData;
|
||||
_GameState = data;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge main. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_GameState.CurrentRoundNr == 1)
|
||||
_Back();
|
||||
else
|
||||
_ShowPopup(true);
|
||||
}
|
||||
else
|
||||
_ShowPopup(false);
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[_ButtonNextRound].Selected)
|
||||
_NextRound();
|
||||
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
|
||||
_Back();
|
||||
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
|
||||
_ShowPopup(true);
|
||||
if (Buttons[_ButtonPlayerScrollUp].Selected)
|
||||
_ScrollPlayerTable(-1);
|
||||
if (Buttons[_ButtonPlayerScrollDown].Selected)
|
||||
_ScrollPlayerTable(1);
|
||||
if (Buttons[_ButtonRoundsScrollUp].Selected)
|
||||
_ScrollRoundsTable(-1);
|
||||
if (Buttons[_ButtonRoundsScrollDown].Selected)
|
||||
_ScrollRoundsTable(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[_ButtonPopupYes].Selected)
|
||||
_EndParty();
|
||||
if (Buttons[_ButtonPopupNo].Selected)
|
||||
_ShowPopup(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[_ButtonNextRound].Selected)
|
||||
_NextRound();
|
||||
if (Buttons[_ButtonBack].Selected && _GameState.CurrentRoundNr == 1)
|
||||
_Back();
|
||||
if (Buttons[_ButtonExit].Selected && _GameState.CurrentRoundNr > 1)
|
||||
_ShowPopup(true);
|
||||
if (Buttons[_ButtonPlayerScrollUp].Selected)
|
||||
_ScrollPlayerTable(-1);
|
||||
if (Buttons[_ButtonPlayerScrollDown].Selected)
|
||||
_ScrollPlayerTable(1);
|
||||
if (Buttons[_ButtonRoundsScrollUp].Selected)
|
||||
_ScrollRoundsTable(-1);
|
||||
if (Buttons[_ButtonRoundsScrollDown].Selected)
|
||||
_ScrollRoundsTable(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[_ButtonPopupYes].Selected)
|
||||
_EndParty();
|
||||
if (Buttons[_ButtonPopupNo].Selected)
|
||||
_ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
{
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_GameState.CurrentRoundNr == 1)
|
||||
_Back();
|
||||
else
|
||||
_ShowPopup(true);
|
||||
}
|
||||
else
|
||||
_ShowPopup(false);
|
||||
}
|
||||
|
||||
if (mouseEvent.Wheel != 0)
|
||||
{
|
||||
if (CHelper.IsInBounds(_RoundsTableScrollArea, mouseEvent))
|
||||
_ScrollRoundsTable(mouseEvent.Wheel);
|
||||
if (CHelper.IsInBounds(_PlayerTableScrollArea, mouseEvent))
|
||||
_ScrollPlayerTable(mouseEvent.Wheel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
_PlayerTableOffset = 0;
|
||||
_RoundsTableOffset = 0;
|
||||
|
||||
_UpdatePlayerTable();
|
||||
_UpdateNextPlayerPositions();
|
||||
_UpdateNextPlayerContents();
|
||||
if (_GameState.CurrentRoundNr == 1)
|
||||
_BuildRoundsTable();
|
||||
else
|
||||
_ScrollRoundsTable(_GameState.CurrentRoundNr - 2);
|
||||
_UpdateRoundsTable();
|
||||
|
||||
if (_GameState.CurrentRoundNr == 1)
|
||||
{
|
||||
Buttons[_ButtonBack].Visible = true;
|
||||
Buttons[_ButtonExit].Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
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]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[_ButtonNextRound].Visible = false;
|
||||
Texts[_TextFinishMessage].Visible = true;
|
||||
Texts[_TextFinishPlayerWin].Visible = true;
|
||||
Texts[_TextFinishPlayerWin].Text = _GetPlayerWinString();
|
||||
SetInteractionToButton(Buttons[_ButtonExit]);
|
||||
}
|
||||
|
||||
_ShowPopup(false);
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _NextRound()
|
||||
{
|
||||
_Data.ScreenMain.FadeToNameSelection = false;
|
||||
_Data.ScreenMain.FadeToSongSelection = true;
|
||||
_PartyMode.DataFromScreen(ThemeName, _Data);
|
||||
}
|
||||
|
||||
private void _EndParty()
|
||||
{
|
||||
_FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void _ShowPopup(bool visible)
|
||||
{
|
||||
_ExitPopupVisible = visible;
|
||||
|
||||
Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
|
||||
Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
|
||||
Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
|
||||
Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
|
||||
|
||||
if (_ExitPopupVisible)
|
||||
SetInteractionToButton(Buttons[_ButtonPopupNo]);
|
||||
}
|
||||
|
||||
private void _Back()
|
||||
{
|
||||
_Data.ScreenMain.FadeToNameSelection = true;
|
||||
_Data.ScreenMain.FadeToSongSelection = false;
|
||||
_PartyMode.DataFromScreen(ThemeName, _Data);
|
||||
}
|
||||
|
||||
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;
|
||||
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//static
|
||||
_NextPlayerStatics[i].Rect.X = x;
|
||||
_NextPlayerStatics[i].Rect.Y = staticY;
|
||||
_NextPlayerStatics[i].Visible = true;
|
||||
//text
|
||||
_NextPlayerTexts[i].X = x + Statics[_StaticNextPlayer].Rect.W / 2;
|
||||
_NextPlayerTexts[i].Y = textY;
|
||||
_NextPlayerTexts[i].Visible = true;
|
||||
|
||||
x += Statics[_StaticNextPlayer].Rect.W + 15;
|
||||
}
|
||||
for (int i = _GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
|
||||
{
|
||||
_NextPlayerStatics[i].Visible = false;
|
||||
_NextPlayerTexts[i].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateNextPlayerContents()
|
||||
{
|
||||
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
|
||||
{
|
||||
Texts[_TextNextPlayerMessage].Visible = true;
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
int pid = _GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i];
|
||||
_NextPlayerStatics[i].Texture = profiles[_GameState.ProfileIDs[pid]].Avatar.Texture;
|
||||
_NextPlayerTexts[i].Text = profiles[_GameState.ProfileIDs[pid]].PlayerName;
|
||||
_NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Texts[_TextNextPlayerMessage].Visible = false;
|
||||
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
_NextPlayerStatics[i].Visible = false;
|
||||
_NextPlayerTexts[i].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _CreateRoundsTable()
|
||||
{
|
||||
//Create lists
|
||||
_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>();
|
||||
_RoundsTable.Add(rtr);
|
||||
}
|
||||
//Create statics and texts for rounds
|
||||
for (int round = 0; round < _RoundsTable.Count; round++)
|
||||
{
|
||||
//Round-number
|
||||
CText text = GetNewText(Texts[_TextRoundNumber]);
|
||||
AddText(text);
|
||||
_RoundsTable[round].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);
|
||||
//Score
|
||||
text = GetNewText(Texts[_TextRoundScore]);
|
||||
AddText(text);
|
||||
_RoundsTable[round].TextScores.Add(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _BuildRoundsTable()
|
||||
{
|
||||
_RoundsTableScrollArea = new SRectF();
|
||||
|
||||
int numPlayerInOneRow = 3;
|
||||
if (_GameState.NumPlayerAtOnce <= numPlayerInOneRow)
|
||||
_NumRoundsVisible = 5;
|
||||
else
|
||||
_NumRoundsVisible = 3;
|
||||
|
||||
if (_NumRoundsVisible > _GameState.Combs.Count)
|
||||
_NumRoundsVisible = _GameState.Combs.Count;
|
||||
|
||||
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;
|
||||
|
||||
float delta = Texts[_TextRoundNumber].Height;
|
||||
|
||||
//Update statics and texts for rounds
|
||||
for (int round = 0; round < _RoundsTable.Count; round++)
|
||||
{
|
||||
//Round-number
|
||||
_RoundsTable[round].Number.X = numberX;
|
||||
_RoundsTable[round].Number.Y = numberY;
|
||||
int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow));
|
||||
for (int row = 0; row < numInnerRows; row++)
|
||||
{
|
||||
int num = (row + 1) * numPlayerInOneRow;
|
||||
int numPlayerInThisRow = numPlayerInOneRow;
|
||||
if (num > _GameState.NumPlayerAtOnce)
|
||||
{
|
||||
num = _GameState.NumPlayerAtOnce;
|
||||
numPlayerInThisRow = _GameState.NumPlayerAtOnce - (row * numPlayerInOneRow);
|
||||
}
|
||||
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;
|
||||
//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;
|
||||
}
|
||||
numberY = numberY + delta + delta;
|
||||
}
|
||||
numberY = numberY + delta / 2;
|
||||
}
|
||||
_RoundsTableScrollArea.H = numberY - _RoundsTableScrollArea.Y;
|
||||
}
|
||||
|
||||
private void _UpdateRoundsTable()
|
||||
{
|
||||
SProfile[] profile = CBase.Profiles.GetProfiles();
|
||||
for (int i = 0; i < _RoundsTable.Count; i++)
|
||||
{
|
||||
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
if (_GameState.Combs.Count > i + _RoundsTableOffset && _GameState.Combs[i + _RoundsTableOffset].Player.Count > p)
|
||||
{
|
||||
_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() + ")";
|
||||
int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]];
|
||||
_RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
|
||||
if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset)
|
||||
_RoundsTable[i].TextScores[p].Text = _GameState.Results[i + _RoundsTableOffset, p].ToString();
|
||||
else
|
||||
_RoundsTable[i].TextScores[p].Text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
_RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
if (_GameState.Combs.Count < i + _RoundsTableOffset || i + 1 > _NumRoundsVisible)
|
||||
{
|
||||
_RoundsTable[i].Number.Visible = false;
|
||||
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
_RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
_RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
_PlayerTable = new List<STableRow>();
|
||||
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]);
|
||||
|
||||
row.Pos.Y += delta * (i + 1);
|
||||
row.Name.Y += delta * (i + 1);
|
||||
row.Rounds.Y += delta * (i + 1);
|
||||
row.Won.Y += delta * (i + 1);
|
||||
row.SingPoints.Y += delta * (i + 1);
|
||||
row.GamePoints.Y += delta * (i + 1);
|
||||
|
||||
row.Pos.Text = (i + 1).ToString() + ".";
|
||||
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
row.Rounds.Visible = false;
|
||||
row.Won.Visible = false;
|
||||
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);
|
||||
|
||||
_PlayerTable.Add(row);
|
||||
|
||||
h = delta * (i + 1);
|
||||
}
|
||||
_PlayerTableScrollArea.H = h + delta;
|
||||
}
|
||||
|
||||
private void _UpdatePlayerTable()
|
||||
{
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < _PlayerTable.Count; i++)
|
||||
{
|
||||
STableRow row = _PlayerTable[i];
|
||||
|
||||
if (i + _PlayerTableOffset < _GameState.ResultTable.Count)
|
||||
{
|
||||
row.Pos.Visible = true;
|
||||
row.Name.Visible = true;
|
||||
row.Rounds.Visible = true;
|
||||
row.Won.Visible = true;
|
||||
row.SingPoints.Visible = true;
|
||||
row.GamePoints.Visible = true;
|
||||
|
||||
row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position.ToString() + ".";
|
||||
row.Name.Text = profiles[_GameState.ResultTable[i + _PlayerTableOffset].PlayerID].PlayerName;
|
||||
row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumRounds.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();
|
||||
}
|
||||
else
|
||||
{
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
row.Rounds.Visible = false;
|
||||
row.Won.Visible = false;
|
||||
row.SingPoints.Visible = false;
|
||||
row.GamePoints.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0;
|
||||
Buttons[_ButtonPlayerScrollDown].Visible = _GameState.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0;
|
||||
}
|
||||
|
||||
private void _ScrollPlayerTable(int offset)
|
||||
{
|
||||
if (_GameState.ProfileIDs.Count <= _NumPlayerVisible)
|
||||
_PlayerTableOffset = 0;
|
||||
else if (offset < 0 && _PlayerTableOffset + offset >= 0)
|
||||
_PlayerTableOffset += offset;
|
||||
else if (offset < 0 && _PlayerTableOffset + offset < 0)
|
||||
_PlayerTableOffset = 0;
|
||||
else if (offset > 0 && _PlayerTableOffset + offset <= _GameState.ProfileIDs.Count - _NumPlayerVisible)
|
||||
_PlayerTableOffset += offset;
|
||||
else if (offset > 0 && _PlayerTableOffset + offset > _GameState.ProfileIDs.Count - _NumPlayerVisible)
|
||||
_PlayerTableOffset = _GameState.ProfileIDs.Count - _NumPlayerVisible;
|
||||
|
||||
_UpdatePlayerTable();
|
||||
}
|
||||
|
||||
private void _ScrollRoundsTable(int offset)
|
||||
{
|
||||
if (_GameState.Combs.Count <= _NumRoundsVisible)
|
||||
_RoundsTableOffset = 0;
|
||||
else if (offset < 0 && _RoundsTableOffset + offset >= 0)
|
||||
_RoundsTableOffset += offset;
|
||||
else if (offset < 0 && _RoundsTableOffset + offset < 0)
|
||||
_RoundsTableOffset = 0;
|
||||
else if (offset > 0 && _RoundsTableOffset + offset <= _GameState.Combs.Count - _NumRoundsVisible)
|
||||
_RoundsTableOffset += offset;
|
||||
else if (offset > 0 && _RoundsTableOffset + offset > _GameState.Combs.Count - _NumRoundsVisible)
|
||||
_RoundsTableOffset = _GameState.Combs.Count - _NumRoundsVisible;
|
||||
|
||||
_UpdateRoundsTable();
|
||||
}
|
||||
|
||||
private string _GetPlayerWinString()
|
||||
{
|
||||
string s = "";
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < _GameState.ResultTable.Count; i++)
|
||||
{
|
||||
if (_GameState.ResultTable[i].Position == 1)
|
||||
{
|
||||
if (i > 0)
|
||||
s += ", ";
|
||||
s += profiles[_GameState.ResultTable[i].PlayerID].PlayerName;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,504 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
{
|
||||
public class CPartyScreenChallengeMedleyNames : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string _ButtonNext = "ButtonNext";
|
||||
private const string _ButtonBack = "ButtonBack";
|
||||
private const string _ButtonPlayerDestination = "ButtonPlayerDestination";
|
||||
private const string _ButtonPlayerChoose = "ButtonPlayerChoose";
|
||||
|
||||
private List<CPlayerChooseButton> _PlayerChooseButtons;
|
||||
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;
|
||||
private const int _PlayerDestinationButtonsSpaceW = 25;
|
||||
//PlayerChooseButtons-Option
|
||||
private List<int> _PlayerChooseButtonsVisibleProfiles;
|
||||
private const int _PlayerChooseButtonsNumH = 7;
|
||||
private const int _PlayerChooseButtonsNumW = 4;
|
||||
private const int _PlayerChooseButtonsFirstX = 52;
|
||||
private const int _PlayerChooseButtonsFirstY = 105;
|
||||
private const int _PlayerChooseButtonsSpaceH = 15;
|
||||
private const int _PlayerChooseButtonsSpaceW = 25;
|
||||
private int _PlayerChooseButtonsOffset = 0;
|
||||
|
||||
private CStatic _ChooseAvatarStatic;
|
||||
private bool _SelectingMouseActive;
|
||||
private int _OldMouseX;
|
||||
private int _OldMouseY;
|
||||
private int _SelectedPlayerNr = -1;
|
||||
private bool _ButtonsAdded;
|
||||
|
||||
private int _NumPlayer = 4;
|
||||
|
||||
private SDataFromScreen _Data;
|
||||
|
||||
private class CPlayerChooseButton
|
||||
{
|
||||
public CButton Button;
|
||||
public int ProfileID;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ChooseAvatarStatic = GetNewStatic();
|
||||
_ChooseAvatarStatic.Visible = false;
|
||||
|
||||
_PlayerChooseButtonsVisibleProfiles = new List<int>();
|
||||
|
||||
_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>();
|
||||
_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>();
|
||||
|
||||
_NumPlayer = config.NumPlayer;
|
||||
|
||||
while (_Data.ScreenNames.ProfileIDs.Count > _NumPlayer)
|
||||
_Data.ScreenNames.ProfileIDs.RemoveAt(_Data.ScreenNames.ProfileIDs.Count - 1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge names. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
_Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
|
||||
if (!_OnAdd())
|
||||
_OnRemove();
|
||||
break;
|
||||
|
||||
case Keys.Delete:
|
||||
_OnRemove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
/*
|
||||
//Check if LeftButton is hold and Select-Mode inactive
|
||||
if (MouseEvent.LBH && !SelectingMouseActive)
|
||||
{
|
||||
//Save mouse-coords
|
||||
OldMouseX = MouseEvent.X;
|
||||
OldMouseY = MouseEvent.Y;
|
||||
//Check if mouse if over tile
|
||||
for (int i = 0; i < PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
if (PlayerChooseButtons[i].Button.Selected)
|
||||
{
|
||||
SelectedPlayerNr = PlayerChooseButtons[i].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.Z = -100;
|
||||
chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
|
||||
chooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[SelectedPlayerNr].Avatar.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode active
|
||||
if (mouseEvent.LBH && _SelectingMouseActive)
|
||||
{
|
||||
//Update coords for Drag/Drop-Texture
|
||||
_ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX;
|
||||
_ChooseAvatarStatic.Rect.Y += mouseEvent.Y - _OldMouseY;
|
||||
_OldMouseX = mouseEvent.X;
|
||||
_OldMouseY = mouseEvent.Y;
|
||||
}
|
||||
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
|
||||
else if (_SelectingMouseActive)
|
||||
{
|
||||
//Check if really a player was selected
|
||||
if (_SelectedPlayerNr != -1)
|
||||
{
|
||||
//Foreach Drop-Area
|
||||
for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
//Check first, if area is "active"
|
||||
if (_PlayerDestinationButtons[i].Visible)
|
||||
{
|
||||
//Check if Mouse is in area
|
||||
if (CHelper.IsInBounds(_PlayerDestinationButtons[i].Rect, mouseEvent))
|
||||
{
|
||||
int added = -1;
|
||||
//Add Player-ID to list.
|
||||
if (_Data.ScreenNames.ProfileIDs.Count < (i + 1))
|
||||
{
|
||||
_Data.ScreenNames.ProfileIDs.Add(_SelectedPlayerNr);
|
||||
added = _Data.ScreenNames.ProfileIDs.Count - 1;
|
||||
}
|
||||
else if (_Data.ScreenNames.ProfileIDs.Count >= (i + 1))
|
||||
{
|
||||
_Data.ScreenNames.ProfileIDs[i] = _SelectedPlayerNr;
|
||||
added = i;
|
||||
}
|
||||
_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 = _ChooseAvatarStatic.Texture;
|
||||
_PlayerDestinationButtons[added].SelTexture = _ChooseAvatarStatic.Texture;
|
||||
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].PlayerName;
|
||||
//Update Tiles-List
|
||||
_UpdateButtonPlayerChoose();
|
||||
}
|
||||
}
|
||||
}
|
||||
_SelectedPlayerNr = -1;
|
||||
}
|
||||
//Reset variables
|
||||
_SelectingMouseActive = false;
|
||||
_ChooseAvatarStatic.Visible = false;
|
||||
}
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
|
||||
if (!_OnAdd())
|
||||
_OnRemove();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
_Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
if (!_ButtonsAdded)
|
||||
{
|
||||
_AddButtonPlayerDestination();
|
||||
_AddButtonPlayerChoose();
|
||||
_ButtonsAdded = true;
|
||||
}
|
||||
|
||||
_UpdateButtonPlayerDestination();
|
||||
_UpdateButtonPlayerChoose();
|
||||
|
||||
_UpdateButtonNext();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
if (_ChooseAvatarStatic.Visible)
|
||||
_ChooseAvatarStatic.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _AddButtonPlayerDestination()
|
||||
{
|
||||
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]);
|
||||
b.Rect.X = _PlayerDestinationButtonsFirstX + column * (b.Rect.W + _PlayerDestinationButtonsSpaceH);
|
||||
b.Rect.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW);
|
||||
_PlayerDestinationButtons.Add(b);
|
||||
column++;
|
||||
if (column >= _PlayerDestinationButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void _AddButtonPlayerChoose()
|
||||
{
|
||||
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]);
|
||||
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;
|
||||
_PlayerChooseButtons.Add(pcb);
|
||||
column++;
|
||||
if (column >= _PlayerChooseButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateButtonPlayerChoose()
|
||||
{
|
||||
_UpdateVisibleProfiles();
|
||||
if ((_PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH) * (_PlayerChooseButtonsOffset + 1) - _PlayerChooseButtonsVisibleProfiles.Count >=
|
||||
(_PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH) * _PlayerChooseButtonsOffset)
|
||||
_UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset - 1);
|
||||
else
|
||||
_UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset);
|
||||
}
|
||||
|
||||
private void _UpdateButtonPlayerChoose(int offset)
|
||||
{
|
||||
int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
|
||||
if (offset < 0)
|
||||
offset = 0;
|
||||
|
||||
if (numButtonPlayerChoose * (offset + 1) - _PlayerChooseButtonsVisibleProfiles.Count <= numButtonPlayerChoose)
|
||||
{
|
||||
for (int i = 0; i < numButtonPlayerChoose; i++)
|
||||
{
|
||||
if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count)
|
||||
{
|
||||
_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.Color = new SColorF(1, 1, 1, 0.6f);
|
||||
_PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1);
|
||||
_PlayerChooseButtons[i].Button.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_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.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateVisibleProfiles()
|
||||
{
|
||||
_PlayerChooseButtonsVisibleProfiles.Clear();
|
||||
for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (visible)
|
||||
_PlayerChooseButtonsVisibleProfiles.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateButtonPlayerDestination()
|
||||
{
|
||||
for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
if (_NumPlayer > i)
|
||||
{
|
||||
_PlayerDestinationButtons[i].Visible = true;
|
||||
_PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_PlayerDestinationButtons[i].Visible = false;
|
||||
_PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _NumPlayer; i++)
|
||||
{
|
||||
if (i < _Data.ScreenNames.ProfileIDs.Count)
|
||||
{
|
||||
if (_Data.ScreenNames.ProfileIDs[i] != -1)
|
||||
{
|
||||
_PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
_PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1);
|
||||
_PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture;
|
||||
_PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture;
|
||||
_PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].PlayerName;
|
||||
_PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
}
|
||||
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].Text.Text = String.Empty;
|
||||
_PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateButtonNext()
|
||||
{
|
||||
if (_Data.ScreenNames.ProfileIDs.Count == _NumPlayer)
|
||||
{
|
||||
Buttons[_ButtonNext].Visible = true;
|
||||
SetInteractionToButton(Buttons[_ButtonNext]);
|
||||
}
|
||||
else
|
||||
Buttons[_ButtonNext].Visible = false;
|
||||
}
|
||||
|
||||
private bool _OnAdd()
|
||||
{
|
||||
for (int i = 0; i < _PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool _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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,12 +107,12 @@
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ChallengeRounds.cs" />
|
||||
<Compile Include="CChallengeRounds.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="PartyModeChallengeMedley.cs" />
|
||||
<Compile Include="PartyScreenChallengeMedleyConfig.cs" />
|
||||
<Compile Include="PartyScreenChallengeMedleyMain.cs" />
|
||||
<Compile Include="PartyScreenChallengeMedleyNames.cs" />
|
||||
<Compile Include="CPartyModeChallengeMedley.cs" />
|
||||
<Compile Include="CPartyScreenChallengeMedleyConfig.cs" />
|
||||
<Compile Include="CPartyScreenChallengeMedleyMain.cs" />
|
||||
<Compile Include="CPartyScreenChallengeMedleyNames.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VocaluxeLib\VocaluxeLib.csproj">
|
||||
@@ -123,10 +123,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.XML" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
{
|
||||
public class PartyScreenChallengeMedleyConfig : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string SelectSlideNumPlayers = "SelectSlideNumPlayers";
|
||||
private const string SelectSlideNumMics = "SelectSlideNumMics";
|
||||
private const string SelectSlideNumRounds = "SelectSlideNumRounds";
|
||||
private const string ButtonNext = "ButtonNext";
|
||||
private const string ButtonBack = "ButtonBack";
|
||||
|
||||
private int _MaxNumMics = 2;
|
||||
private int _MaxNumRounds = 100;
|
||||
private int _RoundSteps = 1;
|
||||
|
||||
private DataFromScreen Data;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeSelectSlides = new string[] {SelectSlideNumPlayers, SelectSlideNumMics, SelectSlideNumRounds};
|
||||
_ThemeButtons = new string[] {ButtonNext, ButtonBack};
|
||||
|
||||
Data = new DataFromScreen();
|
||||
FromScreenConfig config = new FromScreenConfig();
|
||||
config.NumPlayer = 4;
|
||||
config.NumPlayerAtOnce = 2;
|
||||
config.NumRounds = 12;
|
||||
Data.ScreenConfig = config;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenConfig config = new DataToScreenConfig();
|
||||
|
||||
try
|
||||
{
|
||||
config = (DataToScreenConfig)ReceivedData;
|
||||
Data.ScreenConfig.NumPlayer = config.NumPlayer;
|
||||
Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce;
|
||||
Data.ScreenConfig.NumRounds = config.NumRounds;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge config. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
UpdateSlides();
|
||||
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
UpdateSlides();
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
UpdateSlides();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
UpdateSlides();
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
_MaxNumMics = CBase.Config.GetMaxNumMics();
|
||||
if (_MaxNumMics > 6)
|
||||
_MaxNumMics = 6;
|
||||
|
||||
_MaxNumRounds = _PartyMode.GetMaxNumRounds();
|
||||
|
||||
RebuildSlides();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void RebuildSlides()
|
||||
{
|
||||
// build num player slide (min player ... max player);
|
||||
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();
|
||||
|
||||
UpdateMicsAtOnce();
|
||||
SetRoundSteps();
|
||||
UpdateSlideRounds();
|
||||
}
|
||||
|
||||
private void UpdateSlides()
|
||||
{
|
||||
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;
|
||||
|
||||
UpdateMicsAtOnce();
|
||||
SetRoundSteps();
|
||||
|
||||
if (player != Data.ScreenConfig.NumPlayer || mics != Data.ScreenConfig.NumPlayerAtOnce)
|
||||
{
|
||||
int num = CHelper.nCk(Data.ScreenConfig.NumPlayer, Data.ScreenConfig.NumPlayerAtOnce);
|
||||
while (num > _MaxNumRounds)
|
||||
num -= _RoundSteps;
|
||||
Data.ScreenConfig.NumRounds = num;
|
||||
}
|
||||
|
||||
UpdateSlideRounds();
|
||||
}
|
||||
|
||||
private void UpdateMicsAtOnce()
|
||||
{
|
||||
//Data.ScreenConfig.NumPlayerAtOnce
|
||||
int MaxNum = _MaxNumMics;
|
||||
if (Data.ScreenConfig.NumPlayer < _MaxNumMics)
|
||||
MaxNum = Data.ScreenConfig.NumPlayer;
|
||||
|
||||
if (Data.ScreenConfig.NumPlayerAtOnce > MaxNum)
|
||||
Data.ScreenConfig.NumPlayerAtOnce = MaxNum;
|
||||
|
||||
// build mics at once slide
|
||||
SelectSlides[SelectSlideNumMics].Clear();
|
||||
for (int i = 1; i <= MaxNum; i++)
|
||||
SelectSlides[SelectSlideNumMics].AddValue(i.ToString());
|
||||
SelectSlides[SelectSlideNumMics].Selection = Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
|
||||
}
|
||||
|
||||
private void UpdateSlideRounds()
|
||||
{
|
||||
// build num rounds slide
|
||||
SelectSlides[SelectSlideNumRounds].Clear();
|
||||
for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
|
||||
SelectSlides[SelectSlideNumRounds].AddValue(i.ToString());
|
||||
SelectSlides[SelectSlideNumRounds].Selection = Data.ScreenConfig.NumRounds / _RoundSteps - 1;
|
||||
}
|
||||
|
||||
private void SetRoundSteps()
|
||||
{
|
||||
if (Data.ScreenConfig.NumPlayerAtOnce < 1 || Data.ScreenConfig.NumPlayer < 1 || Data.ScreenConfig.NumPlayerAtOnce > Data.ScreenConfig.NumPlayer)
|
||||
{
|
||||
_RoundSteps = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private void Back()
|
||||
{
|
||||
FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void Next()
|
||||
{
|
||||
_PartyMode.DataFromScreen(ThemeName, Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,660 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
{
|
||||
struct TableRow
|
||||
{
|
||||
public CText Pos;
|
||||
public CText Name;
|
||||
public CText Rounds;
|
||||
public CText Won;
|
||||
public CText SingPoints;
|
||||
public CText GamePoints;
|
||||
}
|
||||
|
||||
class RoundsTableRow
|
||||
{
|
||||
public CText Number;
|
||||
public List<CText> TextPlayer;
|
||||
public List<CText> TextScores;
|
||||
}
|
||||
|
||||
public class PartyScreenChallengeMedleyMain : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string TextPosition = "TextPosition";
|
||||
private const string TextPlayerName = "TextPlayerName";
|
||||
private const string TextNumPlayed = "TextNumPlayed";
|
||||
private const string TextWon = "TextWon";
|
||||
private const string TextSingPoints = "TextSingPoints";
|
||||
private const string TextGamePoints = "TextGamePoints";
|
||||
private const string TextNextPlayer = "TextNextPlayer";
|
||||
private const string TextPopupReallyExit = "TextPopupReallyExit";
|
||||
private const string TextRoundPlayer = "TextRoundPlayer";
|
||||
private const string TextRoundScore = "TextRoundScore";
|
||||
private const string TextRoundNumber = "TextRoundNumber";
|
||||
private const string TextFinishMessage = "TextFinishMessage";
|
||||
private const string TextFinishPlayerWin = "TextFinishPlayerWin";
|
||||
private const string TextNextPlayerMessage = "TextNextPlayerMessage";
|
||||
|
||||
private const string ButtonNextRound = "ButtonNextRound";
|
||||
private const string ButtonBack = "ButtonBack";
|
||||
private const string ButtonExit = "ButtonExit";
|
||||
private const string ButtonPopupYes = "ButtonPopupYes";
|
||||
private const string ButtonPopupNo = "ButtonPopupNo";
|
||||
private const string ButtonPlayerScrollUp = "ButtonPlayerScrollUp";
|
||||
private const string ButtonPlayerScrollDown = "ButtonPlayerScrollDown";
|
||||
private const string ButtonRoundsScrollUp = "ButtonRoundsScrollUp";
|
||||
private const string ButtonRoundsScrollDown = "ButtonRoundsScrollDown";
|
||||
|
||||
private const string StaticPopupBG = "StaticPopupBG";
|
||||
private const string StaticNextPlayer = "StaticNextPlayer";
|
||||
|
||||
private bool ExitPopupVisible;
|
||||
|
||||
private DataFromScreen Data;
|
||||
private DataToScreenMain GameState;
|
||||
private List<TableRow> PlayerTable;
|
||||
private List<RoundsTableRow> RoundsTable;
|
||||
|
||||
private List<CText> NextPlayerTexts;
|
||||
private List<CStatic> NextPlayerStatics;
|
||||
|
||||
private SRectF RoundsTableScrollArea;
|
||||
private SRectF PlayerTableScrollArea;
|
||||
private int RoundsTableOffset;
|
||||
private int PlayerTableOffset;
|
||||
private int NumPlayerVisible = 10;
|
||||
private int NumRoundsVisible = 3;
|
||||
|
||||
public PartyScreenChallengeMedleyMain()
|
||||
{
|
||||
Data = new DataFromScreen();
|
||||
Data.ScreenMain = new FromScreenMain();
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeTexts = new string[]
|
||||
{
|
||||
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};
|
||||
_ThemeStatics = new string[] {StaticPopupBG, StaticNextPlayer};
|
||||
}
|
||||
|
||||
public override void LoadTheme(string XmlPath)
|
||||
{
|
||||
base.LoadTheme(XmlPath);
|
||||
|
||||
GameState = new DataToScreenMain();
|
||||
BuildPlayerTable();
|
||||
CreateRoundsTable();
|
||||
NextPlayerTexts = new List<CText>();
|
||||
NextPlayerStatics = new List<CStatic>();
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenMain data = new DataToScreenMain();
|
||||
|
||||
try
|
||||
{
|
||||
data = (DataToScreenMain)ReceivedData;
|
||||
GameState = data;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge main. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
else
|
||||
ShowPopup(true);
|
||||
}
|
||||
else
|
||||
ShowPopup(false);
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[ButtonNextRound].Selected)
|
||||
NextRound();
|
||||
if (Buttons[ButtonBack].Selected && GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
if (Buttons[ButtonExit].Selected && GameState.CurrentRoundNr > 1)
|
||||
ShowPopup(true);
|
||||
if (Buttons[ButtonPlayerScrollUp].Selected)
|
||||
ScrollPlayerTable(-1);
|
||||
if (Buttons[ButtonPlayerScrollDown].Selected)
|
||||
ScrollPlayerTable(1);
|
||||
if (Buttons[ButtonRoundsScrollUp].Selected)
|
||||
ScrollRoundsTable(-1);
|
||||
if (Buttons[ButtonRoundsScrollDown].Selected)
|
||||
ScrollRoundsTable(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[ButtonPopupYes].Selected)
|
||||
EndParty();
|
||||
if (Buttons[ButtonPopupNo].Selected)
|
||||
ShowPopup(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[ButtonNextRound].Selected)
|
||||
NextRound();
|
||||
if (Buttons[ButtonBack].Selected && GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
if (Buttons[ButtonExit].Selected && GameState.CurrentRoundNr > 1)
|
||||
ShowPopup(true);
|
||||
if (Buttons[ButtonPlayerScrollUp].Selected)
|
||||
ScrollPlayerTable(-1);
|
||||
if (Buttons[ButtonPlayerScrollDown].Selected)
|
||||
ScrollPlayerTable(1);
|
||||
if (Buttons[ButtonRoundsScrollUp].Selected)
|
||||
ScrollRoundsTable(-1);
|
||||
if (Buttons[ButtonRoundsScrollDown].Selected)
|
||||
ScrollRoundsTable(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[ButtonPopupYes].Selected)
|
||||
EndParty();
|
||||
if (Buttons[ButtonPopupNo].Selected)
|
||||
ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
{
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
else
|
||||
ShowPopup(true);
|
||||
}
|
||||
else
|
||||
ShowPopup(false);
|
||||
}
|
||||
|
||||
if (mouseEvent.Wheel != 0)
|
||||
{
|
||||
if (CHelper.IsInBounds(RoundsTableScrollArea, mouseEvent))
|
||||
ScrollRoundsTable(mouseEvent.Wheel);
|
||||
if (CHelper.IsInBounds(PlayerTableScrollArea, mouseEvent))
|
||||
ScrollPlayerTable(mouseEvent.Wheel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
PlayerTableOffset = 0;
|
||||
RoundsTableOffset = 0;
|
||||
|
||||
UpdatePlayerTable();
|
||||
UpdateNextPlayerPositions();
|
||||
UpdateNextPlayerContents();
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
BuildRoundsTable();
|
||||
else
|
||||
ScrollRoundsTable(GameState.CurrentRoundNr - 2);
|
||||
UpdateRoundsTable();
|
||||
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
{
|
||||
Buttons[ButtonBack].Visible = true;
|
||||
Buttons[ButtonExit].Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
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]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[ButtonNextRound].Visible = false;
|
||||
Texts[TextFinishMessage].Visible = true;
|
||||
Texts[TextFinishPlayerWin].Visible = true;
|
||||
Texts[TextFinishPlayerWin].Text = GetPlayerWinString();
|
||||
SetInteractionToButton(Buttons[ButtonExit]);
|
||||
}
|
||||
|
||||
ShowPopup(false);
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void NextRound()
|
||||
{
|
||||
Data.ScreenMain.FadeToNameSelection = false;
|
||||
Data.ScreenMain.FadeToSongSelection = true;
|
||||
_PartyMode.DataFromScreen(ThemeName, Data);
|
||||
}
|
||||
|
||||
private void EndParty()
|
||||
{
|
||||
FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void ShowPopup(bool Visible)
|
||||
{
|
||||
ExitPopupVisible = Visible;
|
||||
|
||||
Statics[StaticPopupBG].Visible = ExitPopupVisible;
|
||||
Texts[TextPopupReallyExit].Visible = ExitPopupVisible;
|
||||
Buttons[ButtonPopupYes].Visible = ExitPopupVisible;
|
||||
Buttons[ButtonPopupNo].Visible = ExitPopupVisible;
|
||||
|
||||
if (ExitPopupVisible)
|
||||
SetInteractionToButton(Buttons[ButtonPopupNo]);
|
||||
}
|
||||
|
||||
private void Back()
|
||||
{
|
||||
Data.ScreenMain.FadeToNameSelection = true;
|
||||
Data.ScreenMain.FadeToSongSelection = false;
|
||||
_PartyMode.DataFromScreen(ThemeName, Data);
|
||||
}
|
||||
|
||||
private void UpdateNextPlayerPositions()
|
||||
{
|
||||
float x = CBase.Settings.GetRenderW() / 2 - ((GameState.NumPlayerAtOnce * Statics[StaticNextPlayer].Rect.W) + ((GameState.NumPlayerAtOnce - 1) * 15)) / 2;
|
||||
float static_y = 590;
|
||||
float text_y = 550;
|
||||
for (int i = 0; i < GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//static
|
||||
NextPlayerStatics[i].Rect.X = x;
|
||||
NextPlayerStatics[i].Rect.Y = static_y;
|
||||
NextPlayerStatics[i].Visible = true;
|
||||
//text
|
||||
NextPlayerTexts[i].X = x + Statics[StaticNextPlayer].Rect.W / 2;
|
||||
NextPlayerTexts[i].Y = text_y;
|
||||
NextPlayerTexts[i].Visible = true;
|
||||
|
||||
x += Statics[StaticNextPlayer].Rect.W + 15;
|
||||
}
|
||||
for (int i = GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
|
||||
{
|
||||
NextPlayerStatics[i].Visible = false;
|
||||
NextPlayerTexts[i].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateNextPlayerContents()
|
||||
{
|
||||
if (GameState.CurrentRoundNr <= GameState.Combs.Count)
|
||||
{
|
||||
Texts[TextNextPlayerMessage].Visible = true;
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
for (int i = 0; i < GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
int pid = GameState.Combs[GameState.CurrentRoundNr - 1].Player[i];
|
||||
NextPlayerStatics[i].Texture = profiles[GameState.ProfileIDs[pid]].Avatar.Texture;
|
||||
NextPlayerTexts[i].Text = profiles[GameState.ProfileIDs[pid]].PlayerName;
|
||||
NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Texts[TextNextPlayerMessage].Visible = false;
|
||||
for (int i = 0; i < GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
NextPlayerStatics[i].Visible = false;
|
||||
NextPlayerTexts[i].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateRoundsTable()
|
||||
{
|
||||
//Create lists
|
||||
RoundsTable = new List<RoundsTableRow>();
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RoundsTableRow rtr = new RoundsTableRow();
|
||||
rtr.TextPlayer = new List<CText>();
|
||||
rtr.TextScores = new List<CText>();
|
||||
RoundsTable.Add(rtr);
|
||||
}
|
||||
//Create statics and texts for rounds
|
||||
for (int round = 0; round < RoundsTable.Count; round++)
|
||||
{
|
||||
//Round-number
|
||||
CText text = GetNewText(Texts[TextRoundNumber]);
|
||||
AddText(text);
|
||||
RoundsTable[round].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);
|
||||
//Score
|
||||
text = GetNewText(Texts[TextRoundScore]);
|
||||
AddText(text);
|
||||
RoundsTable[round].TextScores.Add(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildRoundsTable()
|
||||
{
|
||||
RoundsTableScrollArea = new SRectF();
|
||||
|
||||
int NumPlayerInOneRow = 3;
|
||||
if (GameState.NumPlayerAtOnce <= NumPlayerInOneRow)
|
||||
NumRoundsVisible = 5;
|
||||
else
|
||||
NumRoundsVisible = 3;
|
||||
|
||||
if (NumRoundsVisible > GameState.Combs.Count)
|
||||
NumRoundsVisible = GameState.Combs.Count;
|
||||
|
||||
float x = Texts[TextRoundNumber].X;
|
||||
float y = Texts[TextRoundNumber].Y;
|
||||
|
||||
RoundsTableScrollArea.X = x;
|
||||
RoundsTableScrollArea.Y = y;
|
||||
RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - Texts[TextRoundNumber].X - 20;
|
||||
|
||||
float delta = Texts[TextRoundNumber].Height;
|
||||
|
||||
//Update statics and texts for rounds
|
||||
for (int round = 0; round < RoundsTable.Count; round++)
|
||||
{
|
||||
//Round-number
|
||||
RoundsTable[round].Number.X = x;
|
||||
RoundsTable[round].Number.Y = y;
|
||||
int NumInnerRows = (int)Math.Ceiling(GameState.NumPlayerAtOnce / ((double)NumPlayerInOneRow));
|
||||
for (int row = 0; row < NumInnerRows; row++)
|
||||
{
|
||||
int num = (row + 1) * NumPlayerInOneRow;
|
||||
int NumPlayerInThisRow = NumPlayerInOneRow;
|
||||
if (num > GameState.NumPlayerAtOnce)
|
||||
{
|
||||
num = GameState.NumPlayerAtOnce;
|
||||
NumPlayerInThisRow = GameState.NumPlayerAtOnce - (row * NumPlayerInOneRow);
|
||||
}
|
||||
for (int column = row * NumPlayerInOneRow; column < num; column++)
|
||||
{
|
||||
//Player
|
||||
float _x = x + 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 = y;
|
||||
RoundsTable[round].TextPlayer[column].MaxWidth = maxw;
|
||||
//Score
|
||||
RoundsTable[round].TextScores[column] = RoundsTable[round].TextScores[column];
|
||||
RoundsTable[round].TextScores[column].X = _x;
|
||||
RoundsTable[round].TextScores[column].Y = y + delta;
|
||||
RoundsTable[round].TextScores[column].MaxWidth = maxw;
|
||||
}
|
||||
y = y + delta + delta;
|
||||
}
|
||||
y = y + delta / 2;
|
||||
}
|
||||
RoundsTableScrollArea.H = y - RoundsTableScrollArea.Y;
|
||||
}
|
||||
|
||||
private void UpdateRoundsTable()
|
||||
{
|
||||
SProfile[] profile = CBase.Profiles.GetProfiles();
|
||||
for (int i = 0; i < RoundsTable.Count; i++)
|
||||
{
|
||||
for (int p = 0; p < RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
if (GameState.Combs.Count > i + RoundsTableOffset && GameState.Combs[i + RoundsTableOffset].Player.Count > p)
|
||||
{
|
||||
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() + ")";
|
||||
int pID = GameState.ProfileIDs[GameState.Combs[i + RoundsTableOffset].Player[p]];
|
||||
RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
|
||||
if ((GameState.CurrentRoundNr - 1) > i + RoundsTableOffset)
|
||||
RoundsTable[i].TextScores[p].Text = GameState.Results[i + RoundsTableOffset, p].ToString();
|
||||
else
|
||||
RoundsTable[i].TextScores[p].Text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
if (GameState.Combs.Count < i + RoundsTableOffset || i + 1 > NumRoundsVisible)
|
||||
{
|
||||
RoundsTable[i].Number.Visible = false;
|
||||
for (int p = 0; p < RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
PlayerTable = new List<TableRow>();
|
||||
float delta = Texts[TextPosition].Height * 1.2f;
|
||||
|
||||
float h = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
TableRow row = new TableRow();
|
||||
|
||||
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]);
|
||||
|
||||
row.Pos.Y += delta * (i + 1);
|
||||
row.Name.Y += delta * (i + 1);
|
||||
row.Rounds.Y += delta * (i + 1);
|
||||
row.Won.Y += delta * (i + 1);
|
||||
row.SingPoints.Y += delta * (i + 1);
|
||||
row.GamePoints.Y += delta * (i + 1);
|
||||
|
||||
row.Pos.Text = (i + 1).ToString() + ".";
|
||||
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
row.Rounds.Visible = false;
|
||||
row.Won.Visible = false;
|
||||
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);
|
||||
|
||||
PlayerTable.Add(row);
|
||||
|
||||
h = delta * (i + 1);
|
||||
}
|
||||
PlayerTableScrollArea.H = h + delta;
|
||||
}
|
||||
|
||||
private void UpdatePlayerTable()
|
||||
{
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < PlayerTable.Count; i++)
|
||||
{
|
||||
TableRow row = PlayerTable[i];
|
||||
|
||||
if (i + PlayerTableOffset < GameState.ResultTable.Count)
|
||||
{
|
||||
row.Pos.Visible = true;
|
||||
row.Name.Visible = true;
|
||||
row.Rounds.Visible = true;
|
||||
row.Won.Visible = true;
|
||||
row.SingPoints.Visible = true;
|
||||
row.GamePoints.Visible = true;
|
||||
|
||||
row.Pos.Text = GameState.ResultTable[i + PlayerTableOffset].Position.ToString() + ".";
|
||||
row.Name.Text = profiles[GameState.ResultTable[i + PlayerTableOffset].PlayerID].PlayerName;
|
||||
row.Rounds.Text = GameState.ResultTable[i + PlayerTableOffset].NumRounds.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();
|
||||
}
|
||||
else
|
||||
{
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
row.Rounds.Visible = false;
|
||||
row.Won.Visible = false;
|
||||
row.SingPoints.Visible = false;
|
||||
row.GamePoints.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
Buttons[ButtonPlayerScrollUp].Visible = PlayerTableOffset > 0;
|
||||
Buttons[ButtonPlayerScrollDown].Visible = GameState.ProfileIDs.Count - NumPlayerVisible - PlayerTableOffset > 0;
|
||||
}
|
||||
|
||||
private void ScrollPlayerTable(int Offset)
|
||||
{
|
||||
if (GameState.ProfileIDs.Count <= NumPlayerVisible)
|
||||
PlayerTableOffset = 0;
|
||||
else if (Offset < 0 && PlayerTableOffset + Offset >= 0)
|
||||
PlayerTableOffset += Offset;
|
||||
else if (Offset < 0 && PlayerTableOffset + Offset < 0)
|
||||
PlayerTableOffset = 0;
|
||||
else if (Offset > 0 && PlayerTableOffset + Offset <= GameState.ProfileIDs.Count - NumPlayerVisible)
|
||||
PlayerTableOffset += Offset;
|
||||
else if (Offset > 0 && PlayerTableOffset + Offset > GameState.ProfileIDs.Count - NumPlayerVisible)
|
||||
PlayerTableOffset = GameState.ProfileIDs.Count - NumPlayerVisible;
|
||||
|
||||
UpdatePlayerTable();
|
||||
}
|
||||
|
||||
private void ScrollRoundsTable(int Offset)
|
||||
{
|
||||
if (GameState.Combs.Count <= NumRoundsVisible)
|
||||
RoundsTableOffset = 0;
|
||||
else if (Offset < 0 && RoundsTableOffset + Offset >= 0)
|
||||
RoundsTableOffset += Offset;
|
||||
else if (Offset < 0 && RoundsTableOffset + Offset < 0)
|
||||
RoundsTableOffset = 0;
|
||||
else if (Offset > 0 && RoundsTableOffset + Offset <= GameState.Combs.Count - NumRoundsVisible)
|
||||
RoundsTableOffset += Offset;
|
||||
else if (Offset > 0 && RoundsTableOffset + Offset > GameState.Combs.Count - NumRoundsVisible)
|
||||
RoundsTableOffset = GameState.Combs.Count - NumRoundsVisible;
|
||||
|
||||
UpdateRoundsTable();
|
||||
}
|
||||
|
||||
private string GetPlayerWinString()
|
||||
{
|
||||
string s = "";
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < GameState.ResultTable.Count; i++)
|
||||
{
|
||||
if (GameState.ResultTable[i].Position == 1)
|
||||
{
|
||||
if (i > 0)
|
||||
s += ", ";
|
||||
s += profiles[GameState.ResultTable[i].PlayerID].PlayerName;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,504 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.ChallengeMedley
|
||||
{
|
||||
public class PartyScreenChallengeMedleyNames : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string ButtonNext = "ButtonNext";
|
||||
private const string ButtonBack = "ButtonBack";
|
||||
private const string ButtonPlayerDestination = "ButtonPlayerDestination";
|
||||
private const string ButtonPlayerChoose = "ButtonPlayerChoose";
|
||||
|
||||
private List<CPlayerChooseButton> PlayerChooseButtons;
|
||||
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;
|
||||
private const int PlayerDestinationButtonsSpaceW = 25;
|
||||
//PlayerChooseButtons-Option
|
||||
private List<int> PlayerChooseButtonsVisibleProfiles;
|
||||
private const int PlayerChooseButtonsNumH = 7;
|
||||
private const int PlayerChooseButtonsNumW = 4;
|
||||
private const int PlayerChooseButtonsFirstX = 52;
|
||||
private const int PlayerChooseButtonsFirstY = 105;
|
||||
private const int PlayerChooseButtonsSpaceH = 15;
|
||||
private const int PlayerChooseButtonsSpaceW = 25;
|
||||
private int PlayerChooseButtonsOffset = 0;
|
||||
|
||||
private CStatic chooseAvatarStatic;
|
||||
private bool SelectingMouseActive;
|
||||
private int OldMouseX;
|
||||
private int OldMouseY;
|
||||
private int SelectedPlayerNr = -1;
|
||||
private bool ButtonsAdded;
|
||||
|
||||
private int NumPlayer = 4;
|
||||
|
||||
private DataFromScreen Data;
|
||||
|
||||
private class CPlayerChooseButton
|
||||
{
|
||||
public CButton Button;
|
||||
public int ProfileID;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
chooseAvatarStatic = GetNewStatic();
|
||||
chooseAvatarStatic.Visible = false;
|
||||
|
||||
PlayerChooseButtonsVisibleProfiles = new List<int>();
|
||||
|
||||
Data.ScreenNames.ProfileIDs = new List<int>();
|
||||
|
||||
List<string> buttons = new List<string>();
|
||||
_ThemeButtons = new string[] {ButtonBack, ButtonNext, ButtonPlayerDestination, ButtonPlayerChoose};
|
||||
|
||||
Data = new DataFromScreen();
|
||||
FromScreenNames names = new FromScreenNames();
|
||||
names.FadeToConfig = false;
|
||||
names.FadeToMain = false;
|
||||
names.ProfileIDs = new List<int>();
|
||||
Data.ScreenNames = names;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenNames config = new DataToScreenNames();
|
||||
|
||||
try
|
||||
{
|
||||
config = (DataToScreenNames)ReceivedData;
|
||||
Data.ScreenNames.ProfileIDs = config.ProfileIDs;
|
||||
if (Data.ScreenNames.ProfileIDs == null)
|
||||
Data.ScreenNames.ProfileIDs = new List<int>();
|
||||
|
||||
NumPlayer = config.NumPlayer;
|
||||
|
||||
while (Data.ScreenNames.ProfileIDs.Count > NumPlayer)
|
||||
Data.ScreenNames.ProfileIDs.RemoveAt(Data.ScreenNames.ProfileIDs.Count - 1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen challenge names. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
|
||||
if (!OnAdd())
|
||||
OnRemove();
|
||||
break;
|
||||
|
||||
case Keys.Delete:
|
||||
OnRemove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
/*
|
||||
//Check if LeftButton is hold and Select-Mode inactive
|
||||
if (MouseEvent.LBH && !SelectingMouseActive)
|
||||
{
|
||||
//Save mouse-coords
|
||||
OldMouseX = MouseEvent.X;
|
||||
OldMouseY = MouseEvent.Y;
|
||||
//Check if mouse if over tile
|
||||
for (int i = 0; i < PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
if (PlayerChooseButtons[i].Button.Selected)
|
||||
{
|
||||
SelectedPlayerNr = PlayerChooseButtons[i].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.Z = -100;
|
||||
chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
|
||||
chooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[SelectedPlayerNr].Avatar.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode active
|
||||
if (mouseEvent.LBH && SelectingMouseActive)
|
||||
{
|
||||
//Update coords for Drag/Drop-Texture
|
||||
chooseAvatarStatic.Rect.X += mouseEvent.X - OldMouseX;
|
||||
chooseAvatarStatic.Rect.Y += mouseEvent.Y - OldMouseY;
|
||||
OldMouseX = mouseEvent.X;
|
||||
OldMouseY = mouseEvent.Y;
|
||||
}
|
||||
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
|
||||
else if (SelectingMouseActive)
|
||||
{
|
||||
//Check if really a player was selected
|
||||
if (SelectedPlayerNr != -1)
|
||||
{
|
||||
//Foreach Drop-Area
|
||||
for (int i = 0; i < PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
//Check first, if area is "active"
|
||||
if (PlayerDestinationButtons[i].Visible)
|
||||
{
|
||||
//Check if Mouse is in area
|
||||
if (CHelper.IsInBounds(PlayerDestinationButtons[i].Rect, mouseEvent))
|
||||
{
|
||||
int added = -1;
|
||||
//Add Player-ID to list.
|
||||
if (Data.ScreenNames.ProfileIDs.Count < (i + 1))
|
||||
{
|
||||
Data.ScreenNames.ProfileIDs.Add(SelectedPlayerNr);
|
||||
added = Data.ScreenNames.ProfileIDs.Count - 1;
|
||||
}
|
||||
else if (Data.ScreenNames.ProfileIDs.Count >= (i + 1))
|
||||
{
|
||||
Data.ScreenNames.ProfileIDs[i] = SelectedPlayerNr;
|
||||
added = i;
|
||||
}
|
||||
UpdateButtonNext();
|
||||
//Update texture and name
|
||||
PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerDestinationButtons[added].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[added].Texture = chooseAvatarStatic.Texture;
|
||||
PlayerDestinationButtons[added].STexture = chooseAvatarStatic.Texture;
|
||||
PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[SelectedPlayerNr].PlayerName;
|
||||
//Update Tiles-List
|
||||
UpdateButtonPlayerChoose();
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectedPlayerNr = -1;
|
||||
}
|
||||
//Reset variables
|
||||
SelectingMouseActive = false;
|
||||
chooseAvatarStatic.Visible = false;
|
||||
}
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
|
||||
if (!OnAdd())
|
||||
OnRemove();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
if (!ButtonsAdded)
|
||||
{
|
||||
AddButtonPlayerDestination();
|
||||
AddButtonPlayerChoose();
|
||||
ButtonsAdded = true;
|
||||
}
|
||||
|
||||
UpdateButtonPlayerDestination();
|
||||
UpdateButtonPlayerChoose();
|
||||
|
||||
UpdateButtonNext();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
if (chooseAvatarStatic.Visible)
|
||||
chooseAvatarStatic.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AddButtonPlayerDestination()
|
||||
{
|
||||
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]);
|
||||
b.Rect.X = PlayerDestinationButtonsFirstX + column * (b.Rect.W + PlayerDestinationButtonsSpaceH);
|
||||
b.Rect.Y = PlayerDestinationButtonsFirstY + row * (b.Rect.H + PlayerDestinationButtonsSpaceW);
|
||||
PlayerDestinationButtons.Add(b);
|
||||
column++;
|
||||
if (column >= PlayerDestinationButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButtonPlayerChoose()
|
||||
{
|
||||
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]);
|
||||
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;
|
||||
PlayerChooseButtons.Add(pcb);
|
||||
column++;
|
||||
if (column >= PlayerChooseButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerChoose()
|
||||
{
|
||||
UpdateVisibleProfiles();
|
||||
if ((PlayerChooseButtonsNumW * PlayerChooseButtonsNumH) * (PlayerChooseButtonsOffset + 1) - PlayerChooseButtonsVisibleProfiles.Count >=
|
||||
(PlayerChooseButtonsNumW * PlayerChooseButtonsNumH) * PlayerChooseButtonsOffset)
|
||||
UpdateButtonPlayerChoose(PlayerChooseButtonsOffset - 1);
|
||||
else
|
||||
UpdateButtonPlayerChoose(PlayerChooseButtonsOffset);
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerChoose(int Offset)
|
||||
{
|
||||
int NumButtonPlayerChoose = PlayerChooseButtonsNumW * PlayerChooseButtonsNumH;
|
||||
if (Offset < 0)
|
||||
Offset = 0;
|
||||
|
||||
if (NumButtonPlayerChoose * (Offset + 1) - PlayerChooseButtonsVisibleProfiles.Count <= NumButtonPlayerChoose)
|
||||
{
|
||||
for (int i = 0; i < NumButtonPlayerChoose; i++)
|
||||
{
|
||||
if ((i + Offset * NumButtonPlayerChoose) < PlayerChooseButtonsVisibleProfiles.Count)
|
||||
{
|
||||
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.STexture = CBase.Profiles.GetProfiles()[PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose]].Avatar.Texture;
|
||||
PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerChooseButtons[i].Button.SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerChooseButtons[i].Button.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerChooseButtons[i].ProfileID = -1;
|
||||
PlayerChooseButtons[i].Button.Text.Text = String.Empty;
|
||||
PlayerChooseButtons[i].Button.Texture = Buttons[ButtonPlayerChoose].Texture;
|
||||
PlayerChooseButtons[i].Button.STexture = Buttons[ButtonPlayerChoose].STexture;
|
||||
PlayerChooseButtons[i].Button.Color = Buttons[ButtonPlayerChoose].Color;
|
||||
PlayerChooseButtons[i].Button.SColor = Buttons[ButtonPlayerChoose].SColor;
|
||||
PlayerChooseButtons[i].Button.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateVisibleProfiles()
|
||||
{
|
||||
PlayerChooseButtonsVisibleProfiles.Clear();
|
||||
for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (visible)
|
||||
PlayerChooseButtonsVisibleProfiles.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerDestination()
|
||||
{
|
||||
for (int i = 0; i < PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
if (NumPlayer > i)
|
||||
{
|
||||
PlayerDestinationButtons[i].Visible = true;
|
||||
PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerDestinationButtons[i].Visible = false;
|
||||
PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < NumPlayer; i++)
|
||||
{
|
||||
if (i < Data.ScreenNames.ProfileIDs.Count)
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDs[i] != -1)
|
||||
{
|
||||
PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerDestinationButtons[i].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].Avatar.Texture;
|
||||
PlayerDestinationButtons[i].STexture = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].Avatar.Texture;
|
||||
PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].PlayerName;
|
||||
PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerDestinationButtons[i].Color = Buttons[ButtonPlayerDestination].Color;
|
||||
PlayerDestinationButtons[i].SColor = Buttons[ButtonPlayerDestination].SColor;
|
||||
PlayerDestinationButtons[i].Texture = Buttons[ButtonPlayerDestination].Texture;
|
||||
PlayerDestinationButtons[i].STexture = Buttons[ButtonPlayerDestination].STexture;
|
||||
PlayerDestinationButtons[i].Text.Text = String.Empty;
|
||||
PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonNext()
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDs.Count == NumPlayer)
|
||||
{
|
||||
Buttons[ButtonNext].Visible = true;
|
||||
SetInteractionToButton(Buttons[ButtonNext]);
|
||||
}
|
||||
else
|
||||
Buttons[ButtonNext].Visible = false;
|
||||
}
|
||||
|
||||
private bool OnAdd()
|
||||
{
|
||||
for (int i = 0; i < PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
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].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[PlayerChooseButtons[i].ProfileID].Avatar.Texture;
|
||||
PlayerDestinationButtons[added].STexture = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,807 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
public enum ESongSource
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_ALLSONGS,
|
||||
TR_CATEGORY,
|
||||
TR_PLAYLIST
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum EPartyGameMode
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_GAMEMODE_NORMAL,
|
||||
TR_GAMEMODE_SHORTSONG,
|
||||
TR_GAMEMODE_DUET
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public class CRound
|
||||
{
|
||||
public int SongID;
|
||||
public int SingerTeam1;
|
||||
public int SingerTeam2;
|
||||
public int PointsTeam1;
|
||||
public int PointsTeam2;
|
||||
public int Winner;
|
||||
public bool Finished = false;
|
||||
}
|
||||
|
||||
#region Communication
|
||||
|
||||
#region ToScreen
|
||||
public struct SDataToScreenConfig
|
||||
{
|
||||
public int NumPlayerTeam1;
|
||||
public int NumPlayerTeam2;
|
||||
public int NumFields;
|
||||
public ESongSource SongSource;
|
||||
public int CategoryID;
|
||||
public int PlaylistID;
|
||||
public EPartyGameMode GameMode;
|
||||
}
|
||||
|
||||
public struct SDataToScreenNames
|
||||
{
|
||||
public int NumPlayerTeam1;
|
||||
public int NumPlayerTeam2;
|
||||
public List<int> ProfileIDsTeam1;
|
||||
public List<int> ProfileIDsTeam2;
|
||||
}
|
||||
|
||||
public struct SDataToScreenMain
|
||||
{
|
||||
public int CurrentRoundNr;
|
||||
public int Team;
|
||||
public int NumPlayerTeam1;
|
||||
public int NumPlayerTeam2;
|
||||
public int NumFields;
|
||||
public List<CRound> Rounds;
|
||||
public List<int> Songs;
|
||||
public List<int> ProfileIDsTeam1;
|
||||
public List<int> ProfileIDsTeam2;
|
||||
public List<int> PlayerTeam1;
|
||||
public List<int> PlayerTeam2;
|
||||
public int[] NumJokerRandom;
|
||||
public int[] NumJokerRetry;
|
||||
}
|
||||
|
||||
public struct SDataFromScreen
|
||||
{
|
||||
public SFromScreenConfig ScreenConfig;
|
||||
public SFromScreenNames ScreenNames;
|
||||
public SFromScreenMain ScreenMain;
|
||||
}
|
||||
|
||||
public struct SFromScreenConfig
|
||||
{
|
||||
public int NumPlayerTeam1;
|
||||
public int NumPlayerTeam2;
|
||||
public int NumFields;
|
||||
public ESongSource SongSource;
|
||||
public int CategoryID;
|
||||
public int PlaylistID;
|
||||
public EPartyGameMode GameMode;
|
||||
}
|
||||
|
||||
public struct SFromScreenNames
|
||||
{
|
||||
public bool FadeToConfig;
|
||||
public bool FadeToMain;
|
||||
public List<int> ProfileIDsTeam1;
|
||||
public List<int> ProfileIDsTeam2;
|
||||
}
|
||||
|
||||
public struct SFromScreenMain
|
||||
{
|
||||
public bool FadeToSinging;
|
||||
public bool FadeToNameSelection;
|
||||
public List<int> PlayerTeam1;
|
||||
public List<int> PlayerTeam2;
|
||||
public List<CRound> Rounds;
|
||||
public int SingRoundNr;
|
||||
public List<int> Songs;
|
||||
}
|
||||
#endregion FromScreen
|
||||
|
||||
#endregion Communication
|
||||
|
||||
public sealed class CPartyModeTicTacToe : CPartyMode
|
||||
{
|
||||
private const int _MaxPlayer = 20;
|
||||
private const int _MinPlayer = 2;
|
||||
private const int _MaxTeams = 2;
|
||||
private const int _MinTeams = 2;
|
||||
private const int _NumFields = 9;
|
||||
|
||||
private enum EStage
|
||||
{
|
||||
NotStarted,
|
||||
Config,
|
||||
Names,
|
||||
Main,
|
||||
Singing
|
||||
}
|
||||
|
||||
private struct SData
|
||||
{
|
||||
public int NumPlayerTeam1;
|
||||
public int NumPlayerTeam2;
|
||||
public int NumFields;
|
||||
public int Team;
|
||||
public List<int> ProfileIDsTeam1;
|
||||
public List<int> ProfileIDsTeam2;
|
||||
public List<int> PlayerTeam1;
|
||||
public List<int> PlayerTeam2;
|
||||
|
||||
public ESongSource SongSource;
|
||||
public int CategoryID;
|
||||
public int PlaylistID;
|
||||
|
||||
public EPartyGameMode GameMode;
|
||||
|
||||
public List<CRound> Rounds;
|
||||
public List<int> Songs;
|
||||
|
||||
public int CurrentRoundNr;
|
||||
public int SingRoundNr;
|
||||
|
||||
public int[] NumJokerRandom;
|
||||
public int[] NumJokerRetry;
|
||||
}
|
||||
|
||||
private SDataToScreenConfig _ToScreenConfig;
|
||||
private SDataToScreenNames _ToScreenNames;
|
||||
private SDataToScreenMain _ToScreenMain;
|
||||
|
||||
private SData _GameData;
|
||||
private EStage _Stage;
|
||||
|
||||
public CPartyModeTicTacToe()
|
||||
{
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;
|
||||
_ScreenSongOptions.Selection.PartyMode = true;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = true;
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] {5, 5};
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"};
|
||||
|
||||
_ScreenSongOptions.Sorting.SearchString = String.Empty;
|
||||
_ScreenSongOptions.Sorting.SearchActive = false;
|
||||
_ScreenSongOptions.Sorting.DuetOptions = EDuetOptions.NoDuets;
|
||||
|
||||
_Stage = EStage.NotStarted;
|
||||
|
||||
_ToScreenConfig = new SDataToScreenConfig();
|
||||
_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];
|
||||
}
|
||||
|
||||
public override bool Init()
|
||||
{
|
||||
_Stage = EStage.NotStarted;
|
||||
|
||||
_ScreenSongOptions.Sorting.IgnoreArticles = CBase.Config.GetIgnoreArticles();
|
||||
_ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting();
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_OFF;
|
||||
_ScreenSongOptions.Selection.SongIndex = -1;
|
||||
|
||||
if (CBase.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE)
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
|
||||
|
||||
_ToScreenMain.Rounds = new List<CRound>();
|
||||
_ToScreenMain.Songs = new List<int>();
|
||||
_ToScreenMain.PlayerTeam1 = new List<int>();
|
||||
_ToScreenMain.PlayerTeam2 = new List<int>();
|
||||
_GameData.Songs = new List<int>();
|
||||
_GameData.Rounds = new List<CRound>();
|
||||
_GameData.PlayerTeam1 = new List<int>();
|
||||
_GameData.PlayerTeam2 = new List<int>();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void DataFromScreen(string screenName, Object data)
|
||||
{
|
||||
SDataFromScreen dataFrom = new SDataFromScreen();
|
||||
switch (screenName)
|
||||
{
|
||||
case "PartyScreenTicTacToeConfig":
|
||||
|
||||
try
|
||||
{
|
||||
dataFrom = (SDataFromScreen)data;
|
||||
_GameData.NumPlayerTeam1 = dataFrom.ScreenConfig.NumPlayerTeam1;
|
||||
_GameData.NumPlayerTeam2 = dataFrom.ScreenConfig.NumPlayerTeam2;
|
||||
_GameData.NumFields = dataFrom.ScreenConfig.NumFields;
|
||||
_GameData.SongSource = dataFrom.ScreenConfig.SongSource;
|
||||
_GameData.CategoryID = dataFrom.ScreenConfig.CategoryID;
|
||||
_GameData.PlaylistID = dataFrom.ScreenConfig.PlaylistID;
|
||||
_GameData.GameMode = dataFrom.ScreenConfig.GameMode;
|
||||
|
||||
_Stage = EStage.Config;
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode TicTacToe. Can't cast received data from screen " + screenName + ". " + e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PartyScreenTicTacToeNames":
|
||||
try
|
||||
{
|
||||
dataFrom = (SDataFromScreen)data;
|
||||
if (dataFrom.ScreenNames.FadeToConfig)
|
||||
_Stage = EStage.NotStarted;
|
||||
else
|
||||
{
|
||||
if (CBase.Game.GetRandom(100) < 50)
|
||||
_GameData.Team = 0;
|
||||
else
|
||||
_GameData.Team = 1;
|
||||
_GameData.ProfileIDsTeam1 = dataFrom.ScreenNames.ProfileIDsTeam1;
|
||||
_GameData.ProfileIDsTeam2 = dataFrom.ScreenNames.ProfileIDsTeam2;
|
||||
_Stage = EStage.Names;
|
||||
}
|
||||
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode TicTacToe. Can't cast received data from screen " + screenName + ". " + e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PartyScreenTicTacToeMain":
|
||||
try
|
||||
{
|
||||
dataFrom = (SDataFromScreen)data;
|
||||
if (dataFrom.ScreenMain.FadeToSinging)
|
||||
{
|
||||
_Stage = EStage.Singing;
|
||||
_GameData.Rounds = dataFrom.ScreenMain.Rounds;
|
||||
_GameData.SingRoundNr = dataFrom.ScreenMain.SingRoundNr;
|
||||
_GameData.Songs = dataFrom.ScreenMain.Songs;
|
||||
_GameData.PlayerTeam1 = dataFrom.ScreenMain.PlayerTeam1;
|
||||
_GameData.PlayerTeam2 = dataFrom.ScreenMain.PlayerTeam2;
|
||||
}
|
||||
if (dataFrom.ScreenMain.FadeToNameSelection)
|
||||
_Stage = EStage.Config;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode TicTacToe. Can't cast received data from screen " + screenName + ". " + e.Message);
|
||||
}
|
||||
|
||||
|
||||
if (_Stage == EStage.Singing)
|
||||
_StartRound(dataFrom.ScreenMain.SingRoundNr);
|
||||
if (_Stage == EStage.Config)
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
break;
|
||||
|
||||
default:
|
||||
CBase.Log.LogError("Error in party mode TicTacToe. Wrong screen is sending: " + screenName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateGame()
|
||||
{
|
||||
/*
|
||||
if (CBase.Songs.GetCurrentCategoryIndex() != -1 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF)
|
||||
_ScreenSongOptions.Selection.RandomOnly = true;
|
||||
else
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;*/
|
||||
}
|
||||
|
||||
public override CMenuParty GetNextPartyScreen(out EScreens alternativeScreen)
|
||||
{
|
||||
CMenuParty screen = null;
|
||||
alternativeScreen = EScreens.ScreenSong;
|
||||
|
||||
switch (_Stage)
|
||||
{
|
||||
case EStage.NotStarted:
|
||||
_Screens.TryGetValue("CPartyScreenTicTacToeConfig", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
_ToScreenConfig.NumPlayerTeam1 = _GameData.NumPlayerTeam1;
|
||||
_ToScreenConfig.NumPlayerTeam2 = _GameData.NumPlayerTeam2;
|
||||
_ToScreenConfig.NumFields = _GameData.NumFields;
|
||||
_ToScreenConfig.SongSource = _GameData.SongSource;
|
||||
_ToScreenConfig.CategoryID = _GameData.CategoryID;
|
||||
_ToScreenConfig.PlaylistID = _GameData.PlaylistID;
|
||||
_ToScreenConfig.GameMode = _GameData.GameMode;
|
||||
screen.DataToScreen(_ToScreenConfig);
|
||||
}
|
||||
break;
|
||||
case EStage.Config:
|
||||
_Screens.TryGetValue("CPartyScreenTicTacToeNames", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
_ToScreenNames.NumPlayerTeam1 = _GameData.NumPlayerTeam1;
|
||||
_ToScreenNames.NumPlayerTeam2 = _GameData.NumPlayerTeam2;
|
||||
_ToScreenNames.ProfileIDsTeam1 = _GameData.ProfileIDsTeam1;
|
||||
_ToScreenNames.ProfileIDsTeam2 = _GameData.ProfileIDsTeam2;
|
||||
screen.DataToScreen(_ToScreenNames);
|
||||
}
|
||||
break;
|
||||
case EStage.Names:
|
||||
_Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
if (_GameData.Team == 1)
|
||||
_GameData.Team = 0;
|
||||
else
|
||||
_GameData.Team = 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;
|
||||
_CreateRounds();
|
||||
_SetNumJokers();
|
||||
_PreparePlayerList(0);
|
||||
_PrepareSongList();
|
||||
_ToScreenMain.Rounds = _GameData.Rounds;
|
||||
_ToScreenMain.Songs = _GameData.Songs;
|
||||
_ToScreenMain.PlayerTeam1 = _GameData.PlayerTeam1;
|
||||
_ToScreenMain.PlayerTeam1 = _GameData.PlayerTeam2;
|
||||
_ToScreenMain.NumJokerRandom = _GameData.NumJokerRandom;
|
||||
_ToScreenMain.NumJokerRetry = _GameData.NumJokerRetry;
|
||||
_ToScreenMain.Team = _GameData.Team;
|
||||
screen.DataToScreen(_ToScreenMain);
|
||||
}
|
||||
break;
|
||||
case EStage.Main:
|
||||
//nothing to do
|
||||
break;
|
||||
case EStage.Singing:
|
||||
_Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen);
|
||||
if (screen != null)
|
||||
{
|
||||
if (_GameData.Team == 1)
|
||||
_GameData.Team = 0;
|
||||
else
|
||||
_GameData.Team = 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;
|
||||
_ToScreenMain.Rounds = _GameData.Rounds;
|
||||
_ToScreenMain.Songs = _GameData.Songs;
|
||||
_ToScreenMain.PlayerTeam1 = _GameData.PlayerTeam1;
|
||||
_ToScreenMain.PlayerTeam2 = _GameData.PlayerTeam2;
|
||||
_ToScreenMain.NumJokerRandom = _GameData.NumJokerRandom;
|
||||
_ToScreenMain.NumJokerRetry = _GameData.NumJokerRetry;
|
||||
_ToScreenMain.Team = _GameData.Team;
|
||||
screen.DataToScreen(_ToScreenMain);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return screen;
|
||||
}
|
||||
|
||||
public override EScreens GetStartScreen()
|
||||
{
|
||||
return EScreens.ScreenPartyDummy;
|
||||
}
|
||||
|
||||
public override EScreens GetMainScreen()
|
||||
{
|
||||
return EScreens.ScreenPartyDummy;
|
||||
}
|
||||
|
||||
public override SScreenSongOptions GetScreenSongOptions()
|
||||
{
|
||||
_ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting();
|
||||
_ScreenSongOptions.Sorting.Tabs = CBase.Config.GetTabs();
|
||||
_ScreenSongOptions.Sorting.IgnoreArticles = CBase.Config.GetIgnoreArticles();
|
||||
|
||||
return _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
|
||||
{
|
||||
screenSongOptions = _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
|
||||
{
|
||||
screenSongOptions = _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void SetSearchString(string searchString, bool visible)
|
||||
{
|
||||
_ScreenSongOptions.Sorting.SearchString = searchString;
|
||||
_ScreenSongOptions.Sorting.SearchActive = visible;
|
||||
}
|
||||
|
||||
public override int GetMaxPlayer()
|
||||
{
|
||||
return _MaxPlayer;
|
||||
}
|
||||
|
||||
public override int GetMinPlayer()
|
||||
{
|
||||
return _MinPlayer;
|
||||
}
|
||||
|
||||
public override int GetMaxTeams()
|
||||
{
|
||||
return _MaxTeams;
|
||||
}
|
||||
|
||||
public override int GetMinTeams()
|
||||
{
|
||||
return _MinTeams;
|
||||
}
|
||||
|
||||
public override int GetMaxNumRounds()
|
||||
{
|
||||
return _NumFields;
|
||||
}
|
||||
|
||||
public override void JokerUsed(int teamNr) {}
|
||||
|
||||
public override void SongSelected(int songID)
|
||||
{
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
switch (_GameData.GameMode)
|
||||
{
|
||||
case EPartyGameMode.TR_GAMEMODE_NORMAL:
|
||||
gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_DUET:
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
|
||||
gm = EGameMode.TR_GAMEMODE_SHORTSONG;
|
||||
break;
|
||||
}
|
||||
CBase.Game.AddSong(songID, gm);
|
||||
|
||||
CBase.Songs.AddPartySongSung(songID);
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenSing);
|
||||
}
|
||||
|
||||
public override void LeavingHighscore()
|
||||
{
|
||||
_UpdateScores();
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
|
||||
private void _CreateRounds()
|
||||
{
|
||||
_GameData.Rounds = new List<CRound>();
|
||||
for (int i = 0; i < _GameData.NumFields; i++)
|
||||
{
|
||||
CRound r = new CRound();
|
||||
_GameData.Rounds.Add(r);
|
||||
}
|
||||
}
|
||||
|
||||
private void _PreparePlayerList(int team)
|
||||
{
|
||||
if (team == 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);
|
||||
}
|
||||
if (iDs2.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < _GameData.NumPlayerTeam2; i++)
|
||||
iDs2.Add(i);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _PrepareSongList()
|
||||
{
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
switch (_GameData.GameMode)
|
||||
{
|
||||
case EPartyGameMode.TR_GAMEMODE_NORMAL:
|
||||
gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_DUET:
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
|
||||
gm = EGameMode.TR_GAMEMODE_SHORTSONG;
|
||||
break;
|
||||
}
|
||||
|
||||
while (_GameData.Songs.Count < (_GameData.NumFields + _GameData.NumJokerRandom[0] + _GameData.NumJokerRandom[1]))
|
||||
{
|
||||
List<int> songs = new List<int>();
|
||||
switch (_GameData.SongSource)
|
||||
{
|
||||
case ESongSource.TR_PLAYLIST:
|
||||
for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(_GameData.PlaylistID); i++)
|
||||
{
|
||||
int id = CBase.Playlist.GetPlaylistSong(_GameData.PlaylistID, i).SongID;
|
||||
foreach (EGameMode mode in CBase.Songs.GetSongByID(id).AvailableGameModes)
|
||||
{
|
||||
if (mode == gm)
|
||||
songs.Add(id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ESongSource.TR_ALLSONGS:
|
||||
for (int i = 0; i < CBase.Songs.GetNumSongs(); i++)
|
||||
{
|
||||
foreach (EGameMode mode in CBase.Songs.GetSongByID(i).AvailableGameModes)
|
||||
{
|
||||
if (mode == gm)
|
||||
songs.Add(i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ESongSource.TR_CATEGORY:
|
||||
CBase.Songs.SetCategory(_GameData.CategoryID);
|
||||
for (int i = 0; i < CBase.Songs.NumSongsInCategory(_GameData.CategoryID); i++)
|
||||
{
|
||||
foreach (EGameMode mode in CBase.Songs.GetVisibleSong(i).AvailableGameModes)
|
||||
{
|
||||
if (mode == gm)
|
||||
songs.Add(CBase.Songs.GetVisibleSong(i).ID);
|
||||
}
|
||||
}
|
||||
CBase.Songs.SetCategory(-1);
|
||||
break;
|
||||
}
|
||||
while (songs.Count > 0)
|
||||
{
|
||||
_GameData.Songs.Add(songs[CBase.Game.GetRandom(songs.Count - 1)]);
|
||||
songs.Remove(_GameData.Songs[_GameData.Songs.Count - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdatePlayerList()
|
||||
{
|
||||
if (_GameData.PlayerTeam1.Count == 0)
|
||||
_PreparePlayerList(1);
|
||||
if (_GameData.PlayerTeam2.Count == 0)
|
||||
_PreparePlayerList(2);
|
||||
}
|
||||
|
||||
private void _UpdateSongList()
|
||||
{
|
||||
if (_GameData.Songs.Count == 0)
|
||||
_PrepareSongList();
|
||||
}
|
||||
|
||||
private void _StartRound(int roundNr)
|
||||
{
|
||||
CBase.Game.Reset();
|
||||
CBase.Game.ClearSongs();
|
||||
|
||||
CBase.Game.SetNumPlayer(2);
|
||||
|
||||
SPlayer[] player = CBase.Game.GetPlayer();
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (player.Length < 2)
|
||||
return;
|
||||
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
CRound r = _GameData.Rounds[roundNr];
|
||||
bool isDuet = CBase.Songs.GetSongByID(r.SongID).IsDuet;
|
||||
|
||||
for (int i = 0; i < 2; 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 (r != null)
|
||||
{
|
||||
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()
|
||||
{
|
||||
switch (_GameData.NumFields)
|
||||
{
|
||||
case 9:
|
||||
_GameData.NumJokerRandom[0] = 1;
|
||||
_GameData.NumJokerRandom[1] = 1;
|
||||
_GameData.NumJokerRetry[0] = 0;
|
||||
_GameData.NumJokerRetry[1] = 0;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
_GameData.NumJokerRandom[0] = 2;
|
||||
_GameData.NumJokerRandom[1] = 2;
|
||||
_GameData.NumJokerRetry[0] = 1;
|
||||
_GameData.NumJokerRetry[1] = 1;
|
||||
break;
|
||||
|
||||
case 25:
|
||||
_GameData.NumJokerRandom[0] = 3;
|
||||
_GameData.NumJokerRandom[1] = 3;
|
||||
_GameData.NumJokerRetry[0] = 2;
|
||||
_GameData.NumJokerRetry[1] = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateScores()
|
||||
{
|
||||
if (!_GameData.Rounds[_GameData.SingRoundNr].Finished)
|
||||
_GameData.CurrentRoundNr++;
|
||||
|
||||
SPlayer[] results = CBase.Game.GetPlayer();
|
||||
if (results == null)
|
||||
return;
|
||||
|
||||
if (results.Length < 2)
|
||||
return;
|
||||
|
||||
_GameData.Rounds[_GameData.SingRoundNr].PointsTeam1 = (int)Math.Round(results[0].Points);
|
||||
_GameData.Rounds[_GameData.SingRoundNr].PointsTeam2 = (int)Math.Round(results[1].Points);
|
||||
_GameData.Rounds[_GameData.SingRoundNr].Finished = true;
|
||||
if (_GameData.Rounds[_GameData.SingRoundNr].PointsTeam1 < _GameData.Rounds[_GameData.SingRoundNr].PointsTeam2)
|
||||
_GameData.Rounds[_GameData.SingRoundNr].Winner = 2;
|
||||
else if (_GameData.Rounds[_GameData.SingRoundNr].PointsTeam1 > _GameData.Rounds[_GameData.SingRoundNr].PointsTeam2)
|
||||
_GameData.Rounds[_GameData.SingRoundNr].Winner = 1;
|
||||
else
|
||||
{
|
||||
_GameData.Rounds[_GameData.SingRoundNr].Finished = false;
|
||||
_GameData.CurrentRoundNr--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
public class CPartyScreenTicTacToeConfig : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string _SelectSlideNumPlayerTeam1 = "SelectSlideNumPlayerTeam1";
|
||||
private const string _SelectSlideNumPlayerTeam2 = "SelectSlideNumPlayerTeam2";
|
||||
private const string _SelectSlideNumFields = "SelectSlideNumFields";
|
||||
private const string _SelectSlideSongSource = "SelectSlideSongSource";
|
||||
private const string _SelectSlidePlaylist = "SelectSlidePlaylist";
|
||||
private const string _SelectSlideCategory = "SelectSlideCategory";
|
||||
private const string _SelectSlideGameMode = "SelectSlideGameMode";
|
||||
private const string _ButtonNext = "ButtonNext";
|
||||
private const string _ButtonBack = "ButtonBack";
|
||||
|
||||
private bool _ConfigOk = true;
|
||||
|
||||
private SDataFromScreen _Data;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeSelectSlides = new string[]
|
||||
{_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;
|
||||
_Data.ScreenConfig = config;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object receivedData)
|
||||
{
|
||||
SDataToScreenConfig config = new SDataToScreenConfig();
|
||||
|
||||
try
|
||||
{
|
||||
config = (SDataToScreenConfig)receivedData;
|
||||
_Data.ScreenConfig.NumFields = config.NumFields;
|
||||
_Data.ScreenConfig.NumPlayerTeam1 = config.NumPlayerTeam1;
|
||||
_Data.ScreenConfig.NumPlayerTeam2 = config.NumPlayerTeam2;
|
||||
_Data.ScreenConfig.PlaylistID = config.PlaylistID;
|
||||
_Data.ScreenConfig.CategoryID = config.CategoryID;
|
||||
_Data.ScreenConfig.SongSource = config.SongSource;
|
||||
_Data.ScreenConfig.GameMode = config.GameMode;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen TicTacToe config. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
_Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
_UpdateSlides();
|
||||
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
_UpdateSlides();
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
_UpdateSlides();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
_UpdateSlides();
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
_Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
if (CBase.Config.GetMaxNumMics() >= 2)
|
||||
_ConfigOk = true;
|
||||
|
||||
_FillSlides();
|
||||
_UpdateSlides();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
Buttons[_ButtonNext].Visible = _ConfigOk;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _FillSlides()
|
||||
{
|
||||
// build num player slide (min player ... max player);
|
||||
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[_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[_SelectSlideNumFields].Clear();
|
||||
SelectSlides[_SelectSlideNumFields].AddValue("9");
|
||||
SelectSlides[_SelectSlideNumFields].AddValue("16");
|
||||
SelectSlides[_SelectSlideNumFields].AddValue("25");
|
||||
if (_Data.ScreenConfig.NumFields == 9)
|
||||
SelectSlides[_SelectSlideNumFields].Selection = 0;
|
||||
else if (_Data.ScreenConfig.NumFields == 16)
|
||||
SelectSlides[_SelectSlideNumFields].Selection = 1;
|
||||
else if (_Data.ScreenConfig.NumFields == 25)
|
||||
SelectSlides[_SelectSlideNumFields].Selection = 2;
|
||||
|
||||
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++)
|
||||
{
|
||||
string value = playlists[i] + " (" + CBase.Playlist.GetPlaylistSongCount(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")";
|
||||
SelectSlides[_SelectSlidePlaylist].AddValue(value);
|
||||
}
|
||||
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();
|
||||
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].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);
|
||||
}
|
||||
|
||||
private void _UpdateSlides()
|
||||
{
|
||||
_Data.ScreenConfig.NumPlayerTeam1 = SelectSlides[_SelectSlideNumPlayerTeam1].Selection + (_PartyMode.GetMinPlayer() / 2);
|
||||
_Data.ScreenConfig.NumPlayerTeam2 = SelectSlides[_SelectSlideNumPlayerTeam2].Selection + (_PartyMode.GetMinPlayer() / 2);
|
||||
|
||||
if (SelectSlides[_SelectSlideNumFields].Selection == 0)
|
||||
_Data.ScreenConfig.NumFields = 9;
|
||||
else if (SelectSlides[_SelectSlideNumFields].Selection == 1)
|
||||
_Data.ScreenConfig.NumFields = 16;
|
||||
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;
|
||||
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
switch (_Data.ScreenConfig.GameMode)
|
||||
{
|
||||
case EPartyGameMode.TR_GAMEMODE_NORMAL:
|
||||
gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_DUET:
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
|
||||
gm = EGameMode.TR_GAMEMODE_SHORTSONG;
|
||||
break;
|
||||
}
|
||||
|
||||
if (_Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST)
|
||||
{
|
||||
if (CBase.Playlist.GetNumPlaylists() > 0)
|
||||
{
|
||||
if (CBase.Playlist.GetPlaylistSongCount(_Data.ScreenConfig.PlaylistID) > 0)
|
||||
{
|
||||
_ConfigOk = false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (_ConfigOk)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
_ConfigOk = false;
|
||||
}
|
||||
else
|
||||
_ConfigOk = false;
|
||||
}
|
||||
if (_Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY)
|
||||
{
|
||||
if (CBase.Songs.GetNumCategories() > 0)
|
||||
{
|
||||
if (CBase.Songs.NumSongsInCategory(_Data.ScreenConfig.CategoryID) > 0)
|
||||
{
|
||||
CBase.Songs.SetCategory(_Data.ScreenConfig.CategoryID);
|
||||
_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;
|
||||
}
|
||||
}
|
||||
if (_ConfigOk)
|
||||
break;
|
||||
}
|
||||
CBase.Songs.SetCategory(-1);
|
||||
}
|
||||
else
|
||||
_ConfigOk = false;
|
||||
}
|
||||
else
|
||||
_ConfigOk = false;
|
||||
}
|
||||
if (_Data.ScreenConfig.SongSource == ESongSource.TR_ALLSONGS)
|
||||
{
|
||||
if (CBase.Songs.GetNumSongs() > 0)
|
||||
{
|
||||
for (int i = 0; i < CBase.Songs.GetNumSongs(); i++)
|
||||
{
|
||||
foreach (EGameMode mode in CBase.Songs.GetSongByID(i).AvailableGameModes)
|
||||
{
|
||||
if (mode == gm)
|
||||
{
|
||||
_ConfigOk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_ConfigOk)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
_ConfigOk = false;
|
||||
}
|
||||
SelectSlides[_SelectSlideCategory].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY;
|
||||
SelectSlides[_SelectSlidePlaylist].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST;
|
||||
}
|
||||
|
||||
private void _Back()
|
||||
{
|
||||
_FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void _Next()
|
||||
{
|
||||
_PartyMode.DataFromScreen(ThemeName, _Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,711 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Menu.SongMenu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
public class CField
|
||||
{
|
||||
public CRound Content;
|
||||
public CButton Button;
|
||||
}
|
||||
|
||||
public enum EStatus
|
||||
{
|
||||
FieldChoosing,
|
||||
JokerRetry,
|
||||
FieldSelected,
|
||||
None
|
||||
}
|
||||
|
||||
public class CPartyScreenTicTacToeMain : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string _TextPopupReallyExit = "TextPopupReallyExit";
|
||||
private const string _TextTeamChoosing = "TextTeamChoosing";
|
||||
private const string _TextFinishMessage = "TextFinishMessage";
|
||||
private const string _TextNextPlayerT1 = "TextNextPlayerT1";
|
||||
private const string _TextNextPlayerT2 = "TextNextPlayerT2";
|
||||
private const string _TextNextPlayerNameT1 = "TextNextPlayerNameT1";
|
||||
private const string _TextNextPlayerNameT2 = "TextNextPlayerNameT2";
|
||||
|
||||
private const string _ButtonNextRound = "ButtonNextRound";
|
||||
private const string _ButtonBack = "ButtonBack";
|
||||
private const string _ButtonExit = "ButtonExit";
|
||||
private const string _ButtonPopupYes = "ButtonPopupYes";
|
||||
private const string _ButtonPopupNo = "ButtonPopupNo";
|
||||
private const string _ButtonField = "ButtonField";
|
||||
|
||||
private const string _ButtonJokerRandomT1 = "ButtonJokerRandomT1";
|
||||
private const string _ButtonJokerRandomT2 = "ButtonJokerRandomT2";
|
||||
private const string _ButtonJokerRetryT1 = "ButtonJokerRetryT1";
|
||||
private const string _ButtonJokerRetryT2 = "ButtonJokerRetryT2";
|
||||
|
||||
private const string _StaticPopupBG = "StaticPopupBG";
|
||||
private const string _StaticAvatarT1 = "StaticAvatarT1";
|
||||
private const string _StaticAvatarT2 = "StaticAvatarT2";
|
||||
|
||||
private bool _ExitPopupVisible;
|
||||
|
||||
private SDataFromScreen _Data;
|
||||
private SDataToScreenMain _GameData;
|
||||
|
||||
private List<CField> _Fields;
|
||||
private float _FieldFirstX = 25;
|
||||
private float _FieldFirstY = 25;
|
||||
private int _FieldSpace = 10;
|
||||
private float _FieldSize = 100;
|
||||
|
||||
private int _PreviewStream = -1;
|
||||
private int _SelectedField = -1;
|
||||
private int _OldSelectedField = -1;
|
||||
|
||||
private int[,] _Possibilities;
|
||||
private EStatus _Status;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeTexts = new string[] {_TextPopupReallyExit, _TextTeamChoosing, _TextFinishMessage, _TextNextPlayerT1, _TextNextPlayerT2, _TextNextPlayerNameT1, _TextNextPlayerNameT2};
|
||||
_ThemeButtons = new string[]
|
||||
{
|
||||
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonField, _ButtonJokerRandomT1, _ButtonJokerRandomT2, _ButtonJokerRetryT1,
|
||||
_ButtonJokerRetryT2
|
||||
};
|
||||
_ThemeStatics = new string[] {_StaticPopupBG, _StaticAvatarT1, _StaticAvatarT2};
|
||||
|
||||
_Data = new SDataFromScreen();
|
||||
SFromScreenMain config = new SFromScreenMain();
|
||||
_GameData = new SDataToScreenMain();
|
||||
config.SingRoundNr = 1;
|
||||
config.Rounds = new List<CRound>();
|
||||
config.Songs = new List<int>();
|
||||
config.PlayerTeam1 = new List<int>();
|
||||
config.PlayerTeam2 = new List<int>();
|
||||
config.FadeToNameSelection = false;
|
||||
config.FadeToSinging = false;
|
||||
_Data.ScreenMain = config;
|
||||
|
||||
_Fields = new List<CField>();
|
||||
}
|
||||
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
base.LoadTheme(xmlPath);
|
||||
|
||||
_CreateFields();
|
||||
Buttons[_ButtonField].Visible = false;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object receivedData)
|
||||
{
|
||||
SDataToScreenMain config = new SDataToScreenMain();
|
||||
|
||||
try
|
||||
{
|
||||
config = (SDataToScreenMain)receivedData;
|
||||
_GameData = config;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen TicTacToe main. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
|
||||
_Back();
|
||||
else if (_Status == EStatus.None)
|
||||
_EndParty();
|
||||
else
|
||||
_ShowPopup(true);
|
||||
}
|
||||
else
|
||||
_ShowPopup(false);
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[_ButtonNextRound].Selected)
|
||||
_NextRound();
|
||||
if (Buttons[_ButtonBack].Selected && _GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
|
||||
_Back();
|
||||
if (Buttons[_ButtonExit].Selected && (_GameData.CurrentRoundNr > 1 || _Status == EStatus.FieldSelected) && _Status != EStatus.None)
|
||||
_ShowPopup(true);
|
||||
else if (_Status == EStatus.None)
|
||||
_EndParty();
|
||||
for (int i = 0; i < _GameData.NumFields; i++)
|
||||
{
|
||||
switch (_Status)
|
||||
{
|
||||
case EStatus.FieldChoosing:
|
||||
if (_Fields[i].Button.Selected)
|
||||
{
|
||||
_SelectedField = i;
|
||||
_FieldSelected();
|
||||
}
|
||||
break;
|
||||
|
||||
case EStatus.JokerRetry:
|
||||
if (_Fields[i].Button.Selected)
|
||||
{
|
||||
_SelectedField = i;
|
||||
_FieldSelectedAgain();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_Status == EStatus.FieldSelected)
|
||||
{
|
||||
if (Buttons[_ButtonJokerRandomT1].Selected)
|
||||
_UseJoker(0, 0);
|
||||
if (Buttons[_ButtonJokerRandomT2].Selected)
|
||||
_UseJoker(1, 0);
|
||||
if (Buttons[_ButtonJokerRetryT1].Selected)
|
||||
_UseJoker(0, 1);
|
||||
if (Buttons[_ButtonJokerRetryT2].Selected)
|
||||
_UseJoker(1, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[_ButtonPopupYes].Selected)
|
||||
_EndParty();
|
||||
if (Buttons[_ButtonPopupNo].Selected)
|
||||
_ShowPopup(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[_ButtonNextRound].Selected)
|
||||
_NextRound();
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
if (Buttons[_ButtonExit].Selected)
|
||||
{
|
||||
if (_Status == EStatus.None)
|
||||
_EndParty();
|
||||
else
|
||||
_ShowPopup(true);
|
||||
}
|
||||
for (int i = 0; i < _GameData.NumFields; i++)
|
||||
{
|
||||
switch (_Status)
|
||||
{
|
||||
case EStatus.FieldChoosing:
|
||||
if (_Fields[i].Button.Selected)
|
||||
{
|
||||
_SelectedField = i;
|
||||
_FieldSelected();
|
||||
}
|
||||
break;
|
||||
|
||||
case EStatus.JokerRetry:
|
||||
if (_Fields[i].Button.Selected)
|
||||
{
|
||||
_SelectedField = i;
|
||||
_FieldSelectedAgain();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_Status == EStatus.FieldSelected)
|
||||
{
|
||||
if (Buttons[_ButtonJokerRandomT1].Selected)
|
||||
_UseJoker(0, 0);
|
||||
if (Buttons[_ButtonJokerRandomT2].Selected)
|
||||
_UseJoker(1, 0);
|
||||
if (Buttons[_ButtonJokerRetryT1].Selected)
|
||||
_UseJoker(0, 1);
|
||||
if (Buttons[_ButtonJokerRetryT2].Selected)
|
||||
_UseJoker(1, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[_ButtonPopupYes].Selected)
|
||||
_EndParty();
|
||||
if (Buttons[_ButtonPopupNo].Selected)
|
||||
_ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
{
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
|
||||
_Back();
|
||||
else if (_Status == EStatus.None)
|
||||
_EndParty();
|
||||
else
|
||||
_ShowPopup(true);
|
||||
}
|
||||
else
|
||||
_ShowPopup(false);
|
||||
}
|
||||
|
||||
if (mouseEvent.Wheel != 0) {}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
_PreviewStream = -1;
|
||||
|
||||
if (_GameData.CurrentRoundNr == 1)
|
||||
{
|
||||
_BuildWinnerPossibilities();
|
||||
_SelectedField = -1;
|
||||
Buttons[_ButtonBack].Visible = true;
|
||||
Buttons[_ButtonExit].Visible = false;
|
||||
SetInteractionToButton(Buttons[_ButtonBack]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[_ButtonBack].Visible = false;
|
||||
Buttons[_ButtonExit].Visible = true;
|
||||
SetInteractionToButton(Buttons[_ButtonExit]);
|
||||
}
|
||||
|
||||
_Status = EStatus.FieldChoosing;
|
||||
|
||||
_UpdateFields();
|
||||
_UpdateFieldContents();
|
||||
|
||||
int winner = _GetWinner();
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Status = EStatus.None;
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
Texts[_TextFinishMessage].Color = new SColorF(1, 1, 1, 1);
|
||||
Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", _PartyModeID);
|
||||
}
|
||||
SetInteractionToButton(Buttons[_ButtonExit]);
|
||||
}
|
||||
|
||||
_ShowPopup(false);
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
CBase.BackgroundMusic.SetStatus(false);
|
||||
CBase.Sound.FadeAndStop(_PreviewStream, 0f, 0.5f);
|
||||
}
|
||||
|
||||
private void _CreateFields()
|
||||
{
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
CField f = new CField();
|
||||
f.Button = GetNewButton(Buttons[_ButtonField]);
|
||||
f.Button.Visible = false;
|
||||
f.Content = new CRound();
|
||||
AddButton(f.Button);
|
||||
_Fields.Add(f);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
_FieldFirstY = 140 + (CBase.Settings.GetRenderH() - 140) / 2 - (numOneRow * _FieldSize + numOneRow * _FieldSpace) / 2;
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
float x = _FieldFirstX;
|
||||
float y = _FieldFirstY;
|
||||
for (int i = 0; i < _Fields.Count; i++)
|
||||
{
|
||||
if (i < _GameData.NumFields)
|
||||
{
|
||||
_Fields[i].Button.Rect.W = _FieldSize;
|
||||
_Fields[i].Button.Rect.H = _FieldSize;
|
||||
_Fields[i].Button.Rect.X = x;
|
||||
_Fields[i].Button.Rect.Y = y;
|
||||
_Fields[i].Button.Visible = true;
|
||||
_Fields[i].Button.Enabled = true;
|
||||
column++;
|
||||
if ((i + 1) >= numOneRow * (row + 1))
|
||||
{
|
||||
column = 0;
|
||||
row++;
|
||||
y = _FieldFirstY + _FieldSize * row + _FieldSpace * row;
|
||||
x = _FieldFirstX;
|
||||
}
|
||||
else
|
||||
x = _FieldFirstX + _FieldSize * column + _FieldSpace * column;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Fields[i].Button.Visible = false;
|
||||
_Fields[i].Button.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateFieldContents()
|
||||
{
|
||||
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].Content = _GameData.Rounds[i];
|
||||
if (_Fields[i].Content.Finished)
|
||||
{
|
||||
_Fields[i].Button.Enabled = false;
|
||||
_Fields[i].Button.Texture = CBase.Songs.GetSongByID(_Fields[i].Content.SongID).CoverTextureBig;
|
||||
_Fields[i].Button.Color = CBase.Theme.GetPlayerColor(_Fields[i].Content.Winner);
|
||||
_Fields[i].Button.SelColor = CBase.Theme.GetPlayerColor(_Fields[i].Content.Winner);
|
||||
}
|
||||
if (_Status == EStatus.FieldSelected && _SelectedField == i)
|
||||
{
|
||||
_Fields[i].Button.Texture = CBase.Songs.GetSongByID(_Fields[i].Content.SongID).CoverTextureBig;
|
||||
_Fields[i].Button.Color = new SColorF(1, 1, 1, 1);
|
||||
_Fields[i].Button.SelColor = new SColorF(1, 1, 1, 1);
|
||||
_Fields[i].Button.Enabled = false;
|
||||
}
|
||||
if (_Status == EStatus.JokerRetry && _Fields[i].Content.Finished)
|
||||
{
|
||||
_Fields[i].Button.SelColor = CBase.Theme.GetPlayerColor(_GameData.Team + 1);
|
||||
_Fields[i].Button.Enabled = true;
|
||||
}
|
||||
if (_Status == EStatus.JokerRetry && !_Fields[i].Content.Finished)
|
||||
_Fields[i].Button.Enabled = false;
|
||||
if (_Status == EStatus.FieldSelected)
|
||||
_Fields[i].Button.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void _FieldSelected()
|
||||
{
|
||||
int songID = 0;
|
||||
int singerTeam1 = 0;
|
||||
int singerTeam2 = 0;
|
||||
if (_GameData.Songs.Count > 0)
|
||||
{
|
||||
songID = _GameData.Songs[0];
|
||||
_GameData.Songs.RemoveAt(0);
|
||||
}
|
||||
if (_GameData.PlayerTeam1.Count > 0)
|
||||
{
|
||||
singerTeam1 = _GameData.PlayerTeam1[0];
|
||||
_GameData.PlayerTeam1.RemoveAt(0);
|
||||
}
|
||||
|
||||
if (_GameData.PlayerTeam2.Count > 0)
|
||||
{
|
||||
singerTeam2 = _GameData.PlayerTeam2[0];
|
||||
_GameData.PlayerTeam2.RemoveAt(0);
|
||||
}
|
||||
CSong song = CBase.Songs.GetSongByID(songID);
|
||||
|
||||
CBase.BackgroundMusic.SetStatus(true);
|
||||
|
||||
_PreviewStream = CBase.Sound.Load(song.GetMP3(), false);
|
||||
CBase.Sound.SetPosition(_PreviewStream, song.PreviewStart);
|
||||
CBase.Sound.SetStreamVolume(_PreviewStream, 0f);
|
||||
CBase.Sound.Play(_PreviewStream);
|
||||
CBase.Sound.Fade(_PreviewStream, CBase.Config.GetBackgroundMusicVolume(), 1f);
|
||||
_Status = EStatus.FieldSelected;
|
||||
_Fields[_SelectedField].Content.SongID = songID;
|
||||
_GameData.Rounds[_SelectedField].SongID = songID;
|
||||
_GameData.Rounds[_SelectedField].SingerTeam1 = singerTeam1;
|
||||
_GameData.Rounds[_SelectedField].SingerTeam2 = singerTeam2;
|
||||
_UpdateFieldContents();
|
||||
|
||||
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;
|
||||
|
||||
_UpdateJokerButtons();
|
||||
|
||||
Buttons[_ButtonNextRound].Visible = true;
|
||||
Buttons[_ButtonExit].Visible = true;
|
||||
Buttons[_ButtonBack].Visible = false;
|
||||
|
||||
SetInteractionToButton(Buttons[_ButtonNextRound]);
|
||||
}
|
||||
|
||||
private void _FieldSelectedAgain()
|
||||
{
|
||||
int songID = _Fields[_SelectedField].Content.SongID;
|
||||
CSong song = CBase.Songs.GetSongByID(songID);
|
||||
CBase.BackgroundMusic.SetStatus(true);
|
||||
|
||||
_PreviewStream = CBase.Sound.Load(song.GetMP3(), false);
|
||||
CBase.Sound.SetPosition(_PreviewStream, song.PreviewStart);
|
||||
CBase.Sound.SetStreamVolume(_PreviewStream, 0f);
|
||||
CBase.Sound.Play(_PreviewStream);
|
||||
CBase.Sound.Fade(_PreviewStream, CBase.Config.GetBackgroundMusicVolume(), 1f);
|
||||
_Status = EStatus.FieldSelected;
|
||||
_Fields[_SelectedField].Content.SongID = songID;
|
||||
_GameData.Rounds[_SelectedField].SongID = songID;
|
||||
_GameData.Rounds[_SelectedField].SingerTeam1 = _GameData.Rounds[_OldSelectedField].SingerTeam1;
|
||||
_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;
|
||||
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;
|
||||
|
||||
_UpdateJokerButtons();
|
||||
|
||||
Buttons[_ButtonNextRound].Visible = true;
|
||||
Buttons[_ButtonExit].Visible = true;
|
||||
Buttons[_ButtonBack].Visible = false;
|
||||
|
||||
SetInteractionToButton(Buttons[_ButtonNextRound]);
|
||||
}
|
||||
|
||||
private void _UseJoker(int teamNr, int jokerNum)
|
||||
{
|
||||
switch (jokerNum)
|
||||
{
|
||||
//Random-Joker
|
||||
case 0:
|
||||
if (_GameData.NumJokerRandom[teamNr] > 0)
|
||||
{
|
||||
_GameData.NumJokerRandom[teamNr]--;
|
||||
if (!CBase.Sound.IsFinished(_PreviewStream))
|
||||
CBase.Sound.FadeAndStop(_PreviewStream, 0, 1);
|
||||
_FieldSelected();
|
||||
}
|
||||
break;
|
||||
|
||||
//Retry-Joker
|
||||
case 1:
|
||||
if (_GameData.NumJokerRetry[teamNr] > 0 && _GameData.CurrentRoundNr > 1)
|
||||
{
|
||||
_GameData.NumJokerRetry[teamNr]--;
|
||||
_GameData.Team = teamNr;
|
||||
if (!CBase.Sound.IsFinished(_PreviewStream))
|
||||
CBase.Sound.FadeAndStop(_PreviewStream, 0, 1);
|
||||
_Status = EStatus.JokerRetry;
|
||||
_OldSelectedField = _SelectedField;
|
||||
_SelectedField = -1;
|
||||
_UpdateFieldContents();
|
||||
}
|
||||
break;
|
||||
}
|
||||
_UpdateJokerButtons();
|
||||
}
|
||||
|
||||
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);
|
||||
if (_Status == EStatus.JokerRetry || _Status == EStatus.FieldChoosing)
|
||||
Texts[_TextTeamChoosing].Visible = true;
|
||||
else
|
||||
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;
|
||||
}
|
||||
|
||||
private void _NextRound()
|
||||
{
|
||||
CBase.Sound.FadeAndStop(_PreviewStream, 0f, 0.5f);
|
||||
_Data.ScreenMain.Rounds = _GameData.Rounds;
|
||||
_Data.ScreenMain.FadeToNameSelection = false;
|
||||
_Data.ScreenMain.FadeToSinging = true;
|
||||
_Data.ScreenMain.Songs = _GameData.Songs;
|
||||
_Data.ScreenMain.SingRoundNr = _SelectedField;
|
||||
_Data.ScreenMain.PlayerTeam1 = _GameData.PlayerTeam1;
|
||||
_Data.ScreenMain.PlayerTeam2 = _GameData.PlayerTeam2;
|
||||
_PartyMode.DataFromScreen(ThemeName, _Data);
|
||||
}
|
||||
|
||||
private void _EndParty()
|
||||
{
|
||||
CBase.Sound.FadeAndStop(_PreviewStream, 0f, 0.5f);
|
||||
_FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void _ShowPopup(bool visible)
|
||||
{
|
||||
_ExitPopupVisible = visible;
|
||||
|
||||
Statics[_StaticPopupBG].Visible = _ExitPopupVisible;
|
||||
Texts[_TextPopupReallyExit].Visible = _ExitPopupVisible;
|
||||
Buttons[_ButtonPopupYes].Visible = _ExitPopupVisible;
|
||||
Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
|
||||
|
||||
if (_ExitPopupVisible)
|
||||
SetInteractionToButton(Buttons[_ButtonPopupNo]);
|
||||
}
|
||||
|
||||
private void _Back()
|
||||
{
|
||||
CBase.Sound.FadeAndStop(_PreviewStream, 0f, 0.5f);
|
||||
_Data.ScreenMain.FadeToNameSelection = true;
|
||||
_Data.ScreenMain.FadeToSinging = false;
|
||||
_Data.ScreenMain.SingRoundNr = _SelectedField;
|
||||
_PartyMode.DataFromScreen(ThemeName, _Data);
|
||||
}
|
||||
|
||||
private int _BuildWinnerPossibilities()
|
||||
{
|
||||
int numOneRow = (int)Math.Sqrt(_GameData.NumFields);
|
||||
_Possibilities = new int[(numOneRow * 2) + 2,numOneRow];
|
||||
for (int i = 0; i < _Possibilities.GetLength(0); i++)
|
||||
{
|
||||
if (i < numOneRow)
|
||||
{
|
||||
for (int c = 0; c < numOneRow; c++)
|
||||
_Possibilities[i, c] = i * numOneRow + c;
|
||||
}
|
||||
else if (i < numOneRow * 2)
|
||||
{
|
||||
for (int c = 0; c < numOneRow; c++)
|
||||
_Possibilities[i, c] = (i - numOneRow) + (c * numOneRow);
|
||||
}
|
||||
else if (i == _Possibilities.GetLength(0) - 2)
|
||||
{
|
||||
for (int c = 0; c < numOneRow; c++)
|
||||
_Possibilities[i, c] = (numOneRow + 1) * c;
|
||||
}
|
||||
else if (i == _Possibilities.GetLength(0) - 1)
|
||||
{
|
||||
for (int c = 0; c < numOneRow; c++)
|
||||
_Possibilities[i, c] = (numOneRow - 1) * c + (numOneRow - 1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int _GetWinner()
|
||||
{
|
||||
for (int i = 0; i < _Possibilities.GetLength(0); i++)
|
||||
{
|
||||
List<int> check = new List<int>();
|
||||
for (int j = 0; j < _Possibilities.GetLength(1); j++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,646 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
public class CPartyScreenTicTacToeNames : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string _ButtonNext = "ButtonNext";
|
||||
private const string _ButtonBack = "ButtonBack";
|
||||
private const string _ButtonPlayerDestination = "ButtonPlayerDestination";
|
||||
private const string _ButtonPlayerChoose = "ButtonPlayerChoose";
|
||||
private const string _ButtonPlayerChooseScrollUp = "ButtonPlayerChooseScrollUp";
|
||||
private const string _ButtonPlayerChooseScrollDown = "ButtonPlayerChooseScrollDown";
|
||||
|
||||
private List<CPlayerChooseButton> _PlayerChooseButtons;
|
||||
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;
|
||||
private const int _PlayerDestinationButtonsSpaceW = 25;
|
||||
//PlayerChooseButtons-Option
|
||||
private List<int> _PlayerChooseButtonsVisibleProfiles;
|
||||
private const int _PlayerChooseButtonsNumH = 10;
|
||||
private const int _PlayerChooseButtonsNumW = 2;
|
||||
private const int _PlayerChooseButtonsFirstX = 58;
|
||||
private const int _PlayerChooseButtonsFirstY = 105;
|
||||
private const int _PlayerChooseButtonsSpaceH = 15;
|
||||
private const int _PlayerChooseButtonsSpaceW = 25;
|
||||
private int _PlayerChooseButtonsOffset;
|
||||
|
||||
private CStatic _ChooseAvatarStatic;
|
||||
private bool _SelectingMouseActive;
|
||||
private int _OldMouseX;
|
||||
private int _OldMouseY;
|
||||
private int _SelectedPlayerNr = -1;
|
||||
private bool _ButtonsAdded;
|
||||
|
||||
private int _NumPlayerTeam1 = 2;
|
||||
private int _NumPlayerTeam2 = 2;
|
||||
|
||||
private SDataFromScreen _Data;
|
||||
|
||||
private class CPlayerChooseButton
|
||||
{
|
||||
public CButton Button;
|
||||
public int ProfileID;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ChooseAvatarStatic = GetNewStatic();
|
||||
_ChooseAvatarStatic.Visible = false;
|
||||
|
||||
_PlayerChooseButtonsVisibleProfiles = new List<int>();
|
||||
|
||||
_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>();
|
||||
_Data.ScreenNames = names;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object receivedData)
|
||||
{
|
||||
SDataToScreenNames config = new SDataToScreenNames();
|
||||
|
||||
try
|
||||
{
|
||||
config = (SDataToScreenNames)receivedData;
|
||||
_Data.ScreenNames.ProfileIDsTeam1 = config.ProfileIDsTeam1;
|
||||
_Data.ScreenNames.ProfileIDsTeam2 = config.ProfileIDsTeam2;
|
||||
if (_Data.ScreenNames.ProfileIDsTeam1 == null)
|
||||
_Data.ScreenNames.ProfileIDsTeam1 = new List<int>();
|
||||
if (_Data.ScreenNames.ProfileIDsTeam2 == null)
|
||||
_Data.ScreenNames.ProfileIDsTeam2 = new List<int>();
|
||||
|
||||
_NumPlayerTeam1 = config.NumPlayerTeam1;
|
||||
_NumPlayerTeam2 = config.NumPlayerTeam2;
|
||||
|
||||
while (_Data.ScreenNames.ProfileIDsTeam1.Count > _NumPlayerTeam1)
|
||||
_Data.ScreenNames.ProfileIDsTeam1.RemoveAt(_Data.ScreenNames.ProfileIDsTeam1.Count - 1);
|
||||
while (_Data.ScreenNames.ProfileIDsTeam2.Count > _NumPlayerTeam2)
|
||||
_Data.ScreenNames.ProfileIDsTeam2.RemoveAt(_Data.ScreenNames.ProfileIDsTeam2.Count - 1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen TicTacToe names. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
_Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
|
||||
if (Buttons[_ButtonPlayerChooseScrollUp].Selected)
|
||||
_Scroll(-1);
|
||||
|
||||
if (Buttons[_ButtonPlayerChooseScrollDown].Selected)
|
||||
_Scroll(1);
|
||||
|
||||
if (!_OnAdd())
|
||||
_OnRemove();
|
||||
break;
|
||||
|
||||
case Keys.Delete:
|
||||
_OnRemove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode inactive
|
||||
if (mouseEvent.LBH && !_SelectingMouseActive)
|
||||
{
|
||||
//Save mouse-coords
|
||||
_OldMouseX = mouseEvent.X;
|
||||
_OldMouseY = mouseEvent.Y;
|
||||
//Check if mouse if over tile
|
||||
for (int i = 0; i < _PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
if (_PlayerChooseButtons[i].Button.Selected)
|
||||
{
|
||||
_SelectedPlayerNr = _PlayerChooseButtons[i].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.Z = -100;
|
||||
_ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
|
||||
_ChooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].Avatar.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode active
|
||||
if (mouseEvent.LBH && _SelectingMouseActive)
|
||||
{
|
||||
//Update coords for Drag/Drop-Texture
|
||||
_ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX;
|
||||
_ChooseAvatarStatic.Rect.Y += mouseEvent.Y - _OldMouseY;
|
||||
_OldMouseX = mouseEvent.X;
|
||||
_OldMouseY = mouseEvent.Y;
|
||||
|
||||
return true;
|
||||
}
|
||||
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
|
||||
else if (_SelectingMouseActive)
|
||||
{
|
||||
//Check if really a player was selected
|
||||
if (_SelectedPlayerNr != -1)
|
||||
{
|
||||
//Foreach Drop-Area
|
||||
for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
//Check first, if area is "active"
|
||||
if (_PlayerDestinationButtons[i].Visible)
|
||||
{
|
||||
//Check if Mouse is in area
|
||||
if (CHelper.IsInBounds(_PlayerDestinationButtons[i].Rect, mouseEvent))
|
||||
{
|
||||
int added = -1;
|
||||
//Add Player-ID to list.
|
||||
if (i - _PlayerDestinationButtonsNumH < 0)
|
||||
{
|
||||
if (_Data.ScreenNames.ProfileIDsTeam1.Count < (i + 1))
|
||||
{
|
||||
_Data.ScreenNames.ProfileIDsTeam1.Add(_SelectedPlayerNr);
|
||||
added = _Data.ScreenNames.ProfileIDsTeam1.Count - 1;
|
||||
}
|
||||
else if (_Data.ScreenNames.ProfileIDsTeam1.Count >= (i + 1))
|
||||
{
|
||||
_Data.ScreenNames.ProfileIDsTeam1[i] = _SelectedPlayerNr;
|
||||
added = i;
|
||||
}
|
||||
}
|
||||
else if (i - _PlayerDestinationButtonsNumH >= 0)
|
||||
{
|
||||
if (_Data.ScreenNames.ProfileIDsTeam2.Count < ((i - _PlayerDestinationButtonsNumH) + 1))
|
||||
{
|
||||
_Data.ScreenNames.ProfileIDsTeam2.Add(_SelectedPlayerNr);
|
||||
added = _Data.ScreenNames.ProfileIDsTeam2.Count - 1 + _PlayerDestinationButtonsNumH;
|
||||
}
|
||||
else if (_Data.ScreenNames.ProfileIDsTeam2.Count >= ((i - _PlayerDestinationButtonsNumH) + 1))
|
||||
{
|
||||
_Data.ScreenNames.ProfileIDsTeam2[i - _PlayerDestinationButtonsNumH] = _SelectedPlayerNr;
|
||||
added = i;
|
||||
}
|
||||
}
|
||||
_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 = _ChooseAvatarStatic.Texture;
|
||||
_PlayerDestinationButtons[added].SelTexture = _ChooseAvatarStatic.Texture;
|
||||
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].PlayerName;
|
||||
_PlayerDestinationButtons[added].Enabled = true;
|
||||
//Update Tiles-List
|
||||
_UpdateButtonPlayerChoose();
|
||||
}
|
||||
}
|
||||
}
|
||||
_SelectedPlayerNr = -1;
|
||||
}
|
||||
//Reset variables
|
||||
_SelectingMouseActive = false;
|
||||
_ChooseAvatarStatic.Visible = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (Buttons[_ButtonBack].Selected)
|
||||
_Back();
|
||||
|
||||
if (Buttons[_ButtonNext].Selected)
|
||||
_Next();
|
||||
|
||||
if (Buttons[_ButtonPlayerChooseScrollUp].Selected)
|
||||
_Scroll(-1);
|
||||
|
||||
if (Buttons[_ButtonPlayerChooseScrollDown].Selected)
|
||||
_Scroll(1);
|
||||
}
|
||||
|
||||
if (mouseEvent.LD && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (!_OnAdd())
|
||||
_OnRemove();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
_Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
if (!_ButtonsAdded)
|
||||
{
|
||||
_AddButtonPlayerDestination();
|
||||
_AddButtonPlayerChoose();
|
||||
_ButtonsAdded = true;
|
||||
}
|
||||
|
||||
_UpdateButtonPlayerDestination();
|
||||
_UpdateButtonPlayerChoose();
|
||||
|
||||
_UpdateButtonNext();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
if (_ChooseAvatarStatic.Visible)
|
||||
_ChooseAvatarStatic.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _Scroll(int offset)
|
||||
{
|
||||
if (offset < 0 && _PlayerChooseButtonsOffset > 0)
|
||||
{
|
||||
_PlayerChooseButtonsOffset += offset;
|
||||
_UpdateButtonPlayerChoose();
|
||||
}
|
||||
else if (_PlayerChooseButtonsVisibleProfiles.Count < _PlayerChooseButtons.Count + (_PlayerChooseButtonsOffset + offset) * _PlayerChooseButtonsNumH)
|
||||
{
|
||||
_PlayerChooseButtonsOffset += offset;
|
||||
_UpdateButtonPlayerChoose();
|
||||
}
|
||||
}
|
||||
|
||||
private void _AddButtonPlayerDestination()
|
||||
{
|
||||
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]);
|
||||
b.Rect.X = _PlayerDestinationButtonsFirstX + column * (b.Rect.W + _PlayerDestinationButtonsSpaceH);
|
||||
b.Rect.Y = _PlayerDestinationButtonsFirstY + row * (b.Rect.H + _PlayerDestinationButtonsSpaceW);
|
||||
_PlayerDestinationButtons.Add(b);
|
||||
column++;
|
||||
if (column >= _PlayerDestinationButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void _AddButtonPlayerChoose()
|
||||
{
|
||||
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]);
|
||||
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;
|
||||
_PlayerChooseButtons.Add(pcb);
|
||||
column++;
|
||||
if (column >= _PlayerChooseButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateButtonPlayerChoose()
|
||||
{
|
||||
_UpdateVisibleProfiles();
|
||||
if ((_PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH) * (_PlayerChooseButtonsOffset + 1) - _PlayerChooseButtonsVisibleProfiles.Count >=
|
||||
(_PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH) * _PlayerChooseButtonsOffset)
|
||||
_UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset - 1);
|
||||
else
|
||||
_UpdateButtonPlayerChoose(_PlayerChooseButtonsOffset);
|
||||
Buttons[_ButtonPlayerChooseScrollUp].Enabled = _PlayerChooseButtonsOffset > 0;
|
||||
Buttons[_ButtonPlayerChooseScrollDown].Enabled = _PlayerChooseButtonsVisibleProfiles.Count >
|
||||
_PlayerChooseButtons.Count + _PlayerChooseButtonsOffset * _PlayerChooseButtonsNumH;
|
||||
}
|
||||
|
||||
private void _UpdateButtonPlayerChoose(int offset)
|
||||
{
|
||||
int numButtonPlayerChoose = _PlayerChooseButtonsNumW * _PlayerChooseButtonsNumH;
|
||||
if (offset < 0)
|
||||
offset = 0;
|
||||
|
||||
if (numButtonPlayerChoose * (offset + 1) - _PlayerChooseButtonsVisibleProfiles.Count <= numButtonPlayerChoose)
|
||||
{
|
||||
for (int i = 0; i < numButtonPlayerChoose; i++)
|
||||
{
|
||||
if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count)
|
||||
{
|
||||
_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.Color = new SColorF(1, 1, 1, 0.6f);
|
||||
_PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1);
|
||||
_PlayerChooseButtons[i].Button.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_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.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateVisibleProfiles()
|
||||
{
|
||||
_PlayerChooseButtonsVisibleProfiles.Clear();
|
||||
for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (visible)
|
||||
_PlayerChooseButtonsVisibleProfiles.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateButtonPlayerDestination()
|
||||
{
|
||||
for (int i = 0; i < _PlayerDestinationButtons.Count / 2; i++)
|
||||
{
|
||||
if (_NumPlayerTeam1 > i)
|
||||
{
|
||||
_PlayerDestinationButtons[i].Visible = true;
|
||||
_PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_PlayerDestinationButtons[i].Visible = false;
|
||||
_PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _PlayerDestinationButtons.Count / 2; i++)
|
||||
{
|
||||
if (_NumPlayerTeam2 > i)
|
||||
{
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Visible = true;
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Visible = false;
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _NumPlayerTeam1; i++)
|
||||
{
|
||||
if (i < _Data.ScreenNames.ProfileIDsTeam1.Count)
|
||||
{
|
||||
if (_Data.ScreenNames.ProfileIDsTeam1[i] != -1)
|
||||
{
|
||||
_PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
_PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1);
|
||||
_PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam1[i]].Avatar.Texture;
|
||||
_PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam1[i]].Avatar.Texture;
|
||||
_PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam1[i]].PlayerName;
|
||||
_PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
}
|
||||
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].Text.Text = String.Empty;
|
||||
_PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _NumPlayerTeam2; i++)
|
||||
{
|
||||
if (i < _Data.ScreenNames.ProfileIDsTeam2.Count)
|
||||
{
|
||||
if (_Data.ScreenNames.ProfileIDsTeam2[i] != -1)
|
||||
{
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelColor = new SColorF(1, 1, 1, 1);
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Texture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam2[i]].Avatar.Texture;
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelTexture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam2[i]].Avatar.Texture;
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Text.Text = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam2[i]].PlayerName;
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Enabled = true;
|
||||
}
|
||||
}
|
||||
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].Text.Text = String.Empty;
|
||||
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateButtonNext()
|
||||
{
|
||||
if (_Data.ScreenNames.ProfileIDsTeam1.Count == _NumPlayerTeam1 && _Data.ScreenNames.ProfileIDsTeam2.Count == _NumPlayerTeam2)
|
||||
{
|
||||
Buttons[_ButtonNext].Visible = true;
|
||||
SetInteractionToButton(Buttons[_ButtonNext]);
|
||||
}
|
||||
else
|
||||
Buttons[_ButtonNext].Visible = false;
|
||||
}
|
||||
|
||||
private bool _OnAdd()
|
||||
{
|
||||
for (int i = 0; i < _PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
if (_PlayerChooseButtons[i].Button.Selected && _PlayerChooseButtons[i].ProfileID != -1)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool _OnRemove()
|
||||
{
|
||||
for (int i = 0; i < _PlayerDestinationButtonsNumH; i++)
|
||||
{
|
||||
if (_PlayerDestinationButtons[i].Selected)
|
||||
{
|
||||
if ((i + 1) <= _Data.ScreenNames.ProfileIDsTeam1.Count)
|
||||
{
|
||||
_Data.ScreenNames.ProfileIDsTeam1.RemoveAt(i);
|
||||
_UpdateButtonNext();
|
||||
_UpdateButtonPlayerDestination();
|
||||
_UpdateButtonPlayerChoose();
|
||||
CheckInteraction();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = _PlayerDestinationButtonsNumH; i < _PlayerDestinationButtonsNumH * 2; i++)
|
||||
{
|
||||
if (_PlayerDestinationButtons[i].Selected)
|
||||
{
|
||||
if (((i - _PlayerDestinationButtonsNumH) + 1) <= _Data.ScreenNames.ProfileIDsTeam2.Count)
|
||||
{
|
||||
_Data.ScreenNames.ProfileIDsTeam2.RemoveAt(i - _PlayerDestinationButtonsNumH);
|
||||
_UpdateButtonNext();
|
||||
_UpdateButtonPlayerDestination();
|
||||
_UpdateButtonPlayerChoose();
|
||||
CheckInteraction();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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,803 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
public enum ESongSource
|
||||
{
|
||||
TR_ALLSONGS,
|
||||
TR_CATEGORY,
|
||||
TR_PLAYLIST
|
||||
}
|
||||
|
||||
public enum EPartyGameMode
|
||||
{
|
||||
TR_GAMEMODE_NORMAL,
|
||||
TR_GAMEMODE_SHORTSONG,
|
||||
TR_GAMEMODE_DUET
|
||||
}
|
||||
|
||||
public class Round
|
||||
{
|
||||
public int SongID;
|
||||
public int SingerTeam1;
|
||||
public int SingerTeam2;
|
||||
public int PointsTeam1;
|
||||
public int PointsTeam2;
|
||||
public int Winner;
|
||||
public bool Finished = false;
|
||||
}
|
||||
|
||||
#region Communication
|
||||
|
||||
#region ToScreen
|
||||
public struct DataToScreenConfig
|
||||
{
|
||||
public int NumPlayerTeam1;
|
||||
public int NumPlayerTeam2;
|
||||
public int NumFields;
|
||||
public ESongSource SongSource;
|
||||
public int CategoryID;
|
||||
public int PlaylistID;
|
||||
public EPartyGameMode GameMode;
|
||||
}
|
||||
|
||||
public struct DataToScreenNames
|
||||
{
|
||||
public int NumPlayerTeam1;
|
||||
public int NumPlayerTeam2;
|
||||
public List<int> ProfileIDsTeam1;
|
||||
public List<int> ProfileIDsTeam2;
|
||||
}
|
||||
|
||||
public struct DataToScreenMain
|
||||
{
|
||||
public int CurrentRoundNr;
|
||||
public int Team;
|
||||
public int NumPlayerTeam1;
|
||||
public int NumPlayerTeam2;
|
||||
public int NumFields;
|
||||
public List<Round> Rounds;
|
||||
public List<int> Songs;
|
||||
public List<int> ProfileIDsTeam1;
|
||||
public List<int> ProfileIDsTeam2;
|
||||
public List<int> PlayerTeam1;
|
||||
public List<int> PlayerTeam2;
|
||||
public int[] NumJokerRandom;
|
||||
public int[] NumJokerRetry;
|
||||
}
|
||||
|
||||
public struct DataFromScreen
|
||||
{
|
||||
public FromScreenConfig ScreenConfig;
|
||||
public FromScreenNames ScreenNames;
|
||||
public FromScreenMain ScreenMain;
|
||||
}
|
||||
|
||||
public struct FromScreenConfig
|
||||
{
|
||||
public int NumPlayerTeam1;
|
||||
public int NumPlayerTeam2;
|
||||
public int NumFields;
|
||||
public ESongSource SongSource;
|
||||
public int CategoryID;
|
||||
public int PlaylistID;
|
||||
public EPartyGameMode GameMode;
|
||||
}
|
||||
|
||||
public struct FromScreenNames
|
||||
{
|
||||
public bool FadeToConfig;
|
||||
public bool FadeToMain;
|
||||
public List<int> ProfileIDsTeam1;
|
||||
public List<int> ProfileIDsTeam2;
|
||||
}
|
||||
|
||||
public struct FromScreenMain
|
||||
{
|
||||
public bool FadeToSinging;
|
||||
public bool FadeToNameSelection;
|
||||
public List<int> PlayerTeam1;
|
||||
public List<int> PlayerTeam2;
|
||||
public List<Round> Rounds;
|
||||
public int SingRoundNr;
|
||||
public List<int> Songs;
|
||||
}
|
||||
#endregion FromScreen
|
||||
|
||||
#endregion Communication
|
||||
|
||||
public sealed class PartyModeTicTacToe : CPartyMode
|
||||
{
|
||||
private const int MaxPlayer = 20;
|
||||
private const int MinPlayer = 2;
|
||||
private const int MaxTeams = 2;
|
||||
private const int MinTeams = 2;
|
||||
private const int NumFields = 9;
|
||||
|
||||
private enum EStage
|
||||
{
|
||||
NotStarted,
|
||||
Config,
|
||||
Names,
|
||||
Main,
|
||||
Singing
|
||||
}
|
||||
|
||||
private struct Data
|
||||
{
|
||||
public int NumPlayerTeam1;
|
||||
public int NumPlayerTeam2;
|
||||
public int NumFields;
|
||||
public int Team;
|
||||
public List<int> ProfileIDsTeam1;
|
||||
public List<int> ProfileIDsTeam2;
|
||||
public List<int> PlayerTeam1;
|
||||
public List<int> PlayerTeam2;
|
||||
|
||||
public ESongSource SongSource;
|
||||
public int CategoryID;
|
||||
public int PlaylistID;
|
||||
|
||||
public EPartyGameMode GameMode;
|
||||
|
||||
public List<Round> Rounds;
|
||||
public List<int> Songs;
|
||||
|
||||
public int CurrentRoundNr;
|
||||
public int SingRoundNr;
|
||||
|
||||
public int[] NumJokerRandom;
|
||||
public int[] NumJokerRetry;
|
||||
}
|
||||
|
||||
private DataToScreenConfig ToScreenConfig;
|
||||
private DataToScreenNames ToScreenNames;
|
||||
private DataToScreenMain ToScreenMain;
|
||||
|
||||
private Data GameData;
|
||||
private EStage _Stage;
|
||||
|
||||
public PartyModeTicTacToe()
|
||||
{
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;
|
||||
_ScreenSongOptions.Selection.PartyMode = true;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = true;
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] {5, 5};
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"};
|
||||
|
||||
_ScreenSongOptions.Sorting.SearchString = String.Empty;
|
||||
_ScreenSongOptions.Sorting.SearchActive = false;
|
||||
_ScreenSongOptions.Sorting.DuetOptions = EDuetOptions.NoDuets;
|
||||
|
||||
_Stage = EStage.NotStarted;
|
||||
|
||||
ToScreenConfig = new DataToScreenConfig();
|
||||
ToScreenNames = new DataToScreenNames();
|
||||
ToScreenMain = new DataToScreenMain();
|
||||
|
||||
GameData = new Data();
|
||||
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<Round>();
|
||||
GameData.Songs = new List<int>();
|
||||
GameData.NumJokerRandom = new int[2];
|
||||
GameData.NumJokerRetry = new int[2];
|
||||
}
|
||||
|
||||
public override bool Init()
|
||||
{
|
||||
_Stage = EStage.NotStarted;
|
||||
|
||||
_ScreenSongOptions.Sorting.IgnoreArticles = CBase.Config.GetIgnoreArticles();
|
||||
_ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting();
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_OFF;
|
||||
_ScreenSongOptions.Selection.SongIndex = -1;
|
||||
|
||||
if (CBase.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE)
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
|
||||
|
||||
ToScreenMain.Rounds = new List<Round>();
|
||||
ToScreenMain.Songs = new List<int>();
|
||||
ToScreenMain.PlayerTeam1 = new List<int>();
|
||||
ToScreenMain.PlayerTeam2 = new List<int>();
|
||||
GameData.Songs = new List<int>();
|
||||
GameData.Rounds = new List<Round>();
|
||||
GameData.PlayerTeam1 = new List<int>();
|
||||
GameData.PlayerTeam2 = new List<int>();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void DataFromScreen(string ScreenName, Object Data)
|
||||
{
|
||||
DataFromScreen data = new DataFromScreen();
|
||||
switch (ScreenName)
|
||||
{
|
||||
case "PartyScreenTicTacToeConfig":
|
||||
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
GameData.NumPlayerTeam1 = data.ScreenConfig.NumPlayerTeam1;
|
||||
GameData.NumPlayerTeam2 = data.ScreenConfig.NumPlayerTeam2;
|
||||
GameData.NumFields = data.ScreenConfig.NumFields;
|
||||
GameData.SongSource = data.ScreenConfig.SongSource;
|
||||
GameData.CategoryID = data.ScreenConfig.CategoryID;
|
||||
GameData.PlaylistID = data.ScreenConfig.PlaylistID;
|
||||
GameData.GameMode = data.ScreenConfig.GameMode;
|
||||
|
||||
_Stage = EStage.Config;
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode TicTacToe. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PartyScreenTicTacToeNames":
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
if (data.ScreenNames.FadeToConfig)
|
||||
_Stage = EStage.NotStarted;
|
||||
else
|
||||
{
|
||||
if (CBase.Game.GetRandom(100) < 50)
|
||||
GameData.Team = 0;
|
||||
else
|
||||
GameData.Team = 1;
|
||||
GameData.ProfileIDsTeam1 = data.ScreenNames.ProfileIDsTeam1;
|
||||
GameData.ProfileIDsTeam2 = data.ScreenNames.ProfileIDsTeam2;
|
||||
_Stage = EStage.Names;
|
||||
}
|
||||
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode TicTacToe. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PartyScreenTicTacToeMain":
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
if (data.ScreenMain.FadeToSinging)
|
||||
{
|
||||
_Stage = EStage.Singing;
|
||||
GameData.Rounds = data.ScreenMain.Rounds;
|
||||
GameData.SingRoundNr = data.ScreenMain.SingRoundNr;
|
||||
GameData.Songs = data.ScreenMain.Songs;
|
||||
GameData.PlayerTeam1 = data.ScreenMain.PlayerTeam1;
|
||||
GameData.PlayerTeam2 = data.ScreenMain.PlayerTeam2;
|
||||
}
|
||||
if (data.ScreenMain.FadeToNameSelection)
|
||||
_Stage = EStage.Config;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode TicTacToe. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
}
|
||||
|
||||
|
||||
if (_Stage == EStage.Singing)
|
||||
StartRound(data.ScreenMain.SingRoundNr);
|
||||
if (_Stage == EStage.Config)
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
break;
|
||||
|
||||
default:
|
||||
CBase.Log.LogError("Error in party mode TicTacToe. Wrong screen is sending: " + ScreenName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateGame()
|
||||
{
|
||||
/*
|
||||
if (CBase.Songs.GetCurrentCategoryIndex() != -1 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF)
|
||||
_ScreenSongOptions.Selection.RandomOnly = true;
|
||||
else
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;*/
|
||||
}
|
||||
|
||||
public override CMenuParty GetNextPartyScreen(out EScreens AlternativeScreen)
|
||||
{
|
||||
CMenuParty Screen = null;
|
||||
AlternativeScreen = EScreens.ScreenSong;
|
||||
|
||||
switch (_Stage)
|
||||
{
|
||||
case EStage.NotStarted:
|
||||
_Screens.TryGetValue("PartyScreenTicTacToeConfig", out Screen);
|
||||
if (_Screens != null)
|
||||
{
|
||||
ToScreenConfig.NumPlayerTeam1 = GameData.NumPlayerTeam1;
|
||||
ToScreenConfig.NumPlayerTeam2 = GameData.NumPlayerTeam2;
|
||||
ToScreenConfig.NumFields = GameData.NumFields;
|
||||
ToScreenConfig.SongSource = GameData.SongSource;
|
||||
ToScreenConfig.CategoryID = GameData.CategoryID;
|
||||
ToScreenConfig.PlaylistID = GameData.PlaylistID;
|
||||
ToScreenConfig.GameMode = GameData.GameMode;
|
||||
Screen.DataToScreen(ToScreenConfig);
|
||||
}
|
||||
break;
|
||||
case EStage.Config:
|
||||
_Screens.TryGetValue("PartyScreenTicTacToeNames", out Screen);
|
||||
if (_Screens != null)
|
||||
{
|
||||
ToScreenNames.NumPlayerTeam1 = GameData.NumPlayerTeam1;
|
||||
ToScreenNames.NumPlayerTeam2 = GameData.NumPlayerTeam2;
|
||||
ToScreenNames.ProfileIDsTeam1 = GameData.ProfileIDsTeam1;
|
||||
ToScreenNames.ProfileIDsTeam2 = GameData.ProfileIDsTeam2;
|
||||
Screen.DataToScreen(ToScreenNames);
|
||||
}
|
||||
break;
|
||||
case EStage.Names:
|
||||
_Screens.TryGetValue("PartyScreenTicTacToeMain", out Screen);
|
||||
if (_Screens != null)
|
||||
{
|
||||
if (GameData.Team == 1)
|
||||
GameData.Team = 0;
|
||||
else
|
||||
GameData.Team = 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;
|
||||
CreateRounds();
|
||||
SetNumJokers();
|
||||
PreparePlayerList(0);
|
||||
PrepareSongList();
|
||||
ToScreenMain.Rounds = GameData.Rounds;
|
||||
ToScreenMain.Songs = GameData.Songs;
|
||||
ToScreenMain.PlayerTeam1 = GameData.PlayerTeam1;
|
||||
ToScreenMain.PlayerTeam1 = GameData.PlayerTeam2;
|
||||
ToScreenMain.NumJokerRandom = GameData.NumJokerRandom;
|
||||
ToScreenMain.NumJokerRetry = GameData.NumJokerRetry;
|
||||
ToScreenMain.Team = GameData.Team;
|
||||
Screen.DataToScreen(ToScreenMain);
|
||||
}
|
||||
break;
|
||||
case EStage.Main:
|
||||
//nothing to do
|
||||
break;
|
||||
case EStage.Singing:
|
||||
_Screens.TryGetValue("PartyScreenTicTacToeMain", out Screen);
|
||||
if (_Screens != null)
|
||||
{
|
||||
if (GameData.Team == 1)
|
||||
GameData.Team = 0;
|
||||
else
|
||||
GameData.Team = 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;
|
||||
ToScreenMain.Rounds = GameData.Rounds;
|
||||
ToScreenMain.Songs = GameData.Songs;
|
||||
ToScreenMain.PlayerTeam1 = GameData.PlayerTeam1;
|
||||
ToScreenMain.PlayerTeam2 = GameData.PlayerTeam2;
|
||||
ToScreenMain.NumJokerRandom = GameData.NumJokerRandom;
|
||||
ToScreenMain.NumJokerRetry = GameData.NumJokerRetry;
|
||||
ToScreenMain.Team = GameData.Team;
|
||||
Screen.DataToScreen(ToScreenMain);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Screen;
|
||||
}
|
||||
|
||||
public override EScreens GetStartScreen()
|
||||
{
|
||||
return EScreens.ScreenPartyDummy;
|
||||
}
|
||||
|
||||
public override EScreens GetMainScreen()
|
||||
{
|
||||
return EScreens.ScreenPartyDummy;
|
||||
}
|
||||
|
||||
public override ScreenSongOptions GetScreenSongOptions()
|
||||
{
|
||||
_ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting();
|
||||
_ScreenSongOptions.Sorting.Tabs = CBase.Config.GetTabs();
|
||||
_ScreenSongOptions.Sorting.IgnoreArticles = CBase.Config.GetIgnoreArticles();
|
||||
|
||||
return _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void OnSongChange(int SongIndex, ref ScreenSongOptions ScreenSongOptions)
|
||||
{
|
||||
ScreenSongOptions = _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void OnCategoryChange(int CategoryIndex, ref ScreenSongOptions ScreenSongOptions)
|
||||
{
|
||||
ScreenSongOptions = _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void SetSearchString(string SearchString, bool Visible)
|
||||
{
|
||||
_ScreenSongOptions.Sorting.SearchString = SearchString;
|
||||
_ScreenSongOptions.Sorting.SearchActive = Visible;
|
||||
}
|
||||
|
||||
public override int GetMaxPlayer()
|
||||
{
|
||||
return MaxPlayer;
|
||||
}
|
||||
|
||||
public override int GetMinPlayer()
|
||||
{
|
||||
return MinPlayer;
|
||||
}
|
||||
|
||||
public override int GetMaxTeams()
|
||||
{
|
||||
return MaxTeams;
|
||||
}
|
||||
|
||||
public override int GetMinTeams()
|
||||
{
|
||||
return MinTeams;
|
||||
}
|
||||
|
||||
public override int GetMaxNumRounds()
|
||||
{
|
||||
return NumFields;
|
||||
}
|
||||
|
||||
public override void JokerUsed(int TeamNr) {}
|
||||
|
||||
public override void SongSelected(int SongID)
|
||||
{
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
switch (GameData.GameMode)
|
||||
{
|
||||
case EPartyGameMode.TR_GAMEMODE_NORMAL:
|
||||
gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_DUET:
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
|
||||
gm = EGameMode.TR_GAMEMODE_SHORTSONG;
|
||||
break;
|
||||
}
|
||||
CBase.Game.AddSong(SongID, gm);
|
||||
|
||||
CBase.Songs.AddPartySongSung(SongID);
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenSing);
|
||||
}
|
||||
|
||||
public override void LeavingHighscore()
|
||||
{
|
||||
UpdateScores();
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
|
||||
private void CreateRounds()
|
||||
{
|
||||
GameData.Rounds = new List<Round>();
|
||||
for (int i = 0; i < GameData.NumFields; i++)
|
||||
{
|
||||
Round r = new Round();
|
||||
GameData.Rounds.Add(r);
|
||||
}
|
||||
}
|
||||
|
||||
private void PreparePlayerList(int Team)
|
||||
{
|
||||
if (Team == 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);
|
||||
}
|
||||
if (IDs2.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < GameData.NumPlayerTeam2; i++)
|
||||
IDs2.Add(i);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PrepareSongList()
|
||||
{
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
switch (GameData.GameMode)
|
||||
{
|
||||
case EPartyGameMode.TR_GAMEMODE_NORMAL:
|
||||
gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_DUET:
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
|
||||
gm = EGameMode.TR_GAMEMODE_SHORTSONG;
|
||||
break;
|
||||
}
|
||||
|
||||
while (GameData.Songs.Count < (GameData.NumFields + GameData.NumJokerRandom[0] + GameData.NumJokerRandom[1]))
|
||||
{
|
||||
List<int> Songs = new List<int>();
|
||||
switch (GameData.SongSource)
|
||||
{
|
||||
case ESongSource.TR_PLAYLIST:
|
||||
for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(GameData.PlaylistID); i++)
|
||||
{
|
||||
int id = CBase.Playlist.GetPlaylistSong(GameData.PlaylistID, i).SongID;
|
||||
foreach (EGameMode mode in CBase.Songs.GetSongByID(id).AvailableGameModes)
|
||||
{
|
||||
if (mode == gm)
|
||||
Songs.Add(id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ESongSource.TR_ALLSONGS:
|
||||
for (int i = 0; i < CBase.Songs.GetNumSongs(); i++)
|
||||
{
|
||||
foreach (EGameMode mode in CBase.Songs.GetSongByID(i).AvailableGameModes)
|
||||
{
|
||||
if (mode == gm)
|
||||
Songs.Add(i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ESongSource.TR_CATEGORY:
|
||||
CBase.Songs.SetCategory(GameData.CategoryID);
|
||||
for (int i = 0; i < CBase.Songs.NumSongsInCategory(GameData.CategoryID); i++)
|
||||
{
|
||||
foreach (EGameMode mode in CBase.Songs.GetVisibleSong(i).AvailableGameModes)
|
||||
{
|
||||
if (mode == gm)
|
||||
Songs.Add(CBase.Songs.GetVisibleSong(i).ID);
|
||||
}
|
||||
}
|
||||
CBase.Songs.SetCategory(-1);
|
||||
break;
|
||||
}
|
||||
while (Songs.Count > 0)
|
||||
{
|
||||
GameData.Songs.Add(Songs[CBase.Game.GetRandom(Songs.Count - 1)]);
|
||||
Songs.Remove(GameData.Songs[GameData.Songs.Count - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePlayerList()
|
||||
{
|
||||
if (GameData.PlayerTeam1.Count == 0)
|
||||
PreparePlayerList(1);
|
||||
if (GameData.PlayerTeam2.Count == 0)
|
||||
PreparePlayerList(2);
|
||||
}
|
||||
|
||||
private void UpdateSongList()
|
||||
{
|
||||
if (GameData.Songs.Count == 0)
|
||||
PrepareSongList();
|
||||
}
|
||||
|
||||
private void StartRound(int RoundNr)
|
||||
{
|
||||
CBase.Game.Reset();
|
||||
CBase.Game.ClearSongs();
|
||||
|
||||
CBase.Game.SetNumPlayer(2);
|
||||
|
||||
SPlayer[] player = CBase.Game.GetPlayer();
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (player.Length < 2)
|
||||
return;
|
||||
|
||||
SProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
Round r = GameData.Rounds[RoundNr];
|
||||
bool isDuet = CBase.Songs.GetSongByID(r.SongID).IsDuet;
|
||||
|
||||
for (int i = 0; i < 2; 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 (r != null)
|
||||
{
|
||||
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()
|
||||
{
|
||||
switch (GameData.NumFields)
|
||||
{
|
||||
case 9:
|
||||
GameData.NumJokerRandom[0] = 1;
|
||||
GameData.NumJokerRandom[1] = 1;
|
||||
GameData.NumJokerRetry[0] = 0;
|
||||
GameData.NumJokerRetry[1] = 0;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
GameData.NumJokerRandom[0] = 2;
|
||||
GameData.NumJokerRandom[1] = 2;
|
||||
GameData.NumJokerRetry[0] = 1;
|
||||
GameData.NumJokerRetry[1] = 1;
|
||||
break;
|
||||
|
||||
case 25:
|
||||
GameData.NumJokerRandom[0] = 3;
|
||||
GameData.NumJokerRandom[1] = 3;
|
||||
GameData.NumJokerRetry[0] = 2;
|
||||
GameData.NumJokerRetry[1] = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateScores()
|
||||
{
|
||||
if (!GameData.Rounds[GameData.SingRoundNr].Finished)
|
||||
GameData.CurrentRoundNr++;
|
||||
|
||||
SPlayer[] results = CBase.Game.GetPlayer();
|
||||
if (results == null)
|
||||
return;
|
||||
|
||||
if (results.Length < 2)
|
||||
return;
|
||||
|
||||
GameData.Rounds[GameData.SingRoundNr].PointsTeam1 = (int)Math.Round(results[0].Points);
|
||||
GameData.Rounds[GameData.SingRoundNr].PointsTeam2 = (int)Math.Round(results[1].Points);
|
||||
GameData.Rounds[GameData.SingRoundNr].Finished = true;
|
||||
if (GameData.Rounds[GameData.SingRoundNr].PointsTeam1 < GameData.Rounds[GameData.SingRoundNr].PointsTeam2)
|
||||
GameData.Rounds[GameData.SingRoundNr].Winner = 2;
|
||||
else if (GameData.Rounds[GameData.SingRoundNr].PointsTeam1 > GameData.Rounds[GameData.SingRoundNr].PointsTeam2)
|
||||
GameData.Rounds[GameData.SingRoundNr].Winner = 1;
|
||||
else
|
||||
{
|
||||
GameData.Rounds[GameData.SingRoundNr].Finished = false;
|
||||
GameData.CurrentRoundNr--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,10 +108,10 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="PartyModeTicTacToe.cs" />
|
||||
<Compile Include="PartyScreenTicTacToeConfig.cs" />
|
||||
<Compile Include="PartyScreenTicTacToeMain.cs" />
|
||||
<Compile Include="PartyScreenTicTacToeNames.cs" />
|
||||
<Compile Include="CPartyModeTicTacToe.cs" />
|
||||
<Compile Include="CPartyScreenTicTacToeConfig.cs" />
|
||||
<Compile Include="CPartyScreenTicTacToeMain.cs" />
|
||||
<Compile Include="CPartyScreenTicTacToeNames.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VocaluxeLib\VocaluxeLib.csproj">
|
||||
@@ -122,10 +122,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.XML" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
|
||||
@@ -1,328 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
public class PartyScreenTicTacToeConfig : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string SelectSlideNumPlayerTeam1 = "SelectSlideNumPlayerTeam1";
|
||||
private const string SelectSlideNumPlayerTeam2 = "SelectSlideNumPlayerTeam2";
|
||||
private const string SelectSlideNumFields = "SelectSlideNumFields";
|
||||
private const string SelectSlideSongSource = "SelectSlideSongSource";
|
||||
private const string SelectSlidePlaylist = "SelectSlidePlaylist";
|
||||
private const string SelectSlideCategory = "SelectSlideCategory";
|
||||
private const string SelectSlideGameMode = "SelectSlideGameMode";
|
||||
private const string ButtonNext = "ButtonNext";
|
||||
private const string ButtonBack = "ButtonBack";
|
||||
|
||||
private bool ConfigOk = true;
|
||||
|
||||
private DataFromScreen Data;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeSelectSlides = new string[]
|
||||
{SelectSlideNumPlayerTeam1, SelectSlideNumPlayerTeam2, SelectSlideNumFields, SelectSlideSongSource, SelectSlidePlaylist, SelectSlideCategory, SelectSlideGameMode};
|
||||
_ThemeButtons = new string[] {ButtonNext, ButtonBack};
|
||||
|
||||
Data = new DataFromScreen();
|
||||
FromScreenConfig config = new FromScreenConfig();
|
||||
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;
|
||||
Data.ScreenConfig = config;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenConfig config = new DataToScreenConfig();
|
||||
|
||||
try
|
||||
{
|
||||
config = (DataToScreenConfig)ReceivedData;
|
||||
Data.ScreenConfig.NumFields = config.NumFields;
|
||||
Data.ScreenConfig.NumPlayerTeam1 = config.NumPlayerTeam1;
|
||||
Data.ScreenConfig.NumPlayerTeam2 = config.NumPlayerTeam2;
|
||||
Data.ScreenConfig.PlaylistID = config.PlaylistID;
|
||||
Data.ScreenConfig.CategoryID = config.CategoryID;
|
||||
Data.ScreenConfig.SongSource = config.SongSource;
|
||||
Data.ScreenConfig.GameMode = config.GameMode;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen TicTacToe config. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
UpdateSlides();
|
||||
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
UpdateSlides();
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
UpdateSlides();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
UpdateSlides();
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
if (CBase.Config.GetMaxNumMics() >= 2)
|
||||
ConfigOk = true;
|
||||
|
||||
FillSlides();
|
||||
UpdateSlides();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
Buttons[ButtonNext].Visible = ConfigOk;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void FillSlides()
|
||||
{
|
||||
// build num player slide (min player ... max player);
|
||||
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[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[SelectSlideNumFields].Clear();
|
||||
SelectSlides[SelectSlideNumFields].AddValue("9");
|
||||
SelectSlides[SelectSlideNumFields].AddValue("16");
|
||||
SelectSlides[SelectSlideNumFields].AddValue("25");
|
||||
if (Data.ScreenConfig.NumFields == 9)
|
||||
SelectSlides[SelectSlideNumFields].Selection = 0;
|
||||
else if (Data.ScreenConfig.NumFields == 16)
|
||||
SelectSlides[SelectSlideNumFields].Selection = 1;
|
||||
else if (Data.ScreenConfig.NumFields == 25)
|
||||
SelectSlides[SelectSlideNumFields].Selection = 2;
|
||||
|
||||
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++)
|
||||
{
|
||||
string value = _Playlists[i] + " (" + CBase.Playlist.GetPlaylistSongCount(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")";
|
||||
SelectSlides[SelectSlidePlaylist].AddValue(value);
|
||||
}
|
||||
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();
|
||||
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].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);
|
||||
}
|
||||
|
||||
private void UpdateSlides()
|
||||
{
|
||||
Data.ScreenConfig.NumPlayerTeam1 = SelectSlides[SelectSlideNumPlayerTeam1].Selection + (_PartyMode.GetMinPlayer() / 2);
|
||||
Data.ScreenConfig.NumPlayerTeam2 = SelectSlides[SelectSlideNumPlayerTeam2].Selection + (_PartyMode.GetMinPlayer() / 2);
|
||||
|
||||
if (SelectSlides[SelectSlideNumFields].Selection == 0)
|
||||
Data.ScreenConfig.NumFields = 9;
|
||||
else if (SelectSlides[SelectSlideNumFields].Selection == 1)
|
||||
Data.ScreenConfig.NumFields = 16;
|
||||
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;
|
||||
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
switch (Data.ScreenConfig.GameMode)
|
||||
{
|
||||
case EPartyGameMode.TR_GAMEMODE_NORMAL:
|
||||
gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_DUET:
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
break;
|
||||
|
||||
case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
|
||||
gm = EGameMode.TR_GAMEMODE_SHORTSONG;
|
||||
break;
|
||||
}
|
||||
|
||||
if (Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST)
|
||||
{
|
||||
if (CBase.Playlist.GetNumPlaylists() > 0)
|
||||
{
|
||||
if (CBase.Playlist.GetPlaylistSongCount(Data.ScreenConfig.PlaylistID) > 0)
|
||||
{
|
||||
ConfigOk = false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (ConfigOk)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
ConfigOk = false;
|
||||
}
|
||||
else
|
||||
ConfigOk = false;
|
||||
}
|
||||
if (Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY)
|
||||
{
|
||||
if (CBase.Songs.GetNumCategories() > 0)
|
||||
{
|
||||
if (CBase.Songs.NumSongsInCategory(Data.ScreenConfig.CategoryID) > 0)
|
||||
{
|
||||
CBase.Songs.SetCategory(Data.ScreenConfig.CategoryID);
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (ConfigOk)
|
||||
break;
|
||||
}
|
||||
CBase.Songs.SetCategory(-1);
|
||||
}
|
||||
else
|
||||
ConfigOk = false;
|
||||
}
|
||||
else
|
||||
ConfigOk = false;
|
||||
}
|
||||
if (Data.ScreenConfig.SongSource == ESongSource.TR_ALLSONGS)
|
||||
{
|
||||
if (CBase.Songs.GetNumSongs() > 0)
|
||||
{
|
||||
for (int i = 0; i < CBase.Songs.GetNumSongs(); i++)
|
||||
{
|
||||
foreach (EGameMode mode in CBase.Songs.GetSongByID(i).AvailableGameModes)
|
||||
{
|
||||
if (mode == gm)
|
||||
{
|
||||
ConfigOk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ConfigOk)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
ConfigOk = false;
|
||||
}
|
||||
SelectSlides[SelectSlideCategory].Visible = Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY;
|
||||
SelectSlides[SelectSlidePlaylist].Visible = Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST;
|
||||
}
|
||||
|
||||
private void Back()
|
||||
{
|
||||
FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void Next()
|
||||
{
|
||||
_PartyMode.DataFromScreen(ThemeName, Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,711 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Menu.SongMenu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
public class Field
|
||||
{
|
||||
public Round Content;
|
||||
public CButton Button;
|
||||
}
|
||||
|
||||
public enum EStatus
|
||||
{
|
||||
FieldChoosing,
|
||||
JokerRetry,
|
||||
FieldSelected,
|
||||
None
|
||||
}
|
||||
|
||||
public class PartyScreenTicTacToeMain : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string TextPopupReallyExit = "TextPopupReallyExit";
|
||||
private const string TextTeamChoosing = "TextTeamChoosing";
|
||||
private const string TextFinishMessage = "TextFinishMessage";
|
||||
private const string TextNextPlayerT1 = "TextNextPlayerT1";
|
||||
private const string TextNextPlayerT2 = "TextNextPlayerT2";
|
||||
private const string TextNextPlayerNameT1 = "TextNextPlayerNameT1";
|
||||
private const string TextNextPlayerNameT2 = "TextNextPlayerNameT2";
|
||||
|
||||
private const string ButtonNextRound = "ButtonNextRound";
|
||||
private const string ButtonBack = "ButtonBack";
|
||||
private const string ButtonExit = "ButtonExit";
|
||||
private const string ButtonPopupYes = "ButtonPopupYes";
|
||||
private const string ButtonPopupNo = "ButtonPopupNo";
|
||||
private const string ButtonField = "ButtonField";
|
||||
|
||||
private const string ButtonJokerRandomT1 = "ButtonJokerRandomT1";
|
||||
private const string ButtonJokerRandomT2 = "ButtonJokerRandomT2";
|
||||
private const string ButtonJokerRetryT1 = "ButtonJokerRetryT1";
|
||||
private const string ButtonJokerRetryT2 = "ButtonJokerRetryT2";
|
||||
|
||||
private const string StaticPopupBG = "StaticPopupBG";
|
||||
private const string StaticAvatarT1 = "StaticAvatarT1";
|
||||
private const string StaticAvatarT2 = "StaticAvatarT2";
|
||||
|
||||
private bool ExitPopupVisible;
|
||||
|
||||
private DataFromScreen Data;
|
||||
private DataToScreenMain GameData;
|
||||
|
||||
private List<Field> Fields;
|
||||
private float FieldFirstX = 25;
|
||||
private float FieldFirstY = 25;
|
||||
private int FieldSpace = 10;
|
||||
private float FieldSize = 100;
|
||||
|
||||
private int PreviewStream = -1;
|
||||
private int SelectedField = -1;
|
||||
private int OldSelectedField = -1;
|
||||
|
||||
private int[,] Possibilities;
|
||||
private EStatus Status;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeTexts = new string[] {TextPopupReallyExit, TextTeamChoosing, TextFinishMessage, TextNextPlayerT1, TextNextPlayerT2, TextNextPlayerNameT1, TextNextPlayerNameT2};
|
||||
_ThemeButtons = new string[]
|
||||
{
|
||||
ButtonNextRound, ButtonBack, ButtonExit, ButtonPopupYes, ButtonPopupNo, ButtonField, ButtonJokerRandomT1, ButtonJokerRandomT2, ButtonJokerRetryT1,
|
||||
ButtonJokerRetryT2
|
||||
};
|
||||
_ThemeStatics = new string[] {StaticPopupBG, StaticAvatarT1, StaticAvatarT2};
|
||||
|
||||
Data = new DataFromScreen();
|
||||
FromScreenMain config = new FromScreenMain();
|
||||
GameData = new DataToScreenMain();
|
||||
config.SingRoundNr = 1;
|
||||
config.Rounds = new List<Round>();
|
||||
config.Songs = new List<int>();
|
||||
config.PlayerTeam1 = new List<int>();
|
||||
config.PlayerTeam2 = new List<int>();
|
||||
config.FadeToNameSelection = false;
|
||||
config.FadeToSinging = false;
|
||||
Data.ScreenMain = config;
|
||||
|
||||
Fields = new List<Field>();
|
||||
}
|
||||
|
||||
public override void LoadTheme(string XmlPath)
|
||||
{
|
||||
base.LoadTheme(XmlPath);
|
||||
|
||||
CreateFields();
|
||||
Buttons[ButtonField].Visible = false;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenMain config = new DataToScreenMain();
|
||||
|
||||
try
|
||||
{
|
||||
config = (DataToScreenMain)ReceivedData;
|
||||
GameData = config;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen TicTacToe main. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (GameData.CurrentRoundNr == 1 && Status != EStatus.FieldSelected)
|
||||
Back();
|
||||
else if (Status == EStatus.None)
|
||||
EndParty();
|
||||
else
|
||||
ShowPopup(true);
|
||||
}
|
||||
else
|
||||
ShowPopup(false);
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[ButtonNextRound].Selected)
|
||||
NextRound();
|
||||
if (Buttons[ButtonBack].Selected && GameData.CurrentRoundNr == 1 && Status != EStatus.FieldSelected)
|
||||
Back();
|
||||
if (Buttons[ButtonExit].Selected && (GameData.CurrentRoundNr > 1 || Status == EStatus.FieldSelected) && Status != EStatus.None)
|
||||
ShowPopup(true);
|
||||
else if (Status == EStatus.None)
|
||||
EndParty();
|
||||
for (int i = 0; i < GameData.NumFields; i++)
|
||||
{
|
||||
switch (Status)
|
||||
{
|
||||
case EStatus.FieldChoosing:
|
||||
if (Fields[i].Button.Selected)
|
||||
{
|
||||
SelectedField = i;
|
||||
FieldSelected();
|
||||
}
|
||||
break;
|
||||
|
||||
case EStatus.JokerRetry:
|
||||
if (Fields[i].Button.Selected)
|
||||
{
|
||||
SelectedField = i;
|
||||
FieldSelectedAgain();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Status == EStatus.FieldSelected)
|
||||
{
|
||||
if (Buttons[ButtonJokerRandomT1].Selected)
|
||||
UseJoker(0, 0);
|
||||
if (Buttons[ButtonJokerRandomT2].Selected)
|
||||
UseJoker(1, 0);
|
||||
if (Buttons[ButtonJokerRetryT1].Selected)
|
||||
UseJoker(0, 1);
|
||||
if (Buttons[ButtonJokerRetryT2].Selected)
|
||||
UseJoker(1, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[ButtonPopupYes].Selected)
|
||||
EndParty();
|
||||
if (Buttons[ButtonPopupNo].Selected)
|
||||
ShowPopup(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[ButtonNextRound].Selected)
|
||||
NextRound();
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
if (Buttons[ButtonExit].Selected)
|
||||
{
|
||||
if (Status == EStatus.None)
|
||||
EndParty();
|
||||
else
|
||||
ShowPopup(true);
|
||||
}
|
||||
for (int i = 0; i < GameData.NumFields; i++)
|
||||
{
|
||||
switch (Status)
|
||||
{
|
||||
case EStatus.FieldChoosing:
|
||||
if (Fields[i].Button.Selected)
|
||||
{
|
||||
SelectedField = i;
|
||||
FieldSelected();
|
||||
}
|
||||
break;
|
||||
|
||||
case EStatus.JokerRetry:
|
||||
if (Fields[i].Button.Selected)
|
||||
{
|
||||
SelectedField = i;
|
||||
FieldSelectedAgain();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Status == EStatus.FieldSelected)
|
||||
{
|
||||
if (Buttons[ButtonJokerRandomT1].Selected)
|
||||
UseJoker(0, 0);
|
||||
if (Buttons[ButtonJokerRandomT2].Selected)
|
||||
UseJoker(1, 0);
|
||||
if (Buttons[ButtonJokerRetryT1].Selected)
|
||||
UseJoker(0, 1);
|
||||
if (Buttons[ButtonJokerRetryT2].Selected)
|
||||
UseJoker(1, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[ButtonPopupYes].Selected)
|
||||
EndParty();
|
||||
if (Buttons[ButtonPopupNo].Selected)
|
||||
ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
{
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (GameData.CurrentRoundNr == 1 && Status != EStatus.FieldSelected)
|
||||
Back();
|
||||
else if (Status == EStatus.None)
|
||||
EndParty();
|
||||
else
|
||||
ShowPopup(true);
|
||||
}
|
||||
else
|
||||
ShowPopup(false);
|
||||
}
|
||||
|
||||
if (mouseEvent.Wheel != 0) {}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
PreviewStream = -1;
|
||||
|
||||
if (GameData.CurrentRoundNr == 1)
|
||||
{
|
||||
BuildWinnerPossibilities();
|
||||
SelectedField = -1;
|
||||
Buttons[ButtonBack].Visible = true;
|
||||
Buttons[ButtonExit].Visible = false;
|
||||
SetInteractionToButton(Buttons[ButtonBack]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[ButtonBack].Visible = false;
|
||||
Buttons[ButtonExit].Visible = true;
|
||||
SetInteractionToButton(Buttons[ButtonExit]);
|
||||
}
|
||||
|
||||
Status = EStatus.FieldChoosing;
|
||||
|
||||
UpdateFields();
|
||||
UpdateFieldContents();
|
||||
|
||||
int Winner = GetWinner();
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = EStatus.None;
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
Texts[TextFinishMessage].Color = new SColorF(1, 1, 1, 1);
|
||||
Texts[TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", _PartyModeID);
|
||||
}
|
||||
SetInteractionToButton(Buttons[ButtonExit]);
|
||||
}
|
||||
|
||||
ShowPopup(false);
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
CBase.BackgroundMusic.SetStatus(false);
|
||||
CBase.Sound.FadeAndStop(PreviewStream, 0f, 0.5f);
|
||||
}
|
||||
|
||||
private void CreateFields()
|
||||
{
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
Field f = new Field();
|
||||
f.Button = GetNewButton(Buttons[ButtonField]);
|
||||
f.Button.Visible = false;
|
||||
f.Content = new Round();
|
||||
AddButton(f.Button);
|
||||
Fields.Add(f);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
FieldFirstY = 140 + (CBase.Settings.GetRenderH() - 140) / 2 - (NumOneRow * FieldSize + NumOneRow * FieldSpace) / 2;
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
float x = FieldFirstX;
|
||||
float y = FieldFirstY;
|
||||
for (int i = 0; i < Fields.Count; i++)
|
||||
{
|
||||
if (i < GameData.NumFields)
|
||||
{
|
||||
Fields[i].Button.Rect.W = FieldSize;
|
||||
Fields[i].Button.Rect.H = FieldSize;
|
||||
Fields[i].Button.Rect.X = x;
|
||||
Fields[i].Button.Rect.Y = y;
|
||||
Fields[i].Button.Visible = true;
|
||||
Fields[i].Button.Enabled = true;
|
||||
column++;
|
||||
if ((i + 1) >= NumOneRow * (row + 1))
|
||||
{
|
||||
column = 0;
|
||||
row++;
|
||||
y = FieldFirstY + FieldSize * row + FieldSpace * row;
|
||||
x = FieldFirstX;
|
||||
}
|
||||
else
|
||||
x = FieldFirstX + FieldSize * column + FieldSpace * column;
|
||||
}
|
||||
else
|
||||
{
|
||||
Fields[i].Button.Visible = false;
|
||||
Fields[i].Button.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFieldContents()
|
||||
{
|
||||
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.SColor = Buttons[ButtonField].SColor;
|
||||
Fields[i].Content = GameData.Rounds[i];
|
||||
if (Fields[i].Content.Finished)
|
||||
{
|
||||
Fields[i].Button.Enabled = false;
|
||||
Fields[i].Button.Texture = CBase.Songs.GetSongByID(Fields[i].Content.SongID).CoverTextureBig;
|
||||
Fields[i].Button.Color = CBase.Theme.GetPlayerColor(Fields[i].Content.Winner);
|
||||
Fields[i].Button.SColor = CBase.Theme.GetPlayerColor(Fields[i].Content.Winner);
|
||||
}
|
||||
if (Status == EStatus.FieldSelected && SelectedField == i)
|
||||
{
|
||||
Fields[i].Button.Texture = CBase.Songs.GetSongByID(Fields[i].Content.SongID).CoverTextureBig;
|
||||
Fields[i].Button.Color = new SColorF(1, 1, 1, 1);
|
||||
Fields[i].Button.SColor = new SColorF(1, 1, 1, 1);
|
||||
Fields[i].Button.Enabled = false;
|
||||
}
|
||||
if (Status == EStatus.JokerRetry && Fields[i].Content.Finished)
|
||||
{
|
||||
Fields[i].Button.SColor = CBase.Theme.GetPlayerColor(GameData.Team + 1);
|
||||
Fields[i].Button.Enabled = true;
|
||||
}
|
||||
if (Status == EStatus.JokerRetry && !Fields[i].Content.Finished)
|
||||
Fields[i].Button.Enabled = false;
|
||||
if (Status == EStatus.FieldSelected)
|
||||
Fields[i].Button.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void FieldSelected()
|
||||
{
|
||||
int SongID = 0;
|
||||
int SingerTeam1 = 0;
|
||||
int SingerTeam2 = 0;
|
||||
if (GameData.Songs.Count > 0)
|
||||
{
|
||||
SongID = GameData.Songs[0];
|
||||
GameData.Songs.RemoveAt(0);
|
||||
}
|
||||
if (GameData.PlayerTeam1.Count > 0)
|
||||
{
|
||||
SingerTeam1 = GameData.PlayerTeam1[0];
|
||||
GameData.PlayerTeam1.RemoveAt(0);
|
||||
}
|
||||
|
||||
if (GameData.PlayerTeam2.Count > 0)
|
||||
{
|
||||
SingerTeam2 = GameData.PlayerTeam2[0];
|
||||
GameData.PlayerTeam2.RemoveAt(0);
|
||||
}
|
||||
CSong Song = CBase.Songs.GetSongByID(SongID);
|
||||
|
||||
CBase.BackgroundMusic.SetStatus(true);
|
||||
|
||||
PreviewStream = CBase.Sound.Load(Song.GetMP3(), false);
|
||||
CBase.Sound.SetPosition(PreviewStream, Song.PreviewStart);
|
||||
CBase.Sound.SetStreamVolume(PreviewStream, 0f);
|
||||
CBase.Sound.Play(PreviewStream);
|
||||
CBase.Sound.Fade(PreviewStream, CBase.Config.GetBackgroundMusicVolume(), 1f);
|
||||
Status = EStatus.FieldSelected;
|
||||
Fields[SelectedField].Content.SongID = SongID;
|
||||
GameData.Rounds[SelectedField].SongID = SongID;
|
||||
GameData.Rounds[SelectedField].SingerTeam1 = SingerTeam1;
|
||||
GameData.Rounds[SelectedField].SingerTeam2 = SingerTeam2;
|
||||
UpdateFieldContents();
|
||||
|
||||
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;
|
||||
|
||||
UpdateJokerButtons();
|
||||
|
||||
Buttons[ButtonNextRound].Visible = true;
|
||||
Buttons[ButtonExit].Visible = true;
|
||||
Buttons[ButtonBack].Visible = false;
|
||||
|
||||
SetInteractionToButton(Buttons[ButtonNextRound]);
|
||||
}
|
||||
|
||||
private void FieldSelectedAgain()
|
||||
{
|
||||
int SongID = Fields[SelectedField].Content.SongID;
|
||||
CSong Song = CBase.Songs.GetSongByID(SongID);
|
||||
CBase.BackgroundMusic.SetStatus(true);
|
||||
|
||||
PreviewStream = CBase.Sound.Load(Song.GetMP3(), false);
|
||||
CBase.Sound.SetPosition(PreviewStream, Song.PreviewStart);
|
||||
CBase.Sound.SetStreamVolume(PreviewStream, 0f);
|
||||
CBase.Sound.Play(PreviewStream);
|
||||
CBase.Sound.Fade(PreviewStream, CBase.Config.GetBackgroundMusicVolume(), 1f);
|
||||
Status = EStatus.FieldSelected;
|
||||
Fields[SelectedField].Content.SongID = SongID;
|
||||
GameData.Rounds[SelectedField].SongID = SongID;
|
||||
GameData.Rounds[SelectedField].SingerTeam1 = GameData.Rounds[OldSelectedField].SingerTeam1;
|
||||
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;
|
||||
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;
|
||||
|
||||
UpdateJokerButtons();
|
||||
|
||||
Buttons[ButtonNextRound].Visible = true;
|
||||
Buttons[ButtonExit].Visible = true;
|
||||
Buttons[ButtonBack].Visible = false;
|
||||
|
||||
SetInteractionToButton(Buttons[ButtonNextRound]);
|
||||
}
|
||||
|
||||
private void UseJoker(int TeamNr, int JokerNum)
|
||||
{
|
||||
switch (JokerNum)
|
||||
{
|
||||
//Random-Joker
|
||||
case 0:
|
||||
if (GameData.NumJokerRandom[TeamNr] > 0)
|
||||
{
|
||||
GameData.NumJokerRandom[TeamNr]--;
|
||||
if (!CBase.Sound.IsFinished(PreviewStream))
|
||||
CBase.Sound.FadeAndStop(PreviewStream, 0, 1);
|
||||
FieldSelected();
|
||||
}
|
||||
break;
|
||||
|
||||
//Retry-Joker
|
||||
case 1:
|
||||
if (GameData.NumJokerRetry[TeamNr] > 0 && GameData.CurrentRoundNr > 1)
|
||||
{
|
||||
GameData.NumJokerRetry[TeamNr]--;
|
||||
GameData.Team = TeamNr;
|
||||
if (!CBase.Sound.IsFinished(PreviewStream))
|
||||
CBase.Sound.FadeAndStop(PreviewStream, 0, 1);
|
||||
Status = EStatus.JokerRetry;
|
||||
OldSelectedField = SelectedField;
|
||||
SelectedField = -1;
|
||||
UpdateFieldContents();
|
||||
}
|
||||
break;
|
||||
}
|
||||
UpdateJokerButtons();
|
||||
}
|
||||
|
||||
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);
|
||||
if (Status == EStatus.JokerRetry || Status == EStatus.FieldChoosing)
|
||||
Texts[TextTeamChoosing].Visible = true;
|
||||
else
|
||||
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;
|
||||
}
|
||||
|
||||
private void NextRound()
|
||||
{
|
||||
CBase.Sound.FadeAndStop(PreviewStream, 0f, 0.5f);
|
||||
Data.ScreenMain.Rounds = GameData.Rounds;
|
||||
Data.ScreenMain.FadeToNameSelection = false;
|
||||
Data.ScreenMain.FadeToSinging = true;
|
||||
Data.ScreenMain.Songs = GameData.Songs;
|
||||
Data.ScreenMain.SingRoundNr = SelectedField;
|
||||
Data.ScreenMain.PlayerTeam1 = GameData.PlayerTeam1;
|
||||
Data.ScreenMain.PlayerTeam2 = GameData.PlayerTeam2;
|
||||
_PartyMode.DataFromScreen(ThemeName, Data);
|
||||
}
|
||||
|
||||
private void EndParty()
|
||||
{
|
||||
CBase.Sound.FadeAndStop(PreviewStream, 0f, 0.5f);
|
||||
FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void ShowPopup(bool Visible)
|
||||
{
|
||||
ExitPopupVisible = Visible;
|
||||
|
||||
Statics[StaticPopupBG].Visible = ExitPopupVisible;
|
||||
Texts[TextPopupReallyExit].Visible = ExitPopupVisible;
|
||||
Buttons[ButtonPopupYes].Visible = ExitPopupVisible;
|
||||
Buttons[ButtonPopupNo].Visible = ExitPopupVisible;
|
||||
|
||||
if (ExitPopupVisible)
|
||||
SetInteractionToButton(Buttons[ButtonPopupNo]);
|
||||
}
|
||||
|
||||
private void Back()
|
||||
{
|
||||
CBase.Sound.FadeAndStop(PreviewStream, 0f, 0.5f);
|
||||
Data.ScreenMain.FadeToNameSelection = true;
|
||||
Data.ScreenMain.FadeToSinging = false;
|
||||
Data.ScreenMain.SingRoundNr = SelectedField;
|
||||
_PartyMode.DataFromScreen(ThemeName, Data);
|
||||
}
|
||||
|
||||
private int BuildWinnerPossibilities()
|
||||
{
|
||||
int NumOneRow = (int)Math.Sqrt(GameData.NumFields);
|
||||
Possibilities = new int[(NumOneRow * 2) + 2,NumOneRow];
|
||||
for (int i = 0; i < Possibilities.GetLength(0); i++)
|
||||
{
|
||||
if (i < NumOneRow)
|
||||
{
|
||||
for (int c = 0; c < NumOneRow; c++)
|
||||
Possibilities[i, c] = i * NumOneRow + c;
|
||||
}
|
||||
else if (i < NumOneRow * 2)
|
||||
{
|
||||
for (int c = 0; c < NumOneRow; c++)
|
||||
Possibilities[i, c] = (i - NumOneRow) + (c * NumOneRow);
|
||||
}
|
||||
else if (i == Possibilities.GetLength(0) - 2)
|
||||
{
|
||||
for (int c = 0; c < NumOneRow; c++)
|
||||
Possibilities[i, c] = (NumOneRow + 1) * c;
|
||||
}
|
||||
else if (i == Possibilities.GetLength(0) - 1)
|
||||
{
|
||||
for (int c = 0; c < NumOneRow; c++)
|
||||
Possibilities[i, c] = (NumOneRow - 1) * c + (NumOneRow - 1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int GetWinner()
|
||||
{
|
||||
for (int i = 0; i < Possibilities.GetLength(0); i++)
|
||||
{
|
||||
List<int> Check = new List<int>();
|
||||
for (int j = 0; j < Possibilities.GetLength(1); j++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,646 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
public class PartyScreenTicTacToeNames : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string ButtonNext = "ButtonNext";
|
||||
private const string ButtonBack = "ButtonBack";
|
||||
private const string ButtonPlayerDestination = "ButtonPlayerDestination";
|
||||
private const string ButtonPlayerChoose = "ButtonPlayerChoose";
|
||||
private const string ButtonPlayerChooseScrollUp = "ButtonPlayerChooseScrollUp";
|
||||
private const string ButtonPlayerChooseScrollDown = "ButtonPlayerChooseScrollDown";
|
||||
|
||||
private List<CPlayerChooseButton> PlayerChooseButtons;
|
||||
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;
|
||||
private const int PlayerDestinationButtonsSpaceW = 25;
|
||||
//PlayerChooseButtons-Option
|
||||
private List<int> PlayerChooseButtonsVisibleProfiles;
|
||||
private const int PlayerChooseButtonsNumH = 10;
|
||||
private const int PlayerChooseButtonsNumW = 2;
|
||||
private const int PlayerChooseButtonsFirstX = 58;
|
||||
private const int PlayerChooseButtonsFirstY = 105;
|
||||
private const int PlayerChooseButtonsSpaceH = 15;
|
||||
private const int PlayerChooseButtonsSpaceW = 25;
|
||||
private int PlayerChooseButtonsOffset;
|
||||
|
||||
private CStatic chooseAvatarStatic;
|
||||
private bool SelectingMouseActive;
|
||||
private int OldMouseX;
|
||||
private int OldMouseY;
|
||||
private int SelectedPlayerNr = -1;
|
||||
private bool ButtonsAdded;
|
||||
|
||||
private int NumPlayerTeam1 = 2;
|
||||
private int NumPlayerTeam2 = 2;
|
||||
|
||||
private DataFromScreen Data;
|
||||
|
||||
private class CPlayerChooseButton
|
||||
{
|
||||
public CButton Button;
|
||||
public int ProfileID;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
chooseAvatarStatic = GetNewStatic();
|
||||
chooseAvatarStatic.Visible = false;
|
||||
|
||||
PlayerChooseButtonsVisibleProfiles = new List<int>();
|
||||
|
||||
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 DataFromScreen();
|
||||
FromScreenNames names = new FromScreenNames();
|
||||
names.FadeToConfig = false;
|
||||
names.FadeToMain = false;
|
||||
names.ProfileIDsTeam1 = new List<int>();
|
||||
names.ProfileIDsTeam2 = new List<int>();
|
||||
Data.ScreenNames = names;
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenNames config = new DataToScreenNames();
|
||||
|
||||
try
|
||||
{
|
||||
config = (DataToScreenNames)ReceivedData;
|
||||
Data.ScreenNames.ProfileIDsTeam1 = config.ProfileIDsTeam1;
|
||||
Data.ScreenNames.ProfileIDsTeam2 = config.ProfileIDsTeam2;
|
||||
if (Data.ScreenNames.ProfileIDsTeam1 == null)
|
||||
Data.ScreenNames.ProfileIDsTeam1 = new List<int>();
|
||||
if (Data.ScreenNames.ProfileIDsTeam2 == null)
|
||||
Data.ScreenNames.ProfileIDsTeam2 = new List<int>();
|
||||
|
||||
NumPlayerTeam1 = config.NumPlayerTeam1;
|
||||
NumPlayerTeam2 = config.NumPlayerTeam2;
|
||||
|
||||
while (Data.ScreenNames.ProfileIDsTeam1.Count > NumPlayerTeam1)
|
||||
Data.ScreenNames.ProfileIDsTeam1.RemoveAt(Data.ScreenNames.ProfileIDsTeam1.Count - 1);
|
||||
while (Data.ScreenNames.ProfileIDsTeam2.Count > NumPlayerTeam2)
|
||||
Data.ScreenNames.ProfileIDsTeam2.RemoveAt(Data.ScreenNames.ProfileIDsTeam2.Count - 1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error in party mode screen TicTacToe names. Can't cast received data from game mode " + ThemeName + ". " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
|
||||
if (Buttons[ButtonPlayerChooseScrollUp].Selected)
|
||||
Scroll(-1);
|
||||
|
||||
if (Buttons[ButtonPlayerChooseScrollDown].Selected)
|
||||
Scroll(1);
|
||||
|
||||
if (!OnAdd())
|
||||
OnRemove();
|
||||
break;
|
||||
|
||||
case Keys.Delete:
|
||||
OnRemove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode inactive
|
||||
if (mouseEvent.LBH && !SelectingMouseActive)
|
||||
{
|
||||
//Save mouse-coords
|
||||
OldMouseX = mouseEvent.X;
|
||||
OldMouseY = mouseEvent.Y;
|
||||
//Check if mouse if over tile
|
||||
for (int i = 0; i < PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
if (PlayerChooseButtons[i].Button.Selected)
|
||||
{
|
||||
SelectedPlayerNr = PlayerChooseButtons[i].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.Z = -100;
|
||||
chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
|
||||
chooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[SelectedPlayerNr].Avatar.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode active
|
||||
if (mouseEvent.LBH && SelectingMouseActive)
|
||||
{
|
||||
//Update coords for Drag/Drop-Texture
|
||||
chooseAvatarStatic.Rect.X += mouseEvent.X - OldMouseX;
|
||||
chooseAvatarStatic.Rect.Y += mouseEvent.Y - OldMouseY;
|
||||
OldMouseX = mouseEvent.X;
|
||||
OldMouseY = mouseEvent.Y;
|
||||
|
||||
return true;
|
||||
}
|
||||
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
|
||||
else if (SelectingMouseActive)
|
||||
{
|
||||
//Check if really a player was selected
|
||||
if (SelectedPlayerNr != -1)
|
||||
{
|
||||
//Foreach Drop-Area
|
||||
for (int i = 0; i < PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
//Check first, if area is "active"
|
||||
if (PlayerDestinationButtons[i].Visible)
|
||||
{
|
||||
//Check if Mouse is in area
|
||||
if (CHelper.IsInBounds(PlayerDestinationButtons[i].Rect, mouseEvent))
|
||||
{
|
||||
int added = -1;
|
||||
//Add Player-ID to list.
|
||||
if (i - PlayerDestinationButtonsNumH < 0)
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDsTeam1.Count < (i + 1))
|
||||
{
|
||||
Data.ScreenNames.ProfileIDsTeam1.Add(SelectedPlayerNr);
|
||||
added = Data.ScreenNames.ProfileIDsTeam1.Count - 1;
|
||||
}
|
||||
else if (Data.ScreenNames.ProfileIDsTeam1.Count >= (i + 1))
|
||||
{
|
||||
Data.ScreenNames.ProfileIDsTeam1[i] = SelectedPlayerNr;
|
||||
added = i;
|
||||
}
|
||||
}
|
||||
else if (i - PlayerDestinationButtonsNumH >= 0)
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDsTeam2.Count < ((i - PlayerDestinationButtonsNumH) + 1))
|
||||
{
|
||||
Data.ScreenNames.ProfileIDsTeam2.Add(SelectedPlayerNr);
|
||||
added = Data.ScreenNames.ProfileIDsTeam2.Count - 1 + PlayerDestinationButtonsNumH;
|
||||
}
|
||||
else if (Data.ScreenNames.ProfileIDsTeam2.Count >= ((i - PlayerDestinationButtonsNumH) + 1))
|
||||
{
|
||||
Data.ScreenNames.ProfileIDsTeam2[i - PlayerDestinationButtonsNumH] = SelectedPlayerNr;
|
||||
added = i;
|
||||
}
|
||||
}
|
||||
UpdateButtonNext();
|
||||
//Update texture and name
|
||||
PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerDestinationButtons[added].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[added].Texture = chooseAvatarStatic.Texture;
|
||||
PlayerDestinationButtons[added].STexture = chooseAvatarStatic.Texture;
|
||||
PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[SelectedPlayerNr].PlayerName;
|
||||
PlayerDestinationButtons[added].Enabled = true;
|
||||
//Update Tiles-List
|
||||
UpdateButtonPlayerChoose();
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectedPlayerNr = -1;
|
||||
}
|
||||
//Reset variables
|
||||
SelectingMouseActive = false;
|
||||
chooseAvatarStatic.Visible = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (Buttons[ButtonBack].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[ButtonNext].Selected)
|
||||
Next();
|
||||
|
||||
if (Buttons[ButtonPlayerChooseScrollUp].Selected)
|
||||
Scroll(-1);
|
||||
|
||||
if (Buttons[ButtonPlayerChooseScrollDown].Selected)
|
||||
Scroll(1);
|
||||
}
|
||||
|
||||
if (mouseEvent.LD && IsMouseOver(mouseEvent))
|
||||
{
|
||||
if (!OnAdd())
|
||||
OnRemove();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
Back();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
if (!ButtonsAdded)
|
||||
{
|
||||
AddButtonPlayerDestination();
|
||||
AddButtonPlayerChoose();
|
||||
ButtonsAdded = true;
|
||||
}
|
||||
|
||||
UpdateButtonPlayerDestination();
|
||||
UpdateButtonPlayerChoose();
|
||||
|
||||
UpdateButtonNext();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
if (chooseAvatarStatic.Visible)
|
||||
chooseAvatarStatic.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Scroll(int Offset)
|
||||
{
|
||||
if (Offset < 0 && PlayerChooseButtonsOffset > 0)
|
||||
{
|
||||
PlayerChooseButtonsOffset += Offset;
|
||||
UpdateButtonPlayerChoose();
|
||||
}
|
||||
else if (PlayerChooseButtonsVisibleProfiles.Count < PlayerChooseButtons.Count + (PlayerChooseButtonsOffset + Offset) * PlayerChooseButtonsNumH)
|
||||
{
|
||||
PlayerChooseButtonsOffset += Offset;
|
||||
UpdateButtonPlayerChoose();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButtonPlayerDestination()
|
||||
{
|
||||
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]);
|
||||
b.Rect.X = PlayerDestinationButtonsFirstX + column * (b.Rect.W + PlayerDestinationButtonsSpaceH);
|
||||
b.Rect.Y = PlayerDestinationButtonsFirstY + row * (b.Rect.H + PlayerDestinationButtonsSpaceW);
|
||||
PlayerDestinationButtons.Add(b);
|
||||
column++;
|
||||
if (column >= PlayerDestinationButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButtonPlayerChoose()
|
||||
{
|
||||
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]);
|
||||
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;
|
||||
PlayerChooseButtons.Add(pcb);
|
||||
column++;
|
||||
if (column >= PlayerChooseButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerChoose()
|
||||
{
|
||||
UpdateVisibleProfiles();
|
||||
if ((PlayerChooseButtonsNumW * PlayerChooseButtonsNumH) * (PlayerChooseButtonsOffset + 1) - PlayerChooseButtonsVisibleProfiles.Count >=
|
||||
(PlayerChooseButtonsNumW * PlayerChooseButtonsNumH) * PlayerChooseButtonsOffset)
|
||||
UpdateButtonPlayerChoose(PlayerChooseButtonsOffset - 1);
|
||||
else
|
||||
UpdateButtonPlayerChoose(PlayerChooseButtonsOffset);
|
||||
Buttons[ButtonPlayerChooseScrollUp].Enabled = PlayerChooseButtonsOffset > 0;
|
||||
Buttons[ButtonPlayerChooseScrollDown].Enabled = PlayerChooseButtonsVisibleProfiles.Count >
|
||||
PlayerChooseButtons.Count + PlayerChooseButtonsOffset * PlayerChooseButtonsNumH;
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerChoose(int Offset)
|
||||
{
|
||||
int NumButtonPlayerChoose = PlayerChooseButtonsNumW * PlayerChooseButtonsNumH;
|
||||
if (Offset < 0)
|
||||
Offset = 0;
|
||||
|
||||
if (NumButtonPlayerChoose * (Offset + 1) - PlayerChooseButtonsVisibleProfiles.Count <= NumButtonPlayerChoose)
|
||||
{
|
||||
for (int i = 0; i < NumButtonPlayerChoose; i++)
|
||||
{
|
||||
if ((i + Offset * NumButtonPlayerChoose) < PlayerChooseButtonsVisibleProfiles.Count)
|
||||
{
|
||||
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.STexture = CBase.Profiles.GetProfiles()[PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose]].Avatar.Texture;
|
||||
PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerChooseButtons[i].Button.SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerChooseButtons[i].Button.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerChooseButtons[i].ProfileID = -1;
|
||||
PlayerChooseButtons[i].Button.Text.Text = String.Empty;
|
||||
PlayerChooseButtons[i].Button.Texture = Buttons[ButtonPlayerChoose].Texture;
|
||||
PlayerChooseButtons[i].Button.STexture = Buttons[ButtonPlayerChoose].STexture;
|
||||
PlayerChooseButtons[i].Button.Color = Buttons[ButtonPlayerChoose].Color;
|
||||
PlayerChooseButtons[i].Button.SColor = Buttons[ButtonPlayerChoose].SColor;
|
||||
PlayerChooseButtons[i].Button.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateVisibleProfiles()
|
||||
{
|
||||
PlayerChooseButtonsVisibleProfiles.Clear();
|
||||
for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (visible)
|
||||
PlayerChooseButtonsVisibleProfiles.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerDestination()
|
||||
{
|
||||
for (int i = 0; i < PlayerDestinationButtons.Count / 2; i++)
|
||||
{
|
||||
if (NumPlayerTeam1 > i)
|
||||
{
|
||||
PlayerDestinationButtons[i].Visible = true;
|
||||
PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerDestinationButtons[i].Visible = false;
|
||||
PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < PlayerDestinationButtons.Count / 2; i++)
|
||||
{
|
||||
if (NumPlayerTeam2 > i)
|
||||
{
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Visible = true;
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Visible = false;
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < NumPlayerTeam1; i++)
|
||||
{
|
||||
if (i < Data.ScreenNames.ProfileIDsTeam1.Count)
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDsTeam1[i] != -1)
|
||||
{
|
||||
PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerDestinationButtons[i].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDsTeam1[i]].Avatar.Texture;
|
||||
PlayerDestinationButtons[i].STexture = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDsTeam1[i]].Avatar.Texture;
|
||||
PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDsTeam1[i]].PlayerName;
|
||||
PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerDestinationButtons[i].Color = Buttons[ButtonPlayerDestination].Color;
|
||||
PlayerDestinationButtons[i].SColor = Buttons[ButtonPlayerDestination].SColor;
|
||||
PlayerDestinationButtons[i].Texture = Buttons[ButtonPlayerDestination].Texture;
|
||||
PlayerDestinationButtons[i].STexture = Buttons[ButtonPlayerDestination].STexture;
|
||||
PlayerDestinationButtons[i].Text.Text = String.Empty;
|
||||
PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < NumPlayerTeam2; i++)
|
||||
{
|
||||
if (i < Data.ScreenNames.ProfileIDsTeam2.Count)
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDsTeam2[i] != -1)
|
||||
{
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Texture = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDsTeam2[i]].Avatar.Texture;
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].STexture = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDsTeam2[i]].Avatar.Texture;
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Text.Text = CBase.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDsTeam2[i]].PlayerName;
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Enabled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Color = Buttons[ButtonPlayerDestination].Color;
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].SColor = Buttons[ButtonPlayerDestination].SColor;
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Texture = Buttons[ButtonPlayerDestination].Texture;
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].STexture = Buttons[ButtonPlayerDestination].STexture;
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Text.Text = String.Empty;
|
||||
PlayerDestinationButtons[i + PlayerDestinationButtonsNumH].Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonNext()
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDsTeam1.Count == NumPlayerTeam1 && Data.ScreenNames.ProfileIDsTeam2.Count == NumPlayerTeam2)
|
||||
{
|
||||
Buttons[ButtonNext].Visible = true;
|
||||
SetInteractionToButton(Buttons[ButtonNext]);
|
||||
}
|
||||
else
|
||||
Buttons[ButtonNext].Visible = false;
|
||||
}
|
||||
|
||||
private bool OnAdd()
|
||||
{
|
||||
for (int i = 0; i < PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
if (PlayerChooseButtons[i].Button.Selected && PlayerChooseButtons[i].ProfileID != -1)
|
||||
{
|
||||
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].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[PlayerChooseButtons[i].ProfileID].Avatar.Texture;
|
||||
PlayerDestinationButtons[added].STexture = 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].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[PlayerChooseButtons[i].ProfileID].Avatar.Texture;
|
||||
PlayerDestinationButtons[added].STexture = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool OnRemove()
|
||||
{
|
||||
for (int i = 0; i < PlayerDestinationButtonsNumH; i++)
|
||||
{
|
||||
if (PlayerDestinationButtons[i].Selected)
|
||||
{
|
||||
if ((i + 1) <= Data.ScreenNames.ProfileIDsTeam1.Count)
|
||||
{
|
||||
Data.ScreenNames.ProfileIDsTeam1.RemoveAt(i);
|
||||
UpdateButtonNext();
|
||||
UpdateButtonPlayerDestination();
|
||||
UpdateButtonPlayerChoose();
|
||||
CheckInteraction();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = PlayerDestinationButtonsNumH; i < PlayerDestinationButtonsNumH * 2; i++)
|
||||
{
|
||||
if (PlayerDestinationButtons[i].Selected)
|
||||
{
|
||||
if (((i - PlayerDestinationButtonsNumH) + 1) <= Data.ScreenNames.ProfileIDsTeam2.Count)
|
||||
{
|
||||
Data.ScreenNames.ProfileIDsTeam2.RemoveAt(i - PlayerDestinationButtonsNumH);
|
||||
UpdateButtonNext();
|
||||
UpdateButtonPlayerDestination();
|
||||
UpdateButtonPlayerChoose();
|
||||
CheckInteraction();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+73
-1
@@ -1,10 +1,15 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeEditing/GenerateMemberBody/AccessorImplementationKind/@EntryValue">Default</s:String>
|
||||
<s:String x:Key="/Default/CodeEditing/GenerateMemberBody/MethodImplementationKind/@EntryValue">NotCompiledCode</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/IntelliSenseCompletingCharactersSettingCSharp/UpgradedFromVSSettings/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/LookupWindow/ShowSignatures/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EmptyGeneralCatchClause/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantExplicitArrayCreation/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SpecifyACultureInStringConversionExplicitly/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEverywhere/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Cleanup/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="Cleanup"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_EXPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_EXPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_EXPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSShortenReferences>True</CSShortenReferences><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpaLine truncated
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Cleanup/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="Cleanup"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_EXPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_EXPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_EXPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSShortenReferences>True</CSShortenReferences><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpaLine truncated
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Simple_0020Reformat/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="Simple Reformat"><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpace>True</SA1006PreprocessorKeywordsMustNotBePrecededBySpace><SA1021NegativeSignsMustBeSpacedCorrectly>True</SA1021NegativeSignsMustBeSpacedCorrectly><SA1022PositiveSignsMustBeSpacedCorrectly>True</SA1022PositiveSignsMustBeSpacedCorrectly><SA1025CodeMustNotContainMultipleWhitespaceInARow>True</SA1025CodeMustNotContainMultipleWhitespaceInARow></StyleCop.Spacing><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Ordering><AlphabeticalUsingDirectives>Ignore</AlphabeticalUsingDirectives><ExpandUsingDirectiLine truncated
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">Cleanup</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">Simple Reformat</s:String>
|
||||
@@ -32,13 +37,80 @@
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_MULTIPLE_DECLARATION_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_TERNARY_EXPR_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AllowAlias/@EntryValue">False</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderRegionName/@EntryValue">license</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue">/*
|
||||
This file is part of $SOLUTION$.
|
||||

|
||||
$SOLUTION$ 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.
|
||||

|
||||
$SOLUTION$ 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 $SOLUTION$. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AA/@EntryIndexedValue">AA</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AC/@EntryIndexedValue">AC</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AL/@EntryIndexedValue">AL</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ALSA/@EntryIndexedValue">ALSA</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ASIO/@EntryIndexedValue">ASIO</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BG/@EntryIndexedValue">BG</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BGR/@EntryIndexedValue">BGR</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BPM/@EntryIndexedValue">BPM</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CV/@EntryIndexedValue">CV</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DB/@EntryIndexedValue">DB</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DX/@EntryIndexedValue">DX</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DY/@EntryIndexedValue">DY</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FG/@EntryIndexedValue">FG</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FPS/@EntryIndexedValue">FPS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GL/@EntryIndexedValue">GL</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HID/@EntryIndexedValue">HID</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HPI/@EntryIndexedValue">HPI</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IO/@EntryIndexedValue">IO</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IR/@EntryIndexedValue">IR</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=JACK/@EntryIndexedValue">JACK</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LB/@EntryIndexedValue">LB</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LBH/@EntryIndexedValue">LBH</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LD/@EntryIndexedValue">LD</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LE/@EntryIndexedValue">LE</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LED/@EntryIndexedValue">LED</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MB/@EntryIndexedValue">MB</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MBH/@EntryIndexedValue">MBH</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MME/@EntryIndexedValue">MME</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MP/@EntryIndexedValue">MP</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OS/@EntryIndexedValue">OS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OSS/@EntryIndexedValue">OSS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PBO/@EntryIndexedValue">PBO</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PID/@EntryIndexedValue">PID</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RB/@EntryIndexedValue">RB</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RBH/@EntryIndexedValue">RBH</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RC/@EntryIndexedValue">RC</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RGB/@EntryIndexedValue">RGB</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RGBA/@EntryIndexedValue">RGBA</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=USDX/@EntryIndexedValue">USDX</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WASAPI/@EntryIndexedValue">WASAPI</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WDMKS/@EntryIndexedValue">WDMKS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XML/@EntryIndexedValue">XML</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Constants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Other/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypeParameters/@EntryIndexedValue"><Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypesAndNamespaces/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=27c8359b_002D97bf_002D4e1d_002Db126_002D4f613028bcc5/@EntryIndexedValue"><Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected, ProtectedInternal, Internal, Public" Description="Enums"><ElementKinds><Kind Name="ENUM" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="E" Suffix="" Style="AaBb" /></Policy></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=8cff90ce_002Def0d_002D436d_002Db8f2_002D5b5bdb923d3b/@EntryIndexedValue"><Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected, ProtectedInternal, Internal, Public" Description="Classes"><ElementKinds><Kind Name="CLASS" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="C" Suffix="" Style="AaBb" /></Policy></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=9aa707ae_002Dd4fb_002D4760_002Da649_002Dffcedfabd5dc/@EntryIndexedValue"><Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected" Description="Fields (not public)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /><Kind Name="METHOD" /><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /></Policy></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=da335a8d_002D4b6e_002D4df6_002D8434_002D29ffe5e2547b/@EntryIndexedValue"><Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected, ProtectedInternal, Internal, Public" Description="Structs"><ElementKinds><Kind Name="STRUCT" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="S" Suffix="" Style="AaBb" /></Policy></s:String>
|
||||
</wpf:ResourceDictionary>
|
||||
@@ -12,12 +12,12 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
private static int _CurrentMusicStream = -1;
|
||||
private static int _PreviousMusicIndex;
|
||||
private static PlaylistElement _CurrentPlaylistElement = new PlaylistElement();
|
||||
private static CPlaylistElement _CurrentPlaylistElement = new CPlaylistElement();
|
||||
|
||||
private static readonly List<PlaylistElement> _AllFileNames = new List<PlaylistElement>();
|
||||
private static readonly List<PlaylistElement> _NotPlayedFileNames = new List<PlaylistElement>();
|
||||
private static readonly List<PlaylistElement> _BGMusicFileNames = new List<PlaylistElement>();
|
||||
private static readonly List<PlaylistElement> _PreviousFileNames = new List<PlaylistElement>();
|
||||
private static readonly List<CPlaylistElement> _AllFileNames = new List<CPlaylistElement>();
|
||||
private static readonly List<CPlaylistElement> _NotPlayedFileNames = new List<CPlaylistElement>();
|
||||
private static readonly List<CPlaylistElement> _BGMusicFileNames = new List<CPlaylistElement>();
|
||||
private static readonly List<CPlaylistElement> _PreviousFileNames = new List<CPlaylistElement>();
|
||||
|
||||
private static int _Video = -1;
|
||||
private static STexture _CurrentVideoTexture = new STexture(-1);
|
||||
@@ -114,10 +114,10 @@ namespace Vocaluxe.Base
|
||||
List<string> templist = new List<string>();
|
||||
|
||||
foreach (string ending in CSettings.MusicFileTypes)
|
||||
templist.AddRange(CHelper.ListFiles(CSettings.sFolderBackgroundMusic, ending, true, true));
|
||||
templist.AddRange(CHelper.ListFiles(CSettings.FolderBackgroundMusic, ending, true, true));
|
||||
|
||||
foreach (string path in templist)
|
||||
_BGMusicFileNames.Add(new PlaylistElement(path));
|
||||
_BGMusicFileNames.Add(new CPlaylistElement(path));
|
||||
|
||||
if (CConfig.BackgroundMusicSource != EBackgroundMusicSource.TR_CONFIG_ONLY_OWN_MUSIC)
|
||||
AddBackgroundMusic();
|
||||
@@ -147,7 +147,7 @@ namespace Vocaluxe.Base
|
||||
else
|
||||
Next();
|
||||
|
||||
if (!IsBackgroundFile(_CurrentPlaylistElement))
|
||||
if (!_IsBackgroundFile(_CurrentPlaylistElement))
|
||||
_CanSing = true;
|
||||
else
|
||||
_CanSing = false;
|
||||
@@ -169,7 +169,7 @@ namespace Vocaluxe.Base
|
||||
CSound.FadeAndStop(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
|
||||
_CurrentMusicStream = -1;
|
||||
|
||||
_CurrentPlaylistElement = new PlaylistElement();
|
||||
_CurrentPlaylistElement = new CPlaylistElement();
|
||||
_Playing = false;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ namespace Vocaluxe.Base
|
||||
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
|
||||
|
||||
if (_VideoEnabled)
|
||||
LoadVideo();
|
||||
_LoadVideo();
|
||||
CSound.SetStreamVolume(_CurrentMusicStream, 0f);
|
||||
Play();
|
||||
}
|
||||
@@ -294,7 +294,7 @@ namespace Vocaluxe.Base
|
||||
_CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.MusicFilePath);
|
||||
CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume);
|
||||
if (_VideoEnabled)
|
||||
LoadVideo();
|
||||
_LoadVideo();
|
||||
CSound.SetStreamVolume(_CurrentMusicStream, 0f);
|
||||
Play();
|
||||
}
|
||||
@@ -327,8 +327,8 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
foreach (CSong song in CSongs.AllSongs)
|
||||
{
|
||||
_AllFileNames.Add(new PlaylistElement(song));
|
||||
_NotPlayedFileNames.Add(new PlaylistElement(song));
|
||||
_AllFileNames.Add(new CPlaylistElement(song));
|
||||
_NotPlayedFileNames.Add(new CPlaylistElement(song));
|
||||
}
|
||||
}
|
||||
_OwnMusicAdded = true;
|
||||
@@ -345,7 +345,7 @@ namespace Vocaluxe.Base
|
||||
_NotPlayedFileNames.AddRange(_BGMusicFileNames);
|
||||
}
|
||||
|
||||
if (Playing && !IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0)
|
||||
if (Playing && !_IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0)
|
||||
Next();
|
||||
|
||||
_OwnMusicAdded = false;
|
||||
@@ -370,18 +370,18 @@ namespace Vocaluxe.Base
|
||||
AddOwnMusic();
|
||||
_BackgroundMusicAdded = false;
|
||||
|
||||
if (Playing && IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0)
|
||||
if (Playing && _IsBackgroundFile(_CurrentPlaylistElement) || _AllFileNames.Count == 0)
|
||||
Next();
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckAndApplyConfig(EOffOn NewOnOff, EBackgroundMusicSource NewSource, float NewVolume)
|
||||
public static void CheckAndApplyConfig(EOffOn newOnOff, EBackgroundMusicSource newSource, float newVolume)
|
||||
{
|
||||
if (CConfig.BackgroundMusicSource != NewSource || (NewOnOff == EOffOn.TR_CONFIG_ON && !_OwnMusicAdded && !_BackgroundMusicAdded))
|
||||
if (CConfig.BackgroundMusicSource != newSource || (newOnOff == EOffOn.TR_CONFIG_ON && !_OwnMusicAdded && !_BackgroundMusicAdded))
|
||||
{
|
||||
CConfig.BackgroundMusicSource = NewSource;
|
||||
CConfig.BackgroundMusicSource = newSource;
|
||||
|
||||
switch (NewSource)
|
||||
switch (newSource)
|
||||
{
|
||||
case EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC:
|
||||
if (!_BackgroundMusicAdded)
|
||||
@@ -406,18 +406,18 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
if (CConfig.BackgroundMusic != NewOnOff)
|
||||
if (CConfig.BackgroundMusic != newOnOff)
|
||||
{
|
||||
CConfig.BackgroundMusic = NewOnOff;
|
||||
if (NewOnOff == EOffOn.TR_CONFIG_ON)
|
||||
CConfig.BackgroundMusic = newOnOff;
|
||||
if (newOnOff == EOffOn.TR_CONFIG_ON)
|
||||
Play();
|
||||
else
|
||||
Pause();
|
||||
}
|
||||
|
||||
if (CConfig.BackgroundMusicVolume != NewVolume)
|
||||
if (CConfig.BackgroundMusicVolume != newVolume)
|
||||
{
|
||||
CConfig.BackgroundMusicVolume = (int)NewVolume;
|
||||
CConfig.BackgroundMusicVolume = (int)newVolume;
|
||||
ApplyVolume();
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
else
|
||||
LoadVideo();
|
||||
_LoadVideo();
|
||||
}
|
||||
|
||||
public static STexture GetVideoTexture()
|
||||
@@ -455,10 +455,10 @@ namespace Vocaluxe.Base
|
||||
float vtime = 0f;
|
||||
CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), ref vtime);
|
||||
if (_FadeTimer.ElapsedMilliseconds <= 3000L)
|
||||
_CurrentVideoTexture.color.A = _FadeTimer.ElapsedMilliseconds / 3000f;
|
||||
_CurrentVideoTexture.Color.A = _FadeTimer.ElapsedMilliseconds / 3000f;
|
||||
else
|
||||
{
|
||||
_CurrentVideoTexture.color.A = 1f;
|
||||
_CurrentVideoTexture.Color.A = 1f;
|
||||
_FadeTimer.Stop();
|
||||
}
|
||||
return _CurrentVideoTexture;
|
||||
@@ -466,9 +466,9 @@ namespace Vocaluxe.Base
|
||||
return new STexture(-1);
|
||||
}
|
||||
|
||||
private static bool IsBackgroundFile(PlaylistElement element)
|
||||
private static bool _IsBackgroundFile(CPlaylistElement element)
|
||||
{
|
||||
foreach (PlaylistElement elements in _BGMusicFileNames)
|
||||
foreach (CPlaylistElement elements in _BGMusicFileNames)
|
||||
{
|
||||
if (elements.MusicFilePath == element.MusicFilePath)
|
||||
return true;
|
||||
@@ -476,7 +476,7 @@ namespace Vocaluxe.Base
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void LoadVideo()
|
||||
private static void _LoadVideo()
|
||||
{
|
||||
if (_Video == -1)
|
||||
{
|
||||
@@ -493,7 +493,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class PlaylistElement
|
||||
class CPlaylistElement
|
||||
{
|
||||
private readonly CSong _Song;
|
||||
|
||||
@@ -606,7 +606,7 @@ class PlaylistElement
|
||||
}
|
||||
}
|
||||
|
||||
public PlaylistElement(CSong song)
|
||||
public CPlaylistElement(CSong song)
|
||||
{
|
||||
MusicFilePath = string.Empty;
|
||||
_SongID = song.ID;
|
||||
@@ -614,13 +614,13 @@ class PlaylistElement
|
||||
_Song = song;
|
||||
}
|
||||
|
||||
public PlaylistElement(string FilePath)
|
||||
public CPlaylistElement(string filePath)
|
||||
{
|
||||
MusicFilePath = FilePath;
|
||||
MusicFilePath = filePath;
|
||||
_SongID = -1;
|
||||
}
|
||||
|
||||
public PlaylistElement()
|
||||
public CPlaylistElement()
|
||||
{
|
||||
MusicFilePath = string.Empty;
|
||||
_SongID = -1;
|
||||
|
||||
+67
-67
@@ -13,7 +13,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
static class CConfig
|
||||
{
|
||||
private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
|
||||
// Debug
|
||||
public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF;
|
||||
@@ -31,7 +31,7 @@ namespace Vocaluxe.Base
|
||||
public static int ScreenW = 1024;
|
||||
public static int ScreenH = 576;
|
||||
|
||||
public static EAntiAliasingModes AAMode = EAntiAliasingModes.x0;
|
||||
public static EAntiAliasingModes AAMode = EAntiAliasingModes.X0;
|
||||
public static EColorDeep Colors = EColorDeep.Bit32;
|
||||
|
||||
public static EOffOn VSync = EOffOn.TR_CONFIG_ON;
|
||||
@@ -55,7 +55,7 @@ namespace Vocaluxe.Base
|
||||
// Sound
|
||||
public static EPlaybackLib PlayBackLib = EPlaybackLib.Gstreamer;
|
||||
public static ERecordLib RecordLib = ERecordLib.PortAudio;
|
||||
public static EBufferSize AudioBufferSize = EBufferSize.b2048;
|
||||
public static EBufferSize AudioBufferSize = EBufferSize.B2048;
|
||||
public static int AudioLatency = 0;
|
||||
public static int BackgroundMusicVolume = 30;
|
||||
public static EOffOn BackgroundMusic = EOffOn.TR_CONFIG_ON;
|
||||
@@ -97,20 +97,20 @@ namespace Vocaluxe.Base
|
||||
private static readonly List<string> _Values = new List<string>();
|
||||
|
||||
//Variables to save old values for commandline-parameters
|
||||
private static readonly List<string> SongFolderOld = new List<string>();
|
||||
private static readonly List<string> _SongFolderOld = new List<string>();
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_settings.Indent = true;
|
||||
_settings.Encoding = Encoding.UTF8;
|
||||
_settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
_Settings.Indent = true;
|
||||
_Settings.Encoding = Encoding.UTF8;
|
||||
_Settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
|
||||
SongFolder.Add(Path.Combine(Directory.GetCurrentDirectory(), CSettings.sFolderSongs));
|
||||
SongFolder.Add(Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderSongs));
|
||||
|
||||
MicConfig = new SMicConfig[CSettings.MaxNumPlayer];
|
||||
|
||||
// Init config file
|
||||
if (!File.Exists(CSettings.sFileConfig))
|
||||
if (!File.Exists(CSettings.FileConfig))
|
||||
SaveConfig();
|
||||
|
||||
LoadConfig();
|
||||
@@ -118,7 +118,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static bool LoadConfig()
|
||||
{
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(CSettings.sFileConfig);
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(CSettings.FileConfig);
|
||||
if (xmlReader == null)
|
||||
return false;
|
||||
|
||||
@@ -204,10 +204,10 @@ namespace Vocaluxe.Base
|
||||
if (NumPlayer < 1 || NumPlayer > CSettings.MaxNumPlayer)
|
||||
NumPlayer = 2;
|
||||
|
||||
bool _LangExists = CLanguage.SetLanguage(Language);
|
||||
bool langExists = CLanguage.SetLanguage(Language);
|
||||
|
||||
//TODO: What should we do, if English not exists?
|
||||
if (_LangExists == false)
|
||||
if (langExists == false)
|
||||
Language = "English";
|
||||
|
||||
//Read players from config
|
||||
@@ -254,7 +254,7 @@ namespace Vocaluxe.Base
|
||||
XmlWriter writer = null;
|
||||
try
|
||||
{
|
||||
writer = XmlWriter.Create(CSettings.sFileConfig, _settings);
|
||||
writer = XmlWriter.Create(CSettings.FileConfig, _Settings);
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("root");
|
||||
|
||||
@@ -402,12 +402,12 @@ namespace Vocaluxe.Base
|
||||
|
||||
// SongFolder
|
||||
// Check, if program was started with songfolder-parameters
|
||||
if (SongFolderOld.Count > 0)
|
||||
if (_SongFolderOld.Count > 0)
|
||||
{
|
||||
//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]);
|
||||
for (int i = 0; i < _SongFolderOld.Count; i++)
|
||||
writer.WriteElementString("SongFolder" + (i + 1).ToString(), _SongFolderOld[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -540,15 +540,15 @@ namespace Vocaluxe.Base
|
||||
/// <returns></returns>
|
||||
public static bool IsMicConfig()
|
||||
{
|
||||
SRecordDevice[] Devices = CSound.RecordGetDevices();
|
||||
if (Devices == null)
|
||||
SRecordDevice[] devices = CSound.RecordGetDevices();
|
||||
if (devices == null)
|
||||
return false;
|
||||
|
||||
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 != 0 || Devices[dev].Inputs[inp].PlayerChannel2 != 0)
|
||||
if (devices[dev].Inputs[inp].PlayerChannel1 != 0 || devices[dev].Inputs[inp].PlayerChannel2 != 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -562,17 +562,17 @@ namespace Vocaluxe.Base
|
||||
/// <returns></returns>
|
||||
public static bool IsMicConfig(int player)
|
||||
{
|
||||
SRecordDevice[] Devices = CSound.RecordGetDevices();
|
||||
if (Devices == null)
|
||||
SRecordDevice[] devices = CSound.RecordGetDevices();
|
||||
if (devices == null)
|
||||
return false;
|
||||
|
||||
if (Devices != null)
|
||||
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)
|
||||
if (devices[dev].Inputs[inp].PlayerChannel1 == player || devices[dev].Inputs[inp].PlayerChannel2 == player)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -588,30 +588,30 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
//Look for (usb-)mic
|
||||
//SRecordDevice[] Devices = new SRecordDevice[CSound.RecordGetDevices().Length];
|
||||
SRecordDevice[] Devices = CSound.RecordGetDevices();
|
||||
if (Devices == null)
|
||||
SRecordDevice[] devices = CSound.RecordGetDevices();
|
||||
if (devices == null)
|
||||
return false;
|
||||
|
||||
for (int dev = 0; dev < Devices.Length; dev++)
|
||||
for (int dev = 0; dev < devices.Length; dev++)
|
||||
{
|
||||
//Has Device some signal-names in name -> This could be a (usb-)mic
|
||||
if (Regex.IsMatch(Devices[dev].Name, @"Usb|Wireless", RegexOptions.IgnoreCase))
|
||||
if (Regex.IsMatch(devices[dev].Name, @"ReplacedStr:::0:::", RegexOptions.IgnoreCase))
|
||||
{
|
||||
//Check if there are inputs.
|
||||
if (Devices[dev].Inputs.Count >= 1)
|
||||
if (devices[dev].Inputs.Count >= 1)
|
||||
{
|
||||
//Check if there is one or more channels
|
||||
if (Devices[dev].Inputs[0].Channels >= 2)
|
||||
if (devices[dev].Inputs[0].Channels >= 2)
|
||||
{
|
||||
//Set this device to player 1
|
||||
MicConfig[0].DeviceName = Devices[dev].Name;
|
||||
MicConfig[0].DeviceDriver = Devices[dev].Driver;
|
||||
MicConfig[0].InputName = Devices[dev].Inputs[0].Name;
|
||||
MicConfig[0].DeviceName = devices[dev].Name;
|
||||
MicConfig[0].DeviceDriver = devices[dev].Driver;
|
||||
MicConfig[0].InputName = devices[dev].Inputs[0].Name;
|
||||
MicConfig[0].Channel = 1;
|
||||
//Set this device to player 2
|
||||
MicConfig[1].DeviceName = Devices[dev].Name;
|
||||
MicConfig[1].DeviceDriver = Devices[dev].Driver;
|
||||
MicConfig[1].InputName = Devices[dev].Inputs[0].Name;
|
||||
MicConfig[1].DeviceName = devices[dev].Name;
|
||||
MicConfig[1].DeviceDriver = devices[dev].Driver;
|
||||
MicConfig[1].InputName = devices[dev].Inputs[0].Name;
|
||||
MicConfig[1].Channel = 2;
|
||||
|
||||
return true;
|
||||
@@ -619,30 +619,30 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
}
|
||||
//If no usb-mics found -> Look for Devices with "mic" or "mik"
|
||||
for (int dev = 0; dev < Devices.Length; dev++)
|
||||
//If no usb-mics found -> Look for Devices with "ReplacedStr:::1:::" or "ReplacedStr:::2:::"
|
||||
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, @"Mic|Mik", RegexOptions.IgnoreCase))
|
||||
if (Regex.IsMatch(devices[dev].Name, @"ReplacedStr:::3:::", RegexOptions.IgnoreCase))
|
||||
{
|
||||
//Check if there are inputs.
|
||||
if (Devices[dev].Inputs.Count >= 1)
|
||||
if (devices[dev].Inputs.Count >= 1)
|
||||
{
|
||||
//Check if there is one or more channels
|
||||
if (Devices[dev].Inputs[0].Channels >= 1)
|
||||
if (devices[dev].Inputs[0].Channels >= 1)
|
||||
{
|
||||
//Set this device to player 1
|
||||
MicConfig[0].DeviceName = Devices[dev].Name;
|
||||
MicConfig[0].DeviceDriver = Devices[dev].Driver;
|
||||
MicConfig[0].InputName = Devices[dev].Inputs[0].Name;
|
||||
MicConfig[0].DeviceName = devices[dev].Name;
|
||||
MicConfig[0].DeviceDriver = devices[dev].Driver;
|
||||
MicConfig[0].InputName = devices[dev].Inputs[0].Name;
|
||||
MicConfig[0].Channel = 1;
|
||||
|
||||
if (Devices[dev].Inputs[0].Channels >= 2)
|
||||
if (devices[dev].Inputs[0].Channels >= 2)
|
||||
{
|
||||
//Set this device to player 2
|
||||
MicConfig[1].DeviceName = Devices[dev].Name;
|
||||
MicConfig[1].DeviceDriver = Devices[dev].Driver;
|
||||
MicConfig[1].InputName = Devices[dev].Inputs[0].Name;
|
||||
MicConfig[1].DeviceName = devices[dev].Name;
|
||||
MicConfig[1].DeviceDriver = devices[dev].Driver;
|
||||
MicConfig[1].InputName = devices[dev].Inputs[0].Name;
|
||||
MicConfig[1].Channel = 2;
|
||||
|
||||
return true;
|
||||
@@ -661,30 +661,30 @@ namespace Vocaluxe.Base
|
||||
/// <param name="args">Parameters</param>
|
||||
public static void LoadCommandLineParams(string[] args)
|
||||
{
|
||||
Regex SpliterParam = new Regex(@"-{1,2}|\/", RegexOptions.IgnoreCase);
|
||||
Regex spliterParam = new Regex(@"ReplacedStr:::0:::", RegexOptions.IgnoreCase);
|
||||
|
||||
//Complete argument string
|
||||
string arguments = string.Empty;
|
||||
foreach (string arg in args)
|
||||
arguments += arg + " ";
|
||||
|
||||
args = SpliterParam.Split(arguments);
|
||||
args = spliterParam.Split(arguments);
|
||||
|
||||
foreach (string text in args)
|
||||
{
|
||||
Regex SpliterVal = new Regex(@"\s", RegexOptions.IgnoreCase);
|
||||
Regex spliterVal = new Regex(@"ReplacedStr:::2:::", RegexOptions.IgnoreCase);
|
||||
|
||||
//Array for parts of an arg
|
||||
string[] parts;
|
||||
|
||||
//split arg with Spilter-Regex and save in parts
|
||||
parts = SpliterVal.Split(text, 2);
|
||||
parts = spliterVal.Split(text, 2);
|
||||
|
||||
switch (parts.Length)
|
||||
{
|
||||
//Only found a parameter
|
||||
case 1:
|
||||
if (!Regex.IsMatch(parts[0], @"\s") && parts[0].Length > 0)
|
||||
if (!Regex.IsMatch(parts[0], @"ReplacedStr:::3:::") && parts[0].Length > 0)
|
||||
{
|
||||
//Add parameter
|
||||
_Params.Add(parts[0]);
|
||||
@@ -697,7 +697,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
//Found parameter and value
|
||||
case 2:
|
||||
if (!Regex.IsMatch(parts[0], @"\s") && parts[0].Length > 0)
|
||||
if (!Regex.IsMatch(parts[0], @"ReplacedStr:::5:::") && parts[0].Length > 0)
|
||||
{
|
||||
//Add parameter
|
||||
_Params.Add(parts[0]);
|
||||
@@ -729,24 +729,24 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
case "configfile":
|
||||
//Check if value is valid
|
||||
if (CheckFile(value))
|
||||
CSettings.sFileConfig = value;
|
||||
if (_CheckFile(value))
|
||||
CSettings.FileConfig = value;
|
||||
break;
|
||||
|
||||
case "scorefile":
|
||||
//Check if value is valid
|
||||
if (CheckFile(value))
|
||||
CSettings.sFileHighscoreDB = value;
|
||||
if (_CheckFile(value))
|
||||
CSettings.FileHighscoreDB = value;
|
||||
break;
|
||||
|
||||
case "playlistfolder":
|
||||
CSettings.CreateFolder(value);
|
||||
CSettings.sFolderPlaylists = value;
|
||||
CSettings.FolderPlaylists = value;
|
||||
break;
|
||||
|
||||
case "profilefolder":
|
||||
CSettings.CreateFolder(value);
|
||||
CSettings.sFolderProfiles = value;
|
||||
CSettings.FolderProfiles = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -772,10 +772,10 @@ namespace Vocaluxe.Base
|
||||
case "songfolder":
|
||||
case "songpath":
|
||||
//Check if SongFolders from config.xml are saved
|
||||
if (SongFolderOld.Count == 0)
|
||||
if (_SongFolderOld.Count == 0)
|
||||
{
|
||||
SongFolderOld.Clear();
|
||||
SongFolderOld.AddRange(SongFolder);
|
||||
_SongFolderOld.Clear();
|
||||
_SongFolderOld.AddRange(SongFolder);
|
||||
SongFolder.Clear();
|
||||
}
|
||||
//Add parameter-value to SongFolder
|
||||
@@ -785,7 +785,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckFile(string value)
|
||||
private static bool _CheckFile(string value)
|
||||
{
|
||||
char[] chars = Path.GetInvalidPathChars();
|
||||
for (int i = 0; i < chars.Length; i++)
|
||||
|
||||
+27
-27
@@ -23,7 +23,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
abstract class CCover
|
||||
{
|
||||
private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
private static readonly List<SCover> _Cover = new List<SCover>();
|
||||
private static readonly List<SCoverTheme> _CoverThemes = new List<SCoverTheme>();
|
||||
private static STexture _NoCover = new STexture(-1);
|
||||
@@ -37,12 +37,12 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_settings.Indent = true;
|
||||
_settings.Encoding = Encoding.UTF8;
|
||||
_settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
_Settings.Indent = true;
|
||||
_Settings.Encoding = Encoding.UTF8;
|
||||
_Settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
|
||||
LoadCoverThemes();
|
||||
LoadCover(CConfig.CoverTheme);
|
||||
_LoadCoverThemes();
|
||||
_LoadCover(CConfig.CoverTheme);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -52,11 +52,11 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> CoverThemes = new List<string>();
|
||||
List<string> coverThemes = new List<string>();
|
||||
for (int i = 0; i < _CoverThemes.Count; i++)
|
||||
CoverThemes.Add(_CoverThemes[i].Name);
|
||||
coverThemes.Add(_CoverThemes[i].Name);
|
||||
|
||||
return CoverThemes.ToArray();
|
||||
return coverThemes.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,14 +77,14 @@ namespace Vocaluxe.Base
|
||||
/// <summary>
|
||||
/// Returns a STexture for a given cover name. Returns "NoCover" if the cover does not exist.
|
||||
/// </summary>
|
||||
public static STexture Cover(string Name)
|
||||
public static STexture Cover(string name)
|
||||
{
|
||||
STexture cov = _NoCover;
|
||||
lock (_MutexCover)
|
||||
{
|
||||
foreach (SCover cover in _Cover)
|
||||
{
|
||||
if (cover.Name == Name)
|
||||
if (cover.Name == name)
|
||||
{
|
||||
cov = cover.Texture;
|
||||
break;
|
||||
@@ -97,14 +97,14 @@ namespace Vocaluxe.Base
|
||||
/// <summary>
|
||||
/// Returns true if a cover with the given name exists.
|
||||
/// </summary>
|
||||
public static bool CoverExists(string Name)
|
||||
public static bool CoverExists(string name)
|
||||
{
|
||||
STexture cov = _NoCover;
|
||||
lock (_MutexCover)
|
||||
{
|
||||
foreach (SCover cover in _Cover)
|
||||
{
|
||||
if (cover.Name == Name)
|
||||
if (cover.Name == name)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -122,13 +122,13 @@ namespace Vocaluxe.Base
|
||||
CDraw.RemoveTexture(ref texture);
|
||||
}
|
||||
_Cover.Clear();
|
||||
LoadCover(CConfig.CoverTheme);
|
||||
_LoadCover(CConfig.CoverTheme);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a SCoverTheme by cover-theme-name
|
||||
/// </summary>
|
||||
private static SCoverTheme CoverTheme(string coverThemeName)
|
||||
private static SCoverTheme _CoverTheme(string coverThemeName)
|
||||
{
|
||||
SCoverTheme coverTheme = new SCoverTheme();
|
||||
for (int i = 0; i < _CoverThemes.Count; i++)
|
||||
@@ -145,11 +145,11 @@ namespace Vocaluxe.Base
|
||||
/// <summary>
|
||||
/// Loads all cover-themes to list.
|
||||
/// </summary>
|
||||
private static void LoadCoverThemes()
|
||||
private static void _LoadCoverThemes()
|
||||
{
|
||||
_CoverThemes.Clear();
|
||||
|
||||
string path = CSettings.sFolderCover;
|
||||
string path = CSettings.FolderCover;
|
||||
List<string> files = CHelper.ListFiles(path, "*.xml", false);
|
||||
|
||||
foreach (string file in files)
|
||||
@@ -176,15 +176,15 @@ namespace Vocaluxe.Base
|
||||
/// <summary>
|
||||
/// Loads all cover which are defined in the cover config file.
|
||||
/// </summary>
|
||||
private static void LoadCover(string coverThemeName)
|
||||
private static void _LoadCover(string coverThemeName)
|
||||
{
|
||||
SCoverTheme coverTheme = new SCoverTheme();
|
||||
|
||||
coverTheme = CoverTheme(coverThemeName);
|
||||
coverTheme = _CoverTheme(coverThemeName);
|
||||
|
||||
if (coverTheme.Name.Length > 0)
|
||||
{
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.sFolderCover, coverTheme.File));
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderCover, coverTheme.File));
|
||||
|
||||
if (xmlReader != null)
|
||||
{
|
||||
@@ -201,8 +201,8 @@ namespace Vocaluxe.Base
|
||||
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.sFolderCover, Path.Combine(coverTheme.Folder, value))))
|
||||
sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, 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;
|
||||
|
||||
@@ -216,10 +216,10 @@ namespace Vocaluxe.Base
|
||||
|
||||
List<string> files = new List<string>();
|
||||
|
||||
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.png", true, true));
|
||||
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.jpg", true, true));
|
||||
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.jpeg", true, true));
|
||||
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.bmp", true, true));
|
||||
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)
|
||||
@@ -235,7 +235,7 @@ namespace Vocaluxe.Base
|
||||
sk.Name = name;
|
||||
sk.Value = Path.Combine(coverTheme.Folder, Path.GetFileName(file));
|
||||
|
||||
sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, sk.Value));
|
||||
sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.FolderCover, sk.Value));
|
||||
|
||||
_Cover.Add(sk);
|
||||
}
|
||||
|
||||
+238
-238
File diff suppressed because it is too large.
Load diff
+58
-58
@@ -45,7 +45,7 @@ namespace Vocaluxe.Base
|
||||
MessageBox.Show(e.Message + " - Error in initializing of Direct3D. Please check if " +
|
||||
"your DirectX redistributables and graphic card drivers are up to date. You can " +
|
||||
"download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109",
|
||||
CSettings.sProgramName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
CSettings.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
CLog.LogError(e.Message + " - Error in initializing of Direct3D. Please check if " +
|
||||
"your DirectX redistributables and graphic card drivers are up to date. You can " +
|
||||
"download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109");
|
||||
@@ -89,9 +89,9 @@ namespace Vocaluxe.Base
|
||||
return _Draw.GetTextBounds(text);
|
||||
}
|
||||
|
||||
public static RectangleF GetTextBounds(CText text, float Height)
|
||||
public static RectangleF GetTextBounds(CText text, float height)
|
||||
{
|
||||
return _Draw.GetTextBounds(text, Height);
|
||||
return _Draw.GetTextBounds(text, height);
|
||||
}
|
||||
|
||||
public static void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2)
|
||||
@@ -99,15 +99,15 @@ namespace Vocaluxe.Base
|
||||
_Draw.DrawLine(a, r, g, b, w, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
public static void DrawRect(SColorF Color, SRectF Rect, float Thickness)
|
||||
public static void DrawRect(SColorF color, SRectF rect, float thickness)
|
||||
{
|
||||
if (Thickness <= 0f)
|
||||
if (thickness <= 0f)
|
||||
return;
|
||||
|
||||
_Draw.DrawColor(Color, new SRectF(Rect.X - Thickness / 2, Rect.Y - Thickness / 2, Rect.W + Thickness, Thickness, Rect.Z));
|
||||
_Draw.DrawColor(Color, new SRectF(Rect.X - Thickness / 2, Rect.Y + Rect.H - Thickness / 2, Rect.W + Thickness, Thickness, Rect.Z));
|
||||
_Draw.DrawColor(Color, new SRectF(Rect.X - Thickness / 2, Rect.Y - Thickness / 2, Thickness, Rect.H + Thickness, Rect.Z));
|
||||
_Draw.DrawColor(Color, new SRectF(Rect.X + Rect.W - Thickness / 2, Rect.Y - Thickness / 2, Thickness, Rect.H + Thickness, Rect.Z));
|
||||
_Draw.DrawColor(color, new SRectF(rect.X - thickness / 2, rect.Y - thickness / 2, rect.W + thickness, thickness, rect.Z));
|
||||
_Draw.DrawColor(color, new SRectF(rect.X - thickness / 2, rect.Y + rect.H - thickness / 2, rect.W + thickness, thickness, rect.Z));
|
||||
_Draw.DrawColor(color, new SRectF(rect.X - thickness / 2, rect.Y - thickness / 2, thickness, rect.H + thickness, rect.Z));
|
||||
_Draw.DrawColor(color, new SRectF(rect.X + rect.W - thickness / 2, rect.Y - thickness / 2, thickness, rect.H + thickness, rect.Z));
|
||||
}
|
||||
|
||||
public static void DrawColor(SColorF color, SRectF rect)
|
||||
@@ -130,9 +130,9 @@ namespace Vocaluxe.Base
|
||||
return _Draw.CopyScreen();
|
||||
}
|
||||
|
||||
public static void CopyScreen(ref STexture Texture)
|
||||
public static void CopyScreen(ref STexture texture)
|
||||
{
|
||||
_Draw.CopyScreen(ref Texture);
|
||||
_Draw.CopyScreen(ref texture);
|
||||
}
|
||||
|
||||
public static void MakeScreenShot()
|
||||
@@ -141,33 +141,33 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
// Draw Basic Text (must be deleted later)
|
||||
public static void DrawText(string Text, int x, int y, int h)
|
||||
public static void DrawText(string text, int x, int y, int h)
|
||||
{
|
||||
_Draw.DrawText(Text, x, y, h);
|
||||
_Draw.DrawText(text, x, y, h);
|
||||
}
|
||||
|
||||
public static STexture AddTexture(Bitmap Bitmap)
|
||||
public static STexture AddTexture(Bitmap bitmap)
|
||||
{
|
||||
return _Draw.AddTexture(Bitmap);
|
||||
return _Draw.AddTexture(bitmap);
|
||||
}
|
||||
|
||||
public static STexture AddTexture(string TexturePath)
|
||||
public static STexture AddTexture(string texturePath)
|
||||
{
|
||||
return _Draw.AddTexture(TexturePath);
|
||||
return _Draw.AddTexture(texturePath);
|
||||
}
|
||||
|
||||
public static STexture AddTexture(string TexturePath, int MaxSize)
|
||||
public static STexture AddTexture(string texturePath, int maxSize)
|
||||
{
|
||||
if (MaxSize == 0)
|
||||
return _Draw.AddTexture(TexturePath);
|
||||
if (maxSize == 0)
|
||||
return _Draw.AddTexture(texturePath);
|
||||
|
||||
if (!File.Exists(TexturePath))
|
||||
if (!File.Exists(texturePath))
|
||||
return new STexture(-1);
|
||||
|
||||
using (Bitmap origin = new Bitmap(TexturePath))
|
||||
using (Bitmap origin = new Bitmap(texturePath))
|
||||
{
|
||||
int w = MaxSize;
|
||||
int h = MaxSize;
|
||||
int w = maxSize;
|
||||
int h = maxSize;
|
||||
|
||||
if (origin.Width >= origin.Height && origin.Width > w)
|
||||
h = (int)Math.Round((float)w / origin.Width * origin.Height);
|
||||
@@ -182,87 +182,87 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
public static STexture AddTexture(int W, int H, IntPtr Data)
|
||||
public static STexture AddTexture(int w, int h, IntPtr data)
|
||||
{
|
||||
return _Draw.AddTexture(W, H, Data);
|
||||
return _Draw.AddTexture(w, h, data);
|
||||
}
|
||||
|
||||
public static STexture AddTexture(int W, int H, ref byte[] Data)
|
||||
public static STexture AddTexture(int w, int h, ref byte[] data)
|
||||
{
|
||||
return _Draw.AddTexture(W, H, ref Data);
|
||||
return _Draw.AddTexture(w, h, ref data);
|
||||
}
|
||||
|
||||
public static STexture QuequeTexture(int W, int H, ref byte[] Data)
|
||||
public static STexture QuequeTexture(int w, int h, ref byte[] data)
|
||||
{
|
||||
return _Draw.QuequeTexture(W, H, ref Data);
|
||||
return _Draw.QuequeTexture(w, h, ref data);
|
||||
}
|
||||
|
||||
public static bool UpdateTexture(ref STexture Texture, ref byte[] Data)
|
||||
public static bool UpdateTexture(ref STexture texture, ref byte[] data)
|
||||
{
|
||||
return _Draw.UpdateTexture(ref Texture, ref Data);
|
||||
return _Draw.UpdateTexture(ref texture, ref data);
|
||||
}
|
||||
|
||||
public static bool UpdateTexture(ref STexture Texture, IntPtr Data)
|
||||
public static bool UpdateTexture(ref STexture texture, IntPtr data)
|
||||
{
|
||||
return _Draw.UpdateTexture(ref Texture, Data);
|
||||
return _Draw.UpdateTexture(ref texture, data);
|
||||
}
|
||||
|
||||
public static void RemoveTexture(ref STexture Texture)
|
||||
public static void RemoveTexture(ref STexture texture)
|
||||
{
|
||||
_Draw.RemoveTexture(ref Texture);
|
||||
_Draw.RemoveTexture(ref texture);
|
||||
}
|
||||
|
||||
public static void DrawTexture(STexture Texture)
|
||||
public static void DrawTexture(STexture texture)
|
||||
{
|
||||
_Draw.DrawTexture(Texture);
|
||||
_Draw.DrawTexture(texture);
|
||||
}
|
||||
|
||||
public static void DrawTexture(STexture Texture, SRectF rect)
|
||||
public static void DrawTexture(STexture texture, SRectF rect)
|
||||
{
|
||||
_Draw.DrawTexture(Texture, rect);
|
||||
_Draw.DrawTexture(texture, rect);
|
||||
}
|
||||
|
||||
public static void DrawTexture(STexture Texture, SRectF rect, SColorF color)
|
||||
public static void DrawTexture(STexture texture, SRectF rect, SColorF color)
|
||||
{
|
||||
_Draw.DrawTexture(Texture, rect, color);
|
||||
_Draw.DrawTexture(texture, rect, color);
|
||||
}
|
||||
|
||||
public static void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds)
|
||||
public static void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds)
|
||||
{
|
||||
_Draw.DrawTexture(Texture, rect, color, bounds);
|
||||
_Draw.DrawTexture(texture, rect, color, bounds);
|
||||
}
|
||||
|
||||
public static void DrawTexture(STexture Texture, SRectF rect, SColorF color, bool mirrored)
|
||||
public static void DrawTexture(STexture texture, SRectF rect, SColorF color, bool mirrored)
|
||||
{
|
||||
_Draw.DrawTexture(Texture, rect, color, mirrored);
|
||||
_Draw.DrawTexture(texture, rect, color, mirrored);
|
||||
}
|
||||
|
||||
public static void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored)
|
||||
public static void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored)
|
||||
{
|
||||
_Draw.DrawTexture(Texture, rect, color, bounds, mirrored);
|
||||
_Draw.DrawTexture(texture, rect, color, bounds, mirrored);
|
||||
}
|
||||
|
||||
public static void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end)
|
||||
public static void DrawTexture(STexture texture, SRectF rect, SColorF color, float begin, float end)
|
||||
{
|
||||
_Draw.DrawTexture(Texture, rect, color, begin, end);
|
||||
_Draw.DrawTexture(texture, rect, color, begin, end);
|
||||
}
|
||||
|
||||
public static void DrawTexture(CStatic StaticBounds, STexture Texture, EAspect Aspect)
|
||||
public static void DrawTexture(CStatic staticBounds, STexture texture, EAspect aspect)
|
||||
{
|
||||
RectangleF bounds = new RectangleF(StaticBounds.Rect.X, StaticBounds.Rect.Y, StaticBounds.Rect.W, StaticBounds.Rect.H);
|
||||
RectangleF rect = new RectangleF(0f, 0f, Texture.width, Texture.height);
|
||||
RectangleF bounds = new RectangleF(staticBounds.Rect.X, staticBounds.Rect.Y, staticBounds.Rect.W, staticBounds.Rect.H);
|
||||
RectangleF rect = new RectangleF(0f, 0f, texture.Width, texture.Height);
|
||||
|
||||
if (rect.Height <= 0f)
|
||||
return;
|
||||
|
||||
CHelper.SetRect(bounds, ref 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);
|
||||
CHelper.SetRect(bounds, ref 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);
|
||||
}
|
||||
|
||||
public static void DrawTextureReflection(STexture Texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
|
||||
public static void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
|
||||
{
|
||||
_Draw.DrawTextureReflection(Texture, rect, color, bounds, space, height);
|
||||
_Draw.DrawTextureReflection(texture, rect, color, bounds, space, height);
|
||||
}
|
||||
|
||||
public static int TextureCount()
|
||||
|
||||
+148
-148
@@ -13,25 +13,25 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
class CGlyph
|
||||
{
|
||||
private readonly float _SIZEh = 50f;
|
||||
public float SIZEh
|
||||
private readonly float _Sizeh = 50f;
|
||||
public float Sizeh
|
||||
{
|
||||
get { return _SIZEh; }
|
||||
get { return _Sizeh; }
|
||||
}
|
||||
|
||||
public STexture Texture;
|
||||
public char Chr;
|
||||
public int width;
|
||||
public int Width;
|
||||
|
||||
public CGlyph(char chr, float MaxHigh)
|
||||
public CGlyph(char chr, float maxHigh)
|
||||
{
|
||||
_SIZEh = MaxHigh;
|
||||
_Sizeh = maxHigh;
|
||||
|
||||
float outline = CFonts.Outline;
|
||||
TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix;
|
||||
|
||||
float factor = GetFactor(chr, flags);
|
||||
CFonts.Height = SIZEh * factor;
|
||||
float factor = _GetFactor(chr, flags);
|
||||
CFonts.Height = Sizeh * factor;
|
||||
Font fo;
|
||||
Size sizeB;
|
||||
SizeF size;
|
||||
@@ -51,12 +51,12 @@ namespace Vocaluxe.Base
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
|
||||
CFonts.Height = SIZEh;
|
||||
CFonts.Height = Sizeh;
|
||||
fo = CFonts.GetFont();
|
||||
|
||||
PointF point = new PointF(
|
||||
outline * Math.Abs(sizeB.Width - size.Width) + (sizeB.Width - size.Width) / 2f + SIZEh / 5f,
|
||||
(sizeB.Height - size.Height - (size.Height + SIZEh / 4f) * (1f - factor)) / 2f);
|
||||
outline * Math.Abs(sizeB.Width - size.Width) + (sizeB.Width - size.Width) / 2f + Sizeh / 5f,
|
||||
(sizeB.Height - size.Height - (size.Height + Sizeh / 4f) * (1f - factor)) / 2f);
|
||||
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
@@ -64,7 +64,7 @@ namespace Vocaluxe.Base
|
||||
chr.ToString(),
|
||||
fo.FontFamily,
|
||||
(int)fo.Style,
|
||||
SIZEh,
|
||||
Sizeh,
|
||||
point,
|
||||
new StringFormat());
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Vocaluxe.Base
|
||||
(int)CFonts.OutlineColor.R * 255,
|
||||
(int)CFonts.OutlineColor.G * 255,
|
||||
(int)CFonts.OutlineColor.B * 255),
|
||||
SIZEh * outline))
|
||||
Sizeh * outline))
|
||||
{
|
||||
pen.LineJoin = LineJoin.Round;
|
||||
g.DrawPath(pen, path);
|
||||
@@ -92,7 +92,7 @@ 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);
|
||||
Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width);
|
||||
g.Dispose();
|
||||
}
|
||||
fo.Dispose();
|
||||
@@ -103,7 +103,7 @@ namespace Vocaluxe.Base
|
||||
CDraw.RemoveTexture(ref Texture);
|
||||
}
|
||||
|
||||
private float GetFactor(char chr, TextFormatFlags flags)
|
||||
private float _GetFactor(char chr, TextFormatFlags flags)
|
||||
{
|
||||
if (CFonts.Style == EStyle.Normal)
|
||||
return 1f;
|
||||
@@ -111,14 +111,14 @@ namespace Vocaluxe.Base
|
||||
EStyle style = CFonts.Style;
|
||||
|
||||
CFonts.Style = EStyle.Normal;
|
||||
CFonts.Height = SIZEh;
|
||||
float h_style, h_normal;
|
||||
CFonts.Height = Sizeh;
|
||||
float hStyle, hNormal;
|
||||
using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
|
||||
{
|
||||
Font fo = CFonts.GetFont();
|
||||
Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
|
||||
//SizeF size = g.MeasureString(chr.ToString(), fo);
|
||||
h_normal = sizeB.Height;
|
||||
hNormal = sizeB.Height;
|
||||
}
|
||||
CFonts.Style = style;
|
||||
using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
|
||||
@@ -126,59 +126,59 @@ namespace Vocaluxe.Base
|
||||
Font fo = CFonts.GetFont();
|
||||
Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
|
||||
//size = g.MeasureString(chr.ToString(), fo);
|
||||
h_style = sizeB.Height;
|
||||
hStyle = sizeB.Height;
|
||||
}
|
||||
return h_normal / h_style;
|
||||
return hNormal / hStyle;
|
||||
}
|
||||
}
|
||||
|
||||
class CFont : IDisposable
|
||||
{
|
||||
private readonly Dictionary<char, CGlyph> _Glyphs;
|
||||
private PrivateFontCollection fonts;
|
||||
private FontFamily family;
|
||||
private readonly float SIZEh;
|
||||
private PrivateFontCollection _Fonts;
|
||||
private FontFamily _Family;
|
||||
private readonly float _Sizeh;
|
||||
|
||||
public string FilePath;
|
||||
|
||||
public CFont(string File)
|
||||
public CFont(string file)
|
||||
{
|
||||
FilePath = File;
|
||||
FilePath = file;
|
||||
|
||||
_Glyphs = new Dictionary<char, CGlyph>();
|
||||
|
||||
switch (CConfig.TextureQuality)
|
||||
{
|
||||
case ETextureQuality.TR_CONFIG_TEXTURE_LOWEST:
|
||||
SIZEh = 25f;
|
||||
_Sizeh = 25f;
|
||||
break;
|
||||
case ETextureQuality.TR_CONFIG_TEXTURE_LOW:
|
||||
SIZEh = 50f;
|
||||
_Sizeh = 50f;
|
||||
break;
|
||||
case ETextureQuality.TR_CONFIG_TEXTURE_MEDIUM:
|
||||
SIZEh = 100f;
|
||||
_Sizeh = 100f;
|
||||
break;
|
||||
case ETextureQuality.TR_CONFIG_TEXTURE_HIGH:
|
||||
SIZEh = 200f;
|
||||
_Sizeh = 200f;
|
||||
break;
|
||||
case ETextureQuality.TR_CONFIG_TEXTURE_HIGHEST:
|
||||
SIZEh = 400f;
|
||||
_Sizeh = 400f;
|
||||
break;
|
||||
default:
|
||||
SIZEh = 100f;
|
||||
_Sizeh = 100f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public Font GetFont()
|
||||
{
|
||||
if (fonts == null)
|
||||
if (_Fonts == null)
|
||||
{
|
||||
fonts = new PrivateFontCollection();
|
||||
_Fonts = new PrivateFontCollection();
|
||||
try
|
||||
{
|
||||
fonts.AddFontFile(FilePath);
|
||||
family = fonts.Families[0];
|
||||
_Fonts.AddFontFile(FilePath);
|
||||
_Family = _Fonts.Families[0];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -186,7 +186,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
return new Font(family, CFonts.Height, CFonts.GetFontStyle(), GraphicsUnit.Pixel);
|
||||
return new Font(_Family, CFonts.Height, CFonts.GetFontStyle(), GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
public void DrawGlyph(char chr, float x, float y, float h, float z, SColorF color)
|
||||
@@ -220,9 +220,9 @@ namespace Vocaluxe.Base
|
||||
CFonts.Height = h;
|
||||
CGlyph glyph = _Glyphs[chr];
|
||||
texture = glyph.Texture;
|
||||
float factor = h / texture.height;
|
||||
float width = texture.width * factor;
|
||||
float d = glyph.SIZEh / 5f * factor;
|
||||
float factor = h / texture.Height;
|
||||
float width = texture.Width * factor;
|
||||
float d = glyph.Sizeh / 5f * factor;
|
||||
rect = new SRectF(x - d, y, width, h, z);
|
||||
}
|
||||
|
||||
@@ -231,8 +231,8 @@ namespace Vocaluxe.Base
|
||||
AddGlyph(chr);
|
||||
|
||||
CGlyph glyph = _Glyphs[chr];
|
||||
float factor = CFonts.Height / glyph.Texture.height;
|
||||
return glyph.width * factor;
|
||||
float factor = CFonts.Height / glyph.Texture.Height;
|
||||
return glyph.Width * factor;
|
||||
}
|
||||
|
||||
public float GetHeight(char chr)
|
||||
@@ -252,7 +252,7 @@ namespace Vocaluxe.Base
|
||||
return;
|
||||
|
||||
float h = CFonts.Height;
|
||||
_Glyphs.Add(chr, new CGlyph(chr, SIZEh));
|
||||
_Glyphs.Add(chr, new CGlyph(chr, _Sizeh));
|
||||
CFonts.Height = h;
|
||||
}
|
||||
|
||||
@@ -265,10 +265,10 @@ namespace Vocaluxe.Base
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (fonts != null)
|
||||
if (_Fonts != null)
|
||||
{
|
||||
fonts.Dispose();
|
||||
fonts = null;
|
||||
_Fonts.Dispose();
|
||||
_Fonts = null;
|
||||
UnloadAllGlyphs();
|
||||
}
|
||||
GC.SuppressFinalize(this);
|
||||
@@ -300,7 +300,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
static class CFonts
|
||||
{
|
||||
private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
|
||||
private static List<SFont> _Fonts;
|
||||
private static int _CurrentFont;
|
||||
@@ -357,9 +357,9 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_settings.Indent = true;
|
||||
_settings.Encoding = Encoding.UTF8;
|
||||
_settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
_Settings.Indent = true;
|
||||
_Settings.Encoding = Encoding.UTF8;
|
||||
_Settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
|
||||
_CurrentFont = 0;
|
||||
PartyModeID = -1;
|
||||
@@ -371,7 +371,7 @@ namespace Vocaluxe.Base
|
||||
_Fonts = new List<SFont>();
|
||||
_CurrentFont = 0;
|
||||
|
||||
LoadFontList();
|
||||
_LoadFontList();
|
||||
}
|
||||
|
||||
public static Font GetFont()
|
||||
@@ -397,77 +397,77 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
#region DrawText
|
||||
public static void DrawText(string Text, int x, int y, int h)
|
||||
public static void DrawText(string text, int x, int y, int h)
|
||||
{
|
||||
DrawText(Text, h, x, y, 0f, new SColorF(0f, 0f, 0f, 1f));
|
||||
DrawText(text, h, x, y, 0f, new SColorF(0f, 0f, 0f, 1f));
|
||||
}
|
||||
|
||||
public static void DrawText(string Text, float x, float y, float z)
|
||||
public static void DrawText(string text, float x, float y, float z)
|
||||
{
|
||||
DrawText(Text, Height, x, y, z, new SColorF(0f, 0f, 0f, 1f));
|
||||
DrawText(text, Height, x, y, z, new SColorF(0f, 0f, 0f, 1f));
|
||||
}
|
||||
|
||||
public static void DrawText(string Text, float h, float x, float y, float z, SColorF color)
|
||||
public static void DrawText(string text, float h, float x, float y, float z, SColorF color)
|
||||
{
|
||||
if (h <= 0f)
|
||||
return;
|
||||
|
||||
if (Text.Length == 0)
|
||||
if (text.Length == 0)
|
||||
return;
|
||||
|
||||
Height = h;
|
||||
CFont Font = _GetCurrentFont();
|
||||
CFont font = _GetCurrentFont();
|
||||
|
||||
float dx = x;
|
||||
foreach (char chr in Text)
|
||||
foreach (char chr in text)
|
||||
{
|
||||
Font.DrawGlyph(chr, dx, y, Height, z, color);
|
||||
dx += Font.GetWidth(chr);
|
||||
font.DrawGlyph(chr, dx, y, Height, z, color);
|
||||
dx += font.GetWidth(chr);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawTextReflection(string Text, float h, float x, float y, float z, SColorF color, float rspace, float rheight)
|
||||
public static void DrawTextReflection(string text, float h, float x, float y, float z, SColorF color, float rspace, float rheight)
|
||||
{
|
||||
if (h <= 0f)
|
||||
return;
|
||||
|
||||
if (Text.Length == 0)
|
||||
if (text.Length == 0)
|
||||
return;
|
||||
|
||||
Height = h;
|
||||
CFont Font = _GetCurrentFont();
|
||||
CFont font = _GetCurrentFont();
|
||||
|
||||
float dx = x;
|
||||
foreach (char chr in Text)
|
||||
foreach (char chr in text)
|
||||
{
|
||||
Font.DrawGlyphReflection(chr, dx, y, Height, z, color, rspace, rheight);
|
||||
dx += Font.GetWidth(chr);
|
||||
font.DrawGlyphReflection(chr, dx, y, Height, z, color, rspace, rheight);
|
||||
dx += font.GetWidth(chr);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawText(string Text, float h, float x, float y, float z, SColorF color, float begin, float end)
|
||||
public static void DrawText(string text, float h, float x, float y, float z, SColorF color, float begin, float end)
|
||||
{
|
||||
if (h <= 0f)
|
||||
return;
|
||||
|
||||
if (Text.Length == 0)
|
||||
if (text.Length == 0)
|
||||
return;
|
||||
|
||||
Height = h;
|
||||
|
||||
float dx = x;
|
||||
float w = GetTextWidth(Text);
|
||||
float w = GetTextWidth(text);
|
||||
if (w <= 0f)
|
||||
return;
|
||||
|
||||
float x1 = x + w * begin;
|
||||
float x2 = x + w * end;
|
||||
|
||||
CFont Font = _GetCurrentFont();
|
||||
CFont font = _GetCurrentFont();
|
||||
|
||||
foreach (char chr in Text)
|
||||
foreach (char chr in text)
|
||||
{
|
||||
float w2 = Font.GetWidth(chr);
|
||||
float w2 = font.GetWidth(chr);
|
||||
float b = (x1 - dx) / w2;
|
||||
|
||||
if (b < 1f)
|
||||
@@ -479,7 +479,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
if (e > 1f)
|
||||
e = 1f;
|
||||
Font.DrawGlyph(chr, dx, y, Height, z, color, b, e);
|
||||
font.DrawGlyph(chr, dx, y, Height, z, color, b, e);
|
||||
}
|
||||
}
|
||||
dx += w2;
|
||||
@@ -504,32 +504,32 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetFont(string FontName)
|
||||
public static void SetFont(string fontName)
|
||||
{
|
||||
int Index = -1;
|
||||
int index = -1;
|
||||
|
||||
if (PartyModeID != -1)
|
||||
{
|
||||
Index = GetFontIndexParty(PartyModeID, FontName);
|
||||
index = _GetFontIndexParty(PartyModeID, fontName);
|
||||
|
||||
if (Index >= 0 && Index < _Fonts.Count)
|
||||
if (index >= 0 && index < _Fonts.Count)
|
||||
{
|
||||
_CurrentFont = Index;
|
||||
_CurrentFont = index;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Index = GetFontIndex(CConfig.Theme, FontName);
|
||||
index = _GetFontIndex(CConfig.Theme, fontName);
|
||||
|
||||
if (Index >= 0 && Index < _Fonts.Count)
|
||||
if (index >= 0 && index < _Fonts.Count)
|
||||
{
|
||||
_CurrentFont = Index;
|
||||
_CurrentFont = index;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _Fonts.Count; i++)
|
||||
{
|
||||
if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == FontName)
|
||||
if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == fontName)
|
||||
{
|
||||
_CurrentFont = i;
|
||||
return;
|
||||
@@ -552,9 +552,9 @@ namespace Vocaluxe.Base
|
||||
public static float GetTextWidth(string text)
|
||||
{
|
||||
float dx = 0;
|
||||
CFont Font = _GetCurrentFont();
|
||||
CFont font = _GetCurrentFont();
|
||||
foreach (char chr in text)
|
||||
dx += Font.GetWidth(chr);
|
||||
dx += font.GetWidth(chr);
|
||||
return dx;
|
||||
}
|
||||
|
||||
@@ -562,17 +562,17 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
//return TextRenderer.MeasureText(text, GetFont()).Height;
|
||||
float h = 0f;
|
||||
CFont Font = _GetCurrentFont();
|
||||
CFont font = _GetCurrentFont();
|
||||
foreach (char chr in text)
|
||||
{
|
||||
float hh = Font.GetHeight(chr);
|
||||
float hh = font.GetHeight(chr);
|
||||
if (hh > h)
|
||||
h = hh;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
private static void _LoadFontFiles(CXMLReader xmlReader, string FontFolder, string ThemeName = "", int PartyModeId = -1)
|
||||
private static void _LoadFontFiles(CXMLReader xmlReader, string fontFolder, string themeName = "", int partyModeId = -1)
|
||||
{
|
||||
string value = string.Empty;
|
||||
int i = 1;
|
||||
@@ -580,9 +580,9 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
SFont sf = new SFont();
|
||||
sf.Folder = value;
|
||||
sf.IsThemeFont = ThemeName.Length > 0;
|
||||
sf.ThemeName = ThemeName;
|
||||
sf.PartyModeID = PartyModeId;
|
||||
sf.IsThemeFont = themeName.Length > 0;
|
||||
sf.ThemeName = themeName;
|
||||
sf.PartyModeID = partyModeId;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
@@ -592,25 +592,25 @@ namespace Vocaluxe.Base
|
||||
|
||||
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileNormal", ref value, value);
|
||||
sf.FileNormal = value;
|
||||
value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
|
||||
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
|
||||
CFont f = new CFont(value);
|
||||
sf.Normal = f;
|
||||
|
||||
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileItalic", ref value, value);
|
||||
sf.FileItalic = value;
|
||||
value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
|
||||
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
|
||||
f = new CFont(value);
|
||||
sf.Italic = f;
|
||||
|
||||
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileBold", ref value, value);
|
||||
sf.FileBold = value;
|
||||
value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
|
||||
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
|
||||
f = new CFont(value);
|
||||
sf.Bold = f;
|
||||
|
||||
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileBoldItalic", ref value, value);
|
||||
sf.FileBoldItalic = value;
|
||||
value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
|
||||
value = Path.Combine(fontFolder, Path.Combine(sf.Folder, value));
|
||||
f = new CFont(value);
|
||||
sf.BoldItalic = f;
|
||||
|
||||
@@ -628,10 +628,10 @@ namespace Vocaluxe.Base
|
||||
else
|
||||
{
|
||||
string fontTypes;
|
||||
if (PartyModeId >= 0)
|
||||
if (partyModeId >= 0)
|
||||
fontTypes = "theme fonts for party mode";
|
||||
else if (ThemeName.Length > 0)
|
||||
fontTypes = "theme fonts for theme \"" + ThemeName + "\"";
|
||||
else if (themeName.Length > 0)
|
||||
fontTypes = "theme fonts for theme \"" + themeName + "\"";
|
||||
else
|
||||
fontTypes = "basic fonts";
|
||||
CLog.LogError("Error loading " + fontTypes + ": Error in Font" + i.ToString());
|
||||
@@ -644,143 +644,143 @@ namespace Vocaluxe.Base
|
||||
/// Load default fonts
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static bool LoadFontList()
|
||||
private static bool _LoadFontList()
|
||||
{
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.sFolderFonts, CSettings.sFileFonts));
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderFonts, CSettings.FileFonts));
|
||||
if (xmlReader == null)
|
||||
return false;
|
||||
|
||||
_Fonts.Clear();
|
||||
|
||||
_LoadFontFiles(xmlReader, Path.Combine(Directory.GetCurrentDirectory(), CSettings.sFolderFonts));
|
||||
_LoadFontFiles(xmlReader, Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderFonts));
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads theme fonts from skin file
|
||||
/// </summary>
|
||||
public static void LoadThemeFonts(string ThemeName, string FontFolder, CXMLReader xmlReader)
|
||||
public static void LoadThemeFonts(string themeName, string fontFolder, CXMLReader xmlReader)
|
||||
{
|
||||
_LoadFontFiles(xmlReader, FontFolder, ThemeName);
|
||||
_LoadFontFiles(xmlReader, fontFolder, themeName);
|
||||
CLog.StartBenchmark(1, "BuildGlyphs");
|
||||
BuildGlyphs();
|
||||
_BuildGlyphs();
|
||||
CLog.StopBenchmark(1, "BuildGlyphs");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads party mode fonts from skin file
|
||||
/// </summary>
|
||||
public static void LoadPartyModeFonts(int PartyModeID, string FontFolder, CXMLReader xmlReader)
|
||||
public static void LoadPartyModeFonts(int partyModeID, string fontFolder, CXMLReader xmlReader)
|
||||
{
|
||||
_LoadFontFiles(xmlReader, FontFolder, "", PartyModeID);
|
||||
_LoadFontFiles(xmlReader, fontFolder, "", partyModeID);
|
||||
CLog.StartBenchmark(1, "BuildGlyphs");
|
||||
BuildGlyphs();
|
||||
_BuildGlyphs();
|
||||
CLog.StopBenchmark(1, "BuildGlyphs");
|
||||
}
|
||||
|
||||
public static void SaveThemeFonts(string ThemeName, XmlWriter writer)
|
||||
public static void SaveThemeFonts(string themeName, XmlWriter writer)
|
||||
{
|
||||
if (_Fonts.Count == 0)
|
||||
return;
|
||||
|
||||
int Index = 0;
|
||||
int FontNr = 1;
|
||||
bool SetStart = false;
|
||||
while (Index < _Fonts.Count)
|
||||
int index = 0;
|
||||
int fontNr = 1;
|
||||
bool setStart = false;
|
||||
while (index < _Fonts.Count)
|
||||
{
|
||||
if (_Fonts[Index].IsThemeFont && _Fonts[Index].ThemeName == ThemeName)
|
||||
if (_Fonts[index].IsThemeFont && _Fonts[index].ThemeName == themeName)
|
||||
{
|
||||
if (!SetStart)
|
||||
if (!setStart)
|
||||
{
|
||||
writer.WriteStartElement("Fonts");
|
||||
SetStart = true;
|
||||
setStart = true;
|
||||
}
|
||||
|
||||
writer.WriteStartElement("Font" + FontNr.ToString());
|
||||
writer.WriteStartElement("Font" + fontNr.ToString());
|
||||
|
||||
writer.WriteElementString("Name", _Fonts[Index].Name);
|
||||
writer.WriteElementString("Folder", _Fonts[Index].Folder);
|
||||
writer.WriteElementString("Name", _Fonts[index].Name);
|
||||
writer.WriteElementString("Folder", _Fonts[index].Folder);
|
||||
|
||||
writer.WriteElementString("Outline", _Fonts[Index].Outline.ToString("#0.00"));
|
||||
writer.WriteElementString("OutlineColorR", _Fonts[Index].OutlineColor.R.ToString("#0.00"));
|
||||
writer.WriteElementString("OutlineColorG", _Fonts[Index].OutlineColor.G.ToString("#0.00"));
|
||||
writer.WriteElementString("OutlineColorB", _Fonts[Index].OutlineColor.B.ToString("#0.00"));
|
||||
writer.WriteElementString("OutlineColorA", _Fonts[Index].OutlineColor.A.ToString("#0.00"));
|
||||
writer.WriteElementString("Outline", _Fonts[index].Outline.ToString("#0.00"));
|
||||
writer.WriteElementString("OutlineColorR", _Fonts[index].OutlineColor.R.ToString("#0.00"));
|
||||
writer.WriteElementString("OutlineColorG", _Fonts[index].OutlineColor.G.ToString("#0.00"));
|
||||
writer.WriteElementString("OutlineColorB", _Fonts[index].OutlineColor.B.ToString("#0.00"));
|
||||
writer.WriteElementString("OutlineColorA", _Fonts[index].OutlineColor.A.ToString("#0.00"));
|
||||
|
||||
writer.WriteElementString("FileNormal", _Fonts[Index].FileNormal);
|
||||
writer.WriteElementString("FileBold", _Fonts[Index].FileBold);
|
||||
writer.WriteElementString("FileItalic", _Fonts[Index].FileItalic);
|
||||
writer.WriteElementString("FileBoldItalic", _Fonts[Index].FileBoldItalic);
|
||||
writer.WriteElementString("FileNormal", _Fonts[index].FileNormal);
|
||||
writer.WriteElementString("FileBold", _Fonts[index].FileBold);
|
||||
writer.WriteElementString("FileItalic", _Fonts[index].FileItalic);
|
||||
writer.WriteElementString("FileBoldItalic", _Fonts[index].FileBoldItalic);
|
||||
|
||||
writer.WriteEndElement();
|
||||
|
||||
FontNr++;
|
||||
fontNr++;
|
||||
}
|
||||
Index++;
|
||||
index++;
|
||||
}
|
||||
|
||||
if (SetStart)
|
||||
if (setStart)
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
public static void UnloadThemeFonts(string ThemeName)
|
||||
public static void UnloadThemeFonts(string themeName)
|
||||
{
|
||||
if (_Fonts.Count == 0)
|
||||
return;
|
||||
|
||||
int Index = 0;
|
||||
while (Index < _Fonts.Count)
|
||||
int index = 0;
|
||||
while (index < _Fonts.Count)
|
||||
{
|
||||
if (_Fonts[Index].IsThemeFont && _Fonts[Index].ThemeName == ThemeName)
|
||||
if (_Fonts[index].IsThemeFont && _Fonts[index].ThemeName == themeName)
|
||||
{
|
||||
_Fonts[Index].Normal.UnloadAllGlyphs();
|
||||
_Fonts[Index].Italic.UnloadAllGlyphs();
|
||||
_Fonts[Index].Bold.UnloadAllGlyphs();
|
||||
_Fonts[Index].BoldItalic.UnloadAllGlyphs();
|
||||
_Fonts.RemoveAt(Index);
|
||||
_Fonts[index].Normal.UnloadAllGlyphs();
|
||||
_Fonts[index].Italic.UnloadAllGlyphs();
|
||||
_Fonts[index].Bold.UnloadAllGlyphs();
|
||||
_Fonts[index].BoldItalic.UnloadAllGlyphs();
|
||||
_Fonts.RemoveAt(index);
|
||||
}
|
||||
else
|
||||
Index++;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetFontIndex(string ThemeName, string FontName)
|
||||
private static int _GetFontIndex(string themeName, string fontName)
|
||||
{
|
||||
if (ThemeName.Length == 0 || FontName.Length == 0)
|
||||
if (themeName.Length == 0 || fontName.Length == 0)
|
||||
return -1;
|
||||
|
||||
for (int i = 0; i < _Fonts.Count; i++)
|
||||
{
|
||||
if (_Fonts[i].IsThemeFont && _Fonts[i].Name == FontName && _Fonts[i].ThemeName == ThemeName)
|
||||
if (_Fonts[i].IsThemeFont && _Fonts[i].Name == fontName && _Fonts[i].ThemeName == themeName)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static int GetFontIndexParty(int PartyModeID, string FontName)
|
||||
private static int _GetFontIndexParty(int partyModeID, string fontName)
|
||||
{
|
||||
if (PartyModeID == -1 || FontName.Length == 0)
|
||||
if (partyModeID == -1 || fontName.Length == 0)
|
||||
return -1;
|
||||
|
||||
for (int i = 0; i < _Fonts.Count; i++)
|
||||
{
|
||||
if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == FontName && _Fonts[i].PartyModeID == PartyModeID)
|
||||
if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == fontName && _Fonts[i].PartyModeID == partyModeID)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static void BuildGlyphs()
|
||||
private static void _BuildGlyphs()
|
||||
{
|
||||
string Text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890";
|
||||
string text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890";
|
||||
|
||||
for (int i = 0; i < _Fonts.Count; i++)
|
||||
{
|
||||
CurrentFont = i;
|
||||
|
||||
foreach (char chr in Text)
|
||||
foreach (char chr in text)
|
||||
{
|
||||
Style = EStyle.Normal;
|
||||
_Fonts[_CurrentFont].Normal.AddGlyph(chr);
|
||||
|
||||
+68
-68
@@ -26,15 +26,15 @@ namespace Vocaluxe.Base
|
||||
get { return _Rand; }
|
||||
}
|
||||
|
||||
public static float GetBeatFromTime(float Time, float BPM, float Gap)
|
||||
public static float GetBeatFromTime(float time, float bpm, float gap)
|
||||
{
|
||||
return BPM / 60 * (Time - Gap);
|
||||
return bpm / 60 * (time - gap);
|
||||
}
|
||||
|
||||
public static float GetTimeFromBeats(float Beats, float BPM)
|
||||
public static float GetTimeFromBeats(float beats, float bpm)
|
||||
{
|
||||
if (BPM > 0f)
|
||||
return Beats / BPM * 60f;
|
||||
if (bpm > 0f)
|
||||
return beats / bpm * 60f;
|
||||
|
||||
return 0f;
|
||||
}
|
||||
@@ -85,24 +85,24 @@ namespace Vocaluxe.Base
|
||||
get { return _GameMode.GetCurrentGameMode(); }
|
||||
}
|
||||
|
||||
public static bool AddVisibleSong(int VisibleIndex, EGameMode GameMode)
|
||||
public static bool AddVisibleSong(int visibleIndex, EGameMode gameMode)
|
||||
{
|
||||
return _GameMode.AddVisibleSong(VisibleIndex, GameMode);
|
||||
return _GameMode.AddVisibleSong(visibleIndex, gameMode);
|
||||
}
|
||||
|
||||
public static bool AddSong(int AbsoluteIndex, EGameMode GameMode)
|
||||
public static bool AddSong(int absoluteIndex, EGameMode gameMode)
|
||||
{
|
||||
return _GameMode.AddSong(AbsoluteIndex, GameMode);
|
||||
return _GameMode.AddSong(absoluteIndex, gameMode);
|
||||
}
|
||||
|
||||
public static bool RemoveVisibleSong(int VisibleIndex)
|
||||
public static bool RemoveVisibleSong(int visibleIndex)
|
||||
{
|
||||
return _GameMode.RemoveVisibleSong(VisibleIndex);
|
||||
return _GameMode.RemoveVisibleSong(visibleIndex);
|
||||
}
|
||||
|
||||
public static bool RemoveSong(int AbsoluteIndex)
|
||||
public static bool RemoveSong(int absoluteIndex)
|
||||
{
|
||||
return _GameMode.RemoveSong(AbsoluteIndex);
|
||||
return _GameMode.RemoveSong(absoluteIndex);
|
||||
}
|
||||
|
||||
public static void ClearSongs()
|
||||
@@ -140,14 +140,14 @@ namespace Vocaluxe.Base
|
||||
return _GameMode.GetSong();
|
||||
}
|
||||
|
||||
public static CSong GetSong(int Num)
|
||||
public static CSong GetSong(int num)
|
||||
{
|
||||
return _GameMode.GetSong(Num);
|
||||
return _GameMode.GetSong(num);
|
||||
}
|
||||
|
||||
public static EGameMode GetGameMode(int Num)
|
||||
public static EGameMode GetGameMode(int num)
|
||||
{
|
||||
return _GameMode.GetGameMode(Num);
|
||||
return _GameMode.GetGameMode(num);
|
||||
}
|
||||
|
||||
public static int GetNumSongs()
|
||||
@@ -200,23 +200,23 @@ namespace Vocaluxe.Base
|
||||
_CurrentBeatD = -100;
|
||||
}
|
||||
|
||||
public static void UpdatePoints(float Time)
|
||||
public static void UpdatePoints(float time)
|
||||
{
|
||||
bool DEBUG_HIT = false;
|
||||
bool debugHit = false;
|
||||
|
||||
CSong song = _GameMode.GetSong();
|
||||
|
||||
if (song == null)
|
||||
return;
|
||||
|
||||
float b = GetBeatFromTime(Time, song.BPM, song.Gap);
|
||||
float b = GetBeatFromTime(time, song.BPM, song.Gap);
|
||||
if (b <= _Beat)
|
||||
return;
|
||||
|
||||
_Beat = b;
|
||||
_CurrentBeat = (int)Math.Floor(_Beat);
|
||||
|
||||
_MidBeatD = -0.5f + GetBeatFromTime(Time, song.BPM, song.Gap + CConfig.MicDelay / 1000f);
|
||||
_MidBeatD = -0.5f + GetBeatFromTime(time, song.BPM, song.Gap + CConfig.MicDelay / 1000f);
|
||||
_CurrentBeatD = (int)Math.Floor(_MidBeatD);
|
||||
|
||||
for (int p = 0; p < _NumPlayer; p++)
|
||||
@@ -234,115 +234,115 @@ namespace Vocaluxe.Base
|
||||
_Player[p].SongFinished = true;
|
||||
|
||||
CLine[] lines = song.Notes.GetLines(_Player[p].LineNr).Line;
|
||||
int Line = -1;
|
||||
int line = -1;
|
||||
|
||||
for (int j = 0; j < lines.Length; j++)
|
||||
{
|
||||
if (beat >= lines[j].StartBeat && beat <= lines[j].EndBeat)
|
||||
{
|
||||
Line = j;
|
||||
line = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Line >= 0)
|
||||
if (line >= 0)
|
||||
{
|
||||
if (Line != _Player[p].CurrentLine)
|
||||
if (line != _Player[p].CurrentLine)
|
||||
_Player[p].CurrentNote = -1;
|
||||
|
||||
_Player[p].CurrentLine = Line;
|
||||
_Player[p].CurrentLine = line;
|
||||
|
||||
while (_Player[p].SingLine.Count <= Line)
|
||||
while (_Player[p].SingLine.Count <= line)
|
||||
_Player[p].SingLine.Add(new CLine());
|
||||
|
||||
CNote[] notes = lines[Line].Notes;
|
||||
int Note = -1;
|
||||
CNote[] notes = lines[line].Notes;
|
||||
int note = -1;
|
||||
for (int j = 0; j < notes.Length; j++)
|
||||
{
|
||||
if (beat >= notes[j].StartBeat && beat <= notes[j].EndBeat)
|
||||
{
|
||||
Note = j;
|
||||
note = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Note >= 0)
|
||||
if (note >= 0)
|
||||
{
|
||||
_Player[p].CurrentNote = Note;
|
||||
_Player[p].CurrentNote = note;
|
||||
|
||||
if (Line == lines.Length - 1)
|
||||
if (line == lines.Length - 1)
|
||||
{
|
||||
if (Note == lines[Line].NoteCount - 1)
|
||||
if (note == lines[line].NoteCount - 1)
|
||||
{
|
||||
if (notes[Note].EndBeat == beat)
|
||||
if (notes[note].EndBeat == beat)
|
||||
_Player[p].SongFinished = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (notes[Note].PointsForBeat > 0 && (CSound.RecordToneValid(p) || DEBUG_HIT))
|
||||
if (notes[note].PointsForBeat > 0 && (CSound.RecordToneValid(p) || debugHit))
|
||||
{
|
||||
int Tone = notes[Note].Tone;
|
||||
int TonePlayer = CSound.RecordGetTone(p);
|
||||
int tone = notes[note].Tone;
|
||||
int tonePlayer = CSound.RecordGetTone(p);
|
||||
|
||||
while (TonePlayer - Tone > 6)
|
||||
TonePlayer -= 12;
|
||||
while (tonePlayer - tone > 6)
|
||||
tonePlayer -= 12;
|
||||
|
||||
while (TonePlayer - Tone < -6)
|
||||
TonePlayer += 12;
|
||||
while (tonePlayer - tone < -6)
|
||||
tonePlayer += 12;
|
||||
|
||||
if (DEBUG_HIT)
|
||||
TonePlayer = Tone;
|
||||
if (debugHit)
|
||||
tonePlayer = tone;
|
||||
|
||||
_Player[p].NoteDiff = Math.Abs(Tone - TonePlayer);
|
||||
bool Hit = _Player[p].NoteDiff <= (2 - (int)_Player[p].Difficulty);
|
||||
if (Hit)
|
||||
_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 /
|
||||
double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat /
|
||||
song.Notes.GetLines(_Player[p].LineNr).Points;
|
||||
if (notes[Note].NoteType == ENoteType.Golden)
|
||||
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)
|
||||
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));
|
||||
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();
|
||||
_Player[p].SingLine[line].IncLastNoteLength();
|
||||
}
|
||||
else
|
||||
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, Tone, String.Empty, true, notes[Note].NoteType));
|
||||
_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]);
|
||||
_Player[p].SingLine[line].LastNote.IsPerfect(notes[note]);
|
||||
_Player[p].SingLine[line].IsPerfect(lines[line]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Player[p].SingLine[Line].NoteCount > 0)
|
||||
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();
|
||||
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));
|
||||
_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));
|
||||
_Player[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle));
|
||||
}
|
||||
}
|
||||
|
||||
// Line Bonus
|
||||
int NumLinesWithPoints = song.Notes.GetNumLinesWithPoints(_Player[p].LineNr);
|
||||
if (Note == lines[Line].NoteCount - 1 && NumLinesWithPoints > 0)
|
||||
int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(_Player[p].LineNr);
|
||||
if (note == lines[line].NoteCount - 1 && numLinesWithPoints > 0)
|
||||
{
|
||||
if (notes[Note].EndBeat == beat && lines[Line].Points > 0f)
|
||||
if (notes[note].EndBeat == beat && lines[line].Points > 0f)
|
||||
{
|
||||
double factor = _Player[p].SingLine[Line].Points / (double)lines[Line].Points;
|
||||
double factor = _Player[p].SingLine[line].Points / (double)lines[line].Points;
|
||||
if (factor < 0.4)
|
||||
factor = 0.0;
|
||||
else if (factor > 0.9)
|
||||
@@ -354,7 +354,7 @@ namespace Vocaluxe.Base
|
||||
factor *= factor;
|
||||
}
|
||||
|
||||
double points = CSettings.LinebonusScore * factor * 1f / NumLinesWithPoints;
|
||||
double points = CSettings.LinebonusScore * factor * 1f / numLinesWithPoints;
|
||||
_Player[p].Points += points;
|
||||
_Player[p].PointsLineBonus += points;
|
||||
}
|
||||
|
||||
+173
-173
@@ -34,14 +34,14 @@ namespace Vocaluxe.Base
|
||||
|
||||
public int X
|
||||
{
|
||||
get { return (int)_Cursor.rect.X; }
|
||||
set { UpdatePosition(value, (int)_Cursor.rect.Y); }
|
||||
get { return (int)_Cursor.Rect.X; }
|
||||
set { UpdatePosition(value, (int)_Cursor.Rect.Y); }
|
||||
}
|
||||
|
||||
public int Y
|
||||
{
|
||||
get { return (int)_Cursor.rect.Y; }
|
||||
set { UpdatePosition((int)_Cursor.rect.X, value); }
|
||||
get { return (int)_Cursor.Rect.Y; }
|
||||
set { UpdatePosition((int)_Cursor.Rect.X, value); }
|
||||
}
|
||||
|
||||
public bool IsActive
|
||||
@@ -60,10 +60,10 @@ namespace Vocaluxe.Base
|
||||
_CursorName = textureName;
|
||||
_Cursor = CDraw.AddTexture(CTheme.GetSkinFilePath(_CursorName, -1));
|
||||
|
||||
_Cursor.color = color;
|
||||
_Cursor.rect.W = w;
|
||||
_Cursor.rect.H = h;
|
||||
_Cursor.rect.Z = z;
|
||||
_Cursor.Color = color;
|
||||
_Cursor.Rect.W = w;
|
||||
_Cursor.Rect.H = h;
|
||||
_Cursor.Rect.Z = z;
|
||||
|
||||
_Movetimer = new Stopwatch();
|
||||
}
|
||||
@@ -73,7 +73,7 @@ namespace Vocaluxe.Base
|
||||
if (_Movetimer.IsRunning && _Movetimer.ElapsedMilliseconds / 1000f > CSettings.MouseMoveOffTime)
|
||||
{
|
||||
_Movetimer.Stop();
|
||||
Fade(0f, 0.5f);
|
||||
_Fade(0f, 0.5f);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,14 +83,14 @@ namespace Vocaluxe.Base
|
||||
if (t < _CursorFadingTime)
|
||||
{
|
||||
if (_CursorTargetAlpha >= _CursorStartAlpha)
|
||||
_Cursor.color.A = _CursorStartAlpha + (_CursorTargetAlpha - _CursorStartAlpha) * t / _CursorFadingTime;
|
||||
_Cursor.Color.A = _CursorStartAlpha + (_CursorTargetAlpha - _CursorStartAlpha) * t / _CursorFadingTime;
|
||||
else
|
||||
_Cursor.color.A = (_CursorStartAlpha - _CursorTargetAlpha) * (1f - t / _CursorFadingTime);
|
||||
_Cursor.Color.A = (_CursorStartAlpha - _CursorTargetAlpha) * (1f - t / _CursorFadingTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
_CursorFadingTimer.Stop();
|
||||
_Cursor.color.A = _CursorTargetAlpha;
|
||||
_Cursor.Color.A = _CursorTargetAlpha;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,19 +100,19 @@ namespace Vocaluxe.Base
|
||||
|
||||
public void UpdatePosition(int x, int y)
|
||||
{
|
||||
if (Math.Abs(_Cursor.rect.X - x) > CSettings.MouseMoveDiffMin ||
|
||||
Math.Abs(_Cursor.rect.Y - y) > CSettings.MouseMoveDiffMin)
|
||||
if (Math.Abs(_Cursor.Rect.X - x) > CSettings.MouseMoveDiffMin ||
|
||||
Math.Abs(_Cursor.Rect.Y - y) > CSettings.MouseMoveDiffMin)
|
||||
{
|
||||
if (_CursorTargetAlpha == 0f)
|
||||
Fade(1f, 0.2f);
|
||||
_Fade(1f, 0.2f);
|
||||
|
||||
_Movetimer.Reset();
|
||||
_Movetimer.Start();
|
||||
CSettings.MouseActive();
|
||||
}
|
||||
|
||||
_Cursor.rect.X = x;
|
||||
_Cursor.rect.Y = y;
|
||||
_Cursor.Rect.X = x;
|
||||
_Cursor.Rect.Y = y;
|
||||
}
|
||||
|
||||
public void UnloadTextures()
|
||||
@@ -130,17 +130,17 @@ namespace Vocaluxe.Base
|
||||
public void FadeOut()
|
||||
{
|
||||
_Movetimer.Stop();
|
||||
Fade(0f, 0.5f);
|
||||
_Fade(0f, 0.5f);
|
||||
}
|
||||
|
||||
public void FadeIn()
|
||||
{
|
||||
_Movetimer.Reset();
|
||||
_Movetimer.Start();
|
||||
Fade(1f, 0.2f);
|
||||
_Fade(1f, 0.2f);
|
||||
}
|
||||
|
||||
private void Fade(float targetAlpha, float time)
|
||||
private void _Fade(float targetAlpha, float time)
|
||||
{
|
||||
_CursorFadingTimer.Stop();
|
||||
_CursorFadingTimer.Reset();
|
||||
@@ -153,7 +153,7 @@ namespace Vocaluxe.Base
|
||||
if (time >= 0f)
|
||||
_CursorFadingTime = time;
|
||||
|
||||
_CursorStartAlpha = _Cursor.color.A;
|
||||
_CursorStartAlpha = _Cursor.Color.A;
|
||||
_CursorFadingTimer.Start();
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ namespace Vocaluxe.Base
|
||||
private static readonly List<IMenu> _PopupScreens = new List<IMenu>();
|
||||
|
||||
private static Stopwatch _VolumePopupTimer;
|
||||
private static bool CursorOverVolumeControl;
|
||||
private static bool _CursorOverVolumeControl;
|
||||
|
||||
public static float GlobalAlpha
|
||||
{
|
||||
@@ -241,10 +241,10 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
_Cursor = new CCursor(
|
||||
CTheme.Cursor.SkinName,
|
||||
new SColorF(CTheme.Cursor.r, CTheme.Cursor.g, CTheme.Cursor.b, CTheme.Cursor.a),
|
||||
CTheme.Cursor.w,
|
||||
CTheme.Cursor.h,
|
||||
CSettings.zNear);
|
||||
new SColorF(CTheme.Cursor.R, CTheme.Cursor.G, CTheme.Cursor.B, CTheme.Cursor.A),
|
||||
CTheme.Cursor.W,
|
||||
CTheme.Cursor.H,
|
||||
CSettings.ZNear);
|
||||
|
||||
for (int i = 0; i < _Screens.Count; i++)
|
||||
{
|
||||
@@ -263,7 +263,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void ReloadTheme()
|
||||
{
|
||||
ReloadCursor();
|
||||
_ReloadCursor();
|
||||
for (int i = 0; i < _Screens.Count; i++)
|
||||
_Screens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1));
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void ReloadSkin()
|
||||
{
|
||||
ReloadCursor();
|
||||
_ReloadCursor();
|
||||
for (int i = 0; i < _Screens.Count; i++)
|
||||
_Screens[i].ReloadTextures();
|
||||
|
||||
@@ -297,13 +297,13 @@ namespace Vocaluxe.Base
|
||||
_Screens[(int)_CurrentScreen].OnShowFinish();
|
||||
}
|
||||
|
||||
public static bool UpdateGameLogic(CKeys Keys, CMouse Mouse)
|
||||
public static bool UpdateGameLogic(CKeys keys, CMouse mouse)
|
||||
{
|
||||
bool _Run = true;
|
||||
_Cursor.CursorVisible = Mouse.Visible;
|
||||
bool run = true;
|
||||
_Cursor.CursorVisible = mouse.Visible;
|
||||
|
||||
Mouse.CopyEvents();
|
||||
Keys.CopyEvents();
|
||||
mouse.CopyEvents();
|
||||
keys.CopyEvents();
|
||||
|
||||
CVideo.Update();
|
||||
CSound.Update();
|
||||
@@ -315,17 +315,17 @@ namespace Vocaluxe.Base
|
||||
|
||||
if (CSettings.GameState != EGameState.EditTheme)
|
||||
{
|
||||
_Run &= HandleInputs(Keys, Mouse);
|
||||
_Run &= Update();
|
||||
run &= _HandleInputs(keys, mouse);
|
||||
run &= _Update();
|
||||
CParty.UpdateGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
_Run &= HandleInputThemeEditor(Keys, Mouse);
|
||||
_Run &= Update();
|
||||
run &= _HandleInputThemeEditor(keys, mouse);
|
||||
run &= _Update();
|
||||
}
|
||||
|
||||
return _Run;
|
||||
return run;
|
||||
}
|
||||
|
||||
public static bool Draw()
|
||||
@@ -350,18 +350,18 @@ namespace Vocaluxe.Base
|
||||
|
||||
if (_Fading)
|
||||
{
|
||||
long FadeTime = (long)(CConfig.FadeTime * 1000);
|
||||
long fadeTime = (long)(CConfig.FadeTime * 1000);
|
||||
|
||||
if ((_FadingTimer.ElapsedMilliseconds < FadeTime) && (CConfig.FadeTime > 0))
|
||||
if ((_FadingTimer.ElapsedMilliseconds < fadeTime) && (CConfig.FadeTime > 0))
|
||||
{
|
||||
long ms = 1;
|
||||
if (_FadingTimer.ElapsedMilliseconds > 0)
|
||||
ms = _FadingTimer.ElapsedMilliseconds;
|
||||
|
||||
float factor = (float)ms / FadeTime;
|
||||
float factor = (float)ms / fadeTime;
|
||||
|
||||
_GlobalAlpha = 1f; // -factor / 100f;
|
||||
_ZOffset = CSettings.zFar / 2;
|
||||
_ZOffset = CSettings.ZFar / 2;
|
||||
|
||||
if (_CurrentScreen == EScreens.ScreenPartyDummy)
|
||||
{
|
||||
@@ -429,14 +429,14 @@ namespace Vocaluxe.Base
|
||||
_PopupScreens[i].Draw();
|
||||
|
||||
_Cursor.Draw();
|
||||
DrawDebugInfos();
|
||||
_DrawDebugInfos();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void FadeTo(EScreens Screen)
|
||||
public static void FadeTo(EScreens screen)
|
||||
{
|
||||
if (Screen == EScreens.ScreenPartyDummy)
|
||||
if (screen == EScreens.ScreenPartyDummy)
|
||||
{
|
||||
EScreens alt;
|
||||
CMenu scr = CParty.GetNextPartyScreen(out alt);
|
||||
@@ -448,22 +448,22 @@ namespace Vocaluxe.Base
|
||||
_Screens[(int)EScreens.ScreenPartyDummy] = scr;
|
||||
}
|
||||
|
||||
_NextScreen = Screen;
|
||||
_NextScreen = screen;
|
||||
}
|
||||
|
||||
public static void ShowPopup(EPopupScreens PopupScreen)
|
||||
public static void ShowPopup(EPopupScreens popupScreen)
|
||||
{
|
||||
_PopupScreens[(int)PopupScreen].OnShow();
|
||||
_PopupScreens[(int)PopupScreen].OnShowFinish();
|
||||
_CurrentPopupScreen = PopupScreen;
|
||||
_PopupScreens[(int)popupScreen].OnShow();
|
||||
_PopupScreens[(int)popupScreen].OnShowFinish();
|
||||
_CurrentPopupScreen = popupScreen;
|
||||
}
|
||||
|
||||
public static void HidePopup(EPopupScreens PopupScreen)
|
||||
public static void HidePopup(EPopupScreens popupScreen)
|
||||
{
|
||||
if (_CurrentPopupScreen != PopupScreen)
|
||||
if (_CurrentPopupScreen != popupScreen)
|
||||
return;
|
||||
|
||||
_PopupScreens[(int)PopupScreen].OnClose();
|
||||
_PopupScreens[(int)popupScreen].OnClose();
|
||||
_CurrentPopupScreen = EPopupScreens.NoPopup;
|
||||
}
|
||||
|
||||
@@ -479,41 +479,41 @@ namespace Vocaluxe.Base
|
||||
#endregion public methods
|
||||
|
||||
#region private stuff
|
||||
private static bool HandleInputs(CKeys keys, CMouse Mouse)
|
||||
private static bool _HandleInputs(CKeys keys, CMouse mouse)
|
||||
{
|
||||
KeyEvent KeyEvent = new KeyEvent();
|
||||
MouseEvent MouseEvent = new MouseEvent();
|
||||
KeyEvent InputKeyEvent = new KeyEvent();
|
||||
MouseEvent InputMouseEvent = new MouseEvent();
|
||||
SKeyEvent keyEvent = new SKeyEvent();
|
||||
SMouseEvent mouseEvent = new SMouseEvent();
|
||||
SKeyEvent inputKeyEvent = new SKeyEvent();
|
||||
SMouseEvent inputMouseEvent = new SMouseEvent();
|
||||
|
||||
bool PopupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing &&
|
||||
bool popupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing &&
|
||||
(_CurrentScreen != EScreens.ScreenSong ||
|
||||
(_CurrentScreen == EScreens.ScreenSong && !CSongs.IsInCategory && CConfig.Tabs == EOffOn.TR_CONFIG_ON))
|
||||
&& _CurrentScreen != EScreens.ScreenCredits && !CBackgroundMusic.Disabled;
|
||||
|
||||
bool PopupVolumeControlAllowed = _CurrentScreen != EScreens.ScreenCredits && _CurrentScreen != EScreens.ScreenOptionsRecord;
|
||||
bool popupVolumeControlAllowed = _CurrentScreen != EScreens.ScreenCredits && _CurrentScreen != EScreens.ScreenOptionsRecord;
|
||||
//Hide volume control for bg-music if bg-music is disabled
|
||||
if (PopupVolumeControlAllowed && (_CurrentScreen != EScreens.ScreenSong || (_CurrentScreen == EScreens.ScreenSong && CSongs.Category == -1))
|
||||
if (popupVolumeControlAllowed && (_CurrentScreen != EScreens.ScreenSong || (_CurrentScreen == EScreens.ScreenSong && CSongs.Category == -1))
|
||||
&& _CurrentScreen != EScreens.ScreenSing && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_OFF)
|
||||
PopupVolumeControlAllowed = false;
|
||||
popupVolumeControlAllowed = false;
|
||||
|
||||
|
||||
bool Resume = true;
|
||||
bool EventsAvailable = false;
|
||||
bool InputEventsAvailable = CInput.PollKeyEvent(ref InputKeyEvent);
|
||||
bool resume = true;
|
||||
bool eventsAvailable = false;
|
||||
bool inputEventsAvailable = CInput.PollKeyEvent(ref inputKeyEvent);
|
||||
|
||||
while ((EventsAvailable = keys.PollEvent(ref KeyEvent)) || InputEventsAvailable)
|
||||
while ((eventsAvailable = keys.PollEvent(ref keyEvent)) || inputEventsAvailable)
|
||||
{
|
||||
if (!EventsAvailable)
|
||||
KeyEvent = InputKeyEvent;
|
||||
if (!eventsAvailable)
|
||||
keyEvent = inputKeyEvent;
|
||||
|
||||
if (KeyEvent.Key == Keys.Left || KeyEvent.Key == Keys.Right || KeyEvent.Key == Keys.Up || KeyEvent.Key == Keys.Down)
|
||||
if (keyEvent.Key == Keys.Left || keyEvent.Key == Keys.Right || keyEvent.Key == Keys.Up || keyEvent.Key == Keys.Down)
|
||||
{
|
||||
CSettings.MouseInactive();
|
||||
_Cursor.FadeOut();
|
||||
}
|
||||
|
||||
if (PopupPlayerControlAllowed && KeyEvent.Key == Keys.Tab)
|
||||
if (popupPlayerControlAllowed && keyEvent.Key == Keys.Tab)
|
||||
{
|
||||
if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
|
||||
ShowPopup(EPopupScreens.PopupPlayerControl);
|
||||
@@ -521,13 +521,13 @@ namespace Vocaluxe.Base
|
||||
HidePopup(EPopupScreens.PopupPlayerControl);
|
||||
}
|
||||
|
||||
if (PopupPlayerControlAllowed && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
|
||||
if (popupPlayerControlAllowed && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
if (KeyEvent.Key == Keys.MediaNextTrack)
|
||||
if (keyEvent.Key == Keys.MediaNextTrack)
|
||||
CMain.BackgroundMusic.Next();
|
||||
else if (KeyEvent.Key == Keys.MediaPreviousTrack)
|
||||
else if (keyEvent.Key == Keys.MediaPreviousTrack)
|
||||
CMain.BackgroundMusic.Previous();
|
||||
else if (KeyEvent.Key == Keys.MediaPlayPause)
|
||||
else if (keyEvent.Key == Keys.MediaPlayPause)
|
||||
{
|
||||
if (CMain.BackgroundMusic.IsPlaying())
|
||||
CMain.BackgroundMusic.Pause();
|
||||
@@ -536,46 +536,46 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
if (PopupVolumeControlAllowed)
|
||||
if (popupVolumeControlAllowed)
|
||||
{
|
||||
int Diff = 0;
|
||||
if ((KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Add || KeyEvent.Key == Keys.PageUp)) || (KeyEvent.Sender == ESender.WiiMote && KeyEvent.Key == Keys.Add))
|
||||
Diff = 5;
|
||||
else if ((KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) ||
|
||||
(KeyEvent.Sender == ESender.WiiMote && KeyEvent.Key == Keys.Subtract))
|
||||
Diff = -5;
|
||||
int diff = 0;
|
||||
if ((keyEvent.ModShift && (keyEvent.Key == Keys.Add || keyEvent.Key == Keys.PageUp)) || (keyEvent.Sender == ESender.WiiMote && keyEvent.Key == Keys.Add))
|
||||
diff = 5;
|
||||
else if ((keyEvent.ModShift && (keyEvent.Key == Keys.Subtract || keyEvent.Key == Keys.PageDown)) ||
|
||||
(keyEvent.Sender == ESender.WiiMote && keyEvent.Key == Keys.Subtract))
|
||||
diff = -5;
|
||||
|
||||
if (Diff != 0)
|
||||
if (diff != 0)
|
||||
{
|
||||
switch (CurrentScreen)
|
||||
{
|
||||
case EScreens.ScreenSong:
|
||||
if (CSongs.IsInCategory)
|
||||
{
|
||||
CConfig.PreviewMusicVolume += Diff;
|
||||
CConfig.PreviewMusicVolume += diff;
|
||||
_Screens[(int)_CurrentScreen].ApplyVolume();
|
||||
}
|
||||
else
|
||||
{
|
||||
CConfig.BackgroundMusicVolume += Diff;
|
||||
CConfig.BackgroundMusicVolume += diff;
|
||||
CBackgroundMusic.ApplyVolume();
|
||||
}
|
||||
break;
|
||||
|
||||
case EScreens.ScreenSing:
|
||||
CConfig.GameMusicVolume += Diff;
|
||||
CConfig.GameMusicVolume += diff;
|
||||
_Screens[(int)_CurrentScreen].ApplyVolume();
|
||||
break;
|
||||
|
||||
default:
|
||||
CConfig.BackgroundMusicVolume += Diff;
|
||||
CConfig.BackgroundMusicVolume += diff;
|
||||
CBackgroundMusic.ApplyVolume();
|
||||
break;
|
||||
}
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
|
||||
if (_CurrentPopupScreen == EPopupScreens.NoPopup && Diff != 0)
|
||||
if (_CurrentPopupScreen == EPopupScreens.NoPopup && diff != 0)
|
||||
{
|
||||
ShowPopup(EPopupScreens.PopupVolumeControl);
|
||||
_VolumePopupTimer.Reset();
|
||||
@@ -585,11 +585,11 @@ namespace Vocaluxe.Base
|
||||
CMain.BackgroundMusic.ApplyVolume();
|
||||
}
|
||||
|
||||
if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.F1))
|
||||
if (keyEvent.ModShift && (keyEvent.Key == Keys.F1))
|
||||
CSettings.GameState = EGameState.EditTheme;
|
||||
else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.Enter))
|
||||
CSettings.bFullScreen = !CSettings.bFullScreen;
|
||||
else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.P))
|
||||
else if (keyEvent.ModAlt && (keyEvent.Key == Keys.Enter))
|
||||
CSettings.IsFullScreen = !CSettings.IsFullScreen;
|
||||
else if (keyEvent.ModAlt && (keyEvent.Key == Keys.P))
|
||||
CDraw.MakeScreenShot();
|
||||
else
|
||||
{
|
||||
@@ -597,34 +597,34 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
bool handled = false;
|
||||
if (_CurrentPopupScreen != EPopupScreens.NoPopup)
|
||||
handled = _PopupScreens[(int)_CurrentPopupScreen].HandleInput(KeyEvent);
|
||||
handled = _PopupScreens[(int)_CurrentPopupScreen].HandleInput(keyEvent);
|
||||
|
||||
if (!handled)
|
||||
Resume &= _Screens[(int)_CurrentScreen].HandleInput(KeyEvent);
|
||||
resume &= _Screens[(int)_CurrentScreen].HandleInput(keyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
if (!EventsAvailable)
|
||||
InputEventsAvailable = CInput.PollKeyEvent(ref InputKeyEvent);
|
||||
if (!eventsAvailable)
|
||||
inputEventsAvailable = CInput.PollKeyEvent(ref inputKeyEvent);
|
||||
}
|
||||
|
||||
InputEventsAvailable = CInput.PollMouseEvent(ref InputMouseEvent);
|
||||
inputEventsAvailable = CInput.PollMouseEvent(ref inputMouseEvent);
|
||||
|
||||
while ((EventsAvailable = Mouse.PollEvent(ref MouseEvent)) || InputEventsAvailable)
|
||||
while ((eventsAvailable = mouse.PollEvent(ref mouseEvent)) || inputEventsAvailable)
|
||||
{
|
||||
if (!EventsAvailable)
|
||||
MouseEvent = InputMouseEvent;
|
||||
if (!eventsAvailable)
|
||||
mouseEvent = inputMouseEvent;
|
||||
|
||||
if (MouseEvent.Wheel != 0)
|
||||
if (mouseEvent.Wheel != 0)
|
||||
{
|
||||
CSettings.MouseActive();
|
||||
_Cursor.FadeIn();
|
||||
}
|
||||
|
||||
UpdateMousePosition(MouseEvent.X, MouseEvent.Y);
|
||||
_UpdateMousePosition(mouseEvent.X, mouseEvent.Y);
|
||||
|
||||
bool isOverPopupPlayerControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupPlayerControl].ScreenArea, MouseEvent);
|
||||
if (PopupPlayerControlAllowed && isOverPopupPlayerControl)
|
||||
bool isOverPopupPlayerControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupPlayerControl].ScreenArea, mouseEvent);
|
||||
if (popupPlayerControlAllowed && isOverPopupPlayerControl)
|
||||
{
|
||||
if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
|
||||
ShowPopup(EPopupScreens.PopupPlayerControl);
|
||||
@@ -633,8 +633,8 @@ namespace Vocaluxe.Base
|
||||
if (!isOverPopupPlayerControl && _CurrentPopupScreen == EPopupScreens.PopupPlayerControl)
|
||||
HidePopup(EPopupScreens.PopupPlayerControl);
|
||||
|
||||
bool isOverPopupVolumeControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupVolumeControl].ScreenArea, MouseEvent);
|
||||
if (PopupVolumeControlAllowed && isOverPopupVolumeControl)
|
||||
bool isOverPopupVolumeControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupVolumeControl].ScreenArea, mouseEvent);
|
||||
if (popupVolumeControlAllowed && isOverPopupVolumeControl)
|
||||
{
|
||||
if (_CurrentPopupScreen == EPopupScreens.NoPopup)
|
||||
{
|
||||
@@ -644,7 +644,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
if (CursorOverVolumeControl && !isOverPopupVolumeControl)
|
||||
if (_CursorOverVolumeControl && !isOverPopupVolumeControl)
|
||||
{
|
||||
if (_CurrentPopupScreen == EPopupScreens.PopupVolumeControl)
|
||||
{
|
||||
@@ -652,64 +652,64 @@ namespace Vocaluxe.Base
|
||||
_VolumePopupTimer.Reset();
|
||||
}
|
||||
}
|
||||
CursorOverVolumeControl = isOverPopupVolumeControl;
|
||||
_CursorOverVolumeControl = isOverPopupVolumeControl;
|
||||
|
||||
|
||||
bool handled = false;
|
||||
if (_CurrentPopupScreen != EPopupScreens.NoPopup)
|
||||
handled = _PopupScreens[(int)_CurrentPopupScreen].HandleMouse(MouseEvent);
|
||||
handled = _PopupScreens[(int)_CurrentPopupScreen].HandleMouse(mouseEvent);
|
||||
|
||||
if (handled && _CurrentPopupScreen == EPopupScreens.PopupVolumeControl)
|
||||
_Screens[(int)_CurrentScreen].ApplyVolume();
|
||||
|
||||
if (!handled && !_Fading && (_Cursor.IsActive || MouseEvent.LB || MouseEvent.RB || MouseEvent.MB))
|
||||
Resume &= _Screens[(int)_CurrentScreen].HandleMouse(MouseEvent);
|
||||
if (!handled && !_Fading && (_Cursor.IsActive || mouseEvent.LB || mouseEvent.RB || mouseEvent.MB))
|
||||
resume &= _Screens[(int)_CurrentScreen].HandleMouse(mouseEvent);
|
||||
|
||||
if (!EventsAvailable)
|
||||
InputEventsAvailable = CInput.PollMouseEvent(ref InputMouseEvent);
|
||||
if (!eventsAvailable)
|
||||
inputEventsAvailable = CInput.PollMouseEvent(ref inputMouseEvent);
|
||||
}
|
||||
return Resume;
|
||||
return resume;
|
||||
}
|
||||
|
||||
private static bool HandleInputThemeEditor(CKeys keys, CMouse Mouse)
|
||||
private static bool _HandleInputThemeEditor(CKeys keys, CMouse mouse)
|
||||
{
|
||||
KeyEvent KeyEvent = new KeyEvent();
|
||||
MouseEvent MouseEvent = new MouseEvent();
|
||||
SKeyEvent keyEvent = new SKeyEvent();
|
||||
SMouseEvent mouseEvent = new SMouseEvent();
|
||||
|
||||
while (keys.PollEvent(ref KeyEvent))
|
||||
while (keys.PollEvent(ref keyEvent))
|
||||
{
|
||||
if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.F1))
|
||||
if (keyEvent.ModShift && (keyEvent.Key == Keys.F1))
|
||||
{
|
||||
CSettings.GameState = EGameState.Normal;
|
||||
_Screens[(int)_CurrentScreen].NextInteraction();
|
||||
}
|
||||
else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.Enter))
|
||||
CSettings.bFullScreen = !CSettings.bFullScreen;
|
||||
else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.P))
|
||||
else if (keyEvent.ModAlt && (keyEvent.Key == Keys.Enter))
|
||||
CSettings.IsFullScreen = !CSettings.IsFullScreen;
|
||||
else if (keyEvent.ModAlt && (keyEvent.Key == Keys.P))
|
||||
CDraw.MakeScreenShot();
|
||||
else
|
||||
{
|
||||
if (!_Fading)
|
||||
_Screens[(int)_CurrentScreen].HandleInputThemeEditor(KeyEvent);
|
||||
_Screens[(int)_CurrentScreen].HandleInputThemeEditor(keyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
while (Mouse.PollEvent(ref MouseEvent))
|
||||
while (mouse.PollEvent(ref mouseEvent))
|
||||
{
|
||||
if (!_Fading)
|
||||
_Screens[(int)_CurrentScreen].HandleMouseThemeEditor(MouseEvent);
|
||||
_Screens[(int)_CurrentScreen].HandleMouseThemeEditor(mouseEvent);
|
||||
|
||||
UpdateMousePosition(MouseEvent.X, MouseEvent.Y);
|
||||
_UpdateMousePosition(mouseEvent.X, mouseEvent.Y);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void UpdateMousePosition(int x, int y)
|
||||
private static void _UpdateMousePosition(int x, int y)
|
||||
{
|
||||
_Cursor.UpdatePosition(x, y);
|
||||
}
|
||||
|
||||
private static bool Update()
|
||||
private static bool _Update()
|
||||
{
|
||||
if (_VolumePopupTimer.IsRunning && _VolumePopupTimer.ElapsedMilliseconds >= 1500 && _CurrentPopupScreen == EPopupScreens.PopupVolumeControl)
|
||||
{
|
||||
@@ -725,22 +725,22 @@ namespace Vocaluxe.Base
|
||||
return _Screens[(int)_CurrentScreen].UpdateGame();
|
||||
}
|
||||
|
||||
private static void DrawDebugInfos()
|
||||
private static void _DrawDebugInfos()
|
||||
{
|
||||
string txt = String.Empty;
|
||||
CFonts.Style = EStyle.Normal;
|
||||
CFonts.SetFont("Normal");
|
||||
SColorF Gray = new SColorF(1f, 1f, 1f, 0.5f);
|
||||
SColorF gray = new SColorF(1f, 1f, 1f, 0.5f);
|
||||
|
||||
float dy = 0;
|
||||
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_ONLY_FPS)
|
||||
{
|
||||
txt = CTime.GetFPS().ToString("FPS: 000");
|
||||
CFonts.Height = 30f;
|
||||
RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
|
||||
CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
|
||||
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
|
||||
dy += rect.Height;
|
||||
}
|
||||
|
||||
@@ -748,10 +748,10 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
txt = CSound.GetStreamCount().ToString(CLanguage.Translate("TR_DEBUG_AUDIO_STREAMS") + ": 00");
|
||||
|
||||
RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
|
||||
CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
|
||||
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
|
||||
dy += rect.Height;
|
||||
}
|
||||
|
||||
@@ -759,10 +759,10 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
txt = CVideo.GetNumStreams().ToString(CLanguage.Translate("TR_DEBUG_VIDEO_STREAMS") + ": 00");
|
||||
|
||||
RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
|
||||
CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
|
||||
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
|
||||
dy += rect.Height;
|
||||
}
|
||||
|
||||
@@ -770,10 +770,10 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
txt = CDraw.TextureCount().ToString(CLanguage.Translate("TR_DEBUG_TEXTURES") + ": 00000");
|
||||
|
||||
RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
|
||||
CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
|
||||
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
|
||||
dy += rect.Height;
|
||||
}
|
||||
|
||||
@@ -782,10 +782,10 @@ namespace Vocaluxe.Base
|
||||
long memory = GC.GetTotalMemory(false);
|
||||
txt = (memory / 1000000L).ToString(CLanguage.Translate("TR_DEBUG_MEMORY") + ": 00000 MB");
|
||||
|
||||
RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
|
||||
CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
|
||||
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
|
||||
dy += rect.Height;
|
||||
}
|
||||
|
||||
@@ -793,36 +793,36 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
txt = CSound.RecordGetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00");
|
||||
|
||||
RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
|
||||
CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
|
||||
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
|
||||
dy += rect.Height;
|
||||
|
||||
|
||||
txt = CSound.RecordGetMaxVolume(0).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P1: 0.000");
|
||||
|
||||
rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
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);
|
||||
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.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
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);
|
||||
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.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -830,10 +830,10 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
txt = CSongs.NumSongsWithCoverLoaded.ToString(CLanguage.Translate("TR_DEBUG_SONGS") + ": 00000");
|
||||
|
||||
RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
|
||||
CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
|
||||
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
|
||||
dy += rect.Height;
|
||||
}
|
||||
|
||||
@@ -841,34 +841,34 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
txt = _Cursor.X.ToString(CLanguage.Translate("TR_DEBUG_MOUSE") + " : (0000/") + _Cursor.Y.ToString("0000)");
|
||||
|
||||
RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
|
||||
|
||||
CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
|
||||
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
|
||||
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
|
||||
dy += rect.Height;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ReloadCursor()
|
||||
private static void _ReloadCursor()
|
||||
{
|
||||
_Cursor.UnloadTextures();
|
||||
|
||||
if (CTheme.Cursor.color.Length > 0)
|
||||
if (CTheme.Cursor.Color.Length > 0)
|
||||
{
|
||||
SColorF color;
|
||||
color = CTheme.GetColor(CTheme.Cursor.color, -1);
|
||||
CTheme.Cursor.r = color.R;
|
||||
CTheme.Cursor.g = color.G;
|
||||
CTheme.Cursor.b = color.B;
|
||||
CTheme.Cursor.a = color.A;
|
||||
color = CTheme.GetColor(CTheme.Cursor.Color, -1);
|
||||
CTheme.Cursor.R = color.R;
|
||||
CTheme.Cursor.G = color.G;
|
||||
CTheme.Cursor.B = color.B;
|
||||
CTheme.Cursor.A = color.A;
|
||||
}
|
||||
|
||||
_Cursor = new CCursor(
|
||||
CTheme.Cursor.SkinName,
|
||||
new SColorF(CTheme.Cursor.r, CTheme.Cursor.g, CTheme.Cursor.b, CTheme.Cursor.a),
|
||||
CTheme.Cursor.w,
|
||||
CTheme.Cursor.h,
|
||||
CSettings.zNear);
|
||||
new SColorF(CTheme.Cursor.R, CTheme.Cursor.G, CTheme.Cursor.B, CTheme.Cursor.A),
|
||||
CTheme.Cursor.W,
|
||||
CTheme.Cursor.H,
|
||||
CSettings.ZNear);
|
||||
}
|
||||
#endregion private stuff
|
||||
}
|
||||
|
||||
@@ -41,19 +41,19 @@ namespace Vocaluxe.Base
|
||||
_Input.Update();
|
||||
}
|
||||
|
||||
public static bool PollKeyEvent(ref KeyEvent KeyEvent)
|
||||
public static bool PollKeyEvent(ref SKeyEvent keyEvent)
|
||||
{
|
||||
return _Input.PollKeyEvent(ref KeyEvent);
|
||||
return _Input.PollKeyEvent(ref keyEvent);
|
||||
}
|
||||
|
||||
public static bool PollMouseEvent(ref MouseEvent MouseEvent)
|
||||
public static bool PollMouseEvent(ref SMouseEvent mouseEvent)
|
||||
{
|
||||
return _Input.PollMouseEvent(ref MouseEvent);
|
||||
return _Input.PollMouseEvent(ref mouseEvent);
|
||||
}
|
||||
|
||||
public static void SetRumble(float Duration)
|
||||
public static void SetRumble(float duration)
|
||||
{
|
||||
_Input.SetRumble(Duration);
|
||||
_Input.SetRumble(duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
+50
-50
@@ -24,7 +24,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
static class CLanguage
|
||||
{
|
||||
private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
private static List<SLanguage> _Languages;
|
||||
private static int _CurrentLanguage;
|
||||
private static int _FallbackLanguage;
|
||||
@@ -46,31 +46,31 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static string[] GetLanguageNames()
|
||||
{
|
||||
string[] Languages = new string[_Languages.Count];
|
||||
string[] languages = new string[_Languages.Count];
|
||||
|
||||
for (int i = 0; i < _Languages.Count; i++)
|
||||
Languages[i] = _Languages[i].Name;
|
||||
languages[i] = _Languages[i].Name;
|
||||
|
||||
return Languages;
|
||||
return languages;
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_Languages = new List<SLanguage>();
|
||||
_settings.Indent = true;
|
||||
_settings.Encoding = Encoding.UTF8;
|
||||
_settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
_Settings.Indent = true;
|
||||
_Settings.Encoding = Encoding.UTF8;
|
||||
_Settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
|
||||
List<string> files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(CSettings.sFolderLanguages, "*.xml", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderLanguages, "*.xml", true, true));
|
||||
|
||||
foreach (string file in files)
|
||||
LoadLanguageFile(file);
|
||||
_LoadLanguageFile(file);
|
||||
}
|
||||
|
||||
public static bool SetLanguage(string Language)
|
||||
public static bool SetLanguage(string language)
|
||||
{
|
||||
int nr = GetLanguageNr(Language);
|
||||
int nr = GetLanguageNr(language);
|
||||
if (nr != -1)
|
||||
{
|
||||
_CurrentLanguage = nr;
|
||||
@@ -79,92 +79,92 @@ namespace Vocaluxe.Base
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int GetLanguageNr(string Language)
|
||||
public static int GetLanguageNr(string language)
|
||||
{
|
||||
for (int i = 0; i < _Languages.Count; i++)
|
||||
{
|
||||
if (_Languages[i].Name == Language)
|
||||
if (_Languages[i].Name == language)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static string Translate(string KeyWord)
|
||||
public static string Translate(string keyWord)
|
||||
{
|
||||
return Translate(KeyWord, -1);
|
||||
return Translate(keyWord, -1);
|
||||
}
|
||||
|
||||
public static string Translate(string KeyWord, int PartyModeID)
|
||||
public static string Translate(string keyWord, int partyModeID)
|
||||
{
|
||||
if (KeyWord == null)
|
||||
if (keyWord == null)
|
||||
return "Error";
|
||||
|
||||
if (KeyWord.Length < 3 || KeyWord.Substring(0, 3) != "TR_")
|
||||
return KeyWord;
|
||||
if (keyWord.Length < 3 || keyWord.Substring(0, 3) != "TR_")
|
||||
return keyWord;
|
||||
|
||||
string result;
|
||||
if (PartyModeID != -1)
|
||||
if (partyModeID != -1)
|
||||
{
|
||||
int PartyModeNr = GetPartyModeNr(PartyModeID, _CurrentLanguage);
|
||||
if (PartyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[PartyModeNr].Texts.TryGetValue(KeyWord, out result))
|
||||
int partyModeNr = _GetPartyModeNr(partyModeID, _CurrentLanguage);
|
||||
if (partyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[partyModeNr].Texts.TryGetValue(keyWord, out result))
|
||||
return result;
|
||||
|
||||
PartyModeNr = GetPartyModeNr(PartyModeID, _FallbackLanguage);
|
||||
if (PartyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[PartyModeNr].Texts.TryGetValue(KeyWord, out result))
|
||||
partyModeNr = _GetPartyModeNr(partyModeID, _FallbackLanguage);
|
||||
if (partyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[partyModeNr].Texts.TryGetValue(keyWord, out result))
|
||||
return result;
|
||||
}
|
||||
|
||||
if (_Languages[_CurrentLanguage].Texts.TryGetValue(KeyWord, out result))
|
||||
if (_Languages[_CurrentLanguage].Texts.TryGetValue(keyWord, out result))
|
||||
return result;
|
||||
if (_Languages[_FallbackLanguage].Texts.TryGetValue(KeyWord, out result))
|
||||
if (_Languages[_FallbackLanguage].Texts.TryGetValue(keyWord, out result))
|
||||
return result;
|
||||
|
||||
return KeyWord;
|
||||
return keyWord;
|
||||
}
|
||||
|
||||
public static bool TranslationExists(string KeyWord, int PartyModeID = -1)
|
||||
public static bool TranslationExists(string keyWord, int partyModeID = -1)
|
||||
{
|
||||
if (KeyWord == null)
|
||||
if (keyWord == null)
|
||||
return false;
|
||||
|
||||
if (KeyWord.Length < 3 || KeyWord.Substring(0, 3) != "TR_")
|
||||
if (keyWord.Length < 3 || keyWord.Substring(0, 3) != "TR_")
|
||||
return false;
|
||||
|
||||
if (PartyModeID != -1)
|
||||
if (partyModeID != -1)
|
||||
{
|
||||
int PartyModeNr = GetPartyModeNr(PartyModeID, _CurrentLanguage);
|
||||
if (PartyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[PartyModeNr].Texts.ContainsKey(KeyWord))
|
||||
int partyModeNr = _GetPartyModeNr(partyModeID, _CurrentLanguage);
|
||||
if (partyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[partyModeNr].Texts.ContainsKey(keyWord))
|
||||
return true;
|
||||
|
||||
PartyModeNr = GetPartyModeNr(PartyModeID, _FallbackLanguage);
|
||||
if (PartyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[PartyModeNr].Texts.ContainsKey(KeyWord))
|
||||
partyModeNr = _GetPartyModeNr(partyModeID, _FallbackLanguage);
|
||||
if (partyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[partyModeNr].Texts.ContainsKey(keyWord))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_Languages[_CurrentLanguage].Texts.ContainsKey(KeyWord))
|
||||
if (_Languages[_CurrentLanguage].Texts.ContainsKey(keyWord))
|
||||
return true;
|
||||
if (_Languages[_FallbackLanguage].Texts.ContainsKey(KeyWord))
|
||||
if (_Languages[_FallbackLanguage].Texts.ContainsKey(keyWord))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool LoadPartyLanguageFiles(int PartyModeID, string Path)
|
||||
public static bool LoadPartyLanguageFiles(int partyModeID, string path)
|
||||
{
|
||||
List<string> files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(Path, "*.xml", true, true));
|
||||
files.AddRange(CHelper.ListFiles(path, "*.xml", true, true));
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (!LoadPartyLanguageFile(PartyModeID, file))
|
||||
if (!_LoadPartyLanguageFile(partyModeID, file))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool _LoadLanguageEntries(CXMLReader xmlReader, ref Dictionary<string, string> Texts)
|
||||
private static bool _LoadLanguageEntries(CXMLReader xmlReader, ref Dictionary<string, string> texts)
|
||||
{
|
||||
Texts = new Dictionary<string, string>();
|
||||
texts = new Dictionary<string, string>();
|
||||
List<string> names = xmlReader.GetAttributes("resources", "name");
|
||||
string value = string.Empty;
|
||||
foreach (string name in names)
|
||||
@@ -173,7 +173,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
try
|
||||
{
|
||||
Texts.Add(name, value);
|
||||
texts.Add(name, value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -185,7 +185,7 @@ namespace Vocaluxe.Base
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool LoadPartyLanguageFile(int PartyModeID, string file)
|
||||
private static bool _LoadPartyLanguageFile(int partyModeID, string file)
|
||||
{
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(file);
|
||||
if (xmlReader == null)
|
||||
@@ -200,7 +200,7 @@ namespace Vocaluxe.Base
|
||||
return true;
|
||||
|
||||
SPartyLanguage lang = new SPartyLanguage();
|
||||
lang.PartyModeID = PartyModeID;
|
||||
lang.PartyModeID = partyModeID;
|
||||
if (!_LoadLanguageEntries(xmlReader, ref lang.Texts))
|
||||
return false;
|
||||
|
||||
@@ -214,10 +214,10 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadLanguageFile(string FileName)
|
||||
private static void _LoadLanguageFile(string fileName)
|
||||
{
|
||||
SLanguage lang = new SLanguage();
|
||||
lang.LanguageFilePath = Path.Combine(CSettings.sFolderLanguages, FileName);
|
||||
lang.LanguageFilePath = Path.Combine(CSettings.FolderLanguages, fileName);
|
||||
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(lang.LanguageFilePath);
|
||||
if (xmlReader == null)
|
||||
@@ -239,11 +239,11 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetPartyModeNr(int PartyModeID, int Language)
|
||||
private static int _GetPartyModeNr(int partyModeID, int language)
|
||||
{
|
||||
for (int i = 0; i < _Languages[Language].PartyModeTexts.Count; i++)
|
||||
for (int i = 0; i < _Languages[language].PartyModeTexts.Count; i++)
|
||||
{
|
||||
if (_Languages[Language].PartyModeTexts[i].PartyModeID == PartyModeID)
|
||||
if (_Languages[language].PartyModeTexts[i].PartyModeID == partyModeID)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
||||
+43
-44
@@ -5,49 +5,48 @@ using System.Text;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
{
|
||||
class Log : IDisposable
|
||||
class CLogFile : IDisposable
|
||||
{
|
||||
private readonly string _LogFileName;
|
||||
private readonly string _LogName;
|
||||
private StreamWriter _LogFile;
|
||||
|
||||
public Log(string FileName, string LogName)
|
||||
public CLogFile(string fileName, string logName)
|
||||
{
|
||||
_LogName = LogName;
|
||||
_LogFileName = FileName;
|
||||
_LogName = logName;
|
||||
_LogFileName = fileName;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (_LogFile != null)
|
||||
if (_LogFile == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
_LogFile.Flush();
|
||||
_LogFile.Close();
|
||||
}
|
||||
catch (Exception) {}
|
||||
_LogFile.Flush();
|
||||
_LogFile.Close();
|
||||
}
|
||||
catch (Exception) {}
|
||||
}
|
||||
|
||||
public void Add(string Text)
|
||||
public void Add(string text)
|
||||
{
|
||||
if (_LogFile == null)
|
||||
Open();
|
||||
_Open();
|
||||
|
||||
try
|
||||
{
|
||||
_LogFile.WriteLine(Text);
|
||||
_LogFile.WriteLine(text);
|
||||
_LogFile.Flush();
|
||||
}
|
||||
catch (Exception) {}
|
||||
}
|
||||
|
||||
private void Open()
|
||||
private void _Open()
|
||||
{
|
||||
_LogFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, _LogFileName), false, Encoding.UTF8);
|
||||
|
||||
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now.ToString());
|
||||
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
|
||||
_LogFile.WriteLine("----------------------------------------");
|
||||
_LogFile.WriteLine();
|
||||
}
|
||||
@@ -65,24 +64,24 @@ namespace Vocaluxe.Base
|
||||
|
||||
static class CLog
|
||||
{
|
||||
private const int MAXBenchmarks = 10;
|
||||
private const int _MaxBenchmarks = 10;
|
||||
|
||||
private static Log _ErrorLog;
|
||||
private static Log _PerformanceLog;
|
||||
private static Log _BenchmarkLog;
|
||||
private static CLogFile _ErrorLog;
|
||||
private static CLogFile _PerformanceLog;
|
||||
private static CLogFile _BenchmarkLog;
|
||||
|
||||
private static int _NumErrors;
|
||||
private static Stopwatch[] _BenchmarkTimer;
|
||||
private static readonly double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
private static readonly double _NanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_ErrorLog = new Log(CSettings.sFileErrorLog, "ErrorLog");
|
||||
_PerformanceLog = new Log(CSettings.sFilePerformanceLog, "PerformanceLog");
|
||||
_BenchmarkLog = new Log(CSettings.sFileBenchmarkLog, "BenchmarkLog");
|
||||
_ErrorLog = new CLogFile(CSettings.FileErrorLog, "ErrorLog");
|
||||
_PerformanceLog = new CLogFile(CSettings.FilePerformanceLog, "PerformanceLog");
|
||||
_BenchmarkLog = new CLogFile(CSettings.FileBenchmarkLog, "BenchmarkLog");
|
||||
|
||||
_NumErrors = 0;
|
||||
_BenchmarkTimer = new Stopwatch[MAXBenchmarks];
|
||||
_BenchmarkTimer = new Stopwatch[_MaxBenchmarks];
|
||||
for (int i = 0; i < _BenchmarkTimer.Length; i++)
|
||||
_BenchmarkTimer[i] = new Stopwatch();
|
||||
}
|
||||
@@ -95,57 +94,57 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
#region LogError
|
||||
public static void LogError(string ErrorText)
|
||||
public static void LogError(string errorText)
|
||||
{
|
||||
_NumErrors++;
|
||||
|
||||
_ErrorLog.Add(_NumErrors.ToString() + ") " + ErrorText);
|
||||
_ErrorLog.Add(_NumErrors + ") " + errorText);
|
||||
_ErrorLog.Add(String.Empty);
|
||||
}
|
||||
#endregion LogError
|
||||
|
||||
#region LogPerformance
|
||||
public static void LogPerformance(string Text)
|
||||
public static void LogPerformance(string text)
|
||||
{
|
||||
_PerformanceLog.Add(Text);
|
||||
_PerformanceLog.Add(text);
|
||||
_PerformanceLog.Add("-------------------------------");
|
||||
}
|
||||
#endregion LogPerformance
|
||||
|
||||
#region LogBenchmark
|
||||
public static void StartBenchmark(int BenchmarkNr, string Text)
|
||||
public static void StartBenchmark(int benchmarkNr, string text)
|
||||
{
|
||||
if (BenchmarkNr >= 0 && BenchmarkNr < MAXBenchmarks)
|
||||
if (benchmarkNr >= 0 && benchmarkNr < _MaxBenchmarks)
|
||||
{
|
||||
_BenchmarkTimer[BenchmarkNr].Stop();
|
||||
_BenchmarkTimer[BenchmarkNr].Reset();
|
||||
_BenchmarkTimer[benchmarkNr].Stop();
|
||||
_BenchmarkTimer[benchmarkNr].Reset();
|
||||
|
||||
string space = String.Empty;
|
||||
for (int i = 0; i < BenchmarkNr; i++)
|
||||
for (int i = 0; i < benchmarkNr; i++)
|
||||
space += " ";
|
||||
_BenchmarkLog.Add(space + "Start " + Text);
|
||||
_BenchmarkLog.Add(space + "Start " + text);
|
||||
|
||||
_BenchmarkTimer[BenchmarkNr].Start();
|
||||
_BenchmarkTimer[benchmarkNr].Start();
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopBenchmark(int BenchmarkNr, string Text)
|
||||
public static void StopBenchmark(int benchmarkNr, string text)
|
||||
{
|
||||
if (BenchmarkNr >= 0 && BenchmarkNr < MAXBenchmarks)
|
||||
if (benchmarkNr >= 0 && benchmarkNr < _MaxBenchmarks)
|
||||
{
|
||||
_BenchmarkTimer[BenchmarkNr].Stop();
|
||||
_BenchmarkTimer[benchmarkNr].Stop();
|
||||
|
||||
string space = String.Empty;
|
||||
for (int i = 0; i < BenchmarkNr; i++)
|
||||
for (int i = 0; i < benchmarkNr; i++)
|
||||
space += " ";
|
||||
|
||||
float ms;
|
||||
if (Stopwatch.IsHighResolution && nanosecPerTick != 0.0)
|
||||
ms = (float)((nanosecPerTick * _BenchmarkTimer[BenchmarkNr].ElapsedTicks) / (1000.0 * 1000.0));
|
||||
if (Stopwatch.IsHighResolution && _NanosecPerTick != 0.0)
|
||||
ms = (float)((_NanosecPerTick * _BenchmarkTimer[benchmarkNr].ElapsedTicks) / (1000.0 * 1000.0));
|
||||
else
|
||||
ms = _BenchmarkTimer[BenchmarkNr].ElapsedMilliseconds;
|
||||
ms = _BenchmarkTimer[benchmarkNr].ElapsedMilliseconds;
|
||||
|
||||
_BenchmarkLog.Add(space + "Stop " + Text + ", Elapsed Time: " + ms.ToString("0.000") + "ms");
|
||||
_BenchmarkLog.Add(space + "Stop " + text + ", Elapsed Time: " + ms.ToString("0.000") + "ms");
|
||||
_BenchmarkLog.Add(String.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
+195
-195
@@ -8,26 +8,26 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
static class CMain
|
||||
{
|
||||
public static IConfig Config = new BConfig();
|
||||
public static ISettings Settings = new BSettings();
|
||||
public static ITheme Theme = new BTheme();
|
||||
public static IHelper Helper = new BHelper();
|
||||
public static IBackgroundMusic BackgroundMusic = new BBackgroundMusic();
|
||||
public static IDrawing Draw = new BDraw();
|
||||
public static IGraphics Graphics = new BGraphics();
|
||||
public static ILog Log = new BLog();
|
||||
public static IFonts Fonts = new BFonts();
|
||||
public static ILanguage Language = new BLanguage();
|
||||
public static IGame Game = new BGame();
|
||||
public static IProfiles Profiles = new BProfiles();
|
||||
public static IRecording Record = new BRecord();
|
||||
public static ISongs Songs = new BSongs();
|
||||
public static IVideo Video = new BVideo();
|
||||
public static ISound Sound = new BSound();
|
||||
public static ICover Cover = new BCover();
|
||||
public static IDataBase DataBase = new BDataBase();
|
||||
public static IInputs Input = new BInputs();
|
||||
public static IPlaylist Playlist = new BPlaylist();
|
||||
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();
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
@@ -36,16 +36,16 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class BConfig : IConfig
|
||||
class CBconfig : IConfig
|
||||
{
|
||||
public void SetBackgroundMusicVolume(int NewVolume)
|
||||
public void SetBackgroundMusicVolume(int newVolume)
|
||||
{
|
||||
if (NewVolume < 0)
|
||||
if (newVolume < 0)
|
||||
CConfig.BackgroundMusicVolume = 0;
|
||||
else if (NewVolume > 100)
|
||||
else if (newVolume > 100)
|
||||
CConfig.BackgroundMusicVolume = 100;
|
||||
else
|
||||
CConfig.BackgroundMusicVolume = NewVolume;
|
||||
CConfig.BackgroundMusicVolume = newVolume;
|
||||
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
@@ -115,9 +115,9 @@ namespace Vocaluxe.Base
|
||||
return CConfig.IgnoreArticles;
|
||||
}
|
||||
|
||||
public bool IsMicConfigured(int PlayerNr)
|
||||
public bool IsMicConfigured(int playerNr)
|
||||
{
|
||||
return CConfig.IsMicConfig(PlayerNr);
|
||||
return CConfig.IsMicConfig(playerNr);
|
||||
}
|
||||
|
||||
public int GetMaxNumMics()
|
||||
@@ -134,16 +134,16 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class BSettings : ISettings
|
||||
class CBsettings : ISettings
|
||||
{
|
||||
public int GetRenderW()
|
||||
{
|
||||
return CSettings.iRenderW;
|
||||
return CSettings.RenderW;
|
||||
}
|
||||
|
||||
public int GetRenderH()
|
||||
{
|
||||
return CSettings.iRenderH;
|
||||
return CSettings.RenderH;
|
||||
}
|
||||
|
||||
public bool IsTabNavigation()
|
||||
@@ -153,12 +153,12 @@ namespace Vocaluxe.Base
|
||||
|
||||
public float GetZFar()
|
||||
{
|
||||
return CSettings.zFar;
|
||||
return CSettings.ZFar;
|
||||
}
|
||||
|
||||
public float GetZNear()
|
||||
{
|
||||
return CSettings.zNear;
|
||||
return CSettings.ZNear;
|
||||
}
|
||||
|
||||
public EGameState GetGameState()
|
||||
@@ -207,51 +207,51 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class BTheme : ITheme
|
||||
class CBtheme : ITheme
|
||||
{
|
||||
public string GetThemeScreensPath(int PartyModeID)
|
||||
public string GetThemeScreensPath(int partyModeID)
|
||||
{
|
||||
return CTheme.GetThemeScreensPath(PartyModeID);
|
||||
return CTheme.GetThemeScreensPath(partyModeID);
|
||||
}
|
||||
|
||||
public int GetSkinIndex(int PartyModeID)
|
||||
public int GetSkinIndex(int partyModeID)
|
||||
{
|
||||
return CTheme.GetSkinIndex(PartyModeID);
|
||||
return CTheme.GetSkinIndex(partyModeID);
|
||||
}
|
||||
|
||||
public STexture GetSkinTexture(string TextureName, int PartyModeID)
|
||||
public STexture GetSkinTexture(string textureName, int partyModeID)
|
||||
{
|
||||
return CTheme.GetSkinTexture(TextureName, PartyModeID);
|
||||
return CTheme.GetSkinTexture(textureName, partyModeID);
|
||||
}
|
||||
|
||||
public STexture GetSkinVideoTexture(string VideoName, int PartyModeID)
|
||||
public STexture GetSkinVideoTexture(string videoName, int partyModeID)
|
||||
{
|
||||
return CTheme.GetSkinVideoTexture(VideoName, PartyModeID);
|
||||
return CTheme.GetSkinVideoTexture(videoName, partyModeID);
|
||||
}
|
||||
|
||||
public void SkinVideoResume(string VideoName, int PartyModeID)
|
||||
public void SkinVideoResume(string videoName, int partyModeID)
|
||||
{
|
||||
CTheme.SkinVideoResume(VideoName, PartyModeID);
|
||||
CTheme.SkinVideoResume(videoName, partyModeID);
|
||||
}
|
||||
|
||||
public void SkinVideoPause(string VideoName, int PartyModeID)
|
||||
public void SkinVideoPause(string videoName, int partyModeID)
|
||||
{
|
||||
CTheme.SkinVideoPause(VideoName, PartyModeID);
|
||||
CTheme.SkinVideoPause(videoName, partyModeID);
|
||||
}
|
||||
|
||||
public SColorF GetColor(string ColorName, int PartyModeID)
|
||||
public SColorF GetColor(string colorName, int partyModeID)
|
||||
{
|
||||
return CTheme.GetColor(ColorName, PartyModeID);
|
||||
return CTheme.GetColor(colorName, partyModeID);
|
||||
}
|
||||
|
||||
public bool GetColor(string ColorName, int SkinIndex, out SColorF Color)
|
||||
public bool GetColor(string colorName, int skinIndex, out SColorF color)
|
||||
{
|
||||
return CTheme.GetColor(ColorName, SkinIndex, out Color);
|
||||
return CTheme.GetColor(colorName, skinIndex, out color);
|
||||
}
|
||||
|
||||
public SColorF GetPlayerColor(int PlayerNr)
|
||||
public SColorF GetPlayerColor(int playerNr)
|
||||
{
|
||||
return CTheme.GetPlayerColor(PlayerNr);
|
||||
return CTheme.GetPlayerColor(playerNr);
|
||||
}
|
||||
|
||||
public void UnloadSkins()
|
||||
@@ -275,9 +275,9 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class BHelper : IHelper {}
|
||||
class CBhelper : IHelper {}
|
||||
|
||||
class BBackgroundMusic : IBackgroundMusic
|
||||
class CBbackgroundMusic : IBackgroundMusic
|
||||
{
|
||||
public bool IsDisabled()
|
||||
{
|
||||
@@ -299,9 +299,9 @@ namespace Vocaluxe.Base
|
||||
return CBackgroundMusic.VideoEnabled;
|
||||
}
|
||||
|
||||
public void SetStatus(bool Disabled)
|
||||
public void SetStatus(bool disabled)
|
||||
{
|
||||
CBackgroundMusic.Disabled = Disabled;
|
||||
CBackgroundMusic.Disabled = disabled;
|
||||
}
|
||||
|
||||
public void Next()
|
||||
@@ -335,55 +335,55 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class BDraw : IDrawing
|
||||
class CBdraw : IDrawing
|
||||
{
|
||||
public RectangleF GetTextBounds(CText text)
|
||||
{
|
||||
return CDraw.GetTextBounds(text);
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture, SRectF Rect)
|
||||
public void DrawTexture(STexture texture, SRectF rect)
|
||||
{
|
||||
CDraw.DrawTexture(Texture, Rect);
|
||||
CDraw.DrawTexture(texture, rect);
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture, SRectF Rect, SColorF Color)
|
||||
public void DrawTexture(STexture texture, SRectF rect, SColorF color)
|
||||
{
|
||||
CDraw.DrawTexture(Texture, Rect, Color);
|
||||
CDraw.DrawTexture(texture, rect, color);
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture, SRectF Rect, SColorF Color, SRectF Bounds)
|
||||
public void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds)
|
||||
{
|
||||
CDraw.DrawTexture(Texture, Rect, Color, Bounds);
|
||||
CDraw.DrawTexture(texture, rect, color, bounds);
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture, SRectF Rect, SColorF Color, SRectF Bounds, bool Mirrored)
|
||||
public void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored)
|
||||
{
|
||||
CDraw.DrawTexture(Texture, Rect, Color, Bounds, Mirrored);
|
||||
CDraw.DrawTexture(texture, rect, color, bounds, mirrored);
|
||||
}
|
||||
|
||||
public void DrawTextureReflection(STexture Texture, SRectF Rect, SColorF Color, SRectF Bounds, float ReflectionSpace, float ReflectionHeight)
|
||||
public void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float reflectionSpace, float reflectionHeight)
|
||||
{
|
||||
CDraw.DrawTextureReflection(Texture, Rect, Color, Bounds, ReflectionSpace, ReflectionHeight);
|
||||
CDraw.DrawTextureReflection(texture, rect, color, bounds, reflectionSpace, reflectionHeight);
|
||||
}
|
||||
|
||||
public void RemoveTexture(ref STexture Texture)
|
||||
public void RemoveTexture(ref STexture texture)
|
||||
{
|
||||
CDraw.RemoveTexture(ref Texture);
|
||||
CDraw.RemoveTexture(ref texture);
|
||||
}
|
||||
|
||||
public void DrawColor(SColorF Color, SRectF Rect)
|
||||
public void DrawColor(SColorF color, SRectF rect)
|
||||
{
|
||||
CDraw.DrawColor(Color, Rect);
|
||||
CDraw.DrawColor(color, rect);
|
||||
}
|
||||
|
||||
public void DrawColorReflection(SColorF Color, SRectF Rect, float Space, float Height)
|
||||
public void DrawColorReflection(SColorF color, SRectF rect, float space, float height)
|
||||
{
|
||||
CDraw.DrawColorReflection(Color, Rect, Space, Height);
|
||||
CDraw.DrawColorReflection(color, rect, space, height);
|
||||
}
|
||||
}
|
||||
|
||||
class BGraphics : IGraphics
|
||||
class CBGraphics : IGraphics
|
||||
{
|
||||
public void ReloadTheme()
|
||||
{
|
||||
@@ -395,9 +395,9 @@ namespace Vocaluxe.Base
|
||||
CGraphics.SaveTheme();
|
||||
}
|
||||
|
||||
public void FadeTo(EScreens NextScreen)
|
||||
public void FadeTo(EScreens nextScreen)
|
||||
{
|
||||
CGraphics.FadeTo(NextScreen);
|
||||
CGraphics.FadeTo(nextScreen);
|
||||
}
|
||||
|
||||
public float GetGlobalAlpha()
|
||||
@@ -406,75 +406,75 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class BLog : ILog
|
||||
class CBlog : ILog
|
||||
{
|
||||
public void LogError(string ErrorText)
|
||||
public void LogError(string errorText)
|
||||
{
|
||||
CLog.LogError(ErrorText);
|
||||
CLog.LogError(errorText);
|
||||
}
|
||||
}
|
||||
|
||||
class BFonts : IFonts
|
||||
class CBfonts : IFonts
|
||||
{
|
||||
public void SetFont(string FontName)
|
||||
public void SetFont(string fontName)
|
||||
{
|
||||
CFonts.SetFont(FontName);
|
||||
CFonts.SetFont(fontName);
|
||||
}
|
||||
|
||||
public void SetStyle(EStyle FontStyle)
|
||||
public void SetStyle(EStyle fontStyle)
|
||||
{
|
||||
CFonts.Style = FontStyle;
|
||||
CFonts.Style = fontStyle;
|
||||
}
|
||||
|
||||
public RectangleF GetTextBounds(CText Text, float TextHeight)
|
||||
public RectangleF GetTextBounds(CText text, float textHeight)
|
||||
{
|
||||
return CFonts.GetTextBounds(Text, TextHeight);
|
||||
return CFonts.GetTextBounds(text, textHeight);
|
||||
}
|
||||
|
||||
public void DrawText(string Text, float TextHeight, float x, float y, float z, SColorF Color)
|
||||
public void DrawText(string text, float textHeight, float x, float y, float z, SColorF color)
|
||||
{
|
||||
CFonts.DrawText(Text, TextHeight, x, y, z, Color);
|
||||
CFonts.DrawText(text, textHeight, x, y, z, color);
|
||||
}
|
||||
|
||||
public void DrawTextReflection(string Text, float TextHeight, float x, float y, float z, SColorF Color, float ReflectionSpace, float ReflectionHeight)
|
||||
public void DrawTextReflection(string text, float textHeight, float x, float y, float z, SColorF color, float reflectionSpace, float reflectionHeight)
|
||||
{
|
||||
CFonts.DrawTextReflection(Text, TextHeight, x, y, z, Color, ReflectionSpace, ReflectionHeight);
|
||||
CFonts.DrawTextReflection(text, textHeight, x, y, z, color, reflectionSpace, reflectionHeight);
|
||||
}
|
||||
|
||||
public void DrawText(string Text, float TextHeight, float x, float y, float z, SColorF Color, float Begin, float End)
|
||||
public void DrawText(string text, float textHeight, float x, float y, float z, SColorF color, float begin, float end)
|
||||
{
|
||||
CFonts.DrawText(Text, TextHeight, x, y, z, Color, Begin, End);
|
||||
CFonts.DrawText(text, textHeight, x, y, z, color, begin, end);
|
||||
}
|
||||
}
|
||||
|
||||
class BLanguage : ILanguage
|
||||
class CBlanguage : ILanguage
|
||||
{
|
||||
public string Translate(string KeyWord)
|
||||
public string Translate(string keyWord)
|
||||
{
|
||||
return CLanguage.Translate(KeyWord);
|
||||
return CLanguage.Translate(keyWord);
|
||||
}
|
||||
|
||||
public string Translate(string KeyWord, int PartyModeID)
|
||||
public string Translate(string keyWord, int partyModeID)
|
||||
{
|
||||
return CLanguage.Translate(KeyWord, PartyModeID);
|
||||
return CLanguage.Translate(keyWord, partyModeID);
|
||||
}
|
||||
|
||||
public bool TranslationExists(string KeyWord)
|
||||
public bool TranslationExists(string keyWord)
|
||||
{
|
||||
return CLanguage.TranslationExists(KeyWord);
|
||||
return CLanguage.TranslationExists(keyWord);
|
||||
}
|
||||
}
|
||||
|
||||
class BGame : IGame
|
||||
class CBGame : IGame
|
||||
{
|
||||
public int GetNumPlayer()
|
||||
{
|
||||
return CGame.NumPlayer;
|
||||
}
|
||||
|
||||
public void SetNumPlayer(int NumPlayer)
|
||||
public void SetNumPlayer(int numPlayer)
|
||||
{
|
||||
CGame.NumPlayer = NumPlayer;
|
||||
CGame.NumPlayer = numPlayer;
|
||||
}
|
||||
|
||||
public SPlayer[] GetPlayer()
|
||||
@@ -497,9 +497,9 @@ namespace Vocaluxe.Base
|
||||
return CGame.ActBeatD;
|
||||
}
|
||||
|
||||
public int GetRandom(int Max)
|
||||
public int GetRandom(int max)
|
||||
{
|
||||
return CGame.Rand.Next(Max);
|
||||
return CGame.Rand.Next(max);
|
||||
}
|
||||
|
||||
public double GetRandomDouble()
|
||||
@@ -507,14 +507,14 @@ namespace Vocaluxe.Base
|
||||
return CGame.Rand.NextDouble();
|
||||
}
|
||||
|
||||
public float GetTimeFromBeats(float Beat, float BPM)
|
||||
public float GetTimeFromBeats(float beat, float bpm)
|
||||
{
|
||||
return CGame.GetTimeFromBeats(Beat, BPM);
|
||||
return CGame.GetTimeFromBeats(beat, bpm);
|
||||
}
|
||||
|
||||
public void AddSong(int SongID, EGameMode GameMode)
|
||||
public void AddSong(int songID, EGameMode gameMode)
|
||||
{
|
||||
CGame.AddSong(SongID, GameMode);
|
||||
CGame.AddSong(songID, gameMode);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
@@ -533,7 +533,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class BProfiles : IProfiles
|
||||
class CBprofiles : IProfiles
|
||||
{
|
||||
public SProfile[] GetProfiles()
|
||||
{
|
||||
@@ -541,15 +541,15 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class BRecord : IRecording
|
||||
class CBrecord : IRecording
|
||||
{
|
||||
public int GetToneAbs(int PlayerNr)
|
||||
public int GetToneAbs(int playerNr)
|
||||
{
|
||||
return CSound.RecordGetToneAbs(PlayerNr);
|
||||
return CSound.RecordGetToneAbs(playerNr);
|
||||
}
|
||||
}
|
||||
|
||||
class BSongs : ISongs
|
||||
class CBsongs : ISongs
|
||||
{
|
||||
public int GetNumSongs()
|
||||
{
|
||||
@@ -566,9 +566,9 @@ namespace Vocaluxe.Base
|
||||
return CSongs.NumCategories;
|
||||
}
|
||||
|
||||
public int NumSongsInCategory(int CategoryIndex)
|
||||
public int NumSongsInCategory(int categoryIndex)
|
||||
{
|
||||
return CSongs.NumSongsInCategory(CategoryIndex);
|
||||
return CSongs.NumSongsInCategory(categoryIndex);
|
||||
}
|
||||
|
||||
public int GetCurrentCategoryIndex()
|
||||
@@ -586,9 +586,9 @@ namespace Vocaluxe.Base
|
||||
return CSongs.Filter.SearchString;
|
||||
}
|
||||
|
||||
public void SetCategory(int CategoryIndex)
|
||||
public void SetCategory(int categoryIndex)
|
||||
{
|
||||
CSongs.Category = CategoryIndex;
|
||||
CSongs.Category = categoryIndex;
|
||||
}
|
||||
|
||||
public void UpdateRandomSongList()
|
||||
@@ -596,14 +596,14 @@ namespace Vocaluxe.Base
|
||||
CSongs.UpdateRandomSongList();
|
||||
}
|
||||
|
||||
public CSong GetVisibleSong(int VisibleIndex)
|
||||
public CSong GetVisibleSong(int visibleIndex)
|
||||
{
|
||||
return CSongs.GetVisibleSongByIndex(VisibleIndex);
|
||||
return CSongs.GetVisibleSongByIndex(visibleIndex);
|
||||
}
|
||||
|
||||
public CSong GetSongByID(int SongID)
|
||||
public CSong GetSongByID(int songID)
|
||||
{
|
||||
return CSongs.GetSong(SongID);
|
||||
return CSongs.GetSong(songID);
|
||||
}
|
||||
|
||||
public CSong[] GetSongs()
|
||||
@@ -616,17 +616,17 @@ namespace Vocaluxe.Base
|
||||
return CSongs.SongsNotSung;
|
||||
}
|
||||
|
||||
public CCategory GetCategory(int Index)
|
||||
public CCategory GetCategory(int index)
|
||||
{
|
||||
if (Index >= CSongs.NumCategories)
|
||||
if (index >= CSongs.NumCategories)
|
||||
return null;
|
||||
|
||||
return new CCategory(CSongs.Categories[Index]);
|
||||
return new CCategory(CSongs.Categories[index]);
|
||||
}
|
||||
|
||||
public void AddPartySongSung(int SongID)
|
||||
public void AddPartySongSung(int songID)
|
||||
{
|
||||
CSongs.AddPartySongSung(SongID);
|
||||
CSongs.AddPartySongSung(songID);
|
||||
}
|
||||
|
||||
public void ResetPartySongSung()
|
||||
@@ -634,14 +634,14 @@ namespace Vocaluxe.Base
|
||||
CSongs.ResetPartySongSung();
|
||||
}
|
||||
|
||||
public void ResetPartySongSung(int CatIndex)
|
||||
public void ResetPartySongSung(int catIndex)
|
||||
{
|
||||
CSongs.ResetPartySongSung(CatIndex);
|
||||
CSongs.ResetPartySongSung(catIndex);
|
||||
}
|
||||
|
||||
public void SortSongs(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, String SearchString, EDuetOptions DuetOptions)
|
||||
public void SortSongs(ESongSorting sorting, EOffOn tabs, EOffOn ignoreArticles, String searchString, EDuetOptions duetOptions)
|
||||
{
|
||||
CSongs.Sort(Sorting, Tabs, IgnoreArticles, SearchString, DuetOptions);
|
||||
CSongs.Sort(sorting, tabs, ignoreArticles, searchString, duetOptions);
|
||||
}
|
||||
|
||||
public void NextCategory()
|
||||
@@ -655,88 +655,88 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class BVideo : IVideo
|
||||
class CBvideo : IVideo
|
||||
{
|
||||
public int Load(string VideoFileName)
|
||||
public int Load(string videoFileName)
|
||||
{
|
||||
return CVideo.VdLoad(VideoFileName);
|
||||
return CVideo.VdLoad(videoFileName);
|
||||
}
|
||||
|
||||
public bool Skip(int VideoStream, float StartPosition, float VideoGap)
|
||||
public bool Skip(int videoStream, float startPosition, float videoGap)
|
||||
{
|
||||
return CVideo.VdSkip(VideoStream, StartPosition, VideoGap);
|
||||
return CVideo.VdSkip(videoStream, startPosition, videoGap);
|
||||
}
|
||||
|
||||
public bool GetFrame(int VideoStream, ref STexture VideoTexture, float Time, ref float VideoTime)
|
||||
public bool GetFrame(int videoStream, ref STexture videoTexture, float time, ref float videoTime)
|
||||
{
|
||||
return CVideo.VdGetFrame(VideoStream, ref VideoTexture, Time, ref VideoTime);
|
||||
return CVideo.VdGetFrame(videoStream, ref videoTexture, time, ref videoTime);
|
||||
}
|
||||
|
||||
public bool IsFinished(int VideoStream)
|
||||
public bool IsFinished(int videoStream)
|
||||
{
|
||||
return CVideo.VdFinished(VideoStream);
|
||||
return CVideo.VdFinished(videoStream);
|
||||
}
|
||||
|
||||
public bool Close(int VideoStream)
|
||||
public bool Close(int videoStream)
|
||||
{
|
||||
return CVideo.VdClose(VideoStream);
|
||||
return CVideo.VdClose(videoStream);
|
||||
}
|
||||
}
|
||||
|
||||
class BSound : ISound
|
||||
class CBsound : ISound
|
||||
{
|
||||
public int Load(string SoundFile, bool Prescan)
|
||||
public int Load(string soundFile, bool prescan)
|
||||
{
|
||||
return CSound.Load(SoundFile, Prescan);
|
||||
return CSound.Load(soundFile, prescan);
|
||||
}
|
||||
|
||||
public void SetPosition(int SoundStream, float NewPosition)
|
||||
public void SetPosition(int soundStream, float newPosition)
|
||||
{
|
||||
CSound.SetPosition(SoundStream, NewPosition);
|
||||
CSound.SetPosition(soundStream, newPosition);
|
||||
}
|
||||
|
||||
public void Play(int SoundStream)
|
||||
public void Play(int soundStream)
|
||||
{
|
||||
CSound.Play(SoundStream);
|
||||
CSound.Play(soundStream);
|
||||
}
|
||||
|
||||
public void Fade(int SoundStream, float TargetVolume, float Duration)
|
||||
public void Fade(int soundStream, float targetVolume, float duration)
|
||||
{
|
||||
CSound.Fade(SoundStream, TargetVolume, Duration);
|
||||
CSound.Fade(soundStream, targetVolume, duration);
|
||||
}
|
||||
|
||||
public bool IsFinished(int SoundStream)
|
||||
public bool IsFinished(int soundStream)
|
||||
{
|
||||
return CSound.IsFinished(SoundStream);
|
||||
return CSound.IsFinished(soundStream);
|
||||
}
|
||||
|
||||
public float GetPosition(int SoundStream)
|
||||
public float GetPosition(int soundStream)
|
||||
{
|
||||
return CSound.GetPosition(SoundStream);
|
||||
return CSound.GetPosition(soundStream);
|
||||
}
|
||||
|
||||
public float GetLength(int SoundStream)
|
||||
public float GetLength(int soundStream)
|
||||
{
|
||||
return CSound.GetLength(SoundStream);
|
||||
return CSound.GetLength(soundStream);
|
||||
}
|
||||
|
||||
public void FadeAndStop(int SoundStream, float TargetVolume, float Duration)
|
||||
public void FadeAndStop(int soundStream, float targetVolume, float duration)
|
||||
{
|
||||
CSound.FadeAndStop(SoundStream, TargetVolume, Duration);
|
||||
CSound.FadeAndStop(soundStream, targetVolume, duration);
|
||||
}
|
||||
|
||||
public void SetStreamVolume(int SoundStream, float Volume)
|
||||
public void SetStreamVolume(int soundStream, float volume)
|
||||
{
|
||||
CSound.SetStreamVolume(SoundStream, Volume);
|
||||
CSound.SetStreamVolume(soundStream, volume);
|
||||
}
|
||||
|
||||
public void SetStreamVolumeMax(int SoundStream, float MaxVolume)
|
||||
public void SetStreamVolumeMax(int soundStream, float maxVolume)
|
||||
{
|
||||
CSound.SetStreamVolumeMax(SoundStream, MaxVolume);
|
||||
CSound.SetStreamVolumeMax(soundStream, maxVolume);
|
||||
}
|
||||
}
|
||||
|
||||
class BCover : ICover
|
||||
class CBcover : ICover
|
||||
{
|
||||
public STexture GetNoCover()
|
||||
{
|
||||
@@ -744,27 +744,27 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class BDataBase : IDataBase
|
||||
class CBdataBase : IDataBase
|
||||
{
|
||||
public bool GetCover(string FileName, ref STexture Texture, int CoverSize)
|
||||
public bool GetCover(string fileName, ref STexture texture, int coverSize)
|
||||
{
|
||||
return CDataBase.GetCover(FileName, ref Texture, CoverSize);
|
||||
return CDataBase.GetCover(fileName, ref texture, coverSize);
|
||||
}
|
||||
}
|
||||
|
||||
class BInputs : IInputs
|
||||
class CBinputs : IInputs
|
||||
{
|
||||
public void SetRumble(float Duration)
|
||||
public void SetRumble(float duration)
|
||||
{
|
||||
CInput.SetRumble(Duration);
|
||||
CInput.SetRumble(duration);
|
||||
}
|
||||
}
|
||||
|
||||
class BPlaylist : IPlaylist
|
||||
class CBplaylist : IPlaylist
|
||||
{
|
||||
public void SetPlaylistName(int PlaylistID, string Name)
|
||||
public void SetPlaylistName(int playlistID, string name)
|
||||
{
|
||||
CPlaylists.SetPlaylistName(PlaylistID, Name);
|
||||
CPlaylists.SetPlaylistName(playlistID, name);
|
||||
}
|
||||
|
||||
public string[] GetPlaylistNames()
|
||||
@@ -772,19 +772,19 @@ namespace Vocaluxe.Base
|
||||
return CPlaylists.GetPlaylistNames();
|
||||
}
|
||||
|
||||
public string GetPlaylistName(int PlaylistID)
|
||||
public string GetPlaylistName(int playlistID)
|
||||
{
|
||||
return CPlaylists.GetPlaylistName(PlaylistID);
|
||||
return CPlaylists.GetPlaylistName(playlistID);
|
||||
}
|
||||
|
||||
public void DeletePlaylist(int PlaylistID)
|
||||
public void DeletePlaylist(int playlistID)
|
||||
{
|
||||
CPlaylists.DeletePlaylist(PlaylistID);
|
||||
CPlaylists.DeletePlaylist(playlistID);
|
||||
}
|
||||
|
||||
public void SavePlaylist(int PlaylistID)
|
||||
public void SavePlaylist(int playlistID)
|
||||
{
|
||||
CPlaylists.SavePlaylist(PlaylistID);
|
||||
CPlaylists.SavePlaylist(playlistID);
|
||||
}
|
||||
|
||||
public int GetNumPlaylists()
|
||||
@@ -792,49 +792,49 @@ namespace Vocaluxe.Base
|
||||
return CPlaylists.NumPlaylists;
|
||||
}
|
||||
|
||||
public void AddPlaylistSong(int PlaylistID, int SongID)
|
||||
public void AddPlaylistSong(int playlistID, int songID)
|
||||
{
|
||||
CPlaylists.AddPlaylistSong(PlaylistID, SongID);
|
||||
CPlaylists.AddPlaylistSong(playlistID, songID);
|
||||
}
|
||||
|
||||
public void AddPlaylistSong(int PlaylistID, int SongID, EGameMode GameMode)
|
||||
public void AddPlaylistSong(int playlistID, int songID, EGameMode gameMode)
|
||||
{
|
||||
CPlaylists.AddPlaylistSong(PlaylistID, SongID, GameMode);
|
||||
CPlaylists.AddPlaylistSong(playlistID, songID, gameMode);
|
||||
}
|
||||
|
||||
public void InsertPlaylistSong(int PlaylistID, int PositionIndex, int SongID, EGameMode GameMode)
|
||||
public void InsertPlaylistSong(int playlistID, int positionIndex, int songID, EGameMode gameMode)
|
||||
{
|
||||
CPlaylists.InsertPlaylistSong(PlaylistID, PositionIndex, SongID, GameMode);
|
||||
CPlaylists.InsertPlaylistSong(playlistID, positionIndex, songID, gameMode);
|
||||
}
|
||||
|
||||
public void MovePlaylistSong(int PlaylistID, int SourceIndex, int DestIndex)
|
||||
public void MovePlaylistSong(int playlistID, int sourceIndex, int destIndex)
|
||||
{
|
||||
CPlaylists.MovePlaylistSong(PlaylistID, SourceIndex, DestIndex);
|
||||
CPlaylists.MovePlaylistSong(playlistID, sourceIndex, destIndex);
|
||||
}
|
||||
|
||||
public void MovePlaylistSongDown(int PlaylistID, int SongIndex)
|
||||
public void MovePlaylistSongDown(int playlistID, int songIndex)
|
||||
{
|
||||
CPlaylists.MovePlaylistSongDown(PlaylistID, SongIndex);
|
||||
CPlaylists.MovePlaylistSongDown(playlistID, songIndex);
|
||||
}
|
||||
|
||||
public void MovePlaylistSongUp(int PlaylistID, int SongIndex)
|
||||
public void MovePlaylistSongUp(int playlistID, int songIndex)
|
||||
{
|
||||
CPlaylists.MovePlaylistSongUp(PlaylistID, SongIndex);
|
||||
CPlaylists.MovePlaylistSongUp(playlistID, songIndex);
|
||||
}
|
||||
|
||||
public void DeletePlaylistSong(int PlaylistID, int SongIndex)
|
||||
public void DeletePlaylistSong(int playlistID, int songIndex)
|
||||
{
|
||||
CPlaylists.DeletePlaylistSong(PlaylistID, SongIndex);
|
||||
CPlaylists.DeletePlaylistSong(playlistID, songIndex);
|
||||
}
|
||||
|
||||
public int GetPlaylistSongCount(int PlaylistID)
|
||||
public int GetPlaylistSongCount(int playlistID)
|
||||
{
|
||||
return CPlaylists.GetPlaylistSongCount(PlaylistID);
|
||||
return CPlaylists.GetPlaylistSongCount(playlistID);
|
||||
}
|
||||
|
||||
public CPlaylistSong GetPlaylistSong(int PlaylistID, int SongIndex)
|
||||
public CPlaylistSong GetPlaylistSong(int playlistID, int songIndex)
|
||||
{
|
||||
return CPlaylists.GetPlaylistSong(PlaylistID, SongIndex);
|
||||
return CPlaylists.GetPlaylistSong(playlistID, songIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace Vocaluxe.Base
|
||||
public event EventHandler ObjectChanged = delegate { };
|
||||
protected bool _Changed = true;
|
||||
|
||||
protected void NotifyObservers()
|
||||
protected void _NotifyObservers()
|
||||
{
|
||||
ObjectChanged.Invoke(this, null);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace Vocaluxe.Base
|
||||
protected void _SetChanged()
|
||||
{
|
||||
_Changed = true;
|
||||
NotifyObservers();
|
||||
_NotifyObservers();
|
||||
}
|
||||
}
|
||||
}
|
||||
+72
-72
@@ -30,7 +30,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
static class CParty
|
||||
{
|
||||
private const int PartyModeSystemVersion = 1;
|
||||
private const int _PartyModeSystemVersion = 1;
|
||||
|
||||
private static Dictionary<int, SPartyMode> _PartyModes;
|
||||
private static Queue<int> _IDs;
|
||||
@@ -58,7 +58,7 @@ namespace Vocaluxe.Base
|
||||
_CurrentPartyMode = pm;
|
||||
|
||||
//load other party modes
|
||||
LoadPartyModes();
|
||||
_LoadPartyModes();
|
||||
}
|
||||
|
||||
public static int CurrentPartyModeID
|
||||
@@ -81,15 +81,15 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
List<SPartyModeInfos> infos = new List<SPartyModeInfos>();
|
||||
|
||||
int[] UsedKeys = new int[_PartyModes.Count];
|
||||
_PartyModes.Keys.CopyTo(UsedKeys, 0);
|
||||
int[] usedKeys = new int[_PartyModes.Count];
|
||||
_PartyModes.Keys.CopyTo(usedKeys, 0);
|
||||
|
||||
for (int i = 0; i < UsedKeys.Length; i++)
|
||||
for (int i = 0; i < usedKeys.Length; i++)
|
||||
{
|
||||
if (UsedKeys[i] != _NormalGameModeID)
|
||||
if (usedKeys[i] != _NormalGameModeID)
|
||||
{
|
||||
SPartyMode mode = new SPartyMode();
|
||||
_PartyModes.TryGetValue(UsedKeys[i], out mode);
|
||||
_PartyModes.TryGetValue(usedKeys[i], out mode);
|
||||
|
||||
if (mode.PartyMode != null)
|
||||
{
|
||||
@@ -122,17 +122,17 @@ namespace Vocaluxe.Base
|
||||
SetPartyMode(_NormalGameModeID);
|
||||
}
|
||||
|
||||
public static void SetPartyMode(int PartyModeID)
|
||||
public static void SetPartyMode(int partyModeID)
|
||||
{
|
||||
if (!_PartyModes.TryGetValue(PartyModeID, out _CurrentPartyMode))
|
||||
CLog.LogError("CParty: Can't find party mode ID: " + PartyModeID.ToString());
|
||||
if (!_PartyModes.TryGetValue(partyModeID, out _CurrentPartyMode))
|
||||
CLog.LogError("CParty: Can't find party mode ID: " + partyModeID.ToString());
|
||||
|
||||
_CurrentPartyMode.PartyMode.Init();
|
||||
}
|
||||
|
||||
public static CMenu GetNextPartyScreen(out EScreens AlternativeScreen)
|
||||
public static CMenu GetNextPartyScreen(out EScreens alternativeScreen)
|
||||
{
|
||||
return _CurrentPartyMode.PartyMode.GetNextPartyScreen(out AlternativeScreen);
|
||||
return _CurrentPartyMode.PartyMode.GetNextPartyScreen(out alternativeScreen);
|
||||
}
|
||||
#endregion public stuff
|
||||
|
||||
@@ -152,34 +152,34 @@ namespace Vocaluxe.Base
|
||||
return _CurrentPartyMode.PartyMode.GetMainScreen();
|
||||
}
|
||||
|
||||
public static ScreenSongOptions GetSongSelectionOptions()
|
||||
public static SScreenSongOptions GetSongSelectionOptions()
|
||||
{
|
||||
return _CurrentPartyMode.PartyMode.GetScreenSongOptions();
|
||||
}
|
||||
|
||||
public static void OnSongChange(int SongIndex, ref ScreenSongOptions ScreenSongOptions)
|
||||
public static void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
|
||||
{
|
||||
_CurrentPartyMode.PartyMode.OnSongChange(SongIndex, ref ScreenSongOptions);
|
||||
_CurrentPartyMode.PartyMode.OnSongChange(songIndex, ref screenSongOptions);
|
||||
}
|
||||
|
||||
public static void OnCategoryChange(int CategoryIndex, ref ScreenSongOptions ScreenSongOptions)
|
||||
public static void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
|
||||
{
|
||||
_CurrentPartyMode.PartyMode.OnCategoryChange(CategoryIndex, ref ScreenSongOptions);
|
||||
_CurrentPartyMode.PartyMode.OnCategoryChange(categoryIndex, ref screenSongOptions);
|
||||
}
|
||||
|
||||
public static void SetSearchString(string SearchString, bool Visible)
|
||||
public static void SetSearchString(string searchString, bool visible)
|
||||
{
|
||||
_CurrentPartyMode.PartyMode.SetSearchString(SearchString, Visible);
|
||||
_CurrentPartyMode.PartyMode.SetSearchString(searchString, visible);
|
||||
}
|
||||
|
||||
public static void JokerUsed(int TeamNr)
|
||||
public static void JokerUsed(int teamNr)
|
||||
{
|
||||
_CurrentPartyMode.PartyMode.JokerUsed(TeamNr);
|
||||
_CurrentPartyMode.PartyMode.JokerUsed(teamNr);
|
||||
}
|
||||
|
||||
public static void SongSelected(int SongID)
|
||||
public static void SongSelected(int songID)
|
||||
{
|
||||
_CurrentPartyMode.PartyMode.SongSelected(SongID);
|
||||
_CurrentPartyMode.PartyMode.SongSelected(songID);
|
||||
}
|
||||
|
||||
public static void FinishedSinging()
|
||||
@@ -199,19 +199,19 @@ namespace Vocaluxe.Base
|
||||
#endregion Interface
|
||||
|
||||
#region private stuff
|
||||
private static void LoadPartyModes()
|
||||
private static void _LoadPartyModes()
|
||||
{
|
||||
List<string> files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(CSettings.sFolderPartyModes, "*.xml", false, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderPartyModes, "*.xml", false, true));
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
SPartyMode pm = LoadPartyMode(file);
|
||||
SPartyMode pm = _LoadPartyMode(file);
|
||||
_PartyModes.Add(pm.PartyModeID, pm);
|
||||
}
|
||||
}
|
||||
|
||||
private static SPartyMode LoadPartyMode(string file)
|
||||
private static SPartyMode _LoadPartyMode(string file)
|
||||
{
|
||||
SPartyMode pm = new SPartyMode();
|
||||
pm.PartyModeID = _IDs.Dequeue();
|
||||
@@ -243,7 +243,7 @@ namespace Vocaluxe.Base
|
||||
return pm;
|
||||
}
|
||||
|
||||
if (pm.PartyModeSystemVersion != PartyModeSystemVersion)
|
||||
if (pm.PartyModeSystemVersion != _PartyModeSystemVersion)
|
||||
{
|
||||
CLog.LogError("Error loading PartyMode file (wrong PartyModeSystemVersion): " + file);
|
||||
return pm;
|
||||
@@ -255,23 +255,23 @@ namespace Vocaluxe.Base
|
||||
return pm;
|
||||
}
|
||||
|
||||
string PathToCode = Path.Combine(Path.Combine(CSettings.sFolderPartyModes, pm.Folder), CSettings.sFolderPartyModeCode);
|
||||
string pathToCode = Path.Combine(Path.Combine(CSettings.FolderPartyModes, pm.Folder), CSettings.FolderPartyModeCode);
|
||||
|
||||
List<string> FilesToCompile = new List<string>();
|
||||
FilesToCompile.AddRange(CHelper.ListFiles(PathToCode, "*.cs", false, true));
|
||||
List<string> filesToCompile = new List<string>();
|
||||
filesToCompile.AddRange(CHelper.ListFiles(pathToCode, "*.cs", false, true));
|
||||
|
||||
Assembly Output = CompileFiles(FilesToCompile.ToArray());
|
||||
if (Output == null)
|
||||
Assembly output = _CompileFiles(filesToCompile.ToArray());
|
||||
if (output == null)
|
||||
return pm;
|
||||
|
||||
if (!CLanguage.LoadPartyLanguageFiles(pm.PartyModeID, Path.Combine(Path.Combine(CSettings.sFolderPartyModes, pm.Folder), CSettings.sFolderPartyModeLanguages)))
|
||||
if (!CLanguage.LoadPartyLanguageFiles(pm.PartyModeID, Path.Combine(Path.Combine(CSettings.FolderPartyModes, pm.Folder), CSettings.FolderPartyModeLanguages)))
|
||||
{
|
||||
CLog.LogError("Error loading language files for PartyMode: " + file);
|
||||
return pm;
|
||||
}
|
||||
|
||||
object Instance = Output.CreateInstance(typeof(IPartyMode).Namespace + "." + pm.Folder + "." + pm.PartyModeFile);
|
||||
if (Instance == null)
|
||||
object instance = output.CreateInstance(typeof(IPartyMode).Namespace + "." + pm.Folder + "." + pm.PartyModeFile);
|
||||
if (instance == null)
|
||||
{
|
||||
CLog.LogError("Error creating Instance of PartyMode file: " + file);
|
||||
return pm;
|
||||
@@ -279,7 +279,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
try
|
||||
{
|
||||
pm.PartyMode = (IPartyMode)Instance;
|
||||
pm.PartyMode = (IPartyMode)instance;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -288,31 +288,31 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
pm.PartyMode.Initialize();
|
||||
|
||||
if (!CTheme.AddTheme(Path.Combine(Directory.GetCurrentDirectory(), Path.Combine(Path.Combine(CSettings.sFolderPartyModes, pm.Folder), "Theme.xml")), pm.PartyModeID))
|
||||
if (!CTheme.AddTheme(Path.Combine(Directory.GetCurrentDirectory(), Path.Combine(Path.Combine(CSettings.FolderPartyModes, pm.Folder), "Theme.xml")), pm.PartyModeID))
|
||||
return pm;
|
||||
|
||||
int ThemeIndex = CTheme.GetThemeIndex(pm.PartyModeID);
|
||||
CTheme.ListSkins(ThemeIndex);
|
||||
int SkinIndex = CTheme.GetSkinIndex(pm.PartyModeID);
|
||||
int themeIndex = CTheme.GetThemeIndex(pm.PartyModeID);
|
||||
CTheme.ListSkins(themeIndex);
|
||||
int skinIndex = CTheme.GetSkinIndex(pm.PartyModeID);
|
||||
|
||||
if (!CTheme.LoadSkin(SkinIndex))
|
||||
if (!CTheme.LoadSkin(skinIndex))
|
||||
return pm;
|
||||
|
||||
if (!CTheme.LoadTheme(ThemeIndex))
|
||||
if (!CTheme.LoadTheme(themeIndex))
|
||||
return pm;
|
||||
|
||||
foreach (string screenfile in pm.ScreenFiles)
|
||||
{
|
||||
string XmlPath = Path.Combine(Path.Combine(CSettings.sFolderPartyModes, pm.Folder), CSettings.sFolderPartyModeScreens);
|
||||
CMenuParty Screen = GetPartyScreenInstance(Output, screenfile, pm.Folder);
|
||||
string xmlPath = Path.Combine(Path.Combine(CSettings.FolderPartyModes, pm.Folder), CSettings.FolderPartyModeScreens);
|
||||
CMenuParty screen = _GetPartyScreenInstance(output, screenfile, pm.Folder);
|
||||
|
||||
if (Screen != null)
|
||||
if (screen != null)
|
||||
{
|
||||
Screen.Init();
|
||||
Screen.AssingPartyMode(pm.PartyMode);
|
||||
Screen.SetPartyModeID(pm.PartyModeID);
|
||||
Screen.LoadTheme(XmlPath);
|
||||
pm.PartyMode.AddScreen(Screen, screenfile);
|
||||
screen.Init();
|
||||
screen.AssingPartyMode(pm.PartyMode);
|
||||
screen.SetPartyModeID(pm.PartyModeID);
|
||||
screen.LoadTheme(xmlPath);
|
||||
pm.PartyMode.AddScreen(screen, screenfile);
|
||||
}
|
||||
else
|
||||
return pm;
|
||||
@@ -322,7 +322,7 @@ namespace Vocaluxe.Base
|
||||
return pm;
|
||||
}
|
||||
|
||||
private static Assembly CompileFiles(string[] files)
|
||||
private static Assembly _CompileFiles(string[] files)
|
||||
{
|
||||
if (files == null)
|
||||
return null;
|
||||
@@ -330,21 +330,21 @@ namespace Vocaluxe.Base
|
||||
if (files.Length == 0)
|
||||
return null;
|
||||
|
||||
CompilerParameters Params = new CompilerParameters();
|
||||
Params.ReferencedAssemblies.Add("System.Windows.Forms.dll");
|
||||
Params.ReferencedAssemblies.Add("VocaluxeLib.dll");
|
||||
Params.GenerateInMemory = true;
|
||||
CompilerParameters compilerParams = new CompilerParameters();
|
||||
compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("VocaluxeLib.dll");
|
||||
compilerParams.GenerateInMemory = true;
|
||||
#if DEBUG
|
||||
Params.IncludeDebugInformation = true;
|
||||
compilerParams.IncludeDebugInformation = true;
|
||||
#endif
|
||||
|
||||
using (CodeDomProvider CDP = CodeDomProvider.CreateProvider("CSharp"))
|
||||
using (CodeDomProvider cdp = CodeDomProvider.CreateProvider("CSharp"))
|
||||
{
|
||||
CompilerResults CompileResult = null;
|
||||
CompilerResults compileResult = null;
|
||||
|
||||
try
|
||||
{
|
||||
CompileResult = CDP.CompileAssemblyFromFile(Params, files);
|
||||
compileResult = cdp.CompileAssemblyFromFile(compilerParams, files);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -352,39 +352,39 @@ namespace Vocaluxe.Base
|
||||
return null;
|
||||
}
|
||||
|
||||
if (CompileResult.Errors.Count > 0)
|
||||
if (compileResult.Errors.Count > 0)
|
||||
{
|
||||
foreach (CompilerError e in CompileResult.Errors)
|
||||
foreach (CompilerError e in compileResult.Errors)
|
||||
CLog.LogError("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + e.ErrorText + " in '" + e.FileName + "' (" + e.Line + ")");
|
||||
return null;
|
||||
}
|
||||
return CompileResult.CompiledAssembly;
|
||||
return compileResult.CompiledAssembly;
|
||||
}
|
||||
}
|
||||
|
||||
private static CMenuParty GetPartyScreenInstance(Assembly Assembly, string ScreenName, string partyModeName)
|
||||
private static CMenuParty _GetPartyScreenInstance(Assembly assembly, string screenName, string partyModeName)
|
||||
{
|
||||
if (Assembly == null)
|
||||
if (assembly == null)
|
||||
return null;
|
||||
|
||||
object Instance = Assembly.CreateInstance(typeof(IPartyMode).Namespace + "." + partyModeName + "." + ScreenName);
|
||||
if (Instance == null)
|
||||
object instance = assembly.CreateInstance(typeof(IPartyMode).Namespace + "." + partyModeName + "." + screenName);
|
||||
if (instance == null)
|
||||
{
|
||||
CLog.LogError("Error creating Instance of PartyScreen: " + ScreenName);
|
||||
CLog.LogError("Error creating Instance of PartyScreen: " + screenName);
|
||||
return null;
|
||||
}
|
||||
|
||||
CMenuParty Screen = null;
|
||||
CMenuParty screen = null;
|
||||
try
|
||||
{
|
||||
Screen = (CMenuParty)Instance;
|
||||
screen = (CMenuParty)instance;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error casting PartyScreen: " + ScreenName + "; " + e.Message);
|
||||
CLog.LogError("Error casting PartyScreen: " + screenName + "; " + e.Message);
|
||||
return null;
|
||||
}
|
||||
return Screen;
|
||||
return screen;
|
||||
}
|
||||
#endregion private stuff
|
||||
}
|
||||
|
||||
+62
-62
@@ -38,17 +38,17 @@ namespace Vocaluxe.Base
|
||||
LoadPlaylists();
|
||||
ConvertUSDXPlaylists();
|
||||
|
||||
SortPlaylistsByName();
|
||||
_SortPlaylistsByName();
|
||||
}
|
||||
|
||||
public static void ConvertUSDXPlaylists()
|
||||
{
|
||||
List<string> files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(CSettings.sFolderPlaylists, "*.upl", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderPlaylists, "*.upl", true, true));
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
CPlaylistFile playlist = ConvertUSDXPlaylist(file);
|
||||
CPlaylistFile playlist = _ConvertUSDXPlaylist(file);
|
||||
playlist.SavePlaylist();
|
||||
_Playlists.Add(playlist);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
_Playlists = new List<CPlaylistFile>();
|
||||
List<string> files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(CSettings.sFolderPlaylists, "*.xml", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderPlaylists, "*.xml", true, true));
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
@@ -67,12 +67,12 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetPlaylistName(int PlaylistID)
|
||||
public static string GetPlaylistName(int playlistID)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return "Error: Can't find Playlist";
|
||||
|
||||
return _Playlists[PlaylistID].PlaylistName;
|
||||
return _Playlists[playlistID].PlaylistName;
|
||||
}
|
||||
|
||||
public static string[] GetPlaylistNames()
|
||||
@@ -85,37 +85,37 @@ namespace Vocaluxe.Base
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public static void SetPlaylistName(int PlaylistID, string Name)
|
||||
public static void SetPlaylistName(int playlistID, string name)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[PlaylistID].PlaylistName = Name;
|
||||
_Playlists[playlistID].PlaylistName = name;
|
||||
}
|
||||
|
||||
public static void DeletePlaylist(int PlaylistID)
|
||||
public static void DeletePlaylist(int playlistID)
|
||||
{
|
||||
if (PlaylistID < 0 || PlaylistID >= _Playlists.Count)
|
||||
if (playlistID < 0 || playlistID >= _Playlists.Count)
|
||||
return;
|
||||
if (_Playlists[PlaylistID].PlaylistFile.Length > 0)
|
||||
if (_Playlists[playlistID].PlaylistFile.Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(_Playlists[PlaylistID].PlaylistFile);
|
||||
File.Delete(_Playlists[playlistID].PlaylistFile);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Can't delete Playlist File " + _Playlists[PlaylistID].PlaylistFile + ".xml");
|
||||
CLog.LogError("Can't delete Playlist File " + _Playlists[playlistID].PlaylistFile + ".xml");
|
||||
}
|
||||
}
|
||||
_Playlists.RemoveAt(PlaylistID);
|
||||
_Playlists.RemoveAt(playlistID);
|
||||
}
|
||||
|
||||
public static void SavePlaylist(int PlaylistID)
|
||||
public static void SavePlaylist(int playlistID)
|
||||
{
|
||||
if (PlaylistID < 0 || PlaylistID >= _Playlists.Count)
|
||||
if (playlistID < 0 || playlistID >= _Playlists.Count)
|
||||
return;
|
||||
_Playlists[PlaylistID].SavePlaylist();
|
||||
_Playlists[playlistID].SavePlaylist();
|
||||
}
|
||||
|
||||
public static int NewPlaylist()
|
||||
@@ -126,96 +126,96 @@ namespace Vocaluxe.Base
|
||||
return _Playlists.Count - 1;
|
||||
}
|
||||
|
||||
public static void AddPlaylistSong(int PlaylistID, int SongID)
|
||||
public static void AddPlaylistSong(int playlistID, int songID)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[PlaylistID].AddSong(SongID);
|
||||
_Playlists[playlistID].AddSong(songID);
|
||||
}
|
||||
|
||||
public static void AddPlaylistSong(int PlaylistID, int SongID, EGameMode GameMode)
|
||||
public static void AddPlaylistSong(int playlistID, int songID, EGameMode gameMode)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[PlaylistID].AddSong(SongID, GameMode);
|
||||
_Playlists[playlistID].AddSong(songID, gameMode);
|
||||
}
|
||||
|
||||
public static void InsertPlaylistSong(int PlaylistID, int PositionIndex, int SongID, EGameMode GameMode)
|
||||
public static void InsertPlaylistSong(int playlistID, int positionIndex, int songID, EGameMode gameMode)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[PlaylistID].SongInsert(PositionIndex, SongID, GameMode);
|
||||
_Playlists[playlistID].SongInsert(positionIndex, songID, gameMode);
|
||||
}
|
||||
|
||||
public static void MovePlaylistSong(int PlaylistID, int SourceIndex, int DestIndex)
|
||||
public static void MovePlaylistSong(int playlistID, int sourceIndex, int destIndex)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[PlaylistID].SongMove(SourceIndex, DestIndex);
|
||||
_Playlists[playlistID].SongMove(sourceIndex, destIndex);
|
||||
}
|
||||
|
||||
public static void MovePlaylistSongDown(int PlaylistID, int SongIndex)
|
||||
public static void MovePlaylistSongDown(int playlistID, int songIndex)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[PlaylistID].SongDown(SongIndex);
|
||||
_Playlists[playlistID].SongDown(songIndex);
|
||||
}
|
||||
|
||||
public static void MovePlaylistSongUp(int PlaylistID, int SongIndex)
|
||||
public static void MovePlaylistSongUp(int playlistID, int songIndex)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[PlaylistID].SongUp(SongIndex);
|
||||
_Playlists[playlistID].SongUp(songIndex);
|
||||
}
|
||||
|
||||
public static void DeletePlaylistSong(int PlaylistID, int SongIndex)
|
||||
public static void DeletePlaylistSong(int playlistID, int songIndex)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[PlaylistID].DeleteSong(SongIndex);
|
||||
_Playlists[playlistID].DeleteSong(songIndex);
|
||||
}
|
||||
|
||||
public static int GetPlaylistSongCount(int PlaylistID)
|
||||
public static int GetPlaylistSongCount(int playlistID)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return 0;
|
||||
|
||||
return _Playlists[PlaylistID].Songs.Count;
|
||||
return _Playlists[playlistID].Songs.Count;
|
||||
}
|
||||
|
||||
public static CPlaylistSong GetPlaylistSong(int PlaylistID, int SongIndex)
|
||||
public static CPlaylistSong GetPlaylistSong(int playlistID, int songIndex)
|
||||
{
|
||||
if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return null;
|
||||
|
||||
if (SongIndex >= _Playlists[PlaylistID].Songs.Count)
|
||||
if (songIndex >= _Playlists[playlistID].Songs.Count)
|
||||
return null;
|
||||
|
||||
return _Playlists[PlaylistID].Songs[SongIndex];
|
||||
return _Playlists[playlistID].Songs[songIndex];
|
||||
}
|
||||
|
||||
#region private methods
|
||||
private static void SortPlaylistsByName()
|
||||
private static void _SortPlaylistsByName()
|
||||
{
|
||||
_Playlists.Sort(CompareByPlaylistName);
|
||||
_Playlists.Sort(_CompareByPlaylistName);
|
||||
}
|
||||
|
||||
private static int CompareByPlaylistName(CPlaylistFile a, CPlaylistFile b)
|
||||
private static int _CompareByPlaylistName(CPlaylistFile a, CPlaylistFile b)
|
||||
{
|
||||
return String.Compare(a.PlaylistName, b.PlaylistName);
|
||||
}
|
||||
|
||||
private static CPlaylistFile ConvertUSDXPlaylist(string file)
|
||||
private static CPlaylistFile _ConvertUSDXPlaylist(string file)
|
||||
{
|
||||
CPlaylistFile pl = new CPlaylistFile();
|
||||
CSong[] AllSongs = CSongs.AllSongs;
|
||||
CSong[] allSongs = CSongs.AllSongs;
|
||||
|
||||
if (!File.Exists(file))
|
||||
return null;
|
||||
@@ -234,28 +234,28 @@ namespace Vocaluxe.Base
|
||||
//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;
|
||||
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();
|
||||
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++)
|
||||
for (int s = 0; s < allSongs.Length; s++)
|
||||
{
|
||||
if (AllSongs[s].Artist == Artist && AllSongs[s].Title == Title)
|
||||
if (allSongs[s].Artist == artist && allSongs[s].Title == title)
|
||||
{
|
||||
pl.AddSong(AllSongs[s].ID);
|
||||
pl.AddSong(allSongs[s].ID);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
CLog.LogError("Can't find song '" + Title + "' from '" + Artist + "' in playlist file: " + file);
|
||||
CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+97
-97
@@ -9,7 +9,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
static class CProfiles
|
||||
{
|
||||
private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
private static List<SProfile> _Profiles;
|
||||
private static readonly List<SAvatar> _Avatars = new List<SAvatar>();
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_settings.Indent = true;
|
||||
_settings.Encoding = Encoding.UTF8;
|
||||
_settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
_Settings.Indent = true;
|
||||
_Settings.Encoding = Encoding.UTF8;
|
||||
_Settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
|
||||
LoadAvatars();
|
||||
LoadProfiles();
|
||||
@@ -48,7 +48,7 @@ namespace Vocaluxe.Base
|
||||
return NewProfile(String.Empty);
|
||||
}
|
||||
|
||||
public static int NewProfile(string FileName)
|
||||
public static int NewProfile(string fileName)
|
||||
{
|
||||
SProfile profile = new SProfile();
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace Vocaluxe.Base
|
||||
profile.GuestProfile = EOffOn.TR_CONFIG_OFF;
|
||||
profile.Active = EOffOn.TR_CONFIG_ON;
|
||||
|
||||
if (FileName.Length > 0)
|
||||
profile.ProfileFile = Path.Combine(CSettings.sFolderProfiles, FileName);
|
||||
if (fileName.Length > 0)
|
||||
profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName);
|
||||
else
|
||||
profile.ProfileFile = String.Empty;
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Vocaluxe.Base
|
||||
public static void SaveProfiles()
|
||||
{
|
||||
for (int i = 0; i < _Profiles.Count; i++)
|
||||
SaveProfile(i);
|
||||
_SaveProfile(i);
|
||||
LoadProfiles();
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
_Profiles = new List<SProfile>();
|
||||
List<string> files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(CSettings.sFolderProfiles, "*.xml", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.xml", true, true));
|
||||
|
||||
foreach (string file in files)
|
||||
LoadProfile(file);
|
||||
_LoadProfile(file);
|
||||
|
||||
SortProfilesByName();
|
||||
_SortProfilesByName();
|
||||
}
|
||||
|
||||
public static void LoadAvatars()
|
||||
@@ -99,16 +99,16 @@ namespace Vocaluxe.Base
|
||||
_Avatars.Clear();
|
||||
|
||||
List<string> files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(CSettings.sFolderProfiles, "*.png", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.sFolderProfiles, "*.jpg", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.sFolderProfiles, "*.jpeg", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.sFolderProfiles, "*.bmp", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.png", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.jpg", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.jpeg", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.bmp", true, true));
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
STexture tex = CDraw.AddTexture(file);
|
||||
|
||||
if (tex.index != -1)
|
||||
if (tex.Index != -1)
|
||||
{
|
||||
SAvatar avatar = new SAvatar();
|
||||
avatar.Texture = tex;
|
||||
@@ -118,179 +118,179 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
public static string AddGetPlayerName(int ProfileNr, char Chr)
|
||||
public static string AddGetPlayerName(int profileNr, char chr)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return String.Empty;
|
||||
|
||||
SProfile profile = _Profiles[ProfileNr];
|
||||
profile.PlayerName += Chr;
|
||||
_Profiles[ProfileNr] = profile;
|
||||
SProfile profile = _Profiles[profileNr];
|
||||
profile.PlayerName += chr;
|
||||
_Profiles[profileNr] = profile;
|
||||
|
||||
return profile.PlayerName;
|
||||
}
|
||||
|
||||
public static string GetPlayerName(int ProfileNr)
|
||||
public static string GetPlayerName(int profileNr)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return String.Empty;
|
||||
|
||||
return _Profiles[ProfileNr].PlayerName;
|
||||
return _Profiles[profileNr].PlayerName;
|
||||
}
|
||||
|
||||
public static string GetDeleteCharInPlayerName(int ProfileNr)
|
||||
public static string GetDeleteCharInPlayerName(int profileNr)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return String.Empty;
|
||||
|
||||
SProfile profile = _Profiles[ProfileNr];
|
||||
SProfile profile = _Profiles[profileNr];
|
||||
if (profile.PlayerName.Length > 0)
|
||||
profile.PlayerName = profile.PlayerName.Remove(profile.PlayerName.Length - 1);
|
||||
_Profiles[ProfileNr] = profile;
|
||||
_Profiles[profileNr] = profile;
|
||||
|
||||
return profile.PlayerName;
|
||||
}
|
||||
|
||||
public static EGameDifficulty GetDifficulty(int ProfileNr)
|
||||
public static EGameDifficulty GetDifficulty(int profileNr)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return EGameDifficulty.TR_CONFIG_NORMAL;
|
||||
|
||||
return _Profiles[ProfileNr].Difficulty;
|
||||
return _Profiles[profileNr].Difficulty;
|
||||
}
|
||||
|
||||
public static void SetDifficulty(int ProfileNr, EGameDifficulty Difficulty)
|
||||
public static void SetDifficulty(int profileNr, EGameDifficulty difficulty)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return;
|
||||
|
||||
SProfile profile = _Profiles[ProfileNr];
|
||||
profile.Difficulty = Difficulty;
|
||||
_Profiles[ProfileNr] = profile;
|
||||
SProfile profile = _Profiles[profileNr];
|
||||
profile.Difficulty = difficulty;
|
||||
_Profiles[profileNr] = profile;
|
||||
}
|
||||
|
||||
public static EOffOn GetGuestProfile(int ProfileNr)
|
||||
public static EOffOn GetGuestProfile(int profileNr)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return EOffOn.TR_CONFIG_OFF;
|
||||
|
||||
return _Profiles[ProfileNr].GuestProfile;
|
||||
return _Profiles[profileNr].GuestProfile;
|
||||
}
|
||||
|
||||
public static EOffOn GetActive(int ProfileNr)
|
||||
public static EOffOn GetActive(int profileNr)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return EOffOn.TR_CONFIG_OFF;
|
||||
|
||||
return _Profiles[ProfileNr].Active;
|
||||
return _Profiles[profileNr].Active;
|
||||
}
|
||||
|
||||
public static void SetGuestProfile(int ProfileNr, EOffOn Option)
|
||||
public static void SetGuestProfile(int profileNr, EOffOn option)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return;
|
||||
|
||||
SProfile profile = _Profiles[ProfileNr];
|
||||
profile.GuestProfile = Option;
|
||||
_Profiles[ProfileNr] = profile;
|
||||
SProfile profile = _Profiles[profileNr];
|
||||
profile.GuestProfile = option;
|
||||
_Profiles[profileNr] = profile;
|
||||
}
|
||||
|
||||
public static void SetActive(int ProfileNr, EOffOn Option)
|
||||
public static void SetActive(int profileNr, EOffOn option)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return;
|
||||
SProfile profile = _Profiles[ProfileNr];
|
||||
profile.Active = Option;
|
||||
_Profiles[ProfileNr] = profile;
|
||||
SProfile profile = _Profiles[profileNr];
|
||||
profile.Active = option;
|
||||
_Profiles[profileNr] = profile;
|
||||
}
|
||||
|
||||
public static bool IsGuestProfile(int ProfileNr)
|
||||
public static bool IsGuestProfile(int profileNr)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return true; // this will prevent from saving dummy profiles to highscore db
|
||||
|
||||
return _Profiles[ProfileNr].GuestProfile == EOffOn.TR_CONFIG_ON;
|
||||
return _Profiles[profileNr].GuestProfile == EOffOn.TR_CONFIG_ON;
|
||||
}
|
||||
|
||||
public static bool IsActive(int ProfileNr)
|
||||
public static bool IsActive(int profileNr)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return false;
|
||||
return _Profiles[ProfileNr].Active == EOffOn.TR_CONFIG_ON;
|
||||
return _Profiles[profileNr].Active == EOffOn.TR_CONFIG_ON;
|
||||
}
|
||||
|
||||
public static void SetAvatar(int ProfileNr, int AvatarNr)
|
||||
public static void SetAvatar(int profileNr, int avatarNr)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count || AvatarNr < 0 || AvatarNr >= _Avatars.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count || avatarNr < 0 || avatarNr >= _Avatars.Count)
|
||||
return;
|
||||
|
||||
SProfile profile = _Profiles[ProfileNr];
|
||||
profile.Avatar = _Avatars[AvatarNr];
|
||||
_Profiles[ProfileNr] = profile;
|
||||
SProfile profile = _Profiles[profileNr];
|
||||
profile.Avatar = _Avatars[avatarNr];
|
||||
_Profiles[profileNr] = profile;
|
||||
}
|
||||
|
||||
public static int GetAvatarNr(int ProfileNr)
|
||||
public static int GetAvatarNr(int profileNr)
|
||||
{
|
||||
if (ProfileNr < 0 || ProfileNr >= _Profiles.Count)
|
||||
if (profileNr < 0 || profileNr >= _Profiles.Count)
|
||||
return 0;
|
||||
|
||||
for (int i = 0; i < _Avatars.Count; i++)
|
||||
{
|
||||
if (_Profiles[ProfileNr].Avatar.FileName == _Avatars[i].FileName)
|
||||
if (_Profiles[profileNr].Avatar.FileName == _Avatars[i].FileName)
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void DeleteProfile(int ProfileID)
|
||||
public static void DeleteProfile(int profileID)
|
||||
{
|
||||
if (ProfileID < 0 || ProfileID >= _Profiles.Count)
|
||||
if (profileID < 0 || profileID >= _Profiles.Count)
|
||||
return;
|
||||
if (_Profiles[ProfileID].ProfileFile.Length > 0)
|
||||
if (_Profiles[profileID].ProfileFile.Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(_Profiles[ProfileID].ProfileFile);
|
||||
_Profiles.RemoveAt(ProfileID);
|
||||
File.Delete(_Profiles[profileID].ProfileFile);
|
||||
_Profiles.RemoveAt(profileID);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Can't delete Profile File " + _Profiles[ProfileID].ProfileFile + ".xml");
|
||||
CLog.LogError("Can't delete Profile File " + _Profiles[profileID].ProfileFile + ".xml");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SortProfilesByName()
|
||||
private static void _SortProfilesByName()
|
||||
{
|
||||
_Profiles.Sort(CompareByPlayerName);
|
||||
_Profiles.Sort(_CompareByPlayerName);
|
||||
}
|
||||
|
||||
private static int CompareByPlayerName(SProfile a, SProfile b)
|
||||
private static int _CompareByPlayerName(SProfile a, SProfile b)
|
||||
{
|
||||
return String.Compare(a.PlayerName, b.PlayerName);
|
||||
}
|
||||
|
||||
#region private methods
|
||||
private static SAvatar GetAvatar(string FileName)
|
||||
private static SAvatar _GetAvatar(string fileName)
|
||||
{
|
||||
foreach (SAvatar avatar in _Avatars)
|
||||
{
|
||||
if (FileName == avatar.FileName)
|
||||
if (fileName == avatar.FileName)
|
||||
return avatar;
|
||||
}
|
||||
return new SAvatar(-1);
|
||||
}
|
||||
|
||||
private static void SaveProfile(int ProfileID)
|
||||
private static void _SaveProfile(int profileID)
|
||||
{
|
||||
if (ProfileID < 0 || ProfileID >= _Profiles.Count)
|
||||
if (profileID < 0 || profileID >= _Profiles.Count)
|
||||
return;
|
||||
|
||||
if (_Profiles[ProfileID].ProfileFile.Length == 0)
|
||||
if (_Profiles[profileID].ProfileFile.Length == 0)
|
||||
{
|
||||
string filename = string.Empty;
|
||||
foreach (char chr in _Profiles[ProfileID].PlayerName)
|
||||
foreach (char chr in _Profiles[profileID].PlayerName)
|
||||
{
|
||||
if (char.IsLetter(chr))
|
||||
filename += chr.ToString();
|
||||
@@ -300,26 +300,26 @@ namespace Vocaluxe.Base
|
||||
filename = "1";
|
||||
|
||||
int i = 0;
|
||||
while (File.Exists(Path.Combine(CSettings.sFolderProfiles, filename + ".xml")))
|
||||
while (File.Exists(Path.Combine(CSettings.FolderProfiles, filename + ".xml")))
|
||||
{
|
||||
i++;
|
||||
if (!File.Exists(Path.Combine(CSettings.sFolderProfiles, filename + i + ".xml")))
|
||||
if (!File.Exists(Path.Combine(CSettings.FolderProfiles, filename + i + ".xml")))
|
||||
filename += i;
|
||||
}
|
||||
|
||||
SProfile profile = _Profiles[ProfileID];
|
||||
profile.ProfileFile = Path.Combine(CSettings.sFolderProfiles, filename + ".xml");
|
||||
_Profiles[ProfileID] = profile;
|
||||
SProfile profile = _Profiles[profileID];
|
||||
profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, filename + ".xml");
|
||||
_Profiles[profileID] = profile;
|
||||
}
|
||||
|
||||
XmlWriter writer;
|
||||
try
|
||||
{
|
||||
writer = XmlWriter.Create(_Profiles[ProfileID].ProfileFile, _settings);
|
||||
writer = XmlWriter.Create(_Profiles[profileID].ProfileFile, _Settings);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error creating/opening Profile File " + _Profiles[ProfileID].ProfileFile + ": " + e.Message);
|
||||
CLog.LogError("Error creating/opening Profile File " + _Profiles[profileID].ProfileFile + ": " + e.Message);
|
||||
return;
|
||||
}
|
||||
try
|
||||
@@ -328,11 +328,11 @@ namespace Vocaluxe.Base
|
||||
writer.WriteStartElement("root");
|
||||
|
||||
writer.WriteStartElement("Info");
|
||||
writer.WriteElementString("PlayerName", _Profiles[ProfileID].PlayerName);
|
||||
writer.WriteElementString("Difficulty", Enum.GetName(typeof(EGameDifficulty), _Profiles[ProfileID].Difficulty));
|
||||
writer.WriteElementString("Avatar", _Profiles[ProfileID].Avatar.FileName);
|
||||
writer.WriteElementString("GuestProfile", Enum.GetName(typeof(EOffOn), _Profiles[ProfileID].GuestProfile));
|
||||
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), _Profiles[ProfileID].Active));
|
||||
writer.WriteElementString("PlayerName", _Profiles[profileID].PlayerName);
|
||||
writer.WriteElementString("Difficulty", Enum.GetName(typeof(EGameDifficulty), _Profiles[profileID].Difficulty));
|
||||
writer.WriteElementString("Avatar", _Profiles[profileID].Avatar.FileName);
|
||||
writer.WriteElementString("GuestProfile", Enum.GetName(typeof(EOffOn), _Profiles[profileID].GuestProfile));
|
||||
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), _Profiles[profileID].Active));
|
||||
writer.WriteEndElement();
|
||||
|
||||
writer.WriteEndElement(); //end of root
|
||||
@@ -347,10 +347,10 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadProfile(string FileName)
|
||||
private static void _LoadProfile(string fileName)
|
||||
{
|
||||
SProfile profile = new SProfile();
|
||||
profile.ProfileFile = Path.Combine(CSettings.sFolderProfiles, FileName);
|
||||
profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName);
|
||||
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(profile.ProfileFile);
|
||||
if (xmlReader == null)
|
||||
@@ -366,7 +366,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
profile.Avatar = new SAvatar(-1);
|
||||
if (xmlReader.GetValue("//root/Info/Avatar", ref value, value))
|
||||
profile.Avatar = GetAvatar(value);
|
||||
profile.Avatar = _GetAvatar(value);
|
||||
|
||||
profile.GuestProfile = EOffOn.TR_CONFIG_OFF;
|
||||
xmlReader.TryGetEnumValue("//root/Info/GuestProfile", ref profile.GuestProfile);
|
||||
@@ -377,7 +377,7 @@ namespace Vocaluxe.Base
|
||||
_Profiles.Add(profile);
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find PlayerName in Profile File: " + FileName);
|
||||
CLog.LogError("Can't find PlayerName in Profile File: " + fileName);
|
||||
}
|
||||
#endregion private methods
|
||||
}
|
||||
|
||||
+73
-79
@@ -13,85 +13,79 @@ namespace Vocaluxe.Base
|
||||
Release
|
||||
}
|
||||
|
||||
enum EArch
|
||||
{
|
||||
x86,
|
||||
x64
|
||||
}
|
||||
|
||||
static class CSettings
|
||||
{
|
||||
#if ARCH_X86
|
||||
public const EArch ARCH = EArch.x86;
|
||||
public const String Arch = "x86";
|
||||
#endif
|
||||
|
||||
#if ARCH_X64
|
||||
public const EArch ARCH = EArch.x64;
|
||||
public const String Arch = "x64";
|
||||
#endif
|
||||
|
||||
public static EGameState GameState = EGameState.Start;
|
||||
|
||||
public const string sProgramName = "Vocaluxe";
|
||||
public const string sProgramCodeName = "Shining Heaven";
|
||||
public const string ProgramName = "Vocaluxe";
|
||||
public const string ProgramCodeName = "Shining Heaven";
|
||||
|
||||
public const int iVersionMajor = 0;
|
||||
public const int iVersionMinor = 3; // milestones
|
||||
public const int iVersionSub = 0; // patches
|
||||
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 iBuild = 77; // Increase on every published version! Never Reset!
|
||||
public const int Build = 77; // Increase on every published version! Never Reset!
|
||||
|
||||
public const int iDatabaseHighscoreVersion = 2;
|
||||
public const int iDatabaseCoverVersion = 1;
|
||||
public const int iDatabaseCreditsRessourcesVersion = 1;
|
||||
public const int DatabaseHighscoreVersion = 2;
|
||||
public const int DatabaseCoverVersion = 1;
|
||||
public const int DatabaseCreditsRessourcesVersion = 1;
|
||||
|
||||
public static int iRenderW = 1280;
|
||||
public static int iRenderH = 720;
|
||||
public static int RenderW = 1280;
|
||||
public static int RenderH = 720;
|
||||
|
||||
public static int zNear = -100;
|
||||
public static int zFar = 100;
|
||||
public const int ZNear = -100;
|
||||
public const int ZFar = 100;
|
||||
|
||||
public static bool bFullScreen = false;
|
||||
public static int iVertexBufferElements = 10000;
|
||||
public static bool IsFullScreen = false;
|
||||
public static int VertexBufferElements = 10000;
|
||||
|
||||
public const string sIcon = "Vocaluxe.ico";
|
||||
public const string sLogo = "Logo.png";
|
||||
public const string Icon = "Vocaluxe.ico";
|
||||
public const string Logo = "Logo.png";
|
||||
public const string FallbackLanguage = "English";
|
||||
public static string sBassRegistration = "Registration.xml";
|
||||
public static string sFileConfig = "Config.xml";
|
||||
public const string sFileCover = "Cover.xml";
|
||||
public const string sFileFonts = "Fonts.xml";
|
||||
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 sFileOldHighscoreDB = "Ultrastar.db";
|
||||
public static string sFileHighscoreDB = "HighscoreDB.sqlite";
|
||||
public const string sFileCoverDB = "CoverDB.sqlite";
|
||||
public const string sFileCreditsRessourcesDB = "CreditsRessourcesDB.sqlite";
|
||||
public const string sFilePerformanceLog = "Performance.log";
|
||||
public const string sFileErrorLog = "Error.log";
|
||||
public const string sFileBenchmarkLog = "Benchmark.log";
|
||||
public const string FileOldHighscoreDB = "Ultrastar.db";
|
||||
public static string FileHighscoreDB = "HighscoreDB.sqlite";
|
||||
public const string FileCoverDB = "CoverDB.sqlite";
|
||||
public const string FileCreditsRessourcesDB = "CreditsRessourcesDB.sqlite";
|
||||
public const string FilePerformanceLog = "Performance.log";
|
||||
public const string FileErrorLog = "Error.log";
|
||||
public const string FileBenchmarkLog = "Benchmark.log";
|
||||
|
||||
public const string sSoundT440 = "440Hz.mp3";
|
||||
public const string SoundT440 = "440Hz.mp3";
|
||||
|
||||
public const string sFolderCover = "Cover";
|
||||
public const string sFolderGraphics = "Graphics";
|
||||
public const string sFolderFonts = "Fonts";
|
||||
public const string sFolderThemes = "Themes";
|
||||
public const string sFolderSkins = "Skins";
|
||||
public const string sFolderThemeFonts = "Fonts";
|
||||
public const string sFolderScreens = "Screens";
|
||||
public static string sFolderProfiles = "Profiles";
|
||||
public const string sFolderSongs = "Songs";
|
||||
public const string sFolderSounds = "Sounds";
|
||||
public const string sFolderLanguages = "Languages";
|
||||
public const string sFolderScreenshots = "Screenshots";
|
||||
public const string sFolderBackgroundMusic = "BackgroundMusic";
|
||||
public static string sFolderPlaylists = "Playlists";
|
||||
public const string FolderCover = "Cover";
|
||||
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";
|
||||
public const string FolderSongs = "Songs";
|
||||
public const string FolderSounds = "Sounds";
|
||||
public const string FolderLanguages = "Languages";
|
||||
public const string FolderScreenshots = "Screenshots";
|
||||
public const string FolderBackgroundMusic = "BackgroundMusic";
|
||||
public static string FolderPlaylists = "Playlists";
|
||||
|
||||
public static string sFolderPartyModes = "PartyModes";
|
||||
public const string sFolderPartyModeCode = "Code";
|
||||
public const string sFolderPartyModeScreens = "Screens";
|
||||
public const string sFolderPartyModeLanguages = "Languages";
|
||||
public const string sFolderPartyModeFonts = "Fonts";
|
||||
public const string FolderPartyModes = "PartyModes";
|
||||
public const string FolderPartyModeCode = "Code";
|
||||
public const string FolderPartyModeScreens = "Screens";
|
||||
public const string FolderPartyModeLanguages = "Languages";
|
||||
public const string FolderPartyModeFonts = "Fonts";
|
||||
|
||||
//public const String[] ToneStrings = new String[]{ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
|
||||
public const int ToneMin = -36;
|
||||
@@ -129,39 +123,39 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static string GetVersionText()
|
||||
{
|
||||
string sVersion = "v" + iVersionMajor.ToString() + "." +
|
||||
iVersionMinor.ToString() + "." +
|
||||
iVersionSub.ToString() + " (" + Enum.GetName(typeof(EArch), ARCH) + ")";
|
||||
string version = "v" + VersionMajor.ToString() + "." +
|
||||
VersionMinor.ToString() + "." +
|
||||
VersionSub.ToString() + " (" + Arch + ")";
|
||||
|
||||
if (VersionRevision != ERevision.Release)
|
||||
sVersion += " " + GetVersionStatus() + String.Format(" ({0:0000)}", iBuild);
|
||||
version += " " + GetVersionStatus() + String.Format(" ({0:0000)}", Build);
|
||||
|
||||
return sVersion;
|
||||
return version;
|
||||
}
|
||||
|
||||
public static string GetFullVersionText()
|
||||
{
|
||||
string sVersion = sProgramName;
|
||||
string version = ProgramName;
|
||||
|
||||
if (sProgramCodeName.Length > 0)
|
||||
sVersion += " \"" + sProgramCodeName + "\"";
|
||||
if (ProgramCodeName.Length > 0)
|
||||
version += " \"" + ProgramCodeName + "\"";
|
||||
|
||||
return sVersion += " " + GetVersionText();
|
||||
return version + " " + GetVersionText();
|
||||
}
|
||||
|
||||
public static string GetVersionStatus()
|
||||
{
|
||||
string _Result = String.Empty;
|
||||
string result = String.Empty;
|
||||
|
||||
if (VersionRevision != ERevision.Release)
|
||||
_Result = Enum.GetName(typeof(ERevision), VersionRevision);
|
||||
result = Enum.GetName(typeof(ERevision), VersionRevision);
|
||||
|
||||
return _Result;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static float GetRenderAspect()
|
||||
{
|
||||
return iRenderW / (float)iRenderH;
|
||||
return RenderW / (float)RenderH;
|
||||
}
|
||||
|
||||
public static void MouseInactive()
|
||||
@@ -176,18 +170,18 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void CreateFolders()
|
||||
{
|
||||
List<string> Folders = new List<string>();
|
||||
List<string> folders = new List<string>();
|
||||
|
||||
Folders.Add(sFolderCover);
|
||||
Folders.Add(sFolderFonts);
|
||||
Folders.Add(sFolderProfiles);
|
||||
Folders.Add(sFolderSongs);
|
||||
Folders.Add(sFolderScreenshots);
|
||||
Folders.Add(sFolderBackgroundMusic);
|
||||
Folders.Add(sFolderSounds);
|
||||
Folders.Add(sFolderPlaylists);
|
||||
folders.Add(FolderCover);
|
||||
folders.Add(FolderFonts);
|
||||
folders.Add(FolderProfiles);
|
||||
folders.Add(FolderSongs);
|
||||
folders.Add(FolderScreenshots);
|
||||
folders.Add(FolderBackgroundMusic);
|
||||
folders.Add(FolderSounds);
|
||||
folders.Add(FolderPlaylists);
|
||||
|
||||
foreach (string folder in Folders)
|
||||
foreach (string folder in folders)
|
||||
{
|
||||
string path = Path.Combine(Environment.CurrentDirectory, folder);
|
||||
CreateFolder(path);
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public CSongCategorizer()
|
||||
{
|
||||
CSongs.Filter.ObjectChanged += HandleSortedSongsChanged;
|
||||
CSongs.Filter.ObjectChanged += _HandleSortedSongsChanged;
|
||||
}
|
||||
|
||||
public List<CCategory> Categories
|
||||
@@ -38,7 +38,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleSortedSongsChanged(object sender, EventArgs args)
|
||||
private void _HandleSortedSongsChanged(object sender, EventArgs args)
|
||||
{
|
||||
_SetChanged();
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace Vocaluxe.Base
|
||||
private void _CreateCategoriesLetter()
|
||||
{
|
||||
string category = "";
|
||||
int NotLetterCat = -1;
|
||||
int notLetterCat = -1;
|
||||
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
|
||||
{
|
||||
Char firstLetter = Char.ToUpper(CSongs.Sorter.SortedSongs[i].SortString.Normalize(NormalizationForm.FormD)[0]);
|
||||
@@ -55,7 +55,7 @@ namespace Vocaluxe.Base
|
||||
firstLetter = '#';
|
||||
if (firstLetter.ToString() != category)
|
||||
{
|
||||
if (firstLetter != '#' || NotLetterCat == -1)
|
||||
if (firstLetter != '#' || notLetterCat == -1)
|
||||
{
|
||||
category = firstLetter.ToString();
|
||||
_Categories.Add(new CCategory(category));
|
||||
@@ -63,20 +63,20 @@ namespace Vocaluxe.Base
|
||||
CSongs.Sorter.SortedSongs[i].CatIndex = _Categories.Count - 1;
|
||||
|
||||
if (firstLetter == '#')
|
||||
NotLetterCat = CSongs.Sorter.SortedSongs[i].CatIndex;
|
||||
notLetterCat = CSongs.Sorter.SortedSongs[i].CatIndex;
|
||||
}
|
||||
else
|
||||
CSongs.Sorter.SortedSongs[i].CatIndex = NotLetterCat;
|
||||
CSongs.Sorter.SortedSongs[i].CatIndex = notLetterCat;
|
||||
}
|
||||
else
|
||||
CSongs.Sorter.SortedSongs[i].CatIndex = _Categories.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void _CreateCategoriesNormal(string NoCategoryName)
|
||||
private void _CreateCategoriesNormal(string noCategoryName)
|
||||
{
|
||||
string category = "";
|
||||
int NoCategoryIndex = -1;
|
||||
int noCategoryIndex = -1;
|
||||
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
|
||||
{
|
||||
if (CSongs.Sorter.SortedSongs[i].SortString.Length > 0)
|
||||
@@ -90,59 +90,59 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
else
|
||||
{
|
||||
if (NoCategoryIndex < 0)
|
||||
if (noCategoryIndex < 0)
|
||||
{
|
||||
category = NoCategoryName;
|
||||
category = noCategoryName;
|
||||
_Categories.Add(new CCategory(category));
|
||||
NoCategoryIndex = _Categories.Count - 1;
|
||||
noCategoryIndex = _Categories.Count - 1;
|
||||
}
|
||||
CSongs.Sorter.SortedSongs[i].CatIndex = NoCategoryIndex;
|
||||
CSongs.Sorter.SortedSongs[i].CatIndex = noCategoryIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _CreateCategories()
|
||||
{
|
||||
string NoCategoryName = "";
|
||||
string noCategoryName = "";
|
||||
|
||||
ESongSorting Sorting = CSongs.Sorter.SongSorting;
|
||||
ESongSorting sorting = CSongs.Sorter.SongSorting;
|
||||
|
||||
switch (Sorting)
|
||||
switch (sorting)
|
||||
{
|
||||
case ESongSorting.TR_CONFIG_EDITION:
|
||||
NoCategoryName = CLanguage.Translate("TR_SCREENSONG_NOEDITION");
|
||||
noCategoryName = CLanguage.Translate("TR_SCREENSONG_NOEDITION");
|
||||
break;
|
||||
case ESongSorting.TR_CONFIG_GENRE:
|
||||
NoCategoryName = CLanguage.Translate("TR_SCREENSONG_NOGENRE");
|
||||
noCategoryName = CLanguage.Translate("TR_SCREENSONG_NOGENRE");
|
||||
break;
|
||||
case ESongSorting.TR_CONFIG_DECADE:
|
||||
case ESongSorting.TR_CONFIG_YEAR:
|
||||
NoCategoryName = CLanguage.Translate("TR_SCREENSONG_NOYEAR");
|
||||
noCategoryName = CLanguage.Translate("TR_SCREENSONG_NOYEAR");
|
||||
break;
|
||||
case ESongSorting.TR_CONFIG_LANGUAGE:
|
||||
NoCategoryName = CLanguage.Translate("TR_SCREENSONG_NOLANGUAGE");
|
||||
noCategoryName = CLanguage.Translate("TR_SCREENSONG_NOLANGUAGE");
|
||||
break;
|
||||
case ESongSorting.TR_CONFIG_NONE:
|
||||
NoCategoryName = CLanguage.Translate("TR_SCREENSONG_ALLSONGS");
|
||||
noCategoryName = CLanguage.Translate("TR_SCREENSONG_ALLSONGS");
|
||||
break;
|
||||
}
|
||||
if (Sorting == ESongSorting.TR_CONFIG_ARTIST_LETTER || Sorting == ESongSorting.TR_CONFIG_TITLE_LETTER)
|
||||
if (sorting == ESongSorting.TR_CONFIG_ARTIST_LETTER || sorting == ESongSorting.TR_CONFIG_TITLE_LETTER)
|
||||
_CreateCategoriesLetter();
|
||||
else
|
||||
{
|
||||
if (Sorting == ESongSorting.TR_CONFIG_DECADE)
|
||||
if (sorting == ESongSorting.TR_CONFIG_DECADE)
|
||||
{
|
||||
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
|
||||
{
|
||||
string Year = CSongs.Sorter.SortedSongs[i].SortString;
|
||||
if (Year.Length > 0)
|
||||
string year = CSongs.Sorter.SortedSongs[i].SortString;
|
||||
if (year.Length > 0)
|
||||
{
|
||||
Year = Year.Substring(0, 3);
|
||||
CSongs.Sorter.SortedSongs[i].SortString = Year + "0 - " + Year + "9";
|
||||
year = year.Substring(0, 3);
|
||||
CSongs.Sorter.SortedSongs[i].SortString = year + "0 - " + year + "9";
|
||||
}
|
||||
}
|
||||
}
|
||||
_CreateCategoriesNormal(NoCategoryName);
|
||||
_CreateCategoriesNormal(noCategoryName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,16 +8,16 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
class CSongSorter : CObservable
|
||||
{
|
||||
private SongPointer[] _SortedSongs = new SongPointer[0];
|
||||
private SSongPointer[] _SortedSongs = new SSongPointer[0];
|
||||
private EOffOn _IgnoreArticles = CConfig.IgnoreArticles;
|
||||
private ESongSorting _SongSorting = CConfig.SongSorting;
|
||||
|
||||
public CSongSorter()
|
||||
{
|
||||
CSongs.Filter.ObjectChanged += HandleFilteredSongsChanged;
|
||||
CSongs.Filter.ObjectChanged += _HandleFilteredSongsChanged;
|
||||
}
|
||||
|
||||
public SongPointer[] SortedSongs
|
||||
public SSongPointer[] SortedSongs
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -62,12 +62,12 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleFilteredSongsChanged(object sender, EventArgs args)
|
||||
private void _HandleFilteredSongsChanged(object sender, EventArgs args)
|
||||
{
|
||||
_SetChanged();
|
||||
}
|
||||
|
||||
private int _SortByFieldArtistTitle(SongPointer s1, SongPointer s2)
|
||||
private int _SortByFieldArtistTitle(SSongPointer s1, SSongPointer s2)
|
||||
{
|
||||
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
|
||||
if (res == 0)
|
||||
@@ -90,7 +90,7 @@ namespace Vocaluxe.Base
|
||||
return res;
|
||||
}
|
||||
|
||||
private int _SortByFieldTitle(SongPointer s1, SongPointer s2)
|
||||
private int _SortByFieldTitle(SSongPointer s1, SSongPointer s2)
|
||||
{
|
||||
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
|
||||
if (res == 0)
|
||||
@@ -103,13 +103,13 @@ namespace Vocaluxe.Base
|
||||
return res;
|
||||
}
|
||||
|
||||
private List<SongPointer> _CreateSortList(string fieldName)
|
||||
private List<SSongPointer> _CreateSortList(string fieldName)
|
||||
{
|
||||
FieldInfo field = null;
|
||||
bool isString = false;
|
||||
List<SongPointer> SortList = new List<SongPointer>();
|
||||
List<SSongPointer> sortList = new List<SSongPointer>();
|
||||
if (fieldName.Length == 0)
|
||||
CSongs.Filter.FilteredSongs.ForEach((song) => SortList.Add(new SongPointer(song.ID, "")));
|
||||
CSongs.Filter.FilteredSongs.ForEach((song) => sortList.Add(new SSongPointer(song.ID, "")));
|
||||
else
|
||||
{
|
||||
field = typeof(CSong).GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
|
||||
@@ -120,21 +120,21 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
object value = field.GetValue(song);
|
||||
if (isString)
|
||||
SortList.Add(new SongPointer(song.ID, (String)value));
|
||||
sortList.Add(new SSongPointer(song.ID, (String)value));
|
||||
else
|
||||
{
|
||||
List<String> values = (List<String>)value;
|
||||
if (values.Count == 0)
|
||||
SortList.Add(new SongPointer(song.ID, ""));
|
||||
sortList.Add(new SSongPointer(song.ID, ""));
|
||||
else
|
||||
{
|
||||
foreach (String sortString in (List<String>)value)
|
||||
SortList.Add(new SongPointer(song.ID, sortString));
|
||||
sortList.Add(new SSongPointer(song.ID, sortString));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SortList;
|
||||
return sortList;
|
||||
}
|
||||
|
||||
private void _SortSongs()
|
||||
@@ -177,19 +177,19 @@ namespace Vocaluxe.Base
|
||||
fieldName = "";
|
||||
break;
|
||||
}
|
||||
List<SongPointer> SortList = _CreateSortList(fieldName);
|
||||
List<SSongPointer> sortList = _CreateSortList(fieldName);
|
||||
switch (_SongSorting)
|
||||
{
|
||||
case ESongSorting.TR_CONFIG_ARTIST_LETTER:
|
||||
case ESongSorting.TR_CONFIG_ARTIST:
|
||||
case ESongSorting.TR_CONFIG_NONE:
|
||||
SortList.Sort(_SortByFieldTitle);
|
||||
sortList.Sort(_SortByFieldTitle);
|
||||
break;
|
||||
default:
|
||||
SortList.Sort(_SortByFieldArtistTitle);
|
||||
sortList.Sort(_SortByFieldArtistTitle);
|
||||
break;
|
||||
}
|
||||
_SortedSongs = SortList.ToArray();
|
||||
_SortedSongs = sortList.ToArray();
|
||||
_Changed = false;
|
||||
}
|
||||
}
|
||||
|
||||
+43
-43
@@ -8,7 +8,7 @@ using VocaluxeLib.Menu.SongMenu;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
{
|
||||
public struct SongPointer
|
||||
public struct SSongPointer
|
||||
{
|
||||
public int SongID;
|
||||
public string SortString;
|
||||
@@ -17,9 +17,9 @@ namespace Vocaluxe.Base
|
||||
public bool Visible;
|
||||
public bool PartyHidden;
|
||||
|
||||
public SongPointer(int ID, string sortString)
|
||||
public SSongPointer(int iD, string sortString)
|
||||
{
|
||||
SongID = ID;
|
||||
SongID = iD;
|
||||
SortString = sortString;
|
||||
CatIndex = -1;
|
||||
Visible = false;
|
||||
@@ -75,13 +75,13 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
get
|
||||
{
|
||||
int Result = 0;
|
||||
foreach (SongPointer sp in Sorter.SortedSongs)
|
||||
int result = 0;
|
||||
foreach (SSongPointer sp in Sorter.SortedSongs)
|
||||
{
|
||||
if (sp.Visible)
|
||||
Result++;
|
||||
result++;
|
||||
}
|
||||
return Result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,17 +113,17 @@ namespace Vocaluxe.Base
|
||||
/// <summary>
|
||||
/// Returns the number of song in the category specified with CatIndex
|
||||
/// </summary>
|
||||
/// <param name="CatIndex">Category index</param>
|
||||
/// <param name="catIndex">Category index</param>
|
||||
/// <returns></returns>
|
||||
public static int NumSongsInCategory(int CatIndex)
|
||||
public static int NumSongsInCategory(int catIndex)
|
||||
{
|
||||
if (Categorizer.Categories.Count <= CatIndex || CatIndex < 0)
|
||||
if (Categorizer.Categories.Count <= catIndex || catIndex < 0)
|
||||
return 0;
|
||||
|
||||
int num = 0;
|
||||
for (int i = 0; i < Sorter.SortedSongs.Length; i++)
|
||||
{
|
||||
if (Sorter.SortedSongs[i].CatIndex == CatIndex && !Sorter.SortedSongs[i].PartyHidden)
|
||||
if (Sorter.SortedSongs[i].CatIndex == catIndex && !Sorter.SortedSongs[i].PartyHidden)
|
||||
num++;
|
||||
}
|
||||
return num;
|
||||
@@ -145,14 +145,14 @@ namespace Vocaluxe.Base
|
||||
Category--;
|
||||
}
|
||||
|
||||
public static int GetNextSongWithoutCover(ref CSong Song)
|
||||
public static int GetNextSongWithoutCover(ref CSong song)
|
||||
{
|
||||
if (!SongsLoaded)
|
||||
return -1;
|
||||
|
||||
if (_CoverLoadIndex < _Songs.Count)
|
||||
{
|
||||
Song = _Songs[_CoverLoadIndex];
|
||||
song = _Songs[_CoverLoadIndex];
|
||||
_CoverLoadIndex++;
|
||||
return _CoverLoadIndex;
|
||||
}
|
||||
@@ -165,22 +165,22 @@ namespace Vocaluxe.Base
|
||||
get { return _CoverLoadIndex; }
|
||||
}
|
||||
|
||||
public static void SetCoverSmall(int SongIndex, STexture Texture)
|
||||
public static void SetCoverSmall(int songIndex, STexture texture)
|
||||
{
|
||||
if (!_SongsLoaded)
|
||||
return;
|
||||
|
||||
if (SongIndex < _Songs.Count)
|
||||
_Songs[SongIndex].CoverTextureSmall = Texture;
|
||||
if (songIndex < _Songs.Count)
|
||||
_Songs[songIndex].CoverTextureSmall = texture;
|
||||
}
|
||||
|
||||
public static void SetCoverBig(int SongIndex, STexture Texture)
|
||||
public static void SetCoverBig(int songIndex, STexture texture)
|
||||
{
|
||||
if (!_SongsLoaded)
|
||||
return;
|
||||
|
||||
if (SongIndex < _Songs.Count)
|
||||
_Songs[SongIndex].CoverTextureBig = Texture;
|
||||
if (songIndex < _Songs.Count)
|
||||
_Songs[songIndex].CoverTextureBig = texture;
|
||||
}
|
||||
|
||||
public static string GetCurrentCategoryName()
|
||||
@@ -191,22 +191,22 @@ namespace Vocaluxe.Base
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
public static CSong GetSong(int SongID)
|
||||
public static CSong GetSong(int songID)
|
||||
{
|
||||
foreach (CSong song in _Songs)
|
||||
{
|
||||
if (song.ID == SongID)
|
||||
if (song.ID == songID)
|
||||
return song;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void AddPartySongSung(int SongID)
|
||||
public static void AddPartySongSung(int songID)
|
||||
{
|
||||
int cat = -1;
|
||||
for (int i = 0; i < Sorter.SortedSongs.Length; i++)
|
||||
{
|
||||
if (SongID == Sorter.SortedSongs[i].SongID)
|
||||
if (songID == Sorter.SortedSongs[i].SongID)
|
||||
{
|
||||
Sorter.SortedSongs[i].PartyHidden = true;
|
||||
Sorter.SortedSongs[i].Visible = false;
|
||||
@@ -231,11 +231,11 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
public static void ResetPartySongSung(int CatIndex)
|
||||
public static void ResetPartySongSung(int catIndex)
|
||||
{
|
||||
for (int i = 0; i < Sorter.SortedSongs.Length; i++)
|
||||
{
|
||||
if (Sorter.SortedSongs[i].CatIndex == CatIndex)
|
||||
if (Sorter.SortedSongs[i].CatIndex == catIndex)
|
||||
{
|
||||
Sorter.SortedSongs[i].PartyHidden = false;
|
||||
Sorter.SortedSongs[i].Visible = Sorter.SortedSongs[i].CatIndex == _CatIndex && !Sorter.SortedSongs[i].PartyHidden;
|
||||
@@ -243,13 +243,13 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetVisibleSongNumber(int SongID)
|
||||
public static int GetVisibleSongNumber(int songID)
|
||||
{
|
||||
int i = -1;
|
||||
foreach (CSong song in VisibleSongs)
|
||||
{
|
||||
i++;
|
||||
if (song.ID == SongID)
|
||||
if (song.ID == songID)
|
||||
return i;
|
||||
}
|
||||
return i;
|
||||
@@ -284,7 +284,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
CCategory category = _CategoriesForRandom[CGame.Rand.Next(0, _CategoriesForRandom.Count - 1)];
|
||||
_CategoriesForRandom.Remove(category);
|
||||
return GetCategoryNumber(category);
|
||||
return _GetCategoryNumber(category);
|
||||
}
|
||||
|
||||
public static void UpdateRandomCategoryList()
|
||||
@@ -293,7 +293,7 @@ namespace Vocaluxe.Base
|
||||
_CategoriesForRandom.AddRange(Categories);
|
||||
}
|
||||
|
||||
private static int GetCategoryNumber(CCategory category)
|
||||
private static int _GetCategoryNumber(CCategory category)
|
||||
{
|
||||
for (int i = 0; i < Categories.Length; i++)
|
||||
{
|
||||
@@ -313,7 +313,7 @@ namespace Vocaluxe.Base
|
||||
get
|
||||
{
|
||||
List<CSong> songs = new List<CSong>();
|
||||
foreach (SongPointer sp in Sorter.SortedSongs)
|
||||
foreach (SSongPointer sp in Sorter.SortedSongs)
|
||||
{
|
||||
if (sp.Visible)
|
||||
songs.Add(_Songs[sp.SongID]);
|
||||
@@ -327,7 +327,7 @@ namespace Vocaluxe.Base
|
||||
get
|
||||
{
|
||||
List<CSong> songs = new List<CSong>();
|
||||
foreach (SongPointer sp in Sorter.SortedSongs)
|
||||
foreach (SSongPointer sp in Sorter.SortedSongs)
|
||||
{
|
||||
if (sp.Visible)
|
||||
songs.Add(_Songs[sp.SongID]);
|
||||
@@ -346,7 +346,7 @@ namespace Vocaluxe.Base
|
||||
if (index < 0)
|
||||
return null;
|
||||
|
||||
foreach (SongPointer sp in Sorter.SortedSongs)
|
||||
foreach (SSongPointer sp in Sorter.SortedSongs)
|
||||
{
|
||||
if (sp.Visible)
|
||||
{
|
||||
@@ -358,17 +358,17 @@ namespace Vocaluxe.Base
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void HandleCategoriesChanged(object sender, EventArgs args)
|
||||
private static void _HandleCategoriesChanged(object sender, EventArgs args)
|
||||
{
|
||||
_CategoriesForRandom.Clear();
|
||||
Category = _CatIndex;
|
||||
}
|
||||
|
||||
public static void Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, String SearchString, EDuetOptions DuetOptions)
|
||||
public static void Sort(ESongSorting sorting, EOffOn tabs, EOffOn ignoreArticles, String searchString, EDuetOptions duetOptions)
|
||||
{
|
||||
Filter.SetOptions(SearchString, DuetOptions);
|
||||
Sorter.SetOptions(Sorting, IgnoreArticles);
|
||||
Categorizer.Tabs = Tabs;
|
||||
Filter.SetOptions(searchString, duetOptions);
|
||||
Sorter.SetOptions(sorting, ignoreArticles);
|
||||
Categorizer.Tabs = tabs;
|
||||
}
|
||||
|
||||
public static void LoadSongs()
|
||||
@@ -390,12 +390,12 @@ namespace Vocaluxe.Base
|
||||
CLog.StartBenchmark(2, "Read TXTs");
|
||||
foreach (string file in files)
|
||||
{
|
||||
CSong Song = CSong.LoadSong(file);
|
||||
if (Song != null)
|
||||
CSong song = CSong.LoadSong(file);
|
||||
if (song != null)
|
||||
{
|
||||
Song.ID = _Songs.Count;
|
||||
_Songs.Add(Song);
|
||||
Song.ReadNotes();
|
||||
song.ID = _Songs.Count;
|
||||
if(song.ReadNotes())
|
||||
_Songs.Add(song);
|
||||
}
|
||||
}
|
||||
CLog.StopBenchmark(2, "Read TXTs");
|
||||
@@ -404,7 +404,7 @@ namespace Vocaluxe.Base
|
||||
Sorter.SongSorting = CConfig.SongSorting;
|
||||
Sorter.IgnoreArticles = CConfig.IgnoreArticles;
|
||||
Categorizer.Tabs = CConfig.Tabs;
|
||||
Categorizer.ObjectChanged += HandleCategoriesChanged;
|
||||
Categorizer.ObjectChanged += _HandleCategoriesChanged;
|
||||
CLog.StopBenchmark(2, "Sort Songs");
|
||||
Category = -1;
|
||||
_SongsLoaded = true;
|
||||
|
||||
+126
-126
@@ -39,9 +39,9 @@ namespace Vocaluxe.Base
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void SetGlobalVolume(float Volume)
|
||||
public static void SetGlobalVolume(float volume)
|
||||
{
|
||||
_Playback.SetGlobalVolume(Volume);
|
||||
_Playback.SetGlobalVolume(volume);
|
||||
}
|
||||
|
||||
public static int GetStreamCount()
|
||||
@@ -55,89 +55,89 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
#region Stream Handling
|
||||
public static int Load(string Media)
|
||||
public static int Load(string media)
|
||||
{
|
||||
return _Playback.Load(Media);
|
||||
return _Playback.Load(media);
|
||||
}
|
||||
|
||||
public static int Load(string Media, bool Prescan)
|
||||
public static int Load(string media, bool prescan)
|
||||
{
|
||||
return _Playback.Load(Media, Prescan);
|
||||
return _Playback.Load(media, prescan);
|
||||
}
|
||||
|
||||
public static void Close(int Stream)
|
||||
public static void Close(int stream)
|
||||
{
|
||||
_Playback.Close(Stream);
|
||||
_Playback.Close(stream);
|
||||
}
|
||||
|
||||
public static void Play(int Stream)
|
||||
public static void Play(int stream)
|
||||
{
|
||||
_Playback.Play(Stream);
|
||||
_Playback.Play(stream);
|
||||
}
|
||||
|
||||
public static void Play(int Stream, bool Loop)
|
||||
public static void Play(int stream, bool loop)
|
||||
{
|
||||
_Playback.Play(Stream, Loop);
|
||||
_Playback.Play(stream, loop);
|
||||
}
|
||||
|
||||
public static void Pause(int Stream)
|
||||
public static void Pause(int stream)
|
||||
{
|
||||
_Playback.Pause(Stream);
|
||||
_Playback.Pause(stream);
|
||||
}
|
||||
|
||||
public static void Stop(int Stream)
|
||||
public static void Stop(int stream)
|
||||
{
|
||||
_Playback.Stop(Stream);
|
||||
_Playback.Stop(stream);
|
||||
}
|
||||
|
||||
public static void Fade(int Stream, float TargetVolume, float Seconds)
|
||||
public static void Fade(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
_Playback.Fade(Stream, TargetVolume, Seconds);
|
||||
_Playback.Fade(stream, targetVolume, seconds);
|
||||
}
|
||||
|
||||
public static void FadeAndPause(int Stream, float TargetVolume, float Seconds)
|
||||
public static void FadeAndPause(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
_Playback.FadeAndPause(Stream, TargetVolume, Seconds);
|
||||
_Playback.FadeAndPause(stream, targetVolume, seconds);
|
||||
}
|
||||
|
||||
public static void FadeAndStop(int Stream, float TargetVolume, float Seconds)
|
||||
public static void FadeAndStop(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
_Playback.FadeAndStop(Stream, TargetVolume, Seconds);
|
||||
_Playback.FadeAndStop(stream, targetVolume, seconds);
|
||||
}
|
||||
|
||||
public static void SetStreamVolume(int Stream, float Volume)
|
||||
public static void SetStreamVolume(int stream, float volume)
|
||||
{
|
||||
_Playback.SetStreamVolume(Stream, Volume);
|
||||
_Playback.SetStreamVolume(stream, volume);
|
||||
}
|
||||
|
||||
public static void SetStreamVolumeMax(int Stream, float Volume)
|
||||
public static void SetStreamVolumeMax(int stream, float volume)
|
||||
{
|
||||
_Playback.SetStreamVolumeMax(Stream, Volume);
|
||||
_Playback.SetStreamVolumeMax(stream, volume);
|
||||
}
|
||||
|
||||
public static float GetLength(int Stream)
|
||||
public static float GetLength(int stream)
|
||||
{
|
||||
return _Playback.GetLength(Stream);
|
||||
return _Playback.GetLength(stream);
|
||||
}
|
||||
|
||||
public static float GetPosition(int Stream)
|
||||
public static float GetPosition(int stream)
|
||||
{
|
||||
return _Playback.GetPosition(Stream);
|
||||
return _Playback.GetPosition(stream);
|
||||
}
|
||||
|
||||
public static bool IsPlaying(int Stream)
|
||||
public static bool IsPlaying(int stream)
|
||||
{
|
||||
return _Playback.IsPlaying(Stream);
|
||||
return _Playback.IsPlaying(stream);
|
||||
}
|
||||
|
||||
public static bool IsPaused(int Stream)
|
||||
public static bool IsPaused(int stream)
|
||||
{
|
||||
return _Playback.IsPaused(Stream);
|
||||
return _Playback.IsPaused(stream);
|
||||
}
|
||||
|
||||
public static bool IsFinished(int Stream)
|
||||
public static bool IsFinished(int stream)
|
||||
{
|
||||
return _Playback.IsFinished(Stream);
|
||||
return _Playback.IsFinished(stream);
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
@@ -145,22 +145,22 @@ namespace Vocaluxe.Base
|
||||
_Playback.Update();
|
||||
}
|
||||
|
||||
public static void SetPosition(int Stream, float Position)
|
||||
public static void SetPosition(int stream, float position)
|
||||
{
|
||||
_Playback.SetPosition(Stream, Position);
|
||||
_Playback.SetPosition(stream, position);
|
||||
}
|
||||
#endregion Stream Handling
|
||||
|
||||
#endregion Playback
|
||||
|
||||
#region Sounds
|
||||
public static int PlaySound(ESounds Sound)
|
||||
public static int PlaySound(ESounds sound)
|
||||
{
|
||||
string file = Path.Combine(Environment.CurrentDirectory, CSettings.sFolderSounds);
|
||||
switch (Sound)
|
||||
string file = Path.Combine(Environment.CurrentDirectory, CSettings.FolderSounds);
|
||||
switch (sound)
|
||||
{
|
||||
case ESounds.T440:
|
||||
file = Path.Combine(file, CSettings.sSoundT440);
|
||||
file = Path.Combine(file, CSettings.SoundT440);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -217,44 +217,44 @@ namespace Vocaluxe.Base
|
||||
return _Record.Stop();
|
||||
}
|
||||
|
||||
public static void AnalyzeBuffer(int Player)
|
||||
public static void AnalyzeBuffer(int player)
|
||||
{
|
||||
_Record.AnalyzeBuffer(Player);
|
||||
_Record.AnalyzeBuffer(player);
|
||||
}
|
||||
|
||||
public static int RecordGetToneAbs(int Player)
|
||||
public static int RecordGetToneAbs(int player)
|
||||
{
|
||||
return _Record.GetToneAbs(Player);
|
||||
return _Record.GetToneAbs(player);
|
||||
}
|
||||
|
||||
public static int RecordGetTone(int Player)
|
||||
public static int RecordGetTone(int player)
|
||||
{
|
||||
return _Record.GetTone(Player);
|
||||
return _Record.GetTone(player);
|
||||
}
|
||||
|
||||
public static void RecordSetTone(int Player, int Tone)
|
||||
public static void RecordSetTone(int player, int tone)
|
||||
{
|
||||
_Record.SetTone(Player, Tone);
|
||||
_Record.SetTone(player, tone);
|
||||
}
|
||||
|
||||
public static bool RecordToneValid(int Player)
|
||||
public static bool RecordToneValid(int player)
|
||||
{
|
||||
return _Record.ToneValid(Player);
|
||||
return _Record.ToneValid(player);
|
||||
}
|
||||
|
||||
public static float RecordGetMaxVolume(int Player)
|
||||
public static float RecordGetMaxVolume(int player)
|
||||
{
|
||||
return _Record.GetMaxVolume(Player);
|
||||
return _Record.GetMaxVolume(player);
|
||||
}
|
||||
|
||||
public static int NumHalfTones(int Player)
|
||||
public static int NumHalfTones(int player)
|
||||
{
|
||||
return _Record.NumHalfTones(Player);
|
||||
return _Record.NumHalfTones(player);
|
||||
}
|
||||
|
||||
public static float[] ToneWeigth(int Player)
|
||||
public static float[] ToneWeigth(int player)
|
||||
{
|
||||
return _Record.ToneWeigth(Player);
|
||||
return _Record.ToneWeigth(player);
|
||||
}
|
||||
|
||||
public static SRecordDevice[] RecordGetDevices()
|
||||
@@ -269,8 +269,8 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
SInput input = devices[dev].Inputs[inp];
|
||||
|
||||
input.PlayerChannel1 = GetPlayerFromMicConfig(devices[dev].Name, devices[dev].Driver, input.Name, 1);
|
||||
input.PlayerChannel2 = GetPlayerFromMicConfig(devices[dev].Name, devices[dev].Driver, input.Name, 2);
|
||||
input.PlayerChannel1 = _GetPlayerFromMicConfig(devices[dev].Name, devices[dev].Driver, input.Name, 1);
|
||||
input.PlayerChannel2 = _GetPlayerFromMicConfig(devices[dev].Name, devices[dev].Driver, input.Name, 2);
|
||||
|
||||
devices[dev].Inputs[inp] = input;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ namespace Vocaluxe.Base
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int GetPlayerFromMicConfig(string device, string devicedriver, string input, int channel)
|
||||
private static int _GetPlayerFromMicConfig(string device, string devicedriver, string input, int channel)
|
||||
{
|
||||
for (int p = 0; p < CSettings.MaxNumPlayer; p++)
|
||||
{
|
||||
@@ -462,83 +462,83 @@ namespace Vocaluxe.Base
|
||||
_MaxVolume = 0;
|
||||
for (int i = 0; i < _AnalysisBuffer.Length / 4; i++)
|
||||
{
|
||||
float Volume = Math.Abs((float)_AnalysisBuffer[i]) / Int16.MaxValue;
|
||||
if (Volume > MaxVolume)
|
||||
_MaxVolume = Volume;
|
||||
float volume = Math.Abs((float)_AnalysisBuffer[i]) / Int16.MaxValue;
|
||||
if (volume > MaxVolume)
|
||||
_MaxVolume = volume;
|
||||
}
|
||||
|
||||
if (_MaxVolume >= 0.02f)
|
||||
AnalyzeByAutocorrelation(true);
|
||||
_AnalyzeByAutocorrelation(true);
|
||||
else
|
||||
AnalyzeByAutocorrelation(false);
|
||||
_AnalyzeByAutocorrelation(false);
|
||||
}
|
||||
catch (Exception) {}
|
||||
}
|
||||
|
||||
private void AnalyzeByAutocorrelation(bool valid)
|
||||
private void _AnalyzeByAutocorrelation(bool valid)
|
||||
{
|
||||
const double HalftoneBase = 1.05946309436; // 2^(1/12) -> HalftoneBase^12 = 2 (one octave)
|
||||
const double halftoneBase = 1.05946309436; // 2^(1/12) -> HalftoneBase^12 = 2 (one octave)
|
||||
|
||||
// prepare to analyze
|
||||
double MaxWeight = -1.0;
|
||||
double MinWeight = 1.0;
|
||||
int MaxTone = -1;
|
||||
float[] Weigth = new float[_NumHalfTones];
|
||||
double maxWeight = -1.0;
|
||||
double minWeight = 1.0;
|
||||
int maxTone = -1;
|
||||
float[] weigth = new float[_NumHalfTones];
|
||||
|
||||
// analyze halftones
|
||||
// Note: at the lowest tone (~65Hz) and a buffer-size of 4096
|
||||
// at 44.1 (or 48kHz) only 6 (or 5) samples are compared, this might be
|
||||
// too few samples -> use a bigger buffer-size
|
||||
for (int ToneIndex = 0; ToneIndex < _NumHalfTones; ToneIndex++)
|
||||
for (int toneIndex = 0; toneIndex < _NumHalfTones; toneIndex++)
|
||||
{
|
||||
double CurFreq = _BaseToneFreq * Math.Pow(HalftoneBase, ToneIndex);
|
||||
double CurWeight = AnalyzeAutocorrelationFreq(CurFreq);
|
||||
double curFreq = _BaseToneFreq * Math.Pow(halftoneBase, toneIndex);
|
||||
double curWeight = _AnalyzeAutocorrelationFreq(curFreq);
|
||||
|
||||
if (CurWeight > MaxWeight)
|
||||
if (curWeight > maxWeight)
|
||||
{
|
||||
MaxWeight = CurWeight;
|
||||
MaxTone = ToneIndex;
|
||||
maxWeight = curWeight;
|
||||
maxTone = toneIndex;
|
||||
}
|
||||
|
||||
if (CurWeight < MinWeight)
|
||||
MinWeight = CurWeight;
|
||||
if (curWeight < minWeight)
|
||||
minWeight = curWeight;
|
||||
|
||||
Weigth[ToneIndex] = (float)CurWeight;
|
||||
weigth[toneIndex] = (float)curWeight;
|
||||
}
|
||||
|
||||
if (valid && MaxWeight - MinWeight > 0.01)
|
||||
if (valid && maxWeight - minWeight > 0.01)
|
||||
{
|
||||
for (int i = 0; i < Weigth.Length; i++)
|
||||
_ToneWeigth[i] = Weigth[i];
|
||||
for (int i = 0; i < weigth.Length; i++)
|
||||
_ToneWeigth[i] = weigth[i];
|
||||
|
||||
_ToneAbs = MaxTone;
|
||||
_Tone = MaxTone % 12;
|
||||
_ToneAbs = maxTone;
|
||||
_Tone = maxTone % 12;
|
||||
_ToneValid = true;
|
||||
}
|
||||
else
|
||||
_ToneValid = false;
|
||||
}
|
||||
|
||||
private double AnalyzeAutocorrelationFreq(double Freq)
|
||||
private double _AnalyzeAutocorrelationFreq(double freq)
|
||||
{
|
||||
int SampleIndex = 0; // index of sample to analyze
|
||||
int SamplesPerPeriod = (int)Math.Round(44100.0 / Freq); // samples in one period
|
||||
int CorrelatingSampleIndex = SampleIndex + SamplesPerPeriod; // index of sample one period ahead
|
||||
int sampleIndex = 0; // index of sample to analyze
|
||||
int samplesPerPeriod = (int)Math.Round(44100.0 / freq); // samples in one period
|
||||
int correlatingSampleIndex = sampleIndex + samplesPerPeriod; // index of sample one period ahead
|
||||
|
||||
double AccumDist = 0.0; // accumulated distances
|
||||
double accumDist = 0.0; // accumulated distances
|
||||
|
||||
// compare correlating samples
|
||||
while (CorrelatingSampleIndex < _AnalysisBuffer.Length)
|
||||
while (correlatingSampleIndex < _AnalysisBuffer.Length)
|
||||
{
|
||||
// calc distance (correlation: 1-dist) to corresponding sample in next period
|
||||
// distance (0=equal .. 1=totally different) between correlated samples
|
||||
double Dist = Math.Abs((double)_AnalysisBuffer[SampleIndex] - _AnalysisBuffer[CorrelatingSampleIndex]) / Int16.MaxValue;
|
||||
AccumDist += Dist;
|
||||
SampleIndex++;
|
||||
CorrelatingSampleIndex++;
|
||||
double dist = Math.Abs((double)_AnalysisBuffer[sampleIndex] - _AnalysisBuffer[correlatingSampleIndex]) / Int16.MaxValue;
|
||||
accumDist += dist;
|
||||
sampleIndex++;
|
||||
correlatingSampleIndex++;
|
||||
}
|
||||
|
||||
return 1 - AccumDist / _AnalysisBuffer.Length;
|
||||
return 1 - accumDist / _AnalysisBuffer.Length;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -554,7 +554,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
class CSyncTimer
|
||||
{
|
||||
private readonly PT1 _ExternTime;
|
||||
private readonly CPt1 _ExternTime;
|
||||
private readonly Stopwatch _Timer;
|
||||
private float _SetValue;
|
||||
|
||||
@@ -581,16 +581,16 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
public CSyncTimer(float CurrentTime, float K, float T)
|
||||
public CSyncTimer(float currentTime, float k, float t)
|
||||
{
|
||||
_ExternTime = new PT1(CurrentTime, K, T);
|
||||
_ExternTime = new CPt1(currentTime, k, t);
|
||||
_Timer = new Stopwatch();
|
||||
_SetValue = CurrentTime;
|
||||
_SetValue = currentTime;
|
||||
}
|
||||
|
||||
public float Update(float NewTime)
|
||||
public float Update(float newTime)
|
||||
{
|
||||
float et = _ExternTime.Update(NewTime);
|
||||
float et = _ExternTime.Update(newTime);
|
||||
|
||||
float dt = Time;
|
||||
|
||||
@@ -628,12 +628,12 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class PT1
|
||||
class CPt1
|
||||
{
|
||||
private float _CurrentTime;
|
||||
private float _OldTime;
|
||||
|
||||
private readonly Stopwatch _STimer;
|
||||
private readonly Stopwatch _Timer;
|
||||
private readonly float _K;
|
||||
private readonly float _T;
|
||||
|
||||
@@ -642,8 +642,8 @@ namespace Vocaluxe.Base
|
||||
get
|
||||
{
|
||||
double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
long ticks = _STimer.ElapsedTicks;
|
||||
float dt = _STimer.ElapsedMilliseconds / 1000f;
|
||||
long ticks = _Timer.ElapsedTicks;
|
||||
float dt = _Timer.ElapsedMilliseconds / 1000f;
|
||||
|
||||
if (Stopwatch.IsHighResolution && ticks != 0)
|
||||
dt = (float)(ticks * nanosecPerTick / 1000000000.0);
|
||||
@@ -658,53 +658,53 @@ namespace Vocaluxe.Base
|
||||
|
||||
_CurrentTime = value;
|
||||
_OldTime = value;
|
||||
_STimer.Reset();
|
||||
_STimer.Start();
|
||||
_Timer.Reset();
|
||||
_Timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public PT1(float CurrentTime, float K, float T)
|
||||
public CPt1(float currentTime, float k, float t)
|
||||
{
|
||||
_CurrentTime = CurrentTime;
|
||||
_OldTime = CurrentTime;
|
||||
_CurrentTime = currentTime;
|
||||
_OldTime = currentTime;
|
||||
|
||||
_STimer = new Stopwatch();
|
||||
_K = K;
|
||||
_T = T;
|
||||
_Timer = new Stopwatch();
|
||||
_K = k;
|
||||
_T = t;
|
||||
}
|
||||
|
||||
public float Update(float NewTime)
|
||||
public float Update(float newTime)
|
||||
{
|
||||
_STimer.Stop();
|
||||
_Timer.Stop();
|
||||
|
||||
double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
long ticks = _STimer.ElapsedTicks;
|
||||
float dt = _STimer.ElapsedMilliseconds / 1000f;
|
||||
long ticks = _Timer.ElapsedTicks;
|
||||
float dt = _Timer.ElapsedMilliseconds / 1000f;
|
||||
|
||||
if (Stopwatch.IsHighResolution && ticks != 0)
|
||||
dt = (float)(ticks * nanosecPerTick / 1000000000.0);
|
||||
|
||||
float Ts = 0f;
|
||||
float ts = 0f;
|
||||
if (dt > 0)
|
||||
Ts = 1 / (_T / dt + 1);
|
||||
ts = 1 / (_T / dt + 1);
|
||||
|
||||
_CurrentTime = Ts * (_K * NewTime - _OldTime) + _OldTime;
|
||||
_CurrentTime = ts * (_K * newTime - _OldTime) + _OldTime;
|
||||
_OldTime = _CurrentTime;
|
||||
|
||||
_STimer.Reset();
|
||||
_STimer.Start();
|
||||
_Timer.Reset();
|
||||
_Timer.Start();
|
||||
|
||||
return _CurrentTime;
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
_STimer.Stop();
|
||||
_Timer.Stop();
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
_STimer.Start();
|
||||
_Timer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
+232
-232
@@ -10,7 +10,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
|
||||
#region Structs
|
||||
struct Theme
|
||||
struct STheme
|
||||
{
|
||||
public string Name;
|
||||
public string Author;
|
||||
@@ -23,7 +23,7 @@ namespace Vocaluxe.Base
|
||||
public int PartyModeID;
|
||||
}
|
||||
|
||||
struct SkinElement
|
||||
struct SSkinElement
|
||||
{
|
||||
public string Name;
|
||||
public string Value;
|
||||
@@ -32,7 +32,7 @@ namespace Vocaluxe.Base
|
||||
public int VideoIndex;
|
||||
}
|
||||
|
||||
struct Skin
|
||||
struct SSkin
|
||||
{
|
||||
public string Name;
|
||||
public string Author;
|
||||
@@ -43,8 +43,8 @@ namespace Vocaluxe.Base
|
||||
public string FileName;
|
||||
public int PartyModeID;
|
||||
|
||||
public Dictionary<string, SkinElement> SkinList;
|
||||
public List<SkinElement> VideoList;
|
||||
public Dictionary<string, SSkinElement> SkinList;
|
||||
public List<SSkinElement> VideoList;
|
||||
|
||||
public SColors ThemeColors;
|
||||
}
|
||||
@@ -65,33 +65,33 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
public string SkinName;
|
||||
|
||||
public float w;
|
||||
public float h;
|
||||
public float W;
|
||||
public float H;
|
||||
|
||||
public float r;
|
||||
public float g;
|
||||
public float b;
|
||||
public float a;
|
||||
public float R;
|
||||
public float G;
|
||||
public float B;
|
||||
public float A;
|
||||
|
||||
public string color;
|
||||
public string Color;
|
||||
}
|
||||
#endregion Structs
|
||||
|
||||
static class CTheme
|
||||
{
|
||||
// Version number for main theme and skin files. Increment it, if you've changed something on the theme files!
|
||||
private const int ThemeSystemVersion = 5;
|
||||
private const int SkinSystemVersion = 3;
|
||||
private const int _ThemeSystemVersion = 5;
|
||||
private const int _SkinSystemVersion = 3;
|
||||
|
||||
#region Vars
|
||||
private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
|
||||
private static readonly List<Theme> _Themes = new List<Theme>();
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
private static readonly List<STheme> _Themes = new List<STheme>();
|
||||
public static string[] ThemeNames
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> names = new List<string>();
|
||||
foreach (Theme th in _Themes)
|
||||
foreach (STheme th in _Themes)
|
||||
{
|
||||
if (th.PartyModeID == -1)
|
||||
names.Add(th.Name);
|
||||
@@ -100,13 +100,13 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly List<Skin> _Skins = new List<Skin>();
|
||||
private static readonly List<SSkin> _Skins = new List<SSkin>();
|
||||
public static string[] SkinNames
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> names = new List<string>();
|
||||
foreach (Skin sk in _Skins)
|
||||
foreach (SSkin sk in _Skins)
|
||||
{
|
||||
if (sk.PartyModeID == -1)
|
||||
names.Add(sk.Name);
|
||||
@@ -121,11 +121,11 @@ namespace Vocaluxe.Base
|
||||
#region Theme and Skin loading and writing
|
||||
public static void InitTheme()
|
||||
{
|
||||
_settings.Indent = true;
|
||||
_settings.Encoding = Encoding.UTF8;
|
||||
_settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
_Settings.Indent = true;
|
||||
_Settings.Encoding = Encoding.UTF8;
|
||||
_Settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
|
||||
ListThemes();
|
||||
_ListThemes();
|
||||
ListSkins();
|
||||
|
||||
LoadSkins();
|
||||
@@ -141,9 +141,9 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
public static bool LoadSkin(int SkinIndex)
|
||||
public static bool LoadSkin(int skinIndex)
|
||||
{
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Skins[SkinIndex].Path, _Skins[SkinIndex].FileName));
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Skins[skinIndex].Path, _Skins[skinIndex].FileName));
|
||||
if (xmlReader == null)
|
||||
return false;
|
||||
|
||||
@@ -151,18 +151,18 @@ namespace Vocaluxe.Base
|
||||
|
||||
|
||||
// load skins/textures
|
||||
List<string> keys = new List<string>(_Skins[SkinIndex].SkinList.Keys);
|
||||
List<string> keys = new List<string>(_Skins[skinIndex].SkinList.Keys);
|
||||
|
||||
foreach (string name in keys)
|
||||
{
|
||||
try
|
||||
{
|
||||
xmlReader.GetValue("//root/Skins/" + name, ref value, String.Empty);
|
||||
SkinElement sk = _Skins[SkinIndex].SkinList[name];
|
||||
SSkinElement sk = _Skins[skinIndex].SkinList[name];
|
||||
sk.Value = value;
|
||||
sk.VideoIndex = -1;
|
||||
sk.Texture = CDraw.AddTexture(Path.Combine(_Skins[SkinIndex].Path, sk.Value));
|
||||
_Skins[SkinIndex].SkinList[name] = sk;
|
||||
sk.Texture = CDraw.AddTexture(Path.Combine(_Skins[skinIndex].Path, sk.Value));
|
||||
_Skins[skinIndex].SkinList[name] = sk;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -173,55 +173,55 @@ namespace Vocaluxe.Base
|
||||
|
||||
|
||||
// load videos
|
||||
for (int i = 0; i < _Skins[SkinIndex].VideoList.Count; i++)
|
||||
for (int i = 0; i < _Skins[skinIndex].VideoList.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
xmlReader.GetValue("//root/Videos/" + _Skins[SkinIndex].VideoList[i].Name, ref value, String.Empty);
|
||||
SkinElement sk = new SkinElement();
|
||||
sk.Name = _Skins[SkinIndex].VideoList[i].Name;
|
||||
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;
|
||||
sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[SkinIndex].Path, sk.Value));
|
||||
sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[skinIndex].Path, sk.Value));
|
||||
CVideo.VdSetLoop(sk.VideoIndex, true);
|
||||
CVideo.VdPause(sk.VideoIndex);
|
||||
sk.Texture = new STexture(-1);
|
||||
_Skins[SkinIndex].VideoList[i] = sk;
|
||||
_Skins[skinIndex].VideoList[i] = sk;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Error on loading video \"" + _Skins[SkinIndex].VideoList[i].Name + "\": " + e.Message + e.StackTrace);
|
||||
CLog.LogError("Error on loading video \"" + _Skins[SkinIndex].VideoList[i].Name + "\": " + e.Message + e.StackTrace);
|
||||
MessageBox.Show("Error on loading video \"" + _Skins[skinIndex].VideoList[i].Name + "\": " + e.Message + e.StackTrace);
|
||||
CLog.LogError("Error on loading video \"" + _Skins[skinIndex].VideoList[i].Name + "\": " + e.Message + e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
// load colors
|
||||
LoadColors(xmlReader, SkinIndex);
|
||||
_LoadColors(xmlReader, skinIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void UnloadSkins()
|
||||
{
|
||||
int NumPartyModeSkins = 0;
|
||||
int numPartyModeSkins = 0;
|
||||
for (int i = 0; i < _Skins.Count; i++)
|
||||
{
|
||||
foreach (SkinElement sk in _Skins[i].SkinList.Values)
|
||||
foreach (SSkinElement sk in _Skins[i].SkinList.Values)
|
||||
{
|
||||
STexture Texture = sk.Texture;
|
||||
CDraw.RemoveTexture(ref Texture);
|
||||
STexture texture = sk.Texture;
|
||||
CDraw.RemoveTexture(ref texture);
|
||||
}
|
||||
|
||||
for (int j = 0; j < _Skins[i].VideoList.Count; j++)
|
||||
{
|
||||
CVideo.VdClose(_Skins[i].VideoList[j].VideoIndex);
|
||||
STexture VideoTexture = _Skins[i].VideoList[j].Texture;
|
||||
CDraw.RemoveTexture(ref VideoTexture);
|
||||
STexture videoTexture = _Skins[i].VideoList[j].Texture;
|
||||
CDraw.RemoveTexture(ref videoTexture);
|
||||
}
|
||||
|
||||
if (_Skins[i].PartyModeID != -1)
|
||||
NumPartyModeSkins++;
|
||||
numPartyModeSkins++;
|
||||
}
|
||||
|
||||
while (_Skins.Count > NumPartyModeSkins)
|
||||
while (_Skins.Count > numPartyModeSkins)
|
||||
{
|
||||
int num = _Skins.Count;
|
||||
for (int i = 0; i < num; i++)
|
||||
@@ -244,36 +244,36 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
public static bool LoadTheme(int ThemeIndex)
|
||||
public static bool LoadTheme(int themeIndex)
|
||||
{
|
||||
if (ThemeIndex < 0 || ThemeIndex >= _Themes.Count)
|
||||
if (themeIndex < 0 || themeIndex >= _Themes.Count)
|
||||
{
|
||||
CLog.LogError("Can't find Theme Index " + ThemeIndex.ToString());
|
||||
CLog.LogError("Can't find Theme Index " + themeIndex.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Themes[ThemeIndex].Path, _Themes[ThemeIndex].FileName));
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].FileName));
|
||||
if (xmlReader == null)
|
||||
return false;
|
||||
|
||||
int skinIndex = GetSkinIndex(_Themes[ThemeIndex].PartyModeID);
|
||||
int skinIndex = GetSkinIndex(_Themes[themeIndex].PartyModeID);
|
||||
|
||||
// Load Cursor
|
||||
if (_Themes[ThemeIndex].PartyModeID == -1)
|
||||
LoadCursor(xmlReader, skinIndex);
|
||||
if (_Themes[themeIndex].PartyModeID == -1)
|
||||
_LoadCursor(xmlReader, skinIndex);
|
||||
|
||||
// load fonts
|
||||
if (_Themes[ThemeIndex].PartyModeID == -1)
|
||||
if (_Themes[themeIndex].PartyModeID == -1)
|
||||
{
|
||||
CFonts.LoadThemeFonts(
|
||||
_Themes[ThemeIndex].Name,
|
||||
Path.Combine(Path.Combine(_Themes[ThemeIndex].Path, _Themes[ThemeIndex].SkinFolder), CSettings.sFolderThemeFonts),
|
||||
_Themes[themeIndex].Name,
|
||||
Path.Combine(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].SkinFolder), CSettings.FolderThemeFonts),
|
||||
xmlReader);
|
||||
}
|
||||
else
|
||||
{
|
||||
CFonts.LoadPartyModeFonts(_Themes[ThemeIndex].PartyModeID,
|
||||
Path.Combine(_Themes[ThemeIndex].Path, CSettings.sFolderPartyModeFonts),
|
||||
CFonts.LoadPartyModeFonts(_Themes[themeIndex].PartyModeID,
|
||||
Path.Combine(_Themes[themeIndex].Path, CSettings.FolderPartyModeFonts),
|
||||
xmlReader);
|
||||
}
|
||||
return true;
|
||||
@@ -286,40 +286,40 @@ namespace Vocaluxe.Base
|
||||
for (int i = 0; i < _Themes.Count; i++)
|
||||
{
|
||||
if (_Themes[i].Name == CConfig.Theme && _Themes[i].PartyModeID == -1 || _Themes[i].PartyModeID != -1)
|
||||
SaveTheme(i);
|
||||
_SaveTheme(i);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveTheme(int ThemeIndex)
|
||||
private static void _SaveTheme(int themeIndex)
|
||||
{
|
||||
#region ThemeMainFile
|
||||
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Themes[ThemeIndex].Path, _Themes[ThemeIndex].FileName), _settings))
|
||||
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].FileName), _Settings))
|
||||
{
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("root");
|
||||
|
||||
// ThemeSystemVersion
|
||||
writer.WriteElementString("ThemeSystemVersion", ThemeSystemVersion.ToString());
|
||||
writer.WriteElementString("ThemeSystemVersion", _ThemeSystemVersion.ToString());
|
||||
|
||||
#region Info
|
||||
writer.WriteStartElement("Info");
|
||||
|
||||
writer.WriteElementString("Name", _Themes[ThemeIndex].Name);
|
||||
writer.WriteElementString("Author", _Themes[ThemeIndex].Author);
|
||||
writer.WriteElementString("SkinFolder", _Themes[ThemeIndex].SkinFolder);
|
||||
writer.WriteElementString("ThemeVersionMajor", _Themes[ThemeIndex].ThemeVersionMajor.ToString());
|
||||
writer.WriteElementString("ThemeVersionMinor", _Themes[ThemeIndex].ThemeVersionMinor.ToString());
|
||||
writer.WriteElementString("Name", _Themes[themeIndex].Name);
|
||||
writer.WriteElementString("Author", _Themes[themeIndex].Author);
|
||||
writer.WriteElementString("SkinFolder", _Themes[themeIndex].SkinFolder);
|
||||
writer.WriteElementString("ThemeVersionMajor", _Themes[themeIndex].ThemeVersionMajor.ToString());
|
||||
writer.WriteElementString("ThemeVersionMinor", _Themes[themeIndex].ThemeVersionMinor.ToString());
|
||||
|
||||
writer.WriteEndElement();
|
||||
#endregion Info
|
||||
|
||||
// Cursor
|
||||
if (_Themes[ThemeIndex].PartyModeID == -1)
|
||||
SaveCursor(writer);
|
||||
if (_Themes[themeIndex].PartyModeID == -1)
|
||||
_SaveCursor(writer);
|
||||
|
||||
// save fonts
|
||||
if (_Themes[ThemeIndex].PartyModeID == -1)
|
||||
CFonts.SaveThemeFonts(_Themes[ThemeIndex].Name, writer);
|
||||
if (_Themes[themeIndex].PartyModeID == -1)
|
||||
CFonts.SaveThemeFonts(_Themes[themeIndex].Name, writer);
|
||||
|
||||
|
||||
// End of File
|
||||
@@ -333,34 +333,34 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void SaveSkin()
|
||||
{
|
||||
for (int SkinIndex = 0; SkinIndex < _Skins.Count; SkinIndex++)
|
||||
for (int skinIndex = 0; skinIndex < _Skins.Count; skinIndex++)
|
||||
{
|
||||
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Skins[SkinIndex].Path, _Skins[SkinIndex].FileName), _settings))
|
||||
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Skins[skinIndex].Path, _Skins[skinIndex].FileName), _Settings))
|
||||
{
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("root");
|
||||
|
||||
// ThemeSystemVersion
|
||||
writer.WriteElementString("SkinSystemVersion", SkinSystemVersion.ToString());
|
||||
writer.WriteElementString("SkinSystemVersion", _SkinSystemVersion.ToString());
|
||||
|
||||
#region Info
|
||||
writer.WriteStartElement("Info");
|
||||
|
||||
writer.WriteElementString("Name", _Skins[SkinIndex].Name);
|
||||
writer.WriteElementString("Author", _Skins[SkinIndex].Author);
|
||||
writer.WriteElementString("SkinVersionMajor", _Skins[SkinIndex].SkinVersionMajor.ToString());
|
||||
writer.WriteElementString("SkinVersionMinor", _Skins[SkinIndex].SkinVersionMinor.ToString());
|
||||
writer.WriteElementString("Name", _Skins[skinIndex].Name);
|
||||
writer.WriteElementString("Author", _Skins[skinIndex].Author);
|
||||
writer.WriteElementString("SkinVersionMajor", _Skins[skinIndex].SkinVersionMajor.ToString());
|
||||
writer.WriteElementString("SkinVersionMinor", _Skins[skinIndex].SkinVersionMinor.ToString());
|
||||
|
||||
writer.WriteEndElement();
|
||||
#endregion Info
|
||||
|
||||
// save colors
|
||||
SaveColors(writer, SkinIndex);
|
||||
_SaveColors(writer, skinIndex);
|
||||
|
||||
#region Skins
|
||||
writer.WriteStartElement("Skins");
|
||||
|
||||
foreach (SkinElement element in _Skins[SkinIndex].SkinList.Values)
|
||||
foreach (SSkinElement element in _Skins[skinIndex].SkinList.Values)
|
||||
writer.WriteElementString(element.Name, element.Value);
|
||||
writer.WriteEndElement();
|
||||
#endregion Skins
|
||||
@@ -368,7 +368,7 @@ namespace Vocaluxe.Base
|
||||
#region Videos
|
||||
writer.WriteStartElement("Videos");
|
||||
|
||||
foreach (SkinElement element in _Skins[SkinIndex].VideoList)
|
||||
foreach (SSkinElement element in _Skins[skinIndex].VideoList)
|
||||
writer.WriteElementString(element.Name, element.Value);
|
||||
writer.WriteEndElement();
|
||||
#endregion Videos
|
||||
@@ -382,29 +382,29 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
private static void ListThemes()
|
||||
private static void _ListThemes()
|
||||
{
|
||||
_Themes.Clear();
|
||||
|
||||
string path = Path.Combine(Directory.GetCurrentDirectory(), CSettings.sFolderThemes);
|
||||
string path = Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderThemes);
|
||||
List<string> files = CHelper.ListFiles(path, "*.xml", false);
|
||||
|
||||
foreach (string file in files)
|
||||
AddTheme(Path.Combine(path, file), -1);
|
||||
}
|
||||
|
||||
public static bool AddTheme(string FilePath, int PartyModeID)
|
||||
public static bool AddTheme(string filePath, int partyModeID)
|
||||
{
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(FilePath);
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(filePath);
|
||||
if (xmlReader == null)
|
||||
return false;
|
||||
|
||||
Theme theme = new Theme();
|
||||
STheme theme = new STheme();
|
||||
|
||||
int version = 0;
|
||||
xmlReader.TryGetIntValue("//root/ThemeSystemVersion", ref version);
|
||||
|
||||
if (version == ThemeSystemVersion)
|
||||
if (version == _ThemeSystemVersion)
|
||||
{
|
||||
xmlReader.GetValue("//root/Info/Name", ref theme.Name, String.Empty);
|
||||
if (theme.Name.Length > 0)
|
||||
@@ -413,22 +413,22 @@ namespace Vocaluxe.Base
|
||||
xmlReader.GetValue("//root/Info/SkinFolder", ref 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);
|
||||
theme.FileName = Path.GetFileName(FilePath);
|
||||
theme.PartyModeID = PartyModeID;
|
||||
theme.Path = Path.GetDirectoryName(filePath);
|
||||
theme.FileName = Path.GetFileName(filePath);
|
||||
theme.PartyModeID = partyModeID;
|
||||
|
||||
_Themes.Add(theme);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = "Can't load Theme \"" + FilePath + "\", ";
|
||||
if (version < ThemeSystemVersion)
|
||||
string msg = "Can't load Theme \"" + filePath + "\", ";
|
||||
if (version < _ThemeSystemVersion)
|
||||
msg += "the file is outdated! ";
|
||||
else
|
||||
msg += "the file is for newer program versions! ";
|
||||
|
||||
msg += "Current ThemeSystemVersion is " + ThemeSystemVersion.ToString() + " but found " + version;
|
||||
msg += "Current ThemeSystemVersion is " + _ThemeSystemVersion.ToString() + " but found " + version;
|
||||
CLog.LogError(msg);
|
||||
}
|
||||
return true;
|
||||
@@ -447,15 +447,15 @@ namespace Vocaluxe.Base
|
||||
ListSkins(themeIndex);
|
||||
}
|
||||
|
||||
public static void ListSkins(int ThemeIndex)
|
||||
public static void ListSkins(int themeIndex)
|
||||
{
|
||||
if (ThemeIndex < 0 || ThemeIndex >= _Themes.Count)
|
||||
if (themeIndex < 0 || themeIndex >= _Themes.Count)
|
||||
{
|
||||
CLog.LogError("Error List Skins. Can't find Theme index: " + ThemeIndex.ToString());
|
||||
CLog.LogError("Error List Skins. Can't find Theme index: " + themeIndex.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
Theme theme = _Themes[ThemeIndex];
|
||||
STheme theme = _Themes[themeIndex];
|
||||
|
||||
string path = Path.Combine(theme.Path, theme.SkinFolder);
|
||||
List<string> files = CHelper.ListFiles(path, "*.xml", false);
|
||||
@@ -466,12 +466,12 @@ namespace Vocaluxe.Base
|
||||
if (xmlReader == null)
|
||||
continue;
|
||||
|
||||
Skin skin = new Skin();
|
||||
SSkin skin = new SSkin();
|
||||
|
||||
int version = 0;
|
||||
xmlReader.TryGetIntValue("//root/SkinSystemVersion", ref version);
|
||||
|
||||
if (version == SkinSystemVersion)
|
||||
if (version == _SkinSystemVersion)
|
||||
{
|
||||
xmlReader.GetValue("//root/Info/Name", ref skin.Name, String.Empty);
|
||||
if (skin.Name.Length > 0)
|
||||
@@ -485,21 +485,21 @@ namespace Vocaluxe.Base
|
||||
skin.FileName = file;
|
||||
skin.PartyModeID = theme.PartyModeID;
|
||||
|
||||
skin.SkinList = new Dictionary<string, SkinElement>();
|
||||
skin.SkinList = new Dictionary<string, SSkinElement>();
|
||||
List<string> names = xmlReader.GetValues("Skins");
|
||||
foreach (string str in names)
|
||||
{
|
||||
SkinElement sk = new SkinElement();
|
||||
SSkinElement sk = new SSkinElement();
|
||||
sk.Name = str;
|
||||
sk.Value = String.Empty;
|
||||
skin.SkinList[str] = sk;
|
||||
}
|
||||
|
||||
skin.VideoList = new List<SkinElement>();
|
||||
skin.VideoList = new List<SSkinElement>();
|
||||
names = xmlReader.GetValues("Videos");
|
||||
foreach (string str in names)
|
||||
{
|
||||
SkinElement sk = new SkinElement();
|
||||
SSkinElement sk = new SSkinElement();
|
||||
sk.Name = str;
|
||||
sk.Value = String.Empty;
|
||||
skin.VideoList.Add(sk);
|
||||
@@ -510,12 +510,12 @@ namespace Vocaluxe.Base
|
||||
else
|
||||
{
|
||||
string msg = "Can't load Skin \"" + file + "\", ";
|
||||
if (version < SkinSystemVersion)
|
||||
if (version < _SkinSystemVersion)
|
||||
msg += "the file ist outdated! ";
|
||||
else
|
||||
msg += "the file is for newer program versions! ";
|
||||
|
||||
msg += "Current SkinSystemVersion is " + SkinSystemVersion.ToString();
|
||||
msg += "Current SkinSystemVersion is " + _SkinSystemVersion.ToString();
|
||||
CLog.LogError(msg);
|
||||
}
|
||||
}
|
||||
@@ -523,41 +523,41 @@ namespace Vocaluxe.Base
|
||||
#endregion Theme and Skin loading and writing
|
||||
|
||||
#region Theme and Skin index handling
|
||||
public static int GetSkinIndex(int PartyModeID)
|
||||
public static int GetSkinIndex(int partyModeID)
|
||||
{
|
||||
for (int i = 0; i < _Skins.Count; i++)
|
||||
{
|
||||
if (PartyModeID != -1 && _Skins[i].PartyModeID == PartyModeID)
|
||||
if (partyModeID != -1 && _Skins[i].PartyModeID == partyModeID)
|
||||
return i;
|
||||
else if (PartyModeID == -1 && _Skins[i].Name == CConfig.Skin)
|
||||
else if (partyModeID == -1 && _Skins[i].Name == CConfig.Skin)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int GetThemeIndex(int PartyModeID)
|
||||
public static int GetThemeIndex(int partyModeID)
|
||||
{
|
||||
for (int i = 0; i < _Themes.Count; i++)
|
||||
{
|
||||
if (PartyModeID != -1 && _Themes[i].PartyModeID == PartyModeID)
|
||||
if (partyModeID != -1 && _Themes[i].PartyModeID == partyModeID)
|
||||
return i;
|
||||
else if (PartyModeID == -1 && _Themes[i].Name == CConfig.Theme)
|
||||
else if (partyModeID == -1 && _Themes[i].Name == CConfig.Theme)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static string GetThemeScreensPath(int PartyModeID)
|
||||
public static string GetThemeScreensPath(int partyModeID)
|
||||
{
|
||||
string path = String.Empty;
|
||||
|
||||
int themeIndex = GetThemeIndex(PartyModeID);
|
||||
int themeIndex = GetThemeIndex(partyModeID);
|
||||
if (themeIndex != -1)
|
||||
{
|
||||
path = Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].SkinFolder);
|
||||
path = Path.Combine(path, CSettings.sFolderScreens);
|
||||
path = Path.Combine(path, CSettings.FolderScreens);
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find current Theme");
|
||||
@@ -565,59 +565,59 @@ namespace Vocaluxe.Base
|
||||
return path;
|
||||
}
|
||||
|
||||
public static STexture GetSkinTexture(string TextureName, int PartyModeID)
|
||||
public static STexture GetSkinTexture(string textureName, int partyModeID)
|
||||
{
|
||||
int SkinIndex = GetSkinIndex(PartyModeID);
|
||||
if (SkinIndex != -1 && TextureName != null && _Skins[SkinIndex].SkinList.ContainsKey(TextureName))
|
||||
return _Skins[SkinIndex].SkinList[TextureName].Texture;
|
||||
int skinIndex = GetSkinIndex(partyModeID);
|
||||
if (skinIndex != -1 && textureName != null && _Skins[skinIndex].SkinList.ContainsKey(textureName))
|
||||
return _Skins[skinIndex].SkinList[textureName].Texture;
|
||||
return new STexture(-1);
|
||||
}
|
||||
|
||||
public static string GetSkinFilePath(string SkinName, int PartyModeID)
|
||||
public static string GetSkinFilePath(string skinName, int partyModeID)
|
||||
{
|
||||
return GetSkinFileName(SkinName, GetSkinIndex(PartyModeID), true);
|
||||
return _GetSkinFileName(skinName, GetSkinIndex(partyModeID), true);
|
||||
}
|
||||
|
||||
private static string GetSkinFileName(string SkinName, int SkinIndex)
|
||||
private static string _GetSkinFileName(string skinName, int skinIndex)
|
||||
{
|
||||
return GetSkinFileName(SkinName, SkinIndex, false);
|
||||
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)
|
||||
{
|
||||
foreach (SkinElement sk in _Skins[SkinIndex].SkinList.Values)
|
||||
foreach (SSkinElement sk in _Skins[skinIndex].SkinList.Values)
|
||||
{
|
||||
if (sk.Name == SkinName)
|
||||
if (sk.Name == skinName)
|
||||
{
|
||||
if (!ReturnPath)
|
||||
if (!returnPath)
|
||||
return sk.Value;
|
||||
else
|
||||
return Path.Combine(_Skins[SkinIndex].Path, sk.Value);
|
||||
return Path.Combine(_Skins[skinIndex].Path, sk.Value);
|
||||
}
|
||||
}
|
||||
|
||||
CLog.LogError("Can't find Skin Element \"" + SkinName);
|
||||
return SkinName;
|
||||
CLog.LogError("Can't find Skin Element \"" + skinName);
|
||||
return skinName;
|
||||
}
|
||||
|
||||
public static STexture GetSkinVideoTexture(string VideoName, int PartyModeID)
|
||||
public static STexture GetSkinVideoTexture(string videoName, int partyModeID)
|
||||
{
|
||||
int SkinIndex = GetSkinIndex(PartyModeID);
|
||||
if (SkinIndex != -1)
|
||||
int skinIndex = GetSkinIndex(partyModeID);
|
||||
if (skinIndex != -1)
|
||||
{
|
||||
for (int i = 0; i < _Skins[SkinIndex].VideoList.Count; i++)
|
||||
for (int i = 0; i < _Skins[skinIndex].VideoList.Count; i++)
|
||||
{
|
||||
SkinElement sk = _Skins[SkinIndex].VideoList[i];
|
||||
if (sk.Name == VideoName)
|
||||
SSkinElement sk = _Skins[skinIndex].VideoList[i];
|
||||
if (sk.Name == videoName)
|
||||
{
|
||||
float Time = 0f;
|
||||
float time = 0f;
|
||||
if (sk.VideoIndex == -1)
|
||||
{
|
||||
sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, PartyModeID));
|
||||
sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, partyModeID));
|
||||
CVideo.VdSetLoop(sk.VideoIndex, true);
|
||||
}
|
||||
CVideo.VdGetFrame(sk.VideoIndex, ref sk.Texture, Time, ref Time);
|
||||
_Skins[SkinIndex].VideoList[i] = sk;
|
||||
CVideo.VdGetFrame(sk.VideoIndex, ref sk.Texture, time, ref time);
|
||||
_Skins[skinIndex].VideoList[i] = sk;
|
||||
return sk.Texture;
|
||||
}
|
||||
}
|
||||
@@ -625,88 +625,88 @@ namespace Vocaluxe.Base
|
||||
return new STexture(-1);
|
||||
}
|
||||
|
||||
public static void SkinVideoPause(string VideoName, int PartyModeID)
|
||||
public static void SkinVideoPause(string videoName, int partyModeID)
|
||||
{
|
||||
int SkinIndex = GetSkinIndex(PartyModeID);
|
||||
if (SkinIndex != -1)
|
||||
int skinIndex = GetSkinIndex(partyModeID);
|
||||
if (skinIndex != -1)
|
||||
{
|
||||
for (int i = 0; i < _Skins[SkinIndex].VideoList.Count; i++)
|
||||
for (int i = 0; i < _Skins[skinIndex].VideoList.Count; i++)
|
||||
{
|
||||
SkinElement sk = _Skins[SkinIndex].VideoList[i];
|
||||
if (sk.Name == VideoName)
|
||||
SSkinElement sk = _Skins[skinIndex].VideoList[i];
|
||||
if (sk.Name == videoName)
|
||||
{
|
||||
if (sk.VideoIndex == -1)
|
||||
{
|
||||
sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, PartyModeID));
|
||||
sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, partyModeID));
|
||||
CVideo.VdSetLoop(sk.VideoIndex, true);
|
||||
}
|
||||
CVideo.VdPause(sk.VideoIndex);
|
||||
_Skins[SkinIndex].VideoList[i] = sk;
|
||||
_Skins[skinIndex].VideoList[i] = sk;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SkinVideoResume(string VideoName, int PartyModeID)
|
||||
public static void SkinVideoResume(string videoName, int partyModeID)
|
||||
{
|
||||
int SkinIndex = GetSkinIndex(PartyModeID);
|
||||
if (SkinIndex != -1)
|
||||
int skinIndex = GetSkinIndex(partyModeID);
|
||||
if (skinIndex != -1)
|
||||
{
|
||||
for (int i = 0; i < _Skins[SkinIndex].VideoList.Count; i++)
|
||||
for (int i = 0; i < _Skins[skinIndex].VideoList.Count; i++)
|
||||
{
|
||||
SkinElement sk = _Skins[SkinIndex].VideoList[i];
|
||||
if (sk.Name == VideoName)
|
||||
SSkinElement sk = _Skins[skinIndex].VideoList[i];
|
||||
if (sk.Name == videoName)
|
||||
{
|
||||
if (sk.VideoIndex == -1)
|
||||
{
|
||||
sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, PartyModeID));
|
||||
sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name, partyModeID));
|
||||
CVideo.VdSetLoop(sk.VideoIndex, true);
|
||||
}
|
||||
CVideo.VdResume(sk.VideoIndex);
|
||||
_Skins[SkinIndex].VideoList[i] = sk;
|
||||
_Skins[skinIndex].VideoList[i] = sk;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetVideoFilePath(string VideoName, int PartyModeID)
|
||||
public static string GetVideoFilePath(string videoName, int partyModeID)
|
||||
{
|
||||
return GetVideoFileName(VideoName, GetSkinIndex(PartyModeID), true);
|
||||
return _GetVideoFileName(videoName, GetSkinIndex(partyModeID), true);
|
||||
}
|
||||
|
||||
private static string GetVideoFileName(string VideoName, int SkinIndex)
|
||||
private static string _GetVideoFileName(string videoName, int skinIndex)
|
||||
{
|
||||
return GetVideoFileName(VideoName, SkinIndex, false);
|
||||
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)
|
||||
{
|
||||
foreach (SkinElement sk in _Skins[SkinIndex].VideoList)
|
||||
foreach (SSkinElement sk in _Skins[skinIndex].VideoList)
|
||||
{
|
||||
if (sk.Name == VideoName)
|
||||
if (sk.Name == videoName)
|
||||
{
|
||||
if (!ReturnPath)
|
||||
if (!returnPath)
|
||||
return sk.Value;
|
||||
else
|
||||
return Path.Combine(_Skins[SkinIndex].Path, sk.Value);
|
||||
return Path.Combine(_Skins[skinIndex].Path, sk.Value);
|
||||
}
|
||||
}
|
||||
|
||||
CLog.LogError("Can't find Video Element \"" + VideoName);
|
||||
return VideoName;
|
||||
CLog.LogError("Can't find Video Element \"" + videoName);
|
||||
return videoName;
|
||||
}
|
||||
#endregion Theme and Skin index handling
|
||||
|
||||
#region Element loading
|
||||
private static void LoadColors(CXMLReader xmlReader, int SkinIndex)
|
||||
private static void _LoadColors(CXMLReader xmlReader, int skinIndex)
|
||||
{
|
||||
Skin skin = _Skins[SkinIndex];
|
||||
SSkin skin = _Skins[skinIndex];
|
||||
|
||||
if (_Skins[SkinIndex].PartyModeID == -1)
|
||||
if (_Skins[skinIndex].PartyModeID == -1)
|
||||
{
|
||||
List<SColorF> PlayerColors = new List<SColorF>();
|
||||
List<SColorF> playerColors = new List<SColorF>();
|
||||
float value = 0f;
|
||||
|
||||
int i = 1;
|
||||
@@ -719,13 +719,13 @@ namespace Vocaluxe.Base
|
||||
xmlReader.TryGetFloatValue("//root/Colors/Player" + i.ToString() + "/B", ref color.B);
|
||||
xmlReader.TryGetFloatValue("//root/Colors/Player" + i.ToString() + "/A", ref color.A);
|
||||
|
||||
PlayerColors.Add(color);
|
||||
playerColors.Add(color);
|
||||
i++;
|
||||
}
|
||||
skin.ThemeColors.Player = PlayerColors.ToArray();
|
||||
skin.ThemeColors.Player = playerColors.ToArray();
|
||||
}
|
||||
|
||||
List<SColorScheme> ColorScheme = new List<SColorScheme>();
|
||||
List<SColorScheme> colorScheme = new List<SColorScheme>();
|
||||
List<string> names = xmlReader.GetValues("ColorSchemes");
|
||||
foreach (string str in names)
|
||||
{
|
||||
@@ -737,55 +737,55 @@ namespace Vocaluxe.Base
|
||||
xmlReader.TryGetFloatValue("//root/ColorSchemes/" + str + "/B", ref scheme.Color.B);
|
||||
xmlReader.TryGetFloatValue("//root/ColorSchemes/" + str + "/A", ref scheme.Color.A);
|
||||
|
||||
ColorScheme.Add(scheme);
|
||||
colorScheme.Add(scheme);
|
||||
}
|
||||
skin.ThemeColors.ColorSchemes = ColorScheme.ToArray();
|
||||
skin.ThemeColors.ColorSchemes = colorScheme.ToArray();
|
||||
|
||||
_Skins[SkinIndex] = skin;
|
||||
_Skins[skinIndex] = skin;
|
||||
}
|
||||
|
||||
private static void LoadCursor(CXMLReader xmlReader, int SkinIndex)
|
||||
private static void _LoadCursor(CXMLReader xmlReader, int skinIndex)
|
||||
{
|
||||
string value = String.Empty;
|
||||
xmlReader.GetValue("//root/Cursor/Skin", ref Cursor.SkinName, value);
|
||||
|
||||
xmlReader.TryGetFloatValue("//root/Cursor/W", ref Cursor.w);
|
||||
xmlReader.TryGetFloatValue("//root/Cursor/H", ref Cursor.h);
|
||||
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))
|
||||
{
|
||||
SColorF color = GetColor(value, _Skins[SkinIndex].PartyModeID);
|
||||
Cursor.r = color.R;
|
||||
Cursor.g = color.G;
|
||||
Cursor.b = color.B;
|
||||
Cursor.a = color.A;
|
||||
Cursor.color = value;
|
||||
SColorF color = GetColor(value, _Skins[skinIndex].PartyModeID);
|
||||
Cursor.R = color.R;
|
||||
Cursor.G = color.G;
|
||||
Cursor.B = color.B;
|
||||
Cursor.A = color.A;
|
||||
Cursor.Color = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor.color = String.Empty;
|
||||
xmlReader.TryGetFloatValue("//root/Cursor/R", ref Cursor.r);
|
||||
xmlReader.TryGetFloatValue("//root/Cursor/G", ref Cursor.g);
|
||||
xmlReader.TryGetFloatValue("//root/Cursor/B", ref Cursor.b);
|
||||
xmlReader.TryGetFloatValue("//root/Cursor/A", ref Cursor.a);
|
||||
Cursor.Color = String.Empty;
|
||||
xmlReader.TryGetFloatValue("//root/Cursor/R", ref Cursor.R);
|
||||
xmlReader.TryGetFloatValue("//root/Cursor/G", ref Cursor.G);
|
||||
xmlReader.TryGetFloatValue("//root/Cursor/B", ref Cursor.B);
|
||||
xmlReader.TryGetFloatValue("//root/Cursor/A", ref Cursor.A);
|
||||
}
|
||||
}
|
||||
#endregion Element loading
|
||||
|
||||
#region Element Writing
|
||||
private static void SaveColors(XmlWriter writer, int SkinIndex)
|
||||
private static void _SaveColors(XmlWriter writer, int skinIndex)
|
||||
{
|
||||
if (_Skins[SkinIndex].PartyModeID == -1)
|
||||
if (_Skins[skinIndex].PartyModeID == -1)
|
||||
{
|
||||
writer.WriteStartElement("Colors");
|
||||
for (int i = 0; i < _Skins[SkinIndex].ThemeColors.Player.Length; i++)
|
||||
for (int i = 0; i < _Skins[skinIndex].ThemeColors.Player.Length; i++)
|
||||
{
|
||||
writer.WriteStartElement("Player" + (i + 1).ToString());
|
||||
|
||||
writer.WriteElementString("R", _Skins[SkinIndex].ThemeColors.Player[i].R.ToString("#0.000"));
|
||||
writer.WriteElementString("G", _Skins[SkinIndex].ThemeColors.Player[i].G.ToString("#0.000"));
|
||||
writer.WriteElementString("B", _Skins[SkinIndex].ThemeColors.Player[i].B.ToString("#0.000"));
|
||||
writer.WriteElementString("A", _Skins[SkinIndex].ThemeColors.Player[i].A.ToString("#0.000"));
|
||||
writer.WriteElementString("R", _Skins[skinIndex].ThemeColors.Player[i].R.ToString("#0.000"));
|
||||
writer.WriteElementString("G", _Skins[skinIndex].ThemeColors.Player[i].G.ToString("#0.000"));
|
||||
writer.WriteElementString("B", _Skins[skinIndex].ThemeColors.Player[i].B.ToString("#0.000"));
|
||||
writer.WriteElementString("A", _Skins[skinIndex].ThemeColors.Player[i].A.ToString("#0.000"));
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
@@ -793,7 +793,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
writer.WriteStartElement("ColorSchemes");
|
||||
foreach (SColorScheme scheme in _Skins[SkinIndex].ThemeColors.ColorSchemes)
|
||||
foreach (SColorScheme scheme in _Skins[skinIndex].ThemeColors.ColorSchemes)
|
||||
{
|
||||
writer.WriteStartElement(scheme.Name);
|
||||
|
||||
@@ -807,23 +807,23 @@ namespace Vocaluxe.Base
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
private static void SaveCursor(XmlWriter writer)
|
||||
private static void _SaveCursor(XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("Cursor");
|
||||
|
||||
writer.WriteElementString("Skin", Cursor.SkinName);
|
||||
|
||||
writer.WriteElementString("W", Cursor.w.ToString("#0.000"));
|
||||
writer.WriteElementString("H", Cursor.h.ToString("#0.000"));
|
||||
writer.WriteElementString("W", Cursor.W.ToString("#0.000"));
|
||||
writer.WriteElementString("H", Cursor.H.ToString("#0.000"));
|
||||
|
||||
if (Cursor.color.Length > 0)
|
||||
writer.WriteElementString("Color", Cursor.color);
|
||||
if (Cursor.Color.Length > 0)
|
||||
writer.WriteElementString("Color", Cursor.Color);
|
||||
else
|
||||
{
|
||||
writer.WriteElementString("R", Cursor.r.ToString("#0.000"));
|
||||
writer.WriteElementString("G", Cursor.g.ToString("#0.000"));
|
||||
writer.WriteElementString("B", Cursor.b.ToString("#0.000"));
|
||||
writer.WriteElementString("A", Cursor.a.ToString("#0.000"));
|
||||
writer.WriteElementString("R", Cursor.R.ToString("#0.000"));
|
||||
writer.WriteElementString("G", Cursor.G.ToString("#0.000"));
|
||||
writer.WriteElementString("B", Cursor.B.ToString("#0.000"));
|
||||
writer.WriteElementString("A", Cursor.A.ToString("#0.000"));
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
@@ -831,77 +831,77 @@ namespace Vocaluxe.Base
|
||||
#endregion ElementWriting
|
||||
|
||||
#region Color Handling
|
||||
public static SColorF GetColor(string ColorName, int PartyModeID)
|
||||
public static SColorF GetColor(string colorName, int partyModeID)
|
||||
{
|
||||
SColorF color;
|
||||
|
||||
int SkinIndex = GetSkinIndex(PartyModeID);
|
||||
int skinIndex = GetSkinIndex(partyModeID);
|
||||
|
||||
GetColor(ColorName, SkinIndex, out color);
|
||||
GetColor(colorName, skinIndex, out color);
|
||||
return color;
|
||||
}
|
||||
|
||||
public static bool GetColor(string ColorName, int SkinIndex, out SColorF Color)
|
||||
public static bool GetColor(string colorName, int skinIndex, out SColorF color)
|
||||
{
|
||||
foreach (SColorScheme scheme in _Skins[SkinIndex].ThemeColors.ColorSchemes)
|
||||
foreach (SColorScheme scheme in _Skins[skinIndex].ThemeColors.ColorSchemes)
|
||||
{
|
||||
if (scheme.Name == ColorName)
|
||||
if (scheme.Name == colorName)
|
||||
{
|
||||
Color = new SColorF(scheme.Color);
|
||||
color = new SColorF(scheme.Color);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool success;
|
||||
Color = GetPlayerColor(ColorName, GetSkinIndex(-1), out success);
|
||||
color = GetPlayerColor(colorName, GetSkinIndex(-1), out success);
|
||||
return success;
|
||||
}
|
||||
|
||||
public static SColorF GetPlayerColor(int PlayerNr)
|
||||
public static SColorF GetPlayerColor(int playerNr)
|
||||
{
|
||||
SColorF color = new SColorF(1f, 1f, 1f, 1f);
|
||||
|
||||
int SkinIndex = GetSkinIndex(-1);
|
||||
int skinIndex = GetSkinIndex(-1);
|
||||
|
||||
if (_Skins[SkinIndex].ThemeColors.Player.Length < PlayerNr)
|
||||
if (_Skins[skinIndex].ThemeColors.Player.Length < playerNr)
|
||||
return color;
|
||||
|
||||
return _Skins[SkinIndex].ThemeColors.Player[PlayerNr - 1];
|
||||
return _Skins[skinIndex].ThemeColors.Player[playerNr - 1];
|
||||
}
|
||||
|
||||
public static SColorF GetPlayerColor(string PlayerNrString)
|
||||
public static SColorF GetPlayerColor(string playerNrString)
|
||||
{
|
||||
bool dummy;
|
||||
return GetPlayerColor(PlayerNrString, GetSkinIndex(-1), out dummy);
|
||||
return GetPlayerColor(playerNrString, GetSkinIndex(-1), out dummy);
|
||||
}
|
||||
|
||||
public static SColorF GetPlayerColor(string PlayerNrString, int SkinIndex, out bool success)
|
||||
public static SColorF GetPlayerColor(string playerNrString, int skinIndex, out bool success)
|
||||
{
|
||||
int selection = 0;
|
||||
if (PlayerNrString.StartsWith("Player"))
|
||||
int.TryParse(PlayerNrString.Substring(6), out selection);
|
||||
if (playerNrString.StartsWith("Player"))
|
||||
int.TryParse(playerNrString.Substring(6), out selection);
|
||||
|
||||
return GetPlayerColor(selection, SkinIndex, out success);
|
||||
return GetPlayerColor(selection, skinIndex, out success);
|
||||
}
|
||||
|
||||
public static SColorF GetPlayerColor(int PlayerNr, out bool success)
|
||||
public static SColorF GetPlayerColor(int playerNr, out bool success)
|
||||
{
|
||||
return GetPlayerColor(PlayerNr, GetSkinIndex(-1), out success);
|
||||
return GetPlayerColor(playerNr, GetSkinIndex(-1), out success);
|
||||
}
|
||||
|
||||
public static SColorF GetPlayerColor(int PlayerNr, int SkinIndex, out bool success)
|
||||
public static SColorF GetPlayerColor(int playerNr, int skinIndex, out bool success)
|
||||
{
|
||||
success = false;
|
||||
SColorF color = new SColorF(1f, 1f, 1f, 1f);
|
||||
|
||||
if (_Skins[SkinIndex].PartyModeID != -1)
|
||||
SkinIndex = GetSkinIndex(-1);
|
||||
if (_Skins[skinIndex].PartyModeID != -1)
|
||||
skinIndex = GetSkinIndex(-1);
|
||||
|
||||
if (_Skins[SkinIndex].ThemeColors.Player.Length < PlayerNr || PlayerNr < 1)
|
||||
if (_Skins[skinIndex].ThemeColors.Player.Length < playerNr || playerNr < 1)
|
||||
return color;
|
||||
|
||||
success = true;
|
||||
return _Skins[SkinIndex].ThemeColors.Player[PlayerNr - 1];
|
||||
return _Skins[skinIndex].ThemeColors.Player[playerNr - 1];
|
||||
}
|
||||
#endregion Color Handling
|
||||
}
|
||||
|
||||
+91
-91
@@ -9,8 +9,8 @@ namespace Vocaluxe.Base
|
||||
static class CTime
|
||||
{
|
||||
private static readonly Stopwatch _Stopwatch = new Stopwatch();
|
||||
private static float _fps;
|
||||
private static readonly double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
private static float _Fps;
|
||||
private static readonly double _NanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
@@ -39,7 +39,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
long ticks = _Stopwatch.ElapsedTicks;
|
||||
if (Stopwatch.IsHighResolution && ticks != 0)
|
||||
return (float)((nanosecPerTick * ticks) / (1000.0 * 1000.0));
|
||||
return (float)((_NanosecPerTick * ticks) / (1000.0 * 1000.0));
|
||||
else
|
||||
return _Stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
@@ -52,57 +52,57 @@ namespace Vocaluxe.Base
|
||||
float ms = GetMilliseconds();
|
||||
|
||||
if (ms > 0)
|
||||
_fps = 1 / ms;
|
||||
_Fps = 1 / ms;
|
||||
|
||||
return _fps * 1000f;
|
||||
return _Fps * 1000f;
|
||||
}
|
||||
|
||||
public static double GetFPS()
|
||||
{
|
||||
return _fps * 1000f;
|
||||
return _Fps * 1000f;
|
||||
}
|
||||
}
|
||||
|
||||
class CKeys
|
||||
{
|
||||
private readonly List<KeyEvent> _KeysPool;
|
||||
private readonly List<KeyEvent> _ActualPool;
|
||||
private readonly List<SKeyEvent> _KeysPool;
|
||||
private readonly List<SKeyEvent> _ActualPool;
|
||||
|
||||
private readonly Object _CopyLock = new Object();
|
||||
|
||||
private bool _ModALT;
|
||||
private bool _ModCTRL;
|
||||
private bool _ModSHIFT;
|
||||
private bool _ModAlt;
|
||||
private bool _ModCtrl;
|
||||
private bool _ModShift;
|
||||
private bool _KeyPressed;
|
||||
private Keys _Keys;
|
||||
private Char _char;
|
||||
private readonly Stopwatch _timer;
|
||||
private Char _Char;
|
||||
private readonly Stopwatch _Timer;
|
||||
|
||||
public CKeys()
|
||||
{
|
||||
_ModALT = false;
|
||||
_ModCTRL = false;
|
||||
_ModSHIFT = false;
|
||||
_char = ' ';
|
||||
_ModAlt = false;
|
||||
_ModCtrl = false;
|
||||
_ModShift = false;
|
||||
_Char = ' ';
|
||||
_KeyPressed = false;
|
||||
_Keys = Keys.D0;
|
||||
|
||||
_KeysPool = new List<KeyEvent>();
|
||||
_ActualPool = new List<KeyEvent>();
|
||||
_timer = new Stopwatch();
|
||||
_KeysPool = new List<SKeyEvent>();
|
||||
_ActualPool = new List<SKeyEvent>();
|
||||
_Timer = new Stopwatch();
|
||||
}
|
||||
|
||||
private void Add(bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key)
|
||||
private void _Add(bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key)
|
||||
{
|
||||
bool KeyRepeat = false;
|
||||
if ((_char == unicode) && _KeyPressed)
|
||||
KeyRepeat = true;
|
||||
bool keyRepeat = false;
|
||||
if ((_Char == unicode) && _KeyPressed)
|
||||
keyRepeat = true;
|
||||
else if (_Keys == key)
|
||||
KeyRepeat = true;
|
||||
keyRepeat = true;
|
||||
|
||||
if (!_timer.IsRunning || (_timer.ElapsedMilliseconds > 75) || !KeyRepeat)
|
||||
if (!_Timer.IsRunning || (_Timer.ElapsedMilliseconds > 75) || !keyRepeat)
|
||||
{
|
||||
KeyEvent pool = new KeyEvent(ESender.Keyboard, alt, shift, ctrl, pressed && (unicode != Char.MinValue), unicode, key);
|
||||
SKeyEvent pool = new SKeyEvent(ESender.Keyboard, alt, shift, ctrl, pressed && (unicode != Char.MinValue), unicode, key);
|
||||
|
||||
lock (_CopyLock)
|
||||
{
|
||||
@@ -113,64 +113,64 @@ namespace Vocaluxe.Base
|
||||
catch (Exception) {}
|
||||
}
|
||||
|
||||
_timer.Reset();
|
||||
_timer.Start();
|
||||
_Timer.Reset();
|
||||
_Timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void Del(int index)
|
||||
private void _Del(int index)
|
||||
{
|
||||
_ActualPool.RemoveAt(index);
|
||||
}
|
||||
|
||||
private void CheckModifiers()
|
||||
private void _CheckModifiers()
|
||||
{
|
||||
Keys keys = Control.ModifierKeys;
|
||||
|
||||
_ModSHIFT = (keys & Keys.Shift) == Keys.Shift;
|
||||
_ModALT = (keys & Keys.Alt) == Keys.Alt;
|
||||
_ModCTRL = (keys & Keys.Control) == Keys.Control;
|
||||
_ModShift = (keys & Keys.Shift) == Keys.Shift;
|
||||
_ModAlt = (keys & Keys.Alt) == Keys.Alt;
|
||||
_ModCtrl = (keys & Keys.Control) == Keys.Control;
|
||||
}
|
||||
|
||||
public void KeyDown(KeyEventArgs e)
|
||||
{
|
||||
CheckModifiers();
|
||||
_CheckModifiers();
|
||||
|
||||
bool Repeat = false;
|
||||
bool repeat = false;
|
||||
if (_Keys == e.KeyCode)
|
||||
Repeat = true;
|
||||
repeat = true;
|
||||
|
||||
if (!_timer.IsRunning || (_timer.ElapsedMilliseconds > 75) || !Repeat)
|
||||
if (!_Timer.IsRunning || (_Timer.ElapsedMilliseconds > 75) || !repeat)
|
||||
{
|
||||
_Keys = e.KeyCode;
|
||||
if (Repeat)
|
||||
Add(_ModALT, _ModSHIFT, _ModCTRL, _KeyPressed, _char, _Keys);
|
||||
if (repeat)
|
||||
_Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, _Char, _Keys);
|
||||
else
|
||||
Add(_ModALT, _ModSHIFT, _ModCTRL, _KeyPressed, Char.MinValue, _Keys);
|
||||
_Add(_ModAlt, _ModShift, _ModCtrl, _KeyPressed, Char.MinValue, _Keys);
|
||||
}
|
||||
}
|
||||
|
||||
public void KeyPress(KeyPressEventArgs e)
|
||||
{
|
||||
CheckModifiers();
|
||||
_CheckModifiers();
|
||||
|
||||
Add(_ModALT, _ModSHIFT, _ModCTRL, true, e.KeyChar, Keys.None);
|
||||
_char = e.KeyChar;
|
||||
_Add(_ModAlt, _ModShift, _ModCtrl, true, e.KeyChar, Keys.None);
|
||||
_Char = e.KeyChar;
|
||||
_KeyPressed = true;
|
||||
}
|
||||
|
||||
public void KeyUp(KeyEventArgs e)
|
||||
{
|
||||
CheckModifiers();
|
||||
_CheckModifiers();
|
||||
_KeyPressed = false;
|
||||
}
|
||||
|
||||
public bool PollEvent(ref KeyEvent KeyEvent)
|
||||
public bool PollEvent(ref SKeyEvent keyEvent)
|
||||
{
|
||||
if (_ActualPool.Count > 0)
|
||||
{
|
||||
KeyEvent = _ActualPool[0];
|
||||
Del(0);
|
||||
keyEvent = _ActualPool[0];
|
||||
_Del(0);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -181,7 +181,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
lock (_CopyLock)
|
||||
{
|
||||
foreach (KeyEvent e in _KeysPool)
|
||||
foreach (SKeyEvent e in _KeysPool)
|
||||
_ActualPool.Add(e);
|
||||
_KeysPool.Clear();
|
||||
}
|
||||
@@ -190,110 +190,110 @@ namespace Vocaluxe.Base
|
||||
|
||||
class CMouse
|
||||
{
|
||||
private readonly List<MouseEvent> _EventsPool;
|
||||
private readonly List<MouseEvent> _CurrentPool;
|
||||
private readonly List<SMouseEvent> _EventsPool;
|
||||
private readonly List<SMouseEvent> _CurrentPool;
|
||||
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _X;
|
||||
private int _Y;
|
||||
|
||||
private readonly Object _CopyLock = new Object();
|
||||
|
||||
private bool _ModALT;
|
||||
private bool _ModCTRL;
|
||||
private bool _ModSHIFT;
|
||||
private bool _ModAlt;
|
||||
private bool _ModCtrl;
|
||||
private bool _ModShift;
|
||||
|
||||
private readonly Stopwatch _timer;
|
||||
private readonly Stopwatch _Timer;
|
||||
|
||||
public int X
|
||||
{
|
||||
get { return _x; }
|
||||
get { return _X; }
|
||||
}
|
||||
|
||||
public int Y
|
||||
{
|
||||
get { return _y; }
|
||||
get { return _Y; }
|
||||
}
|
||||
|
||||
public bool Visible = false;
|
||||
|
||||
public CMouse()
|
||||
{
|
||||
_ModALT = false;
|
||||
_ModCTRL = false;
|
||||
_ModSHIFT = false;
|
||||
_ModAlt = false;
|
||||
_ModCtrl = false;
|
||||
_ModShift = false;
|
||||
|
||||
_EventsPool = new List<MouseEvent>();
|
||||
_CurrentPool = new List<MouseEvent>();
|
||||
_EventsPool = new List<SMouseEvent>();
|
||||
_CurrentPool = new List<SMouseEvent>();
|
||||
|
||||
_timer = new Stopwatch();
|
||||
_Timer = new Stopwatch();
|
||||
}
|
||||
|
||||
private void Add(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
|
||||
private void _Add(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)
|
||||
{
|
||||
x = (int)(x * (float)CSettings.iRenderW / CDraw.GetScreenWidth());
|
||||
y = (int)(y * (float)CSettings.iRenderH / CDraw.GetScreenHeight());
|
||||
x = (int)(x * (float)CSettings.RenderW / CDraw.GetScreenWidth());
|
||||
y = (int)(y * (float)CSettings.RenderH / CDraw.GetScreenHeight());
|
||||
|
||||
MouseEvent pool = new MouseEvent(ESender.Mouse, alt, shift, ctrl, x, y, lb, ld, rb, -wheel / 120, lbh, rbh, mb, mbh);
|
||||
SMouseEvent pool = new SMouseEvent(ESender.Mouse, alt, shift, ctrl, x, y, lb, ld, rb, -wheel / 120, lbh, rbh, mb, mbh);
|
||||
|
||||
lock (_CopyLock)
|
||||
{
|
||||
_EventsPool.Add(pool);
|
||||
}
|
||||
_x = x;
|
||||
_y = y;
|
||||
_X = x;
|
||||
_Y = y;
|
||||
}
|
||||
|
||||
private void Del(int index)
|
||||
private void _Del(int index)
|
||||
{
|
||||
_CurrentPool.RemoveAt(index);
|
||||
}
|
||||
|
||||
private void CheckModifiers()
|
||||
private void _CheckModifiers()
|
||||
{
|
||||
Keys keys = Control.ModifierKeys;
|
||||
|
||||
_ModSHIFT = (keys & Keys.Shift) == Keys.Shift;
|
||||
_ModALT = (keys & Keys.Alt) == Keys.Alt;
|
||||
_ModCTRL = (keys & Keys.Control) == Keys.Control;
|
||||
_ModShift = (keys & Keys.Shift) == Keys.Shift;
|
||||
_ModAlt = (keys & Keys.Alt) == Keys.Alt;
|
||||
_ModCtrl = (keys & Keys.Control) == Keys.Control;
|
||||
}
|
||||
|
||||
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,
|
||||
_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);
|
||||
}
|
||||
|
||||
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,
|
||||
_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);
|
||||
}
|
||||
|
||||
public void MouseDown(MouseEventArgs e)
|
||||
{
|
||||
CheckModifiers();
|
||||
_CheckModifiers();
|
||||
|
||||
bool lb = e.Button == MouseButtons.Left;
|
||||
bool ld = false;
|
||||
if (lb)
|
||||
{
|
||||
if (_timer.IsRunning && _timer.ElapsedMilliseconds < 450)
|
||||
if (_Timer.IsRunning && _Timer.ElapsedMilliseconds < 450)
|
||||
{
|
||||
ld = true;
|
||||
_timer.Reset();
|
||||
_Timer.Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
_timer.Reset();
|
||||
_timer.Start();
|
||||
_Timer.Reset();
|
||||
_Timer.Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
_timer.Reset();
|
||||
_Timer.Reset();
|
||||
|
||||
Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, lb, ld, e.Button == MouseButtons.Right, e.Delta, false, false,
|
||||
_Add(_ModAlt, _ModShift, _ModCtrl, e.X, e.Y, lb, ld, e.Button == MouseButtons.Right, e.Delta, false, false,
|
||||
e.Button == MouseButtons.Middle, false);
|
||||
}
|
||||
|
||||
@@ -303,12 +303,12 @@ namespace Vocaluxe.Base
|
||||
//Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, e.Delta);
|
||||
}
|
||||
|
||||
public bool PollEvent(ref MouseEvent MouseEvent)
|
||||
public bool PollEvent(ref SMouseEvent mouseEvent)
|
||||
{
|
||||
if (_CurrentPool.Count > 0)
|
||||
{
|
||||
MouseEvent = _CurrentPool[0];
|
||||
Del(0);
|
||||
mouseEvent = _CurrentPool[0];
|
||||
_Del(0);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -319,7 +319,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
lock (_CopyLock)
|
||||
{
|
||||
foreach (MouseEvent e in _EventsPool)
|
||||
foreach (SMouseEvent e in _EventsPool)
|
||||
_CurrentPool.Add(e);
|
||||
_EventsPool.Clear();
|
||||
}
|
||||
|
||||
+32
-32
@@ -46,49 +46,49 @@ namespace Vocaluxe.Base
|
||||
return _VideoDecoder.GetNumStreams();
|
||||
}
|
||||
|
||||
public static int VdLoad(string VideoFileName)
|
||||
public static int VdLoad(string videoFileName)
|
||||
{
|
||||
return _VideoDecoder.Load(VideoFileName);
|
||||
return _VideoDecoder.Load(videoFileName);
|
||||
}
|
||||
|
||||
public static bool VdClose(int StreamID)
|
||||
public static bool VdClose(int streamID)
|
||||
{
|
||||
return _VideoDecoder.Close(StreamID);
|
||||
return _VideoDecoder.Close(streamID);
|
||||
}
|
||||
|
||||
public static float VdGetLength(int StreamID)
|
||||
public static float VdGetLength(int streamID)
|
||||
{
|
||||
return _VideoDecoder.GetLength(StreamID);
|
||||
return _VideoDecoder.GetLength(streamID);
|
||||
}
|
||||
|
||||
public static bool VdGetFrame(int StreamID, ref STexture Frame, float Time, ref float VideoTime)
|
||||
public static bool VdGetFrame(int streamID, ref STexture frame, float time, ref float videoTime)
|
||||
{
|
||||
return _VideoDecoder.GetFrame(StreamID, ref Frame, Time, ref VideoTime);
|
||||
return _VideoDecoder.GetFrame(streamID, ref frame, time, ref videoTime);
|
||||
}
|
||||
|
||||
public static bool VdSkip(int StreamID, float Start, float Gap)
|
||||
public static bool VdSkip(int streamID, float start, float gap)
|
||||
{
|
||||
return _VideoDecoder.Skip(StreamID, Start, Gap);
|
||||
return _VideoDecoder.Skip(streamID, start, gap);
|
||||
}
|
||||
|
||||
public static void VdSetLoop(int StreamID, bool Loop)
|
||||
public static void VdSetLoop(int streamID, bool loop)
|
||||
{
|
||||
_VideoDecoder.SetLoop(StreamID, Loop);
|
||||
_VideoDecoder.SetLoop(streamID, loop);
|
||||
}
|
||||
|
||||
public static void VdPause(int StreamID)
|
||||
public static void VdPause(int streamID)
|
||||
{
|
||||
_VideoDecoder.Pause(StreamID);
|
||||
_VideoDecoder.Pause(streamID);
|
||||
}
|
||||
|
||||
public static void VdResume(int StreamID)
|
||||
public static void VdResume(int streamID)
|
||||
{
|
||||
_VideoDecoder.Resume(StreamID);
|
||||
_VideoDecoder.Resume(streamID);
|
||||
}
|
||||
|
||||
public static bool VdFinished(int StreamID)
|
||||
public static bool VdFinished(int streamID)
|
||||
{
|
||||
return _VideoDecoder.Finished(StreamID);
|
||||
return _VideoDecoder.Finished(streamID);
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
@@ -100,7 +100,7 @@ namespace Vocaluxe.Base
|
||||
#endregion VideoDecoder
|
||||
}
|
||||
|
||||
class VideoPlayer
|
||||
class CVideoPlayer
|
||||
{
|
||||
private STexture _VideoTexture;
|
||||
private int _VideoStream;
|
||||
@@ -118,7 +118,7 @@ namespace Vocaluxe.Base
|
||||
set { CVideo.VdSetLoop(_VideoStream, value); }
|
||||
}
|
||||
|
||||
public VideoPlayer()
|
||||
public CVideoPlayer()
|
||||
{
|
||||
_VideoTimer = new Stopwatch();
|
||||
_VideoTexture = new STexture(-1);
|
||||
@@ -126,9 +126,9 @@ namespace Vocaluxe.Base
|
||||
_Loaded = false;
|
||||
}
|
||||
|
||||
public void Load(string VideoName)
|
||||
public void Load(string videoName)
|
||||
{
|
||||
_VideoStream = CVideo.VdLoad(CTheme.GetVideoFilePath(VideoName, -1));
|
||||
_VideoStream = CVideo.VdLoad(CTheme.GetVideoFilePath(videoName, -1));
|
||||
_Loaded = true;
|
||||
}
|
||||
|
||||
@@ -154,34 +154,34 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
if (!_Finished)
|
||||
{
|
||||
float VideoTime = _VideoTimer.ElapsedMilliseconds / 1000f;
|
||||
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);
|
||||
tex.Height = 0f;
|
||||
CVideo.VdGetFrame(_VideoStream, ref tex, videoTime, ref videoTime);
|
||||
|
||||
if (tex.height > 0)
|
||||
if (tex.Height > 0)
|
||||
{
|
||||
CDraw.RemoveTexture(ref _VideoTexture);
|
||||
_VideoTexture = tex;
|
||||
}
|
||||
}
|
||||
RectangleF bounds = new RectangleF(0f, 0f, CSettings.iRenderW, CSettings.iRenderH);
|
||||
RectangleF rect = new RectangleF(0f, 0f, _VideoTexture.width, _VideoTexture.height);
|
||||
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);
|
||||
|
||||
CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.zFar / 4));
|
||||
CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.ZFar / 4));
|
||||
}
|
||||
|
||||
public void PreLoad()
|
||||
{
|
||||
float VideoTime = 0f;
|
||||
while (_VideoTexture.index == -1 && VideoTime < 1f)
|
||||
float videoTime = 0f;
|
||||
while (_VideoTexture.Index == -1 && videoTime < 1f)
|
||||
{
|
||||
float dummy = 0f;
|
||||
CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, ref dummy);
|
||||
VideoTime += 0.05f;
|
||||
videoTime += 0.05f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Vocaluxe.Base;
|
||||
|
||||
namespace Vocaluxe
|
||||
{
|
||||
class CSplashScreen : Form
|
||||
{
|
||||
private readonly Bitmap _Logo;
|
||||
|
||||
public CSplashScreen()
|
||||
{
|
||||
string path = Path.Combine(Environment.CurrentDirectory, Path.Combine(CSettings.FolderGraphics, CSettings.Logo));
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
_Logo = new Bitmap(path);
|
||||
ClientSize = new Size(_Logo.Width, _Logo.Height);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading logo: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
|
||||
path = Path.Combine(Environment.CurrentDirectory, CSettings.Icon);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
Icon = new Icon(path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading icon: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
BackColor = Color.Transparent;
|
||||
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
Text = CSettings.ProgramName;
|
||||
CenterToScreen();
|
||||
Show();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e) {}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
if (_Logo == null)
|
||||
return;
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
g.DrawImage(_Logo, new Rectangle(0, 0, Width, Height));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,12 @@ using VocaluxeLib.Menu.SongMenu;
|
||||
|
||||
namespace Vocaluxe.GameModes
|
||||
{
|
||||
struct SongQueque
|
||||
struct SSongQueque
|
||||
{
|
||||
public int SongID;
|
||||
public EGameMode GameMode;
|
||||
|
||||
public SongQueque(int songID, EGameMode gameMode)
|
||||
public SSongQueque(int songID, EGameMode gameMode)
|
||||
{
|
||||
SongID = songID;
|
||||
GameMode = gameMode;
|
||||
@@ -20,14 +20,14 @@ namespace Vocaluxe.GameModes
|
||||
abstract class CGameMode : IGameMode
|
||||
{
|
||||
protected bool _Initialized = false;
|
||||
protected List<SongQueque> _SongQueque;
|
||||
protected List<SSongQueque> _SongQueque;
|
||||
protected int _CurrentSong;
|
||||
protected CPoints _Points;
|
||||
|
||||
#region Implementation
|
||||
public virtual void Init()
|
||||
{
|
||||
_SongQueque = new List<SongQueque>();
|
||||
_SongQueque = new List<SSongQueque>();
|
||||
Reset();
|
||||
}
|
||||
|
||||
@@ -38,43 +38,43 @@ namespace Vocaluxe.GameModes
|
||||
return EGameMode.TR_GAMEMODE_NORMAL;
|
||||
}
|
||||
|
||||
public virtual bool AddVisibleSong(int VisibleIndex, EGameMode GameMode)
|
||||
public virtual bool AddVisibleSong(int visibleIndex, EGameMode gameMode)
|
||||
{
|
||||
if (CSongs.VisibleSongs.Length > VisibleIndex)
|
||||
if (CSongs.VisibleSongs.Length > visibleIndex)
|
||||
{
|
||||
int SongID = CSongs.VisibleSongs[VisibleIndex].ID;
|
||||
if (GameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(SongID).IsDuet)
|
||||
int songID = CSongs.VisibleSongs[visibleIndex].ID;
|
||||
if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet)
|
||||
return false;
|
||||
|
||||
_SongQueque.Add(new SongQueque(SongID, GameMode));
|
||||
_SongQueque.Add(new SSongQueque(songID, gameMode));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool AddSong(int AbsoluteIndex, EGameMode GameMode)
|
||||
public virtual bool AddSong(int absoluteIndex, EGameMode gameMode)
|
||||
{
|
||||
if (CSongs.AllSongs.Length > AbsoluteIndex)
|
||||
if (CSongs.AllSongs.Length > absoluteIndex)
|
||||
{
|
||||
int SongID = CSongs.AllSongs[AbsoluteIndex].ID;
|
||||
if (GameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(SongID).IsDuet)
|
||||
int songID = CSongs.AllSongs[absoluteIndex].ID;
|
||||
if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet)
|
||||
return false;
|
||||
|
||||
_SongQueque.Add(new SongQueque(SongID, GameMode));
|
||||
_SongQueque.Add(new SSongQueque(songID, gameMode));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool RemoveVisibleSong(int VisibleIndex)
|
||||
public virtual bool RemoveVisibleSong(int visibleIndex)
|
||||
{
|
||||
if (CSongs.VisibleSongs.Length > VisibleIndex)
|
||||
if (CSongs.VisibleSongs.Length > visibleIndex)
|
||||
{
|
||||
int index = -1;
|
||||
int SongID = CSongs.VisibleSongs[VisibleIndex].ID;
|
||||
int songID = CSongs.VisibleSongs[visibleIndex].ID;
|
||||
for (int i = 0; i < _SongQueque.Count; i++)
|
||||
{
|
||||
if (_SongQueque[i].SongID == SongID)
|
||||
if (_SongQueque[i].SongID == songID)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
@@ -90,15 +90,15 @@ namespace Vocaluxe.GameModes
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool RemoveSong(int AbsoluteIndex)
|
||||
public virtual bool RemoveSong(int absoluteIndex)
|
||||
{
|
||||
if (CSongs.AllSongs.Length > AbsoluteIndex)
|
||||
if (CSongs.AllSongs.Length > absoluteIndex)
|
||||
{
|
||||
int index = -1;
|
||||
int SongID = CSongs.AllSongs[AbsoluteIndex].ID;
|
||||
int songID = CSongs.AllSongs[absoluteIndex].ID;
|
||||
for (int i = 0; i < _SongQueque.Count; i++)
|
||||
{
|
||||
if (_SongQueque[i].SongID == SongID)
|
||||
if (_SongQueque[i].SongID == songID)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
@@ -123,12 +123,12 @@ namespace Vocaluxe.GameModes
|
||||
_CurrentSong = -1;
|
||||
}
|
||||
|
||||
public virtual void Start(SPlayer[] Player)
|
||||
public virtual void Start(SPlayer[] player)
|
||||
{
|
||||
_Points = new CPoints(_SongQueque.Count, Player);
|
||||
_Points = new CPoints(_SongQueque.Count, player);
|
||||
}
|
||||
|
||||
public virtual void NextRound(SPlayer[] Player)
|
||||
public virtual void NextRound(SPlayer[] player)
|
||||
{
|
||||
if (_CurrentSong < _SongQueque.Count && _SongQueque.Count > 0)
|
||||
{
|
||||
@@ -137,7 +137,7 @@ namespace Vocaluxe.GameModes
|
||||
_Points.SetPoints(
|
||||
_CurrentSong,
|
||||
_SongQueque[_CurrentSong].SongID,
|
||||
Player,
|
||||
player,
|
||||
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_MEDLEY,
|
||||
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_DUET,
|
||||
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_SHORTSONG);
|
||||
@@ -195,18 +195,18 @@ namespace Vocaluxe.GameModes
|
||||
return _SongQueque.Count;
|
||||
}
|
||||
|
||||
public virtual CSong GetSong(int Num)
|
||||
public virtual CSong GetSong(int num)
|
||||
{
|
||||
if (Num - 1 < _SongQueque.Count && Num - 1 > -1)
|
||||
return CSongs.GetSong(_SongQueque[Num - 1].SongID);
|
||||
if (num - 1 < _SongQueque.Count && num - 1 > -1)
|
||||
return CSongs.GetSong(_SongQueque[num - 1].SongID);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual EGameMode GetGameMode(int Num)
|
||||
public virtual EGameMode GetGameMode(int num)
|
||||
{
|
||||
if (Num - 1 < _SongQueque.Count && Num > -1)
|
||||
return _SongQueque[Num].GameMode;
|
||||
if (num - 1 < _SongQueque.Count && num > -1)
|
||||
return _SongQueque[num].GameMode;
|
||||
|
||||
return EGameMode.TR_GAMEMODE_NORMAL;
|
||||
}
|
||||
@@ -217,6 +217,6 @@ namespace Vocaluxe.GameModes
|
||||
}
|
||||
#endregion Implementation
|
||||
|
||||
protected virtual void SongManipulation(int SongIndex) {}
|
||||
protected virtual void _SongManipulation(int songIndex) {}
|
||||
}
|
||||
}
|
||||
@@ -9,15 +9,15 @@ namespace Vocaluxe.GameModes
|
||||
|
||||
EGameMode GetCurrentGameMode();
|
||||
|
||||
bool AddVisibleSong(int VisibleIndex, EGameMode GameMode);
|
||||
bool AddSong(int AbsoluteIndex, EGameMode GameMode);
|
||||
bool RemoveVisibleSong(int VisibleIndex);
|
||||
bool RemoveSong(int AbsoluteIndex);
|
||||
bool AddVisibleSong(int visibleIndex, EGameMode gameMode);
|
||||
bool AddSong(int absoluteIndex, EGameMode gameMode);
|
||||
bool RemoveVisibleSong(int visibleIndex);
|
||||
bool RemoveSong(int absoluteIndex);
|
||||
void ClearSongs();
|
||||
|
||||
void Reset();
|
||||
void Start(SPlayer[] Player);
|
||||
void NextRound(SPlayer[] Player);
|
||||
void Start(SPlayer[] player);
|
||||
void NextRound(SPlayer[] player);
|
||||
bool IsFinished();
|
||||
int GetCurrentRoundNr();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Vocaluxe.GameModes
|
||||
|
||||
int GetNumSongs();
|
||||
CSong GetSong();
|
||||
CSong GetSong(int Num);
|
||||
EGameMode GetGameMode(int Num);
|
||||
CSong GetSong(int num);
|
||||
EGameMode GetGameMode(int num);
|
||||
}
|
||||
}
|
||||
+313
-318
File diff suppressed because it is too large.
Load diff
+131
-131
@@ -15,25 +15,25 @@ namespace Vocaluxe.Lib.Draw
|
||||
class CDrawWinForm : Form, IDraw
|
||||
{
|
||||
private bool _Run;
|
||||
private readonly Bitmap _backbuffer;
|
||||
private readonly Graphics _g;
|
||||
private bool _fullscreen;
|
||||
private readonly Bitmap _Backbuffer;
|
||||
private readonly Graphics _G;
|
||||
private bool _Fullscreen;
|
||||
|
||||
private readonly CKeys _Keys;
|
||||
private readonly CMouse _Mouse;
|
||||
|
||||
private FormBorderStyle _brdStyle;
|
||||
private bool _topMost;
|
||||
private Rectangle _bounds;
|
||||
private FormBorderStyle _BrdStyle;
|
||||
private bool _TopMost;
|
||||
private Rectangle _Bounds;
|
||||
|
||||
private readonly List<STexture> _Textures;
|
||||
private readonly List<Bitmap> _Bitmaps;
|
||||
|
||||
private readonly Color ClearColor = Color.DarkBlue;
|
||||
private readonly Color _ClearColor = Color.DarkBlue;
|
||||
|
||||
public CDrawWinForm()
|
||||
{
|
||||
Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.sIcon));
|
||||
Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon));
|
||||
|
||||
_Textures = new List<STexture>();
|
||||
_Bitmaps = new List<Bitmap>();
|
||||
@@ -45,34 +45,34 @@ namespace Vocaluxe.Lib.Draw
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Opaque, true);
|
||||
|
||||
// Create the backbuffer
|
||||
_backbuffer = new Bitmap(CSettings.iRenderW, CSettings.iRenderH);
|
||||
_g = Graphics.FromImage(_backbuffer);
|
||||
_g.Clear(Color.DarkBlue);
|
||||
_Backbuffer = new Bitmap(CSettings.RenderW, CSettings.RenderH);
|
||||
_G = Graphics.FromImage(_Backbuffer);
|
||||
_G.Clear(Color.DarkBlue);
|
||||
|
||||
Paint += OnPaintEvent;
|
||||
Closing += OnClosingEvent;
|
||||
KeyDown += OnKeyDownEvent;
|
||||
KeyPress += OnKeyPressEvent;
|
||||
KeyUp += OnKeyUpEvent;
|
||||
Resize += OnResizeEvent;
|
||||
Paint += _OnPaintEvent;
|
||||
Closing += _OnClosingEvent;
|
||||
KeyDown += _OnKeyDownEvent;
|
||||
KeyPress += _OnKeyPressEvent;
|
||||
KeyUp += _OnKeyUpEvent;
|
||||
Resize += _OnResizeEvent;
|
||||
|
||||
MouseMove += OnMouseMove;
|
||||
MouseDown += OnMouseDown;
|
||||
MouseUp += OnMouseUp;
|
||||
MouseMove += _OnMouseMove;
|
||||
MouseDown += _OnMouseDown;
|
||||
MouseUp += _OnMouseUp;
|
||||
|
||||
FlipBuffer();
|
||||
_FlipBuffer();
|
||||
Cursor.Show();
|
||||
}
|
||||
|
||||
private void FlipBuffer()
|
||||
private void _FlipBuffer()
|
||||
{
|
||||
DrawBuffer();
|
||||
_g.Clear(ClearColor);
|
||||
_DrawBuffer();
|
||||
_G.Clear(_ClearColor);
|
||||
}
|
||||
|
||||
private void DrawBuffer()
|
||||
private void _DrawBuffer()
|
||||
{
|
||||
Graphics gFrontBuffer = Graphics.FromHwnd(Handle);
|
||||
Graphics frontBuffer = Graphics.FromHwnd(Handle);
|
||||
int h = ClientSize.Height;
|
||||
int w = ClientSize.Width;
|
||||
int y = 0;
|
||||
@@ -89,61 +89,61 @@ namespace Vocaluxe.Lib.Draw
|
||||
y = (ClientSize.Height - h) / 2;
|
||||
}
|
||||
|
||||
gFrontBuffer.DrawImage(_backbuffer, new Rectangle(x, y, w, h), new Rectangle(0, 0, _backbuffer.Width, _backbuffer.Height), GraphicsUnit.Pixel);
|
||||
frontBuffer.DrawImage(_Backbuffer, new Rectangle(x, y, w, h), new Rectangle(0, 0, _Backbuffer.Width, _Backbuffer.Height), GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
private void OnPaintEvent(object sender, PaintEventArgs e) {}
|
||||
private void _OnPaintEvent(object sender, PaintEventArgs e) {}
|
||||
|
||||
#region FullScreenStuff
|
||||
private void ToggleFullScreen()
|
||||
private void _ToggleFullScreen()
|
||||
{
|
||||
if (!_fullscreen)
|
||||
Maximize(this);
|
||||
if (!_Fullscreen)
|
||||
_Maximize(this);
|
||||
else
|
||||
Restore(this);
|
||||
_Restore(this);
|
||||
}
|
||||
|
||||
private void Maximize(Form targetForm)
|
||||
private void _Maximize(Form targetForm)
|
||||
{
|
||||
if (!_fullscreen)
|
||||
if (!_Fullscreen)
|
||||
{
|
||||
Save(targetForm);
|
||||
_Save(targetForm);
|
||||
targetForm.FormBorderStyle = FormBorderStyle.None;
|
||||
targetForm.Bounds = Screen.PrimaryScreen.Bounds;
|
||||
targetForm.TopMost = true;
|
||||
_fullscreen = true;
|
||||
_Fullscreen = true;
|
||||
|
||||
CConfig.FullScreen = EOffOn.TR_CONFIG_ON;
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void Save(Form targetForm)
|
||||
private void _Save(Form targetForm)
|
||||
{
|
||||
_brdStyle = targetForm.FormBorderStyle;
|
||||
_topMost = targetForm.TopMost;
|
||||
_bounds = targetForm.Bounds;
|
||||
_BrdStyle = targetForm.FormBorderStyle;
|
||||
_TopMost = targetForm.TopMost;
|
||||
_Bounds = targetForm.Bounds;
|
||||
}
|
||||
|
||||
private void Restore(Form targetForm)
|
||||
private void _Restore(Form targetForm)
|
||||
{
|
||||
targetForm.FormBorderStyle = _brdStyle;
|
||||
targetForm.TopMost = _topMost;
|
||||
targetForm.Bounds = _bounds;
|
||||
_fullscreen = false;
|
||||
targetForm.FormBorderStyle = _BrdStyle;
|
||||
targetForm.TopMost = _TopMost;
|
||||
targetForm.Bounds = _Bounds;
|
||||
_Fullscreen = false;
|
||||
|
||||
CConfig.FullScreen = EOffOn.TR_CONFIG_OFF;
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
#endregion FullScreenStuff
|
||||
|
||||
private void OnResizeEvent(object sender, EventArgs e)
|
||||
private void _OnResizeEvent(object sender, EventArgs e)
|
||||
{
|
||||
Graphics gFrontBuffer = Graphics.FromHwnd(Handle);
|
||||
gFrontBuffer.Clear(Color.Black);
|
||||
Graphics frontBuffer = Graphics.FromHwnd(Handle);
|
||||
frontBuffer.Clear(Color.Black);
|
||||
}
|
||||
|
||||
private void OnClosingEvent(object sender, CancelEventArgs e)
|
||||
private void _OnClosingEvent(object sender, CancelEventArgs e)
|
||||
{
|
||||
_Run = false;
|
||||
}
|
||||
@@ -169,33 +169,33 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
}
|
||||
|
||||
private void OnKeyDownEvent(object sender, KeyEventArgs e)
|
||||
private void _OnKeyDownEvent(object sender, KeyEventArgs e)
|
||||
{
|
||||
_Keys.KeyDown(e);
|
||||
}
|
||||
|
||||
private void OnKeyPressEvent(object sender, KeyPressEventArgs e)
|
||||
private void _OnKeyPressEvent(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
_Keys.KeyPress(e);
|
||||
}
|
||||
|
||||
private void OnKeyUpEvent(object sender, KeyEventArgs e)
|
||||
private void _OnKeyUpEvent(object sender, KeyEventArgs e)
|
||||
{
|
||||
_Keys.KeyUp(e);
|
||||
}
|
||||
|
||||
#region mouse event handlers
|
||||
private void OnMouseMove(object sender, MouseEventArgs e)
|
||||
private void _OnMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
_Mouse.MouseMove(e);
|
||||
}
|
||||
|
||||
private void OnMouseDown(object sender, MouseEventArgs e)
|
||||
private void _OnMouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
_Mouse.MouseDown(e);
|
||||
}
|
||||
|
||||
private void OnMouseUp(object sender, MouseEventArgs e)
|
||||
private void _OnMouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
_Mouse.MouseUp(e);
|
||||
}
|
||||
@@ -215,8 +215,8 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
CSettings.bFullScreen = true;
|
||||
Maximize(this);
|
||||
CSettings.IsFullScreen = true;
|
||||
_Maximize(this);
|
||||
}
|
||||
|
||||
while (_Run)
|
||||
@@ -227,10 +227,10 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
_Run = _Run && CGraphics.Draw();
|
||||
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
|
||||
FlipBuffer();
|
||||
_FlipBuffer();
|
||||
|
||||
if ((CSettings.bFullScreen && !_fullscreen) || (!CSettings.bFullScreen && _fullscreen))
|
||||
ToggleFullScreen();
|
||||
if ((CSettings.IsFullScreen && !_Fullscreen) || (!CSettings.IsFullScreen && _Fullscreen))
|
||||
_ToggleFullScreen();
|
||||
|
||||
if (CTime.IsRunning())
|
||||
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
|
||||
@@ -266,9 +266,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
return GetTextBounds(text, text.Height);
|
||||
}
|
||||
|
||||
public RectangleF GetTextBounds(CText text, float Height)
|
||||
public RectangleF GetTextBounds(CText text, float height)
|
||||
{
|
||||
CFonts.Height = Height;
|
||||
CFonts.Height = height;
|
||||
CFonts.SetFont(text.Font);
|
||||
CFonts.Style = text.Style;
|
||||
return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text)));
|
||||
@@ -276,66 +276,66 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
public void ClearScreen()
|
||||
{
|
||||
_g.Clear(ClearColor);
|
||||
_G.Clear(_ClearColor);
|
||||
}
|
||||
|
||||
public STexture CopyScreen()
|
||||
{
|
||||
STexture texture = new STexture(0);
|
||||
Bitmap bmp = new Bitmap(_backbuffer);
|
||||
Bitmap bmp = new Bitmap(_Backbuffer);
|
||||
_Bitmaps.Add(bmp);
|
||||
|
||||
texture.index = _Bitmaps.Count - 1;
|
||||
texture.Index = _Bitmaps.Count - 1;
|
||||
|
||||
texture.width = bmp.Width;
|
||||
texture.height = bmp.Height;
|
||||
texture.Width = bmp.Width;
|
||||
texture.Height = bmp.Height;
|
||||
|
||||
// Add to Texture List
|
||||
texture.color = new SColorF(1f, 1f, 1f, 1f);
|
||||
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
|
||||
texture.Color = new SColorF(1f, 1f, 1f, 1f);
|
||||
texture.Rect = new SRectF(0f, 0f, texture.Width, texture.Height, 0f);
|
||||
_Textures.Add(texture);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
public void CopyScreen(ref STexture Texture)
|
||||
public void CopyScreen(ref STexture texture)
|
||||
{
|
||||
if ((Texture.index == 0) || (Texture.width != GetScreenWidth()) || (Texture.height != GetScreenHeight()))
|
||||
if ((texture.Index == 0) || (texture.Width != GetScreenWidth()) || (texture.Height != GetScreenHeight()))
|
||||
{
|
||||
RemoveTexture(ref Texture);
|
||||
Texture = CopyScreen();
|
||||
RemoveTexture(ref texture);
|
||||
texture = CopyScreen();
|
||||
}
|
||||
else
|
||||
_Bitmaps[Texture.index] = new Bitmap(_backbuffer);
|
||||
_Bitmaps[texture.Index] = new Bitmap(_Backbuffer);
|
||||
}
|
||||
|
||||
public void MakeScreenShot()
|
||||
{
|
||||
string file = "Screenshot_";
|
||||
string path = Path.Combine(Environment.CurrentDirectory, CSettings.sFolderScreenshots);
|
||||
string path = Path.Combine(Environment.CurrentDirectory, CSettings.FolderScreenshots);
|
||||
|
||||
int i = 0;
|
||||
while (File.Exists(Path.Combine(path, file + i.ToString("00000") + ".png")))
|
||||
i++;
|
||||
|
||||
_backbuffer.Save(Path.Combine(path, file + i.ToString("00000") + ".png"), ImageFormat.Png);
|
||||
_Backbuffer.Save(Path.Combine(path, file + i.ToString("00000") + ".png"), ImageFormat.Png);
|
||||
}
|
||||
|
||||
public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
_g.DrawLine(new Pen(Color.FromArgb(a, r, g, b), w), new Point(x1, y1), new Point(x2, y2));
|
||||
_G.DrawLine(new Pen(Color.FromArgb(a, r, g, b), w), new Point(x1, y1), new Point(x2, y2));
|
||||
}
|
||||
|
||||
// Draw Basic Text
|
||||
public void DrawText(string Text, int x, int y, int h)
|
||||
public void DrawText(string text, int x, int y, int h)
|
||||
{
|
||||
DrawText(Text, x, y, h, 0f);
|
||||
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, float h, float z)
|
||||
{
|
||||
CFonts.DrawText(Text, h, x, y, z, new SColorF(1, 1, 1, 1));
|
||||
CFonts.DrawText(text, h, x, y, z, new SColorF(1, 1, 1, 1));
|
||||
}
|
||||
|
||||
public void DrawColor(SColorF color, SRectF rect) {}
|
||||
@@ -348,14 +348,14 @@ namespace Vocaluxe.Lib.Draw
|
||||
_Bitmaps.Add(bmp2);
|
||||
STexture texture = new STexture();
|
||||
|
||||
texture.index = _Bitmaps.Count - 1;
|
||||
texture.Index = _Bitmaps.Count - 1;
|
||||
|
||||
texture.width = bmp.Width;
|
||||
texture.height = bmp.Height;
|
||||
texture.Width = bmp.Width;
|
||||
texture.Height = bmp.Height;
|
||||
|
||||
// Add to Texture List
|
||||
texture.color = new SColorF(1f, 1f, 1f, 1f);
|
||||
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
|
||||
texture.Color = new SColorF(1f, 1f, 1f, 1f);
|
||||
texture.Rect = new SRectF(0f, 0f, texture.Width, texture.Height, 0f);
|
||||
texture.TexturePath = String.Empty;
|
||||
|
||||
_Textures.Add(texture);
|
||||
@@ -363,15 +363,15 @@ namespace Vocaluxe.Lib.Draw
|
||||
return texture;
|
||||
}
|
||||
|
||||
public STexture AddTexture(string TexturePath)
|
||||
public STexture AddTexture(string texturePath)
|
||||
{
|
||||
STexture texture = new STexture();
|
||||
if (File.Exists(TexturePath))
|
||||
if (File.Exists(texturePath))
|
||||
{
|
||||
bool found = false;
|
||||
foreach (STexture tex in _Textures)
|
||||
{
|
||||
if (tex.TexturePath == TexturePath)
|
||||
if (tex.TexturePath == texturePath)
|
||||
{
|
||||
texture = tex;
|
||||
found = true;
|
||||
@@ -381,7 +381,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
if (!found)
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap(TexturePath))
|
||||
using (Bitmap bmp = new Bitmap(texturePath))
|
||||
return AddTexture(bmp);
|
||||
}
|
||||
}
|
||||
@@ -389,104 +389,104 @@ namespace Vocaluxe.Lib.Draw
|
||||
return texture;
|
||||
}
|
||||
|
||||
public void RemoveTexture(ref STexture Texture)
|
||||
public void RemoveTexture(ref STexture texture)
|
||||
{
|
||||
if ((Texture.index >= 0) && (_Textures.Count > 0))
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0))
|
||||
{
|
||||
for (int i = 0; i < _Textures.Count; i++)
|
||||
{
|
||||
if (_Textures[i].index == Texture.index)
|
||||
if (_Textures[i].Index == texture.Index)
|
||||
{
|
||||
_Bitmaps[Texture.index].Dispose();
|
||||
_Bitmaps[texture.Index].Dispose();
|
||||
_Textures.RemoveAt(i);
|
||||
Texture.index = -1;
|
||||
texture.Index = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public STexture AddTexture(int W, int H, IntPtr Data)
|
||||
public STexture AddTexture(int w, int h, IntPtr data)
|
||||
{
|
||||
return new STexture(-1);
|
||||
}
|
||||
|
||||
public STexture QuequeTexture(int W, int H, ref byte[] Data)
|
||||
public STexture QuequeTexture(int w, int h, ref byte[] data)
|
||||
{
|
||||
return AddTexture(W, H, ref Data);
|
||||
return AddTexture(w, h, ref data);
|
||||
}
|
||||
|
||||
public STexture AddTexture(int W, int H, ref byte[] Data)
|
||||
public STexture AddTexture(int w, int h, ref byte[] data)
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap(W, H))
|
||||
using (Bitmap bmp = new Bitmap(w, h))
|
||||
{
|
||||
BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||
Marshal.Copy(Data, 0, bmp_data.Scan0, Data.Length);
|
||||
bmp.UnlockBits(bmp_data);
|
||||
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||
Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
|
||||
bmp.UnlockBits(bmpData);
|
||||
return AddTexture(bmp);
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateTexture(ref STexture Texture, IntPtr Data)
|
||||
public bool UpdateTexture(ref STexture texture, IntPtr data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool UpdateTexture(ref STexture Texture, ref byte[] Data)
|
||||
public bool UpdateTexture(ref STexture texture, ref byte[] data)
|
||||
{
|
||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > texture.Index))
|
||||
{
|
||||
BitmapData bmp_data = _Bitmaps[Texture.index].LockBits(new Rectangle(0, 0, _Bitmaps[Texture.index].Width, _Bitmaps[Texture.index].Height),
|
||||
BitmapData bmpData = _Bitmaps[texture.Index].LockBits(new Rectangle(0, 0, _Bitmaps[texture.Index].Width, _Bitmaps[texture.Index].Height),
|
||||
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||
Marshal.Copy(Data, 0, bmp_data.Scan0, Data.Length);
|
||||
_Bitmaps[Texture.index].UnlockBits(bmp_data);
|
||||
Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
|
||||
_Bitmaps[texture.Index].UnlockBits(bmpData);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture)
|
||||
public void DrawTexture(STexture texture)
|
||||
{
|
||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
|
||||
DrawTexture(Texture, Texture.rect, Texture.color);
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > texture.Index))
|
||||
DrawTexture(texture, texture.Rect, texture.Color);
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture, SRectF rect)
|
||||
public void DrawTexture(STexture texture, SRectF rect)
|
||||
{
|
||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
|
||||
DrawTexture(Texture, rect, Texture.color);
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > texture.Index))
|
||||
DrawTexture(texture, rect, texture.Color);
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture, SRectF rect, SColorF color)
|
||||
public void DrawTexture(STexture texture, SRectF rect, SColorF color)
|
||||
{
|
||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
|
||||
DrawTexture(Texture, rect, color, rect, false);
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > texture.Index))
|
||||
DrawTexture(texture, rect, color, rect, false);
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds)
|
||||
public void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds)
|
||||
{
|
||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
|
||||
DrawTexture(Texture, rect, color, bounds, false);
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > texture.Index))
|
||||
DrawTexture(texture, rect, color, bounds, false);
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, bool mirrored)
|
||||
public void DrawTexture(STexture texture, SRectF rect, SColorF color, bool mirrored)
|
||||
{
|
||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
|
||||
DrawTexture(Texture, rect, color, rect, mirrored);
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > texture.Index))
|
||||
DrawTexture(texture, rect, color, rect, mirrored);
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored)
|
||||
public void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored)
|
||||
{
|
||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > texture.Index))
|
||||
{
|
||||
Bitmap ColoredBitmap = ColorizeBitmap(_Bitmaps[Texture.index], color);
|
||||
_g.DrawImage(ColoredBitmap, new RectangleF(rect.X, rect.Y, rect.W, rect.H));
|
||||
ColoredBitmap.Dispose();
|
||||
Bitmap coloredBitmap = ColorizeBitmap(_Bitmaps[texture.Index], color);
|
||||
_G.DrawImage(coloredBitmap, new RectangleF(rect.X, rect.Y, rect.W, rect.H));
|
||||
coloredBitmap.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end) {}
|
||||
public void DrawTexture(STexture texture, SRectF rect, SColorF color, float begin, float end) {}
|
||||
|
||||
public void DrawTextureReflection(STexture Texture, SRectF rect, SColorF color, SRectF bounds, float space, float height) {}
|
||||
public void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float space, float height) {}
|
||||
|
||||
public int TextureCount()
|
||||
{
|
||||
|
||||
+359
-359
File diff suppressed because it is too large.
Load diff
+19
-19
@@ -14,7 +14,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
int GetScreenHeight();
|
||||
|
||||
RectangleF GetTextBounds(CText text);
|
||||
RectangleF GetTextBounds(CText text, float Height);
|
||||
RectangleF GetTextBounds(CText text, float height);
|
||||
|
||||
// Basic Draw Methods
|
||||
void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2);
|
||||
@@ -23,31 +23,31 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
void ClearScreen();
|
||||
STexture CopyScreen();
|
||||
void CopyScreen(ref STexture Texture);
|
||||
void CopyScreen(ref STexture texture);
|
||||
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);
|
||||
|
||||
STexture AddTexture(string TexturePath);
|
||||
STexture AddTexture(Bitmap Bitmap);
|
||||
STexture AddTexture(int W, int H, IntPtr Data);
|
||||
STexture AddTexture(int W, int H, ref byte[] Data);
|
||||
STexture QuequeTexture(int W, int H, ref byte[] Data);
|
||||
bool UpdateTexture(ref STexture Texture, ref byte[] Data);
|
||||
bool UpdateTexture(ref STexture Texture, IntPtr Data);
|
||||
STexture AddTexture(string texturePath);
|
||||
STexture AddTexture(Bitmap bitmap);
|
||||
STexture AddTexture(int w, int h, IntPtr data);
|
||||
STexture AddTexture(int w, int h, ref byte[] data);
|
||||
STexture QuequeTexture(int w, int h, ref byte[] data);
|
||||
bool UpdateTexture(ref STexture texture, ref byte[] data);
|
||||
bool UpdateTexture(ref STexture texture, IntPtr data);
|
||||
|
||||
void RemoveTexture(ref STexture Texture);
|
||||
void DrawTexture(STexture Texture);
|
||||
void DrawTexture(STexture Texture, SRectF rect);
|
||||
void DrawTexture(STexture Texture, SRectF rect, SColorF color);
|
||||
void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds);
|
||||
void RemoveTexture(ref STexture texture);
|
||||
void DrawTexture(STexture texture);
|
||||
void DrawTexture(STexture texture, SRectF rect);
|
||||
void DrawTexture(STexture texture, SRectF rect, SColorF color);
|
||||
void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds);
|
||||
|
||||
void DrawTexture(STexture Texture, SRectF rect, SColorF color, bool mirrored);
|
||||
void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored);
|
||||
void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end);
|
||||
void DrawTexture(STexture texture, SRectF rect, SColorF color, bool mirrored);
|
||||
void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored);
|
||||
void DrawTexture(STexture texture, SRectF rect, SColorF color, float begin, float end);
|
||||
|
||||
void DrawTextureReflection(STexture Texture, SRectF rect, SColorF color, SRectF bounds, float space, float height);
|
||||
void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float space, float height);
|
||||
|
||||
int TextureCount();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using Vocaluxe.Base;
|
||||
namespace Vocaluxe.Lib.Input
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
public struct HIDDeviceInfo
|
||||
public struct SHIDDeviceInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPTStr)] public String Path;
|
||||
public ushort VendorString;
|
||||
@@ -20,29 +20,29 @@ namespace Vocaluxe.Lib.Input
|
||||
internal IntPtr Next;
|
||||
}
|
||||
|
||||
public static class CHIDAPI
|
||||
public static class CHIDApi
|
||||
{
|
||||
#if ARCH_X86
|
||||
#if WIN
|
||||
private const string HIDapiDll = "x86\\hidapi.dll";
|
||||
private const string _HIDApiDll = "x86\\hidapi.dll";
|
||||
#endif
|
||||
|
||||
#if LINUX
|
||||
private const string HIDapiDll = "libhidapi.so";
|
||||
private const string _HIDApiDll = "libhidapi.so";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ARCH_X64
|
||||
#if WIN
|
||||
private const string HIDapiDll = "x64\\hidapi.dll";
|
||||
private const string _HIDApiDll = "x64\\hidapi.dll";
|
||||
#endif
|
||||
|
||||
#if LINUX
|
||||
private const string HIDapiDll = "libhidapi.so";
|
||||
private const string _HIDApiDll = "libhidapi.so";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_init", CharSet = CharSet.Unicode)]
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_init", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_init();
|
||||
|
||||
public static bool Init()
|
||||
@@ -64,7 +64,7 @@ namespace Vocaluxe.Lib.Input
|
||||
return false;
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_exit", CharSet = CharSet.Unicode)]
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_exit", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_exit();
|
||||
|
||||
public static bool Exit()
|
||||
@@ -86,33 +86,33 @@ namespace Vocaluxe.Lib.Input
|
||||
return false;
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_enumerate", CharSet = CharSet.Ansi)]
|
||||
private static extern IntPtr hid_enumerate(ushort VendorID, ushort ProductID);
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_enumerate", CharSet = CharSet.Ansi)]
|
||||
private static extern IntPtr hid_enumerate(ushort vendorID, ushort productID);
|
||||
|
||||
//HIDDeviceInfo
|
||||
public static IntPtr Enumerate(ushort VendorID, ushort ProductID)
|
||||
public static IntPtr Enumerate(ushort vendorID, ushort productID)
|
||||
{
|
||||
//HIDDeviceInfo
|
||||
return hid_enumerate(VendorID, ProductID);
|
||||
return hid_enumerate(vendorID, productID);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_free_enumeration", CharSet = CharSet.Unicode)]
|
||||
private static extern void hid_free_enumeration(HIDDeviceInfo devs);
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_free_enumeration", CharSet = CharSet.Unicode)]
|
||||
private static extern void hid_free_enumeration(SHIDDeviceInfo devs);
|
||||
|
||||
public static void FreeEnumeration(HIDDeviceInfo devs)
|
||||
public static void FreeEnumeration(SHIDDeviceInfo devs)
|
||||
{
|
||||
hid_free_enumeration(devs);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_open", CharSet = CharSet.Unicode)]
|
||||
private static extern IntPtr hid_open(ushort VendorID, ushort ProductID, IntPtr SerialNumber);
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_open", CharSet = CharSet.Unicode)]
|
||||
private static extern IntPtr hid_open(ushort vendorID, ushort productID, IntPtr serialNumber);
|
||||
|
||||
public static bool Open(ushort VendorID, ushort ProductID, out IntPtr Handle)
|
||||
public static bool Open(ushort vendorID, ushort productID, out IntPtr handle)
|
||||
{
|
||||
Handle = IntPtr.Zero;
|
||||
handle = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
Handle = hid_open(VendorID, ProductID, IntPtr.Zero);
|
||||
handle = hid_open(vendorID, productID, IntPtr.Zero);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -120,40 +120,40 @@ namespace Vocaluxe.Lib.Input
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Handle != IntPtr.Zero)
|
||||
if (handle != IntPtr.Zero)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_open_path", CharSet = CharSet.Unicode)]
|
||||
private static extern IntPtr hid_open_path(string Path);
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_open_path", CharSet = CharSet.Unicode)]
|
||||
private static extern IntPtr hid_open_path(string path);
|
||||
|
||||
public static IntPtr OpenPath(string Path)
|
||||
public static IntPtr OpenPath(string path)
|
||||
{
|
||||
return hid_open_path(Path);
|
||||
return hid_open_path(path);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_write", CharSet = CharSet.Unicode)]
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_write", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_write(IntPtr device, byte[] data, int length);
|
||||
|
||||
public static int Write(IntPtr Device, byte[] Data)
|
||||
public static int Write(IntPtr device, byte[] data)
|
||||
{
|
||||
return hid_write(Device, Data, Data.Length);
|
||||
return hid_write(device, data, data.Length);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_read_timeout", CharSet = CharSet.Unicode)]
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_read_timeout", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_read_timeout(IntPtr device, IntPtr data, int length, int milliseconds);
|
||||
|
||||
public static int ReadTimeout(IntPtr Device, out byte[] Data, int length, int milliseconds)
|
||||
public static int ReadTimeout(IntPtr device, out byte[] data, int length, int milliseconds)
|
||||
{
|
||||
Data = new byte[length];
|
||||
IntPtr data = Marshal.AllocHGlobal(length);
|
||||
data = new byte[length];
|
||||
IntPtr dataPtr = Marshal.AllocHGlobal(length);
|
||||
|
||||
int result = -1;
|
||||
try
|
||||
{
|
||||
result = hid_read_timeout(Device, data, length, milliseconds);
|
||||
result = hid_read_timeout(device, dataPtr, length, milliseconds);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -162,26 +162,26 @@ namespace Vocaluxe.Lib.Input
|
||||
}
|
||||
|
||||
if (result != -1)
|
||||
Marshal.Copy(data, Data, 0, result);
|
||||
Marshal.Copy(dataPtr, data, 0, result);
|
||||
else
|
||||
Data = null;
|
||||
data = null;
|
||||
|
||||
Marshal.FreeHGlobal(data);
|
||||
Marshal.FreeHGlobal(dataPtr);
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_read", CharSet = CharSet.Unicode)]
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_read", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_read(IntPtr device, IntPtr data, int length);
|
||||
|
||||
public static int Read(IntPtr Device, out byte[] Data, int length)
|
||||
public static int Read(IntPtr device, out byte[] data, int length)
|
||||
{
|
||||
Data = new byte[length];
|
||||
IntPtr data = Marshal.AllocHGlobal(length);
|
||||
data = new byte[length];
|
||||
IntPtr dataPtr = Marshal.AllocHGlobal(length);
|
||||
|
||||
int result = -1;
|
||||
try
|
||||
{
|
||||
result = hid_read(Device, data, length);
|
||||
result = hid_read(device, dataPtr, length);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -190,46 +190,46 @@ namespace Vocaluxe.Lib.Input
|
||||
}
|
||||
|
||||
if (result != -1)
|
||||
Marshal.Copy(data, Data, 0, result);
|
||||
Marshal.Copy(dataPtr, data, 0, result);
|
||||
else
|
||||
Data = null;
|
||||
data = null;
|
||||
|
||||
Marshal.FreeHGlobal(data);
|
||||
Marshal.FreeHGlobal(dataPtr);
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_set_nonblocking", CharSet = CharSet.Unicode)]
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_set_nonblocking", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_set_nonblocking(IntPtr device, bool nonblock);
|
||||
|
||||
public static int Read(IntPtr Device, bool Nonblocking)
|
||||
public static int Read(IntPtr device, bool nonblocking)
|
||||
{
|
||||
return hid_set_nonblocking(Device, Nonblocking);
|
||||
return hid_set_nonblocking(device, nonblocking);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_send_feature_report", CharSet = CharSet.Unicode)]
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_send_feature_report", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_send_feature_report(IntPtr device, string data, int length);
|
||||
|
||||
public static int SendFeatureReport(IntPtr Device, string Data)
|
||||
public static int SendFeatureReport(IntPtr device, string data)
|
||||
{
|
||||
return hid_send_feature_report(Device, Data, Data.Length);
|
||||
return hid_send_feature_report(device, data, data.Length);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_feature_report", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_get_feature_report(IntPtr device, string Data, int length);
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_feature_report", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_get_feature_report(IntPtr device, string data, int length);
|
||||
|
||||
public static int GetFeatureReport(IntPtr Device, string Data)
|
||||
public static int GetFeatureReport(IntPtr device, string data)
|
||||
{
|
||||
return hid_get_feature_report(Device, Data, Data.Length);
|
||||
return hid_get_feature_report(device, data, data.Length);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_close", CharSet = CharSet.Unicode)]
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_close", CharSet = CharSet.Unicode)]
|
||||
private static extern void hid_close(IntPtr device);
|
||||
|
||||
public static bool Close(IntPtr Device)
|
||||
public static bool Close(IntPtr device)
|
||||
{
|
||||
try
|
||||
{
|
||||
hid_close(Device);
|
||||
hid_close(device);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -239,44 +239,44 @@ namespace Vocaluxe.Lib.Input
|
||||
return true;
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_manufacturer_string", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_get_manufacturer_string(IntPtr device, string Data, int maxlength);
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_manufacturer_string", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_get_manufacturer_string(IntPtr device, string data, int maxlength);
|
||||
|
||||
public static int GetManufacturerString(IntPtr Device, string Data, int MaxLength)
|
||||
public static int GetManufacturerString(IntPtr device, string data, int maxLength)
|
||||
{
|
||||
return hid_get_manufacturer_string(Device, Data, MaxLength);
|
||||
return hid_get_manufacturer_string(device, data, maxLength);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_product_string", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_get_product_string(IntPtr device, string Data, int maxlength);
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_product_string", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_get_product_string(IntPtr device, string data, int maxlength);
|
||||
|
||||
public static int GetProductString(IntPtr Device, string Data, int MaxLength)
|
||||
public static int GetProductString(IntPtr device, string data, int maxLength)
|
||||
{
|
||||
return hid_get_product_string(Device, Data, MaxLength);
|
||||
return hid_get_product_string(device, data, maxLength);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_serial_number_string", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_get_serial_number_string(IntPtr device, string Data, int maxlength);
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_serial_number_string", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_get_serial_number_string(IntPtr device, string data, int maxlength);
|
||||
|
||||
public static int GetSerialNumberString(IntPtr Device, string Data, int MaxLength)
|
||||
public static int GetSerialNumberString(IntPtr device, string data, int maxLength)
|
||||
{
|
||||
return hid_get_serial_number_string(Device, Data, MaxLength);
|
||||
return hid_get_serial_number_string(device, data, maxLength);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_indexed_string", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_get_indexed_string(IntPtr device, string Data, int maxlength);
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_indexed_string", CharSet = CharSet.Unicode)]
|
||||
private static extern int hid_get_indexed_string(IntPtr device, string data, int maxlength);
|
||||
|
||||
public static int GetIndexedString(IntPtr Device, string Data, int MaxLength)
|
||||
public static int GetIndexedString(IntPtr device, string data, int maxLength)
|
||||
{
|
||||
return hid_get_indexed_string(Device, Data, MaxLength);
|
||||
return hid_get_indexed_string(device, data, maxLength);
|
||||
}
|
||||
|
||||
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_error", CharSet = CharSet.Unicode)]
|
||||
[DllImport(_HIDApiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_error", CharSet = CharSet.Unicode)]
|
||||
private static extern string hid_error(IntPtr device);
|
||||
|
||||
public static string Error(IntPtr Device)
|
||||
public static string Error(IntPtr device)
|
||||
{
|
||||
return hid_error(Device);
|
||||
return hid_error(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,24 +23,24 @@ namespace Vocaluxe.Lib.Input
|
||||
bool IsConnected();
|
||||
void Update();
|
||||
|
||||
bool PollKeyEvent(ref KeyEvent KeyEvent);
|
||||
bool PollMouseEvent(ref MouseEvent MouseEvent);
|
||||
bool PollKeyEvent(ref SKeyEvent keyEvent);
|
||||
bool PollMouseEvent(ref SMouseEvent mouseEvent);
|
||||
|
||||
void SetRumble(float Duration);
|
||||
void SetRumble(float duration);
|
||||
}
|
||||
|
||||
class RumbleTimer
|
||||
class CRumbleTimer
|
||||
{
|
||||
private readonly Stopwatch _timer;
|
||||
private float _duration;
|
||||
private readonly Stopwatch _Timer;
|
||||
private float _Duration;
|
||||
|
||||
public bool ShouldStart
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_timer.IsRunning && _duration != 0f)
|
||||
if (!_Timer.IsRunning && _Duration != 0f)
|
||||
{
|
||||
_timer.Start();
|
||||
_Timer.Start();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace Vocaluxe.Lib.Input
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_timer.IsRunning && _timer.ElapsedMilliseconds / 1000f >= _duration)
|
||||
if (_Timer.IsRunning && _Timer.ElapsedMilliseconds / 1000f >= _Duration)
|
||||
{
|
||||
_timer.Reset();
|
||||
_duration = 0f;
|
||||
_Timer.Reset();
|
||||
_Duration = 0f;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -63,76 +63,76 @@ namespace Vocaluxe.Lib.Input
|
||||
}
|
||||
}
|
||||
|
||||
public RumbleTimer()
|
||||
public CRumbleTimer()
|
||||
{
|
||||
_timer = new Stopwatch();
|
||||
_duration = 0f;
|
||||
_Timer = new Stopwatch();
|
||||
_Duration = 0f;
|
||||
}
|
||||
|
||||
public void Set(float Duration)
|
||||
public void Set(float duration)
|
||||
{
|
||||
if (!_timer.IsRunning)
|
||||
if (!_Timer.IsRunning)
|
||||
{
|
||||
_duration = Duration;
|
||||
_timer.Reset();
|
||||
_Duration = duration;
|
||||
_Timer.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_duration = 0f;
|
||||
_Duration = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
class CGesture
|
||||
{
|
||||
private Point _Begin;
|
||||
private bool _locked;
|
||||
private bool _Locked;
|
||||
|
||||
public CGesture()
|
||||
{
|
||||
_locked = false;
|
||||
_Locked = false;
|
||||
}
|
||||
|
||||
public void SetLockPosition(Point Position)
|
||||
public void SetLockPosition(Point position)
|
||||
{
|
||||
_locked = true;
|
||||
_Begin = new Point(Position.X, Position.Y);
|
||||
_Locked = true;
|
||||
_Begin = new Point(position.X, position.Y);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_locked = false;
|
||||
_Locked = false;
|
||||
}
|
||||
|
||||
public EGesture GetGesture(Point NewPosition)
|
||||
public EGesture GetGesture(Point newPosition)
|
||||
{
|
||||
if (!_locked)
|
||||
if (!_Locked)
|
||||
return EGesture.None;
|
||||
|
||||
int dx = NewPosition.X - _Begin.X;
|
||||
int dy = NewPosition.Y - _Begin.Y;
|
||||
int dx = newPosition.X - _Begin.X;
|
||||
int dy = newPosition.Y - _Begin.Y;
|
||||
|
||||
//Back/Escape
|
||||
if (dx < -150 && Math.Abs(dy) < 150)
|
||||
{
|
||||
_locked = false;
|
||||
_Locked = false;
|
||||
return EGesture.Back;
|
||||
}
|
||||
|
||||
//ScrollDown
|
||||
if (Math.Abs(dx) < 150 && dy > 30)
|
||||
{
|
||||
_Begin.Y = NewPosition.Y;
|
||||
_Begin.X = NewPosition.X;
|
||||
_Begin.Y = newPosition.Y;
|
||||
_Begin.X = newPosition.X;
|
||||
return EGesture.ScrollDown;
|
||||
}
|
||||
|
||||
//ScrollUp
|
||||
if (Math.Abs(dx) < 150 && dy < -30)
|
||||
{
|
||||
_Begin.Y = NewPosition.Y;
|
||||
_Begin.X = NewPosition.X;
|
||||
_Begin.Y = newPosition.Y;
|
||||
_Begin.X = newPosition.X;
|
||||
return EGesture.ScrollUp;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
{
|
||||
class CWiiMote : IInput, IDisposable
|
||||
{
|
||||
private WiiMoteLib _WiiMote;
|
||||
private CWiiMoteLib _WiiMote;
|
||||
|
||||
private List<KeyEvent> _KeysPool;
|
||||
private List<KeyEvent> _CurrentKeysPool;
|
||||
private List<SKeyEvent> _KeysPool;
|
||||
private List<SKeyEvent> _CurrentKeysPool;
|
||||
private readonly Object _KeyCopyLock = new Object();
|
||||
|
||||
private List<MouseEvent> _MousePool;
|
||||
private List<MouseEvent> _CurrentMousePool;
|
||||
private List<SMouseEvent> _MousePool;
|
||||
private List<SMouseEvent> _CurrentMousePool;
|
||||
private readonly Object _MouseCopyLock = new Object();
|
||||
|
||||
private bool[] _ButtonStates;
|
||||
@@ -27,25 +27,25 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
private Thread _HandlerThread;
|
||||
private Object _Sync;
|
||||
private bool _Active;
|
||||
private RumbleTimer _RumbleTimer;
|
||||
private CRumbleTimer _RumbleTimer;
|
||||
|
||||
private CGesture _Gesture;
|
||||
|
||||
public bool Init()
|
||||
{
|
||||
_Sync = new Object();
|
||||
_RumbleTimer = new RumbleTimer();
|
||||
_RumbleTimer = new CRumbleTimer();
|
||||
_Gesture = new CGesture();
|
||||
|
||||
_Active = true;
|
||||
_HandlerThread = new Thread(MainLoop);
|
||||
_HandlerThread = new Thread(_MainLoop);
|
||||
_HandlerThread.Priority = ThreadPriority.BelowNormal;
|
||||
|
||||
_KeysPool = new List<KeyEvent>();
|
||||
_CurrentKeysPool = new List<KeyEvent>();
|
||||
_KeysPool = new List<SKeyEvent>();
|
||||
_CurrentKeysPool = new List<SKeyEvent>();
|
||||
|
||||
_MousePool = new List<MouseEvent>();
|
||||
_CurrentMousePool = new List<MouseEvent>();
|
||||
_MousePool = new List<SMouseEvent>();
|
||||
_CurrentMousePool = new List<SMouseEvent>();
|
||||
|
||||
_ButtonStates = new bool[11];
|
||||
_OldPosition = new Point();
|
||||
@@ -83,14 +83,14 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
|
||||
public void Update()
|
||||
{
|
||||
CopyEvents();
|
||||
_CopyEvents();
|
||||
}
|
||||
|
||||
public bool PollKeyEvent(ref KeyEvent KeyEvent)
|
||||
public bool PollKeyEvent(ref SKeyEvent keyEvent)
|
||||
{
|
||||
if (_CurrentKeysPool.Count > 0)
|
||||
{
|
||||
KeyEvent = _CurrentKeysPool[0];
|
||||
keyEvent = _CurrentKeysPool[0];
|
||||
_CurrentKeysPool.RemoveAt(0);
|
||||
return true;
|
||||
}
|
||||
@@ -98,11 +98,11 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool PollMouseEvent(ref MouseEvent MouseEvent)
|
||||
public bool PollMouseEvent(ref SMouseEvent mouseEvent)
|
||||
{
|
||||
if (_CurrentMousePool.Count > 0)
|
||||
{
|
||||
MouseEvent = _CurrentMousePool[0];
|
||||
mouseEvent = _CurrentMousePool[0];
|
||||
_CurrentMousePool.RemoveAt(0);
|
||||
return true;
|
||||
}
|
||||
@@ -110,18 +110,18 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetRumble(float Duration)
|
||||
public void SetRumble(float duration)
|
||||
{
|
||||
lock (_Sync)
|
||||
{
|
||||
_RumbleTimer.Set(Duration);
|
||||
_RumbleTimer.Set(duration);
|
||||
}
|
||||
}
|
||||
|
||||
private void MainLoop()
|
||||
private void _MainLoop()
|
||||
{
|
||||
_WiiMote = new WiiMoteLib();
|
||||
_WiiMote.WiiMoteChanged += wm_WiiMoteChanged;
|
||||
_WiiMote = new CWiiMoteLib();
|
||||
_WiiMote.WiiMoteChanged += _WmWiiMoteChanged;
|
||||
|
||||
while (_Active)
|
||||
{
|
||||
@@ -129,23 +129,23 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
|
||||
if (!_WiiMote.Connected)
|
||||
{
|
||||
if (!DoConnect())
|
||||
if (!_DoConnect())
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool StartRumble = false;
|
||||
bool StopRumble = false;
|
||||
bool startRumble = false;
|
||||
bool stopRumble = false;
|
||||
lock (_Sync)
|
||||
{
|
||||
StartRumble = _RumbleTimer.ShouldStart;
|
||||
StopRumble = _RumbleTimer.ShouldStop;
|
||||
startRumble = _RumbleTimer.ShouldStart;
|
||||
stopRumble = _RumbleTimer.ShouldStop;
|
||||
}
|
||||
|
||||
if (StartRumble)
|
||||
if (startRumble)
|
||||
_WiiMote.SetRumble(true);
|
||||
|
||||
if (StopRumble)
|
||||
if (stopRumble)
|
||||
_WiiMote.SetRumble(false);
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
_Connected = false;
|
||||
}
|
||||
|
||||
private bool DoConnect()
|
||||
private bool _DoConnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -167,7 +167,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
return false;
|
||||
}
|
||||
|
||||
_WiiMote.SetReportType(InputReport.IRAccel, IRSensitivity.Max, false);
|
||||
_WiiMote.SetReportType(EInputReport.IRAccel, EIRSensitivity.Max, false);
|
||||
_WiiMote.SetLEDs(false, false, true, false);
|
||||
|
||||
_WiiMote.SetRumble(true);
|
||||
@@ -182,12 +182,12 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
return true;
|
||||
}
|
||||
|
||||
private void wm_WiiMoteChanged(object sender, WiiMoteChangedEventArgs args)
|
||||
private void _WmWiiMoteChanged(object sender, CWiiMoteChangedEventArgs args)
|
||||
{
|
||||
if (!_Active)
|
||||
return;
|
||||
|
||||
WiiMoteStatus ws = args.WiiMoteState;
|
||||
CWiiMoteStatus ws = args.WiiMoteState;
|
||||
|
||||
Point p = ws.IRState.Position;
|
||||
p.X = 1023 - p.X;
|
||||
@@ -245,7 +245,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
|
||||
if (alt || shift || ctrl || pressed || unicode != char.MinValue || key != Keys.None)
|
||||
{
|
||||
KeyEvent pool = new KeyEvent(ESender.WiiMote, alt, shift, ctrl, pressed, unicode, key);
|
||||
SKeyEvent pool = new SKeyEvent(ESender.WiiMote, alt, shift, ctrl, pressed, unicode, key);
|
||||
|
||||
lock (_KeyCopyLock)
|
||||
{
|
||||
@@ -259,8 +259,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
float rx = ((p.X / 1024f) - reducing) * factor;
|
||||
float ry = ((p.Y / 768f) - reducing) * factor;
|
||||
|
||||
int x = (int)(rx * CSettings.iRenderW);
|
||||
int y = (int)(ry * CSettings.iRenderH);
|
||||
int x = (int)(rx * CSettings.RenderW);
|
||||
int y = (int)(ry * CSettings.RenderH);
|
||||
|
||||
|
||||
bool ld = false;
|
||||
@@ -275,17 +275,17 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
if (gesture == EGesture.ScrollDown)
|
||||
wheel = 1;
|
||||
|
||||
MouseEvent mpool = new MouseEvent();
|
||||
SMouseEvent mpool = new SMouseEvent();
|
||||
bool trigger = false;
|
||||
|
||||
if (!lb && !rb && (p.X != _OldPosition.X || p.Y != _OldPosition.Y))
|
||||
{
|
||||
mpool = new MouseEvent(ESender.WiiMote, alt, shift, ctrl, x, y, false, false, false, wheel, lbh, rbh, false, mbh);
|
||||
mpool = new SMouseEvent(ESender.WiiMote, alt, shift, ctrl, x, y, false, false, false, wheel, lbh, rbh, false, mbh);
|
||||
trigger = true;
|
||||
}
|
||||
else if (lb || rb)
|
||||
{
|
||||
mpool = new MouseEvent(ESender.WiiMote, alt, shift, ctrl, x, y, lb, ld, rb, wheel, false, false, mb, false);
|
||||
mpool = new SMouseEvent(ESender.WiiMote, alt, shift, ctrl, x, y, lb, ld, rb, wheel, false, false, mb, false);
|
||||
trigger = true;
|
||||
}
|
||||
|
||||
@@ -302,18 +302,18 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
_OldPosition.Y = p.Y;
|
||||
}
|
||||
|
||||
private void CopyEvents()
|
||||
private void _CopyEvents()
|
||||
{
|
||||
lock (_KeyCopyLock)
|
||||
{
|
||||
foreach (KeyEvent e in _KeysPool)
|
||||
foreach (SKeyEvent e in _KeysPool)
|
||||
_CurrentKeysPool.Add(e);
|
||||
_KeysPool.Clear();
|
||||
}
|
||||
|
||||
lock (_MouseCopyLock)
|
||||
{
|
||||
foreach (MouseEvent e in _MousePool)
|
||||
foreach (SMouseEvent e in _MousePool)
|
||||
_CurrentMousePool.Add(e);
|
||||
_MousePool.Clear();
|
||||
}
|
||||
|
||||
@@ -8,29 +8,29 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
{
|
||||
|
||||
#region DataTypes
|
||||
public class WiiMoteStatus
|
||||
public class CWiiMoteStatus
|
||||
{
|
||||
public AccelCalibrationInfo AccelCalibrationInfo = new AccelCalibrationInfo();
|
||||
public SAccelCalibrationInfo AccelCalibrationInfo = new SAccelCalibrationInfo();
|
||||
|
||||
public AccelStatus AccelState = new AccelStatus();
|
||||
public SAccelStatus AccelState = new SAccelStatus();
|
||||
|
||||
public Buttons ButtonState = new Buttons();
|
||||
public SButtons ButtonState = new SButtons();
|
||||
|
||||
public IRState IRState = new IRState();
|
||||
public SIRState IRState = new SIRState();
|
||||
|
||||
public byte Battery;
|
||||
|
||||
public bool Rumble;
|
||||
|
||||
public LEDStatus LEDState;
|
||||
public SLEDStatus LEDState;
|
||||
|
||||
public WiiMoteStatus()
|
||||
public CWiiMoteStatus()
|
||||
{
|
||||
IRState.Sensors = new IR[4];
|
||||
IRState.Sensors = new SIR[4];
|
||||
}
|
||||
}
|
||||
|
||||
public struct LEDStatus
|
||||
public struct SLEDStatus
|
||||
{
|
||||
public bool LED1;
|
||||
public bool LED2;
|
||||
@@ -38,46 +38,46 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
public bool LED4;
|
||||
}
|
||||
|
||||
public enum IRMode : byte
|
||||
public enum EIRMode : byte
|
||||
{
|
||||
Off = 0x00,
|
||||
Basic = 0x01, // 10 bytes
|
||||
Extended = 0x03 // 12 bytes
|
||||
};
|
||||
|
||||
public struct IR
|
||||
public struct SIR
|
||||
{
|
||||
public bool Active;
|
||||
public Point Position; // X: 0-1023; Y: 0-767
|
||||
public int Width; // 0-15
|
||||
}
|
||||
|
||||
public struct IRState
|
||||
public struct SIRState
|
||||
{
|
||||
public IRMode Mode;
|
||||
public IR[] Sensors;
|
||||
public EIRMode Mode;
|
||||
public SIR[] Sensors;
|
||||
public Point Position; //0..1023, 0..767
|
||||
public Point Distance; //between Point 0 and Point 1
|
||||
}
|
||||
|
||||
public struct AccelStatus
|
||||
public struct SAccelStatus
|
||||
{
|
||||
public SPoint3 RawValues; //0-255
|
||||
public SPoint3f Values; //0-3
|
||||
public SPoint3F Values; //0-3
|
||||
}
|
||||
|
||||
public struct AccelCalibrationInfo
|
||||
public struct SAccelCalibrationInfo
|
||||
{
|
||||
public byte X0, Y0, Z0; //zero point
|
||||
public byte XG, YG, ZG; //gravity
|
||||
public byte GravityX, GravityY, GravityZ; //gravity
|
||||
}
|
||||
|
||||
public struct Buttons
|
||||
public struct SButtons
|
||||
{
|
||||
public bool Up, Down, Left, Right, A, B, Plus, Minus, One, Two, Home;
|
||||
}
|
||||
|
||||
public enum InputReport : byte
|
||||
public enum EInputReport : byte
|
||||
{
|
||||
Status = 0x20,
|
||||
ReadData = 0x21,
|
||||
@@ -91,7 +91,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
IRExtensionAccel = 0x37,
|
||||
};
|
||||
|
||||
public enum IRSensitivity
|
||||
public enum EIRSensitivity
|
||||
{
|
||||
Level1,
|
||||
Level2,
|
||||
@@ -103,35 +103,39 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
#endregion DataTypes
|
||||
|
||||
#region Events
|
||||
public class WiiMoteChangedEventArgs : EventArgs
|
||||
public class CWiiMoteChangedEventArgs : EventArgs
|
||||
{
|
||||
public WiiMoteStatus WiiMoteState;
|
||||
public CWiiMoteStatus WiiMoteState;
|
||||
|
||||
public WiiMoteChangedEventArgs(WiiMoteStatus ws)
|
||||
public CWiiMoteChangedEventArgs(CWiiMoteStatus ws)
|
||||
{
|
||||
WiiMoteState = ws;
|
||||
}
|
||||
}
|
||||
#endregion Events
|
||||
|
||||
public class WiiMoteLib : IDisposable
|
||||
public class CWiiMoteLib : IDisposable
|
||||
{
|
||||
private const ushort VID = 0x057e;
|
||||
private const ushort PID = 0x0306; //Wiimotion
|
||||
private const ushort PIDPlus = 0x0330; //Wiimotion Plus
|
||||
// ReSharper disable InconsistentNaming
|
||||
private const ushort _VID = 0x057e;
|
||||
// ReSharper restore InconsistentNaming
|
||||
private const ushort _PID = 0x0306; //Wiimotion
|
||||
private const ushort _PIDPlus = 0x0330; //Wiimotion Plus
|
||||
|
||||
// registers
|
||||
private const int REGISTER_IR = 0x04b00030;
|
||||
private const int REGISTER_IR_SENSITIVITY_1 = 0x04b00000;
|
||||
private const int REGISTER_IR_SENSITIVITY_2 = 0x04b0001a;
|
||||
private const int REGISTER_IR_MODE = 0x04b00033;
|
||||
private const int _RegisterIR = 0x04b00030;
|
||||
private const int _RegisterIRSensitivity1 = 0x04b00000;
|
||||
private const int _RegisterIRSensitivity2 = 0x04b0001a;
|
||||
private const int _RegisterIRMode = 0x04b00033;
|
||||
|
||||
private const int REPORT_LENGTH = 22;
|
||||
private const int _ReportLength = 22;
|
||||
|
||||
// output commands
|
||||
private enum OutputReport : byte
|
||||
private enum EOutputReport : byte
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
LEDs = 0x11,
|
||||
// ReSharper restore InconsistentNaming
|
||||
Type = 0x12,
|
||||
IR = 0x13,
|
||||
Status = 0x15,
|
||||
@@ -144,7 +148,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
|
||||
// data handling
|
||||
private IntPtr _Handle;
|
||||
private readonly byte[] _Buff = new byte[REPORT_LENGTH];
|
||||
private readonly byte[] _Buff = new byte[_ReportLength];
|
||||
private byte[] _ReadBuff;
|
||||
private int _Address;
|
||||
private short _Size;
|
||||
@@ -159,20 +163,32 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
get { return _Connected; }
|
||||
}
|
||||
|
||||
private readonly WiiMoteStatus _WiiMoteState = new WiiMoteStatus();
|
||||
private readonly CWiiMoteStatus _WiiMoteState = new CWiiMoteStatus();
|
||||
private readonly AutoResetEvent _ReadDone = new AutoResetEvent(false);
|
||||
public event EventHandler<WiiMoteChangedEventArgs> WiiMoteChanged;
|
||||
public event EventHandler<CWiiMoteChangedEventArgs> WiiMoteChanged;
|
||||
|
||||
#region Interface
|
||||
public WiiMoteLib()
|
||||
public CWiiMoteLib()
|
||||
{
|
||||
_Connected = false;
|
||||
_Active = true;
|
||||
_Error = false;
|
||||
_Reader = new Thread(ReaderLoop);
|
||||
_Reader = new Thread(_ReaderLoop);
|
||||
_Reader.Start();
|
||||
}
|
||||
|
||||
private bool _TryConnect(ushort pid)
|
||||
{
|
||||
bool connected = CHIDApi.Open(_VID, pid, out _Handle);
|
||||
if (connected)
|
||||
{
|
||||
connected = _ReadCalibration();
|
||||
if (!connected)
|
||||
CHIDApi.Close(_Handle);
|
||||
}
|
||||
return connected;
|
||||
}
|
||||
|
||||
public bool Connect()
|
||||
{
|
||||
_Connected = false;
|
||||
@@ -180,9 +196,9 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
if (_Error)
|
||||
return false;
|
||||
|
||||
CHIDAPI.Exit();
|
||||
CHIDApi.Exit();
|
||||
|
||||
if (!CHIDAPI.Init())
|
||||
if (!CHIDApi.Init())
|
||||
{
|
||||
CLog.LogError("WiiMoteLib: Can't initialize HID API");
|
||||
string msg = "Please install the Visual C++ Redistributable Packages 2008!";
|
||||
@@ -194,21 +210,11 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
}
|
||||
|
||||
//Try WiiMotion
|
||||
if (_Connected = CHIDAPI.Open(VID, PID, out _Handle))
|
||||
{
|
||||
if (!(_Connected = ReadCalibration()))
|
||||
CHIDAPI.Close(_Handle);
|
||||
}
|
||||
|
||||
if (_Connected)
|
||||
return true;
|
||||
_Connected = _TryConnect(_PID);
|
||||
|
||||
//Try WiiMotion Plus
|
||||
if (_Connected = CHIDAPI.Open(VID, PIDPlus, out _Handle))
|
||||
{
|
||||
if (!(_Connected = ReadCalibration()))
|
||||
CHIDAPI.Close(_Handle);
|
||||
}
|
||||
if (!_Connected)
|
||||
_Connected = _TryConnect(_PIDPlus);
|
||||
|
||||
return _Connected;
|
||||
}
|
||||
@@ -217,30 +223,30 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
{
|
||||
_Connected = false;
|
||||
_Active = false;
|
||||
CHIDAPI.Exit();
|
||||
CHIDApi.Exit();
|
||||
}
|
||||
|
||||
public void SetReportType(InputReport type, IRSensitivity irSensitivity, bool continuous)
|
||||
public void SetReportType(EInputReport type, EIRSensitivity irSensitivity, bool continuous)
|
||||
{
|
||||
if (!_Connected)
|
||||
return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case InputReport.IRAccel:
|
||||
EnableIR(IRMode.Extended, irSensitivity);
|
||||
case EInputReport.IRAccel:
|
||||
_EnableIR(EIRMode.Extended, irSensitivity);
|
||||
break;
|
||||
default:
|
||||
DisableIR();
|
||||
_DisableIR();
|
||||
break;
|
||||
}
|
||||
|
||||
ClearReport();
|
||||
_Buff[0] = (byte)OutputReport.Type;
|
||||
_ClearReport();
|
||||
_Buff[0] = (byte)EOutputReport.Type;
|
||||
_Buff[1] = (byte)((continuous ? 0x04 : 0x00) | (byte)(_WiiMoteState.Rumble ? 0x01 : 0x00));
|
||||
_Buff[2] = (byte)type;
|
||||
|
||||
CHIDAPI.Write(_Handle, _Buff);
|
||||
CHIDApi.Write(_Handle, _Buff);
|
||||
}
|
||||
|
||||
public void SetLEDs(bool led1, bool led2, bool led3, bool led4)
|
||||
@@ -253,17 +259,17 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
if (!_Connected)
|
||||
return;
|
||||
|
||||
ClearReport();
|
||||
_ClearReport();
|
||||
|
||||
_Buff[0] = (byte)OutputReport.LEDs;
|
||||
_Buff[0] = (byte)EOutputReport.LEDs;
|
||||
_Buff[1] = (byte)(
|
||||
(led1 ? 0x10 : 0x00) |
|
||||
(led2 ? 0x20 : 0x00) |
|
||||
(led3 ? 0x40 : 0x00) |
|
||||
(led4 ? 0x80 : 0x00) |
|
||||
RumbleBit);
|
||||
_RumbleBit);
|
||||
|
||||
CHIDAPI.Write(_Handle, _Buff);
|
||||
CHIDApi.Write(_Handle, _Buff);
|
||||
}
|
||||
|
||||
public void SetRumble(bool on)
|
||||
@@ -277,14 +283,14 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
_WiiMoteState.LEDState.LED4);
|
||||
}
|
||||
|
||||
public WiiMoteStatus WiiMoteState
|
||||
public CWiiMoteStatus WiiMoteState
|
||||
{
|
||||
get { return _WiiMoteState; }
|
||||
}
|
||||
#endregion Interface
|
||||
|
||||
#region Private stuff
|
||||
private void ReaderLoop()
|
||||
private void _ReaderLoop()
|
||||
{
|
||||
while (_Active)
|
||||
{
|
||||
@@ -292,27 +298,27 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
|
||||
if (_Handle != IntPtr.Zero && _Connected)
|
||||
{
|
||||
byte[] buff = new byte[REPORT_LENGTH];
|
||||
byte[] buff = new byte[_ReportLength];
|
||||
|
||||
try
|
||||
{
|
||||
CHIDAPI.ReadTimeout(_Handle, out buff, REPORT_LENGTH, 100);
|
||||
CHIDApi.ReadTimeout(_Handle, out buff, _ReportLength, 100);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("(WiiMoteLib) Error reading from device: " + e);
|
||||
}
|
||||
|
||||
if (ParseInputReport(buff))
|
||||
if (_ParseInputReport(buff))
|
||||
{
|
||||
if (WiiMoteChanged != null)
|
||||
WiiMoteChanged(this, new WiiMoteChangedEventArgs(_WiiMoteState));
|
||||
WiiMoteChanged(this, new CWiiMoteChangedEventArgs(_WiiMoteState));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool ParseInputReport(byte[] buff)
|
||||
private bool _ParseInputReport(byte[] buff)
|
||||
{
|
||||
if (buff == null)
|
||||
{
|
||||
@@ -320,42 +326,42 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
return false;
|
||||
}
|
||||
|
||||
InputReport type = (InputReport)buff[0];
|
||||
EInputReport type = (EInputReport)buff[0];
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case InputReport.Buttons:
|
||||
ParseButtons(buff);
|
||||
case EInputReport.Buttons:
|
||||
_ParseButtons(buff);
|
||||
break;
|
||||
|
||||
case InputReport.ButtonsAccel:
|
||||
ParseButtons(buff);
|
||||
ParseAccel(buff);
|
||||
case EInputReport.ButtonsAccel:
|
||||
_ParseButtons(buff);
|
||||
_ParseAccel(buff);
|
||||
break;
|
||||
|
||||
case InputReport.IRAccel:
|
||||
ParseButtons(buff);
|
||||
ParseAccel(buff);
|
||||
ParseIR(buff);
|
||||
case EInputReport.IRAccel:
|
||||
_ParseButtons(buff);
|
||||
_ParseAccel(buff);
|
||||
_ParseIR(buff);
|
||||
break;
|
||||
|
||||
case InputReport.ButtonsExtension:
|
||||
ParseButtons(buff);
|
||||
case EInputReport.ButtonsExtension:
|
||||
_ParseButtons(buff);
|
||||
break;
|
||||
|
||||
case InputReport.ExtensionAccel:
|
||||
ParseButtons(buff);
|
||||
ParseAccel(buff);
|
||||
case EInputReport.ExtensionAccel:
|
||||
_ParseButtons(buff);
|
||||
_ParseAccel(buff);
|
||||
break;
|
||||
|
||||
case InputReport.IRExtensionAccel:
|
||||
ParseButtons(buff);
|
||||
ParseAccel(buff);
|
||||
ParseIR(buff);
|
||||
case EInputReport.IRExtensionAccel:
|
||||
_ParseButtons(buff);
|
||||
_ParseAccel(buff);
|
||||
_ParseIR(buff);
|
||||
break;
|
||||
|
||||
case InputReport.Status:
|
||||
ParseButtons(buff);
|
||||
case EInputReport.Status:
|
||||
_ParseButtons(buff);
|
||||
_WiiMoteState.Battery = buff[6];
|
||||
|
||||
_WiiMoteState.LEDState.LED1 = (buff[3] & 0x10) != 0;
|
||||
@@ -364,15 +370,15 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
_WiiMoteState.LEDState.LED4 = (buff[3] & 0x80) != 0;
|
||||
break;
|
||||
|
||||
case InputReport.ReadData:
|
||||
ParseButtons(buff);
|
||||
ParseReadData(buff);
|
||||
case EInputReport.ReadData:
|
||||
_ParseButtons(buff);
|
||||
_ParseReadData(buff);
|
||||
break;
|
||||
|
||||
case InputReport.Ack:
|
||||
case EInputReport.Ack:
|
||||
return false;
|
||||
|
||||
case InputReport.Buttons8Bytes:
|
||||
case EInputReport.Buttons8Bytes:
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -383,7 +389,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
return true;
|
||||
}
|
||||
|
||||
private byte[] DecryptBuffer(byte[] buff)
|
||||
private byte[] _DecryptBuffer(byte[] buff)
|
||||
{
|
||||
for (int i = 0; i < buff.Length; i++)
|
||||
buff[i] = (byte)(((buff[i] ^ 0x17) + 0x17) & 0xff);
|
||||
@@ -391,7 +397,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
return buff;
|
||||
}
|
||||
|
||||
private void ParseButtons(byte[] buff)
|
||||
private void _ParseButtons(byte[] buff)
|
||||
{
|
||||
_WiiMoteState.ButtonState.A = (buff[2] & 0x08) != 0;
|
||||
_WiiMoteState.ButtonState.B = (buff[2] & 0x04) != 0;
|
||||
@@ -406,25 +412,25 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
_WiiMoteState.ButtonState.Right = (buff[1] & 0x02) != 0;
|
||||
}
|
||||
|
||||
private void ParseAccel(byte[] buff)
|
||||
private void _ParseAccel(byte[] buff)
|
||||
{
|
||||
_WiiMoteState.AccelState.RawValues.X = buff[3];
|
||||
_WiiMoteState.AccelState.RawValues.Y = buff[4];
|
||||
_WiiMoteState.AccelState.RawValues.Z = buff[5];
|
||||
|
||||
_WiiMoteState.AccelState.Values.X = ((float)_WiiMoteState.AccelState.RawValues.X - _WiiMoteState.AccelCalibrationInfo.X0) /
|
||||
((float)_WiiMoteState.AccelCalibrationInfo.XG - _WiiMoteState.AccelCalibrationInfo.X0);
|
||||
((float)_WiiMoteState.AccelCalibrationInfo.GravityX - _WiiMoteState.AccelCalibrationInfo.X0);
|
||||
_WiiMoteState.AccelState.Values.Y = ((float)_WiiMoteState.AccelState.RawValues.Y - _WiiMoteState.AccelCalibrationInfo.Y0) /
|
||||
((float)_WiiMoteState.AccelCalibrationInfo.YG - _WiiMoteState.AccelCalibrationInfo.Y0);
|
||||
((float)_WiiMoteState.AccelCalibrationInfo.GravityY - _WiiMoteState.AccelCalibrationInfo.Y0);
|
||||
_WiiMoteState.AccelState.Values.Z = ((float)_WiiMoteState.AccelState.RawValues.Z - _WiiMoteState.AccelCalibrationInfo.Z0) /
|
||||
((float)_WiiMoteState.AccelCalibrationInfo.ZG - _WiiMoteState.AccelCalibrationInfo.Z0);
|
||||
((float)_WiiMoteState.AccelCalibrationInfo.GravityZ - _WiiMoteState.AccelCalibrationInfo.Z0);
|
||||
}
|
||||
|
||||
private void ParseIR(byte[] buff)
|
||||
private void _ParseIR(byte[] buff)
|
||||
{
|
||||
switch (_WiiMoteState.IRState.Mode)
|
||||
{
|
||||
case IRMode.Basic:
|
||||
case EIRMode.Basic:
|
||||
if (_WiiMoteState.IRState.Sensors[0].Active = !(buff[6] == 0xff && buff[7] == 0xff))
|
||||
{
|
||||
_WiiMoteState.IRState.Sensors[0].Position.X = buff[6] | ((buff[8] >> 4) & 0x03) << 8;
|
||||
@@ -439,7 +445,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
_WiiMoteState.IRState.Sensors[1].Width = 0;
|
||||
}
|
||||
break;
|
||||
case IRMode.Extended:
|
||||
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))
|
||||
@@ -474,7 +480,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
}
|
||||
}
|
||||
|
||||
private void ParseReadData(byte[] buff)
|
||||
private void _ParseReadData(byte[] buff)
|
||||
{
|
||||
if ((buff[3] & 0x08) != 0)
|
||||
{
|
||||
@@ -497,7 +503,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
_ReadDone.Set();
|
||||
}
|
||||
|
||||
private byte RumbleBit
|
||||
private byte _RumbleBit
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -507,112 +513,112 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
}
|
||||
}
|
||||
|
||||
private bool ReadCalibration()
|
||||
private bool _ReadCalibration()
|
||||
{
|
||||
// this appears to change the report type to 0x31
|
||||
byte[] buff = ReadData(0x0016, 7);
|
||||
byte[] buff = _ReadData(0x0016, 7);
|
||||
if (buff == null)
|
||||
return false;
|
||||
|
||||
_WiiMoteState.AccelCalibrationInfo.X0 = buff[0];
|
||||
_WiiMoteState.AccelCalibrationInfo.Y0 = buff[1];
|
||||
_WiiMoteState.AccelCalibrationInfo.Z0 = buff[2];
|
||||
_WiiMoteState.AccelCalibrationInfo.XG = buff[4];
|
||||
_WiiMoteState.AccelCalibrationInfo.YG = buff[5];
|
||||
_WiiMoteState.AccelCalibrationInfo.ZG = buff[6];
|
||||
_WiiMoteState.AccelCalibrationInfo.GravityX = buff[4];
|
||||
_WiiMoteState.AccelCalibrationInfo.GravityY = buff[5];
|
||||
_WiiMoteState.AccelCalibrationInfo.GravityZ = buff[6];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void EnableIR(IRMode mode, IRSensitivity Sensitivity)
|
||||
private void _EnableIR(EIRMode mode, EIRSensitivity sensitivity)
|
||||
{
|
||||
_WiiMoteState.IRState.Mode = mode;
|
||||
|
||||
ClearReport();
|
||||
_Buff[0] = (byte)OutputReport.IR;
|
||||
_Buff[1] = (byte)(0x04 | RumbleBit);
|
||||
CHIDAPI.Write(_Handle, _Buff);
|
||||
_ClearReport();
|
||||
_Buff[0] = (byte)EOutputReport.IR;
|
||||
_Buff[1] = (byte)(0x04 | _RumbleBit);
|
||||
CHIDApi.Write(_Handle, _Buff);
|
||||
Thread.Sleep(50);
|
||||
|
||||
ClearReport();
|
||||
_Buff[0] = (byte)OutputReport.IR2;
|
||||
_Buff[1] = (byte)(0x04 | RumbleBit);
|
||||
CHIDAPI.Write(_Handle, _Buff);
|
||||
_ClearReport();
|
||||
_Buff[0] = (byte)EOutputReport.IR2;
|
||||
_Buff[1] = (byte)(0x04 | _RumbleBit);
|
||||
CHIDApi.Write(_Handle, _Buff);
|
||||
Thread.Sleep(50);
|
||||
|
||||
WriteData(REGISTER_IR, 0x08);
|
||||
_WriteData(_RegisterIR, 0x08);
|
||||
Thread.Sleep(50);
|
||||
|
||||
switch (Sensitivity)
|
||||
switch (sensitivity)
|
||||
{
|
||||
case IRSensitivity.Level1:
|
||||
WriteData(REGISTER_IR_SENSITIVITY_1, 9, new byte[] {0x02, 0x00, 0x00, 0x71, 0x01, 0x00, 0x64, 0x00, 0xfe});
|
||||
case EIRSensitivity.Level1:
|
||||
_WriteData(_RegisterIRSensitivity1, 9, new byte[] {0x02, 0x00, 0x00, 0x71, 0x01, 0x00, 0x64, 0x00, 0xfe});
|
||||
Thread.Sleep(50);
|
||||
WriteData(REGISTER_IR_SENSITIVITY_2, 2, new byte[] {0xfd, 0x05});
|
||||
_WriteData(_RegisterIRSensitivity2, 2, new byte[] {0xfd, 0x05});
|
||||
break;
|
||||
case IRSensitivity.Level2:
|
||||
WriteData(REGISTER_IR_SENSITIVITY_1, 9, new byte[] {0x02, 0x00, 0x00, 0x71, 0x01, 0x00, 0x96, 0x00, 0xb4});
|
||||
case EIRSensitivity.Level2:
|
||||
_WriteData(_RegisterIRSensitivity1, 9, new byte[] {0x02, 0x00, 0x00, 0x71, 0x01, 0x00, 0x96, 0x00, 0xb4});
|
||||
Thread.Sleep(50);
|
||||
WriteData(REGISTER_IR_SENSITIVITY_2, 2, new byte[] {0xb3, 0x04});
|
||||
_WriteData(_RegisterIRSensitivity2, 2, new byte[] {0xb3, 0x04});
|
||||
break;
|
||||
case IRSensitivity.Level3:
|
||||
WriteData(REGISTER_IR_SENSITIVITY_1, 9, new byte[] {0x02, 0x00, 0x00, 0x71, 0x01, 0x00, 0xaa, 0x00, 0x64});
|
||||
case EIRSensitivity.Level3:
|
||||
_WriteData(_RegisterIRSensitivity1, 9, new byte[] {0x02, 0x00, 0x00, 0x71, 0x01, 0x00, 0xaa, 0x00, 0x64});
|
||||
Thread.Sleep(50);
|
||||
WriteData(REGISTER_IR_SENSITIVITY_2, 2, new byte[] {0x63, 0x03});
|
||||
_WriteData(_RegisterIRSensitivity2, 2, new byte[] {0x63, 0x03});
|
||||
break;
|
||||
case IRSensitivity.Level4:
|
||||
WriteData(REGISTER_IR_SENSITIVITY_1, 9, new byte[] {0x02, 0x00, 0x00, 0x71, 0x01, 0x00, 0xc8, 0x00, 0x36});
|
||||
case EIRSensitivity.Level4:
|
||||
_WriteData(_RegisterIRSensitivity1, 9, new byte[] {0x02, 0x00, 0x00, 0x71, 0x01, 0x00, 0xc8, 0x00, 0x36});
|
||||
Thread.Sleep(50);
|
||||
WriteData(REGISTER_IR_SENSITIVITY_2, 2, new byte[] {0x35, 0x03});
|
||||
_WriteData(_RegisterIRSensitivity2, 2, new byte[] {0x35, 0x03});
|
||||
break;
|
||||
case IRSensitivity.Level5:
|
||||
WriteData(REGISTER_IR_SENSITIVITY_1, 9, new byte[] {0x07, 0x00, 0x00, 0x71, 0x01, 0x00, 0x72, 0x00, 0x20});
|
||||
case EIRSensitivity.Level5:
|
||||
_WriteData(_RegisterIRSensitivity1, 9, new byte[] {0x07, 0x00, 0x00, 0x71, 0x01, 0x00, 0x72, 0x00, 0x20});
|
||||
Thread.Sleep(50);
|
||||
WriteData(REGISTER_IR_SENSITIVITY_2, 2, new byte[] {0x1, 0x03});
|
||||
_WriteData(_RegisterIRSensitivity2, 2, new byte[] {0x1, 0x03});
|
||||
break;
|
||||
case IRSensitivity.Max:
|
||||
WriteData(REGISTER_IR_SENSITIVITY_1, 9, new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0x41});
|
||||
case EIRSensitivity.Max:
|
||||
_WriteData(_RegisterIRSensitivity1, 9, new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0x41});
|
||||
Thread.Sleep(50);
|
||||
WriteData(REGISTER_IR_SENSITIVITY_2, 2, new byte[] {0x40, 0x00});
|
||||
_WriteData(_RegisterIRSensitivity2, 2, new byte[] {0x40, 0x00});
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(50);
|
||||
WriteData(REGISTER_IR_MODE, (byte)mode);
|
||||
_WriteData(_RegisterIRMode, (byte)mode);
|
||||
Thread.Sleep(50);
|
||||
WriteData(REGISTER_IR, 0x08);
|
||||
_WriteData(_RegisterIR, 0x08);
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
|
||||
private void DisableIR()
|
||||
private void _DisableIR()
|
||||
{
|
||||
_WiiMoteState.IRState.Mode = IRMode.Off;
|
||||
_WiiMoteState.IRState.Mode = EIRMode.Off;
|
||||
|
||||
ClearReport();
|
||||
_Buff[0] = (byte)OutputReport.IR;
|
||||
_Buff[1] = RumbleBit;
|
||||
CHIDAPI.Write(_Handle, _Buff);
|
||||
_ClearReport();
|
||||
_Buff[0] = (byte)EOutputReport.IR;
|
||||
_Buff[1] = _RumbleBit;
|
||||
CHIDApi.Write(_Handle, _Buff);
|
||||
|
||||
ClearReport();
|
||||
_Buff[0] = (byte)OutputReport.IR2;
|
||||
_Buff[1] = RumbleBit;
|
||||
CHIDAPI.Write(_Handle, _Buff);
|
||||
_ClearReport();
|
||||
_Buff[0] = (byte)EOutputReport.IR2;
|
||||
_Buff[1] = _RumbleBit;
|
||||
CHIDApi.Write(_Handle, _Buff);
|
||||
}
|
||||
|
||||
private void ClearReport()
|
||||
private void _ClearReport()
|
||||
{
|
||||
Array.Clear(_Buff, 0, REPORT_LENGTH);
|
||||
Array.Clear(_Buff, 0, _ReportLength);
|
||||
}
|
||||
|
||||
private byte[] ReadData(int address, short size)
|
||||
private byte[] _ReadData(int address, short size)
|
||||
{
|
||||
ClearReport();
|
||||
_ClearReport();
|
||||
|
||||
_ReadBuff = new byte[size];
|
||||
_Address = address & 0xffff;
|
||||
_Size = size;
|
||||
|
||||
_Buff[0] = (byte)OutputReport.ReadMemory;
|
||||
_Buff[1] = (byte)(((address & 0xff000000) >> 24) | RumbleBit);
|
||||
_Buff[0] = (byte)EOutputReport.ReadMemory;
|
||||
_Buff[1] = (byte)(((address & 0xff000000) >> 24) | _RumbleBit);
|
||||
_Buff[2] = (byte)((address & 0x00ff0000) >> 16);
|
||||
_Buff[3] = (byte)((address & 0x0000ff00) >> 8);
|
||||
_Buff[4] = (byte)(address & 0x000000ff);
|
||||
@@ -620,7 +626,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
_Buff[5] = (byte)((size & 0xff00) >> 8);
|
||||
_Buff[6] = (byte)(size & 0xff);
|
||||
|
||||
CHIDAPI.Write(_Handle, _Buff);
|
||||
CHIDApi.Write(_Handle, _Buff);
|
||||
|
||||
if (!_ReadDone.WaitOne(1000, false))
|
||||
{
|
||||
@@ -631,24 +637,24 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
return _ReadBuff;
|
||||
}
|
||||
|
||||
private void WriteData(int address, byte data)
|
||||
private void _WriteData(int address, byte data)
|
||||
{
|
||||
WriteData(address, 1, new byte[] {data});
|
||||
_WriteData(address, 1, new byte[] {data});
|
||||
}
|
||||
|
||||
private void WriteData(int address, byte size, byte[] buff)
|
||||
private void _WriteData(int address, byte size, byte[] buff)
|
||||
{
|
||||
ClearReport();
|
||||
_ClearReport();
|
||||
|
||||
_Buff[0] = (byte)OutputReport.WriteMemory;
|
||||
_Buff[1] = (byte)(((address & 0xff000000) >> 24) | RumbleBit);
|
||||
_Buff[0] = (byte)EOutputReport.WriteMemory;
|
||||
_Buff[1] = (byte)(((address & 0xff000000) >> 24) | _RumbleBit);
|
||||
_Buff[2] = (byte)((address & 0x00ff0000) >> 16);
|
||||
_Buff[3] = (byte)((address & 0x0000ff00) >> 8);
|
||||
_Buff[4] = (byte)(address & 0x000000ff);
|
||||
_Buff[5] = size;
|
||||
Array.Copy(buff, 0, _Buff, 6, size);
|
||||
|
||||
CHIDAPI.Write(_Handle, _Buff);
|
||||
CHIDApi.Write(_Handle, _Buff);
|
||||
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@@ -661,7 +667,9 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
protected virtual void Dispose(bool disposing)
|
||||
// ReSharper restore InconsistentNaming
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Vocaluxe.Lib.Playlist
|
||||
{
|
||||
public class CPlaylistFile
|
||||
{
|
||||
private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
|
||||
public string PlaylistName;
|
||||
public string PlaylistFile;
|
||||
@@ -19,23 +19,23 @@ namespace Vocaluxe.Lib.Playlist
|
||||
|
||||
public CPlaylistFile()
|
||||
{
|
||||
Init();
|
||||
_Init();
|
||||
PlaylistName = string.Empty;
|
||||
PlaylistFile = string.Empty;
|
||||
}
|
||||
|
||||
public CPlaylistFile(string file)
|
||||
{
|
||||
Init();
|
||||
_Init();
|
||||
PlaylistFile = file;
|
||||
LoadPlaylist();
|
||||
_LoadPlaylist();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
private void _Init()
|
||||
{
|
||||
_settings.Indent = true;
|
||||
_settings.Encoding = Encoding.UTF8;
|
||||
_settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
_Settings.Indent = true;
|
||||
_Settings.Encoding = Encoding.UTF8;
|
||||
_Settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
}
|
||||
|
||||
public void SavePlaylist()
|
||||
@@ -53,20 +53,20 @@ namespace Vocaluxe.Lib.Playlist
|
||||
filename = "1";
|
||||
|
||||
int i = 0;
|
||||
while (File.Exists(Path.Combine(CSettings.sFolderPlaylists, filename + ".xml")))
|
||||
while (File.Exists(Path.Combine(CSettings.FolderPlaylists, filename + ".xml")))
|
||||
{
|
||||
i++;
|
||||
if (!File.Exists(Path.Combine(CSettings.sFolderPlaylists, filename + i + ".xml")))
|
||||
if (!File.Exists(Path.Combine(CSettings.FolderPlaylists, filename + i + ".xml")))
|
||||
filename += i;
|
||||
}
|
||||
|
||||
PlaylistFile = Path.Combine(CSettings.sFolderPlaylists, filename + ".xml");
|
||||
PlaylistFile = Path.Combine(CSettings.FolderPlaylists, filename + ".xml");
|
||||
}
|
||||
|
||||
XmlWriter writer;
|
||||
try
|
||||
{
|
||||
writer = XmlWriter.Create(PlaylistFile, _settings);
|
||||
writer = XmlWriter.Create(PlaylistFile, _Settings);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ namespace Vocaluxe.Lib.Playlist
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadPlaylist()
|
||||
private void _LoadPlaylist()
|
||||
{
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(PlaylistFile);
|
||||
if (xmlReader == null)
|
||||
@@ -143,13 +143,13 @@ namespace Vocaluxe.Lib.Playlist
|
||||
|
||||
CPlaylistSong song = new CPlaylistSong();
|
||||
song.SongID = -1;
|
||||
CSong[] AllSongs = CSongs.AllSongs;
|
||||
CSong[] allSongs = CSongs.AllSongs;
|
||||
|
||||
for (int s = 0; s < AllSongs.Length; s++)
|
||||
for (int s = 0; s < allSongs.Length; s++)
|
||||
{
|
||||
if (AllSongs[s].Artist == artist && AllSongs[s].Title == title)
|
||||
if (allSongs[s].Artist == artist && allSongs[s].Title == title)
|
||||
{
|
||||
song.SongID = AllSongs[s].ID;
|
||||
song.SongID = allSongs[s].ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -167,11 +167,11 @@ namespace Vocaluxe.Lib.Playlist
|
||||
CLog.LogError("Can't find PlaylistName in Playlist File: " + PlaylistFile);
|
||||
}
|
||||
|
||||
public void AddSong(int SongID)
|
||||
public void AddSong(int songID)
|
||||
{
|
||||
CPlaylistSong song = new CPlaylistSong();
|
||||
song.SongID = SongID;
|
||||
if (CSongs.GetSong(SongID).IsDuet)
|
||||
song.SongID = songID;
|
||||
if (CSongs.GetSong(songID).IsDuet)
|
||||
song.GameMode = EGameMode.TR_GAMEMODE_DUET;
|
||||
else
|
||||
song.GameMode = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
@@ -179,49 +179,49 @@ namespace Vocaluxe.Lib.Playlist
|
||||
Songs.Add(song);
|
||||
}
|
||||
|
||||
public void AddSong(int SongID, EGameMode gm)
|
||||
public void AddSong(int songID, EGameMode gm)
|
||||
{
|
||||
CPlaylistSong song = new CPlaylistSong();
|
||||
song.SongID = SongID;
|
||||
song.SongID = songID;
|
||||
song.GameMode = gm;
|
||||
|
||||
Songs.Add(song);
|
||||
}
|
||||
|
||||
public void DeleteSong(int SongNr)
|
||||
public void DeleteSong(int songNr)
|
||||
{
|
||||
Songs.RemoveAt(SongNr);
|
||||
Songs.RemoveAt(songNr);
|
||||
}
|
||||
|
||||
public void SongUp(int SongNr)
|
||||
public void SongUp(int songNr)
|
||||
{
|
||||
if (SongNr < Songs.Count - 1 && SongNr > 0)
|
||||
Songs.Reverse(SongNr - 1, 2);
|
||||
if (songNr < Songs.Count - 1 && songNr > 0)
|
||||
Songs.Reverse(songNr - 1, 2);
|
||||
}
|
||||
|
||||
public void SongDown(int SongNr)
|
||||
public void SongDown(int songNr)
|
||||
{
|
||||
if (SongNr < Songs.Count - 1 && SongNr >= 0)
|
||||
Songs.Reverse(SongNr, 2);
|
||||
if (songNr < Songs.Count - 1 && songNr >= 0)
|
||||
Songs.Reverse(songNr, 2);
|
||||
}
|
||||
|
||||
public void SongMove(int SourceNr, int DestNr)
|
||||
public void SongMove(int sourceNr, int destNr)
|
||||
{
|
||||
if (SourceNr < 0 || DestNr < 0 || SourceNr == DestNr || SourceNr > Songs.Count - 1 || DestNr > Songs.Count - 1)
|
||||
if (sourceNr < 0 || destNr < 0 || sourceNr == destNr || sourceNr > Songs.Count - 1 || destNr > Songs.Count - 1)
|
||||
return;
|
||||
|
||||
CPlaylistSong ps = new CPlaylistSong(Songs[SourceNr]);
|
||||
Songs.RemoveAt(SourceNr);
|
||||
Songs.Insert(DestNr, ps);
|
||||
CPlaylistSong ps = new CPlaylistSong(Songs[sourceNr]);
|
||||
Songs.RemoveAt(sourceNr);
|
||||
Songs.Insert(destNr, ps);
|
||||
}
|
||||
|
||||
public void SongInsert(int DestNr, int SongID, EGameMode gm)
|
||||
public void SongInsert(int destNr, int songID, EGameMode gm)
|
||||
{
|
||||
if (DestNr < 0 || DestNr > Songs.Count - 1)
|
||||
if (destNr < 0 || destNr > Songs.Count - 1)
|
||||
return;
|
||||
|
||||
CPlaylistSong ps = new CPlaylistSong(SongID, gm);
|
||||
Songs.Insert(DestNr, ps);
|
||||
CPlaylistSong ps = new CPlaylistSong(songID, gm);
|
||||
Songs.Insert(destNr, ps);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,10 @@ namespace Vocaluxe.Lib.Sound
|
||||
{
|
||||
class CDirectSoundRecord : IRecord
|
||||
{
|
||||
private bool _initialized;
|
||||
private bool _Initialized;
|
||||
private List<SRecordDevice> _Devices;
|
||||
private SRecordDevice[] _DeviceConfig;
|
||||
private List<SoundCardSource> _Sources;
|
||||
private List<CSoundCardSource> _Sources;
|
||||
|
||||
private readonly CBuffer[] _Buffer;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
{
|
||||
DeviceCollection devices = DirectSoundCapture.GetDevices();
|
||||
_Devices = new List<SRecordDevice>();
|
||||
_Sources = new List<SoundCardSource>();
|
||||
_Sources = new List<CSoundCardSource>();
|
||||
|
||||
int id = 0;
|
||||
foreach (DeviceInformation dev in devices)
|
||||
@@ -57,43 +57,43 @@ namespace Vocaluxe.Lib.Sound
|
||||
}
|
||||
|
||||
_DeviceConfig = _Devices.ToArray();
|
||||
_initialized = true;
|
||||
_Initialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void CloseAll()
|
||||
{
|
||||
if (_initialized)
|
||||
if (_Initialized)
|
||||
{
|
||||
Stop();
|
||||
_initialized = false;
|
||||
_Initialized = false;
|
||||
}
|
||||
//System.IO.File.WriteAllBytes("test0.raw", _Buffer[0].Buffer);
|
||||
}
|
||||
|
||||
public bool Start(SRecordDevice[] DeviceConfig)
|
||||
public bool Start(SRecordDevice[] deviceConfig)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < _Buffer.Length; i++)
|
||||
_Buffer[i].Reset();
|
||||
|
||||
_DeviceConfig = DeviceConfig;
|
||||
bool[] active = new bool[DeviceConfig.Length];
|
||||
Guid[] guid = new Guid[DeviceConfig.Length];
|
||||
short[] channels = new short[DeviceConfig.Length];
|
||||
for (int dev = 0; dev < DeviceConfig.Length; dev++)
|
||||
_DeviceConfig = deviceConfig;
|
||||
bool[] active = new bool[deviceConfig.Length];
|
||||
Guid[] guid = new Guid[deviceConfig.Length];
|
||||
short[] channels = new short[deviceConfig.Length];
|
||||
for (int dev = 0; dev < deviceConfig.Length; dev++)
|
||||
{
|
||||
active[dev] = false;
|
||||
for (int inp = 0; inp < DeviceConfig[dev].Inputs.Count; inp++)
|
||||
for (int inp = 0; inp < deviceConfig[dev].Inputs.Count; inp++)
|
||||
{
|
||||
if (DeviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 ||
|
||||
DeviceConfig[dev].Inputs[inp].PlayerChannel2 > 0)
|
||||
if (deviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 ||
|
||||
deviceConfig[dev].Inputs[inp].PlayerChannel2 > 0)
|
||||
active[dev] = true;
|
||||
guid[dev] = new Guid(DeviceConfig[dev].Driver);
|
||||
channels[dev] = (short)DeviceConfig[dev].Inputs[0].Channels;
|
||||
guid[dev] = new Guid(deviceConfig[dev].Driver);
|
||||
channels[dev] = (short)deviceConfig[dev].Inputs[0].Channels;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,25 +101,25 @@ namespace Vocaluxe.Lib.Sound
|
||||
{
|
||||
if (active[i])
|
||||
{
|
||||
SoundCardSource source = new SoundCardSource(guid[i], channels[i]);
|
||||
source.SampleRateKHz = 44.1;
|
||||
source.SampleDataReady += OnDataReady;
|
||||
CSoundCardSource source = new CSoundCardSource(guid[i], channels[i]);
|
||||
source.SampleRateKhz = 44.1;
|
||||
source.SampleDataReady += _OnDataReady;
|
||||
source.Start();
|
||||
|
||||
_Sources.Add(source);
|
||||
}
|
||||
}
|
||||
|
||||
_DeviceConfig = DeviceConfig;
|
||||
_DeviceConfig = deviceConfig;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Stop()
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return false;
|
||||
|
||||
foreach (SoundCardSource source in _Sources)
|
||||
foreach (CSoundCardSource source in _Sources)
|
||||
{
|
||||
source.Stop();
|
||||
source.Dispose();
|
||||
@@ -129,57 +129,57 @@ namespace Vocaluxe.Lib.Sound
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AnalyzeBuffer(int Player)
|
||||
public void AnalyzeBuffer(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return;
|
||||
|
||||
_Buffer[Player].AnalyzeBuffer();
|
||||
_Buffer[player].AnalyzeBuffer();
|
||||
}
|
||||
|
||||
public int GetToneAbs(int Player)
|
||||
public int GetToneAbs(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return 0;
|
||||
|
||||
return _Buffer[Player].ToneAbs;
|
||||
return _Buffer[player].ToneAbs;
|
||||
}
|
||||
|
||||
public int GetTone(int Player)
|
||||
public int GetTone(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return 0;
|
||||
|
||||
return _Buffer[Player].Tone;
|
||||
return _Buffer[player].Tone;
|
||||
}
|
||||
|
||||
public void SetTone(int Player, int Tone)
|
||||
public void SetTone(int player, int tone)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return;
|
||||
|
||||
_Buffer[Player].Tone = Tone;
|
||||
_Buffer[player].Tone = tone;
|
||||
}
|
||||
|
||||
public float GetMaxVolume(int Player)
|
||||
public float GetMaxVolume(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return 0f;
|
||||
|
||||
return _Buffer[Player].MaxVolume;
|
||||
return _Buffer[player].MaxVolume;
|
||||
}
|
||||
|
||||
public bool ToneValid(int Player)
|
||||
public bool ToneValid(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return false;
|
||||
|
||||
return _Buffer[Player].ToneValid;
|
||||
return _Buffer[player].ToneValid;
|
||||
}
|
||||
|
||||
public SRecordDevice[] RecordDevices()
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return null;
|
||||
|
||||
if (_Devices.Count == 0)
|
||||
@@ -188,36 +188,36 @@ namespace Vocaluxe.Lib.Sound
|
||||
return _Devices.ToArray();
|
||||
}
|
||||
|
||||
public int NumHalfTones(int Player)
|
||||
public int NumHalfTones(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return 0;
|
||||
|
||||
return _Buffer[Player].NumHalfTones;
|
||||
return _Buffer[player].NumHalfTones;
|
||||
}
|
||||
|
||||
public float[] ToneWeigth(int Player)
|
||||
public float[] ToneWeigth(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return null;
|
||||
|
||||
return _Buffer[Player].ToneWeigth;
|
||||
return _Buffer[player].ToneWeigth;
|
||||
}
|
||||
|
||||
private void OnDataReady(object sender, SampleDataEventArgs e)
|
||||
private void _OnDataReady(object sender, CSampleDataEventArgs e)
|
||||
{
|
||||
if (_initialized)
|
||||
if (_Initialized)
|
||||
{
|
||||
byte[] _leftBuffer = new byte[e.Data.Length / 2];
|
||||
byte[] _rightBuffer = new byte[e.Data.Length / 2];
|
||||
byte[] leftBuffer = new byte[e.Data.Length / 2];
|
||||
byte[] rightBuffer = new byte[e.Data.Length / 2];
|
||||
|
||||
//[]: Sample, L: Left channel R: Right channel
|
||||
//[LR][LR][LR][LR][LR][LR]
|
||||
//The data is interleaved and needs to be demultiplexed
|
||||
for (int i = 0; i < e.Data.Length / 2; i++)
|
||||
{
|
||||
_leftBuffer[i] = e.Data[i * 2 - (i % 2)];
|
||||
_rightBuffer[i] = e.Data[i * 2 - (i % 2) + 2];
|
||||
leftBuffer[i] = e.Data[i * 2 - (i % 2)];
|
||||
rightBuffer[i] = e.Data[i * 2 - (i % 2) + 2];
|
||||
}
|
||||
|
||||
for (int i = 0; i < _DeviceConfig.Length; i++)
|
||||
@@ -225,18 +225,18 @@ namespace Vocaluxe.Lib.Sound
|
||||
if (_DeviceConfig[i].Driver == e.Guid.ToString())
|
||||
{
|
||||
if (_DeviceConfig[i].Inputs[0].PlayerChannel1 > 0)
|
||||
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel1 - 1].ProcessNewBuffer(_leftBuffer);
|
||||
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer);
|
||||
|
||||
if (_DeviceConfig[i].Inputs[0].PlayerChannel2 > 0)
|
||||
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel2 - 1].ProcessNewBuffer(_rightBuffer);
|
||||
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SampleDataEventArgs : EventArgs
|
||||
public class CSampleDataEventArgs : EventArgs
|
||||
{
|
||||
public SampleDataEventArgs(byte[] data, Guid guid)
|
||||
public CSampleDataEventArgs(byte[] data, Guid guid)
|
||||
{
|
||||
Data = data;
|
||||
Guid = guid;
|
||||
@@ -246,119 +246,119 @@ namespace Vocaluxe.Lib.Sound
|
||||
public Guid Guid { get; private set; }
|
||||
}
|
||||
|
||||
public class SoundCardSource : IDisposable
|
||||
public class CSoundCardSource : IDisposable
|
||||
{
|
||||
private volatile bool running;
|
||||
private readonly int bufferSize;
|
||||
private CaptureBuffer buffer;
|
||||
private CaptureBufferDescription bufferDescription;
|
||||
private DirectSoundCapture captureDevice;
|
||||
private readonly WaveFormat waveFormat;
|
||||
private Thread captureThread;
|
||||
private List<NotificationPosition> notifications;
|
||||
private int bufferPortionCount;
|
||||
private int bufferPortionSize;
|
||||
private WaitHandle[] waitHandles;
|
||||
private double sampleRate;
|
||||
private readonly Guid guid;
|
||||
private readonly short channels;
|
||||
private volatile bool _Running;
|
||||
private readonly int _BufferSize;
|
||||
private CaptureBuffer _CaptureBuffer;
|
||||
private CaptureBufferDescription _BufferDescription;
|
||||
private DirectSoundCapture _CaptureDevice;
|
||||
private readonly WaveFormat _WaveFormat;
|
||||
private Thread _CaptureThread;
|
||||
private List<NotificationPosition> _Notifications;
|
||||
private int _BufferPortionCount;
|
||||
private int _BufferPortionSize;
|
||||
private WaitHandle[] _WaitHandles;
|
||||
private double _SampleRate;
|
||||
private readonly Guid _Guid;
|
||||
private readonly short _Channels;
|
||||
|
||||
public SoundCardSource(Guid guid, short channels)
|
||||
public CSoundCardSource(Guid guid, short channels)
|
||||
{
|
||||
this.guid = guid;
|
||||
this.channels = channels;
|
||||
waveFormat = new WaveFormat();
|
||||
SampleRateKHz = 44.1;
|
||||
bufferSize = 2048;
|
||||
this._Guid = guid;
|
||||
this._Channels = channels;
|
||||
_WaveFormat = new WaveFormat();
|
||||
SampleRateKhz = 44.1;
|
||||
_BufferSize = 2048;
|
||||
}
|
||||
|
||||
public event EventHandler<SampleDataEventArgs> SampleDataReady = delegate { };
|
||||
public event EventHandler<CSampleDataEventArgs> SampleDataReady = delegate { };
|
||||
|
||||
public double SampleRateKHz
|
||||
public double SampleRateKhz
|
||||
{
|
||||
get { return sampleRate; }
|
||||
get { return _SampleRate; }
|
||||
|
||||
set
|
||||
{
|
||||
sampleRate = value;
|
||||
_SampleRate = value;
|
||||
|
||||
if (running)
|
||||
if (_Running)
|
||||
Restart();
|
||||
}
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (running)
|
||||
if (_Running)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
if (captureDevice == null)
|
||||
captureDevice = new DirectSoundCapture(guid);
|
||||
if (_CaptureDevice == null)
|
||||
_CaptureDevice = new DirectSoundCapture(_Guid);
|
||||
|
||||
waveFormat.FormatTag = WaveFormatTag.Pcm; // Change to WaveFormatTag.IeeeFloat for float
|
||||
waveFormat.BitsPerSample = 16; // Set this to 32 for float
|
||||
waveFormat.BlockAlignment = (short)(channels * (waveFormat.BitsPerSample / 8));
|
||||
waveFormat.Channels = channels;
|
||||
waveFormat.SamplesPerSecond = (int)(SampleRateKHz * 1000D);
|
||||
waveFormat.AverageBytesPerSecond =
|
||||
waveFormat.SamplesPerSecond *
|
||||
waveFormat.BlockAlignment;
|
||||
_WaveFormat.FormatTag = WaveFormatTag.Pcm; // Change to WaveFormatTag.IeeeFloat for float
|
||||
_WaveFormat.BitsPerSample = 16; // Set this to 32 for float
|
||||
_WaveFormat.BlockAlignment = (short)(_Channels * (_WaveFormat.BitsPerSample / 8));
|
||||
_WaveFormat.Channels = _Channels;
|
||||
_WaveFormat.SamplesPerSecond = (int)(SampleRateKhz * 1000D);
|
||||
_WaveFormat.AverageBytesPerSecond =
|
||||
_WaveFormat.SamplesPerSecond *
|
||||
_WaveFormat.BlockAlignment;
|
||||
|
||||
bufferPortionCount = 2;
|
||||
_BufferPortionCount = 2;
|
||||
|
||||
bufferDescription.BufferBytes = bufferSize * sizeof(short) * bufferPortionCount * channels;
|
||||
bufferDescription.Format = waveFormat;
|
||||
bufferDescription.WaveMapped = false;
|
||||
_BufferDescription.BufferBytes = _BufferSize * sizeof(short) * _BufferPortionCount * _Channels;
|
||||
_BufferDescription.Format = _WaveFormat;
|
||||
_BufferDescription.WaveMapped = false;
|
||||
|
||||
buffer = new CaptureBuffer(captureDevice, bufferDescription);
|
||||
_CaptureBuffer = new CaptureBuffer(_CaptureDevice, _BufferDescription);
|
||||
|
||||
bufferPortionSize = buffer.SizeInBytes / bufferPortionCount;
|
||||
notifications = new List<NotificationPosition>();
|
||||
_BufferPortionSize = _CaptureBuffer.SizeInBytes / _BufferPortionCount;
|
||||
_Notifications = new List<NotificationPosition>();
|
||||
|
||||
for (int i = 0; i < bufferPortionCount; i++)
|
||||
for (int i = 0; i < _BufferPortionCount; i++)
|
||||
{
|
||||
NotificationPosition notification = new NotificationPosition();
|
||||
notification.Offset = bufferPortionCount - 1 + (bufferPortionSize * i);
|
||||
notification.Offset = _BufferPortionCount - 1 + (_BufferPortionSize * i);
|
||||
notification.Event = new AutoResetEvent(false);
|
||||
notifications.Add(notification);
|
||||
_Notifications.Add(notification);
|
||||
}
|
||||
|
||||
buffer.SetNotificationPositions(notifications.ToArray());
|
||||
waitHandles = new WaitHandle[notifications.Count];
|
||||
_CaptureBuffer.SetNotificationPositions(_Notifications.ToArray());
|
||||
_WaitHandles = new WaitHandle[_Notifications.Count];
|
||||
|
||||
for (int i = 0; i < notifications.Count; i++)
|
||||
waitHandles[i] = notifications[i].Event;
|
||||
for (int i = 0; i < _Notifications.Count; i++)
|
||||
_WaitHandles[i] = _Notifications[i].Event;
|
||||
|
||||
captureThread = new Thread(CaptureThread);
|
||||
captureThread.IsBackground = true;
|
||||
_CaptureThread = new Thread(_DoCapture);
|
||||
_CaptureThread.IsBackground = true;
|
||||
|
||||
running = true;
|
||||
captureThread.Start();
|
||||
_Running = true;
|
||||
_CaptureThread.Start();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
running = false;
|
||||
_Running = false;
|
||||
|
||||
if (captureThread != null)
|
||||
if (_CaptureThread != null)
|
||||
{
|
||||
captureThread.Join();
|
||||
captureThread = null;
|
||||
_CaptureThread.Join();
|
||||
_CaptureThread = null;
|
||||
}
|
||||
|
||||
if (buffer != null)
|
||||
if (_CaptureBuffer != null)
|
||||
{
|
||||
buffer.Dispose();
|
||||
buffer = null;
|
||||
_CaptureBuffer.Dispose();
|
||||
_CaptureBuffer = null;
|
||||
}
|
||||
|
||||
if (notifications != null)
|
||||
if (_Notifications != null)
|
||||
{
|
||||
for (int i = 0; i < notifications.Count; i++)
|
||||
notifications[i].Event.Close();
|
||||
for (int i = 0; i < _Notifications.Count; i++)
|
||||
_Notifications[i].Event.Close();
|
||||
|
||||
notifications.Clear();
|
||||
notifications = null;
|
||||
_Notifications.Clear();
|
||||
_Notifications = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,30 +368,30 @@ namespace Vocaluxe.Lib.Sound
|
||||
Start();
|
||||
}
|
||||
|
||||
private void CaptureThread()
|
||||
private void _DoCapture()
|
||||
{
|
||||
int bufferPortionSamples = bufferPortionSize / sizeof(byte);
|
||||
int bufferPortionSamples = _BufferPortionSize / sizeof(byte);
|
||||
|
||||
// Buffer type must match this.waveFormat.FormatTag and this.waveFormat.BitsPerSample
|
||||
byte[] bufferPortion = new byte[bufferPortionSamples];
|
||||
int bufferPortionIndex;
|
||||
|
||||
buffer.Start(true);
|
||||
_CaptureBuffer.Start(true);
|
||||
|
||||
while (running)
|
||||
while (_Running)
|
||||
{
|
||||
bufferPortionIndex = WaitHandle.WaitAny(waitHandles);
|
||||
bufferPortionIndex = WaitHandle.WaitAny(_WaitHandles);
|
||||
|
||||
buffer.Read(
|
||||
_CaptureBuffer.Read(
|
||||
bufferPortion,
|
||||
0,
|
||||
bufferPortionSamples,
|
||||
bufferPortionSize * Math.Abs((bufferPortionIndex - 1) % bufferPortionCount));
|
||||
_BufferPortionSize * Math.Abs((bufferPortionIndex - 1) % _BufferPortionCount));
|
||||
|
||||
SampleDataReady(this, new SampleDataEventArgs(bufferPortion, guid));
|
||||
SampleDataReady(this, new CSampleDataEventArgs(bufferPortion, _Guid));
|
||||
}
|
||||
|
||||
buffer.Stop();
|
||||
_CaptureBuffer.Stop();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -400,16 +400,18 @@ namespace Vocaluxe.Lib.Sound
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
protected virtual void Dispose(bool disposing)
|
||||
// ReSharper restore InconsistentNaming
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Stop();
|
||||
|
||||
if (captureDevice != null)
|
||||
if (_CaptureDevice != null)
|
||||
{
|
||||
captureDevice.Dispose();
|
||||
captureDevice = null;
|
||||
_CaptureDevice.Dispose();
|
||||
_CaptureDevice = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
#region log
|
||||
public CGstreamerAudioWrapper.LogCallback Log;
|
||||
|
||||
private void LogHandler(string text)
|
||||
private void _LogHandler(string text)
|
||||
{
|
||||
CLog.LogError(text);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
public CGstreamerAudio()
|
||||
{
|
||||
Init();
|
||||
Log = LogHandler;
|
||||
Log = _LogHandler;
|
||||
//Is this really needed? CodaAnalyzer complains about it...
|
||||
//GC.SuppressFinalize(Log);
|
||||
CGstreamerAudioWrapper.SetLogCallback(Log);
|
||||
@@ -30,9 +30,9 @@ namespace Vocaluxe.Lib.Sound
|
||||
return CGstreamerAudioWrapper.Init();
|
||||
}
|
||||
|
||||
public void SetGlobalVolume(float Volume)
|
||||
public void SetGlobalVolume(float volume)
|
||||
{
|
||||
CGstreamerAudioWrapper.SetGlobalVolume(Volume);
|
||||
CGstreamerAudioWrapper.SetGlobalVolume(volume);
|
||||
}
|
||||
|
||||
public int GetStreamCount()
|
||||
@@ -45,98 +45,98 @@ namespace Vocaluxe.Lib.Sound
|
||||
CGstreamerAudioWrapper.CloseAll();
|
||||
}
|
||||
|
||||
public int Load(string Media)
|
||||
public int Load(string media)
|
||||
{
|
||||
Uri u = new Uri(Media);
|
||||
Uri u = new Uri(media);
|
||||
int i = CGstreamerAudioWrapper.Load(u.AbsoluteUri);
|
||||
return i;
|
||||
}
|
||||
|
||||
public int Load(string Media, bool Prescan)
|
||||
public int Load(string media, bool prescan)
|
||||
{
|
||||
Uri u = new Uri(Media);
|
||||
int i = CGstreamerAudioWrapper.Load(u.AbsoluteUri, Prescan);
|
||||
Uri u = new Uri(media);
|
||||
int i = CGstreamerAudioWrapper.Load(u.AbsoluteUri, prescan);
|
||||
return i;
|
||||
}
|
||||
|
||||
public void Close(int Stream)
|
||||
public void Close(int stream)
|
||||
{
|
||||
CGstreamerAudioWrapper.Close(Stream);
|
||||
CGstreamerAudioWrapper.Close(stream);
|
||||
}
|
||||
|
||||
public void Play(int Stream)
|
||||
public void Play(int stream)
|
||||
{
|
||||
CGstreamerAudioWrapper.Play(Stream);
|
||||
CGstreamerAudioWrapper.Play(stream);
|
||||
}
|
||||
|
||||
public void Play(int Stream, bool Loop)
|
||||
public void Play(int stream, bool loop)
|
||||
{
|
||||
CGstreamerAudioWrapper.Play(Stream, Loop);
|
||||
CGstreamerAudioWrapper.Play(stream, loop);
|
||||
}
|
||||
|
||||
public void Pause(int Stream)
|
||||
public void Pause(int stream)
|
||||
{
|
||||
CGstreamerAudioWrapper.Pause(Stream);
|
||||
CGstreamerAudioWrapper.Pause(stream);
|
||||
}
|
||||
|
||||
public void Stop(int Stream)
|
||||
public void Stop(int stream)
|
||||
{
|
||||
CGstreamerAudioWrapper.Stop(Stream);
|
||||
CGstreamerAudioWrapper.Stop(stream);
|
||||
}
|
||||
|
||||
public void Fade(int Stream, float TargetVolume, float Seconds)
|
||||
public void Fade(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
CGstreamerAudioWrapper.Fade(Stream, TargetVolume, Seconds);
|
||||
CGstreamerAudioWrapper.Fade(stream, targetVolume, seconds);
|
||||
}
|
||||
|
||||
public void FadeAndPause(int Stream, float TargetVolume, float Seconds)
|
||||
public void FadeAndPause(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
CGstreamerAudioWrapper.FadeAndPause(Stream, TargetVolume, Seconds);
|
||||
CGstreamerAudioWrapper.FadeAndPause(stream, targetVolume, seconds);
|
||||
}
|
||||
|
||||
public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
|
||||
public void FadeAndStop(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
CGstreamerAudioWrapper.FadeAndStop(Stream, TargetVolume, Seconds);
|
||||
CGstreamerAudioWrapper.FadeAndStop(stream, targetVolume, seconds);
|
||||
}
|
||||
|
||||
public void SetStreamVolume(int Stream, float Volume)
|
||||
public void SetStreamVolume(int stream, float volume)
|
||||
{
|
||||
CGstreamerAudioWrapper.SetStreamVolume(Stream, Volume);
|
||||
CGstreamerAudioWrapper.SetStreamVolume(stream, volume);
|
||||
}
|
||||
|
||||
public void SetStreamVolumeMax(int Stream, float Volume)
|
||||
public void SetStreamVolumeMax(int stream, float volume)
|
||||
{
|
||||
CGstreamerAudioWrapper.SetStreamVolumeMax(Stream, Volume);
|
||||
CGstreamerAudioWrapper.SetStreamVolumeMax(stream, volume);
|
||||
}
|
||||
|
||||
public float GetLength(int Stream)
|
||||
public float GetLength(int stream)
|
||||
{
|
||||
return CGstreamerAudioWrapper.GetLength(Stream);
|
||||
return CGstreamerAudioWrapper.GetLength(stream);
|
||||
}
|
||||
|
||||
public float GetPosition(int Stream)
|
||||
public float GetPosition(int stream)
|
||||
{
|
||||
return CGstreamerAudioWrapper.GetPosition(Stream);
|
||||
return CGstreamerAudioWrapper.GetPosition(stream);
|
||||
}
|
||||
|
||||
public bool IsPlaying(int Stream)
|
||||
public bool IsPlaying(int stream)
|
||||
{
|
||||
return CGstreamerAudioWrapper.IsPlaying(Stream);
|
||||
return CGstreamerAudioWrapper.IsPlaying(stream);
|
||||
}
|
||||
|
||||
public bool IsPaused(int Stream)
|
||||
public bool IsPaused(int stream)
|
||||
{
|
||||
return CGstreamerAudioWrapper.IsPaused(Stream);
|
||||
return CGstreamerAudioWrapper.IsPaused(stream);
|
||||
}
|
||||
|
||||
public bool IsFinished(int Stream)
|
||||
public bool IsFinished(int stream)
|
||||
{
|
||||
return CGstreamerAudioWrapper.IsFinished(Stream);
|
||||
return CGstreamerAudioWrapper.IsFinished(stream);
|
||||
}
|
||||
|
||||
public void SetPosition(int Stream, float Position)
|
||||
public void SetPosition(int stream, float position)
|
||||
{
|
||||
CGstreamerAudioWrapper.SetPosition(Stream, Position);
|
||||
CGstreamerAudioWrapper.SetPosition(stream, position);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
|
||||
+255
-256
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -9,12 +9,12 @@ namespace Vocaluxe.Lib.Sound
|
||||
{
|
||||
class CPortAudioRecord : IRecord
|
||||
{
|
||||
private bool _initialized;
|
||||
private bool _Initialized;
|
||||
private List<SRecordDevice> _Devices;
|
||||
private SRecordDevice[] _DeviceConfig;
|
||||
|
||||
private PortAudio.PaStreamCallbackDelegate _myRecProc;
|
||||
private IntPtr[] _recHandle;
|
||||
private CPortAudio.PaStreamCallbackDelegate _MyRecProc;
|
||||
private IntPtr[] _RecHandle;
|
||||
|
||||
private readonly CBuffer[] _Buffer;
|
||||
|
||||
@@ -39,32 +39,32 @@ namespace Vocaluxe.Lib.Sound
|
||||
|
||||
try
|
||||
{
|
||||
if (_initialized)
|
||||
if (_Initialized)
|
||||
CloseAll();
|
||||
|
||||
if (errorCheck("Initialize", PortAudio.Pa_Initialize()))
|
||||
if (_ErrorCheck("Initialize", CPortAudio.Pa_Initialize()))
|
||||
return false;
|
||||
|
||||
_initialized = true;
|
||||
int hostAPI = apiSelect();
|
||||
_Initialized = true;
|
||||
int hostAPI = _ApiSelect();
|
||||
|
||||
int numDevices = PortAudio.Pa_GetDeviceCount();
|
||||
int numDevices = CPortAudio.Pa_GetDeviceCount();
|
||||
for (int i = 0; i < numDevices; i++)
|
||||
{
|
||||
PortAudio.PaDeviceInfo info = PortAudio.Pa_GetDeviceInfo(i);
|
||||
if (info.hostApi == hostAPI && info.maxInputChannels > 0)
|
||||
CPortAudio.SPaDeviceInfo info = CPortAudio.PaGetDeviceInfo(i);
|
||||
if (info.HostApi == hostAPI && info.MaxInputChannels > 0)
|
||||
{
|
||||
SRecordDevice dev = new SRecordDevice();
|
||||
|
||||
dev.ID = i;
|
||||
dev.Name = info.name;
|
||||
dev.Driver = info.name + i.ToString();
|
||||
dev.Name = info.Name;
|
||||
dev.Driver = info.Name + i.ToString();
|
||||
dev.Inputs = new List<SInput>();
|
||||
|
||||
SInput inp = new SInput();
|
||||
inp.Name = "Default";
|
||||
|
||||
inp.Channels = info.maxInputChannels;
|
||||
inp.Channels = info.MaxInputChannels;
|
||||
if (inp.Channels > 2)
|
||||
inp.Channels = 2; //more are not supported in vocaluxe
|
||||
|
||||
@@ -73,14 +73,14 @@ namespace Vocaluxe.Lib.Sound
|
||||
}
|
||||
}
|
||||
|
||||
_recHandle = new IntPtr[_Devices.Count];
|
||||
_myRecProc = myPaStreamCallback;
|
||||
_RecHandle = new IntPtr[_Devices.Count];
|
||||
_MyRecProc = MyPaStreamCallback;
|
||||
|
||||
_DeviceConfig = _Devices.ToArray();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_initialized = false;
|
||||
_Initialized = false;
|
||||
CLog.LogError("Error initializing PortAudio: " + e.Message);
|
||||
return false;
|
||||
}
|
||||
@@ -91,74 +91,74 @@ namespace Vocaluxe.Lib.Sound
|
||||
/// <summary>
|
||||
/// Start Voice Capturing
|
||||
/// </summary>
|
||||
/// <param name="DeviceConfig"></param>
|
||||
/// <param name="deviceConfig"></param>
|
||||
/// <returns></returns>
|
||||
public bool Start(SRecordDevice[] DeviceConfig)
|
||||
public bool Start(SRecordDevice[] deviceConfig)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return false;
|
||||
|
||||
if (DeviceConfig == null)
|
||||
if (deviceConfig == null)
|
||||
return false;
|
||||
|
||||
if (_recHandle == null)
|
||||
if (_RecHandle == null)
|
||||
return false;
|
||||
|
||||
if (_recHandle.Length == 0)
|
||||
if (_RecHandle.Length == 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < _Buffer.Length; i++)
|
||||
_Buffer[i].Reset();
|
||||
|
||||
for (int i = 0; i < _recHandle.Length; i++)
|
||||
for (int i = 0; i < _RecHandle.Length; i++)
|
||||
{
|
||||
int waitcount = 0;
|
||||
while (waitcount < 5 && PortAudio.Pa_IsStreamStopped(_recHandle[i]) == PortAudio.PaError.paStreamIsNotStopped)
|
||||
while (waitcount < 5 && CPortAudio.Pa_IsStreamStopped(_RecHandle[i]) == CPortAudio.EPaError.PaStreamIsNotStopped)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
waitcount++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _recHandle.Length; i++)
|
||||
_recHandle[i] = IntPtr.Zero;
|
||||
for (int i = 0; i < _RecHandle.Length; i++)
|
||||
_RecHandle[i] = IntPtr.Zero;
|
||||
|
||||
_DeviceConfig = DeviceConfig;
|
||||
bool[] active = new bool[DeviceConfig.Length];
|
||||
for (int dev = 0; dev < DeviceConfig.Length; dev++)
|
||||
_DeviceConfig = deviceConfig;
|
||||
bool[] active = new bool[deviceConfig.Length];
|
||||
for (int dev = 0; dev < deviceConfig.Length; dev++)
|
||||
{
|
||||
active[dev] = false;
|
||||
for (int inp = 0; inp < DeviceConfig[dev].Inputs.Count; inp++)
|
||||
for (int inp = 0; inp < deviceConfig[dev].Inputs.Count; inp++)
|
||||
{
|
||||
if (DeviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 ||
|
||||
DeviceConfig[dev].Inputs[inp].PlayerChannel2 > 0)
|
||||
if (deviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 ||
|
||||
deviceConfig[dev].Inputs[inp].PlayerChannel2 > 0)
|
||||
active[dev] = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
for (int i = 0; i < _recHandle.Length; i++)
|
||||
for (int i = 0; i < _RecHandle.Length; i++)
|
||||
{
|
||||
if (active[i])
|
||||
{
|
||||
PortAudio.PaStreamParameters inputParams = new PortAudio.PaStreamParameters();
|
||||
inputParams.channelCount = _DeviceConfig[i].Inputs[0].Channels;
|
||||
inputParams.device = _DeviceConfig[i].ID;
|
||||
inputParams.sampleFormat = PortAudio.PaSampleFormat.paInt16;
|
||||
inputParams.suggestedLatency = PortAudio.Pa_GetDeviceInfo(_DeviceConfig[i].ID).defaultLowInputLatency;
|
||||
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;
|
||||
|
||||
if (errorCheck("OpenStream (rec)", PortAudio.Pa_OpenStream(
|
||||
out _recHandle[i],
|
||||
if (_ErrorCheck("OpenStream (rec)", CPortAudio.Pa_OpenStream(
|
||||
out _RecHandle[i],
|
||||
ref inputParams,
|
||||
IntPtr.Zero,
|
||||
44100,
|
||||
882,
|
||||
PortAudio.PaStreamFlags.paNoFlag,
|
||||
_myRecProc,
|
||||
CPortAudio.EPaStreamFlags.PaNoFlag,
|
||||
_MyRecProc,
|
||||
new IntPtr(i))))
|
||||
return false;
|
||||
|
||||
if (errorCheck("Start Stream (rec)", PortAudio.Pa_StartStream(_recHandle[i])))
|
||||
if (_ErrorCheck("Start Stream (rec)", CPortAudio.Pa_StartStream(_RecHandle[i])))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -171,11 +171,11 @@ namespace Vocaluxe.Lib.Sound
|
||||
/// <returns></returns>
|
||||
public bool Stop()
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < _recHandle.Length; i++)
|
||||
PortAudio.Pa_StopStream(_recHandle[i]);
|
||||
for (int i = 0; i < _RecHandle.Length; i++)
|
||||
CPortAudio.Pa_StopStream(_RecHandle[i]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -186,10 +186,10 @@ namespace Vocaluxe.Lib.Sound
|
||||
{
|
||||
Stop();
|
||||
|
||||
if (_initialized)
|
||||
if (_Initialized)
|
||||
{
|
||||
PortAudio.Pa_Terminate();
|
||||
_initialized = false;
|
||||
CPortAudio.Pa_Terminate();
|
||||
_Initialized = false;
|
||||
}
|
||||
|
||||
//System.IO.File.WriteAllBytes("test0.raw", _Buffer[0].Buffer);
|
||||
@@ -198,74 +198,74 @@ namespace Vocaluxe.Lib.Sound
|
||||
/// <summary>
|
||||
/// Detect Pitch and Volume of the newest voice buffer
|
||||
/// </summary>
|
||||
/// <param name="Player"></param>
|
||||
public void AnalyzeBuffer(int Player)
|
||||
/// <param name="player"></param>
|
||||
public void AnalyzeBuffer(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return;
|
||||
|
||||
_Buffer[Player].AnalyzeBuffer();
|
||||
_Buffer[player].AnalyzeBuffer();
|
||||
}
|
||||
|
||||
public int GetToneAbs(int Player)
|
||||
public int GetToneAbs(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return 0;
|
||||
|
||||
return _Buffer[Player].ToneAbs;
|
||||
return _Buffer[player].ToneAbs;
|
||||
}
|
||||
|
||||
public int GetTone(int Player)
|
||||
public int GetTone(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return 0;
|
||||
|
||||
return _Buffer[Player].Tone;
|
||||
return _Buffer[player].Tone;
|
||||
}
|
||||
|
||||
public void SetTone(int Player, int Tone)
|
||||
public void SetTone(int player, int tone)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return;
|
||||
|
||||
_Buffer[Player].Tone = Tone;
|
||||
_Buffer[player].Tone = tone;
|
||||
}
|
||||
|
||||
public float GetMaxVolume(int Player)
|
||||
public float GetMaxVolume(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return 0f;
|
||||
|
||||
return _Buffer[Player].MaxVolume;
|
||||
return _Buffer[player].MaxVolume;
|
||||
}
|
||||
|
||||
public bool ToneValid(int Player)
|
||||
public bool ToneValid(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return false;
|
||||
|
||||
return _Buffer[Player].ToneValid;
|
||||
return _Buffer[player].ToneValid;
|
||||
}
|
||||
|
||||
public int NumHalfTones(int Player)
|
||||
public int NumHalfTones(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return 0;
|
||||
|
||||
return _Buffer[Player].NumHalfTones;
|
||||
return _Buffer[player].NumHalfTones;
|
||||
}
|
||||
|
||||
public float[] ToneWeigth(int Player)
|
||||
public float[] ToneWeigth(int player)
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return null;
|
||||
|
||||
return _Buffer[Player].ToneWeigth;
|
||||
return _Buffer[player].ToneWeigth;
|
||||
}
|
||||
|
||||
public SRecordDevice[] RecordDevices()
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return null;
|
||||
|
||||
if (_Devices.Count == 0)
|
||||
@@ -274,12 +274,12 @@ namespace Vocaluxe.Lib.Sound
|
||||
return _Devices.ToArray();
|
||||
}
|
||||
|
||||
public PortAudio.PaStreamCallbackResult myPaStreamCallback(
|
||||
public CPortAudio.EPaStreamCallbackResult MyPaStreamCallback(
|
||||
IntPtr input,
|
||||
IntPtr output,
|
||||
uint frameCount,
|
||||
ref PortAudio.PaStreamCallbackTimeInfo timeInfo,
|
||||
PortAudio.PaStreamCallbackFlags statusFlags,
|
||||
ref CPortAudio.SPaStreamCallbackTimeInfo timeInfo,
|
||||
CPortAudio.EPaStreamCallbackFlags statusFlags,
|
||||
IntPtr userData)
|
||||
{
|
||||
try
|
||||
@@ -287,29 +287,29 @@ namespace Vocaluxe.Lib.Sound
|
||||
frameCount *= 4;
|
||||
if (frameCount > 0 && input != IntPtr.Zero)
|
||||
{
|
||||
byte[] _recbuffer = new byte[frameCount];
|
||||
byte[] _leftBuffer = new byte[frameCount / 2];
|
||||
byte[] _rightBuffer = new byte[frameCount / 2];
|
||||
byte[] recbuffer = new byte[frameCount];
|
||||
byte[] leftBuffer = new byte[frameCount / 2];
|
||||
byte[] rightBuffer = new byte[frameCount / 2];
|
||||
|
||||
// copy from managed to unmanaged memory
|
||||
Marshal.Copy(input, _recbuffer, 0, (int)frameCount);
|
||||
Marshal.Copy(input, recbuffer, 0, (int)frameCount);
|
||||
|
||||
// copy into left/right Buffer
|
||||
for (int i = 0; i < frameCount / 2; i++)
|
||||
{
|
||||
_leftBuffer[i] = _recbuffer[i * 2 - (i % 2)];
|
||||
_rightBuffer[i] = _recbuffer[i * 2 - (i % 2) + 2];
|
||||
leftBuffer[i] = recbuffer[i * 2 - (i % 2)];
|
||||
rightBuffer[i] = recbuffer[i * 2 - (i % 2) + 2];
|
||||
}
|
||||
|
||||
for (int i = 0; i < _recHandle.Length; i++)
|
||||
for (int i = 0; i < _RecHandle.Length; i++)
|
||||
{
|
||||
if (new IntPtr(i) == userData)
|
||||
{
|
||||
if (_DeviceConfig[i].Inputs[0].PlayerChannel1 > 0)
|
||||
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel1 - 1].ProcessNewBuffer(_leftBuffer);
|
||||
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer);
|
||||
|
||||
if (_DeviceConfig[i].Inputs[0].PlayerChannel2 > 0)
|
||||
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel2 - 1].ProcessNewBuffer(_rightBuffer);
|
||||
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -321,20 +321,20 @@ namespace Vocaluxe.Lib.Sound
|
||||
CLog.LogError("Error on Stream Callback (rec): " + e);
|
||||
}
|
||||
|
||||
return PortAudio.PaStreamCallbackResult.paContinue;
|
||||
return CPortAudio.EPaStreamCallbackResult.PaContinue;
|
||||
}
|
||||
|
||||
private bool errorCheck(String action, PortAudio.PaError errorCode)
|
||||
private bool _ErrorCheck(String action, CPortAudio.EPaError errorCode)
|
||||
{
|
||||
if (errorCode != PortAudio.PaError.paNoError)
|
||||
if (errorCode != CPortAudio.EPaError.PaNoError)
|
||||
{
|
||||
CLog.LogError(action + " error (rec): " + PortAudio.Pa_GetErrorText(errorCode));
|
||||
if (errorCode == PortAudio.PaError.paUnanticipatedHostError)
|
||||
CLog.LogError(action + " error (rec): " + CPortAudio.PaGetErrorText(errorCode));
|
||||
if (errorCode == CPortAudio.EPaError.PaUnanticipatedHostError)
|
||||
{
|
||||
PortAudio.PaHostErrorInfo errorInfo = PortAudio.Pa_GetLastHostErrorInfo();
|
||||
CLog.LogError("- Host error API type: " + errorInfo.hostApiType);
|
||||
CLog.LogError("- Host error code: " + errorInfo.errorCode);
|
||||
CLog.LogError("- Host error text: " + errorInfo.errorText);
|
||||
CPortAudio.SPaHostErrorInfo errorInfo = CPortAudio.PaGetLastHostErrorInfo();
|
||||
CLog.LogError("- Host error API type: " + errorInfo.HostApiType);
|
||||
CLog.LogError("- Host error code: " + errorInfo.ErrorCode);
|
||||
CLog.LogError("- Host error text: " + errorInfo.ErrorText);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -342,18 +342,18 @@ namespace Vocaluxe.Lib.Sound
|
||||
return false;
|
||||
}
|
||||
|
||||
private int apiSelect()
|
||||
private int _ApiSelect()
|
||||
{
|
||||
if (!_initialized)
|
||||
if (!_Initialized)
|
||||
return 0;
|
||||
|
||||
int selectedHostApi = PortAudio.Pa_GetDefaultHostApi();
|
||||
int apiCount = PortAudio.Pa_GetHostApiCount();
|
||||
int selectedHostApi = CPortAudio.Pa_GetDefaultHostApi();
|
||||
int apiCount = CPortAudio.Pa_GetHostApiCount();
|
||||
for (int i = 0; i < apiCount; i++)
|
||||
{
|
||||
PortAudio.PaHostApiInfo apiInfo = PortAudio.Pa_GetHostApiInfo(i);
|
||||
if ((apiInfo.type == PortAudio.PaHostApiTypeId.paDirectSound)
|
||||
|| (apiInfo.type == PortAudio.PaHostApiTypeId.paALSA))
|
||||
CPortAudio.SPaHostApiInfo apiInfo = CPortAudio.PaGetHostApiInfo(i);
|
||||
if ((apiInfo.Type == CPortAudio.EPaHostApiTypeId.PaDirectSound)
|
||||
|| (apiInfo.Type == CPortAudio.EPaHostApiTypeId.PaALSA))
|
||||
selectedHostApi = i;
|
||||
}
|
||||
return selectedHostApi;
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
|
||||
public virtual void Close() {}
|
||||
|
||||
public void Open(string FileName)
|
||||
public void Open(string fileName)
|
||||
{
|
||||
Open(FileName, false);
|
||||
Open(fileName, false);
|
||||
}
|
||||
|
||||
public virtual void Open(string FileName, bool Loop) {}
|
||||
public virtual void Open(string fileName, bool loop) {}
|
||||
|
||||
public virtual FormatInfo GetFormatInfo()
|
||||
public virtual SFormatInfo GetFormatInfo()
|
||||
{
|
||||
return new FormatInfo();
|
||||
return new SFormatInfo();
|
||||
}
|
||||
|
||||
public virtual float GetLength()
|
||||
@@ -25,17 +25,17 @@
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public virtual void SetPosition(float Time) {}
|
||||
public virtual void SetPosition(float time) {}
|
||||
|
||||
public virtual float GetPosition()
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public virtual void Decode(out byte[] Buffer, out float TimeStamp)
|
||||
public virtual void Decode(out byte[] buffer, out float timeStamp)
|
||||
{
|
||||
Buffer = null;
|
||||
TimeStamp = 0f;
|
||||
buffer = null;
|
||||
timeStamp = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,11 @@ namespace Vocaluxe.Lib.Sound.Decoder
|
||||
{
|
||||
class CAudioDecoderFFmpeg : CAudioDecoder, IDisposable
|
||||
{
|
||||
private IntPtr _instance = IntPtr.Zero;
|
||||
private IntPtr _audiodecoder = IntPtr.Zero;
|
||||
private IntPtr _InstancePtr = IntPtr.Zero;
|
||||
private IntPtr _Audiodecoder = IntPtr.Zero;
|
||||
|
||||
private TAc_instance _Instance;
|
||||
private FormatInfo _FormatInfo;
|
||||
private SACInstance _Instance;
|
||||
private SFormatInfo _FormatInfo;
|
||||
private float _CurrentTime;
|
||||
|
||||
private string _FileName;
|
||||
@@ -24,18 +24,18 @@ namespace Vocaluxe.Lib.Sound.Decoder
|
||||
_Initialized = true;
|
||||
}
|
||||
|
||||
public override void Open(string FileName, bool Loop)
|
||||
public override void Open(string fileName, bool loop)
|
||||
{
|
||||
if (!_Initialized)
|
||||
return;
|
||||
|
||||
_FileName = FileName;
|
||||
_FileName = fileName;
|
||||
|
||||
try
|
||||
{
|
||||
_instance = CAcinerella.ac_init();
|
||||
CAcinerella.ac_open2(_instance, _FileName);
|
||||
_Instance = (TAc_instance)Marshal.PtrToStructure(_instance, typeof(TAc_instance));
|
||||
_InstancePtr = CAcinerella.AcInit();
|
||||
CAcinerella.AcOpen2(_InstancePtr, _FileName);
|
||||
_Instance = (SACInstance)Marshal.PtrToStructure(_InstancePtr, typeof(SACInstance));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -44,19 +44,19 @@ namespace Vocaluxe.Lib.Sound.Decoder
|
||||
}
|
||||
|
||||
|
||||
if (!_Instance.opened)
|
||||
if (!_Instance.Opened)
|
||||
{
|
||||
//Free();
|
||||
return;
|
||||
}
|
||||
|
||||
int AudioStreamIndex = -1;
|
||||
TAc_decoder Audiodecoder;
|
||||
int audioStreamIndex = -1;
|
||||
SACDecoder audiodecoder;
|
||||
try
|
||||
{
|
||||
_audiodecoder = CAcinerella.ac_create_audio_decoder(_instance);
|
||||
Audiodecoder = (TAc_decoder)Marshal.PtrToStructure(_audiodecoder, typeof(TAc_decoder));
|
||||
AudioStreamIndex = Audiodecoder.stream_index;
|
||||
_Audiodecoder = CAcinerella.AcCreateAudioDecoder(_InstancePtr);
|
||||
audiodecoder = (SACDecoder)Marshal.PtrToStructure(_Audiodecoder, typeof(SACDecoder));
|
||||
audioStreamIndex = audiodecoder.StreamIndex;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -64,23 +64,23 @@ namespace Vocaluxe.Lib.Sound.Decoder
|
||||
return;
|
||||
}
|
||||
|
||||
if (AudioStreamIndex < 0)
|
||||
if (audioStreamIndex < 0)
|
||||
{
|
||||
//Free();
|
||||
return;
|
||||
}
|
||||
|
||||
_FormatInfo = new FormatInfo();
|
||||
_FormatInfo = new SFormatInfo();
|
||||
|
||||
_FormatInfo.SamplesPerSecond = Audiodecoder.stream_info.audio_info.samples_per_second;
|
||||
_FormatInfo.BitDepth = Audiodecoder.stream_info.audio_info.bit_depth;
|
||||
_FormatInfo.ChannelCount = Audiodecoder.stream_info.audio_info.channel_count;
|
||||
_FormatInfo.SamplesPerSecond = audiodecoder.StreamInfo.AudioInfo.SamplesPerSecond;
|
||||
_FormatInfo.BitDepth = audiodecoder.StreamInfo.AudioInfo.BitDepth;
|
||||
_FormatInfo.ChannelCount = audiodecoder.StreamInfo.AudioInfo.ChannelCount;
|
||||
|
||||
_CurrentTime = 0f;
|
||||
|
||||
if (_FormatInfo.BitDepth != 16)
|
||||
{
|
||||
CLog.LogError("Unsupported BitDepth in file " + FileName);
|
||||
CLog.LogError("Unsupported BitDepth in file " + fileName);
|
||||
return;
|
||||
}
|
||||
_FileOpened = true;
|
||||
@@ -96,22 +96,22 @@ namespace Vocaluxe.Lib.Sound.Decoder
|
||||
if (!_FileOpened)
|
||||
return;
|
||||
|
||||
if (_audiodecoder != IntPtr.Zero)
|
||||
CAcinerella.ac_free_decoder(_audiodecoder);
|
||||
if (_Audiodecoder != IntPtr.Zero)
|
||||
CAcinerella.AcFreeDecoder(_Audiodecoder);
|
||||
|
||||
if (_instance != IntPtr.Zero)
|
||||
CAcinerella.ac_close(_instance);
|
||||
if (_InstancePtr != IntPtr.Zero)
|
||||
CAcinerella.AcClose(_InstancePtr);
|
||||
|
||||
if (_instance != IntPtr.Zero)
|
||||
CAcinerella.ac_free(_instance);
|
||||
if (_InstancePtr != IntPtr.Zero)
|
||||
CAcinerella.AcFree(_InstancePtr);
|
||||
|
||||
_FileOpened = false;
|
||||
}
|
||||
|
||||
public override FormatInfo GetFormatInfo()
|
||||
public override SFormatInfo GetFormatInfo()
|
||||
{
|
||||
if (!_Initialized && !_FileOpened)
|
||||
return new FormatInfo();
|
||||
return new SFormatInfo();
|
||||
|
||||
return _FormatInfo;
|
||||
}
|
||||
@@ -121,17 +121,17 @@ namespace Vocaluxe.Lib.Sound.Decoder
|
||||
if (!_Initialized && !_FileOpened)
|
||||
return 0f;
|
||||
|
||||
return _Instance.info.duration / 1000f;
|
||||
return _Instance.Info.Duration / 1000f;
|
||||
}
|
||||
|
||||
public override void SetPosition(float Time)
|
||||
public override void SetPosition(float time)
|
||||
{
|
||||
if (!_Initialized && !_FileOpened)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
CAcinerella.ac_seek(_audiodecoder, 0, (Int64)(Time * 1000f));
|
||||
CAcinerella.AcSeek(_Audiodecoder, 0, (Int64)(time * 1000f));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -148,42 +148,42 @@ namespace Vocaluxe.Lib.Sound.Decoder
|
||||
return _CurrentTime;
|
||||
}
|
||||
|
||||
public override void Decode(out byte[] Buffer, out float TimeStamp)
|
||||
public override void Decode(out byte[] buffer, out float timeStamp)
|
||||
{
|
||||
if (!_Initialized && !_FileOpened)
|
||||
{
|
||||
Buffer = null;
|
||||
TimeStamp = 0f;
|
||||
buffer = null;
|
||||
timeStamp = 0f;
|
||||
return;
|
||||
}
|
||||
|
||||
int FrameFinished = 0;
|
||||
int frameFinished = 0;
|
||||
try
|
||||
{
|
||||
FrameFinished = CAcinerella.ac_get_audio_frame(_instance, _audiodecoder);
|
||||
frameFinished = CAcinerella.AcGetAudioFrame(_InstancePtr, _Audiodecoder);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
FrameFinished = 0;
|
||||
frameFinished = 0;
|
||||
}
|
||||
|
||||
if (FrameFinished == 1)
|
||||
if (frameFinished == 1)
|
||||
{
|
||||
TAc_decoder Decoder = (TAc_decoder)Marshal.PtrToStructure(_audiodecoder, typeof(TAc_decoder));
|
||||
SACDecoder decoder = (SACDecoder)Marshal.PtrToStructure(_Audiodecoder, typeof(SACDecoder));
|
||||
|
||||
TimeStamp = (float)Decoder.timecode;
|
||||
_CurrentTime = TimeStamp;
|
||||
//Console.WriteLine(_CurrentTime.ToString("#0.000") + " Buffer size: " + Decoder.buffer_size.ToString());
|
||||
Buffer = new byte[Decoder.buffer_size];
|
||||
timeStamp = (float)decoder.Timecode;
|
||||
_CurrentTime = timeStamp;
|
||||
//Console.WriteLine(_CurrentTime.ToString("ReplacedStr:::0:::") + "ReplacedStr:::1:::" + Decoder.buffer_size.ToString());
|
||||
buffer = new byte[decoder.BufferSize];
|
||||
|
||||
if (Decoder.buffer_size > 0)
|
||||
Marshal.Copy(Decoder.buffer, Buffer, 0, Buffer.Length);
|
||||
if (decoder.BufferSize > 0)
|
||||
Marshal.Copy(decoder.Buffer, buffer, 0, buffer.Length);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Buffer = null;
|
||||
TimeStamp = 0f;
|
||||
buffer = null;
|
||||
timeStamp = 0f;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Vocaluxe.Lib.Sound.Decoder
|
||||
{
|
||||
struct FormatInfo
|
||||
struct SFormatInfo
|
||||
{
|
||||
public int ChannelCount;
|
||||
public int SamplesPerSecond;
|
||||
@@ -12,15 +12,15 @@
|
||||
void Init();
|
||||
void Close();
|
||||
|
||||
void Open(string FileName);
|
||||
void Open(string FileName, bool Loop);
|
||||
FormatInfo GetFormatInfo();
|
||||
void Open(string fileName);
|
||||
void Open(string fileName, bool loop);
|
||||
SFormatInfo GetFormatInfo();
|
||||
|
||||
float GetLength();
|
||||
|
||||
void SetPosition(float Time);
|
||||
void SetPosition(float time);
|
||||
float GetPosition();
|
||||
|
||||
void Decode(out byte[] Buffer, out float TimeStamp);
|
||||
void Decode(out byte[] buffer, out float timeStamp);
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,13 @@ namespace Vocaluxe.Lib.Sound.Gstreamer
|
||||
#region arch
|
||||
#if ARCH_X86
|
||||
#if WIN
|
||||
private const string Dll = "x86\\gstreamer\\gstreamerhelper.dll";
|
||||
private const string _Dll = "x86\\gstreamer\\gstreamerhelper.dll";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ARCH_X64
|
||||
#if WIN
|
||||
private const string Dll = "x64\\gstreamer\\gstreamerhelper.dll";
|
||||
private const string _Dll = "x64\\gstreamer\\gstreamerhelper.dll";
|
||||
#endif
|
||||
#endif
|
||||
#endregion arch
|
||||
@@ -21,82 +21,82 @@ 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)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool Init();
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetGlobalVolume(float Volume);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetGlobalVolume(float volume);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GetStreamCount();
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void CloseAll();
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Load(string Media);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Load(string media);
|
||||
|
||||
[DllImport(Dll, EntryPoint = "LoadPrescan", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Load(string Media,
|
||||
[MarshalAs(UnmanagedType.U1)] bool Prescan);
|
||||
[DllImport(_Dll, EntryPoint = "LoadPrescan", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Load(string media,
|
||||
[MarshalAs(UnmanagedType.U1)] bool prescan);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Close(int Stream);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Close(int stream);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Play(int Stream);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Play(int stream);
|
||||
|
||||
[DllImport(Dll, EntryPoint = "PlayLoop")]
|
||||
public static extern void Play(int Stream,
|
||||
[MarshalAs(UnmanagedType.U1)] bool Loop);
|
||||
[DllImport(_Dll, EntryPoint = "PlayLoop")]
|
||||
public static extern void Play(int stream,
|
||||
[MarshalAs(UnmanagedType.U1)] bool loop);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Pause(int Stream);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Pause(int stream);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Stop(int Stream);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Stop(int stream);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Fade(int Stream, float TargetVolume, float Seconds);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Fade(int stream, float targetVolume, float seconds);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void FadeAndPause(int Stream, float TargetVolume, float Seconds);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void FadeAndPause(int stream, float targetVolume, float seconds);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void FadeAndStop(int Stream, float TargetVolume, float Seconds);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void FadeAndStop(int stream, float targetVolume, float seconds);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetStreamVolume(int Stream, float Volume);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetStreamVolume(int stream, float volume);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetStreamVolumeMax(int Stream, float Volume);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetStreamVolumeMax(int stream, float volume);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float GetLength(int Stream);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float GetLength(int stream);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float GetPosition(int Stream);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float GetPosition(int stream);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool IsPlaying(int Stream);
|
||||
public static extern bool IsPlaying(int stream);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool IsPaused(int Stream);
|
||||
public static extern bool IsPaused(int stream);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool IsFinished(int Stream);
|
||||
public static extern bool IsFinished(int stream);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetPosition(int Stream, float Position);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetPosition(int stream, float position);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Update();
|
||||
}
|
||||
}
|
||||
@@ -2,104 +2,104 @@
|
||||
|
||||
namespace Vocaluxe.Lib.Sound
|
||||
{
|
||||
struct AudioStreams
|
||||
struct SAudioStreams
|
||||
{
|
||||
public int handle;
|
||||
public string file;
|
||||
public int Handle;
|
||||
public string File;
|
||||
|
||||
public AudioStreams(int stream)
|
||||
public SAudioStreams(int stream)
|
||||
{
|
||||
handle = stream;
|
||||
file = String.Empty;
|
||||
Handle = stream;
|
||||
File = String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
delegate void CLOSEPROC(int StreamID);
|
||||
delegate void Closeproc(int streamID);
|
||||
|
||||
interface IPlayback
|
||||
{
|
||||
bool Init();
|
||||
void SetGlobalVolume(float Volume);
|
||||
void SetGlobalVolume(float volume);
|
||||
int GetStreamCount();
|
||||
void CloseAll();
|
||||
|
||||
#region Stream Handling
|
||||
int Load(string Media);
|
||||
int Load(string Media, bool Prescan);
|
||||
void Close(int Stream);
|
||||
int Load(string media);
|
||||
int Load(string media, bool prescan);
|
||||
void Close(int stream);
|
||||
|
||||
void Play(int Stream);
|
||||
void Play(int Stream, bool Loop);
|
||||
void Pause(int Stream);
|
||||
void Stop(int Stream);
|
||||
void Fade(int Stream, float TargetVolume, float Seconds);
|
||||
void FadeAndPause(int Stream, float TargetVolume, float Seconds);
|
||||
void FadeAndStop(int Stream, float TargetVolume, float Seconds);
|
||||
void SetStreamVolume(int Stream, float Volume);
|
||||
void SetStreamVolumeMax(int Stream, float Volume);
|
||||
void Play(int stream);
|
||||
void Play(int stream, bool loop);
|
||||
void Pause(int stream);
|
||||
void Stop(int stream);
|
||||
void Fade(int stream, float targetVolume, float seconds);
|
||||
void FadeAndPause(int stream, float targetVolume, float seconds);
|
||||
void FadeAndStop(int stream, float targetVolume, float seconds);
|
||||
void SetStreamVolume(int stream, float volume);
|
||||
void SetStreamVolumeMax(int stream, float volume);
|
||||
|
||||
float GetLength(int Stream);
|
||||
float GetPosition(int Stream);
|
||||
float GetLength(int stream);
|
||||
float GetPosition(int stream);
|
||||
|
||||
bool IsPlaying(int Stream);
|
||||
bool IsPaused(int Stream);
|
||||
bool IsFinished(int Stream);
|
||||
bool IsPlaying(int stream);
|
||||
bool IsPaused(int stream);
|
||||
bool IsFinished(int stream);
|
||||
|
||||
void SetPosition(int Stream, float Position);
|
||||
void SetPosition(int stream, float position);
|
||||
|
||||
void Update();
|
||||
#endregion Stream Handling
|
||||
}
|
||||
|
||||
class RingBuffer
|
||||
class CRingBuffer
|
||||
{
|
||||
private readonly byte[] _data;
|
||||
private readonly long _size;
|
||||
private long _readPos;
|
||||
private long _writePos;
|
||||
private long _bytesNotRead;
|
||||
private readonly byte[] _Data;
|
||||
private readonly long _Size;
|
||||
private long _ReadPos;
|
||||
private long _WritePos;
|
||||
private long _BytesNotRead;
|
||||
|
||||
public long BytesNotRead
|
||||
{
|
||||
get { return _bytesNotRead; }
|
||||
get { return _BytesNotRead; }
|
||||
}
|
||||
|
||||
public RingBuffer(long size)
|
||||
public CRingBuffer(long size)
|
||||
{
|
||||
_size = size;
|
||||
_data = new byte[size];
|
||||
_readPos = 0L;
|
||||
_writePos = 0L;
|
||||
_bytesNotRead = 0L;
|
||||
_Size = size;
|
||||
_Data = new byte[size];
|
||||
_ReadPos = 0L;
|
||||
_WritePos = 0L;
|
||||
_BytesNotRead = 0L;
|
||||
}
|
||||
|
||||
public void Write(byte[] Data)
|
||||
public void Write(byte[] data)
|
||||
{
|
||||
long written = 0L;
|
||||
while (written < Data.Length)
|
||||
while (written < data.Length)
|
||||
{
|
||||
_data[_writePos] = Data[written];
|
||||
_writePos++;
|
||||
if (_writePos >= _size)
|
||||
_writePos = 0L;
|
||||
_Data[_WritePos] = data[written];
|
||||
_WritePos++;
|
||||
if (_WritePos >= _Size)
|
||||
_WritePos = 0L;
|
||||
|
||||
written++;
|
||||
_bytesNotRead++;
|
||||
_BytesNotRead++;
|
||||
}
|
||||
}
|
||||
|
||||
public void Read(ref byte[] Data)
|
||||
public void Read(ref byte[] data)
|
||||
{
|
||||
long read = 0L;
|
||||
while (read < Data.Length && _bytesNotRead > 0L)
|
||||
while (read < data.Length && _BytesNotRead > 0L)
|
||||
{
|
||||
Data[read] = _data[_readPos];
|
||||
_readPos++;
|
||||
if (_readPos >= _size)
|
||||
_readPos = 0L;
|
||||
data[read] = _Data[_ReadPos];
|
||||
_ReadPos++;
|
||||
if (_ReadPos >= _Size)
|
||||
_ReadPos = 0L;
|
||||
|
||||
read++;
|
||||
_bytesNotRead--;
|
||||
_BytesNotRead--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,17 +41,17 @@ namespace Vocaluxe.Lib.Sound
|
||||
bool Init();
|
||||
void CloseAll();
|
||||
|
||||
bool Start(SRecordDevice[] DeviceConfig);
|
||||
bool Start(SRecordDevice[] deviceConfig);
|
||||
bool Stop();
|
||||
void AnalyzeBuffer(int Player);
|
||||
void AnalyzeBuffer(int player);
|
||||
|
||||
int GetToneAbs(int Player);
|
||||
int GetTone(int Player);
|
||||
void SetTone(int Player, int Tone);
|
||||
float GetMaxVolume(int Player);
|
||||
bool ToneValid(int Player);
|
||||
int NumHalfTones(int Player);
|
||||
float[] ToneWeigth(int Player);
|
||||
int GetToneAbs(int player);
|
||||
int GetTone(int player);
|
||||
void SetTone(int player, int tone);
|
||||
float GetMaxVolume(int player);
|
||||
bool ToneValid(int player);
|
||||
int NumHalfTones(int player);
|
||||
float[] ToneWeigth(int player);
|
||||
|
||||
SRecordDevice[] RecordDevices();
|
||||
}
|
||||
|
||||
@@ -29,16 +29,16 @@ namespace PortAudioSharp
|
||||
PortAudio v.19 bindings for .NET
|
||||
</summary>
|
||||
*/
|
||||
public partial class PortAudio
|
||||
public partial class CPortAudio
|
||||
{
|
||||
#region **** PORTAUDIO CALLBACKS ****
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate PaStreamCallbackResult PaStreamCallbackDelegate(
|
||||
public delegate EPaStreamCallbackResult PaStreamCallbackDelegate(
|
||||
IntPtr input,
|
||||
IntPtr output,
|
||||
uint frameCount,
|
||||
ref PaStreamCallbackTimeInfo timeInfo,
|
||||
PaStreamCallbackFlags statusFlags,
|
||||
ref SPaStreamCallbackTimeInfo timeInfo,
|
||||
EPaStreamCallbackFlags statusFlags,
|
||||
IntPtr userData);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
@@ -47,366 +47,366 @@ namespace PortAudioSharp
|
||||
|
||||
#region **** PORTAUDIO DATA STRUCTURES ****
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PaDeviceInfo
|
||||
public struct SPaDeviceInfo
|
||||
{
|
||||
public int structVersion;
|
||||
[MarshalAs(UnmanagedType.LPStr)] public string name;
|
||||
public int hostApi;
|
||||
public int maxInputChannels;
|
||||
public int maxOutputChannels;
|
||||
public double defaultLowInputLatency;
|
||||
public double defaultLowOutputLatency;
|
||||
public double defaultHighInputLatency;
|
||||
public double defaultHighOutputLatency;
|
||||
public double defaultSampleRate;
|
||||
public int StructVersion;
|
||||
[MarshalAs(UnmanagedType.LPStr)] public string Name;
|
||||
public int HostApi;
|
||||
public int MaxInputChannels;
|
||||
public int MaxOutputChannels;
|
||||
public double DefaultLowInputLatency;
|
||||
public double DefaultLowOutputLatency;
|
||||
public double DefaultHighInputLatency;
|
||||
public double DefaultHighOutputLatency;
|
||||
public double DefaultSampleRate;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "[" + GetType().Name + "]" + "\n"
|
||||
+ "name: " + name + "\n"
|
||||
+ "hostApi: " + hostApi + "\n"
|
||||
+ "maxInputChannels: " + maxInputChannels + "\n"
|
||||
+ "maxOutputChannels: " + maxOutputChannels + "\n"
|
||||
+ "defaultLowInputLatency: " + defaultLowInputLatency + "\n"
|
||||
+ "defaultLowOutputLatency: " + defaultLowOutputLatency + "\n"
|
||||
+ "defaultHighInputLatency: " + defaultHighInputLatency + "\n"
|
||||
+ "defaultHighOutputLatency: " + defaultHighOutputLatency + "\n"
|
||||
+ "defaultSampleRate: " + defaultSampleRate;
|
||||
+ "name: " + Name + "\n"
|
||||
+ "hostApi: " + HostApi + "\n"
|
||||
+ "maxInputChannels: " + MaxInputChannels + "\n"
|
||||
+ "maxOutputChannels: " + MaxOutputChannels + "\n"
|
||||
+ "defaultLowInputLatency: " + DefaultLowInputLatency + "\n"
|
||||
+ "defaultLowOutputLatency: " + DefaultLowOutputLatency + "\n"
|
||||
+ "defaultHighInputLatency: " + DefaultHighInputLatency + "\n"
|
||||
+ "defaultHighOutputLatency: " + DefaultHighOutputLatency + "\n"
|
||||
+ "defaultSampleRate: " + DefaultSampleRate;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PaHostApiInfo
|
||||
public struct SPaHostApiInfo
|
||||
{
|
||||
public int structVersion;
|
||||
public PaHostApiTypeId type;
|
||||
[MarshalAs(UnmanagedType.LPStr)] public string name;
|
||||
public int deviceCount;
|
||||
public int defaultInputDevice;
|
||||
public int defaultOutputDevice;
|
||||
public int StructVersion;
|
||||
public EPaHostApiTypeId Type;
|
||||
[MarshalAs(UnmanagedType.LPStr)] public string Name;
|
||||
public int DeviceCount;
|
||||
public int DefaultInputDevice;
|
||||
public int DefaultOutputDevice;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "[" + GetType().Name + "]" + "\n"
|
||||
+ "structVersion: " + structVersion + "\n"
|
||||
+ "type: " + type + "\n"
|
||||
+ "name: " + name + "\n"
|
||||
+ "deviceCount: " + deviceCount + "\n"
|
||||
+ "defaultInputDevice: " + defaultInputDevice + "\n"
|
||||
+ "defaultOutputDevice: " + defaultOutputDevice;
|
||||
+ "structVersion: " + StructVersion + "\n"
|
||||
+ "type: " + Type + "\n"
|
||||
+ "name: " + Name + "\n"
|
||||
+ "deviceCount: " + DeviceCount + "\n"
|
||||
+ "defaultInputDevice: " + DefaultInputDevice + "\n"
|
||||
+ "defaultOutputDevice: " + DefaultOutputDevice;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PaHostErrorInfo
|
||||
public struct SPaHostErrorInfo
|
||||
{
|
||||
public PaHostApiTypeId hostApiType;
|
||||
public int errorCode;
|
||||
[MarshalAs(UnmanagedType.LPStr)] public string errorText;
|
||||
public EPaHostApiTypeId HostApiType;
|
||||
public int ErrorCode;
|
||||
[MarshalAs(UnmanagedType.LPStr)] public string ErrorText;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "[" + GetType().Name + "]" + "\n"
|
||||
+ "hostApiType: " + hostApiType + "\n"
|
||||
+ "errorCode: " + errorCode + "\n"
|
||||
+ "errorText: " + errorText;
|
||||
+ "hostApiType: " + HostApiType + "\n"
|
||||
+ "errorCode: " + ErrorCode + "\n"
|
||||
+ "errorText: " + ErrorText;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PaStreamCallbackTimeInfo
|
||||
public struct SPaStreamCallbackTimeInfo
|
||||
{
|
||||
public double inputBufferAdcTime;
|
||||
public double currentTime;
|
||||
public double outputBufferDacTime;
|
||||
public double InputBufferAdcTime;
|
||||
public double CurrentTime;
|
||||
public double OutputBufferDacTime;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "[" + GetType().Name + "]" + "\n"
|
||||
+ "currentTime: " + currentTime + "\n"
|
||||
+ "inputBufferAdcTime: " + inputBufferAdcTime + "\n"
|
||||
+ "outputBufferDacTime: " + outputBufferDacTime;
|
||||
+ "currentTime: " + CurrentTime + "\n"
|
||||
+ "inputBufferAdcTime: " + InputBufferAdcTime + "\n"
|
||||
+ "outputBufferDacTime: " + OutputBufferDacTime;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PaStreamInfo
|
||||
public struct SPaStreamInfo
|
||||
{
|
||||
public int structVersion;
|
||||
public double inputLatency;
|
||||
public double outputLatency;
|
||||
public double sampleRate;
|
||||
public int StructVersion;
|
||||
public double InputLatency;
|
||||
public double OutputLatency;
|
||||
public double SampleRate;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "[" + GetType().Name + "]" + "\n"
|
||||
+ "structVersion: " + structVersion + "\n"
|
||||
+ "inputLatency: " + inputLatency + "\n"
|
||||
+ "outputLatency: " + outputLatency + "\n"
|
||||
+ "sampleRate: " + sampleRate;
|
||||
+ "structVersion: " + StructVersion + "\n"
|
||||
+ "inputLatency: " + InputLatency + "\n"
|
||||
+ "outputLatency: " + OutputLatency + "\n"
|
||||
+ "sampleRate: " + SampleRate;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PaStreamParameters
|
||||
public struct SPaStreamParameters
|
||||
{
|
||||
public int device;
|
||||
public int channelCount;
|
||||
public PaSampleFormat sampleFormat;
|
||||
public double suggestedLatency;
|
||||
internal IntPtr hostApiSpecificStreamInfo;
|
||||
public int Device;
|
||||
public int ChannelCount;
|
||||
public EPaSampleFormat SampleFormat;
|
||||
public double SuggestedLatency;
|
||||
internal IntPtr HostApiSpecificStreamInfo;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "[" + GetType().Name + "]" + "\n"
|
||||
+ "device: " + device + "\n"
|
||||
+ "channelCount: " + channelCount + "\n"
|
||||
+ "sampleFormat: " + sampleFormat + "\n"
|
||||
+ "suggestedLatency: " + suggestedLatency;
|
||||
+ "device: " + Device + "\n"
|
||||
+ "channelCount: " + ChannelCount + "\n"
|
||||
+ "sampleFormat: " + SampleFormat + "\n"
|
||||
+ "suggestedLatency: " + SuggestedLatency;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region **** PORTAUDIO DEFINES ****
|
||||
public enum PaDeviceIndex
|
||||
public enum EPaDeviceIndex
|
||||
{
|
||||
paNoDevice = -1,
|
||||
paUseHostApiSpecificDeviceSpecification = -2
|
||||
PaNoDevice = -1,
|
||||
PaUseHostApiSpecificDeviceSpecification = -2
|
||||
}
|
||||
|
||||
public enum PaSampleFormat : uint
|
||||
public enum EPaSampleFormat : uint
|
||||
{
|
||||
paFloat32 = 0x00000001,
|
||||
paInt32 = 0x00000002,
|
||||
paInt24 = 0x00000004,
|
||||
paInt16 = 0x00000008,
|
||||
paInt8 = 0x00000010,
|
||||
paUInt8 = 0x00000020,
|
||||
paCustomFormat = 0x00010000,
|
||||
paNonInterleaved = 0x80000000,
|
||||
PaFloat32 = 0x00000001,
|
||||
PaInt32 = 0x00000002,
|
||||
PaInt24 = 0x00000004,
|
||||
PaInt16 = 0x00000008,
|
||||
PaInt8 = 0x00000010,
|
||||
PaUInt8 = 0x00000020,
|
||||
PaCustomFormat = 0x00010000,
|
||||
PaNonInterleaved = 0x80000000,
|
||||
}
|
||||
|
||||
public const int paFormatIsSupported = 0;
|
||||
public const int paFramesPerBufferUnspecified = 0;
|
||||
public const int PaFormatIsSupported = 0;
|
||||
public const int PaFramesPerBufferUnspecified = 0;
|
||||
|
||||
public enum PaStreamFlags : uint
|
||||
public enum EPaStreamFlags : uint
|
||||
{
|
||||
paNoFlag = 0,
|
||||
paClipOff = 0x00000001,
|
||||
paDitherOff = 0x00000002,
|
||||
paNeverDropInput = 0x00000004,
|
||||
paPrimeOutputBuffersUsingStreamCallback = 0x00000008,
|
||||
paPlatformSpecificFlags = 0xFFFF0000
|
||||
PaNoFlag = 0,
|
||||
PaClipOff = 0x00000001,
|
||||
PaDitherOff = 0x00000002,
|
||||
PaNeverDropInput = 0x00000004,
|
||||
PaPrimeOutputBuffersUsingStreamCallback = 0x00000008,
|
||||
PaPlatformSpecificFlags = 0xFFFF0000
|
||||
}
|
||||
|
||||
public enum PaStreamCallbackFlags : uint
|
||||
public enum EPaStreamCallbackFlags : uint
|
||||
{
|
||||
paInputUnderflow = 0x00000001,
|
||||
paInputOverflow = 0x00000002,
|
||||
paOutputUnderflow = 0x00000004,
|
||||
paOutputOverflow = 0x00000008,
|
||||
paPrimingOutput = 0x00000010
|
||||
PaInputUnderflow = 0x00000001,
|
||||
PaInputOverflow = 0x00000002,
|
||||
PaOutputUnderflow = 0x00000004,
|
||||
PaOutputOverflow = 0x00000008,
|
||||
PaPrimingOutput = 0x00000010
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region **** PORTAUDIO ENUMERATIONS ****
|
||||
public enum PaError
|
||||
public enum EPaError
|
||||
{
|
||||
paNoError = 0,
|
||||
paNotInitialized = -10000,
|
||||
paUnanticipatedHostError,
|
||||
paInvalidChannelCount,
|
||||
paInvalidSampleRate,
|
||||
paInvalidDevice,
|
||||
paInvalidFlag,
|
||||
paSampleFormatNotSupported,
|
||||
paBadIODeviceCombination,
|
||||
paInsufficientMemory,
|
||||
paBufferTooBig,
|
||||
paBufferTooSmall,
|
||||
paNullCallback,
|
||||
paBadStreamPtr,
|
||||
paTimedOut,
|
||||
paInternalError,
|
||||
paDeviceUnavailable,
|
||||
paIncompatibleHostApiSpecificStreamInfo,
|
||||
paStreamIsStopped,
|
||||
paStreamIsNotStopped,
|
||||
paInputOverflowed,
|
||||
paOutputUnderflowed,
|
||||
paHostApiNotFound,
|
||||
paInvalidHostApi,
|
||||
paCanNotReadFromACallbackStream,
|
||||
paCanNotWriteToACallbackStream,
|
||||
paCanNotReadFromAnOutputOnlyStream,
|
||||
paCanNotWriteToAnInputOnlyStream,
|
||||
paIncompatibleStreamHostApi,
|
||||
paBadBufferPtr
|
||||
PaNoError = 0,
|
||||
PaNotInitialized = -10000,
|
||||
PaUnanticipatedHostError,
|
||||
PaInvalidChannelCount,
|
||||
PaInvalidSampleRate,
|
||||
PaInvalidDevice,
|
||||
PaInvalidFlag,
|
||||
PaSampleFormatNotSupported,
|
||||
PaBadIODeviceCombination,
|
||||
PaInsufficientMemory,
|
||||
PaBufferTooBig,
|
||||
PaBufferTooSmall,
|
||||
PaNullCallback,
|
||||
PaBadStreamPtr,
|
||||
PaTimedOut,
|
||||
PaInternalError,
|
||||
PaDeviceUnavailable,
|
||||
PaIncompatibleHostApiSpecificStreamInfo,
|
||||
PaStreamIsStopped,
|
||||
PaStreamIsNotStopped,
|
||||
PaInputOverflowed,
|
||||
PaOutputUnderflowed,
|
||||
PaHostApiNotFound,
|
||||
PaInvalidHostApi,
|
||||
PaCanNotReadFromCallbackStream,
|
||||
PaCanNotWriteToACallbackStream,
|
||||
PaCanNotReadFromAnOutputOnlyStream,
|
||||
PaCanNotWriteToAnInputOnlyStream,
|
||||
PaIncompatibleStreamHostApi,
|
||||
PaBadBufferPtr
|
||||
}
|
||||
|
||||
public enum PaHostApiTypeId : uint
|
||||
public enum EPaHostApiTypeId : uint
|
||||
{
|
||||
paInDevelopment = 0,
|
||||
paDirectSound = 1,
|
||||
paMME = 2,
|
||||
paASIO = 3,
|
||||
paSoundManager = 4,
|
||||
paCoreAudio = 5,
|
||||
paOSS = 7,
|
||||
paALSA = 8,
|
||||
paAL = 9,
|
||||
paBeOS = 10,
|
||||
paWDMKS = 11,
|
||||
paJACK = 12,
|
||||
paWASAPI = 13,
|
||||
paAudioScienceHPI = 14
|
||||
PaInDevelopment = 0,
|
||||
PaDirectSound = 1,
|
||||
PaMME = 2,
|
||||
PaASIO = 3,
|
||||
PaSoundManager = 4,
|
||||
PaCoreAudio = 5,
|
||||
PaOSS = 7,
|
||||
PaALSA = 8,
|
||||
PaAL = 9,
|
||||
PaBeOS = 10,
|
||||
PaWDMKS = 11,
|
||||
PaJACK = 12,
|
||||
PaWASAPI = 13,
|
||||
PaAudioScienceHPI = 14
|
||||
}
|
||||
|
||||
public enum PaStreamCallbackResult : uint
|
||||
public enum EPaStreamCallbackResult : uint
|
||||
{
|
||||
paContinue = 0,
|
||||
paComplete = 1,
|
||||
paAbort = 2
|
||||
PaContinue = 0,
|
||||
PaComplete = 1,
|
||||
PaAbort = 2
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region **** PORTAUDIO FUNCTIONS ****
|
||||
#if ARCH_X86
|
||||
#if WIN
|
||||
private const string PaDll = "x86\\portaudio_x86.dll";
|
||||
private const string _PaDll = "x86\\portaudio_x86.dll";
|
||||
#endif
|
||||
|
||||
#if LINUX
|
||||
private const string PaDll = "libportaudio.so.2.0.0";
|
||||
private const string _PaDll = "libportaudio.so.2.0.0";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ARCH_X64
|
||||
#if WIN
|
||||
private const string PaDll = "x64\\portaudio_x64.dll";
|
||||
private const string _PaDll = "x64\\portaudio_x64.dll";
|
||||
#endif
|
||||
|
||||
#if LINUX
|
||||
private const string PaDll = "libportaudio.so.2.0.0";
|
||||
private const string _PaDll = "libportaudio.so.2.0.0";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_GetVersion();
|
||||
|
||||
[DllImport(PaDll, EntryPoint = "Pa_GetVersionText", CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, EntryPoint = "Pa_GetVersionText", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr IntPtr_Pa_GetVersionText();
|
||||
|
||||
public static string Pa_GetVersionText()
|
||||
public static string PaGetVersionText()
|
||||
{
|
||||
IntPtr strptr = IntPtr_Pa_GetVersionText();
|
||||
return Marshal.PtrToStringAnsi(strptr);
|
||||
}
|
||||
|
||||
[DllImport(PaDll, EntryPoint = "Pa_GetErrorText", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr IntPtr_Pa_GetErrorText(PaError errorCode);
|
||||
[DllImport(_PaDll, EntryPoint = "Pa_GetErrorText", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr IntPtr_Pa_GetErrorText(EPaError errorCode);
|
||||
|
||||
public static string Pa_GetErrorText(PaError errorCode)
|
||||
public static string PaGetErrorText(EPaError errorCode)
|
||||
{
|
||||
IntPtr strptr = IntPtr_Pa_GetErrorText(errorCode);
|
||||
return Marshal.PtrToStringAnsi(strptr);
|
||||
}
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_Initialize();
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_Initialize();
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_Terminate();
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_Terminate();
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_GetHostApiCount();
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_GetDefaultHostApi();
|
||||
|
||||
[DllImport(PaDll, EntryPoint = "Pa_GetHostApiInfo", CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, EntryPoint = "Pa_GetHostApiInfo", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr IntPtr_Pa_GetHostApiInfo(int hostApi);
|
||||
|
||||
public static PaHostApiInfo Pa_GetHostApiInfo(int hostApi)
|
||||
public static SPaHostApiInfo PaGetHostApiInfo(int hostApi)
|
||||
{
|
||||
IntPtr structptr = IntPtr_Pa_GetHostApiInfo(hostApi);
|
||||
return (PaHostApiInfo)Marshal.PtrToStructure(structptr, typeof(PaHostApiInfo));
|
||||
return (SPaHostApiInfo)Marshal.PtrToStructure(structptr, typeof(SPaHostApiInfo));
|
||||
}
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_HostApiTypeIdToHostApiIndex(PaHostApiTypeId type);
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_HostApiTypeIdToHostApiIndex(EPaHostApiTypeId type);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_HostApiDeviceIndexToDeviceIndex(int hostApi, int hostApiDeviceIndex);
|
||||
|
||||
[DllImport(PaDll, EntryPoint = "Pa_GetLastHostErrorInfo", CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, EntryPoint = "Pa_GetLastHostErrorInfo", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr IntPtr_Pa_GetLastHostErrorInfo();
|
||||
|
||||
public static PaHostErrorInfo Pa_GetLastHostErrorInfo()
|
||||
public static SPaHostErrorInfo PaGetLastHostErrorInfo()
|
||||
{
|
||||
IntPtr structptr = IntPtr_Pa_GetLastHostErrorInfo();
|
||||
return (PaHostErrorInfo)Marshal.PtrToStructure(structptr, typeof(PaHostErrorInfo));
|
||||
return (SPaHostErrorInfo)Marshal.PtrToStructure(structptr, typeof(SPaHostErrorInfo));
|
||||
}
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_GetDeviceCount();
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_GetDefaultInputDevice();
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_GetDefaultOutputDevice();
|
||||
|
||||
[DllImport(PaDll, EntryPoint = "Pa_GetDeviceInfo", CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, EntryPoint = "Pa_GetDeviceInfo", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr IntPtr_Pa_GetDeviceInfo(int device);
|
||||
|
||||
public static PaDeviceInfo Pa_GetDeviceInfo(int device)
|
||||
public static SPaDeviceInfo PaGetDeviceInfo(int device)
|
||||
{
|
||||
IntPtr structptr = IntPtr_Pa_GetDeviceInfo(device);
|
||||
return (PaDeviceInfo)Marshal.PtrToStructure(structptr, typeof(PaDeviceInfo));
|
||||
return (SPaDeviceInfo)Marshal.PtrToStructure(structptr, typeof(SPaDeviceInfo));
|
||||
}
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_IsFormatSupported(
|
||||
ref PaStreamParameters inputParameters,
|
||||
ref PaStreamParameters outputParameters,
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_IsFormatSupported(
|
||||
ref SPaStreamParameters inputParameters,
|
||||
ref SPaStreamParameters outputParameters,
|
||||
double sampleRate);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_OpenStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_OpenStream(
|
||||
out IntPtr stream,
|
||||
ref PaStreamParameters inputParameters,
|
||||
ref PaStreamParameters outputParameters,
|
||||
ref SPaStreamParameters inputParameters,
|
||||
ref SPaStreamParameters outputParameters,
|
||||
double sampleRate,
|
||||
uint framesPerBuffer,
|
||||
PaStreamFlags streamFlags,
|
||||
EPaStreamFlags streamFlags,
|
||||
PaStreamCallbackDelegate streamCallback,
|
||||
IntPtr userData);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_OpenStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_OpenStream(
|
||||
out IntPtr stream,
|
||||
ref PaStreamParameters inputParameters,
|
||||
ref SPaStreamParameters inputParameters,
|
||||
IntPtr outputParameters,
|
||||
double sampleRate,
|
||||
uint framesPerBuffer,
|
||||
PaStreamFlags streamFlags,
|
||||
EPaStreamFlags streamFlags,
|
||||
PaStreamCallbackDelegate streamCallback,
|
||||
IntPtr userData);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_OpenStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_OpenStream(
|
||||
out IntPtr stream,
|
||||
IntPtr inputParameters,
|
||||
ref PaStreamParameters outputParameters,
|
||||
ref SPaStreamParameters outputParameters,
|
||||
double sampleRate,
|
||||
uint framesPerBuffer,
|
||||
PaStreamFlags streamFlags,
|
||||
EPaStreamFlags streamFlags,
|
||||
PaStreamCallbackDelegate streamCallback,
|
||||
IntPtr userData);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_OpenDefaultStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_OpenDefaultStream(
|
||||
out IntPtr stream,
|
||||
int numInputChannels,
|
||||
int numOutputChannels,
|
||||
@@ -416,142 +416,142 @@ namespace PortAudioSharp
|
||||
PaStreamCallbackDelegate streamCallback,
|
||||
IntPtr userData);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_CloseStream(IntPtr stream);
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_CloseStream(IntPtr stream);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_SetStreamFinishedCallback(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_SetStreamFinishedCallback(
|
||||
ref IntPtr stream,
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] PaStreamFinishedCallbackDelegate streamFinishedCallback);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_StartStream(IntPtr stream);
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_StartStream(IntPtr stream);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_StopStream(IntPtr stream);
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_StopStream(IntPtr stream);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_AbortStream(IntPtr stream);
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_AbortStream(IntPtr stream);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_IsStreamStopped(IntPtr stream);
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_IsStreamStopped(IntPtr stream);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_IsStreamActive(IntPtr stream);
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_IsStreamActive(IntPtr stream);
|
||||
|
||||
[DllImport(PaDll, EntryPoint = "Pa_GetStreamInfo", CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, EntryPoint = "Pa_GetStreamInfo", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr IntPtr_Pa_GetStreamInfo(IntPtr stream);
|
||||
|
||||
public static PaStreamInfo Pa_GetStreamInfo(IntPtr stream)
|
||||
public static SPaStreamInfo PaGetStreamInfo(IntPtr stream)
|
||||
{
|
||||
IntPtr structptr = IntPtr_Pa_GetStreamInfo(stream);
|
||||
return (PaStreamInfo)Marshal.PtrToStructure(structptr, typeof(PaStreamInfo));
|
||||
return (SPaStreamInfo)Marshal.PtrToStructure(structptr, typeof(SPaStreamInfo));
|
||||
}
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern double Pa_GetStreamTime(IntPtr stream);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern double Pa_GetStreamCpuLoad(IntPtr stream);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_ReadStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_ReadStream(
|
||||
IntPtr stream,
|
||||
[Out] float[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_ReadStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_ReadStream(
|
||||
IntPtr stream,
|
||||
[Out] byte[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_ReadStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_ReadStream(
|
||||
IntPtr stream,
|
||||
[Out] sbyte[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_ReadStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_ReadStream(
|
||||
IntPtr stream,
|
||||
[Out] ushort[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_ReadStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_ReadStream(
|
||||
IntPtr stream,
|
||||
[Out] short[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_ReadStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_ReadStream(
|
||||
IntPtr stream,
|
||||
[Out] uint[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_ReadStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_ReadStream(
|
||||
IntPtr stream,
|
||||
[Out] int[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_WriteStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_WriteStream(
|
||||
IntPtr stream,
|
||||
[In] float[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_WriteStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_WriteStream(
|
||||
IntPtr stream,
|
||||
[In] byte[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_WriteStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_WriteStream(
|
||||
IntPtr stream,
|
||||
[In] sbyte[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_WriteStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_WriteStream(
|
||||
IntPtr stream,
|
||||
[In] ushort[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_WriteStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_WriteStream(
|
||||
IntPtr stream,
|
||||
[In] short[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_WriteStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_WriteStream(
|
||||
IntPtr stream,
|
||||
[In] uint[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_WriteStream(
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_WriteStream(
|
||||
IntPtr stream,
|
||||
[In] int[] buffer,
|
||||
uint frames);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_GetStreamReadAvailable(IntPtr stream);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Pa_GetStreamWriteAvailable(IntPtr stream);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError Pa_GetSampleSize(PaSampleFormat format);
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern EPaError Pa_GetSampleSize(EPaSampleFormat format);
|
||||
|
||||
[DllImport(PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_PaDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Pa_Sleep(int msec);
|
||||
#endregion
|
||||
|
||||
private PortAudio()
|
||||
private CPortAudio()
|
||||
{
|
||||
// This is a static class
|
||||
}
|
||||
|
||||
@@ -25,16 +25,16 @@ using System.Runtime.InteropServices;
|
||||
namespace PortAudioSharp
|
||||
{
|
||||
/// <summary> PortAudio v.19 bindings for .NET - ASIO bindings </summary>
|
||||
public partial class PortAudio
|
||||
public partial class CPortAudio
|
||||
{
|
||||
#region **** PORTAUDIO DATA STRUCTURES ****
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PaAsioStreamInfo
|
||||
public struct SPaAsioStreamInfo
|
||||
{
|
||||
public ulong size; /**< sizeof(PaAsioStreamInfo) */
|
||||
public int hostApiType; /**< paASIO */
|
||||
public ulong version; /**< 1 */
|
||||
public ulong flags;
|
||||
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
|
||||
@@ -45,12 +45,12 @@ namespace PortAudioSharp
|
||||
/// 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;
|
||||
private readonly IntPtr _ChannelSelectors;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region **** PORTAUDIO DEFINES ****
|
||||
public const int paAsioUseChannelSelectors = 0x01;
|
||||
public const int PaAsioUseChannelSelectors = 0x01;
|
||||
#endregion
|
||||
|
||||
#region **** PORTAUDIO FUNCTIONS ****
|
||||
@@ -73,7 +73,7 @@ namespace PortAudioSharp
|
||||
/// on Macintosh this value should be zero.
|
||||
/// </param>
|
||||
[DllImport("PortAudio.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern PaError PaAsio_ShowControlPanel(int device, IntPtr systemSpecific);
|
||||
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.
|
||||
@@ -86,7 +86,7 @@ namespace PortAudioSharp
|
||||
// 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>
|
||||
/// <param name="stream"></param>
|
||||
/// The stream to operate on.
|
||||
/// <param name="sampleRate"></param>
|
||||
/// The new sample rate.
|
||||
@@ -94,7 +94,7 @@ namespace PortAudioSharp
|
||||
/// 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 PaError PaAsio_SetStreamSampleRate(IntPtr stream, double sampleRate);
|
||||
public static extern EPaError PaAsio_SetStreamSampleRate(IntPtr stream, double sampleRate);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -3,135 +3,135 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Vocaluxe.Lib.Video.Acinerella
|
||||
{
|
||||
public enum TAc_stream_type : sbyte
|
||||
public enum EACStreamType : sbyte
|
||||
{
|
||||
/*The type of the media stream is not known. This kind of stream can not be
|
||||
decoded.*/
|
||||
AC_STREAM_TYPE_UNKNOWN = -1,
|
||||
ACStreamTypeUnknown = -1,
|
||||
//This media stream is a video stream.
|
||||
AC_STREAM_TYPE_VIDEO = 0,
|
||||
ACStreamTypeVideo = 0,
|
||||
//This media stream is an audio stream.
|
||||
AC_STREAM_TYPE_AUDIO = 1
|
||||
ACStreamTypeAudio = 1
|
||||
}
|
||||
|
||||
//Defines the type of an Acinerella media decoder.
|
||||
public enum TAc_decoder_type : byte
|
||||
public enum EACDecoderType : byte
|
||||
{
|
||||
//This decoder is used to decode a video stream.
|
||||
AC_DECODER_TYPE_VIDEO = 0,
|
||||
ACDecoderTypeVideo = 0,
|
||||
//This decoder is used to decode an audio stram.
|
||||
AC_DECODER_TYPE_AUDIO = 1
|
||||
ACDecoderTypeAudio = 1
|
||||
}
|
||||
|
||||
//Defines the format video/image data is outputted in
|
||||
public enum TAc_output_format : byte
|
||||
public enum EACOutputFormat : byte
|
||||
{
|
||||
AC_OUTPUT_RGB24 = 0,
|
||||
AC_OUTPUT_BGR24 = 1,
|
||||
AC_OUTPUT_RGBA32 = 2,
|
||||
AC_OUTPUT_BGRA32 = 3
|
||||
ACOutputRGB24 = 0,
|
||||
ACOutputBGR24 = 1,
|
||||
ACOutputRGBA32 = 2,
|
||||
ACOutputBGra32 = 3
|
||||
}
|
||||
|
||||
// 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 TAc_file_info
|
||||
public struct SACFileInfo
|
||||
{
|
||||
public Int64 duration;
|
||||
public Int64 Duration;
|
||||
}
|
||||
|
||||
// TAc_instance represents an Acinerella instance. Each instance can open and
|
||||
// decode one file at once. There can be only 26 Acinerella instances opened at
|
||||
// once.
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct TAc_instance
|
||||
public struct SACInstance
|
||||
{
|
||||
//If true, the instance currently opened a media file
|
||||
public bool opened;
|
||||
public bool Opened;
|
||||
//Contains the count of streams the media file has. This value is available
|
||||
//after calling the ac_open function.
|
||||
public Int32 stream_count;
|
||||
public Int32 StreamCount;
|
||||
//Set this value to change the image output format
|
||||
public TAc_output_format output_format;
|
||||
public EACOutputFormat OutputFormat;
|
||||
//Contains information about the opened stream/file
|
||||
public TAc_file_info info;
|
||||
public SACFileInfo Info;
|
||||
}
|
||||
|
||||
// Contains information about an Acinerella audio stream.
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct TAc_audio_stream_info
|
||||
public struct SACAudioStreamInfo
|
||||
{
|
||||
//Samples per second. Default values are 44100 or 48000.
|
||||
public Int32 samples_per_second;
|
||||
public Int32 SamplesPerSecond;
|
||||
//Bits per sample. Can be 8 or 16 Bit.
|
||||
public Int32 bit_depth;
|
||||
public Int32 BitDepth;
|
||||
//Count of channels in the audio stream.
|
||||
public Int32 channel_count;
|
||||
public Int32 ChannelCount;
|
||||
}
|
||||
|
||||
// Contains information about an Acinerella video stream.
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct TAc_video_stream_info
|
||||
public struct SACVideoStreamInfo
|
||||
{
|
||||
//The width of one frame.
|
||||
public Int32 frame_width;
|
||||
public Int32 FrameWidth;
|
||||
//The height of one frame.
|
||||
public Int32 frame_height;
|
||||
public Int32 FrameHeight;
|
||||
//The width of one pixel. 1.07 for 4:3 format, 1,42 for the 16:9 format
|
||||
public float pixel_aspect;
|
||||
public float PixelAspect;
|
||||
//Frames per second that should be played.
|
||||
public double frames_per_second;
|
||||
public double FramesPerSecond;
|
||||
}
|
||||
|
||||
// Contains information about an Acinerella stream.
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct TAc_stream_info
|
||||
public struct SACStreamInfo
|
||||
{
|
||||
//Contains the type of the stream.
|
||||
public TAc_stream_type stream_type;
|
||||
public EACStreamType StreamType;
|
||||
//Additional info about the stream
|
||||
public TAc_audio_stream_info audio_info;
|
||||
public TAc_video_stream_info video_info;
|
||||
public SACAudioStreamInfo AudioInfo;
|
||||
public SACVideoStreamInfo VideoInfo;
|
||||
}
|
||||
|
||||
// Contains information about an Acinerella video/audio decoder.
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct TAc_decoder
|
||||
public struct SACDecoder
|
||||
{
|
||||
//Pointer on the Acinerella instance
|
||||
private readonly IntPtr pAcInstance;
|
||||
private readonly IntPtr _ACInstancePtr;
|
||||
//Contains the type of the decoder.
|
||||
public TAc_decoder_type dec_type;
|
||||
public EACDecoderType DecType;
|
||||
|
||||
//The timecode of the currently decoded picture in seconds.
|
||||
public double timecode;
|
||||
public double Timecode;
|
||||
|
||||
public double video_clock;
|
||||
public double VideoClock;
|
||||
|
||||
//Contains information about the stream the decoder is attached to.
|
||||
public TAc_stream_info stream_info;
|
||||
public SACStreamInfo StreamInfo;
|
||||
//The index of the stream the decoder is attached to.
|
||||
public Int32 stream_index;
|
||||
public Int32 StreamIndex;
|
||||
|
||||
//Pointer to the buffer which contains the data.
|
||||
internal IntPtr buffer;
|
||||
internal IntPtr Buffer;
|
||||
//Size of the data in the buffer.
|
||||
public Int32 buffer_size;
|
||||
public Int32 BufferSize;
|
||||
}
|
||||
|
||||
// Contains information about an Acinerella package.
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct TAc_package
|
||||
public struct SACPackage
|
||||
{
|
||||
//The stream the package belongs to.
|
||||
public Int32 stream_index;
|
||||
public Int32 StreamIndex;
|
||||
}
|
||||
|
||||
// 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;
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate Int32 TAc_read_callback(
|
||||
public delegate Int32 ACReadCallback(
|
||||
IntPtr sender,
|
||||
IntPtr buf,
|
||||
Int32 size
|
||||
@@ -140,38 +140,38 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
// Callback function used to ask the application to seek. return 0 if succeed , -1 on failure.
|
||||
//TAc_seek_callback = function(sender: Pointer; pos: int64; whence: integer): int64; cdecl;
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate Int64 TAc_seek_callback(IntPtr sender, Int64 pos, Int32 whence);
|
||||
public delegate Int64 ACSeekCallback(IntPtr sender, Int64 pos, Int32 whence);
|
||||
|
||||
// Callback function that is used to notify the application when the data stream
|
||||
// is opened or closed. For example the file pointer should be resetted to zero
|
||||
// when the "open" function is called.
|
||||
// TAc_openclose_callback = function(sender: Pointer): integer; cdecl;
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate Int32 TAc_openclose_callback(IntPtr sender);
|
||||
public delegate Int32 ACOpencloseCallback(IntPtr sender);
|
||||
|
||||
public static class CAcinerella
|
||||
{
|
||||
#if ARCH_X86
|
||||
#if WIN
|
||||
private const string AcDll = "x86\\acinerella.dll";
|
||||
private const string _AcDll = "x86\\acinerella.dll";
|
||||
#endif
|
||||
|
||||
#if LINUX
|
||||
private const string AcDll = "x86/libacinerella.so";
|
||||
private const string _AcDll = "x86/libacinerella.so";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ARCH_X64
|
||||
#if WIN
|
||||
private const string AcDll = "x64\\acinerella.dll";
|
||||
private const string _AcDll = "x64\\acinerella.dll";
|
||||
#endif
|
||||
|
||||
#if LINUX
|
||||
private const string AcDll = "x64/libacinerella.so";
|
||||
private const string _AcDll = "x64/libacinerella.so";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
private static readonly Object _lock = new Object();
|
||||
private static readonly Object _Lock = new Object();
|
||||
|
||||
// Defines the type of an Acinerella media stream. Currently only video and
|
||||
// audio streams are supported, subtitle and data streams will be marked as
|
||||
@@ -179,12 +179,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
|
||||
// Initializes an Acinerella instance.
|
||||
//function ac_init(): PAc_instance; cdecl; external ac_dll;
|
||||
[DllImport(AcDll, EntryPoint = "ac_init", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
[DllImport(_AcDll, EntryPoint = "ac_init", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern IntPtr _ac_init();
|
||||
|
||||
public static IntPtr ac_init()
|
||||
public static IntPtr AcInit()
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
return _ac_init();
|
||||
}
|
||||
@@ -192,14 +192,14 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
|
||||
// Frees an Acinerella instance.
|
||||
//procedure ac_free(inst: PAc_instance); cdecl; external ac_dll;
|
||||
[DllImport(AcDll, EntryPoint = "ac_free", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern void _ac_free(IntPtr PAc_instance);
|
||||
[DllImport(_AcDll, EntryPoint = "ac_free", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern void _ac_free(IntPtr pAcInstance);
|
||||
|
||||
public static void ac_free(IntPtr PAc_instance)
|
||||
public static void AcFree(IntPtr pAcInstance)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
_ac_free(PAc_instance);
|
||||
_ac_free(pAcInstance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,152 +248,152 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
}
|
||||
}*/
|
||||
|
||||
[DllImport(AcDll, EntryPoint = "ac_open", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[DllImport(_AcDll, EntryPoint = "ac_open", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
private static extern Int32 _ac_open2(
|
||||
IntPtr PAc_instance,
|
||||
IntPtr pAcInstance,
|
||||
string filename
|
||||
);
|
||||
|
||||
public static Int32 ac_open2(
|
||||
IntPtr PAc_instance,
|
||||
public static Int32 AcOpen2(
|
||||
IntPtr pAcInstance,
|
||||
string filename
|
||||
)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
return _ac_open2(PAc_instance, filename);
|
||||
return _ac_open2(pAcInstance, filename);
|
||||
}
|
||||
}
|
||||
|
||||
// Closes an opened media file.
|
||||
//procedure ac_close(inst: PAc_instance);cdecl; external ac_dll;
|
||||
[DllImport(AcDll, EntryPoint = "ac_close", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern void _ac_close(IntPtr PAc_instance);
|
||||
[DllImport(_AcDll, EntryPoint = "ac_close", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern void _ac_close(IntPtr pAcInstance);
|
||||
|
||||
public static void ac_close(IntPtr PAc_instance)
|
||||
public static void AcClose(IntPtr pAcInstance)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
_ac_close(PAc_instance);
|
||||
_ac_close(pAcInstance);
|
||||
}
|
||||
}
|
||||
|
||||
// Stores information in "pInfo" about stream number "nb".
|
||||
//procedure ac_get_stream_info(
|
||||
//inst: PAc_instance; nb: integer; pinfo: PAc_stream_info); cdecl; external ac_dll;
|
||||
[DllImport(AcDll, EntryPoint = "ac_get_stream_info", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
[DllImport(_AcDll, EntryPoint = "ac_get_stream_info", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern void _ac_get_stream_info(
|
||||
IntPtr PAc_instance,
|
||||
IntPtr pAcInstance,
|
||||
Int32 nb,
|
||||
out TAc_stream_info Info
|
||||
out SACStreamInfo info
|
||||
);
|
||||
|
||||
public static void ac_get_stream_info(
|
||||
IntPtr PAc_instance,
|
||||
public static void AcGetStreamInfo(
|
||||
IntPtr pAcInstance,
|
||||
Int32 nb,
|
||||
out TAc_stream_info Info
|
||||
out SACStreamInfo info
|
||||
)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
_ac_get_stream_info(
|
||||
PAc_instance,
|
||||
pAcInstance,
|
||||
nb,
|
||||
out Info
|
||||
out info
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Reads a package from an opened media file.
|
||||
//function ac_read_package(inst: PAc_instance): PAc_package; cdecl; external ac_dll;
|
||||
[DllImport(AcDll, EntryPoint = "ac_read_package", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
[DllImport(_AcDll, EntryPoint = "ac_read_package", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr ac_read_package(IntPtr inst);
|
||||
|
||||
// Frees a package that has been read.
|
||||
//procedure ac_free_package(package: PAc_package); cdecl; external ac_dll;
|
||||
[DllImport(AcDll, EntryPoint = "ac_free_package", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
public static extern void ac_free_package(IntPtr PAc_package);
|
||||
[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 PAc_instance);
|
||||
[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);
|
||||
|
||||
public static IntPtr ac_create_video_decoder(IntPtr PAc_instance)
|
||||
public static IntPtr AcCreateVideoDecoder(IntPtr pAcInstance)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
return _ac_create_video_decoder(PAc_instance);
|
||||
return _ac_create_video_decoder(pAcInstance);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(AcDll, EntryPoint = "ac_create_audio_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern IntPtr _ac_create_audio_decoder(IntPtr PAc_instance);
|
||||
[DllImport(_AcDll, EntryPoint = "ac_create_audio_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern IntPtr _ac_create_audio_decoder(IntPtr pAcInstance);
|
||||
|
||||
public static IntPtr ac_create_audio_decoder(IntPtr PAc_instance)
|
||||
public static IntPtr AcCreateAudioDecoder(IntPtr pAcInstance)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
return _ac_create_audio_decoder(PAc_instance);
|
||||
return _ac_create_audio_decoder(pAcInstance);
|
||||
}
|
||||
}
|
||||
|
||||
// Frees an created decoder.
|
||||
//procedure ac_free_decoder(pDecoder: PAc_decoder); cdecl; external ac_dll;
|
||||
[DllImport(AcDll, EntryPoint = "ac_free_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern void _ac_free_decoder(IntPtr PAc_decoder);
|
||||
[DllImport(_AcDll, EntryPoint = "ac_free_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern void _ac_free_decoder(IntPtr pAcDecoder);
|
||||
|
||||
public static void ac_free_decoder(IntPtr PAc_decoder)
|
||||
public static void AcFreeDecoder(IntPtr pAcDecoder)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
_ac_free_decoder(PAc_decoder);
|
||||
_ac_free_decoder(pAcDecoder);
|
||||
}
|
||||
}
|
||||
|
||||
// Decodes a package using the specified decoder. The decodec data is stored in the
|
||||
// "buffer" property of the decoder.
|
||||
//function ac_decode_package(pPackage: PAc_package; pDecoder: PAc_decoder): integer; cdecl; external ac_dll;
|
||||
[DllImport(AcDll, EntryPoint = "ac_decode_package", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern Int32 _ac_decode_package(IntPtr PAc_package, IntPtr PAc_decoder);
|
||||
[DllImport(_AcDll, EntryPoint = "ac_decode_package", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern Int32 _ac_decode_package(IntPtr pAcPackage, IntPtr pAcDecoder);
|
||||
|
||||
public static Int32 ac_decode_package(IntPtr PAc_package, IntPtr PAc_decoder)
|
||||
public static Int32 AcDecodePackage(IntPtr pAcPackage, IntPtr pAcDecoder)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
return _ac_decode_package(PAc_package, PAc_decoder);
|
||||
return _ac_decode_package(pAcPackage, pAcDecoder);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(AcDll, EntryPoint = "ac_get_audio_frame", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern Int32 _ac_get_audio_frame(IntPtr PAcInstance, IntPtr PAc_decoder);
|
||||
[DllImport(_AcDll, EntryPoint = "ac_get_audio_frame", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern Int32 _ac_get_audio_frame(IntPtr pAcInstance, IntPtr pAcDecoder);
|
||||
|
||||
public static Int32 ac_get_audio_frame(IntPtr PAcInstance, IntPtr PAc_decoder)
|
||||
public static Int32 AcGetAudioFrame(IntPtr pAcInstance, IntPtr pAcDecoder)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
return _ac_get_audio_frame(PAcInstance, PAc_decoder);
|
||||
return _ac_get_audio_frame(pAcInstance, pAcDecoder);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(AcDll, EntryPoint = "ac_get_frame", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern Int32 _ac_get_frame(IntPtr PAcInstance, IntPtr PAc_decoder);
|
||||
[DllImport(_AcDll, EntryPoint = "ac_get_frame", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern Int32 _ac_get_frame(IntPtr pAcInstance, IntPtr pAcDecoder);
|
||||
|
||||
public static Int32 ac_get_frame(IntPtr PAcInstance, IntPtr PAc_decoder)
|
||||
public static Int32 AcGetFrame(IntPtr pAcInstance, IntPtr pAcDecoder)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
return _ac_get_frame(PAcInstance, PAc_decoder);
|
||||
return _ac_get_frame(pAcInstance, pAcDecoder);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(AcDll, EntryPoint = "ac_skip_frames", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern Int32 _ac_skip_frames(IntPtr PAcInstance, IntPtr PAc_decoder, Int32 num);
|
||||
[DllImport(_AcDll, EntryPoint = "ac_skip_frames", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern Int32 _ac_skip_frames(IntPtr pAcInstance, IntPtr pAcDecoder, Int32 num);
|
||||
|
||||
public static Int32 ac_skip_frames(IntPtr PAcInstance, IntPtr PAc_decoder, Int32 num)
|
||||
public static Int32 AcSkipFrames(IntPtr pAcInstance, IntPtr pAcDecoder, Int32 num)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
return _ac_skip_frames(PAcInstance, PAc_decoder, num);
|
||||
return _ac_skip_frames(pAcInstance, pAcDecoder, num);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,25 +402,25 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
// The parameter "dir" specifies the seek direction: 0 for forward, -1 for backward.
|
||||
// The target_pos paremeter is in milliseconds. Returns 1 if the functions succeded.}
|
||||
//function ac_seek(pDecoder: PAc_decoder; dir: integer; target_pos: int64): integer; cdecl; external ac_dll;
|
||||
[DllImport(AcDll, EntryPoint = "ac_seek", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
private static extern Int32 _ac_seek(IntPtr PAc_decoder, Int32 dir, Int64 target_pos);
|
||||
[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);
|
||||
|
||||
public static Int32 ac_seek(IntPtr PAc_decoder, Int32 dir, Int64 target_pos)
|
||||
public static Int32 AcSeek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos)
|
||||
{
|
||||
lock (_lock)
|
||||
lock (_Lock)
|
||||
{
|
||||
return _ac_seek(PAc_decoder, dir, target_pos);
|
||||
return _ac_seek(pAcDecoder, dir, targetPos);
|
||||
}
|
||||
}
|
||||
|
||||
//function ac_probe_input_buffer(buf: PChar; bufsize: Integer; filename: PChar;
|
||||
//var score_max: Integer): PAc_proberesult; cdecl; external ac_dll;
|
||||
[DllImport(AcDll, EntryPoint = "ac_probe_input_buffer", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
[DllImport(_AcDll, EntryPoint = "ac_probe_input_buffer", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr ac_probe_input_buffer(
|
||||
IntPtr buf,
|
||||
Int32 bufsize,
|
||||
IntPtr filename,
|
||||
out Int32 score_max
|
||||
out Int32 scoreMax
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,12 @@ namespace Vocaluxe.Lib.Video
|
||||
{
|
||||
abstract class CVideoDecoder : IVideoDecoder
|
||||
{
|
||||
protected List<VideoStreams> _Streams = new List<VideoStreams>();
|
||||
protected List<SVideoStreams> _Streams = new List<SVideoStreams>();
|
||||
protected bool _Initialized = false;
|
||||
|
||||
public virtual bool Init()
|
||||
{
|
||||
_Streams = new List<VideoStreams>();
|
||||
_Streams = new List<SVideoStreams>();
|
||||
_Initialized = true;
|
||||
|
||||
return true;
|
||||
@@ -23,59 +23,59 @@ namespace Vocaluxe.Lib.Video
|
||||
return _Streams.Count;
|
||||
}
|
||||
|
||||
public virtual int Load(string VideoFileName)
|
||||
public virtual int Load(string videoFileName)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public virtual bool Close(int StreamID)
|
||||
public virtual bool Close(int streamID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual float GetLength(int StreamID)
|
||||
public virtual float GetLength(int streamID)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public virtual bool GetFrame(int StreamID, ref STexture Frame, float Time, ref float VideoTime)
|
||||
public virtual bool GetFrame(int streamID, ref STexture frame, float time, ref float videoTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool Skip(int StreamID, float Start, float Gap)
|
||||
public virtual bool Skip(int streamID, float start, float gap)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void SetLoop(int StreamID, bool Loop) {}
|
||||
public virtual void SetLoop(int streamID, bool loop) {}
|
||||
|
||||
public virtual void Pause(int StreamID) {}
|
||||
public virtual void Pause(int streamID) {}
|
||||
|
||||
public virtual void Resume(int StreamID) {}
|
||||
public virtual void Resume(int streamID) {}
|
||||
|
||||
public virtual bool Finished(int StreamID)
|
||||
public virtual bool Finished(int streamID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void Update() {}
|
||||
|
||||
protected bool AlreadyAdded(int StreamID)
|
||||
protected bool _AlreadyAdded(int streamID)
|
||||
{
|
||||
foreach (VideoStreams st in _Streams)
|
||||
foreach (SVideoStreams st in _Streams)
|
||||
{
|
||||
if (st.handle == StreamID)
|
||||
if (st.Handle == streamID)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int GetStreamIndex(int StreamID)
|
||||
protected int _GetStreamIndex(int streamID)
|
||||
{
|
||||
for (int i = 0; i < _Streams.Count; i++)
|
||||
{
|
||||
if (_Streams[i].handle == StreamID)
|
||||
if (_Streams[i].Handle == streamID)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -10,19 +10,19 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Lib.Video
|
||||
{
|
||||
delegate void CLOSEPROC(int StreamID);
|
||||
delegate void Closeproc(int streamID);
|
||||
|
||||
class CVideoDecoderFFmpeg : CVideoDecoder
|
||||
{
|
||||
private readonly List<Decoder> _Decoder = new List<Decoder>();
|
||||
private CLOSEPROC closeproc;
|
||||
private readonly List<CDecoder> _Decoder = new List<CDecoder>();
|
||||
private Closeproc _Closeproc;
|
||||
private int _Count = 1;
|
||||
|
||||
private readonly Object MutexDecoder = new Object();
|
||||
private readonly Object _MutexDecoder = new Object();
|
||||
|
||||
public override bool Init()
|
||||
{
|
||||
closeproc = close_proc;
|
||||
_Closeproc = _CloseProc;
|
||||
CloseAll();
|
||||
|
||||
return base.Init();
|
||||
@@ -30,41 +30,41 @@ namespace Vocaluxe.Lib.Video
|
||||
|
||||
public override void CloseAll()
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
for (int i = 0; i < _Decoder.Count; i++)
|
||||
_Decoder[i].Free(closeproc, i + 1);
|
||||
_Decoder[i].Free(_Closeproc, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public override int Load(string VideoFileName)
|
||||
public override int Load(string videoFileName)
|
||||
{
|
||||
VideoStreams stream = new VideoStreams(0);
|
||||
Decoder decoder = new Decoder();
|
||||
SVideoStreams stream = new SVideoStreams(0);
|
||||
CDecoder decoder = new CDecoder();
|
||||
|
||||
if (decoder.Open(VideoFileName))
|
||||
if (decoder.Open(videoFileName))
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
_Decoder.Add(decoder);
|
||||
stream.handle = _Count++;
|
||||
stream.file = VideoFileName;
|
||||
stream.Handle = _Count++;
|
||||
stream.File = videoFileName;
|
||||
_Streams.Add(stream);
|
||||
return stream.handle;
|
||||
return stream.Handle;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override bool Close(int StreamID)
|
||||
public override bool Close(int streamID)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(StreamID))
|
||||
if (_AlreadyAdded(streamID))
|
||||
{
|
||||
_Decoder[GetStreamIndex(StreamID)].Free(closeproc, StreamID);
|
||||
_Decoder[_GetStreamIndex(streamID)].Free(_Closeproc, streamID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -72,105 +72,105 @@ 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, ref float videoTime)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(StreamID))
|
||||
return _Decoder[GetStreamIndex(StreamID)].GetFrame(ref Frame, Time, ref VideoTime);
|
||||
if (_AlreadyAdded(streamID))
|
||||
return _Decoder[_GetStreamIndex(streamID)].GetFrame(ref frame, time, ref videoTime);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override float GetLength(int StreamID)
|
||||
public override float GetLength(int streamID)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(StreamID))
|
||||
return _Decoder[GetStreamIndex(StreamID)].Length;
|
||||
if (_AlreadyAdded(streamID))
|
||||
return _Decoder[_GetStreamIndex(streamID)].Length;
|
||||
}
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public override bool Skip(int StreamID, float Start, float Gap)
|
||||
public override bool Skip(int streamID, float start, float gap)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(StreamID))
|
||||
return _Decoder[GetStreamIndex(StreamID)].Skip(Start, Gap);
|
||||
if (_AlreadyAdded(streamID))
|
||||
return _Decoder[_GetStreamIndex(streamID)].Skip(start, gap);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void SetLoop(int StreamID, bool Loop)
|
||||
public override void SetLoop(int streamID, bool loop)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(StreamID))
|
||||
_Decoder[GetStreamIndex(StreamID)].Loop = Loop;
|
||||
if (_AlreadyAdded(streamID))
|
||||
_Decoder[_GetStreamIndex(streamID)].Loop = loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Pause(int StreamID)
|
||||
public override void Pause(int streamID)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(StreamID))
|
||||
_Decoder[GetStreamIndex(StreamID)].Paused = true;
|
||||
if (_AlreadyAdded(streamID))
|
||||
_Decoder[_GetStreamIndex(streamID)].Paused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Resume(int StreamID)
|
||||
public override void Resume(int streamID)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(StreamID))
|
||||
_Decoder[GetStreamIndex(StreamID)].Paused = false;
|
||||
if (_AlreadyAdded(streamID))
|
||||
_Decoder[_GetStreamIndex(streamID)].Paused = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Finished(int StreamID)
|
||||
public override bool Finished(int streamID)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(StreamID))
|
||||
return _Decoder[GetStreamIndex(StreamID)].Finished;
|
||||
if (_AlreadyAdded(streamID))
|
||||
return _Decoder[_GetStreamIndex(streamID)].Finished;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void close_proc(int StreamID)
|
||||
private void _CloseProc(int streamID)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(StreamID))
|
||||
if (_AlreadyAdded(streamID))
|
||||
{
|
||||
int Index = GetStreamIndex(StreamID);
|
||||
_Decoder.RemoveAt(Index);
|
||||
_Streams.RemoveAt(Index);
|
||||
int index = _GetStreamIndex(streamID);
|
||||
_Decoder.RemoveAt(index);
|
||||
_Streams.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,18 +179,18 @@ namespace Vocaluxe.Lib.Video
|
||||
|
||||
struct SFrameBuffer
|
||||
{
|
||||
public byte[] data;
|
||||
public float time;
|
||||
public bool displayed;
|
||||
public byte[] Data;
|
||||
public float Time;
|
||||
public bool Displayed;
|
||||
}
|
||||
|
||||
class Decoder : IDisposable
|
||||
class CDecoder : IDisposable
|
||||
{
|
||||
private IntPtr _instance = IntPtr.Zero; // acinerella instance
|
||||
private IntPtr _videodecoder = IntPtr.Zero; // acinerella video decoder instance
|
||||
private IntPtr _Instance = IntPtr.Zero; // acinerella instance
|
||||
private IntPtr _Videodecoder = IntPtr.Zero; // acinerella video decoder instance
|
||||
|
||||
private readonly Stopwatch _LoopTimer = new Stopwatch();
|
||||
private CLOSEPROC _Closeproc; // delegate for stream closing
|
||||
private Closeproc _Closeproc; // delegate for stream closing
|
||||
private int _StreamID; // stream ID for stream closing
|
||||
private string _FileName; // current video file name
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace Vocaluxe.Lib.Video
|
||||
private float _CurrentVideoTime; // current video position
|
||||
private bool _BufferFull; // buffer is full, waiting for free frame slot
|
||||
|
||||
private bool _skip; // do skip
|
||||
private bool _Skip; // do skip
|
||||
private float _Time;
|
||||
private float _Gap;
|
||||
private float _Start;
|
||||
@@ -222,25 +222,25 @@ namespace Vocaluxe.Lib.Video
|
||||
private float _SetStart;
|
||||
private bool _SetLoop;
|
||||
private bool _SetSkip;
|
||||
private bool _terminated;
|
||||
private bool _Terminated;
|
||||
|
||||
private readonly Thread _thread;
|
||||
private readonly Thread _Thread;
|
||||
//AutoResetEvent EventDecode = new AutoResetEvent(false);
|
||||
private readonly SFrameBuffer[] _FrameBuffer = new SFrameBuffer[5];
|
||||
private bool _NewFrame;
|
||||
private readonly Object MutexFramebuffer = new Object();
|
||||
private readonly Object MutexSyncSignals = new Object();
|
||||
private readonly Object _MutexFramebuffer = new Object();
|
||||
private readonly Object _MutexSyncSignals = new Object();
|
||||
|
||||
public Decoder()
|
||||
public CDecoder()
|
||||
{
|
||||
_thread = new Thread(Execute);
|
||||
_Thread = new Thread(_Execute);
|
||||
}
|
||||
|
||||
public void Free(CLOSEPROC close_proc, int StreamID)
|
||||
public void Free(Closeproc closeProc, int streamID)
|
||||
{
|
||||
_Closeproc = close_proc;
|
||||
_StreamID = StreamID;
|
||||
_terminated = true;
|
||||
_Closeproc = closeProc;
|
||||
_StreamID = streamID;
|
||||
_Terminated = true;
|
||||
}
|
||||
|
||||
public float Length
|
||||
@@ -259,7 +259,7 @@ namespace Vocaluxe.Lib.Video
|
||||
get { return _Paused; }
|
||||
set
|
||||
{
|
||||
lock (MutexSyncSignals)
|
||||
lock (_MutexSyncSignals)
|
||||
{
|
||||
_Paused = value;
|
||||
if (_Paused)
|
||||
@@ -281,22 +281,22 @@ namespace Vocaluxe.Lib.Video
|
||||
get { return _Finished; }
|
||||
}
|
||||
|
||||
public bool Open(string FileName)
|
||||
public bool Open(string fileName)
|
||||
{
|
||||
if (_FileOpened)
|
||||
return false;
|
||||
|
||||
if (!File.Exists(FileName))
|
||||
if (!File.Exists(fileName))
|
||||
return false;
|
||||
|
||||
_FileName = FileName;
|
||||
_thread.Priority = ThreadPriority.Normal;
|
||||
_thread.Name = Path.GetFileName(FileName);
|
||||
_thread.Start();
|
||||
_FileName = fileName;
|
||||
_Thread.Priority = ThreadPriority.Normal;
|
||||
_Thread.Name = Path.GetFileName(fileName);
|
||||
_Thread.Start();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool GetFrame(ref STexture frame, float Time, ref float VideoTime)
|
||||
public bool GetFrame(ref STexture frame, float time, ref float videoTime)
|
||||
{
|
||||
if (!_FileOpened)
|
||||
return false;
|
||||
@@ -306,10 +306,10 @@ namespace Vocaluxe.Lib.Video
|
||||
|
||||
if (_SetLoop)
|
||||
{
|
||||
lock (MutexSyncSignals)
|
||||
lock (_MutexSyncSignals)
|
||||
{
|
||||
_SetTime += _LoopTimer.ElapsedMilliseconds / 1000f;
|
||||
VideoTime = _SetTime;
|
||||
videoTime = _SetTime;
|
||||
|
||||
_LoopTimer.Stop();
|
||||
_LoopTimer.Reset();
|
||||
@@ -317,31 +317,31 @@ namespace Vocaluxe.Lib.Video
|
||||
}
|
||||
|
||||
|
||||
UploadNewFrame(ref frame);
|
||||
_UploadNewFrame(ref frame);
|
||||
//EventDecode.Set();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_SetTime != Time)
|
||||
if (_SetTime != time)
|
||||
{
|
||||
lock (MutexSyncSignals)
|
||||
lock (_MutexSyncSignals)
|
||||
{
|
||||
_SetTime = Time;
|
||||
_SetTime = time;
|
||||
}
|
||||
UploadNewFrame(ref frame);
|
||||
VideoTime = _CurrentVideoTime;
|
||||
_UploadNewFrame(ref frame);
|
||||
videoTime = _CurrentVideoTime;
|
||||
//EventDecode.Set();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Skip(float Start, float Gap)
|
||||
public bool Skip(float start, float gap)
|
||||
{
|
||||
lock (MutexSyncSignals)
|
||||
lock (_MutexSyncSignals)
|
||||
{
|
||||
_SetStart = Start;
|
||||
_SetGap = Gap;
|
||||
_SetStart = start;
|
||||
_SetGap = gap;
|
||||
_SetSkip = true;
|
||||
_NoMoreFrames = false;
|
||||
_Finished = false;
|
||||
@@ -351,7 +351,7 @@ namespace Vocaluxe.Lib.Video
|
||||
}
|
||||
|
||||
#region Threading
|
||||
private void DoSkip()
|
||||
private void _DoSkip()
|
||||
{
|
||||
if (!_FileOpened)
|
||||
return;
|
||||
@@ -365,7 +365,7 @@ namespace Vocaluxe.Lib.Video
|
||||
_VideoDecoderTime = _SkipTime;
|
||||
try
|
||||
{
|
||||
CAcinerella.ac_seek(_videodecoder, -1, (Int64)(_SkipTime * 1000f));
|
||||
CAcinerella.AcSeek(_Videodecoder, -1, (Int64)(_SkipTime * 1000f));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -377,7 +377,7 @@ namespace Vocaluxe.Lib.Video
|
||||
_VideoDecoderTime = 0f;
|
||||
try
|
||||
{
|
||||
CAcinerella.ac_seek(_videodecoder, -1, 0);
|
||||
CAcinerella.AcSeek(_Videodecoder, -1, 0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -385,39 +385,39 @@ namespace Vocaluxe.Lib.Video
|
||||
}
|
||||
}
|
||||
|
||||
lock (MutexSyncSignals)
|
||||
lock (_MutexSyncSignals)
|
||||
{
|
||||
_CurrentVideoTime = _VideoDecoderTime;
|
||||
}
|
||||
|
||||
lock (MutexFramebuffer)
|
||||
lock (_MutexFramebuffer)
|
||||
{
|
||||
for (int i = 0; i < _FrameBuffer.Length; i++)
|
||||
{
|
||||
_FrameBuffer[i].displayed = true;
|
||||
_FrameBuffer[i].time = -1f;
|
||||
_FrameBuffer[i].Displayed = true;
|
||||
_FrameBuffer[i].Time = -1f;
|
||||
}
|
||||
}
|
||||
|
||||
_BufferFull = false;
|
||||
_skip = false;
|
||||
_Skip = false;
|
||||
_NewFrame = false;
|
||||
//EventDecode.Set();
|
||||
}
|
||||
|
||||
private void Execute()
|
||||
private void _Execute()
|
||||
{
|
||||
DoOpen();
|
||||
_DoOpen();
|
||||
//EventDecode.Set();
|
||||
while (!_terminated)
|
||||
while (!_Terminated)
|
||||
{
|
||||
{
|
||||
//if (EventDecode.WaitOne(10))
|
||||
lock (MutexSyncSignals)
|
||||
lock (_MutexSyncSignals)
|
||||
{
|
||||
_Time = _SetTime;
|
||||
if (_SetSkip)
|
||||
_skip = true;
|
||||
_Skip = true;
|
||||
|
||||
_SetSkip = false;
|
||||
_Gap = _SetGap;
|
||||
@@ -425,32 +425,32 @@ namespace Vocaluxe.Lib.Video
|
||||
_Loop = _SetLoop;
|
||||
}
|
||||
|
||||
if (_skip)
|
||||
DoSkip();
|
||||
if (_Skip)
|
||||
_DoSkip();
|
||||
|
||||
if (!_NewFrame)
|
||||
DoDecode();
|
||||
_DoDecode();
|
||||
|
||||
if (_NewFrame)
|
||||
Copy();
|
||||
_Copy();
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
DoFree();
|
||||
_DoFree();
|
||||
}
|
||||
|
||||
private void DoOpen()
|
||||
private void _DoOpen()
|
||||
{
|
||||
bool ok = false;
|
||||
TAc_instance Instance = new TAc_instance();
|
||||
SACInstance instance = new SACInstance();
|
||||
try
|
||||
{
|
||||
_instance = CAcinerella.ac_init();
|
||||
CAcinerella.ac_open2(_instance, _FileName);
|
||||
_Instance = CAcinerella.AcInit();
|
||||
CAcinerella.AcOpen2(_Instance, _FileName);
|
||||
|
||||
Instance = (TAc_instance)Marshal.PtrToStructure(_instance, typeof(TAc_instance));
|
||||
ok = Instance.opened;
|
||||
instance = (SACInstance)Marshal.PtrToStructure(_Instance, typeof(SACInstance));
|
||||
ok = instance.Opened;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -459,21 +459,21 @@ namespace Vocaluxe.Lib.Video
|
||||
}
|
||||
|
||||
|
||||
if (!Instance.opened || !ok)
|
||||
if (!instance.Opened || !ok)
|
||||
{
|
||||
//Free();
|
||||
return;
|
||||
}
|
||||
|
||||
_Duration = Instance.info.duration / 1000f;
|
||||
_Duration = instance.Info.Duration / 1000f;
|
||||
|
||||
int VideoStreamIndex = -1;
|
||||
TAc_decoder Videodecoder;
|
||||
int videoStreamIndex = -1;
|
||||
SACDecoder videodecoder;
|
||||
try
|
||||
{
|
||||
_videodecoder = CAcinerella.ac_create_video_decoder(_instance);
|
||||
Videodecoder = (TAc_decoder)Marshal.PtrToStructure(_videodecoder, typeof(TAc_decoder));
|
||||
VideoStreamIndex = Videodecoder.stream_index;
|
||||
_Videodecoder = CAcinerella.AcCreateVideoDecoder(_Instance);
|
||||
videodecoder = (SACDecoder)Marshal.PtrToStructure(_Videodecoder, typeof(SACDecoder));
|
||||
videoStreamIndex = videodecoder.StreamIndex;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -482,33 +482,33 @@ namespace Vocaluxe.Lib.Video
|
||||
}
|
||||
|
||||
|
||||
if (VideoStreamIndex < 0)
|
||||
if (videoStreamIndex < 0)
|
||||
{
|
||||
//Free();
|
||||
return;
|
||||
}
|
||||
|
||||
_Width = Videodecoder.stream_info.video_info.frame_width;
|
||||
_Height = Videodecoder.stream_info.video_info.frame_height;
|
||||
_Width = videodecoder.StreamInfo.VideoInfo.FrameWidth;
|
||||
_Height = videodecoder.StreamInfo.VideoInfo.FrameHeight;
|
||||
|
||||
if (Videodecoder.stream_info.video_info.frames_per_second > 0)
|
||||
_VideoTimeBase = 1f / (float)Videodecoder.stream_info.video_info.frames_per_second;
|
||||
if (videodecoder.StreamInfo.VideoInfo.FramesPerSecond > 0)
|
||||
_VideoTimeBase = 1f / (float)videodecoder.StreamInfo.VideoInfo.FramesPerSecond;
|
||||
|
||||
_VideoDecoderTime = 0f;
|
||||
_Time = 0f;
|
||||
|
||||
for (int i = 0; i < _FrameBuffer.Length; i++)
|
||||
{
|
||||
_FrameBuffer[i].time = -1f;
|
||||
_FrameBuffer[i].displayed = true;
|
||||
_FrameBuffer[i].data = new byte[_Width * _Height * 4];
|
||||
_FrameBuffer[i].Time = -1f;
|
||||
_FrameBuffer[i].Displayed = true;
|
||||
_FrameBuffer[i].Data = new byte[_Width * _Height * 4];
|
||||
}
|
||||
_FileOpened = true;
|
||||
}
|
||||
|
||||
private void DoDecode()
|
||||
private void _DoDecode()
|
||||
{
|
||||
const int FRAMEDROPCOUNT = 4;
|
||||
const int framedropcount = 4;
|
||||
|
||||
if (!_FileOpened || _NewFrame)
|
||||
return;
|
||||
@@ -520,21 +520,21 @@ namespace Vocaluxe.Lib.Video
|
||||
_SkipTime = 0f;
|
||||
|
||||
float myTime = _Time + _VideoSkipTime;
|
||||
float TimeDifference = myTime - _VideoDecoderTime;
|
||||
float timeDifference = myTime - _VideoDecoderTime;
|
||||
|
||||
bool DropFrame = false;
|
||||
if (TimeDifference >= (FRAMEDROPCOUNT - 1) * _VideoTimeBase)
|
||||
DropFrame = true;
|
||||
bool dropFrame = false;
|
||||
if (timeDifference >= (framedropcount - 1) * _VideoTimeBase)
|
||||
dropFrame = true;
|
||||
|
||||
if (_terminated)
|
||||
if (_Terminated)
|
||||
return;
|
||||
|
||||
int FrameFinished = 0;
|
||||
if (DropFrame && !_BeforeLoop)
|
||||
int frameFinished = 0;
|
||||
if (dropFrame && !_BeforeLoop)
|
||||
{
|
||||
try
|
||||
{
|
||||
FrameFinished = CAcinerella.ac_skip_frames(_instance, _videodecoder, FRAMEDROPCOUNT - 1);
|
||||
frameFinished = CAcinerella.AcSkipFrames(_Instance, _Videodecoder, framedropcount - 1);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -542,11 +542,11 @@ namespace Vocaluxe.Lib.Video
|
||||
}
|
||||
}
|
||||
|
||||
if (!_BeforeLoop && (!DropFrame || FrameFinished != 0))
|
||||
if (!_BeforeLoop && (!dropFrame || frameFinished != 0))
|
||||
{
|
||||
try
|
||||
{
|
||||
FrameFinished = CAcinerella.ac_get_frame(_instance, _videodecoder);
|
||||
frameFinished = CAcinerella.AcGetFrame(_Instance, _Videodecoder);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -554,7 +554,7 @@ namespace Vocaluxe.Lib.Video
|
||||
}
|
||||
}
|
||||
|
||||
if (FrameFinished == 0)
|
||||
if (frameFinished == 0)
|
||||
{
|
||||
if (_Loop)
|
||||
{
|
||||
@@ -562,32 +562,32 @@ namespace Vocaluxe.Lib.Video
|
||||
bool doskip = true;
|
||||
float tm = 0f;
|
||||
int num = -1;
|
||||
lock (MutexFramebuffer)
|
||||
lock (_MutexFramebuffer)
|
||||
{
|
||||
for (int i = 0; i < _FrameBuffer.Length; i++)
|
||||
{
|
||||
if (_FrameBuffer[i].time > tm && !_FrameBuffer[i].displayed)
|
||||
if (_FrameBuffer[i].Time > tm && !_FrameBuffer[i].Displayed)
|
||||
{
|
||||
tm = _FrameBuffer[i].time;
|
||||
tm = _FrameBuffer[i].Time;
|
||||
num = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (num >= 0)
|
||||
doskip = _FrameBuffer[num].displayed;
|
||||
doskip = _FrameBuffer[num].Displayed;
|
||||
}
|
||||
|
||||
if (!doskip)
|
||||
return;
|
||||
|
||||
lock (MutexSyncSignals)
|
||||
lock (_MutexSyncSignals)
|
||||
{
|
||||
_Start = 0f;
|
||||
_Gap = 0f;
|
||||
_SetTime = 0f;
|
||||
}
|
||||
|
||||
DoSkip();
|
||||
_DoSkip();
|
||||
}
|
||||
else
|
||||
_NoMoreFrames = true;
|
||||
@@ -596,22 +596,22 @@ namespace Vocaluxe.Lib.Video
|
||||
else
|
||||
{
|
||||
_NewFrame = true;
|
||||
Copy();
|
||||
_Copy();
|
||||
}
|
||||
}
|
||||
|
||||
private void Copy()
|
||||
private void _Copy()
|
||||
{
|
||||
if (!_NewFrame)
|
||||
return;
|
||||
|
||||
int num = -1;
|
||||
|
||||
lock (MutexFramebuffer)
|
||||
lock (_MutexFramebuffer)
|
||||
{
|
||||
for (int i = 0; i < _FrameBuffer.Length; i++)
|
||||
{
|
||||
if (_FrameBuffer[i].displayed)
|
||||
if (_FrameBuffer[i].Displayed)
|
||||
{
|
||||
num = i;
|
||||
break;
|
||||
@@ -622,22 +622,22 @@ namespace Vocaluxe.Lib.Video
|
||||
_BufferFull = true;
|
||||
else
|
||||
{
|
||||
TAc_decoder Videodecoder = (TAc_decoder)Marshal.PtrToStructure(_videodecoder, typeof(TAc_decoder));
|
||||
SACDecoder videodecoder = (SACDecoder)Marshal.PtrToStructure(_Videodecoder, typeof(SACDecoder));
|
||||
|
||||
_VideoDecoderTime = (float)Videodecoder.timecode;
|
||||
_FrameBuffer[num].time = _VideoDecoderTime;
|
||||
_VideoDecoderTime = (float)videodecoder.Timecode;
|
||||
_FrameBuffer[num].Time = _VideoDecoderTime;
|
||||
|
||||
if (Videodecoder.buffer != IntPtr.Zero)
|
||||
if (videodecoder.Buffer != IntPtr.Zero)
|
||||
{
|
||||
Marshal.Copy(Videodecoder.buffer, _FrameBuffer[num].data, 0, _Width * _Height * 4);
|
||||
Marshal.Copy(videodecoder.Buffer, _FrameBuffer[num].Data, 0, _Width * _Height * 4);
|
||||
|
||||
_FrameBuffer[num].displayed = false;
|
||||
_FrameBuffer[num].Displayed = false;
|
||||
}
|
||||
|
||||
int numfull = 0;
|
||||
for (int i = 0; i < _FrameBuffer.Length; i++)
|
||||
{
|
||||
if (!_FrameBuffer[i].displayed)
|
||||
if (!_FrameBuffer[i].Displayed)
|
||||
numfull++;
|
||||
}
|
||||
|
||||
@@ -649,28 +649,28 @@ namespace Vocaluxe.Lib.Video
|
||||
}
|
||||
}
|
||||
|
||||
private void UploadNewFrame(ref STexture frame)
|
||||
private void _UploadNewFrame(ref STexture frame)
|
||||
{
|
||||
if (!_FileOpened)
|
||||
return;
|
||||
|
||||
lock (MutexFramebuffer)
|
||||
lock (_MutexFramebuffer)
|
||||
{
|
||||
int num = FindFrame();
|
||||
int num = _FindFrame();
|
||||
|
||||
if (num >= 0)
|
||||
{
|
||||
if (frame.index == -1 || _Width != frame.width || _Height != frame.height)
|
||||
if (frame.Index == -1 || _Width != frame.Width || _Height != frame.Height)
|
||||
{
|
||||
CDraw.RemoveTexture(ref frame);
|
||||
frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].data);
|
||||
frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].Data);
|
||||
}
|
||||
else
|
||||
CDraw.UpdateTexture(ref frame, ref _FrameBuffer[num].data);
|
||||
CDraw.UpdateTexture(ref frame, ref _FrameBuffer[num].Data);
|
||||
|
||||
lock (MutexSyncSignals)
|
||||
lock (_MutexSyncSignals)
|
||||
{
|
||||
_CurrentVideoTime = _FrameBuffer[num].time;
|
||||
_CurrentVideoTime = _FrameBuffer[num].Time;
|
||||
}
|
||||
_Finished = false;
|
||||
}
|
||||
@@ -682,44 +682,44 @@ namespace Vocaluxe.Lib.Video
|
||||
}
|
||||
}
|
||||
|
||||
private int FindFrame()
|
||||
private int _FindFrame()
|
||||
{
|
||||
int Result = -1;
|
||||
int result = -1;
|
||||
float diff = 10000000f;
|
||||
|
||||
for (int i = 0; i < _FrameBuffer.Length; i++)
|
||||
{
|
||||
float td = _SetTime + _VideoSkipTime - _FrameBuffer[i].time;
|
||||
float td = _SetTime + _VideoSkipTime - _FrameBuffer[i].Time;
|
||||
|
||||
if (td > _VideoTimeBase * 2f)
|
||||
_FrameBuffer[i].displayed = true;
|
||||
_FrameBuffer[i].Displayed = true;
|
||||
|
||||
if (!_FrameBuffer[i].displayed && (td < diff) && (td > _VideoTimeBase))
|
||||
if (!_FrameBuffer[i].Displayed && (td < diff) && (td > _VideoTimeBase))
|
||||
{
|
||||
diff = Math.Abs(_FrameBuffer[i].time - _SetTime - _VideoSkipTime);
|
||||
Result = i;
|
||||
diff = Math.Abs(_FrameBuffer[i].Time - _SetTime - _VideoSkipTime);
|
||||
result = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (Result != -1)
|
||||
if (result != -1)
|
||||
{
|
||||
_FrameBuffer[Result].displayed = true;
|
||||
_FrameBuffer[result].Displayed = true;
|
||||
_BufferFull = false;
|
||||
}
|
||||
|
||||
return Result;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void DoFree()
|
||||
private void _DoFree()
|
||||
{
|
||||
if (_videodecoder != IntPtr.Zero)
|
||||
CAcinerella.ac_free_decoder(_videodecoder);
|
||||
if (_Videodecoder != IntPtr.Zero)
|
||||
CAcinerella.AcFreeDecoder(_Videodecoder);
|
||||
|
||||
if (_instance != IntPtr.Zero)
|
||||
CAcinerella.ac_close(_instance);
|
||||
if (_Instance != IntPtr.Zero)
|
||||
CAcinerella.AcClose(_Instance);
|
||||
|
||||
if (_instance != IntPtr.Zero)
|
||||
CAcinerella.ac_free(_instance);
|
||||
if (_Instance != IntPtr.Zero)
|
||||
CAcinerella.AcFree(_Instance);
|
||||
|
||||
_Closeproc(_StreamID);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Vocaluxe.Lib.Video
|
||||
#region log
|
||||
public CGstreamerVideoWrapper.LogCallback Log;
|
||||
|
||||
private void LogHandler(string text)
|
||||
private void _LogHandler(string text)
|
||||
{
|
||||
CLog.LogError(text);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ 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);
|
||||
@@ -31,12 +31,12 @@ namespace Vocaluxe.Lib.Video
|
||||
CGstreamerVideoWrapper.CloseAllVideos();
|
||||
}
|
||||
|
||||
public int Load(string VideoFileName)
|
||||
public int Load(string videoFileName)
|
||||
{
|
||||
int i = -1;
|
||||
try
|
||||
{
|
||||
Uri u = new Uri(VideoFileName);
|
||||
Uri u = new Uri(videoFileName);
|
||||
i = CGstreamerVideoWrapper.LoadVideo(u.AbsoluteUri);
|
||||
return i;
|
||||
}
|
||||
@@ -44,9 +44,9 @@ namespace Vocaluxe.Lib.Video
|
||||
return i;
|
||||
}
|
||||
|
||||
public bool Close(int StreamID)
|
||||
public bool Close(int streamID)
|
||||
{
|
||||
return CGstreamerVideoWrapper.CloseVideo(StreamID);
|
||||
return CGstreamerVideoWrapper.CloseVideo(streamID);
|
||||
}
|
||||
|
||||
public int GetNumStreams()
|
||||
@@ -54,43 +54,43 @@ namespace Vocaluxe.Lib.Video
|
||||
return CGstreamerVideoWrapper.GetVideoNumStreams();
|
||||
}
|
||||
|
||||
public float GetLength(int StreamID)
|
||||
public float GetLength(int streamID)
|
||||
{
|
||||
return CGstreamerVideoWrapper.GetVideoLength(StreamID);
|
||||
return CGstreamerVideoWrapper.GetVideoLength(streamID);
|
||||
}
|
||||
|
||||
public bool GetFrame(int StreamID, ref STexture Frame, float Time, ref float VideoTime)
|
||||
public bool GetFrame(int streamID, ref STexture frame, float time, ref float videoTime)
|
||||
{
|
||||
ManagedFrame frame = CGstreamerVideoWrapper.GetFrame(StreamID, Time);
|
||||
VideoTime = frame.Videotime;
|
||||
SManagedFrame managedFrame = CGstreamerVideoWrapper.GetFrame(streamID, time);
|
||||
videoTime = managedFrame.Videotime;
|
||||
|
||||
UploadNewFrame(ref Frame, ref frame.buffer, frame.Width, frame.Height);
|
||||
_UploadNewFrame(ref frame, ref managedFrame.Buffer, managedFrame.Width, managedFrame.Height);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Skip(int StreamID, float Start, float Gap)
|
||||
public bool Skip(int streamID, float start, float gap)
|
||||
{
|
||||
return CGstreamerVideoWrapper.Skip(StreamID, Start, Gap);
|
||||
return CGstreamerVideoWrapper.Skip(streamID, start, gap);
|
||||
}
|
||||
|
||||
public void SetLoop(int StreamID, bool Loop)
|
||||
public void SetLoop(int streamID, bool loop)
|
||||
{
|
||||
CGstreamerVideoWrapper.SetVideoLoop(StreamID, Loop);
|
||||
CGstreamerVideoWrapper.SetVideoLoop(streamID, loop);
|
||||
}
|
||||
|
||||
public void Pause(int StreamID)
|
||||
public void Pause(int streamID)
|
||||
{
|
||||
CGstreamerVideoWrapper.PauseVideo(StreamID);
|
||||
CGstreamerVideoWrapper.PauseVideo(streamID);
|
||||
}
|
||||
|
||||
public void Resume(int StreamID)
|
||||
public void Resume(int streamID)
|
||||
{
|
||||
CGstreamerVideoWrapper.ResumeVideo(StreamID);
|
||||
CGstreamerVideoWrapper.ResumeVideo(streamID);
|
||||
}
|
||||
|
||||
public bool Finished(int StreamID)
|
||||
public bool Finished(int streamID)
|
||||
{
|
||||
return CGstreamerVideoWrapper.Finished(StreamID);
|
||||
return CGstreamerVideoWrapper.Finished(streamID);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
@@ -98,18 +98,18 @@ namespace Vocaluxe.Lib.Video
|
||||
CGstreamerVideoWrapper.UpdateVideo();
|
||||
}
|
||||
|
||||
private void UploadNewFrame(ref STexture frame, ref byte[] Data, int Width, int Height)
|
||||
private void _UploadNewFrame(ref STexture frame, ref byte[] data, int width, int height)
|
||||
{
|
||||
if (Data != null)
|
||||
if (data != null)
|
||||
{
|
||||
if (frame.index == -1 || Width != frame.width || Height != frame.height || Data.Length == 0)
|
||||
if (frame.Index == -1 || width != frame.Width || height != frame.Height || data.Length == 0)
|
||||
{
|
||||
CDraw.RemoveTexture(ref frame);
|
||||
frame = CDraw.AddTexture(Width, Height, ref Data);
|
||||
frame = CDraw.AddTexture(width, height, ref data);
|
||||
}
|
||||
else
|
||||
CDraw.UpdateTexture(ref frame, ref Data);
|
||||
Data = null;
|
||||
CDraw.UpdateTexture(ref frame, ref data);
|
||||
data = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,18 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Vocaluxe.Lib.Video.Gstreamer
|
||||
{
|
||||
public struct NativeFrame
|
||||
public struct SNativeFrame
|
||||
{
|
||||
internal IntPtr buffer;
|
||||
internal IntPtr Buffer;
|
||||
public int Size;
|
||||
public int Width;
|
||||
public int Height;
|
||||
public float Videotime;
|
||||
}
|
||||
|
||||
public struct ManagedFrame
|
||||
public struct SManagedFrame
|
||||
{
|
||||
public byte[] buffer;
|
||||
public byte[] Buffer;
|
||||
public int Size;
|
||||
public int Width;
|
||||
public int Height;
|
||||
@@ -26,13 +26,13 @@ namespace Vocaluxe.Lib.Video.Gstreamer
|
||||
#region arch
|
||||
#if ARCH_X86
|
||||
#if WIN
|
||||
private const string Dll = "x86\\gstreamer\\gstreamerhelper.dll";
|
||||
private const string _Dll = "x86\\gstreamer\\gstreamerhelper.dll";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ARCH_X64
|
||||
#if WIN
|
||||
private const string Dll = "x64\\gstreamer\\gstreamerhelper.dll";
|
||||
private const string _Dll = "x64\\gstreamer\\gstreamerhelper.dll";
|
||||
#endif
|
||||
#endif
|
||||
#endregion arch
|
||||
@@ -40,46 +40,46 @@ namespace Vocaluxe.Lib.Video.Gstreamer
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate void LogCallback(string message);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetVideoLogCallback(LogCallback c);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool InitVideo();
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void CloseAllVideos();
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int LoadVideo(string VideoFileName);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int LoadVideo(string videoFileName);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool CloseVideo(int StreamID);
|
||||
public static extern bool CloseVideo(int streamID);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GetVideoNumStreams();
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float GetVideoLength(int StreamID);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float GetVideoLength(int streamID);
|
||||
|
||||
[DllImport(Dll, EntryPoint = "GetFrame", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern NativeFrame GetFrameNative(int StreamID, float Time);
|
||||
[DllImport(_Dll, EntryPoint = "GetFrame", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern SNativeFrame GetFrameNative(int streamID, float time);
|
||||
|
||||
public static ManagedFrame GetFrame(int StreamID, float Time)
|
||||
public static SManagedFrame GetFrame(int streamID, float time)
|
||||
{
|
||||
NativeFrame f = GetFrameNative(StreamID, Time);
|
||||
SNativeFrame f = GetFrameNative(streamID, time);
|
||||
|
||||
byte[] buffer = null;
|
||||
|
||||
if (f.Size > 0)
|
||||
{
|
||||
buffer = new byte[f.Size];
|
||||
Marshal.Copy(f.buffer, buffer, 0, f.Size);
|
||||
Marshal.Copy(f.Buffer, buffer, 0, f.Size);
|
||||
}
|
||||
|
||||
ManagedFrame m;
|
||||
m.buffer = buffer;
|
||||
SManagedFrame m;
|
||||
m.Buffer = buffer;
|
||||
m.Height = f.Height;
|
||||
m.Size = f.Size;
|
||||
m.Videotime = f.Videotime;
|
||||
@@ -87,25 +87,25 @@ namespace Vocaluxe.Lib.Video.Gstreamer
|
||||
return m;
|
||||
}
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool Skip(int StreamID, float Start, float Gap);
|
||||
public static extern bool Skip(int streamID, float start, float gap);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetVideoLoop(int StreamID,
|
||||
[MarshalAs(UnmanagedType.U1)] bool Loop);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetVideoLoop(int streamID,
|
||||
[MarshalAs(UnmanagedType.U1)] bool loop);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void PauseVideo(int StreamID);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void PauseVideo(int streamID);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void ResumeVideo(int StreamID);
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void ResumeVideo(int streamID);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool Finished(int StreamID);
|
||||
public static extern bool Finished(int streamID);
|
||||
|
||||
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(_Dll, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool UpdateVideo();
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Lib.Video
|
||||
{
|
||||
struct VideoStreams
|
||||
struct SVideoStreams
|
||||
{
|
||||
public int handle;
|
||||
public string file;
|
||||
public int Handle;
|
||||
public string File;
|
||||
|
||||
public VideoStreams(int stream)
|
||||
public SVideoStreams(int stream)
|
||||
{
|
||||
handle = stream;
|
||||
file = String.Empty;
|
||||
Handle = stream;
|
||||
File = String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,18 +20,18 @@ namespace Vocaluxe.Lib.Video
|
||||
bool Init();
|
||||
void CloseAll();
|
||||
|
||||
int Load(string VideoFileName);
|
||||
bool Close(int StreamID);
|
||||
int Load(string videoFileName);
|
||||
bool Close(int streamID);
|
||||
int GetNumStreams();
|
||||
|
||||
float GetLength(int StreamID);
|
||||
bool GetFrame(int StreamID, ref STexture Frame, float Time, ref float VideoTime);
|
||||
bool Skip(int StreamID, float Start, float Gap);
|
||||
void SetLoop(int StreamID, bool Loop);
|
||||
void Pause(int StreamID);
|
||||
void Resume(int StreamID);
|
||||
float GetLength(int streamID);
|
||||
bool GetFrame(int streamID, ref STexture frame, float time, ref float videoTime);
|
||||
bool Skip(int streamID, float start, float gap);
|
||||
void SetLoop(int streamID, bool loop);
|
||||
void Pause(int streamID);
|
||||
void Resume(int streamID);
|
||||
|
||||
bool Finished(int StreamID);
|
||||
bool Finished(int streamID);
|
||||
|
||||
void Update();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Vocaluxe.Lib.Webcam
|
||||
private VideoCaptureDevice _Webcam;
|
||||
private FilterInfoCollection _WebcamDevices;
|
||||
private SWebcamConfig _Config;
|
||||
private byte[] data = new byte[1];
|
||||
private static readonly object _mutexData = new object();
|
||||
private byte[] _Data = new byte[1];
|
||||
private static readonly object _MutexData = new object();
|
||||
private int _Width, _Height;
|
||||
|
||||
public void Close()
|
||||
@@ -26,24 +26,24 @@ namespace Vocaluxe.Lib.Webcam
|
||||
{
|
||||
_Webcam.SignalToStop();
|
||||
_Webcam.WaitForStop();
|
||||
_Webcam.NewFrame -= OnFrame;
|
||||
data = new byte[1];
|
||||
_Webcam.NewFrame -= _OnFrame;
|
||||
_Data = new byte[1];
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetFrame(ref STexture Frame)
|
||||
public bool GetFrame(ref STexture frame)
|
||||
{
|
||||
if (_Webcam != null && _Width > 0 && _Height > 0 && data.Length == _Width * _Height * 4)
|
||||
if (_Webcam != null && _Width > 0 && _Height > 0 && _Data.Length == _Width * _Height * 4)
|
||||
{
|
||||
lock (_mutexData)
|
||||
lock (_MutexData)
|
||||
{
|
||||
if (Frame.index == -1 || _Width != Frame.width || _Height != Frame.height)
|
||||
if (frame.Index == -1 || _Width != frame.Width || _Height != frame.Height)
|
||||
{
|
||||
CDraw.RemoveTexture(ref Frame);
|
||||
Frame = CDraw.AddTexture(_Width, _Height, ref data);
|
||||
CDraw.RemoveTexture(ref frame);
|
||||
frame = CDraw.AddTexture(_Width, _Height, ref _Data);
|
||||
}
|
||||
else
|
||||
CDraw.UpdateTexture(ref Frame, ref data);
|
||||
CDraw.UpdateTexture(ref frame, ref _Data);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -51,13 +51,13 @@ namespace Vocaluxe.Lib.Webcam
|
||||
|
||||
public Bitmap GetBitmap()
|
||||
{
|
||||
if (_Webcam != null && _Width > 0 && _Height > 0 && data.Length == _Height * _Width * 4)
|
||||
if (_Webcam != null && _Width > 0 && _Height > 0 && _Data.Length == _Height * _Width * 4)
|
||||
{
|
||||
lock (_mutexData)
|
||||
lock (_MutexData)
|
||||
{
|
||||
Bitmap bmp = new Bitmap(_Width, _Height);
|
||||
BitmapData bitmapdata = bmp.LockBits(new Rectangle(0, 0, _Width, _Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
Marshal.Copy(data, 0, bitmapdata.Scan0, data.Length);
|
||||
Marshal.Copy(_Data, 0, bitmapdata.Scan0, _Data.Length);
|
||||
bmp.UnlockBits(bitmapdata);
|
||||
return bmp;
|
||||
}
|
||||
@@ -97,19 +97,19 @@ namespace Vocaluxe.Lib.Webcam
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnFrame(object sender, NewFrameEventArgs e)
|
||||
private void _OnFrame(object sender, NewFrameEventArgs e)
|
||||
{
|
||||
if (!_Paused)
|
||||
{
|
||||
lock (_mutexData)
|
||||
lock (_MutexData)
|
||||
{
|
||||
if (_Width != e.Frame.Width || _Height != e.Frame.Height || data.Length != e.Frame.Width * e.Frame.Height * 4)
|
||||
data = new byte[4 * e.Frame.Width * e.Frame.Height];
|
||||
if (_Width != e.Frame.Width || _Height != e.Frame.Height || _Data.Length != e.Frame.Width * e.Frame.Height * 4)
|
||||
_Data = new byte[4 * e.Frame.Width * e.Frame.Height];
|
||||
|
||||
_Width = e.Frame.Width;
|
||||
_Height = e.Frame.Height;
|
||||
BitmapData bitmapdata = e.Frame.LockBits(new Rectangle(0, 0, _Width, _Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
Marshal.Copy(bitmapdata.Scan0, data, 0, data.Length);
|
||||
Marshal.Copy(bitmapdata.Scan0, _Data, 0, _Data.Length);
|
||||
e.Frame.UnlockBits(bitmapdata);
|
||||
}
|
||||
}
|
||||
@@ -125,9 +125,9 @@ namespace Vocaluxe.Lib.Webcam
|
||||
{
|
||||
if (_Webcam != null)
|
||||
{
|
||||
_Webcam.NewFrame -= OnFrame;
|
||||
_Webcam.NewFrame -= _OnFrame;
|
||||
//Subscribe to NewFrame event
|
||||
_Webcam.NewFrame += OnFrame;
|
||||
_Webcam.NewFrame += _OnFrame;
|
||||
_Webcam.Start();
|
||||
_Paused = false;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ namespace Vocaluxe.Lib.Webcam
|
||||
return _Devices.ToArray();
|
||||
}
|
||||
|
||||
public bool Select(SWebcamConfig Config)
|
||||
public bool Select(SWebcamConfig config)
|
||||
{
|
||||
//Close old camera connection
|
||||
Close();
|
||||
@@ -155,18 +155,18 @@ namespace Vocaluxe.Lib.Webcam
|
||||
return false;
|
||||
|
||||
//No MonikerString found, try first webcam
|
||||
if (Config.MonikerString.Length == 0)
|
||||
if (config.MonikerString.Length == 0)
|
||||
_Webcam = new VideoCaptureDevice(_WebcamDevices[0].MonikerString);
|
||||
else //Found MonikerString
|
||||
_Webcam = new VideoCaptureDevice(Config.MonikerString);
|
||||
_Webcam = new VideoCaptureDevice(config.MonikerString);
|
||||
|
||||
if (_Webcam == null)
|
||||
return false;
|
||||
|
||||
if (Config.Framerate != 0 && Config.Height != 0 && Config.Width != 0)
|
||||
if (config.Framerate != 0 && config.Height != 0 && config.Width != 0)
|
||||
{
|
||||
_Webcam.DesiredFrameRate = Config.Framerate;
|
||||
_Webcam.DesiredFrameSize = new Size(Config.Width, Config.Height);
|
||||
_Webcam.DesiredFrameRate = config.Framerate;
|
||||
_Webcam.DesiredFrameSize = new Size(config.Width, config.Height);
|
||||
}
|
||||
|
||||
_Config.Framerate = _Webcam.DesiredFrameRate;
|
||||
|
||||
@@ -36,11 +36,11 @@ namespace Vocaluxe.Lib.Webcam
|
||||
void Stop();
|
||||
void Close();
|
||||
|
||||
bool GetFrame(ref STexture Frame);
|
||||
bool GetFrame(ref STexture frame);
|
||||
Bitmap GetBitmap();
|
||||
SWebcamConfig GetConfig();
|
||||
SWebcamDevice[] GetDevices();
|
||||
|
||||
bool Select(SWebcamConfig sWebcamConfig);
|
||||
bool Select(SWebcamConfig webcamConfig);
|
||||
}
|
||||
}
|
||||
+99
-98
@@ -1,25 +1,67 @@
|
||||
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 System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using Vocaluxe.Base;
|
||||
using System.Runtime.ExceptionServices;
|
||||
|
||||
namespace Vocaluxe
|
||||
{
|
||||
// just a small comment for the new develop branch
|
||||
static class MainProgram
|
||||
static class CMainProgram
|
||||
{
|
||||
private static SplashScreen _SplashScreen;
|
||||
private static CSplashScreen _SplashScreen;
|
||||
|
||||
[STAThread]
|
||||
[STAThread, HandleProcessCorruptedStateExceptions]
|
||||
// ReSharper disable InconsistentNaming
|
||||
private static void Main(string[] args)
|
||||
// ReSharper restore InconsistentNaming
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver;
|
||||
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
|
||||
AppDomain.CurrentDomain.AssemblyResolve += _AssemblyResolver;
|
||||
try
|
||||
{
|
||||
_Run(args);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string stackTrace = "";
|
||||
try
|
||||
{
|
||||
stackTrace = e.StackTrace;
|
||||
}
|
||||
catch {}
|
||||
MessageBox.Show("Unhandled error: " + e.Message + stackTrace);
|
||||
CLog.LogError("Unhandled error: " + e.Message + stackTrace);
|
||||
}
|
||||
_CloseProgram();
|
||||
}
|
||||
|
||||
private static void _Run(string[] args)
|
||||
{
|
||||
// Close program if there is another instance running
|
||||
if (!EnsureSingleInstance())
|
||||
if (!_EnsureSingleInstance())
|
||||
{
|
||||
//TODO: put it into language file
|
||||
MessageBox.Show("Another Instance of Vocaluxe is already runnning!");
|
||||
@@ -53,7 +95,7 @@ namespace Vocaluxe
|
||||
CLog.StopBenchmark(0, "Init Config");
|
||||
|
||||
Application.DoEvents();
|
||||
_SplashScreen = new SplashScreen();
|
||||
_SplashScreen = new CSplashScreen();
|
||||
Application.DoEvents();
|
||||
|
||||
// Init Draw
|
||||
@@ -159,7 +201,7 @@ namespace Vocaluxe
|
||||
{
|
||||
MessageBox.Show("Error on start up: " + e.Message + e.StackTrace);
|
||||
CLog.LogError("Error on start up: " + e.Message + e.StackTrace);
|
||||
CloseProgram();
|
||||
_CloseProgram();
|
||||
Environment.Exit(Environment.ExitCode);
|
||||
}
|
||||
Application.DoEvents();
|
||||
@@ -167,127 +209,86 @@ namespace Vocaluxe
|
||||
// Start Main Loop
|
||||
_SplashScreen.Close();
|
||||
|
||||
try
|
||||
{
|
||||
CDraw.MainLoop();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Unhandled error: " + e.Message + e.StackTrace);
|
||||
CLog.LogError("Unhandled error: " + e.Message + e.StackTrace);
|
||||
}
|
||||
|
||||
CloseProgram();
|
||||
CDraw.MainLoop();
|
||||
}
|
||||
|
||||
private static void CloseProgram()
|
||||
private static void _CloseProgram()
|
||||
{
|
||||
// Unloading
|
||||
try
|
||||
{
|
||||
CLog.CloseAll();
|
||||
CInput.Close();
|
||||
CSound.RecordCloseAll();
|
||||
CSound.CloseAllStreams();
|
||||
CVideo.VdCloseAll();
|
||||
CDraw.Unload();
|
||||
CLog.CloseAll();
|
||||
CDataBase.CloseConnections();
|
||||
CWebcam.Close();
|
||||
}
|
||||
catch (Exception) {}
|
||||
}
|
||||
|
||||
private static Assembly AssemblyResolver(Object sender, ResolveEventArgs args)
|
||||
[HandleProcessCorruptedStateExceptions]
|
||||
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args)
|
||||
{
|
||||
string[] arr = args.Name.Split(new char[] {','});
|
||||
if (arr != null)
|
||||
Exception e = (Exception)args.ExceptionObject;
|
||||
string stackTrace = "";
|
||||
try
|
||||
{
|
||||
stackTrace = e.StackTrace;
|
||||
}
|
||||
catch {}
|
||||
MessageBox.Show("Unhandled exception: " + e.Message + stackTrace);
|
||||
CLog.LogError("Unhandled exception: " + e.Message + stackTrace);
|
||||
}
|
||||
|
||||
private static Assembly _AssemblyResolver(Object sender, ResolveEventArgs args)
|
||||
{
|
||||
// a fix to handle mscorlib.resources
|
||||
if (args.Name.IndexOf(".resources", StringComparison.Ordinal) >= 0)
|
||||
return null;
|
||||
|
||||
string[] arr = args.Name.Split(new char[] {','});
|
||||
if (arr.Length > 0)
|
||||
{
|
||||
|
||||
#if ARCH_X86
|
||||
Assembly assembly = Assembly.LoadFrom(Path.Combine("x86", arr[0] + ".dll"));
|
||||
string path="x86";
|
||||
#endif
|
||||
|
||||
#if ARCH_X64
|
||||
Assembly assembly = Assembly.LoadFrom(Path.Combine("x64", arr[0] + ".dll"));
|
||||
string path="x64";
|
||||
#endif
|
||||
|
||||
return assembly;
|
||||
path = Path.Combine(path, arr[0] + ".dll");
|
||||
try
|
||||
{
|
||||
Assembly assembly;
|
||||
try
|
||||
{
|
||||
assembly = Assembly.LoadFrom(path);
|
||||
}
|
||||
catch (FileLoadException)
|
||||
{
|
||||
//possibly loading from network, this would work always but better use the normal LoadFrom for more specific errors
|
||||
assembly = Assembly.Load(File.ReadAllBytes(path));
|
||||
}
|
||||
return assembly;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Cannot load assembly "+args.Name+" from "+path+": "+e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool EnsureSingleInstance()
|
||||
private static bool _EnsureSingleInstance()
|
||||
{
|
||||
Process currentProcess = Process.GetCurrentProcess();
|
||||
Process[] processes = Process.GetProcesses();
|
||||
|
||||
if (processes == null)
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < processes.Length; i++)
|
||||
{
|
||||
if (processes[i].Id != currentProcess.Id && currentProcess.ProcessName == processes[i].ProcessName)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class SplashScreen : Form
|
||||
{
|
||||
private readonly Bitmap logo;
|
||||
|
||||
public SplashScreen()
|
||||
{
|
||||
string path = Path.Combine(Environment.CurrentDirectory, Path.Combine(CSettings.sFolderGraphics, CSettings.sLogo));
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
logo = new Bitmap(path);
|
||||
ClientSize = new Size(logo.Width, logo.Height);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading logo: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
|
||||
path = Path.Combine(Environment.CurrentDirectory, CSettings.sIcon);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
Icon = new Icon(path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading icon: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
BackColor = Color.Transparent;
|
||||
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
Text = CSettings.sProgramName;
|
||||
CenterToScreen();
|
||||
Show();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e) {}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
if (logo == null)
|
||||
return;
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
g.DrawImage(logo, new Rectangle(0, 0, Width, Height));
|
||||
return processes.All(t => t.Id == currentProcess.Id || currentProcess.ProcessName != t.ProcessName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@ 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.Properties")]
|
||||
[assembly: AssemblyTitle("Vocaluxe")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Vocaluxe.Properties")]
|
||||
[assembly: AssemblyProduct("Vocaluxe")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@@ -14,35 +14,35 @@ namespace Vocaluxe.Screens
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string StaticBG = "StaticBG";
|
||||
private const string StaticCover = "StaticCover";
|
||||
private const string _StaticBG = "StaticBG";
|
||||
private const string _StaticCover = "StaticCover";
|
||||
|
||||
private const string ButtonPrevious = "ButtonPrevious";
|
||||
private const string ButtonPlay = "ButtonPlay";
|
||||
private const string ButtonPause = "ButtonPause";
|
||||
private const string ButtonNext = "ButtonNext";
|
||||
private const string ButtonRepeat = "ButtonRepeat";
|
||||
private const string ButtonShowVideo = "ButtonShowVideo";
|
||||
private const string ButtonSing = "ButtonSing";
|
||||
private const string ButtonToBackgroundVideo = "ButtonToBackgroundVideo";
|
||||
private const string _ButtonPrevious = "ButtonPrevious";
|
||||
private const string _ButtonPlay = "ButtonPlay";
|
||||
private const string _ButtonPause = "ButtonPause";
|
||||
private const string _ButtonNext = "ButtonNext";
|
||||
private const string _ButtonRepeat = "ButtonRepeat";
|
||||
private const string _ButtonShowVideo = "ButtonShowVideo";
|
||||
private const string _ButtonSing = "ButtonSing";
|
||||
private const string _ButtonToBackgroundVideo = "ButtonToBackgroundVideo";
|
||||
|
||||
private const string TextCurrentSong = "TextCurrentSong";
|
||||
private bool _VideoPreview;
|
||||
private const string _TextCurrentSong = "TextCurrentSong";
|
||||
private bool _VideoPreviewInt;
|
||||
|
||||
private bool VideoPreview
|
||||
private bool _VideoPreview
|
||||
{
|
||||
get { return _VideoPreview; }
|
||||
get { return _VideoPreviewInt; }
|
||||
set
|
||||
{
|
||||
_VideoPreview = value;
|
||||
if (!_VideoPreview && !VideoBackground)
|
||||
_VideoPreviewInt = value;
|
||||
if (!_VideoPreviewInt && !_VideoBackground)
|
||||
CBackgroundMusic.VideoEnabled = false;
|
||||
else
|
||||
CBackgroundMusic.VideoEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool VideoBackground
|
||||
private bool _VideoBackground
|
||||
{
|
||||
get { return CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON; }
|
||||
set
|
||||
@@ -52,7 +52,7 @@ namespace Vocaluxe.Screens
|
||||
if (CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
CConfig.VideosToBackground = EOffOn.TR_CONFIG_OFF;
|
||||
if (!_VideoPreview)
|
||||
if (!_VideoPreviewInt)
|
||||
CBackgroundMusic.VideoEnabled = false;
|
||||
}
|
||||
}
|
||||
@@ -69,29 +69,29 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeStatics = new string[] {StaticBG, StaticCover};
|
||||
_ThemeTexts = new string[] {TextCurrentSong};
|
||||
_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);
|
||||
buttons.Add(_ButtonPlay);
|
||||
buttons.Add(_ButtonPause);
|
||||
buttons.Add(_ButtonPrevious);
|
||||
buttons.Add(_ButtonNext);
|
||||
buttons.Add(_ButtonRepeat);
|
||||
buttons.Add(_ButtonShowVideo);
|
||||
buttons.Add(_ButtonSing);
|
||||
buttons.Add(_ButtonToBackgroundVideo);
|
||||
_ThemeButtons = buttons.ToArray();
|
||||
}
|
||||
|
||||
public override void LoadTheme(string XmlPath)
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
base.LoadTheme(XmlPath);
|
||||
base.LoadTheme(xmlPath);
|
||||
|
||||
_ScreenArea = Statics[StaticBG].Rect;
|
||||
_ScreenArea = Statics[_StaticBG].Rect;
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode)) {}
|
||||
@@ -105,22 +105,22 @@ 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)
|
||||
VideoPreview = !VideoPreview;
|
||||
if (Buttons[ButtonSing].Selected)
|
||||
StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet);
|
||||
if (Buttons[ButtonToBackgroundVideo].Selected)
|
||||
VideoBackground = !VideoBackground;
|
||||
if (Buttons[_ButtonShowVideo].Selected)
|
||||
_VideoPreview = !_VideoPreview;
|
||||
if (Buttons[_ButtonSing].Selected)
|
||||
_StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet);
|
||||
if (Buttons[_ButtonToBackgroundVideo].Selected)
|
||||
_VideoBackground = !_VideoBackground;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -128,27 +128,27 @@ namespace Vocaluxe.Screens
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(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)
|
||||
VideoPreview = !VideoPreview;
|
||||
if (Buttons[ButtonSing].Selected)
|
||||
StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet);
|
||||
if (Buttons[ButtonToBackgroundVideo].Selected)
|
||||
VideoBackground = !VideoBackground;
|
||||
if (Buttons[_ButtonShowVideo].Selected)
|
||||
_VideoPreview = !_VideoPreview;
|
||||
if (Buttons[_ButtonSing].Selected)
|
||||
_StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet);
|
||||
if (Buttons[_ButtonToBackgroundVideo].Selected)
|
||||
_VideoBackground = !_VideoBackground;
|
||||
}
|
||||
else if (mouseEvent.LB)
|
||||
{
|
||||
@@ -165,11 +165,11 @@ namespace Vocaluxe.Screens
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
Statics[StaticCover].Visible = !_VideoPreview || !CBackgroundMusic.SongHasVideo;
|
||||
Buttons[ButtonToBackgroundVideo].Pressed = VideoBackground;
|
||||
Buttons[ButtonShowVideo].Pressed = _VideoPreview;
|
||||
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,28 +177,28 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
if (!_Active)
|
||||
return false;
|
||||
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;
|
||||
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;
|
||||
|
||||
return base.Draw();
|
||||
}
|
||||
|
||||
private void StartSong(int SongNr, bool Duet)
|
||||
private void _StartSong(int songNr, bool duet)
|
||||
{
|
||||
if (SongNr >= 0 && CSongs.SongsLoaded)
|
||||
if (songNr >= 0 && CSongs.SongsLoaded)
|
||||
{
|
||||
CGame.Reset();
|
||||
CGame.ClearSongs();
|
||||
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
if (CSongs.AllSongs[SongNr].IsDuet)
|
||||
if (CSongs.AllSongs[songNr].IsDuet)
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
|
||||
CGame.AddSong(SongNr, gm);
|
||||
CGame.AddSong(songNr, gm);
|
||||
|
||||
CGraphics.FadeTo(EScreens.ScreenNames);
|
||||
}
|
||||
|
||||
@@ -11,57 +11,57 @@ namespace Vocaluxe.Screens
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string StaticBG = "StaticBG";
|
||||
private const string _StaticBG = "StaticBG";
|
||||
|
||||
private const string SelectSlideVolume = "SelectSlideVolume";
|
||||
private const string _SelectSlideVolume = "SelectSlideVolume";
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeStatics = new string[] {StaticBG};
|
||||
_ThemeSelectSlides = new string[] {SelectSlideVolume};
|
||||
_ThemeStatics = new string[] {_StaticBG};
|
||||
_ThemeSelectSlides = new string[] {_SelectSlideVolume};
|
||||
}
|
||||
|
||||
public override void LoadTheme(string XmlPath)
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
base.LoadTheme(XmlPath);
|
||||
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"});
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
UpdateSlides();
|
||||
_UpdateSlides();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
if (mouseEvent.LB)
|
||||
{
|
||||
SaveConfig();
|
||||
_SaveConfig();
|
||||
return true;
|
||||
}
|
||||
else 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;
|
||||
SaveConfig();
|
||||
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 (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();
|
||||
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)
|
||||
@@ -72,12 +72,12 @@ namespace Vocaluxe.Screens
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
UpdateSlides();
|
||||
_UpdateSlides();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
UpdateSlides();
|
||||
_UpdateSlides();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -89,49 +89,49 @@ namespace Vocaluxe.Screens
|
||||
return base.Draw();
|
||||
}
|
||||
|
||||
private void SaveConfig()
|
||||
private void _SaveConfig()
|
||||
{
|
||||
switch (CGraphics.CurrentScreen)
|
||||
{
|
||||
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;
|
||||
}
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
|
||||
private void UpdateSlides()
|
||||
private void _UpdateSlides()
|
||||
{
|
||||
switch (CGraphics.CurrentScreen)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ class CCreditName
|
||||
public float StartTimeUp;
|
||||
public bool Active;
|
||||
|
||||
public CCreditName(CStatic Image, CStatic ImgDot, CParticleEffect Particle, int ParticleOffsetX, int ParticleOffsetY)
|
||||
public CCreditName(CStatic image, CStatic imgDot, CParticleEffect particle, int particleOffsetX, int particleOffsetY)
|
||||
{
|
||||
_Image = Image;
|
||||
_ImgDot = ImgDot;
|
||||
_Particle = Particle;
|
||||
_ParticleOffsetX = (int)Math.Round(ParticleOffsetX * Image.Rect.W / Image.Texture.w2 - Particle.Rect.W / 2);
|
||||
_ParticleOffsetY = (int)Math.Round(ParticleOffsetY * Image.Rect.H / Image.Texture.h2 - Particle.Rect.H / 2);
|
||||
_Image = image;
|
||||
_ImgDot = imgDot;
|
||||
_Particle = particle;
|
||||
_ParticleOffsetX = (int)Math.Round(particleOffsetX * image.Rect.W / image.Texture.Width - particle.Rect.W / 2);
|
||||
_ParticleOffsetY = (int)Math.Round(particleOffsetY * image.Rect.H / image.Texture.Height - particle.Rect.H / 2);
|
||||
Active = true;
|
||||
}
|
||||
|
||||
@@ -94,17 +94,17 @@ namespace Vocaluxe.Screens
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private CStatic logo;
|
||||
private CParticleEffect starsRed;
|
||||
private CParticleEffect starsBlue;
|
||||
private CStatic _Logo;
|
||||
private CParticleEffect _StarsRed;
|
||||
private CParticleEffect _StarsBlue;
|
||||
private List<CCreditName> _CreditNames;
|
||||
|
||||
private Stopwatch LogoTimer;
|
||||
private Stopwatch CreditsTimer;
|
||||
private Stopwatch TextTimer;
|
||||
private Stopwatch _LogoTimer;
|
||||
private Stopwatch _CreditsTimer;
|
||||
private Stopwatch _TextTimer;
|
||||
|
||||
private List<string[]> paragraphs;
|
||||
private List<CText> paragraphTexts;
|
||||
private List<string[]> _Paragraphs;
|
||||
private List<CText> _ParagraphTexts;
|
||||
|
||||
private STexture _TexLogo;
|
||||
private STexture _TexPerfectNoteStar;
|
||||
@@ -125,13 +125,13 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
base.Init();
|
||||
|
||||
LogoTimer = new Stopwatch();
|
||||
CreditsTimer = new Stopwatch();
|
||||
TextTimer = new Stopwatch();
|
||||
_LogoTimer = new Stopwatch();
|
||||
_CreditsTimer = new Stopwatch();
|
||||
_TextTimer = new Stopwatch();
|
||||
|
||||
//Text for last part of credits.
|
||||
paragraphTexts = new List<CText>();
|
||||
paragraphs = new List<string[]>();
|
||||
_ParagraphTexts = new List<CText>();
|
||||
_Paragraphs = new List<string[]>();
|
||||
|
||||
string paragraph;
|
||||
string[] words;
|
||||
@@ -140,14 +140,14 @@ namespace Vocaluxe.Screens
|
||||
"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[] {' '});
|
||||
paragraphs.Add(words);
|
||||
_Paragraphs.Add(words);
|
||||
|
||||
paragraph = "This first public version has already implemented many of the original features and it is fully " +
|
||||
"compatible with all the song files in your existing song collection. The code design allows a much faster " +
|
||||
"implementation of new features, thus the roadmap for the next few stable releases is packed and we expect much " +
|
||||
"shorter release cycles than ever before. And, of course, our and your ideas may be the features of tomorrow.";
|
||||
words = paragraph.Split(new char[] {' '});
|
||||
paragraphs.Add(words);
|
||||
_Paragraphs.Add(words);
|
||||
|
||||
paragraph = "We appreciate the feedback in the beta release phase and are, of course, always open for bug reports, " +
|
||||
"suggestions for improvements and ideas for new features. We would also like to thank the translators who make " +
|
||||
@@ -155,15 +155,15 @@ namespace Vocaluxe.Screens
|
||||
"there's something for everyone in the huge collection of available songs! Last but not least, thanks to " +
|
||||
"Kosal Sen's Philly Sans type used in the Vocaluxe Logo.";
|
||||
words = paragraph.Split(new char[] {' '});
|
||||
paragraphs.Add(words);
|
||||
_Paragraphs.Add(words);
|
||||
|
||||
paragraph = "Go ahead and grab your mics, crank up your stereo, warm up your voice and get ready to sing to the best " +
|
||||
"of your abilities!";
|
||||
words = paragraph.Split(new char[] {' '});
|
||||
paragraphs.Add(words);
|
||||
_Paragraphs.Add(words);
|
||||
}
|
||||
|
||||
public override void LoadTheme(string XmlPath)
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
//Vocaluxe-Logo
|
||||
CDataBase.GetCreditsRessource("Logo_voc.png", ref _TexLogo);
|
||||
@@ -185,32 +185,32 @@ namespace Vocaluxe.Screens
|
||||
|
||||
//Prepare Text
|
||||
int lastY = 280;
|
||||
for (int i = 0; i < paragraphs.Count; i++)
|
||||
for (int i = 0; i < _Paragraphs.Count; i++)
|
||||
{
|
||||
string line = "";
|
||||
for (int e = 0; e < paragraphs[i].Length; e++)
|
||||
for (int e = 0; e < _Paragraphs[i].Length; e++)
|
||||
{
|
||||
if (paragraphs[i][e] != null)
|
||||
if (_Paragraphs[i][e] != null)
|
||||
{
|
||||
string newline = line + " " + paragraphs[i][e];
|
||||
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.iRenderW - 220))
|
||||
if (CDraw.GetTextBounds(text).Width < (CSettings.RenderW - 220))
|
||||
{
|
||||
line = line + " " + paragraphs[i][e];
|
||||
line = line + " " + _Paragraphs[i][e];
|
||||
|
||||
//Check if all words are used
|
||||
if ((e + 1) == paragraphs[i].Length)
|
||||
if ((e + 1) == _Paragraphs[i].Length)
|
||||
{
|
||||
text.Text = line;
|
||||
paragraphTexts.Add(text);
|
||||
_ParagraphTexts.Add(text);
|
||||
line = "";
|
||||
lastY += 40;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
paragraphTexts.Add(text);
|
||||
line = " " + paragraphs[i][e];
|
||||
_ParagraphTexts.Add(text);
|
||||
line = " " + _Paragraphs[i][e];
|
||||
lastY += 27;
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReloadTheme(string XmlPath) {}
|
||||
public override void ReloadTheme(string xmlPath) {}
|
||||
|
||||
public override void SaveTheme() {}
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
public override void ReloadTextures() {}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
if (!keyEvent.KeyPressed || Char.IsControl(keyEvent.Unicode))
|
||||
{
|
||||
@@ -243,7 +243,7 @@ namespace Vocaluxe.Screens
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
if (mouseEvent.LB || mouseEvent.RB)
|
||||
CGraphics.FadeTo(EScreens.ScreenMain);
|
||||
@@ -252,38 +252,38 @@ namespace Vocaluxe.Screens
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
if (!animation())
|
||||
if (!_Animation())
|
||||
CGraphics.FadeTo(EScreens.ScreenMain);
|
||||
return true;
|
||||
}
|
||||
|
||||
public CParticleEffect _GetStarParticles(int NumStars, bool isRed, SRectF Rect, bool BigParticles)
|
||||
public 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;
|
||||
return GetNewParticleEffect(NumStars, partColor, Rect, _TexPerfectNoteStar, partSize, EParticleType.Star);
|
||||
int partSize = bigParticles ? 35 : 25;
|
||||
return GetNewParticleEffect(numStars, partColor, rect, _TexPerfectNoteStar, partSize, EParticleType.Star);
|
||||
}
|
||||
|
||||
private void _AddNewCreditName(STexture Texture, int ParticleOffsetX, int ParticleOffsetY, bool BigParticles)
|
||||
private void _AddNewCreditName(STexture texture, int particleOffsetX, int particleOffsetY, bool bigParticles)
|
||||
{
|
||||
bool isRight = _CreditNames.Count % 2 == 0;
|
||||
int partRectSize = BigParticles ? 25 : 20;
|
||||
int partCount = BigParticles ? 8 : 6;
|
||||
STexture TexDot = isRight ? _TexRedDot : _TexBlueDot;
|
||||
int partRectSize = bigParticles ? 25 : 20;
|
||||
int partCount = bigParticles ? 8 : 6;
|
||||
STexture texDot = isRight ? _TexRedDot : _TexBlueDot;
|
||||
|
||||
CStatic Image = GetNewStatic(Texture, new SColorF(1, 1, 1, 1), new SRectF(-1, -1, 400, 120, -4));
|
||||
CStatic image = GetNewStatic(texture, new SColorF(1, 1, 1, 1), new SRectF(-1, -1, 400, 120, -4));
|
||||
|
||||
SRectF particleRect = new SRectF(-1, -1, partRectSize, partRectSize, -6);
|
||||
SRectF imgDotRect = new SRectF(particleRect);
|
||||
imgDotRect.Z = -5;
|
||||
CStatic ImgDot = GetNewStatic(TexDot, new SColorF(1, 1, 1, 1), imgDotRect);
|
||||
CParticleEffect Particle = _GetStarParticles(partCount, isRight, particleRect, BigParticles);
|
||||
CStatic imgDot = GetNewStatic(texDot, new SColorF(1, 1, 1, 1), imgDotRect);
|
||||
CParticleEffect particle = GetStarParticles(partCount, isRight, particleRect, bigParticles);
|
||||
|
||||
CCreditName credit = new CCreditName(Image, ImgDot, Particle, ParticleOffsetX, ParticleOffsetY);
|
||||
CCreditName credit = new CCreditName(image, imgDot, particle, particleOffsetX, particleOffsetY);
|
||||
|
||||
if (isRight)
|
||||
{
|
||||
credit.X = CSettings.iRenderW;
|
||||
credit.X = CSettings.RenderW;
|
||||
credit.Direction = EDirection.Right;
|
||||
}
|
||||
else
|
||||
@@ -300,13 +300,13 @@ namespace Vocaluxe.Screens
|
||||
base.OnShow();
|
||||
|
||||
//Vocaluxe-Logo
|
||||
logo = GetNewStatic(_TexLogo, new SColorF(1, 1, 1, 1), new SRectF((CSettings.iRenderW - _TexLogo.width) / 2, -270, _TexLogo.width, _TexLogo.height, -2));
|
||||
_Logo = GetNewStatic(_TexLogo, new SColorF(1, 1, 1, 1), new SRectF((CSettings.RenderW - _TexLogo.Width) / 2, -270, _TexLogo.Width, _TexLogo.Height, -2));
|
||||
|
||||
//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);
|
||||
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);
|
||||
|
||||
//Credit names
|
||||
_CreditNames = new List<CCreditName>();
|
||||
@@ -320,16 +320,16 @@ namespace Vocaluxe.Screens
|
||||
_AddNewCreditName(_TexNamePantero, 311, 45, false);
|
||||
_AddNewCreditName(_TexNamePinky007, 113, 50, false);
|
||||
|
||||
TextTimer.Reset();
|
||||
LogoTimer.Reset();
|
||||
CreditsTimer.Reset();
|
||||
_TextTimer.Reset();
|
||||
_LogoTimer.Reset();
|
||||
_CreditsTimer.Reset();
|
||||
}
|
||||
|
||||
public override void OnShowFinish()
|
||||
{
|
||||
base.OnShowFinish();
|
||||
|
||||
LogoTimer.Start();
|
||||
_LogoTimer.Start();
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
@@ -337,47 +337,47 @@ namespace Vocaluxe.Screens
|
||||
base.Draw();
|
||||
|
||||
//Draw background
|
||||
CDraw.DrawColor(new SColorF(0, 0.18f, 0.474f, 1), new SRectF(0, 0, CSettings.iRenderW, CSettings.iRenderH, 0));
|
||||
CDraw.DrawColor(new SColorF(0, 0.18f, 0.474f, 1), new SRectF(0, 0, CSettings.RenderW, CSettings.RenderH, 0));
|
||||
|
||||
//Draw stars
|
||||
starsBlue.Draw();
|
||||
starsRed.Draw();
|
||||
_StarsBlue.Draw();
|
||||
_StarsRed.Draw();
|
||||
|
||||
logo.Draw();
|
||||
_Logo.Draw();
|
||||
|
||||
//Draw credit-entries
|
||||
foreach (CCreditName cn in _CreditNames)
|
||||
cn.Draw();
|
||||
|
||||
//Draw Text
|
||||
if (TextTimer.IsRunning)
|
||||
if (_TextTimer.IsRunning)
|
||||
{
|
||||
for (int i = 0; i < paragraphTexts.Count; i++)
|
||||
paragraphTexts[i].Draw();
|
||||
for (int i = 0; i < _ParagraphTexts.Count; i++)
|
||||
_ParagraphTexts[i].Draw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool animation()
|
||||
private bool _Animation()
|
||||
{
|
||||
bool active = false;
|
||||
if (LogoTimer.IsRunning)
|
||||
if (_LogoTimer.IsRunning)
|
||||
{
|
||||
active = true;
|
||||
|
||||
logo.Rect.Y = -270 + (270f / 3000f) * LogoTimer.ElapsedMilliseconds;
|
||||
starsRed.Rect.Y = logo.Rect.Y;
|
||||
starsBlue.Rect.Y = logo.Rect.Y;
|
||||
if (LogoTimer.ElapsedMilliseconds >= 2000 && !CreditsTimer.IsRunning)
|
||||
CreditsTimer.Start();
|
||||
if (LogoTimer.ElapsedMilliseconds >= 3000)
|
||||
_Logo.Rect.Y = -270 + (270f / 3000f) * _LogoTimer.ElapsedMilliseconds;
|
||||
_StarsRed.Rect.Y = _Logo.Rect.Y;
|
||||
_StarsBlue.Rect.Y = _Logo.Rect.Y;
|
||||
if (_LogoTimer.ElapsedMilliseconds >= 2000 && !_CreditsTimer.IsRunning)
|
||||
_CreditsTimer.Start();
|
||||
if (_LogoTimer.ElapsedMilliseconds >= 3000)
|
||||
{
|
||||
LogoTimer.Stop();
|
||||
LogoTimer.Reset();
|
||||
_LogoTimer.Stop();
|
||||
_LogoTimer.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
if (CreditsTimer.IsRunning)
|
||||
if (_CreditsTimer.IsRunning)
|
||||
{
|
||||
active = true;
|
||||
|
||||
@@ -388,36 +388,36 @@ namespace Vocaluxe.Screens
|
||||
switch (_CreditNames[i].Direction)
|
||||
{
|
||||
case EDirection.Right:
|
||||
if (i * 4000f <= CreditsTimer.ElapsedMilliseconds)
|
||||
if (i * 4000f <= _CreditsTimer.ElapsedMilliseconds)
|
||||
{
|
||||
_CreditNames[i].X = -450 + (((CSettings.iRenderW - _CreditNames[i].W) / 2) / 3000f) * (CreditsTimer.ElapsedMilliseconds - (i * 4000f));
|
||||
_CreditNames[i].X = -450 + (((CSettings.RenderW - _CreditNames[i].W) / 2) / 3000f) * (_CreditsTimer.ElapsedMilliseconds - (i * 4000f));
|
||||
|
||||
//Check if name is in middle of screen and should go up
|
||||
if (_CreditNames[i].X >= (CSettings.iRenderW - _CreditNames[i].W) / 2)
|
||||
if (_CreditNames[i].X >= (CSettings.RenderW - _CreditNames[i].W) / 2)
|
||||
{
|
||||
_CreditNames[i].Direction = EDirection.Up;
|
||||
_CreditNames[i].StartTimeUp = CreditsTimer.ElapsedMilliseconds;
|
||||
_CreditNames[i].StartTimeUp = _CreditsTimer.ElapsedMilliseconds;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EDirection.Left:
|
||||
if (i * 4000f <= CreditsTimer.ElapsedMilliseconds)
|
||||
if (i * 4000f <= _CreditsTimer.ElapsedMilliseconds)
|
||||
{
|
||||
_CreditNames[i].X = CSettings.iRenderW -
|
||||
(((CSettings.iRenderW - _CreditNames[i].W) / 2) / 3000f) * (CreditsTimer.ElapsedMilliseconds - (i * 4000f));
|
||||
_CreditNames[i].X = CSettings.RenderW -
|
||||
(((CSettings.RenderW - _CreditNames[i].W) / 2) / 3000f) * (_CreditsTimer.ElapsedMilliseconds - (i * 4000f));
|
||||
|
||||
//Check if name is in middle of screen and should go up
|
||||
if (_CreditNames[i].X <= (CSettings.iRenderW - _CreditNames[i].W) / 2)
|
||||
if (_CreditNames[i].X <= (CSettings.RenderW - _CreditNames[i].W) / 2)
|
||||
{
|
||||
_CreditNames[i].Direction = EDirection.Up;
|
||||
_CreditNames[i].StartTimeUp = CreditsTimer.ElapsedMilliseconds;
|
||||
_CreditNames[i].StartTimeUp = _CreditsTimer.ElapsedMilliseconds;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EDirection.Up:
|
||||
_CreditNames[i].Y = 580 - (430f / 3000f) * (CreditsTimer.ElapsedMilliseconds - _CreditNames[i].StartTimeUp);
|
||||
_CreditNames[i].Y = 580 - (430f / 3000f) * (_CreditsTimer.ElapsedMilliseconds - _CreditNames[i].StartTimeUp);
|
||||
|
||||
//Set name inactive
|
||||
if (_CreditNames[i].Y <= 160f)
|
||||
@@ -427,11 +427,11 @@ namespace Vocaluxe.Screens
|
||||
if (i == _CreditNames.Count - 1)
|
||||
{
|
||||
//Stop and reset timer for next time
|
||||
CreditsTimer.Stop();
|
||||
CreditsTimer.Reset();
|
||||
_CreditsTimer.Stop();
|
||||
_CreditsTimer.Reset();
|
||||
|
||||
//Start Text-Timer
|
||||
TextTimer.Start();
|
||||
_TextTimer.Start();
|
||||
active = true;
|
||||
}
|
||||
}
|
||||
@@ -453,8 +453,8 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
}
|
||||
|
||||
if (TextTimer.IsRunning)
|
||||
active = TextTimer.ElapsedMilliseconds <= 60000;
|
||||
if (_TextTimer.IsRunning)
|
||||
active = _TextTimer.ElapsedMilliseconds <= 60000;
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace Vocaluxe.Screens
|
||||
get { return 2; }
|
||||
}
|
||||
|
||||
private const int NumEntrys = 10;
|
||||
private const string TextSongName = "TextSongName";
|
||||
private const string TextSongMode = "TextSongMode";
|
||||
private string[] TextNumber;
|
||||
private string[] TextName;
|
||||
private string[] TextScore;
|
||||
private string[] TextDate;
|
||||
private string[] ParticleEffectNew;
|
||||
private const int _NumEntrys = 10;
|
||||
private const string _TextSongName = "TextSongName";
|
||||
private const string _TextSongMode = "TextSongMode";
|
||||
private string[] _TextNumber;
|
||||
private string[] _TextName;
|
||||
private string[] _TextScore;
|
||||
private string[] _TextDate;
|
||||
private string[] _ParticleEffectNew;
|
||||
|
||||
private List<SScores>[] _Scores;
|
||||
private List<int> _NewEntryIDs;
|
||||
@@ -35,48 +35,48 @@ namespace Vocaluxe.Screens
|
||||
base.Init();
|
||||
|
||||
List<string> texts = new List<string>();
|
||||
texts.Add(TextSongName);
|
||||
texts.Add(TextSongMode);
|
||||
texts.Add(_TextSongName);
|
||||
texts.Add(_TextSongMode);
|
||||
|
||||
TextNumber = new string[NumEntrys];
|
||||
for (int i = 0; i < NumEntrys; i++)
|
||||
_TextNumber = new string[_NumEntrys];
|
||||
for (int i = 0; i < _NumEntrys; i++)
|
||||
{
|
||||
TextNumber[i] = "TextNumber" + (i + 1).ToString();
|
||||
texts.Add(TextNumber[i]);
|
||||
_TextNumber[i] = "TextNumber" + (i + 1).ToString();
|
||||
texts.Add(_TextNumber[i]);
|
||||
}
|
||||
|
||||
TextName = new string[NumEntrys];
|
||||
for (int i = 0; i < NumEntrys; i++)
|
||||
_TextName = new string[_NumEntrys];
|
||||
for (int i = 0; i < _NumEntrys; i++)
|
||||
{
|
||||
TextName[i] = "TextName" + (i + 1).ToString();
|
||||
texts.Add(TextName[i]);
|
||||
_TextName[i] = "TextName" + (i + 1).ToString();
|
||||
texts.Add(_TextName[i]);
|
||||
}
|
||||
|
||||
TextScore = new string[NumEntrys];
|
||||
for (int i = 0; i < NumEntrys; i++)
|
||||
_TextScore = new string[_NumEntrys];
|
||||
for (int i = 0; i < _NumEntrys; i++)
|
||||
{
|
||||
TextScore[i] = "TextScore" + (i + 1).ToString();
|
||||
texts.Add(TextScore[i]);
|
||||
_TextScore[i] = "TextScore" + (i + 1).ToString();
|
||||
texts.Add(_TextScore[i]);
|
||||
}
|
||||
|
||||
TextDate = new string[NumEntrys];
|
||||
for (int i = 0; i < NumEntrys; i++)
|
||||
_TextDate = new string[_NumEntrys];
|
||||
for (int i = 0; i < _NumEntrys; i++)
|
||||
{
|
||||
TextDate[i] = "TextDate" + (i + 1).ToString();
|
||||
texts.Add(TextDate[i]);
|
||||
_TextDate[i] = "TextDate" + (i + 1).ToString();
|
||||
texts.Add(_TextDate[i]);
|
||||
}
|
||||
|
||||
ParticleEffectNew = new string[NumEntrys];
|
||||
for (int i = 0; i < NumEntrys; i++)
|
||||
ParticleEffectNew[i] = "ParticleEffectNew" + (i + 1).ToString();
|
||||
_ParticleEffectNew = new string[_NumEntrys];
|
||||
for (int i = 0; i < _NumEntrys; i++)
|
||||
_ParticleEffectNew[i] = "ParticleEffectNew" + (i + 1).ToString();
|
||||
|
||||
_ThemeTexts = texts.ToArray();
|
||||
_ThemeParticleEffects = ParticleEffectNew;
|
||||
_ThemeParticleEffects = _ParticleEffectNew;
|
||||
|
||||
_NewEntryIDs = new List<int>();
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode)) {}
|
||||
else
|
||||
@@ -86,23 +86,23 @@ namespace Vocaluxe.Screens
|
||||
case Keys.Escape:
|
||||
case Keys.Back:
|
||||
case Keys.Enter:
|
||||
LeaveScreen();
|
||||
_LeaveScreen();
|
||||
break;
|
||||
|
||||
case Keys.Down:
|
||||
ChangePos(1);
|
||||
_ChangePos(1);
|
||||
break;
|
||||
|
||||
case Keys.Up:
|
||||
ChangePos(-1);
|
||||
_ChangePos(-1);
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
ChangeRound(-1);
|
||||
_ChangeRound(-1);
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
ChangeRound(1);
|
||||
_ChangeRound(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -110,65 +110,65 @@ namespace Vocaluxe.Screens
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent)) {}
|
||||
|
||||
if (mouseEvent.LB)
|
||||
LeaveScreen();
|
||||
_LeaveScreen();
|
||||
|
||||
if (mouseEvent.RB)
|
||||
LeaveScreen();
|
||||
_LeaveScreen();
|
||||
|
||||
if (mouseEvent.MB)
|
||||
{
|
||||
int LastRound = _Round;
|
||||
ChangeRound(1);
|
||||
if (LastRound == _Round)
|
||||
int lastRound = _Round;
|
||||
_ChangeRound(1);
|
||||
if (lastRound == _Round)
|
||||
{
|
||||
_Round = 0;
|
||||
UpdateRound();
|
||||
_UpdateRound();
|
||||
}
|
||||
}
|
||||
|
||||
ChangePos(mouseEvent.Wheel);
|
||||
_ChangePos(mouseEvent.Wheel);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
for (int p = 0; p < NumEntrys; p++)
|
||||
for (int p = 0; p < _NumEntrys; p++)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
if (_IsNewEntry(_Scores[_Round][_Pos + p].ID))
|
||||
ParticleEffects[_ParticleEffectNew[p]].Visible = true;
|
||||
else
|
||||
ParticleEffects[ParticleEffectNew[p]].Visible = false;
|
||||
ParticleEffects[_ParticleEffectNew[p]].Visible = false;
|
||||
}
|
||||
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;
|
||||
@@ -179,19 +179,19 @@ namespace Vocaluxe.Screens
|
||||
base.OnShow();
|
||||
_Round = 0;
|
||||
_Pos = 0;
|
||||
CPoints _Points = CGame.GetPoints();
|
||||
_Scores = new List<SScores>[_Points.NumRounds];
|
||||
CPoints points = CGame.GetPoints();
|
||||
_Scores = new List<SScores>[points.NumRounds];
|
||||
for (int i = 0; i < _Scores.Length; i++)
|
||||
_Scores[i] = new List<SScores>();
|
||||
_NewEntryIDs.Clear();
|
||||
AddScoresToDB();
|
||||
LoadScores();
|
||||
UpdateRound();
|
||||
_AddScoresToDB();
|
||||
_LoadScores();
|
||||
_UpdateRound();
|
||||
|
||||
UpdateGame();
|
||||
}
|
||||
|
||||
private bool isNewEntry(int id)
|
||||
private bool _IsNewEntry(int id)
|
||||
{
|
||||
for (int i = 0; i < _NewEntryIDs.Count; i++)
|
||||
{
|
||||
@@ -202,7 +202,7 @@ namespace Vocaluxe.Screens
|
||||
return false;
|
||||
}
|
||||
|
||||
private void AddScoresToDB()
|
||||
private void _AddScoresToDB()
|
||||
{
|
||||
CPoints points = CGame.GetPoints();
|
||||
if (points == null)
|
||||
@@ -220,7 +220,7 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadScores()
|
||||
private void _LoadScores()
|
||||
{
|
||||
CPoints points = CGame.GetPoints();
|
||||
if (points == null)
|
||||
@@ -234,7 +234,7 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRound()
|
||||
private void _UpdateRound()
|
||||
{
|
||||
_IsDuet = false;
|
||||
CPoints points = CGame.GetPoints();
|
||||
@@ -243,65 +243,65 @@ namespace Vocaluxe.Screens
|
||||
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;
|
||||
}
|
||||
|
||||
_Pos = 0;
|
||||
}
|
||||
|
||||
private void ChangePos(int Num)
|
||||
private void _ChangePos(int num)
|
||||
{
|
||||
if (Num > 0)
|
||||
if (num > 0)
|
||||
{
|
||||
if (_Pos + Num + NumEntrys < _Scores[_Round].Count)
|
||||
_Pos += Num;
|
||||
if (_Pos + num + _NumEntrys < _Scores[_Round].Count)
|
||||
_Pos += num;
|
||||
}
|
||||
if (Num < 0)
|
||||
if (num < 0)
|
||||
{
|
||||
_Pos += Num;
|
||||
_Pos += num;
|
||||
if (_Pos < 0)
|
||||
_Pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeRound(int Num)
|
||||
private void _ChangeRound(int num)
|
||||
{
|
||||
CPoints _Points = CGame.GetPoints();
|
||||
if (_Round + Num < _Points.NumRounds && _Round + Num > -1)
|
||||
_Round += Num;
|
||||
else if (_Round + Num >= _Points.NumRounds)
|
||||
_Round = _Points.NumRounds - 1;
|
||||
else if (_Round + Num < 0)
|
||||
CPoints points = CGame.GetPoints();
|
||||
if (_Round + num < points.NumRounds && _Round + num > -1)
|
||||
_Round += num;
|
||||
else if (_Round + num >= points.NumRounds)
|
||||
_Round = points.NumRounds - 1;
|
||||
else if (_Round + num < 0)
|
||||
_Round = 0;
|
||||
UpdateRound();
|
||||
_UpdateRound();
|
||||
}
|
||||
|
||||
private void LeaveScreen()
|
||||
private void _LeaveScreen()
|
||||
{
|
||||
CParty.LeavingHighscore();
|
||||
}
|
||||
|
||||
@@ -13,18 +13,18 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
private const float WaitTime = 0.5f; //wait time before starting first video
|
||||
private const float _WaitTime = 0.5f; //wait time before starting first video
|
||||
|
||||
private const string TextStatus = "TextStatus";
|
||||
private const string _TextStatus = "TextStatus";
|
||||
|
||||
private readonly string[] IntroVideo = new string[] {"IntroIn", "IntroMid", "IntroOut"};
|
||||
private readonly string[] _IntroVideo = new string[] {"IntroIn", "IntroMid", "IntroOut"};
|
||||
|
||||
private Thread _SongLoaderThread;
|
||||
private Stopwatch _timer;
|
||||
private Stopwatch _Timer;
|
||||
private bool _SkipIntro;
|
||||
private int _CurrentIntroVideoNr;
|
||||
private bool _IntroOutPlayed;
|
||||
private VideoPlayer[] _Intros;
|
||||
private CVideoPlayer[] _Intros;
|
||||
|
||||
private bool _BGMusicStartet;
|
||||
|
||||
@@ -32,14 +32,14 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeTexts = new string[] {TextStatus};
|
||||
_Intros = new VideoPlayer[IntroVideo.Length];
|
||||
_ThemeTexts = new string[] {_TextStatus};
|
||||
_Intros = new CVideoPlayer[_IntroVideo.Length];
|
||||
for (int i = 0; i < _Intros.Length; i++)
|
||||
_Intros[i] = new VideoPlayer();
|
||||
_timer = new Stopwatch();
|
||||
_Intros[i] = new CVideoPlayer();
|
||||
_Timer = new Stopwatch();
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Vocaluxe.Screens
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Vocaluxe.Screens
|
||||
_SongLoaderThread = new Thread(CSongs.LoadSongs);
|
||||
_SongLoaderThread.Name = "SongLoader";
|
||||
|
||||
Texts[TextStatus].Text = CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": 0 " +
|
||||
Texts[_TextStatus].Text = CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": 0 " +
|
||||
CLanguage.Translate("TR_SCREENLOAD_SONGS") + " (0 " +
|
||||
CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")";
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Vocaluxe.Screens
|
||||
if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
for (int i = 0; i < _Intros.Length; i++)
|
||||
_Intros[i].Load(IntroVideo[i]);
|
||||
_Intros[i].Load(_IntroVideo[i]);
|
||||
}
|
||||
|
||||
_BGMusicStartet = false;
|
||||
@@ -117,7 +117,7 @@ namespace Vocaluxe.Screens
|
||||
CLog.StartBenchmark(0, "Load Songs Full");
|
||||
_SongLoaderThread.IsBackground = true;
|
||||
_SongLoaderThread.Start();
|
||||
_timer.Start();
|
||||
_Timer.Start();
|
||||
|
||||
if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON &&
|
||||
CConfig.BackgroundMusicSource == EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC && !_BGMusicStartet)
|
||||
@@ -135,12 +135,12 @@ namespace Vocaluxe.Screens
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
CheckStartIntroVideos();
|
||||
_CheckStartIntroVideos();
|
||||
|
||||
if (CSettings.GameState == EGameState.EditTheme)
|
||||
_timer.Stop();
|
||||
_Timer.Stop();
|
||||
else
|
||||
_timer.Start();
|
||||
_Timer.Start();
|
||||
|
||||
bool next = CConfig.CoverLoading != ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART || CSongs.CoverLoaded;
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Vocaluxe.Screens
|
||||
if (CSettings.GameState == EGameState.Normal)
|
||||
CGraphics.FadeTo(EScreens.ScreenMain);
|
||||
|
||||
Texts[TextStatus].Text =
|
||||
Texts[_TextStatus].Text =
|
||||
CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": " + CSongs.NumAllSongs.ToString() + " " +
|
||||
CLanguage.Translate("TR_SCREENLOAD_SONGS") + " (" + CSongs.NumSongsWithCoverLoaded + " " +
|
||||
CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")";
|
||||
@@ -183,8 +183,8 @@ namespace Vocaluxe.Screens
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
_timer.Stop();
|
||||
_timer.Reset();
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
|
||||
for (int i = 0; i < _Intros.Length; i++)
|
||||
_Intros[i].Close();
|
||||
@@ -199,7 +199,7 @@ namespace Vocaluxe.Screens
|
||||
CLog.StopBenchmark(0, "Init Playlists");
|
||||
}
|
||||
|
||||
private void CheckStartIntroVideos()
|
||||
private void _CheckStartIntroVideos()
|
||||
{
|
||||
if (_IntroOutPlayed)
|
||||
return;
|
||||
|
||||
@@ -12,11 +12,11 @@ namespace Vocaluxe.Screens
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
private const string ButtonSing = "ButtonSing";
|
||||
private const string ButtonParty = "ButtonParty";
|
||||
private const string ButtonOptions = "ButtonOptions";
|
||||
private const string ButtonProfiles = "ButtonProfiles";
|
||||
private const string ButtonExit = "ButtonExit";
|
||||
private const string _ButtonSing = "ButtonSing";
|
||||
private const string _ButtonParty = "ButtonParty";
|
||||
private const string _ButtonOptions = "ButtonOptions";
|
||||
private const string _ButtonProfiles = "ButtonProfiles";
|
||||
private const string _ButtonExit = "ButtonExit";
|
||||
|
||||
//CParticleEffect Snowflakes;
|
||||
public override void Init()
|
||||
@@ -24,10 +24,10 @@ namespace Vocaluxe.Screens
|
||||
base.Init();
|
||||
|
||||
_ThemeStatics = new string[] {"StaticMenuBar"};
|
||||
_ThemeButtons = new string[] {ButtonSing, ButtonParty, ButtonOptions, ButtonProfiles, ButtonExit};
|
||||
_ThemeButtons = new string[] {_ButtonSing, _ButtonParty, _ButtonOptions, _ButtonProfiles, _ButtonExit};
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
@@ -53,22 +53,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;
|
||||
@@ -77,28 +77,28 @@ namespace Vocaluxe.Screens
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(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;
|
||||
}
|
||||
|
||||
|
||||
+269
-269
@@ -14,33 +14,33 @@ namespace Vocaluxe.Screens
|
||||
get { return 3; }
|
||||
}
|
||||
|
||||
private CStatic chooseAvatarStatic;
|
||||
private int OldMouseX;
|
||||
private int OldMouseY;
|
||||
private CStatic _ChooseAvatarStatic;
|
||||
private int _OldMouseX;
|
||||
private int _OldMouseY;
|
||||
|
||||
private const string SelectSlidePlayerNumber = "SelectSlidePlayerNumber";
|
||||
private const string NameSelection = "NameSelection";
|
||||
private const string ButtonBack = "ButtonBack";
|
||||
private const string ButtonStart = "ButtonStart";
|
||||
private const string TextWarningMics = "TextWarningMics";
|
||||
private const string StaticWarningMics = "StaticWarningMics";
|
||||
private const string TextWarningProfiles = "TextWarningProfiles";
|
||||
private const string StaticWarningProfiles = "StaticWarningProfiles";
|
||||
private readonly string[] StaticPlayer = new string[] {"StaticPlayer1", "StaticPlayer2", "StaticPlayer3", "StaticPlayer4", "StaticPlayer5", "StaticPlayer6"};
|
||||
private readonly string[] StaticPlayerAvatar = new string[]
|
||||
private const string _SelectSlidePlayerNumber = "SelectSlidePlayerNumber";
|
||||
private const string _NameSelection = "NameSelection";
|
||||
private const string _ButtonBack = "ButtonBack";
|
||||
private const string _ButtonStart = "ButtonStart";
|
||||
private const string _TextWarningMics = "TextWarningMics";
|
||||
private const string _StaticWarningMics = "StaticWarningMics";
|
||||
private const string _TextWarningProfiles = "TextWarningProfiles";
|
||||
private const string _StaticWarningProfiles = "StaticWarningProfiles";
|
||||
private readonly string[] _StaticPlayer = new string[] {"StaticPlayer1", "StaticPlayer2", "StaticPlayer3", "StaticPlayer4", "StaticPlayer5", "StaticPlayer6"};
|
||||
private readonly string[] _StaticPlayerAvatar = new string[]
|
||||
{"StaticPlayerAvatar1", "StaticPlayerAvatar2", "StaticPlayerAvatar3", "StaticPlayerAvatar4", "StaticPlayerAvatar5", "StaticPlayerAvatar6"};
|
||||
private readonly string[] TextPlayer = new string[] {"TextPlayer1", "TextPlayer2", "TextPlayer3", "TextPlayer4", "TextPlayer5", "TextPlayer6"};
|
||||
private readonly string[] EqualizerPlayer = new string[]
|
||||
private readonly string[] _TextPlayer = new string[] {"TextPlayer1", "TextPlayer2", "TextPlayer3", "TextPlayer4", "TextPlayer5", "TextPlayer6"};
|
||||
private readonly string[] _EqualizerPlayer = new string[]
|
||||
{"EqualizerPlayer1", "EqualizerPlayer2", "EqualizerPlayer3", "EqualizerPlayer4", "EqualizerPlayer5", "EqualizerPlayer6"};
|
||||
private readonly string[] SelectSlideDuetPlayer = new string[]
|
||||
private readonly string[] _SelectSlideDuetPlayer = new string[]
|
||||
{"SelectSlideDuetPlayer1", "SelectSlideDuetPlayer2", "SelectSlideDuetPlayer3", "SelectSlideDuetPlayer4", "SelectSlideDuetPlayer5", "SelectSlideDuetPlayer6"};
|
||||
private readonly STexture[] OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer];
|
||||
private readonly STexture[] _OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer];
|
||||
|
||||
private bool selectingMouseActive;
|
||||
private bool selectingKeyboardActive;
|
||||
private bool selectingKeyboardUnendless;
|
||||
private int selectingKeyboardPlayerNr;
|
||||
private int SelectedPlayerNr;
|
||||
private bool _SelectingMouseActive;
|
||||
private bool _SelectingKeyboardActive;
|
||||
private bool _SelectingKeyboardUnendless;
|
||||
private int _SelectingKeyboardPlayerNr;
|
||||
private int _SelectedPlayerNr;
|
||||
|
||||
private int[] _PlayerNr;
|
||||
|
||||
@@ -49,291 +49,291 @@ namespace Vocaluxe.Screens
|
||||
base.Init();
|
||||
|
||||
List<string> statics = new List<string>();
|
||||
foreach (string text in StaticPlayer)
|
||||
foreach (string text in _StaticPlayer)
|
||||
statics.Add(text);
|
||||
foreach (string text in StaticPlayerAvatar)
|
||||
foreach (string text in _StaticPlayerAvatar)
|
||||
statics.Add(text);
|
||||
statics.Add(StaticWarningMics);
|
||||
statics.Add(StaticWarningProfiles);
|
||||
statics.Add(_StaticWarningMics);
|
||||
statics.Add(_StaticWarningProfiles);
|
||||
_ThemeStatics = statics.ToArray();
|
||||
|
||||
List<string> texts = new List<string>();
|
||||
texts.Add(SelectSlidePlayerNumber);
|
||||
texts.AddRange(SelectSlideDuetPlayer);
|
||||
texts.Add(_SelectSlidePlayerNumber);
|
||||
texts.AddRange(_SelectSlideDuetPlayer);
|
||||
_ThemeSelectSlides = texts.ToArray();
|
||||
|
||||
texts.Clear();
|
||||
texts.Add(TextWarningMics);
|
||||
texts.Add(TextWarningProfiles);
|
||||
foreach (string text in TextPlayer)
|
||||
texts.Add(_TextWarningMics);
|
||||
texts.Add(_TextWarningProfiles);
|
||||
foreach (string text in _TextPlayer)
|
||||
texts.Add(text);
|
||||
_ThemeTexts = texts.ToArray();
|
||||
|
||||
texts.Clear();
|
||||
texts.Add(ButtonBack);
|
||||
texts.Add(ButtonStart);
|
||||
texts.Add(_ButtonBack);
|
||||
texts.Add(_ButtonStart);
|
||||
|
||||
_ThemeButtons = texts.ToArray();
|
||||
|
||||
texts.Clear();
|
||||
texts.Add(NameSelection);
|
||||
texts.Add(_NameSelection);
|
||||
_ThemeNameSelections = texts.ToArray();
|
||||
|
||||
texts.Clear();
|
||||
texts.AddRange(EqualizerPlayer);
|
||||
texts.AddRange(_EqualizerPlayer);
|
||||
_ThemeEqualizers = texts.ToArray();
|
||||
|
||||
chooseAvatarStatic = GetNewStatic();
|
||||
chooseAvatarStatic.Visible = false;
|
||||
_ChooseAvatarStatic = GetNewStatic();
|
||||
_ChooseAvatarStatic.Visible = false;
|
||||
}
|
||||
|
||||
public override void LoadTheme(string XmlPath)
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
base.LoadTheme(XmlPath);
|
||||
base.LoadTheme(xmlPath);
|
||||
|
||||
_PlayerNr = new int[CSettings.MaxNumPlayer];
|
||||
for (int i = 0; i < _PlayerNr.Length; i++)
|
||||
_PlayerNr[i] = i;
|
||||
|
||||
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
|
||||
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;
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent keyEvent)
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Add:
|
||||
if (CConfig.NumPlayer + 1 <= CSettings.MaxNumPlayer)
|
||||
{
|
||||
SelectSlides[SelectSlidePlayerNumber].Selection = CConfig.NumPlayer;
|
||||
UpdatePlayerNumber();
|
||||
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;
|
||||
UpdatePlayerNumber();
|
||||
SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 2;
|
||||
_UpdatePlayerNumber();
|
||||
//Update Tiles-List
|
||||
NameSelections[NameSelection].UpdateList();
|
||||
NameSelections[_NameSelection].UpdateList();
|
||||
}
|
||||
break;
|
||||
|
||||
case Keys.P:
|
||||
if (!selectingKeyboardActive)
|
||||
if (!_SelectingKeyboardActive)
|
||||
{
|
||||
selectingKeyboardPlayerNr = 1;
|
||||
selectingKeyboardUnendless = true;
|
||||
_SelectingKeyboardPlayerNr = 1;
|
||||
_SelectingKeyboardUnendless = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectingKeyboardPlayerNr + 1 <= CGame.NumPlayer)
|
||||
selectingKeyboardPlayerNr++;
|
||||
if (_SelectingKeyboardPlayerNr + 1 <= CGame.NumPlayer)
|
||||
_SelectingKeyboardPlayerNr++;
|
||||
else
|
||||
selectingKeyboardPlayerNr = 1;
|
||||
NameSelections[NameSelection].KeyboardSelection(true, selectingKeyboardPlayerNr);
|
||||
_SelectingKeyboardPlayerNr = 1;
|
||||
NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
//Check if selecting with keyboard is active
|
||||
if (selectingKeyboardActive)
|
||||
if (_SelectingKeyboardActive)
|
||||
{
|
||||
//Handle left/right/up/down
|
||||
NameSelections[NameSelection].HandleInput(keyEvent);
|
||||
NameSelections[_NameSelection].HandleInput(keyEvent);
|
||||
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.Player[_SelectingKeyboardPlayerNr - 1].Name = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
|
||||
CGame.Player[_SelectingKeyboardPlayerNr - 1].Difficulty = CProfiles.Profiles[_SelectedPlayerNr].Difficulty;
|
||||
CGame.Player[_SelectingKeyboardPlayerNr - 1].ProfileID = _SelectedPlayerNr;
|
||||
//Update config for default players.
|
||||
CConfig.Players[selectingKeyboardPlayerNr - 1] = CProfiles.Profiles[SelectedPlayerNr].ProfileFile;
|
||||
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();
|
||||
_CheckPlayers();
|
||||
//Update Tiles-List
|
||||
NameSelections[NameSelection].UpdateList();
|
||||
SetInteractionToButton(Buttons[ButtonStart]);
|
||||
NameSelections[_NameSelection].UpdateList();
|
||||
SetInteractionToButton(Buttons[_ButtonStart]);
|
||||
}
|
||||
//Started selecting with 'P'
|
||||
if (selectingKeyboardUnendless)
|
||||
if (_SelectingKeyboardUnendless)
|
||||
{
|
||||
if (selectingKeyboardPlayerNr == CGame.NumPlayer)
|
||||
if (_SelectingKeyboardPlayerNr == CGame.NumPlayer)
|
||||
{
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
NameSelections[_NameSelection].KeyboardSelection(false, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectingKeyboardPlayerNr++;
|
||||
NameSelections[NameSelection].KeyboardSelection(true, selectingKeyboardPlayerNr);
|
||||
_SelectingKeyboardPlayerNr++;
|
||||
NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
NameSelections[_NameSelection].KeyboardSelection(false, -1);
|
||||
}
|
||||
break;
|
||||
|
||||
case Keys.D1:
|
||||
case Keys.NumPad1:
|
||||
if (selectingKeyboardPlayerNr == 1)
|
||||
if (_SelectingKeyboardPlayerNr == 1)
|
||||
{
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
NameSelections[_NameSelection].KeyboardSelection(false, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectingKeyboardPlayerNr = 1;
|
||||
NameSelections[NameSelection].KeyboardSelection(true, 1);
|
||||
_SelectingKeyboardPlayerNr = 1;
|
||||
NameSelections[_NameSelection].KeyboardSelection(true, 1);
|
||||
}
|
||||
selectingKeyboardUnendless = false;
|
||||
_SelectingKeyboardUnendless = false;
|
||||
break;
|
||||
case Keys.D2:
|
||||
case Keys.NumPad2:
|
||||
if (selectingKeyboardPlayerNr == 2)
|
||||
if (_SelectingKeyboardPlayerNr == 2)
|
||||
{
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
NameSelections[_NameSelection].KeyboardSelection(false, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectingKeyboardPlayerNr = 2;
|
||||
NameSelections[NameSelection].KeyboardSelection(true, 2);
|
||||
_SelectingKeyboardPlayerNr = 2;
|
||||
NameSelections[_NameSelection].KeyboardSelection(true, 2);
|
||||
}
|
||||
selectingKeyboardUnendless = false;
|
||||
_SelectingKeyboardUnendless = false;
|
||||
break;
|
||||
case Keys.D3:
|
||||
case Keys.NumPad3:
|
||||
if (selectingKeyboardPlayerNr == 3)
|
||||
if (_SelectingKeyboardPlayerNr == 3)
|
||||
{
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
NameSelections[_NameSelection].KeyboardSelection(false, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectingKeyboardPlayerNr = 3;
|
||||
NameSelections[NameSelection].KeyboardSelection(true, 3);
|
||||
_SelectingKeyboardPlayerNr = 3;
|
||||
NameSelections[_NameSelection].KeyboardSelection(true, 3);
|
||||
}
|
||||
selectingKeyboardUnendless = false;
|
||||
_SelectingKeyboardUnendless = false;
|
||||
break;
|
||||
case Keys.D4:
|
||||
case Keys.NumPad4:
|
||||
if (selectingKeyboardPlayerNr == 4)
|
||||
if (_SelectingKeyboardPlayerNr == 4)
|
||||
{
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
NameSelections[_NameSelection].KeyboardSelection(false, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectingKeyboardPlayerNr = 4;
|
||||
NameSelections[NameSelection].KeyboardSelection(true, 4);
|
||||
_SelectingKeyboardPlayerNr = 4;
|
||||
NameSelections[_NameSelection].KeyboardSelection(true, 4);
|
||||
}
|
||||
selectingKeyboardUnendless = false;
|
||||
_SelectingKeyboardUnendless = false;
|
||||
break;
|
||||
case Keys.D5:
|
||||
case Keys.NumPad5:
|
||||
if (selectingKeyboardPlayerNr == 5)
|
||||
if (_SelectingKeyboardPlayerNr == 5)
|
||||
{
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
NameSelections[_NameSelection].KeyboardSelection(false, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectingKeyboardPlayerNr = 5;
|
||||
NameSelections[NameSelection].KeyboardSelection(true, 5);
|
||||
_SelectingKeyboardPlayerNr = 5;
|
||||
NameSelections[_NameSelection].KeyboardSelection(true, 5);
|
||||
}
|
||||
selectingKeyboardUnendless = false;
|
||||
_SelectingKeyboardUnendless = false;
|
||||
break;
|
||||
case Keys.D6:
|
||||
case Keys.NumPad6:
|
||||
if (selectingKeyboardPlayerNr == 6)
|
||||
if (_SelectingKeyboardPlayerNr == 6)
|
||||
{
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
NameSelections[_NameSelection].KeyboardSelection(false, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectingKeyboardPlayerNr = 6;
|
||||
NameSelections[NameSelection].KeyboardSelection(true, 6);
|
||||
_SelectingKeyboardPlayerNr = 6;
|
||||
NameSelections[_NameSelection].KeyboardSelection(true, 6);
|
||||
}
|
||||
selectingKeyboardUnendless = false;
|
||||
_SelectingKeyboardUnendless = false;
|
||||
break;
|
||||
|
||||
case Keys.Escape:
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
selectingKeyboardUnendless = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
_SelectingKeyboardUnendless = false;
|
||||
NameSelections[_NameSelection].KeyboardSelection(false, -1);
|
||||
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.Player[_SelectingKeyboardPlayerNr - 1].ProfileID = -1;
|
||||
CGame.Player[_SelectingKeyboardPlayerNr - 1].Name = String.Empty;
|
||||
CGame.Player[_SelectingKeyboardPlayerNr - 1].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
|
||||
//Update config for default players.
|
||||
CConfig.Players[selectingKeyboardPlayerNr - 1] = String.Empty;
|
||||
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 = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + _SelectingKeyboardPlayerNr.ToString();
|
||||
//Update profile-warning
|
||||
CheckPlayers();
|
||||
_CheckPlayers();
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
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;
|
||||
if (SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]].Selection == 0)
|
||||
SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]].Selection = 1;
|
||||
else
|
||||
SelectSlides[SelectSlideDuetPlayer[selectingKeyboardPlayerNr - 1]].Selection = 0;
|
||||
SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]].Selection = 0;
|
||||
//Reset all values
|
||||
selectingKeyboardPlayerNr = 0;
|
||||
selectingKeyboardActive = false;
|
||||
selectingKeyboardUnendless = false;
|
||||
NameSelections[NameSelection].KeyboardSelection(false, -1);
|
||||
SetInteractionToButton(Buttons[ButtonStart]);
|
||||
_SelectingKeyboardPlayerNr = 0;
|
||||
_SelectingKeyboardActive = false;
|
||||
_SelectingKeyboardUnendless = false;
|
||||
NameSelections[_NameSelection].KeyboardSelection(false, -1);
|
||||
SetInteractionToButton(Buttons[_ButtonStart]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -352,7 +352,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
case Keys.Enter:
|
||||
|
||||
if (!processed && Buttons[ButtonBack].Selected)
|
||||
if (!processed && Buttons[_ButtonBack].Selected)
|
||||
{
|
||||
processed = true;
|
||||
CGraphics.FadeTo(EScreens.ScreenSong);
|
||||
@@ -361,132 +361,132 @@ namespace Vocaluxe.Screens
|
||||
if (!processed /* && Buttons[ButtonStart].Selected */)
|
||||
{
|
||||
processed = true;
|
||||
StartSong();
|
||||
_StartSong();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Keys.D1:
|
||||
case Keys.NumPad1:
|
||||
selectingKeyboardPlayerNr = 1;
|
||||
_SelectingKeyboardPlayerNr = 1;
|
||||
break;
|
||||
|
||||
case Keys.D2:
|
||||
case Keys.NumPad2:
|
||||
selectingKeyboardPlayerNr = 2;
|
||||
_SelectingKeyboardPlayerNr = 2;
|
||||
break;
|
||||
|
||||
case Keys.D3:
|
||||
case Keys.NumPad3:
|
||||
selectingKeyboardPlayerNr = 3;
|
||||
_SelectingKeyboardPlayerNr = 3;
|
||||
break;
|
||||
|
||||
case Keys.D4:
|
||||
case Keys.NumPad4:
|
||||
selectingKeyboardPlayerNr = 4;
|
||||
_SelectingKeyboardPlayerNr = 4;
|
||||
break;
|
||||
|
||||
case Keys.D5:
|
||||
case Keys.NumPad5:
|
||||
selectingKeyboardPlayerNr = 5;
|
||||
_SelectingKeyboardPlayerNr = 5;
|
||||
break;
|
||||
|
||||
case Keys.D6:
|
||||
case Keys.NumPad6:
|
||||
selectingKeyboardPlayerNr = 6;
|
||||
_SelectingKeyboardPlayerNr = 6;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!processed)
|
||||
UpdatePlayerNumber();
|
||||
_UpdatePlayerNumber();
|
||||
|
||||
if (selectingKeyboardPlayerNr > 0 && selectingKeyboardPlayerNr <= CConfig.NumPlayer)
|
||||
if (_SelectingKeyboardPlayerNr > 0 && _SelectingKeyboardPlayerNr <= CConfig.NumPlayer)
|
||||
{
|
||||
selectingKeyboardActive = true;
|
||||
NameSelections[NameSelection].KeyboardSelection(true, selectingKeyboardPlayerNr);
|
||||
_SelectingKeyboardActive = true;
|
||||
NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent mouseEvent)
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
{
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode inactive
|
||||
if (mouseEvent.LBH && !selectingMouseActive)
|
||||
if (mouseEvent.LBH && !_SelectingMouseActive)
|
||||
{
|
||||
//Save mouse-coords
|
||||
OldMouseX = mouseEvent.X;
|
||||
OldMouseY = mouseEvent.Y;
|
||||
_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);
|
||||
if (SelectedPlayerNr != -1)
|
||||
_SelectedPlayerNr = NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
|
||||
if (_SelectedPlayerNr != -1)
|
||||
{
|
||||
//Activate mouse-selecting
|
||||
selectingMouseActive = true;
|
||||
_SelectingMouseActive = true;
|
||||
|
||||
//Update of Drag/Drop-Texture
|
||||
CStatic SelectedPlayer = NameSelections[NameSelection].TilePlayerAvatar(mouseEvent);
|
||||
chooseAvatarStatic.Visible = true;
|
||||
chooseAvatarStatic.Rect = SelectedPlayer.Rect;
|
||||
chooseAvatarStatic.Rect.Z = CSettings.zNear;
|
||||
chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
|
||||
chooseAvatarStatic.Texture = SelectedPlayer.Texture;
|
||||
CStatic selectedPlayer = NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
|
||||
_ChooseAvatarStatic.Visible = true;
|
||||
_ChooseAvatarStatic.Rect = selectedPlayer.Rect;
|
||||
_ChooseAvatarStatic.Rect.Z = CSettings.ZNear;
|
||||
_ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
|
||||
_ChooseAvatarStatic.Texture = selectedPlayer.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode active
|
||||
if (mouseEvent.LBH && selectingMouseActive)
|
||||
if (mouseEvent.LBH && _SelectingMouseActive)
|
||||
{
|
||||
//Update coords for Drag/Drop-Texture
|
||||
chooseAvatarStatic.Rect.X += mouseEvent.X - OldMouseX;
|
||||
chooseAvatarStatic.Rect.Y += mouseEvent.Y - OldMouseY;
|
||||
OldMouseX = mouseEvent.X;
|
||||
OldMouseY = mouseEvent.Y;
|
||||
_ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX;
|
||||
_ChooseAvatarStatic.Rect.Y += mouseEvent.Y - _OldMouseY;
|
||||
_OldMouseX = mouseEvent.X;
|
||||
_OldMouseY = mouseEvent.Y;
|
||||
}
|
||||
// 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 -> "ReplacedStr:::0:::" of Avatar
|
||||
else if (_SelectingMouseActive)
|
||||
{
|
||||
//Check if really a player was selected
|
||||
if (SelectedPlayerNr != -1)
|
||||
if (_SelectedPlayerNr != -1)
|
||||
{
|
||||
//Foreach Drop-Area
|
||||
for (int i = 0; i < StaticPlayer.Length; i++)
|
||||
for (int i = 0; i < _StaticPlayer.Length; i++)
|
||||
{
|
||||
//Check first, if area is "active"
|
||||
if (Statics[StaticPlayer[i]].Visible)
|
||||
//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))
|
||||
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;
|
||||
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.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;
|
||||
Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture;
|
||||
Texts[_TextPlayer[i]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
|
||||
//Update profile-warning
|
||||
CheckPlayers();
|
||||
_CheckPlayers();
|
||||
//Update Tiles-List
|
||||
NameSelections[NameSelection].UpdateList();
|
||||
NameSelections[_NameSelection].UpdateList();
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectedPlayerNr = -1;
|
||||
_SelectedPlayerNr = -1;
|
||||
}
|
||||
//Reset variables
|
||||
selectingMouseActive = false;
|
||||
chooseAvatarStatic.Visible = false;
|
||||
_SelectingMouseActive = false;
|
||||
_ChooseAvatarStatic.Visible = false;
|
||||
}
|
||||
|
||||
if (mouseEvent.LB && IsMouseOver(mouseEvent)) {}
|
||||
@@ -495,22 +495,22 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
if (!processed && Buttons[ButtonBack].Selected)
|
||||
if (!processed && Buttons[_ButtonBack].Selected)
|
||||
{
|
||||
processed = true;
|
||||
CGraphics.FadeTo(EScreens.ScreenSong);
|
||||
}
|
||||
|
||||
if (!processed && Buttons[ButtonStart].Selected)
|
||||
if (!processed && Buttons[_ButtonStart].Selected)
|
||||
{
|
||||
processed = true;
|
||||
StartSong();
|
||||
_StartSong();
|
||||
}
|
||||
|
||||
if (!processed)
|
||||
UpdatePlayerNumber();
|
||||
_UpdatePlayerNumber();
|
||||
//Update Tiles-List
|
||||
NameSelections[NameSelection].UpdateList();
|
||||
NameSelections[_NameSelection].UpdateList();
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
@@ -519,7 +519,7 @@ 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;
|
||||
@@ -528,12 +528,12 @@ namespace Vocaluxe.Screens
|
||||
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 = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + (i + 1).ToString();
|
||||
//Update profile-warning
|
||||
CheckPlayers();
|
||||
_CheckPlayers();
|
||||
//Update Tiles-List
|
||||
NameSelections[NameSelection].UpdateList();
|
||||
NameSelections[_NameSelection].UpdateList();
|
||||
exit = false;
|
||||
}
|
||||
}
|
||||
@@ -544,10 +544,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;
|
||||
@@ -568,12 +568,12 @@ namespace Vocaluxe.Screens
|
||||
base.OnShow();
|
||||
CSound.RecordStart();
|
||||
|
||||
NameSelections[NameSelection].Init();
|
||||
NameSelections[_NameSelection].Init();
|
||||
|
||||
UpdateSlides();
|
||||
UpdatePlayerNumber();
|
||||
CheckMics();
|
||||
CheckPlayers();
|
||||
_UpdateSlides();
|
||||
_UpdatePlayerNumber();
|
||||
_CheckMics();
|
||||
_CheckPlayers();
|
||||
|
||||
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
|
||||
{
|
||||
@@ -582,29 +582,29 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
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.Profiles[CGame.Player[i].ProfileID].Avatar.Texture;
|
||||
Texts[_TextPlayer[i]].Text = CProfiles.Profiles[CGame.Player[i].ProfileID].PlayerName;
|
||||
}
|
||||
}
|
||||
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
|
||||
{
|
||||
SelectSlides[SelectSlideDuetPlayer[i]].Clear();
|
||||
SelectSlides[_SelectSlideDuetPlayer[i]].Clear();
|
||||
if (i + 1 <= CGame.NumPlayer)
|
||||
SelectSlides[SelectSlideDuetPlayer[i]].Visible = true;
|
||||
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);
|
||||
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;
|
||||
SelectSlides[_SelectSlideDuetPlayer[i]].Selection = 1;
|
||||
else
|
||||
SelectSlides[SelectSlideDuetPlayer[i]].Selection = 0;
|
||||
SelectSlides[_SelectSlideDuetPlayer[i]].Selection = 0;
|
||||
}
|
||||
else
|
||||
SelectSlides[SelectSlideDuetPlayer[i]].Visible = false;
|
||||
SelectSlides[_SelectSlideDuetPlayer[i]].Visible = false;
|
||||
}
|
||||
|
||||
SetInteractionToButton(Buttons[ButtonStart]);
|
||||
SetInteractionToButton(Buttons[_ButtonStart]);
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
@@ -617,14 +617,14 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
base.Draw();
|
||||
|
||||
if (chooseAvatarStatic.Visible)
|
||||
chooseAvatarStatic.Draw();
|
||||
if (_ChooseAvatarStatic.Visible)
|
||||
_ChooseAvatarStatic.Draw();
|
||||
for (int i = 1; i <= CGame.NumPlayer; i++)
|
||||
Equalizers["EqualizerPlayer" + i].Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void StartSong()
|
||||
private void _StartSong()
|
||||
{
|
||||
for (int i = 0; i < CGame.NumPlayer; i++)
|
||||
{
|
||||
@@ -641,24 +641,24 @@ namespace Vocaluxe.Screens
|
||||
CGame.Player[i].Name = "";
|
||||
}
|
||||
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
|
||||
CGame.Player[i].LineNr = SelectSlides[SelectSlideDuetPlayer[i]].Selection;
|
||||
CGame.Player[i].LineNr = SelectSlides[_SelectSlideDuetPlayer[i]].Selection;
|
||||
}
|
||||
|
||||
CGraphics.FadeTo(EScreens.ScreenSing);
|
||||
}
|
||||
|
||||
private void UpdateSlides()
|
||||
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()
|
||||
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)
|
||||
@@ -682,84 +682,84 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
}
|
||||
CConfig.SaveConfig();
|
||||
CheckMics();
|
||||
CheckPlayers();
|
||||
_CheckMics();
|
||||
_CheckPlayers();
|
||||
}
|
||||
|
||||
private void CheckMics()
|
||||
private void _CheckMics()
|
||||
{
|
||||
List<int> _PlayerWithoutMicro = new List<int>();
|
||||
List<int> playerWithoutMicro = new List<int>();
|
||||
for (int player = 0; player < CConfig.NumPlayer; player++)
|
||||
{
|
||||
if (!CConfig.IsMicConfig(player + 1))
|
||||
_PlayerWithoutMicro.Add(player + 1);
|
||||
playerWithoutMicro.Add(player + 1);
|
||||
}
|
||||
if (_PlayerWithoutMicro.Count > 0)
|
||||
if (playerWithoutMicro.Count > 0)
|
||||
{
|
||||
Statics[StaticWarningMics].Visible = true;
|
||||
Texts[TextWarningMics].Visible = true;
|
||||
Statics[_StaticWarningMics].Visible = true;
|
||||
Texts[_TextWarningMics].Visible = true;
|
||||
|
||||
if (_PlayerWithoutMicro.Count > 1)
|
||||
if (playerWithoutMicro.Count > 1)
|
||||
{
|
||||
string PlayerNums = string.Empty;
|
||||
for (int i = 0; i < _PlayerWithoutMicro.Count; i++)
|
||||
string playerNums = string.Empty;
|
||||
for (int i = 0; i < playerWithoutMicro.Count; i++)
|
||||
{
|
||||
if (_PlayerWithoutMicro.Count - 1 == i)
|
||||
PlayerNums += _PlayerWithoutMicro[i].ToString();
|
||||
else if (_PlayerWithoutMicro.Count - 2 == i)
|
||||
PlayerNums += _PlayerWithoutMicro[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
|
||||
if (playerWithoutMicro.Count - 1 == i)
|
||||
playerNums += playerWithoutMicro[i].ToString();
|
||||
else if (playerWithoutMicro.Count - 2 == i)
|
||||
playerNums += playerWithoutMicro[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
|
||||
else
|
||||
PlayerNums += _PlayerWithoutMicro[i].ToString() + ", ";
|
||||
playerNums += playerWithoutMicro[i].ToString() + ", ";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckPlayers()
|
||||
private void _CheckPlayers()
|
||||
{
|
||||
List<int> _PlayerWithoutProfile = new List<int>();
|
||||
List<int> playerWithoutProfile = new List<int>();
|
||||
for (int player = 0; player < CConfig.NumPlayer; player++)
|
||||
{
|
||||
if (CGame.Player[player].ProfileID < 0)
|
||||
_PlayerWithoutProfile.Add(player + 1);
|
||||
playerWithoutProfile.Add(player + 1);
|
||||
}
|
||||
|
||||
if (_PlayerWithoutProfile.Count > 0)
|
||||
if (playerWithoutProfile.Count > 0)
|
||||
{
|
||||
Statics[StaticWarningProfiles].Visible = true;
|
||||
Texts[TextWarningProfiles].Visible = true;
|
||||
Statics[_StaticWarningProfiles].Visible = true;
|
||||
Texts[_TextWarningProfiles].Visible = true;
|
||||
|
||||
if (_PlayerWithoutProfile.Count > 1)
|
||||
if (playerWithoutProfile.Count > 1)
|
||||
{
|
||||
string PlayerNums = string.Empty;
|
||||
for (int i = 0; i < _PlayerWithoutProfile.Count; i++)
|
||||
string playerNums = string.Empty;
|
||||
for (int i = 0; i < playerWithoutProfile.Count; i++)
|
||||
{
|
||||
if (_PlayerWithoutProfile.Count - 1 == i)
|
||||
PlayerNums += _PlayerWithoutProfile[i].ToString();
|
||||
else if (_PlayerWithoutProfile.Count - 2 == i)
|
||||
PlayerNums += _PlayerWithoutProfile[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
|
||||
if (playerWithoutProfile.Count - 1 == i)
|
||||
playerNums += playerWithoutProfile[i].ToString();
|
||||
else if (playerWithoutProfile.Count - 2 == i)
|
||||
playerNums += playerWithoutProfile[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
|
||||
else
|
||||
PlayerNums += _PlayerWithoutProfile[i].ToString() + ", ";
|
||||
playerNums += playerWithoutProfile[i].ToString() + ", ";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 154 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user