Merge remote-tracking branch 'refs/remotes/Vocaluxe/develop' into NamesScroll

# Conflicts:
#	VocaluxeLib/Menu/CNameSelection.cs
This commit is contained in:
Jiiniasu committed 2017-11-27 18:55:39 +01:00
commit 2dbc84710b
45 files changed
+764 -335

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<ID>600352d6-d975-4945-9758-e6b379972a12</ID>
<PlayerName>Guest 1</PlayerName> <PlayerName>Guest 1</PlayerName>
<Difficulty>TR_CONFIG_EASY</Difficulty> <Difficulty>TR_CONFIG_EASY</Difficulty>
<UserRole>TR_USERROLE_GUEST</UserRole> <UserRole>TR_USERROLE_GUEST</UserRole>
+1
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<ID>abeb987f-bf44-4d6d-b922-e5deb608a1ab</ID>
<PlayerName>Guest 2</PlayerName> <PlayerName>Guest 2</PlayerName>
<Difficulty>TR_CONFIG_EASY</Difficulty> <Difficulty>TR_CONFIG_EASY</Difficulty>
<UserRole>TR_USERROLE_GUEST</UserRole> <UserRole>TR_USERROLE_GUEST</UserRole>
+1
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<ID>fd433fc4-60c0-4521-87ef-53aa7d252337</ID>
<PlayerName>Guest 3</PlayerName> <PlayerName>Guest 3</PlayerName>
<Difficulty>TR_CONFIG_EASY</Difficulty> <Difficulty>TR_CONFIG_EASY</Difficulty>
<UserRole>TR_USERROLE_GUEST</UserRole> <UserRole>TR_USERROLE_GUEST</UserRole>
@@ -30,7 +30,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public class CResultTableRow : IComparable public class CResultTableRow : IComparable
{ {
public int Position; public int Position;
public int PlayerID; public Guid PlayerID;
public int NumPlayed; public int NumPlayed;
public int NumWon; public int NumWon;
public int NumSingPoints; public int NumSingPoints;
@@ -121,7 +121,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public int NumJokers; public int NumJokers;
public bool RefillJokers; public bool RefillJokers;
public int[] Jokers; public int[] Jokers;
public List<int> ProfileIDs; public List<Guid> ProfileIDs;
public ESongSource SongSource; public ESongSource SongSource;
public ESongSorting Sorting; public ESongSorting Sorting;
@@ -143,7 +143,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private struct SStats private struct SStats
{ {
public int ProfileID; public Guid ProfileID;
public int SingPoints; public int SingPoints;
public int GamePoints; public int GamePoints;
public int Won; public int Won;
@@ -173,7 +173,7 @@ namespace VocaluxeLib.PartyModes.Challenge
NumJokers = 5, NumJokers = 5,
RefillJokers = true, RefillJokers = true,
CurrentRoundNr = 1, CurrentRoundNr = 1,
ProfileIDs = new List<int>(), ProfileIDs = new List<Guid>(),
Sorting = CBase.Config.GetSongSorting(), Sorting = CBase.Config.GetSongSorting(),
SongSource = ESongSource.TR_SONGSOURCE_ALLSONGS, SongSource = ESongSource.TR_SONGSOURCE_ALLSONGS,
PlaylistID = 0, PlaylistID = 0,
@@ -479,7 +479,7 @@ namespace VocaluxeLib.PartyModes.Challenge
if (c != null) if (c != null)
players[i].ProfileID = GameData.ProfileIDs[c.Players[i]]; players[i].ProfileID = GameData.ProfileIDs[c.Players[i]];
else else
players[i].ProfileID = -1; players[i].ProfileID = Guid.Empty;
} }
#endregion PlayerNames #endregion PlayerNames
@@ -125,6 +125,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]); _AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]);
_NextPlayerStatics.Add(GetNewStatic(_Statics[_StaticNextPlayer])); _NextPlayerStatics.Add(GetNewStatic(_Statics[_StaticNextPlayer]));
_AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]); _AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]);
_NextPlayerStatics[_NextPlayerStatics.Count - 1].Aspect = EAspect.Crop;
} }
_Statics[_StaticNextPlayer].Visible = false; _Statics[_StaticNextPlayer].Visible = false;
} }
@@ -340,7 +341,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_Texts[_TextNextPlayerMessage].Visible = true; _Texts[_TextNextPlayerMessage].Visible = true;
for (int i = 0; i < _PartyMode.GameData.NumPlayerAtOnce; i++) for (int i = 0; i < _PartyMode.GameData.NumPlayerAtOnce; i++)
{ {
int id = _PartyMode.GameData.ProfileIDs[_PartyMode.GameData.Rounds[_PartyMode.GameData.CurrentRoundNr - 1].Players[i]]; Guid id = _PartyMode.GameData.ProfileIDs[_PartyMode.GameData.Rounds[_PartyMode.GameData.CurrentRoundNr - 1].Players[i]];
_NextPlayerStatics[i].Texture = CBase.Profiles.GetAvatar(id); _NextPlayerStatics[i].Texture = CBase.Profiles.GetAvatar(id);
_NextPlayerTexts[i].Text = CBase.Profiles.GetPlayerName(id); _NextPlayerTexts[i].Text = CBase.Profiles.GetPlayerName(id);
_NextPlayerTexts[i].Color = CBase.Themes.GetPlayerColor(i + 1); _NextPlayerTexts[i].Color = CBase.Themes.GetPlayerColor(i + 1);
@@ -15,6 +15,7 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>. // along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -47,7 +48,7 @@ namespace VocaluxeLib.PartyModes.Challenge
while (_PartyMode.GameData.ProfileIDs.Count > _NumPlayer) while (_PartyMode.GameData.ProfileIDs.Count > _NumPlayer)
_PartyMode.GameData.ProfileIDs.RemoveAt(_PartyMode.GameData.ProfileIDs.Count - 1); _PartyMode.GameData.ProfileIDs.RemoveAt(_PartyMode.GameData.ProfileIDs.Count - 1);
List<int>[] ids = new List<int>[] {_PartyMode.GameData.ProfileIDs}; List<Guid>[] ids = new List<Guid>[] {_PartyMode.GameData.ProfileIDs};
SetPartyModeProfiles(ids); SetPartyModeProfiles(ids);
} }
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">DebugWin</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">DebugWin</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,8 +10,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VocaluxeLib.PartyModes.Challenge</RootNamespace> <RootNamespace>VocaluxeLib.PartyModes.Challenge</RootNamespace>
<AssemblyName>Challenge</AssemblyName> <AssemblyName>Challenge</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|AnyCPU'">
@@ -25,6 +26,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CodeAnalysisRuleSet>..\..\CheckingRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>..\..\CheckingRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -36,6 +38,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>WIN</DefineConstants> <DefineConstants>WIN</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -47,6 +50,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -58,6 +62,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>LINUX</DefineConstants> <DefineConstants>LINUX</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|AnyCPU'">
<OutputPath>bin</OutputPath> <OutputPath>bin</OutputPath>
@@ -68,6 +73,7 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CChallengeRounds.cs" /> <Compile Include="CChallengeRounds.cs" />
@@ -104,8 +104,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public int NumPlayerTeam2; public int NumPlayerTeam2;
public int NumFields; public int NumFields;
public int Team; public int Team;
public List<int> ProfileIDsTeam1; public List<Guid> ProfileIDsTeam1;
public List<int> ProfileIDsTeam2; public List<Guid> ProfileIDsTeam2;
public List<int> PlayerTeam1; public List<int> PlayerTeam1;
public List<int> PlayerTeam2; public List<int> PlayerTeam2;
@@ -148,8 +148,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
NumPlayerTeam1 = 2, NumPlayerTeam1 = 2,
NumPlayerTeam2 = 2, NumPlayerTeam2 = 2,
NumFields = 9, NumFields = 9,
ProfileIDsTeam1 = new List<int>(), ProfileIDsTeam1 = new List<Guid>(),
ProfileIDsTeam2 = new List<int>(), ProfileIDsTeam2 = new List<Guid>(),
PlayerTeam1 = new List<int>(), PlayerTeam1 = new List<int>(),
PlayerTeam2 = new List<int>(), PlayerTeam2 = new List<int>(),
CurrentRoundNr = 0, CurrentRoundNr = 0,
@@ -491,7 +491,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
//default values //default values
players[i].ProfileID = -1; players[i].ProfileID = Guid.Empty;
} }
//try to fill with the right data //try to fill with the right data
@@ -98,6 +98,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_CreateFields(); _CreateFields();
_Buttons[_ButtonField].Visible = false; _Buttons[_ButtonField].Visible = false;
_Statics[_StaticAvatarT1].Aspect = EAspect.Crop;
_Statics[_StaticAvatarT2].Aspect = EAspect.Crop;
} }
public override bool HandleInput(SKeyEvent keyEvent) public override bool HandleInput(SKeyEvent keyEvent)
@@ -15,6 +15,7 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>. // along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -49,7 +50,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
SetPartyModeData(2, _PartyMode.GameData.NumPlayerTeam1 + _PartyMode.GameData.NumPlayerTeam2, SetPartyModeData(2, _PartyMode.GameData.NumPlayerTeam1 + _PartyMode.GameData.NumPlayerTeam2,
new int[] {_PartyMode.GameData.NumPlayerTeam1, _PartyMode.GameData.NumPlayerTeam2}); new int[] {_PartyMode.GameData.NumPlayerTeam1, _PartyMode.GameData.NumPlayerTeam2});
List<int>[] ids = new List<int>[] {_PartyMode.GameData.ProfileIDsTeam1, _PartyMode.GameData.ProfileIDsTeam2}; List<Guid>[] ids = new List<Guid>[] {_PartyMode.GameData.ProfileIDsTeam1, _PartyMode.GameData.ProfileIDsTeam2};
SetPartyModeProfiles(ids); SetPartyModeProfiles(ids);
} }
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">DebugWin</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">DebugWin</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,8 +10,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VocaluxeLib.PartyModes.TicTacToe</RootNamespace> <RootNamespace>VocaluxeLib.PartyModes.TicTacToe</RootNamespace>
<AssemblyName>TicTacToe</AssemblyName> <AssemblyName>TicTacToe</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|AnyCPU'">
@@ -25,6 +26,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CodeAnalysisRuleSet>..\..\CheckingRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>..\..\CheckingRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -36,6 +38,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>WIN</DefineConstants> <DefineConstants>WIN</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -47,6 +50,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -58,6 +62,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>LINUX</DefineConstants> <DefineConstants>LINUX</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|AnyCPU'">
<OutputPath>bin</OutputPath> <OutputPath>bin</OutputPath>
@@ -68,6 +73,7 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CPartyScreenTicTacToeSongs.cs" /> <Compile Include="CPartyScreenTicTacToeSongs.cs" />
+45 -19
View File
@@ -51,6 +51,7 @@ namespace Vocaluxe.Base
private static Task _PreviewStartHelperTask; private static Task _PreviewStartHelperTask;
private static int _PreviewStartWaitCounter; private static int _PreviewStartWaitCounter;
private const int _PreviewStartWaitMaxTries = 10; private const int _PreviewStartWaitMaxTries = 10;
private static readonly object _PreviewStartHelperTaskLock = new Object();
public static bool VideoEnabled public static bool VideoEnabled
{ {
@@ -256,10 +257,17 @@ namespace Vocaluxe.Base
{ {
if (_PreviewStartHelperTask != null && ( _PreviewPlayer.Length > 0 || _PreviewStartWaitCounter++ >= _PreviewStartWaitMaxTries)) if (_PreviewStartHelperTask != null && ( _PreviewPlayer.Length > 0 || _PreviewStartWaitCounter++ >= _PreviewStartWaitMaxTries))
{ {
_PreviewStartHelperTask.RunSynchronously(TaskScheduler.FromCurrentSynchronizationContext()); lock (_PreviewStartHelperTaskLock)
_PreviewStartHelperTask.Dispose(); {
_PreviewStartHelperTask = null; // Recheck the condition as it cloud have change before we got the lock
_PreviewStartWaitCounter = 0; if (_PreviewStartHelperTask != null && (_PreviewPlayer.Length > 0 || _PreviewStartWaitCounter++ >= _PreviewStartWaitMaxTries))
{
_PreviewStartHelperTask.RunSynchronously(TaskScheduler.FromCurrentSynchronizationContext());
_PreviewStartHelperTask.Dispose();
_PreviewStartHelperTask = null;
_PreviewStartWaitCounter = 0;
}
}
} }
if (!IsPlaying) if (!IsPlaying)
@@ -317,28 +325,46 @@ namespace Vocaluxe.Base
//Change song position only if song is changed or near to end //Change song position only if song is changed or near to end
if (songChanged || _CurPlayer.Position + 30 < _CurPlayer.Length) if (songChanged || _CurPlayer.Position + 30 < _CurPlayer.Length)
{ {
_PreviewStartHelperTask = new Task(() => lock (_PreviewStartHelperTaskLock)
{ {
float length = _PreviewPlayer.Length; // Check if the old _PreviewStartHelperTask needs to disposed
if (length < 1) if (_PreviewStartHelperTask != null)
length = 30; // If length is unknow or invalid assume a length of 30s {
_PreviewStartHelperTask.Dispose();
}
_PreviewStartHelperTask = new Task(() =>
{
float length = _PreviewPlayer.Length;
if (length < 1)
length = 30; // If length is unknow or invalid assume a length of 30s
if (start < 0) if (start < 0)
start = (song.Preview.Source == EDataSource.None) ? length / 4f : song.Preview.StartTime; start = (song.Preview.Source == EDataSource.None) ? length / 4f : song.Preview.StartTime;
if (start > length - 5f) if (start > length - 5f)
start = Math.Max(0f, Math.Min(length / 4f, length - 5f)); start = Math.Max(0f, Math.Min(length / 4f, length - 5f));
if (start >= 0.5f) if (start >= 0.5f)
start -= 0.5f; start -= 0.5f;
_PreviewPlayer.Position = start; _PreviewPlayer.Position = start;
Play(); Play();
}); });
}
_CurPlayer = _PreviewPlayer; _CurPlayer = _PreviewPlayer;
} }
else else
{ {
_PreviewStartHelperTask.Dispose(); if (_PreviewStartHelperTask != null)
_PreviewStartHelperTask = null; {
lock (_PreviewStartHelperTaskLock)
{
// Recheck the condition as it cloud have change before we got the lock
if (_PreviewStartHelperTask != null)
{
_PreviewStartHelperTask.Dispose();
_PreviewStartHelperTask = null;
}
}
}
_PreviewPlayer.Position = _CurPlayer.Position; _PreviewPlayer.Position = _CurPlayer.Position;
_CurPlayer = _PreviewPlayer; _CurPlayer = _PreviewPlayer;
Play(); Play();
+28 -12
View File
@@ -236,13 +236,14 @@ namespace Vocaluxe.Base
public static event OnSongMenuChanged SongMenuChanged; public static event OnSongMenuChanged SongMenuChanged;
//Folders //Folders
//We need full path for folders for matching folder path with textfile path when loading
public static readonly List<string> SongFolders = new List<string> public static readonly List<string> SongFolders = new List<string>
{ {
#if INSTALLER #if INSTALLER
Path.Combine(CSettings.DataFolder, CSettings.FolderNameSongs), Path.Combine(CSettings.DataFolder, CSettings.FolderNameSongs),
CSettings.FolderNameSongs Path.Combine(CSettings.ProgramFolder, FolderNameSongs)
#elif WIN #elif WIN
CSettings.FolderNameSongs Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameSongs)
#elif LINUX #elif LINUX
Path.Combine(CSettings.DataFolder, CSettings.FolderNameSongs) Path.Combine(CSettings.DataFolder, CSettings.FolderNameSongs)
#endif #endif
@@ -380,15 +381,7 @@ namespace Vocaluxe.Base
else else
Config = xml.DeserializeString<SConfig>("<root />"); Config = xml.DeserializeString<SConfig>("<root />");
if (Config.Game.SongFolder.Length > 0 && Config.Game.SongFolder[0] != "") NormalizeSongPaths();
{
SongFolders.Clear();
SongFolders.AddRange(Config.Game.SongFolder);
}
else
{
Config.Game.SongFolder = SongFolders.ToArray();
}
if (Config.Game.MinLineBreakTime < 0) if (Config.Game.MinLineBreakTime < 0)
Config.Game.MinLineBreakTime = 0.1f; Config.Game.MinLineBreakTime = 0.1f;
@@ -680,6 +673,29 @@ namespace Vocaluxe.Base
return false; return false;
} }
/// <summary>
/// Set song path if none is find in config and check if every path exists
/// </summary>
public static void NormalizeSongPaths()
{
//Check if there are configured songfolders
if (Config.Game.SongFolder.Length > 0 && Config.Game.SongFolder[0] != "")
{
SongFolders.Clear();
foreach (string folder in Config.Game.SongFolder)
{
//Check if folder exists
if (Directory.Exists(folder))
SongFolders.Add(folder);
}
}
//Test if songfolders are still empty or now empty
if(Config.Game.SongFolder.Length == 0)
Config.Game.SongFolder = SongFolders.ToArray();
}
/// <summary> /// <summary>
/// Load command-line-parameters and their values to lists. /// Load command-line-parameters and their values to lists.
/// </summary> /// </summary>
@@ -821,7 +837,7 @@ namespace Vocaluxe.Base
for (int j = 0; j < CSettings.MaxNumPlayer; j++) for (int j = 0; j < CSettings.MaxNumPlayer; j++)
{ {
CGame.Players[j].ProfileID = -1; CGame.Players[j].ProfileID = Guid.Empty;
if (string.IsNullOrEmpty(Config.Game.Players[j])) if (string.IsNullOrEmpty(Config.Game.Players[j]))
continue; continue;
+34 -8
View File
@@ -656,17 +656,22 @@ namespace Vocaluxe.Base
return CProfiles.GetProfiles(); return CProfiles.GetProfiles();
} }
public EGameDifficulty GetDifficulty(int profileID) public int GetNum()
{
return CProfiles.NumProfiles;
}
public EGameDifficulty GetDifficulty(Guid profileID)
{ {
return CProfiles.GetDifficulty(profileID); return CProfiles.GetDifficulty(profileID);
} }
public string GetPlayerName(int profileID, int playerNum = 0) public string GetPlayerName(Guid profileID, int playerNum = 0)
{ {
return CProfiles.GetPlayerName(profileID, playerNum); return CProfiles.GetPlayerName(profileID, playerNum);
} }
public CTextureRef GetAvatar(int profileID) public CTextureRef GetAvatar(Guid profileID)
{ {
return CProfiles.GetAvatarTextureFromProfile(profileID); return CProfiles.GetAvatarTextureFromProfile(profileID);
} }
@@ -676,12 +681,12 @@ namespace Vocaluxe.Base
return CProfiles.GetAvatarByFilename(fileName); return CProfiles.GetAvatarByFilename(fileName);
} }
public bool IsProfileIDValid(int profileID) public bool IsProfileIDValid(Guid profileID)
{ {
return CProfiles.IsProfileIDValid(profileID); return CProfiles.IsProfileIDValid(profileID);
} }
public bool IsGuest(int profileID) public bool IsGuest(Guid profileID)
{ {
return CProfiles.IsGuestProfile(profileID); return CProfiles.IsGuestProfile(profileID);
} }
@@ -837,7 +842,14 @@ namespace Vocaluxe.Base
public void Close(ref CVideoStream stream) public void Close(ref CVideoStream stream)
{ {
CVideo.Close(ref stream); try
{
CVideo.Close(ref stream);
}
catch (NotSupportedException e)
{
CLog.LogError($"Clould not close the background video: {e.Message}");
}
} }
public void SetLoop(CVideoStream stream, bool loop = true) public void SetLoop(CVideoStream stream, bool loop = true)
@@ -847,12 +859,26 @@ namespace Vocaluxe.Base
public void Pause(CVideoStream stream) public void Pause(CVideoStream stream)
{ {
CVideo.Pause(stream); try
{
CVideo.Pause(stream);
}
catch (NotSupportedException e)
{
CLog.LogError($"Clould not pause the background video: {e.Message}");
}
} }
public void Resume(CVideoStream stream) public void Resume(CVideoStream stream)
{ {
CVideo.Resume(stream); try
{
CVideo.Resume(stream);
}
catch (NotSupportedException e)
{
CLog.LogError($"Clould not resume the background video: {e.Message}");
}
} }
} }
+36 -44
View File
@@ -45,13 +45,12 @@ namespace Vocaluxe.Base
public CProfile Profile; public CProfile Profile;
public CAvatar Avatar; public CAvatar Avatar;
public EAction Action; public EAction Action;
public int ProfileID; public Guid ProfileID;
} }
#endregion enums and structs #endregion enums and structs
#region private vars #region private vars
private static Dictionary<int, CProfile> _Profiles; private static Dictionary<Guid, CProfile> _Profiles;
private static Queue<int> _ProfileIDs;
private static Dictionary<int, CAvatar> _Avatars; private static Dictionary<int, CAvatar> _Avatars;
private static Queue<int> _AvatarIDs; private static Queue<int> _AvatarIDs;
@@ -84,10 +83,7 @@ namespace Vocaluxe.Base
for (int i = 0; i < 1000; i++) for (int i = 0; i < 1000; i++)
_AvatarIDs.Enqueue(i); _AvatarIDs.Enqueue(i);
_Profiles = new Dictionary<int, CProfile>(); _Profiles = new Dictionary<Guid, CProfile>();
_ProfileIDs = new Queue<int>(100);
for (int i = 0; i < 100; i++)
_ProfileIDs.Enqueue(i);
LoadProfiles(); LoadProfiles();
} }
@@ -117,7 +113,7 @@ namespace Vocaluxe.Base
if (newProf == null) if (newProf == null)
break; break;
newProf.ID = _ProfileIDs.Dequeue(); newProf.ID = Guid.NewGuid();
if (newProf.Avatar == null) if (newProf.Avatar == null)
newProf.Avatar = _Avatars.Values.First(); newProf.Avatar = _Avatars.Values.First();
else if (newProf.Avatar.ID < 0) else if (newProf.Avatar.ID < 0)
@@ -256,7 +252,7 @@ namespace Vocaluxe.Base
} }
} }
public static void DeleteProfile(int profileID) public static void DeleteProfile(Guid profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return; return;
@@ -305,7 +301,7 @@ namespace Vocaluxe.Base
return list.ToArray(); return list.ToArray();
} }
public static CProfile GetProfile(int profileID) public static CProfile GetProfile(Guid profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return null; return null;
@@ -324,7 +320,7 @@ namespace Vocaluxe.Base
return result; return result;
} }
public static int NewProfile(string fileName = "") public static Guid NewProfile(string fileName = "")
{ {
var profile = new CProfile var profile = new CProfile
{ {
@@ -332,9 +328,9 @@ namespace Vocaluxe.Base
}; };
if (File.Exists(profile.FilePath)) if (File.Exists(profile.FilePath))
return -1; return Guid.Empty;
profile.ID = _ProfileIDs.Dequeue(); profile.ID = Guid.NewGuid();
_Profiles.Add(profile.ID, profile); _Profiles.Add(profile.ID, profile);
_ProfilesChanged = true; _ProfilesChanged = true;
return profile.ID; return profile.ID;
@@ -354,11 +350,11 @@ namespace Vocaluxe.Base
public static void SaveProfiles() public static void SaveProfiles()
{ {
foreach (int id in _Profiles.Keys) foreach (Guid id in _Profiles.Keys)
_Profiles[id].SaveProfile(); _Profiles[id].SaveProfile();
} }
public static bool IsProfileIDValid(int profileID) public static bool IsProfileIDValid(Guid profileID)
{ {
return _Profiles.ContainsKey(profileID); return _Profiles.ContainsKey(profileID);
} }
@@ -370,7 +366,7 @@ namespace Vocaluxe.Base
#endregion public methods #endregion public methods
#region profile properties #region profile properties
public static string GetPlayerName(int profileID, int playerNum = 0) public static string GetPlayerName(Guid profileID, int playerNum = 0)
{ {
if (IsProfileIDValid(profileID)) if (IsProfileIDValid(profileID))
return _Profiles[profileID].PlayerName; return _Profiles[profileID].PlayerName;
@@ -381,7 +377,7 @@ namespace Vocaluxe.Base
return playerName; return playerName;
} }
public static void SetPlayerName(int profileID, string playerName) public static void SetPlayerName(Guid profileID, string playerName)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return; return;
@@ -389,7 +385,7 @@ namespace Vocaluxe.Base
_Profiles[profileID].PlayerName = playerName; _Profiles[profileID].PlayerName = playerName;
} }
public static string GetProfileFileName(int profileID) public static string GetProfileFileName(Guid profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return String.Empty; return String.Empty;
@@ -397,7 +393,7 @@ namespace Vocaluxe.Base
return Path.GetFileName(_Profiles[profileID].FilePath); return Path.GetFileName(_Profiles[profileID].FilePath);
} }
public static string AddGetPlayerName(int profileID, char chr) public static string AddGetPlayerName(Guid profileID, char chr)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return String.Empty; return String.Empty;
@@ -406,7 +402,7 @@ namespace Vocaluxe.Base
return _Profiles[profileID].PlayerName; return _Profiles[profileID].PlayerName;
} }
public static string GetDeleteCharInPlayerName(int profileID) public static string GetDeleteCharInPlayerName(Guid profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return String.Empty; return String.Empty;
@@ -418,12 +414,12 @@ namespace Vocaluxe.Base
return profile.PlayerName; return profile.PlayerName;
} }
public static EGameDifficulty GetDifficulty(int profileID) public static EGameDifficulty GetDifficulty(Guid profileID)
{ {
return IsProfileIDValid(profileID) ? _Profiles[profileID].Difficulty : EGameDifficulty.TR_CONFIG_NORMAL; return IsProfileIDValid(profileID) ? _Profiles[profileID].Difficulty : EGameDifficulty.TR_CONFIG_NORMAL;
} }
public static void SetDifficulty(int profileID, EGameDifficulty difficulty) public static void SetDifficulty(Guid profileID, EGameDifficulty difficulty)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return; return;
@@ -431,12 +427,12 @@ namespace Vocaluxe.Base
_Profiles[profileID].Difficulty = difficulty; _Profiles[profileID].Difficulty = difficulty;
} }
public static EUserRole GetUserRoleProfile(int profileID) public static EUserRole GetUserRoleProfile(Guid profileID)
{ {
return IsProfileIDValid(profileID) ? _Profiles[profileID].UserRole : EUserRole.TR_USERROLE_GUEST; return IsProfileIDValid(profileID) ? _Profiles[profileID].UserRole : EUserRole.TR_USERROLE_GUEST;
} }
public static void SetUserRoleProfile(int profileID, EUserRole option) public static void SetUserRoleProfile(Guid profileID, EUserRole option)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return; return;
@@ -446,12 +442,12 @@ namespace Vocaluxe.Base
_Profiles[profileID].UserRole = (_Profiles[profileID].UserRole & ~mask) | option; _Profiles[profileID].UserRole = (_Profiles[profileID].UserRole & ~mask) | option;
} }
public static EOffOn GetActive(int profileID) public static EOffOn GetActive(Guid profileID)
{ {
return IsProfileIDValid(profileID) ? _Profiles[profileID].Active : EOffOn.TR_CONFIG_OFF; return IsProfileIDValid(profileID) ? _Profiles[profileID].Active : EOffOn.TR_CONFIG_OFF;
} }
public static void SetActive(int profileID, EOffOn option) public static void SetActive(Guid profileID, EOffOn option)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return; return;
@@ -459,7 +455,7 @@ namespace Vocaluxe.Base
_Profiles[profileID].Active = option; _Profiles[profileID].Active = option;
} }
public static bool IsGuestProfile(int profileID) public static bool IsGuestProfile(Guid profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return true; // this will prevent from saving dummy profiles to highscore db return true; // this will prevent from saving dummy profiles to highscore db
@@ -467,14 +463,14 @@ namespace Vocaluxe.Base
return _Profiles[profileID].UserRole <= EUserRole.TR_USERROLE_GUEST; return _Profiles[profileID].UserRole <= EUserRole.TR_USERROLE_GUEST;
} }
public static bool IsActive(int profileID) public static bool IsActive(Guid profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return false; return false;
return _Profiles[profileID].Active == EOffOn.TR_CONFIG_ON; return _Profiles[profileID].Active == EOffOn.TR_CONFIG_ON;
} }
public static void SetAvatar(int profileID, int avatarID) public static void SetAvatar(Guid profileID, int avatarID)
{ {
if (!IsProfileIDValid(profileID) || !IsAvatarIDValid(avatarID)) if (!IsProfileIDValid(profileID) || !IsAvatarIDValid(avatarID))
return; return;
@@ -482,7 +478,7 @@ namespace Vocaluxe.Base
_Profiles[profileID].Avatar = _Avatars[avatarID]; _Profiles[profileID].Avatar = _Avatars[avatarID];
} }
public static int GetAvatarID(int profileID) public static int GetAvatarID(Guid profileID)
{ {
if (!IsProfileIDValid(profileID) || _Profiles[profileID].Avatar == null) if (!IsProfileIDValid(profileID) || _Profiles[profileID].Avatar == null)
return -1; return -1;
@@ -490,7 +486,7 @@ namespace Vocaluxe.Base
return _Profiles[profileID].Avatar.ID; return _Profiles[profileID].Avatar.ID;
} }
public static CAvatar GetAvatar(int profileID) public static CAvatar GetAvatar(Guid profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return null; return null;
@@ -498,7 +494,8 @@ namespace Vocaluxe.Base
return _Profiles[profileID].Avatar; return _Profiles[profileID].Avatar;
} }
public static int GetProfileID(int num) //TODO: Remove this?
public static Guid GetProfileID(Guid num)
{ {
return _Profiles[num].ID; return _Profiles[num].ID;
} }
@@ -513,7 +510,7 @@ namespace Vocaluxe.Base
return _Avatars[avatarID].Texture; return _Avatars[avatarID].Texture;
} }
public static CTextureRef GetAvatarTextureFromProfile(int profileID) public static CTextureRef GetAvatarTextureFromProfile(Guid profileID)
{ {
if (!IsProfileIDValid(profileID) || _Profiles[profileID].Avatar == null) if (!IsProfileIDValid(profileID) || _Profiles[profileID].Avatar == null)
return null; return null;
@@ -530,9 +527,9 @@ namespace Vocaluxe.Base
var knownFiles = new List<string>(); var knownFiles = new List<string>();
if (_Profiles.Count > 0) if (_Profiles.Count > 0)
{ {
var ids = new int[_Profiles.Keys.Count]; var ids = new Guid[_Profiles.Keys.Count];
_Profiles.Keys.CopyTo(ids, 0); _Profiles.Keys.CopyTo(ids, 0);
foreach (int id in ids) foreach (Guid id in ids)
{ {
if (_Profiles[id].LoadProfile()) if (_Profiles[id].LoadProfile())
knownFiles.Add(Path.GetFileName(_Profiles[id].FilePath)); knownFiles.Add(Path.GetFileName(_Profiles[id].FilePath));
@@ -554,10 +551,7 @@ namespace Vocaluxe.Base
var profile = new CProfile(); var profile = new CProfile();
if (profile.LoadProfile(file)) if (profile.LoadProfile(file))
{
profile.ID = _ProfileIDs.Dequeue();
_Profiles.Add(profile.ID, profile); _Profiles.Add(profile.ID, profile);
}
} }
_ProfilesChanged = true; _ProfilesChanged = true;
} }
@@ -597,7 +591,7 @@ namespace Vocaluxe.Base
_ProfilesChanged = true; _ProfilesChanged = true;
} }
private static void _DeleteProfile(int profileID) private static void _DeleteProfile(Guid profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return; return;
@@ -625,10 +619,8 @@ namespace Vocaluxe.Base
//Check if profile is selected in game //Check if profile is selected in game
for (int i = 0; i < CGame.Players.Length; i++) for (int i = 0; i < CGame.Players.Length; i++)
{ {
if (CGame.Players[i].ProfileID > profileID) if (CGame.Players[i].ProfileID == profileID)
CGame.Players[i].ProfileID--; CGame.Players[i].ProfileID = Guid.Empty;
else if (CGame.Players[i].ProfileID == profileID)
CGame.Players[i].ProfileID = -1;
} }
} }
catch (Exception) catch (Exception)
@@ -638,7 +630,7 @@ namespace Vocaluxe.Base
_ProfilesChanged = true; _ProfilesChanged = true;
} }
private static void _RemoveProfile(int profileID) private static void _RemoveProfile(Guid profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID))
return; return;
+73
View File
@@ -15,6 +15,7 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>. // along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion #endregion
using System;
using Vocaluxe.Lib.Video; using Vocaluxe.Lib.Video;
using VocaluxeLib; using VocaluxeLib;
@@ -61,6 +62,10 @@ namespace Vocaluxe.Base
public static CVideoStream Load(string videoFileName) public static CVideoStream Load(string videoFileName)
{ {
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
return _VideoDecoder.Load(videoFileName); return _VideoDecoder.Load(videoFileName);
} }
@@ -73,41 +78,109 @@ namespace Vocaluxe.Base
public static float GetLength(CVideoStream stream) public static float GetLength(CVideoStream stream)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
return _VideoDecoder.GetLength(stream); return _VideoDecoder.GetLength(stream);
} }
public static bool GetFrame(CVideoStream stream, float time) public static bool GetFrame(CVideoStream stream, float time)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
return _VideoDecoder.GetFrame(stream, time); return _VideoDecoder.GetFrame(stream, time);
} }
public static bool Skip(CVideoStream stream, float start, float gap) public static bool Skip(CVideoStream stream, float start, float gap)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
return _VideoDecoder.Skip(stream, start, gap); return _VideoDecoder.Skip(stream, start, gap);
} }
public static void SetLoop(CVideoStream stream, bool loop) public static void SetLoop(CVideoStream stream, bool loop)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
_VideoDecoder.SetLoop(stream, loop); _VideoDecoder.SetLoop(stream, loop);
} }
public static void Pause(CVideoStream stream) public static void Pause(CVideoStream stream)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
_VideoDecoder.Pause(stream); _VideoDecoder.Pause(stream);
} }
public static void Resume(CVideoStream stream) public static void Resume(CVideoStream stream)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
_VideoDecoder.Resume(stream); _VideoDecoder.Resume(stream);
} }
public static bool Finished(CVideoStream stream) public static bool Finished(CVideoStream stream)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
return _VideoDecoder.Finished(stream); return _VideoDecoder.Finished(stream);
} }
public static void Update() public static void Update()
{ {
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
_VideoDecoder.Update(); _VideoDecoder.Update();
} }
#endregion Interface #endregion Interface
+17 -3
View File
@@ -53,6 +53,10 @@ namespace Vocaluxe.Base
{ {
_VideoTimer.Reset(); _VideoTimer.Reset();
_Finished = false; _Finished = false;
if (_VideoStream == null)
{
return;
}
//CVideo.VdSkip(_VideoStream, 0f, 0f); //CVideo.VdSkip(_VideoStream, 0f, 0f);
_VideoTimer.Start(); _VideoTimer.Start();
CVideo.Resume(_VideoStream); CVideo.Resume(_VideoStream);
@@ -60,12 +64,19 @@ namespace Vocaluxe.Base
public void Pause() public void Pause()
{ {
CVideo.Pause(_VideoStream); if (_VideoStream != null)
{
CVideo.Pause(_VideoStream);
}
_VideoTimer.Stop(); _VideoTimer.Stop();
} }
public void Resume() public void Resume()
{ {
if (_VideoStream == null)
{
return;
}
CVideo.Resume(_VideoStream); CVideo.Resume(_VideoStream);
_VideoTimer.Start(); _VideoTimer.Start();
} }
@@ -92,7 +103,7 @@ namespace Vocaluxe.Base
public void PreLoad() public void PreLoad()
{ {
if (!_Loaded) if (!_Loaded || _VideoStream == null)
{ {
return; return;
} }
@@ -111,7 +122,10 @@ namespace Vocaluxe.Base
public void Close() public void Close()
{ {
CVideo.Close(ref _VideoStream); if (_VideoStream != null)
{
CVideo.Close(ref _VideoStream);
}
_Loaded = false; _Loaded = false;
_Finished = false; _Finished = false;
_VideoTimer.Reset(); _VideoTimer.Reset();
+8 -8
View File
@@ -388,7 +388,7 @@ namespace Vocaluxe.Base.Server
} }
#region profile #region profile
public static SProfileData GetProfileData(int profileId, bool isReadonly) public static SProfileData GetProfileData(Guid profileId, bool isReadonly)
{ {
CProfile profile = CProfiles.GetProfile(profileId); CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null) if (profile == null)
@@ -807,7 +807,7 @@ namespace Vocaluxe.Base.Server
#endregion #endregion
#region user management #region user management
public static bool ValidatePassword(int profileId, string password) public static bool ValidatePassword(Guid profileId, string password)
{ {
CProfile profile = CProfiles.GetProfile(profileId); CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null) if (profile == null)
@@ -824,7 +824,7 @@ namespace Vocaluxe.Base.Server
return _Hash((new UTF8Encoding()).GetBytes(password), salt).SequenceEqual(profile.PasswordHash); return _Hash((new UTF8Encoding()).GetBytes(password), salt).SequenceEqual(profile.PasswordHash);
} }
public static bool ValidatePassword(int profileId, byte[] hashedPassword) public static bool ValidatePassword(Guid profileId, byte[] hashedPassword)
{ {
CProfile profile = CProfiles.GetProfile(profileId); CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null) if (profile == null)
@@ -841,7 +841,7 @@ namespace Vocaluxe.Base.Server
return hashedPassword.SequenceEqual(profile.PasswordHash); return hashedPassword.SequenceEqual(profile.PasswordHash);
} }
private static byte[] _GetPasswordSalt(int profileId) private static byte[] _GetPasswordSalt(Guid profileId)
{ {
CProfile profile = CProfiles.GetProfile(profileId); CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null) if (profile == null)
@@ -853,7 +853,7 @@ namespace Vocaluxe.Base.Server
return profile.PasswordSalt; return profile.PasswordSalt;
} }
public static int GetUserRole(int profileId) public static int GetUserRole(Guid profileId)
{ {
CProfile profile = CProfiles.GetProfile(profileId); CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null) if (profile == null)
@@ -865,7 +865,7 @@ namespace Vocaluxe.Base.Server
return (int)(profile.UserRole); return (int)(profile.UserRole);
} }
public static void SetUserRole(int profileId, int userRole) public static void SetUserRole(Guid profileId, int userRole)
{ {
CProfile profile = CProfiles.GetProfile(profileId); CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null) if (profile == null)
@@ -884,9 +884,9 @@ namespace Vocaluxe.Base.Server
CProfiles.SaveProfiles(); CProfiles.SaveProfiles();
} }
public static int GetUserIdFromUsername(string username) public static Guid GetUserIdFromUsername(string username)
{ {
IEnumerable<int> playerIds = (from p in CProfiles.GetProfiles() IEnumerable<Guid> playerIds = (from p in CProfiles.GetProfiles()
where String.Equals(p.PlayerName, username, StringComparison.OrdinalIgnoreCase) where String.Equals(p.PlayerName, username, StringComparison.OrdinalIgnoreCase)
select p.ID); select p.ID);
try try
+10 -10
View File
@@ -61,7 +61,7 @@ namespace Vocaluxe.Base.Server
} }
#region profile #region profile
public int GetOwnProfileId() public Guid GetOwnProfileId()
{ {
Guid sessionKey = _GetSession(); Guid sessionKey = _GetSession();
if (sessionKey == Guid.Empty) if (sessionKey == Guid.Empty)
@@ -71,17 +71,17 @@ namespace Vocaluxe.Base.Server
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session"; WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
} }
return -1; return Guid.Empty;
} }
int profileId = CSessionControl.GetUserIdFromSession(sessionKey); Guid profileId = CSessionControl.GetUserIdFromSession(sessionKey);
if (profileId < 0) if (profileId == Guid.Empty)
{ {
if (WebOperationContext.Current != null) if (WebOperationContext.Current != null)
{ {
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session"; WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
} }
return -1; return Guid.Empty;
} }
return profileId; return profileId;
} }
@@ -90,7 +90,7 @@ namespace Vocaluxe.Base.Server
{ {
Guid sessionKey = _GetSession(); Guid sessionKey = _GetSession();
if (profile.ProfileId != -1) //-1 is the id for a new profile if (profile.ProfileId != Guid.Empty) //-1 is the id for a new profile
{ {
if (CSessionControl.GetUserIdFromSession(sessionKey) != profile.ProfileId if (CSessionControl.GetUserIdFromSession(sessionKey) != profile.ProfileId
&& !(_CheckRight(EUserRights.EditAllProfiles))) && !(_CheckRight(EUserRights.EditAllProfiles)))
@@ -100,7 +100,7 @@ namespace Vocaluxe.Base.Server
CVocaluxeServer.DoTask(CVocaluxeServer.SendProfileData, profile); CVocaluxeServer.DoTask(CVocaluxeServer.SendProfileData, profile);
} }
public SProfileData GetProfile(int profileId) public SProfileData GetProfile(Guid profileId)
{ {
Guid sessionKey = _GetSession(); Guid sessionKey = _GetSession();
if (CSessionControl.GetUserIdFromSession(sessionKey) == profileId || _CheckRight(EUserRights.ViewOtherProfiles)) if (CSessionControl.GetUserIdFromSession(sessionKey) == profileId || _CheckRight(EUserRights.ViewOtherProfiles))
@@ -146,7 +146,7 @@ namespace Vocaluxe.Base.Server
public void Logout() public void Logout()
{ {
Guid sessionKey = _GetSession(); Guid sessionKey = _GetSession();
CSessionControl.InvalidateSessions(sessionKey); CSessionControl.InvalidateSessionByID(sessionKey);
} }
public Stream Index() public Stream Index()
@@ -501,12 +501,12 @@ namespace Vocaluxe.Base.Server
#endregion #endregion
#region user management #region user management
public int GetUserRole(int profileId) public int GetUserRole(Guid profileId)
{ {
return CVocaluxeServer.DoTask(CVocaluxeServer.GetUserRole, profileId); return CVocaluxeServer.DoTask(CVocaluxeServer.GetUserRole, profileId);
} }
public void SetUserRole(int profileId, int userRole) public void SetUserRole(Guid profileId, int userRole)
{ {
if (_CheckRight(EUserRights.EditAllProfiles)) if (_CheckRight(EUserRights.EditAllProfiles))
CVocaluxeServer.DoTaskWithoutReturn(CVocaluxeServer.SetUserRole, profileId, userRole); CVocaluxeServer.DoTaskWithoutReturn(CVocaluxeServer.SetUserRole, profileId, userRole);
+4 -4
View File
@@ -39,7 +39,7 @@ namespace Vocaluxe.Base.Server
[OperationContract, WebInvoke(Method = "GET", [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getOwnProfileId")] UriTemplate = "/getOwnProfileId")]
int GetOwnProfileId(); Guid GetOwnProfileId();
[OperationContract, WebInvoke(Method = "POST", [OperationContract, WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
@@ -49,7 +49,7 @@ namespace Vocaluxe.Base.Server
[OperationContract, WebInvoke(Method = "GET", [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getProfile?profileId={profileId}")] UriTemplate = "/getProfile?profileId={profileId}")]
SProfileData GetProfile(int profileId); SProfileData GetProfile(Guid profileId);
[OperationContract, WebInvoke(Method = "GET", [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
@@ -195,12 +195,12 @@ namespace Vocaluxe.Base.Server
[OperationContract, WebInvoke(Method = "GET", [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getUserRole?profileId={profileId}")] UriTemplate = "/getUserRole?profileId={profileId}")]
int GetUserRole(int profileId); int GetUserRole(Guid profileId);
[OperationContract, WebInvoke(Method = "GET", [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/setUserRole?profileId={profileId}&userRole={userRole}")] UriTemplate = "/setUserRole?profileId={profileId}&userRole={userRole}")]
void SetUserRole(int profileId, int userRole); void SetUserRole(Guid profileId, int userRole);
[OperationContract, WebInvoke(Method = "GET", [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
+3 -3
View File
@@ -27,8 +27,8 @@ namespace Vocaluxe.Base.Server
get { return _ID; } get { return _ID; }
} }
private readonly int _ProfileId; private readonly Guid _ProfileId;
public int ProfileId public Guid ProfileId
{ {
get { return _ProfileId; } get { return _ProfileId; }
} }
@@ -46,7 +46,7 @@ namespace Vocaluxe.Base.Server
internal set { _LastSeen = value; } internal set { _LastSeen = value; }
} }
public CSession(Guid id, int profileId, EUserRoles roles) public CSession(Guid id, Guid profileId, EUserRoles roles)
{ {
_ID = id; _ID = id;
_ProfileId = profileId; _ProfileId = profileId;
+8 -8
View File
@@ -44,7 +44,7 @@ namespace Vocaluxe.Base.Server
foreach (var sessionToRemove in sessionIdsToRemove) foreach (var sessionToRemove in sessionIdsToRemove)
{ {
InvalidateSessions(sessionToRemove); InvalidateSessionByID(sessionToRemove);
} }
} }
@@ -54,7 +54,7 @@ namespace Vocaluxe.Base.Server
return Guid.Empty; return Guid.Empty;
Guid newId = Guid.NewGuid(); Guid newId = Guid.NewGuid();
int id = _GetProfileIdFormUsername(userName); Guid id = _GetProfileIdFormUsername(userName);
EUserRoles roles = _GetUserRoles(id); EUserRoles roles = _GetUserRoles(id);
CSession session = new CSession(newId, id, roles); CSession session = new CSession(newId, id, roles);
//InvalidateSessions(id); //InvalidateSessions(id);
@@ -68,17 +68,17 @@ namespace Vocaluxe.Base.Server
return CVocaluxeServer.ValidatePassword(_GetProfileIdFormUsername(userName), password); return CVocaluxeServer.ValidatePassword(_GetProfileIdFormUsername(userName), password);
} }
private static int _GetProfileIdFormUsername(string username) private static Guid _GetProfileIdFormUsername(string username)
{ {
return CVocaluxeServer.GetUserIdFromUsername(username); return CVocaluxeServer.GetUserIdFromUsername(username);
} }
private static EUserRoles _GetUserRoles(int profileId) private static EUserRoles _GetUserRoles(Guid profileId)
{ {
return (EUserRoles)CVocaluxeServer.GetUserRole(profileId); return (EUserRoles)CVocaluxeServer.GetUserRole(profileId);
} }
internal static void InvalidateSessions(int profileId) internal static void InvalidateSessionByProfile(Guid profileId)
{ {
foreach (KeyValuePair<Guid, CSession> s in (from kv in _ActiveSessions foreach (KeyValuePair<Guid, CSession> s in (from kv in _ActiveSessions
where kv.Value.ProfileId == profileId where kv.Value.ProfileId == profileId
@@ -86,7 +86,7 @@ namespace Vocaluxe.Base.Server
_ActiveSessions.Remove(s.Key); _ActiveSessions.Remove(s.Key);
} }
internal static void InvalidateSessions(Guid sessionId) internal static void InvalidateSessionByID(Guid sessionId)
{ {
if (_ActiveSessions.ContainsKey(sessionId)) if (_ActiveSessions.ContainsKey(sessionId))
{ {
@@ -100,10 +100,10 @@ namespace Vocaluxe.Base.Server
.HasFlag(requestedRight))); .HasFlag(requestedRight)));
} }
internal static int GetUserIdFromSession(Guid sessionId) internal static Guid GetUserIdFromSession(Guid sessionId)
{ {
if (!_ActiveSessions.ContainsKey(sessionId)) if (!_ActiveSessions.ContainsKey(sessionId))
return -1; return Guid.Empty;
return _ActiveSessions[sessionId].ProfileId; return _ActiveSessions[sessionId].ProfileId;
} }
+1 -1
View File
@@ -56,7 +56,7 @@ namespace Vocaluxe.Base.Server
[DataMember] [DataMember]
public int Difficulty; public int Difficulty;
[DataMember] [DataMember]
public int ProfileId; public Guid ProfileId;
[DataMember] [DataMember]
public bool IsEditable; public bool IsEditable;
[DataMember] [DataMember]
+27 -9
View File
@@ -74,12 +74,23 @@ namespace Vocaluxe.Lib.Sound
} }
lock (_Mutex) lock (_Mutex)
{ {
if (_Disposed)
return;
Debug.Assert(_RefCount > 0); Debug.Assert(_RefCount > 0);
_RefCount--; _RefCount--;
if (_RefCount == 0) if (_RefCount == 0)
PortAudio.Pa_Terminate(); {
try
{
PortAudio.Pa_Terminate();
}
catch (Exception ex)
{
CLog.LogError(errorText: $"Error disposing PortAudio: {ex.Message}", e: ex);
}
}
_Disposed = true;
} }
_Disposed = true;
} }
public void Dispose() public void Dispose()
@@ -100,11 +111,11 @@ namespace Vocaluxe.Lib.Sound
double sampleRate, uint framesPerBuffer, PortAudio.PaStreamFlags streamFlags, double sampleRate, uint framesPerBuffer, PortAudio.PaStreamFlags streamFlags,
PortAudio.PaStreamCallbackDelegate streamCallback, IntPtr userData) PortAudio.PaStreamCallbackDelegate streamCallback, IntPtr userData)
{ {
if (_Disposed)
throw new ObjectDisposedException("PortAudioHandle already disposed");
lock (_Mutex) lock (_Mutex)
{ {
if (_Disposed)
throw new ObjectDisposedException("PortAudioHandle already disposed");
PortAudio.PaError res = PortAudio.Pa_OpenStream(out stream, ref inputParameters, ref outputParameters, sampleRate, framesPerBuffer, streamFlags, streamCallback, PortAudio.PaError res = PortAudio.Pa_OpenStream(out stream, ref inputParameters, ref outputParameters, sampleRate, framesPerBuffer, streamFlags, streamCallback,
userData); userData);
if (res == PortAudio.PaError.paNoError) if (res == PortAudio.PaError.paNoError)
@@ -157,12 +168,19 @@ namespace Vocaluxe.Lib.Sound
public void CloseStream(IntPtr stream) public void CloseStream(IntPtr stream)
{ {
if (_Disposed)
throw new ObjectDisposedException("PortAudioHandle already disposed");
lock (_Mutex) lock (_Mutex)
{ {
PortAudio.Pa_CloseStream(stream); if (_Disposed)
throw new ObjectDisposedException("PortAudioHandle already disposed");
try
{
PortAudio.Pa_CloseStream(stream);
}
catch (Exception ex)
{
CLog.LogError(errorText:$"Error closing stream: {ex.Message}", e:ex);
}
_Streams.Remove(stream); _Streams.Remove(stream);
} }
} }
@@ -16,6 +16,8 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using Vocaluxe.Base; using Vocaluxe.Base;
@@ -142,9 +144,13 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
foreach (IntPtr handle in _RecHandle) foreach (IntPtr handle in _RecHandle)
{ {
PortAudioSharp.PortAudio.Pa_StopStream(handle); if (handle != IntPtr.Zero)
PortAudioSharp.PortAudio.Pa_CloseStream(handle); {
PortAudioSharp.PortAudio.Pa_StopStream(handle);
PortAudioSharp.PortAudio.Pa_CloseStream(handle);
}
} }
_RecHandle = new IntPtr[_Devices.Count];
return true; return true;
} }
@@ -153,13 +159,17 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
/// </summary> /// </summary>
public override void Close() public override void Close()
{ {
if (_RecHandle != null) if (_RecHandle != null && _RecHandle.Length > 0)
{ {
foreach (IntPtr handle in _RecHandle) foreach (IntPtr handle in _RecHandle)
{ {
if (handle != IntPtr.Zero) if (handle != IntPtr.Zero)
{
_PaHandle.CloseStream(handle); _PaHandle.CloseStream(handle);
}
} }
_RecHandle = new IntPtr[_Devices.Count];
} }
if (_PaHandle != null) if (_PaHandle != null)
{ {
@@ -429,7 +429,18 @@ namespace Vocaluxe.Lib.Video.Acinerella
private bool _CopyDecodedFrameToBuffer() private bool _CopyDecodedFrameToBuffer()
{ {
bool result; bool result;
var decoder = (SACDecoder)Marshal.PtrToStructure(_Videodecoder, typeof(SACDecoder)); SACDecoder decoder;
try
{
decoder = (SACDecoder)Marshal.PtrToStructure(_Videodecoder, typeof(SACDecoder));
}
catch (Exception e)
{
CLog.LogError("Couldn't copy the frame to the managed environment.", false, false, e);
return false;
}
if (decoder.Buffer != IntPtr.Zero) if (decoder.Buffer != IntPtr.Zero)
{ {
_LastDecodedTime = (float)decoder.Timecode; _LastDecodedTime = (float)decoder.Timecode;
+98 -1
View File
@@ -285,23 +285,120 @@ namespace Vocaluxe
try try
{ {
CController.Close(); CController.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CController)", false, false, e);
}
try
{
CVocaluxeServer.Close(); CVocaluxeServer.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CVocaluxeServer)", false, false, e);
}
try
{
CGraphics.Close(); CGraphics.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CGraphics)", false, false, e);
}
try
{
CThemes.Close(); CThemes.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CThemes)", false, false, e);
}
try
{
CCover.Close(); CCover.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CCover)", false, false, e);
}
try
{
CFonts.Close(); CFonts.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CFonts)", false, false, e);
}
try
{
CBackgroundMusic.Close(); CBackgroundMusic.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CBackgroundMusic)", false, false, e);
}
try
{
CWebcam.Close(); CWebcam.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CWebcam)", false, false, e);
}
try
{
CDataBase.Close(); CDataBase.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CDataBase)", false, false, e);
}
try
{
CVideo.Close(); CVideo.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CVideo)", false, false, e);
}
try
{
CRecord.Close(); CRecord.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CRecord)", false, false, e);
}
try
{
CSound.Close(); CSound.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CSound)", false, false, e);
}
try
{
CDraw.Close(); CDraw.Close();
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("Error during shutdown!", false, false, e); CLog.LogError("Error during shutdown! (CDraw)", false, false, e);
} }
GC.Collect(); // Do a GC run here before we close logs to have finalizers run GC.Collect(); // Do a GC run here before we close logs to have finalizers run
try try
{ {
+22 -22
View File
@@ -61,7 +61,7 @@ namespace Vocaluxe.Screens
private bool _SelectingFast; private bool _SelectingFast;
private int _SelectingSwitchNr = -1; private int _SelectingSwitchNr = -1;
private int _SelectingFastPlayerNr; private int _SelectingFastPlayerNr;
private int _SelectedProfileID = -1; private Guid _SelectedProfileID = Guid.Empty;
private bool _AvatarsChanged; private bool _AvatarsChanged;
private bool _ProfilesChanged; private bool _ProfilesChanged;
@@ -177,9 +177,9 @@ namespace Vocaluxe.Screens
{ {
case Keys.Enter: case Keys.Enter:
//Check, if a player is selected //Check, if a player is selected
if (_NameSelections[_NameSelection].Selection > -1) if (_NameSelections[_NameSelection].SelectedID != Guid.Empty)
{ {
_SelectedProfileID = _NameSelections[_NameSelection].Selection; _SelectedProfileID = _NameSelections[_NameSelection].SelectedID;
if (!CProfiles.IsProfileIDValid(_SelectedProfileID)) if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
@@ -359,7 +359,7 @@ namespace Vocaluxe.Screens
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
//Check if LeftButton is hold and Select-Mode inactive //Check if LeftButton is hold and Select-Mode inactive
if (mouseEvent.LBH && _SelectedProfileID < 0 && !_SelectingFast) if (mouseEvent.LBH && _SelectedProfileID == Guid.Empty && !_SelectingFast)
{ {
//Save mouse-coords //Save mouse-coords
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
@@ -368,8 +368,8 @@ namespace Vocaluxe.Screens
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{ {
//Get player-number of tile //Get player-number of tile
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
if (_SelectedProfileID != -1) if (_SelectedProfileID != Guid.Empty)
{ {
//Update of Drag/Drop-Texture //Update of Drag/Drop-Texture
CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent); CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
@@ -402,7 +402,7 @@ namespace Vocaluxe.Screens
} }
//Check if LeftButton is hold and Select-Mode active //Check if LeftButton is hold and Select-Mode active
if (mouseEvent.LBH && _SelectedProfileID >= 0 && !_SelectingFast) if (mouseEvent.LBH && _SelectedProfileID != Guid.Empty && !_SelectingFast)
{ {
//Update coords for Drag/Drop-Texture //Update coords for Drag/Drop-Texture
_ChooseAvatarStatic.X += mouseEvent.X - _OldMouseX; _ChooseAvatarStatic.X += mouseEvent.X - _OldMouseX;
@@ -411,7 +411,7 @@ namespace Vocaluxe.Screens
_OldMouseY = mouseEvent.Y; _OldMouseY = mouseEvent.Y;
} }
// LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar // LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar
else if (_SelectedProfileID >= 0 && !_SelectingFast) else if (_SelectedProfileID != Guid.Empty && !_SelectingFast)
{ {
//Foreach Drop-Area //Foreach Drop-Area
for (int i = 0; i < _StaticPlayer.Length; i++) for (int i = 0; i < _StaticPlayer.Length; i++)
@@ -422,7 +422,7 @@ namespace Vocaluxe.Screens
//Check if Mouse is in area //Check if Mouse is in area
if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent))
{ {
if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID > -1) if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID != Guid.Empty)
_UpdateSelectedProfile(_SelectingSwitchNr, CGame.Players[i].ProfileID); _UpdateSelectedProfile(_SelectingSwitchNr, CGame.Players[i].ProfileID);
else if (_SelectingSwitchNr > -1) else if (_SelectingSwitchNr > -1)
_ResetPlayerSelection(_SelectingSwitchNr); _ResetPlayerSelection(_SelectingSwitchNr);
@@ -438,7 +438,7 @@ namespace Vocaluxe.Screens
_ResetPlayerSelection(_SelectingSwitchNr); _ResetPlayerSelection(_SelectingSwitchNr);
} }
_SelectingSwitchNr = -1; _SelectingSwitchNr = -1;
_SelectedProfileID = -1; _SelectedProfileID = Guid.Empty;
//Reset variables //Reset variables
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
} }
@@ -448,8 +448,8 @@ namespace Vocaluxe.Screens
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{ {
//Get player-number of tile //Get player-number of tile
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
if (_SelectedProfileID != -1) if (_SelectedProfileID != Guid.Empty)
{ {
if (!CProfiles.IsProfileIDValid(_SelectedProfileID)) if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
@@ -480,12 +480,12 @@ namespace Vocaluxe.Screens
if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast) if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast)
{ {
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
if (_SelectedProfileID > -1) if (_SelectedProfileID != Guid.Empty)
{ {
for (int i = 0; i < CGame.NumPlayers; i++) for (int i = 0; i < CGame.NumPlayers; i++)
{ {
if (CGame.Players[i].ProfileID == -1) if (CGame.Players[i].ProfileID == Guid.Empty)
{ {
if (!CProfiles.IsProfileIDValid(_SelectedProfileID)) if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
@@ -657,7 +657,7 @@ namespace Vocaluxe.Screens
_Statics["StaticPlayerAvatar" + i].Visible = true; _Statics["StaticPlayerAvatar" + i].Visible = true;
_Texts["TextPlayer" + i].Visible = true; _Texts["TextPlayer" + i].Visible = true;
if (_Texts["TextPlayer" + i].Text == "") if (_Texts["TextPlayer" + i].Text == "")
_Texts["TextPlayer" + i].Text = CProfiles.GetPlayerName(-1, i); _Texts["TextPlayer" + i].Text = CProfiles.GetPlayerName(Guid.Empty, i);
_Equalizers["EqualizerPlayer" + i].Visible = true; _Equalizers["EqualizerPlayer" + i].Visible = true;
if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet) if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet)
_SelectSlides["SelectSlideDuetPlayer" + i].Visible = true; _SelectSlides["SelectSlideDuetPlayer" + i].Visible = true;
@@ -677,7 +677,7 @@ namespace Vocaluxe.Screens
_CheckPlayers(); _CheckPlayers();
} }
private void _UpdateSelectedProfile(int playerNum, int profileId) private void _UpdateSelectedProfile(int playerNum, Guid profileId)
{ {
_NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[playerNum].ProfileID); _NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[playerNum].ProfileID);
_NameSelections[_NameSelection].UseProfile(profileId); _NameSelections[_NameSelection].UseProfile(profileId);
@@ -700,12 +700,12 @@ namespace Vocaluxe.Screens
for (int i = 0; i < CGame.NumPlayers; i++) for (int i = 0; i < CGame.NumPlayers; i++)
{ {
_NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[i].ProfileID); _NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[i].ProfileID);
CGame.Players[i].ProfileID = -1; CGame.Players[i].ProfileID = Guid.Empty;
//Update config for default players. //Update config for default players.
CConfig.Config.Game.Players[i] = String.Empty; CConfig.Config.Game.Players[i] = String.Empty;
//Update texture and name //Update texture and name
_Statics[_StaticPlayerAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i]; _Statics[_StaticPlayerAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i];
_Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(-1, i + 1); _Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(Guid.Empty, i + 1);
} }
_NameSelections[_NameSelection].UpdateList(); _NameSelections[_NameSelection].UpdateList();
CConfig.SaveConfig(); CConfig.SaveConfig();
@@ -714,13 +714,13 @@ namespace Vocaluxe.Screens
private void _ResetPlayerSelection(int playerNum) private void _ResetPlayerSelection(int playerNum)
{ {
_NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[playerNum].ProfileID); _NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[playerNum].ProfileID);
CGame.Players[playerNum].ProfileID = -1; CGame.Players[playerNum].ProfileID = Guid.Empty;
//Update config for default players. //Update config for default players.
CConfig.Config.Game.Players[playerNum] = String.Empty; CConfig.Config.Game.Players[playerNum] = String.Empty;
CConfig.SaveConfig(); CConfig.SaveConfig();
//Update texture and name //Update texture and name
_Statics[_StaticPlayerAvatar[playerNum]].Texture = _OriginalPlayerAvatarTextures[playerNum]; _Statics[_StaticPlayerAvatar[playerNum]].Texture = _OriginalPlayerAvatarTextures[playerNum];
_Texts[_TextPlayer[playerNum]].Text = CProfiles.GetPlayerName(-1, playerNum + 1); _Texts[_TextPlayer[playerNum]].Text = CProfiles.GetPlayerName(Guid.Empty, playerNum + 1);
//Update profile-warning //Update profile-warning
_CheckPlayers(); _CheckPlayers();
//Update Tiles-List //Update Tiles-List
@@ -770,7 +770,7 @@ namespace Vocaluxe.Screens
var playerWithoutProfile = new List<int>(); var playerWithoutProfile = new List<int>();
for (int player = 0; player < CConfig.Config.Game.NumPlayers; player++) for (int player = 0; player < CConfig.Config.Game.NumPlayers; player++)
{ {
if (CGame.Players[player].ProfileID < 0) if (CGame.Players[player].ProfileID == Guid.Empty)
playerWithoutProfile.Add(player + 1); playerWithoutProfile.Add(player + 1);
} }
+49 -29
View File
@@ -16,6 +16,7 @@
#endregion #endregion
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
@@ -62,6 +63,8 @@ namespace Vocaluxe.Screens
private bool _ProfilesChanged; private bool _ProfilesChanged;
private bool _AvatarsChanged; private bool _AvatarsChanged;
private Dictionary<int, Guid> _SelectSlideGuids = new Dictionary<int, Guid>();
private EEditMode _EditMode; private EEditMode _EditMode;
private CTextureRef _WebcamTexture; private CTextureRef _WebcamTexture;
@@ -109,7 +112,7 @@ namespace Vocaluxe.Screens
break; break;
case EEditMode.PlayerName: case EEditMode.PlayerName:
_SelectSlides[_SelectSlideProfiles].RenameValue( _SelectSlides[_SelectSlideProfiles].RenameValue(
CProfiles.AddGetPlayerName(_SelectSlides[_SelectSlideProfiles].SelectedTag, keyEvent.Unicode)); CProfiles.AddGetPlayerName(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag), keyEvent.Unicode));
_ProfilesChanged = true; _ProfilesChanged = true;
break; break;
} }
@@ -155,7 +158,7 @@ namespace Vocaluxe.Screens
if (_EditMode == EEditMode.PlayerName) if (_EditMode == EEditMode.PlayerName)
{ {
_SelectSlides[_SelectSlideProfiles].RenameValue( _SelectSlides[_SelectSlideProfiles].RenameValue(
CProfiles.GetDeleteCharInPlayerName(_SelectSlides[_SelectSlideProfiles].SelectedTag)); CProfiles.GetDeleteCharInPlayerName(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag)));
_ProfilesChanged = true; _ProfilesChanged = true;
} }
else else
@@ -168,22 +171,22 @@ namespace Vocaluxe.Screens
} }
if (_SelectSlides[_SelectSlideDifficulty].Selected) if (_SelectSlides[_SelectSlideDifficulty].Selected)
{ {
CProfiles.SetDifficulty(_SelectSlides[_SelectSlideProfiles].SelectedTag, CProfiles.SetDifficulty(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
(EGameDifficulty)_SelectSlides[_SelectSlideDifficulty].Selection); (EGameDifficulty)_SelectSlides[_SelectSlideDifficulty].Selection);
} }
else if (_SelectSlides[_SelectSlideAvatars].Selected) else if (_SelectSlides[_SelectSlideAvatars].Selected)
{ {
CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].SelectedTag, CProfiles.SetAvatar(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
_SelectSlides[_SelectSlideAvatars].SelectedTag); _SelectSlides[_SelectSlideAvatars].SelectedTag);
} }
else if (_SelectSlides[_SelectSlideUserRole].Selected) else if (_SelectSlides[_SelectSlideUserRole].Selected)
{ {
CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].SelectedTag, CProfiles.SetUserRoleProfile(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
(EUserRole)_SelectSlides[_SelectSlideUserRole].Selection); (EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
} }
else if (_SelectSlides[_SelectSlideActive].Selected) else if (_SelectSlides[_SelectSlideActive].Selected)
{ {
CProfiles.SetActive(_SelectSlides[_SelectSlideProfiles].SelectedTag, CProfiles.SetActive(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
(EOffOn)_SelectSlides[_SelectSlideActive].Selection); (EOffOn)_SelectSlides[_SelectSlideActive].Selection);
} }
} }
@@ -215,24 +218,24 @@ namespace Vocaluxe.Screens
} }
else if (_SelectSlides[_SelectSlideDifficulty].Selected) else if (_SelectSlides[_SelectSlideDifficulty].Selected)
{ {
CProfiles.SetDifficulty(_SelectSlides[_SelectSlideProfiles].SelectedTag, CProfiles.SetDifficulty(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
(EGameDifficulty)_SelectSlides[_SelectSlideDifficulty].Selection); (EGameDifficulty)_SelectSlides[_SelectSlideDifficulty].Selection);
} }
else if (_SelectSlides[_SelectSlideAvatars].Selected) else if (_SelectSlides[_SelectSlideAvatars].Selected)
{ {
CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].SelectedTag, CProfiles.SetAvatar(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
_SelectSlides[_SelectSlideAvatars].SelectedTag); _SelectSlides[_SelectSlideAvatars].SelectedTag);
if (CWebcam.IsDeviceAvailable() && _WebcamTexture != null) if (CWebcam.IsDeviceAvailable() && _WebcamTexture != null)
_OnDiscardSnapshot(); _OnDiscardSnapshot();
} }
else if (_SelectSlides[_SelectSlideUserRole].Selected) else if (_SelectSlides[_SelectSlideUserRole].Selected)
{ {
CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].SelectedTag, CProfiles.SetUserRoleProfile(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
(EUserRole)_SelectSlides[_SelectSlideUserRole].Selection); (EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
} }
else if (_SelectSlides[_SelectSlideActive].Selected) else if (_SelectSlides[_SelectSlideActive].Selected)
{ {
CProfiles.SetActive(_SelectSlides[_SelectSlideProfiles].SelectedTag, CProfiles.SetActive(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag),
(EOffOn)_SelectSlides[_SelectSlideActive].Selection); (EOffOn)_SelectSlides[_SelectSlideActive].Selection);
} }
else if (_Buttons[_ButtonWebcam].Selected) else if (_Buttons[_ButtonWebcam].Selected)
@@ -260,15 +263,15 @@ namespace Vocaluxe.Screens
if (_SelectSlides[_SelectSlideProfiles].Selection > -1) if (_SelectSlides[_SelectSlideProfiles].Selection > -1)
{ {
_Buttons[_ButtonPlayerName].Text.Text = CProfiles.GetPlayerName(_SelectSlides[_SelectSlideProfiles].SelectedTag); _Buttons[_ButtonPlayerName].Text.Text = CProfiles.GetPlayerName(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag));
if (_EditMode == EEditMode.PlayerName) if (_EditMode == EEditMode.PlayerName)
_Buttons[_ButtonPlayerName].Text.Text += "|"; _Buttons[_ButtonPlayerName].Text.Text += "|";
_SelectSlides[_SelectSlideDifficulty].Selection = (int)CProfiles.GetDifficulty(_SelectSlides[_SelectSlideProfiles].SelectedTag); _SelectSlides[_SelectSlideDifficulty].Selection = (int)CProfiles.GetDifficulty(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag));
_SelectSlides[_SelectSlideUserRole].Selection = (int)CProfiles.GetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].SelectedTag); _SelectSlides[_SelectSlideUserRole].Selection = (int)CProfiles.GetUserRoleProfile(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag));
_SelectSlides[_SelectSlideActive].Selection = (int)CProfiles.GetActive(_SelectSlides[_SelectSlideProfiles].SelectedTag); _SelectSlides[_SelectSlideActive].Selection = (int)CProfiles.GetActive(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag));
int avatarID = CProfiles.GetAvatarID(_SelectSlides[_SelectSlideProfiles].SelectedTag); int avatarID = CProfiles.GetAvatarID(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag));
_SelectSlides[_SelectSlideAvatars].SelectedTag = avatarID; _SelectSlides[_SelectSlideAvatars].SelectedTag = avatarID;
if (_Snapshot == null) if (_Snapshot == null)
{ {
@@ -363,7 +366,7 @@ namespace Vocaluxe.Screens
_Buttons[_ButtonWebcam].Visible = CWebcam.IsDeviceAvailable(); _Buttons[_ButtonWebcam].Visible = CWebcam.IsDeviceAvailable();
int id = CProfiles.NewAvatar(file); int id = CProfiles.NewAvatar(file);
CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].SelectedTag, id); CProfiles.SetAvatar(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag), id);
_LoadAvatars(false); _LoadAvatars(false);
_SelectElement(_Buttons[_ButtonSave]); _SelectElement(_Buttons[_ButtonSave]);
@@ -389,11 +392,13 @@ namespace Vocaluxe.Screens
private void _NewProfile() private void _NewProfile()
{ {
_EditMode = EEditMode.None; _EditMode = EEditMode.None;
int id = CProfiles.NewProfile(); Guid id = CProfiles.NewProfile();
_LoadProfiles(false); _LoadProfiles(false);
_SelectSlides[_SelectSlideProfiles].SelectedTag = id; int num = CProfiles.NumProfiles;
_SelectSlides[_SelectSlideProfiles].SelectedTag = num;
_SelectSlideGuids.Add(num, id);
CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].SelectedTag, _SelectSlides[_SelectSlideAvatars].SelectedTag); CProfiles.SetAvatar(id, _SelectSlides[_SelectSlideAvatars].SelectedTag);
_SelectElement(_Buttons[_ButtonPlayerName]); _SelectElement(_Buttons[_ButtonPlayerName]);
_EditMode = EEditMode.PlayerName; _EditMode = EEditMode.PlayerName;
@@ -409,7 +414,8 @@ namespace Vocaluxe.Screens
{ {
_EditMode = EEditMode.None; _EditMode = EEditMode.None;
CProfiles.DeleteProfile(_SelectSlides[_SelectSlideProfiles].SelectedTag); CProfiles.DeleteProfile(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag));
_SelectSlideGuids.Remove(_SelectSlides[_SelectSlideProfiles].SelectedTag);
int selection = _SelectSlides[_SelectSlideProfiles].Selection; int selection = _SelectSlides[_SelectSlideProfiles].Selection;
if (_SelectSlides[_SelectSlideProfiles].NumValues - 1 > selection) if (_SelectSlides[_SelectSlideProfiles].NumValues - 1 > selection)
@@ -422,23 +428,29 @@ namespace Vocaluxe.Screens
{ {
string name = String.Empty; string name = String.Empty;
if (_EditMode == EEditMode.PlayerName) if (_EditMode == EEditMode.PlayerName)
name = CProfiles.GetPlayerName(_SelectSlides[_SelectSlideProfiles].SelectedTag); name = CProfiles.GetPlayerName(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag));
int selectedProfileID = _SelectSlides[_SelectSlideProfiles].SelectedTag; Guid selectedProfileID = _GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag);
_SelectSlides[_SelectSlideProfiles].Clear(); _SelectSlides[_SelectSlideProfiles].Clear();
_SelectSlideGuids.Clear();
CProfile[] profiles = CProfiles.GetProfiles(); CProfile[] profiles = CProfiles.GetProfiles();
int i = 0;
foreach (CProfile profile in profiles) foreach (CProfile profile in profiles)
_SelectSlides[_SelectSlideProfiles].AddValue(profile.PlayerName, null, profile.ID); {
_SelectSlides[_SelectSlideProfiles].AddValue(profile.PlayerName, null, i);
_SelectSlideGuids.Add(i, profile.ID);
i++;
}
if (CProfiles.NumProfiles > 0 && CProfiles.NumAvatars > 0) if (CProfiles.NumProfiles > 0 && CProfiles.NumAvatars > 0)
{ {
if (selectedProfileID != -1) if (selectedProfileID != Guid.Empty)
_SelectSlides[_SelectSlideProfiles].SelectedTag = selectedProfileID; _SelectSlides[_SelectSlideProfiles].SelectedTag = _SelectSlideGuids.FirstOrDefault(x => x.Value.Equals(selectedProfileID)).Key;
else else
{ {
_SelectSlides[_SelectSlideProfiles].Selection = 0; _SelectSlides[_SelectSlideProfiles].Selection = 0;
selectedProfileID = _SelectSlides[_SelectSlideProfiles].SelectedTag; selectedProfileID = _GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag);
} }
if (!keep) if (!keep)
@@ -450,7 +462,7 @@ namespace Vocaluxe.Screens
} }
if (_EditMode == EEditMode.PlayerName) if (_EditMode == EEditMode.PlayerName)
CProfiles.SetPlayerName(_SelectSlides[_SelectSlideProfiles].SelectedTag, name); CProfiles.SetPlayerName(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag), name);
} }
_ProfilesChanged = false; _ProfilesChanged = false;
} }
@@ -469,12 +481,20 @@ namespace Vocaluxe.Screens
if (keep) if (keep)
{ {
_SelectSlides[_SelectSlideAvatars].SelectedTag = selectedAvatarID; _SelectSlides[_SelectSlideAvatars].SelectedTag = selectedAvatarID;
CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].SelectedTag, selectedAvatarID); CProfiles.SetAvatar(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag), selectedAvatarID);
} }
else else
_SelectSlides[_SelectSlideAvatars].SelectedTag = CProfiles.GetAvatarID(_SelectSlides[_SelectSlideProfiles].SelectedTag); _SelectSlides[_SelectSlideAvatars].SelectedTag = CProfiles.GetAvatarID(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag));
_AvatarsChanged = false; _AvatarsChanged = false;
} }
private Guid _GetIdFromTag(int tag)
{
if (tag == -1 || !_SelectSlideGuids.ContainsKey(tag))
return Guid.Empty;
else
return _SelectSlideGuids[tag];
}
} }
} }
+3
View File
@@ -138,6 +138,9 @@ namespace Vocaluxe.Screens
_SetVisibility(); _SetVisibility();
_UpdateRatings(); _UpdateRatings();
_SlideShowBG.Visible = _UpdateBackground(); _SlideShowBG.Visible = _UpdateBackground();
for (int p = 0; p < CGame.NumPlayers; p++)
_Statics[_StaticAvatar[p, CGame.NumPlayers - 1]].Aspect = EAspect.Crop;
} }
public override bool UpdateGame() public override bool UpdateGame()
+91 -46
View File
@@ -50,12 +50,12 @@ namespace Vocaluxe.Screens
private const string _TextSongName = "TextSongName"; private const string _TextSongName = "TextSongName";
private const string _TextTime = "TextTime"; private const string _TextTime = "TextTime";
private const string _TextPause = "TextPause";
private const string _TextDuetName1 = "TextDuetName1"; private const string _TextDuetName1 = "TextDuetName1";
private const string _TextDuetName2 = "TextDuetName2"; private const string _TextDuetName2 = "TextDuetName2";
private const string _TextMedleyCountdown = "TextMedleyCountdown"; private const string _TextMedleyCountdown = "TextMedleyCountdown";
private string[,,] _TextScores; private string[,,] _TextScores;
private string[,,] _TextNames; private string[,,] _TextNames;
private List<string> _TextsPause;
private const string _StaticSongText = "StaticSongText"; private const string _StaticSongText = "StaticSongText";
private const string _StaticLyrics = "StaticLyrics"; private const string _StaticLyrics = "StaticLyrics";
@@ -69,7 +69,7 @@ namespace Vocaluxe.Screens
private const string _StaticLyricHelper = "StaticLyricHelper"; private const string _StaticLyricHelper = "StaticLyricHelper";
private const string _StaticLyricHelperDuet = "StaticLyricHelperDuet"; private const string _StaticLyricHelperDuet = "StaticLyricHelperDuet";
private const string _StaticLyricHelperTop = "StaticLyricHelperTop"; private const string _StaticLyricHelperTop = "StaticLyricHelperTop";
private const string _StaticPauseBG = "StaticPauseBG"; private List<string> _StaticsPause;
private string[,,] _StaticScores; private string[,,] _StaticScores;
private string[,,] _StaticAvatars; private string[,,] _StaticAvatars;
@@ -139,7 +139,7 @@ namespace Vocaluxe.Screens
{ {
base.Init(); base.Init();
var texts = new List<string> { _TextSongName, _TextTime, _TextPause, _TextDuetName1, _TextDuetName2, _TextMedleyCountdown }; var texts = new List<string> { _TextSongName, _TextTime, _TextDuetName1, _TextDuetName2, _TextMedleyCountdown };
_BuildTextStrings(texts); _BuildTextStrings(texts);
_ThemeTexts = texts.ToArray(); _ThemeTexts = texts.ToArray();
@@ -156,9 +156,8 @@ namespace Vocaluxe.Screens
_StaticTimePointer, _StaticTimePointer,
_StaticLyricHelper, _StaticLyricHelper,
_StaticLyricHelperDuet, _StaticLyricHelperDuet,
_StaticLyricHelperTop, _StaticLyricHelperTop
_StaticPauseBG };
};
_BuildStaticStrings(ref statics); _BuildStaticStrings(ref statics);
_ThemeStatics = statics.ToArray(); _ThemeStatics = statics.ToArray();
@@ -181,6 +180,21 @@ namespace Vocaluxe.Screens
_TimerDuetText2 = new Stopwatch(); _TimerDuetText2 = new Stopwatch();
} }
public override void LoadTheme(string xmlPath)
{
base.LoadTheme(xmlPath);
_StaticsPause = new List<string>();
_TextsPause = new List<string>();
//Automatically find statics and texts with pause prefix
foreach (CStatic s in _Statics.Where(s => s.ThemeLoaded && s.GetThemeName().StartsWith("StaticPause")))
_StaticsPause.Add(s.GetThemeName());
foreach (CText t in _Texts.Where(s => s.ThemeLoaded && s.GetThemeName().StartsWith("TextPause")))
_TextsPause.Add(t.GetThemeName());
}
public override bool HandleInput(SKeyEvent keyEvent) public override bool HandleInput(SKeyEvent keyEvent)
{ {
base.HandleInput(keyEvent); base.HandleInput(keyEvent);
@@ -220,15 +234,13 @@ namespace Vocaluxe.Screens
CConfig.Config.Theme.PlayerInfo = (EPlayerInfo)mode; CConfig.Config.Theme.PlayerInfo = (EPlayerInfo)mode;
CConfig.SaveConfig(); CConfig.SaveConfig();
_SetVisibility(); _SetVisibility();
if (CGame.GetSong() != null)
_SetDuetLyricsVisibility(CGame.GetSong().IsDuet); //make sure duet lyrics remain visible
break; break;
case Keys.S: case Keys.S:
if (CGame.NumRounds > CGame.RoundNr) if (CGame.NumRounds > CGame.RoundNr)
{ {
if (keyEvent.ModCtrl) if (keyEvent.ModCtrl)
_LoadNextSong(); _NextSong();
} }
break; break;
case Keys.W: case Keys.W:
@@ -250,7 +262,7 @@ namespace Vocaluxe.Screens
_Stop(); _Stop();
if (_Buttons[_ButtonSkip].Selected) if (_Buttons[_ButtonSkip].Selected)
{ {
_LoadNextSong(); _NextSong();
_SetPause(false); _SetPause(false);
} }
} }
@@ -295,7 +307,7 @@ namespace Vocaluxe.Screens
if (_Buttons[_ButtonSkip].Selected) if (_Buttons[_ButtonSkip].Selected)
{ {
_LoadNextSong(); _NextSong();
_SetPause(false); _SetPause(false);
} }
} }
@@ -318,7 +330,7 @@ namespace Vocaluxe.Screens
finish = true; finish = true;
if (finish && !_FadeOut) if (finish && !_FadeOut)
_LoadNextSong(); _NextSong();
_UpdateSongText(); _UpdateSongText();
_UpdateDuetNames(); _UpdateDuetNames();
@@ -451,7 +463,7 @@ namespace Vocaluxe.Screens
base.OnShowFinish(); base.OnShowFinish();
CGame.Start(); CGame.Start();
_LoadNextSong(); _NextSong();
} }
public override void Draw() public override void Draw()
@@ -535,12 +547,40 @@ namespace Vocaluxe.Screens
_Texts[_TextMedleyCountdown].Text = String.Empty; _Texts[_TextMedleyCountdown].Text = String.Empty;
} }
private void _LoadNextSong() private void _RestartRound()
{
_CloseSong();
CGame.ResetPlayer();
_LoadCurrentSong();
_StartSong();
}
private void _RestartGame()
{
_CloseSong();
CGame.Reset();
CGame.ResetPlayer();
CGame.NextRound();
_LoadCurrentSong();
_StartSong();
}
private void _NextSong()
{ {
_CloseSong(); _CloseSong();
CGame.NextRound(); CGame.NextRound();
_LoadCurrentSong();
_StartSong();
}
private void _LoadCurrentSong()
{
if (CGame.IsFinished()) if (CGame.IsFinished())
{ {
_FinishedSinging(); _FinishedSinging();
@@ -634,7 +674,6 @@ namespace Vocaluxe.Screens
for (int p = 0; p < CGame.NumPlayers; p++) for (int p = 0; p < CGame.NumPlayers; p++)
_ProgressBars[_PlayerProgressBarRating[p]].Reset(); _ProgressBars[_PlayerProgressBarRating[p]].Reset();
_SetDuetLyricsVisibility(song.IsDuet);
_SetNormalLyricsVisibility(); _SetNormalLyricsVisibility();
_TimerSongText.Reset(); _TimerSongText.Reset();
@@ -643,41 +682,38 @@ namespace Vocaluxe.Screens
if (!song.IsDuet) if (!song.IsDuet)
_TimerSongText.Start(); _TimerSongText.Start();
_StartSong();
}
private void _SetDuetLyricsVisibility(bool isDuet)
{
_Statics[_StaticLyricsDuet].Visible = isDuet;
_Lyrics[_LyricMainDuet].Visible = isDuet;
_Lyrics[_LyricSubDuet].Visible = isDuet;
if (isDuet)
{
_Lyrics[_LyricMainTop].Visible = false;
_Lyrics[_LyricSubTop].Visible = false;
_Statics[_StaticLyricsTop].Visible = false;
}
else
{
bool lyricsOnTop = CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_TOP
|| CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH
|| (CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && _DynamicLyricsTop);
_Lyrics[_LyricMainTop].Visible = lyricsOnTop;
_Lyrics[_LyricSubTop].Visible = lyricsOnTop;
_Statics[_StaticLyricsTop].Visible = lyricsOnTop;
}
} }
private void _SetNormalLyricsVisibility() private void _SetNormalLyricsVisibility()
{ {
bool visible = CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTTOM bool bottomLyricsVisible = CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTTOM
|| CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH || CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH
|| (CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && _DynamicLyricsBottom); || (CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && _DynamicLyricsBottom);
_Lyrics[_LyricMain].Visible = visible;
_Lyrics[_LyricSub].Visible = visible; bool topLyricsVisible = CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_TOP
_Statics[_StaticLyrics].Visible = visible; || CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH
|| (CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && _DynamicLyricsTop);
bool duetLyricsVisible = false;
if (CGame.GetSong() != null && CGame.GetSong().IsDuet)
{
bottomLyricsVisible = true;
topLyricsVisible = false;
duetLyricsVisible = true;
}
_Lyrics[_LyricMain].Visible = bottomLyricsVisible;
_Lyrics[_LyricSub].Visible = bottomLyricsVisible;
_Statics[_StaticLyrics].Visible = bottomLyricsVisible;
_Lyrics[_LyricMainTop].Visible = topLyricsVisible;
_Lyrics[_LyricSubTop].Visible = topLyricsVisible;
_Statics[_StaticLyricsTop].Visible = topLyricsVisible;
_Lyrics[_LyricMainDuet].Visible = duetLyricsVisible;
_Lyrics[_LyricSubDuet].Visible = duetLyricsVisible;
_Statics[_StaticLyricsDuet].Visible = duetLyricsVisible;
} }
private void _StartSong() private void _StartSong()
@@ -693,7 +729,10 @@ namespace Vocaluxe.Screens
{ {
//Need this to set other songs to points-var //Need this to set other songs to points-var
while (!CGame.IsFinished()) while (!CGame.IsFinished())
{
CGame.NextRound(); CGame.NextRound();
CGame.ResetPlayer();
}
_FinishedSinging(); _FinishedSinging();
} }
@@ -830,11 +869,17 @@ namespace Vocaluxe.Screens
private void _SetPause(bool paused) private void _SetPause(bool paused)
{ {
_Pause = paused; _Pause = paused;
_Statics[_StaticPauseBG].Visible = _Pause;
_Texts[_TextPause].Visible = _Pause; foreach(String s in _StaticsPause)
_Statics[s].Visible = _Pause;
foreach(String s in _TextsPause)
_Texts[s].Visible = _Pause;
_Buttons[_ButtonCancel].Visible = _Pause; _Buttons[_ButtonCancel].Visible = _Pause;
_Buttons[_ButtonContinue].Visible = _Pause; _Buttons[_ButtonContinue].Visible = _Pause;
_Buttons[_ButtonSkip].Visible = _Pause && CGame.NumRounds > CGame.RoundNr && CGame.NumRounds > 1; _Buttons[_ButtonSkip].Visible = _Pause && CGame.NumRounds > CGame.RoundNr && CGame.NumRounds > 1;
if (_Pause) if (_Pause)
CSound.Pause(_CurrentStream); CSound.Pause(_CurrentStream);
else else
+12 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">DebugWin</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">DebugWin</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vocaluxe</RootNamespace> <RootNamespace>Vocaluxe</RootNamespace>
<AssemblyName>Vocaluxe</AssemblyName> <AssemblyName>Vocaluxe</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<StartupObject>Vocaluxe.CMainProgram</StartupObject> <StartupObject>Vocaluxe.CMainProgram</StartupObject>
@@ -43,6 +43,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseWin|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseWin|x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@@ -54,6 +55,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>WIN;ARCH_X86</DefineConstants> <DefineConstants>WIN;ARCH_X86</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|x64'">
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@@ -66,6 +68,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CodeAnalysisRuleSet>..\CheckingRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>..\CheckingRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|x64'">
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@@ -77,6 +80,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>WIN;ARCH_X64</DefineConstants> <DefineConstants>WIN;ARCH_X64</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugLinux|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugLinux|x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@@ -88,6 +92,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseLinux|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseLinux|x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@@ -99,6 +104,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>LINUX;ARCH_X86</DefineConstants> <DefineConstants>LINUX;ARCH_X86</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|x64'">
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@@ -110,6 +116,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|x64'">
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@@ -121,6 +128,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>LINUX;ARCH_X64</DefineConstants> <DefineConstants>LINUX;ARCH_X64</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|x86'">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@@ -132,6 +140,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>WIN;ARCH_X86;INSTALLER</DefineConstants> <DefineConstants>WIN;ARCH_X86;INSTALLER</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|x64'">
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@@ -143,6 +152,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>WIN;ARCH_X64;INSTALLER</DefineConstants> <DefineConstants>WIN;ARCH_X64;INSTALLER</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
+2 -2
View File
@@ -1,11 +1,11 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
</startup> </startup>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="libs\managed\;libs\unmanaged;libs\;.;libs\managed\x64\;libs\unmanaged\x64\;libs\x64\;.\x64\;libs\managed\x86\;libs\unmanaged\x86\;libs\x86\;.\x86\" /> <probing privatePath="libs\managed\;libs\unmanaged;libs\;.;libs\managed\x64\;libs\unmanaged\x64\;libs\x64\;.\x64\;libs\managed\x86\;libs\unmanaged\x86\;libs\x86\;.\x86\"/>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
<!-- Enable for WCF tracing <!-- Enable for WCF tracing
+6 -5
View File
@@ -219,12 +219,13 @@ namespace VocaluxeLib
public interface IProfiles public interface IProfiles
{ {
CProfile[] GetProfiles(); CProfile[] GetProfiles();
EGameDifficulty GetDifficulty(int profileID); int GetNum();
string GetPlayerName(int profileID, int playerNum = 0); EGameDifficulty GetDifficulty(Guid profileID);
CTextureRef GetAvatar(int profileID); string GetPlayerName(Guid profileID, int playerNum = 0);
CTextureRef GetAvatar(Guid profileID);
CAvatar GetAvatarByFilename(string fileName); CAvatar GetAvatarByFilename(string fileName);
bool IsProfileIDValid(int profileID); bool IsProfileIDValid(Guid profileID);
bool IsGuest(int profileID); bool IsGuest(Guid profileID);
void AddProfileChangedCallback(ProfileChangedCallback notification); void AddProfileChangedCallback(ProfileChangedCallback notification);
} }
+37 -30
View File
@@ -15,6 +15,7 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>. // along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
@@ -53,7 +54,7 @@ namespace VocaluxeLib.Menu
private bool _SelectingKeyboardActive; private bool _SelectingKeyboardActive;
private bool _SelectingFast; private bool _SelectingFast;
private int _SelectingFastPlayerNr; private int _SelectingFastPlayerNr;
private int _SelectedProfileID = -1; private Guid _SelectedProfileID = Guid.Empty;
private CStatic _ChooseAvatarStatic; private CStatic _ChooseAvatarStatic;
private int _OldMouseX; private int _OldMouseX;
@@ -70,7 +71,7 @@ namespace VocaluxeLib.Menu
private const string _SelectSlidePlayer = "SelectSlidePlayer"; private const string _SelectSlidePlayer = "SelectSlidePlayer";
private const string _NameSelection = "NameSelection"; private const string _NameSelection = "NameSelection";
protected List<int>[] _TeamList; protected List<Guid>[] _TeamList;
public override void Init() public override void Init()
{ {
@@ -98,13 +99,13 @@ namespace VocaluxeLib.Menu
_NumPlayer = numPlayer; _NumPlayer = numPlayer;
_NumPlayerTeams = numPlayerTeams; _NumPlayerTeams = numPlayerTeams;
_TeamList = new List<int>[_NumTeams > 0 ? _NumTeams : 1]; _TeamList = new List<Guid>[_NumTeams > 0 ? _NumTeams : 1];
if (_NumTeams != _NumPlayerTeams.Length) if (_NumTeams != _NumPlayerTeams.Length)
_NumPlayerTeams = new int[_NumTeams]; _NumPlayerTeams = new int[_NumTeams];
for (int i = 0; i < _TeamList.Length; i++) for (int i = 0; i < _TeamList.Length; i++)
_TeamList[i] = new List<int>(); _TeamList[i] = new List<Guid>();
_UpdateSlides(); _UpdateSlides();
_LoadProfiles(); _LoadProfiles();
@@ -113,7 +114,7 @@ namespace VocaluxeLib.Menu
_UpdateNextButtonVisibility(); _UpdateNextButtonVisibility();
} }
public void SetPartyModeProfiles(List<int>[] teamProfiles) public void SetPartyModeProfiles(List<Guid>[] teamProfiles)
{ {
_TeamList = teamProfiles; _TeamList = teamProfiles;
_UpdateSlides(); _UpdateSlides();
@@ -133,9 +134,9 @@ namespace VocaluxeLib.Menu
{ {
case Keys.Enter: case Keys.Enter:
//Check, if a player is selected //Check, if a player is selected
if (_NameSelections[_NameSelection].Selection > -1) if (_NameSelections[_NameSelection].SelectedID != Guid.Empty)
{ {
_SelectedProfileID = _NameSelections[_NameSelection].Selection; _SelectedProfileID = _NameSelections[_NameSelection].SelectedID;
if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID)) if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
@@ -371,7 +372,7 @@ namespace VocaluxeLib.Menu
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
//Check if LeftButton is hold and Select-Mode inactive //Check if LeftButton is hold and Select-Mode inactive
if (mouseEvent.LBH && _SelectedProfileID < 0 && !_SelectingFast) if (mouseEvent.LBH && _SelectedProfileID == Guid.Empty && !_SelectingFast)
{ {
//Save mouse-coords //Save mouse-coords
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
@@ -380,8 +381,8 @@ namespace VocaluxeLib.Menu
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{ {
//Get player-number of tile //Get player-number of tile
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
if (_SelectedProfileID != -1) if (_SelectedProfileID != Guid.Empty)
{ {
//Update of Drag/Drop-Texture //Update of Drag/Drop-Texture
CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent); CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
@@ -394,7 +395,7 @@ namespace VocaluxeLib.Menu
} }
} }
//Check if LeftButton is hold and Select-Mode active //Check if LeftButton is hold and Select-Mode active
if (mouseEvent.LBH && _SelectedProfileID >= 0 && !_SelectingFast) if (mouseEvent.LBH && _SelectedProfileID != Guid.Empty && !_SelectingFast)
{ {
//Update coords for Drag/Drop-Texture //Update coords for Drag/Drop-Texture
_ChooseAvatarStatic.X += mouseEvent.X - _OldMouseX; _ChooseAvatarStatic.X += mouseEvent.X - _OldMouseX;
@@ -403,7 +404,7 @@ namespace VocaluxeLib.Menu
_OldMouseY = mouseEvent.Y; _OldMouseY = mouseEvent.Y;
} }
// LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar // LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar
else if (_SelectedProfileID >= 0 && !_SelectingFast) else if (_SelectedProfileID != Guid.Empty && !_SelectingFast)
{ {
//Check if mouse is in drop-area //Check if mouse is in drop-area
if (CHelper.IsInBounds(_SelectSlides[_SelectSlidePlayer].Rect, mouseEvent)) if (CHelper.IsInBounds(_SelectSlides[_SelectSlidePlayer].Rect, mouseEvent))
@@ -415,7 +416,7 @@ namespace VocaluxeLib.Menu
} }
//Reset variables //Reset variables
_SelectedProfileID = -1; _SelectedProfileID = Guid.Empty;
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
} }
if (mouseEvent.LB && _SelectingFast) if (mouseEvent.LB && _SelectingFast)
@@ -423,8 +424,8 @@ namespace VocaluxeLib.Menu
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{ {
//Get player-number of tile //Get player-number of tile
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
if (_SelectedProfileID != -1) if (_SelectedProfileID != Guid.Empty)
{ {
if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID)) if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
@@ -473,8 +474,8 @@ namespace VocaluxeLib.Menu
if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast) if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast)
{ {
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
if (_SelectedProfileID > -1) if (_SelectedProfileID != Guid.Empty)
{ {
if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID)) if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
@@ -491,7 +492,7 @@ namespace VocaluxeLib.Menu
if (_SelectSlides[_SelectSlidePlayer].Selected && _TeamList[_CurrentTeam].Count > _SelectSlides[_SelectSlidePlayer].Selection) if (_SelectSlides[_SelectSlidePlayer].Selected && _TeamList[_CurrentTeam].Count > _SelectSlides[_SelectSlidePlayer].Selection)
{ {
int currentSelection = _SelectSlides[_SelectSlidePlayer].Selection; int currentSelection = _SelectSlides[_SelectSlidePlayer].Selection;
int id = _TeamList[_CurrentTeam][currentSelection]; Guid id = _TeamList[_CurrentTeam][currentSelection];
_RemovePlayer(_CurrentTeam, id); _RemovePlayer(_CurrentTeam, id);
_UpdatePlayerSlide(); _UpdatePlayerSlide();
exit = false; exit = false;
@@ -575,9 +576,9 @@ namespace VocaluxeLib.Menu
{ {
_NumTeams++; _NumTeams++;
int[] numPlayerTeams = _NumPlayerTeams; int[] numPlayerTeams = _NumPlayerTeams;
List<int>[] teamList = _TeamList; List<Guid>[] teamList = _TeamList;
_NumPlayerTeams = new int[_NumTeams]; _NumPlayerTeams = new int[_NumTeams];
_TeamList = new List<int>[_NumTeams]; _TeamList = new List<Guid>[_NumTeams];
for (int i = 0; i < _NumPlayerTeams.Length; i++) for (int i = 0; i < _NumPlayerTeams.Length; i++)
{ {
if (i < numPlayerTeams.Length) if (i < numPlayerTeams.Length)
@@ -588,7 +589,7 @@ namespace VocaluxeLib.Menu
else else
{ {
_NumPlayerTeams[i] = _NumPlayer; _NumPlayerTeams[i] = _NumPlayer;
_TeamList[i] = new List<int>(); _TeamList[i] = new List<Guid>();
} }
} }
} }
@@ -721,7 +722,7 @@ namespace VocaluxeLib.Menu
} }
} }
private void _AddPlayer(int team, int profileID) private void _AddPlayer(int team, Guid profileID, bool updateElements=true)
{ {
if (_NumPlayerTeams[team] == _TeamList[team].Count && !_ChangePlayerNumDynamic) if (_NumPlayerTeams[team] == _TeamList[team].Count && !_ChangePlayerNumDynamic)
return; return;
@@ -731,17 +732,20 @@ namespace VocaluxeLib.Menu
_NameSelections[_NameSelection].UseProfile(profileID); _NameSelections[_NameSelection].UseProfile(profileID);
_TeamList[team].Add(profileID); _TeamList[team].Add(profileID);
_UpdatePlayerSlide(); if (updateElements)
_UpdateNextButtonVisibility(); {
_UpdatePlayerSlide();
_UpdateNextButtonVisibility();
}
} }
private void _RemoveAllPlayer() private void _RemoveAllPlayer()
{ {
for (int t = 0; t < _TeamList.Length; t++) for (int t = 0; t < _TeamList.Length; t++)
{ {
List<int> ids = new List<int>(); List<Guid> ids = new List<Guid>();
ids.AddRange(_TeamList[t]); ids.AddRange(_TeamList[t]);
foreach (int id in ids) foreach (Guid id in ids)
_RemovePlayer(t, id); _RemovePlayer(t, id);
} }
} }
@@ -750,7 +754,7 @@ namespace VocaluxeLib.Menu
{ {
if (_TeamList[team].Count > index) if (_TeamList[team].Count > index)
{ {
int id = _TeamList[team][index]; Guid id = _TeamList[team][index];
_TeamList[team].RemoveAt(index); _TeamList[team].RemoveAt(index);
_NameSelections[_NameSelection].RemoveUsedProfile(id); _NameSelections[_NameSelection].RemoveUsedProfile(id);
} }
@@ -758,7 +762,7 @@ namespace VocaluxeLib.Menu
_UpdateNextButtonVisibility(); _UpdateNextButtonVisibility();
} }
private void _RemovePlayer(int team, int profileID) private void _RemovePlayer(int team, Guid profileID)
{ {
_TeamList[team].Remove(profileID); _TeamList[team].Remove(profileID);
_NameSelections[_NameSelection].RemoveUsedProfile(profileID); _NameSelections[_NameSelection].RemoveUsedProfile(profileID);
@@ -773,11 +777,14 @@ namespace VocaluxeLib.Menu
{ {
for (int p = 0; p < _NumPlayerTeams[t]; p++) for (int p = 0; p < _NumPlayerTeams[t]; p++)
{ {
int profileID = _NameSelections[_NameSelection].GetRandomUnusedProfile(); Guid profileID = _NameSelections[_NameSelection].GetRandomUnusedProfile();
if(profileID >= 0) //only add valid profiles if(profileID != Guid.Empty)
_AddPlayer(t, profileID); _AddPlayer(t, profileID);
} }
} }
_UpdatePlayerSlide();
_UpdateButtonVisibility();
} }
private void _UpdateNextButtonVisibility() private void _UpdateNextButtonVisibility()
+48 -35
View File
@@ -16,6 +16,7 @@
#endregion #endregion
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml.Serialization; using System.Xml.Serialization;
@@ -59,11 +60,11 @@ namespace VocaluxeLib.Menu
{ {
private class CTile private class CTile
{ {
public int ProfileID; public Guid ProfileID;
public readonly CStatic Avatar; public readonly CStatic Avatar;
public readonly CText Name; public readonly CText Name;
public CTile(CStatic av, CText tex, int pID) public CTile(CStatic av, CText tex, Guid pID)
{ {
Avatar = av; Avatar = av;
Name = tex; Name = tex;
@@ -95,12 +96,12 @@ namespace VocaluxeLib.Menu
public int Offset; public int Offset;
private int _ActualSelection = -1; private int _ActualSelection = -1;
public int Selection = -1; public Guid SelectedID = Guid.Empty;
private int _Player = -1; private int _Player = -1;
private readonly List<int> _VisibleProfiles; private readonly List<Guid> _VisibleProfiles;
private readonly List<int> _UsedProfiles; private readonly List<Guid> _UsedProfiles;
private CStatic _PlayerSelector; private CStatic _PlayerSelector;
@@ -121,8 +122,8 @@ namespace VocaluxeLib.Menu
_Theme = new SThemeNameSelection {Tiles = new SThemeNameSelectionTiles {Name = new SThemeNameSelectionName()}}; _Theme = new SThemeNameSelection {Tiles = new SThemeNameSelectionTiles {Name = new SThemeNameSelectionName()}};
_Tiles = new List<CTile>(); _Tiles = new List<CTile>();
_VisibleProfiles = new List<int>(); _VisibleProfiles = new List<Guid>();
_UsedProfiles = new List<int>(); _UsedProfiles = new List<Guid>();
} }
public CNameSelection(SThemeNameSelection theme, int partyModeID) public CNameSelection(SThemeNameSelection theme, int partyModeID)
@@ -131,8 +132,8 @@ namespace VocaluxeLib.Menu
_Theme = theme; _Theme = theme;
_Tiles = new List<CTile>(); _Tiles = new List<CTile>();
_VisibleProfiles = new List<int>(); _VisibleProfiles = new List<Guid>();
_UsedProfiles = new List<int>(); _UsedProfiles = new List<Guid>();
ThemeLoaded = true; ThemeLoaded = true;
} }
@@ -185,7 +186,7 @@ namespace VocaluxeLib.Menu
case Keys.Right: case Keys.Right:
if (_ActualSelection + 1 < _Tiles.Count) if (_ActualSelection + 1 < _Tiles.Count)
{ {
if (_Tiles[_ActualSelection + 1].ProfileID != -1) if (_Tiles[_ActualSelection + 1].ProfileID != Guid.Empty)
_ActualSelection++; _ActualSelection++;
} }
else else
@@ -219,7 +220,7 @@ namespace VocaluxeLib.Menu
case Keys.Down: case Keys.Down:
if (_ActualSelection + _Theme.Tiles.NumW < _Tiles.Count) if (_ActualSelection + _Theme.Tiles.NumW < _Tiles.Count)
{ {
if (_Tiles[_ActualSelection + _Theme.Tiles.NumW].ProfileID != -1) if (_Tiles[_ActualSelection + _Theme.Tiles.NumW].ProfileID != Guid.Empty)
_ActualSelection += _Theme.Tiles.NumW; _ActualSelection += _Theme.Tiles.NumW;
} }
else else
@@ -227,10 +228,10 @@ namespace VocaluxeLib.Menu
int offset = Offset; int offset = Offset;
UpdateList(Offset + 1); UpdateList(Offset + 1);
} }
if (_Tiles[_ActualSelection].ProfileID == -1) if (_Tiles[_ActualSelection].ProfileID == Guid.Empty)
{ {
_ActualSelection = _Tiles.Count - _Theme.Tiles.NumW; _ActualSelection = _Tiles.Count - _Theme.Tiles.NumW;
while(_Tiles[_ActualSelection + 1].ProfileID != -1) while(_Tiles[_ActualSelection + 1].ProfileID != Guid.Empty)
{ {
_ActualSelection++; _ActualSelection++;
} }
@@ -239,23 +240,23 @@ namespace VocaluxeLib.Menu
} }
if (Offset * _Theme.Tiles.NumW + _ActualSelection < _VisibleProfiles.Count) if (Offset * _Theme.Tiles.NumW + _ActualSelection < _VisibleProfiles.Count)
Selection = _VisibleProfiles[Offset * _Theme.Tiles.NumW + _ActualSelection]; SelectedID = _VisibleProfiles.ElementAt(Offset * _Theme.Tiles.NumW + _ActualSelection);
else else
Selection = -1; SelectedID = Guid.Empty;
} }
public void HandleMouse(SMouseEvent mevent) public void HandleMouse(SMouseEvent mevent)
{ {
for (int i = 0; i < _Tiles.Count; i++) for (int i = 0; i < _Tiles.Count; i++)
{ {
if (CHelper.IsInBounds(_Tiles[i].Avatar.Rect, mevent) && _Tiles[i].ProfileID != -1) if (CHelper.IsInBounds(_Tiles[i].Avatar.Rect, mevent) && _Tiles[i].ProfileID != Guid.Empty)
{ {
_ActualSelection = i; _ActualSelection = i;
if (Offset * _Theme.Tiles.NumW + _ActualSelection < _VisibleProfiles.Count) if (Offset * _Theme.Tiles.NumW + _ActualSelection < _VisibleProfiles.Count)
Selection = _VisibleProfiles[Offset * _Theme.Tiles.NumW + _ActualSelection]; SelectedID = _VisibleProfiles.ElementAt(Offset * _Theme.Tiles.NumW + _ActualSelection);
else else
Selection = -1; SelectedID = Guid.Empty;
} }
} }
} }
@@ -263,7 +264,7 @@ namespace VocaluxeLib.Menu
public void FastSelection(bool active, int player) public void FastSelection(bool active, int player)
{ {
//Overwrite player-selection; Same profile, but other player //Overwrite player-selection; Same profile, but other player
if (active && Selection != -1) if (active && SelectedID != Guid.Empty)
{ {
_Player = player; _Player = player;
_PlayerSelector.Color = CBase.Themes.GetPlayerColor(player); _PlayerSelector.Color = CBase.Themes.GetPlayerColor(player);
@@ -271,7 +272,7 @@ namespace VocaluxeLib.Menu
//Normal activation //Normal activation
else if (active) else if (active)
{ {
Selection = 0; SelectedID = _VisibleProfiles.ElementAt(0);
_ActualSelection = 0; _ActualSelection = 0;
_Player = player; _Player = player;
_PlayerSelector.Color = CBase.Themes.GetPlayerColor(player); _PlayerSelector.Color = CBase.Themes.GetPlayerColor(player);
@@ -280,7 +281,7 @@ namespace VocaluxeLib.Menu
//Deactivate //Deactivate
else else
{ {
Selection = -1; SelectedID = Guid.Empty;
_ActualSelection = -1; _ActualSelection = -1;
_Player = -1; _Player = -1;
_PlayerSelector.Visible = false; _PlayerSelector.Visible = false;
@@ -307,14 +308,14 @@ namespace VocaluxeLib.Menu
_Tiles[i].Avatar.Texture = CBase.Profiles.GetAvatar(_VisibleProfiles[i + offset * _Theme.Tiles.NumW]); _Tiles[i].Avatar.Texture = CBase.Profiles.GetAvatar(_VisibleProfiles[i + offset * _Theme.Tiles.NumW]);
_Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1); _Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1);
_Tiles[i].Name.Text = CBase.Profiles.GetPlayerName(_VisibleProfiles[i + offset * _Theme.Tiles.NumW]); _Tiles[i].Name.Text = CBase.Profiles.GetPlayerName(_VisibleProfiles[i + offset * _Theme.Tiles.NumW]);
_Tiles[i].ProfileID = _VisibleProfiles[i + offset * _Theme.Tiles.NumW]; _Tiles[i].ProfileID = _VisibleProfiles.ElementAt(i + offset * _Theme.Tiles.NumW);
} }
else else
{ {
_Tiles[i].Avatar.Texture = _TextureEmptyTile; _Tiles[i].Avatar.Texture = _TextureEmptyTile;
_Tiles[i].Avatar.Color = _ColorEmptyTile; _Tiles[i].Avatar.Color = _ColorEmptyTile;
_Tiles[i].Name.Text = ""; _Tiles[i].Name.Text = "";
_Tiles[i].ProfileID = -1; _Tiles[i].ProfileID = Guid.Empty;
} }
} }
Offset = offset; Offset = offset;
@@ -331,7 +332,7 @@ namespace VocaluxeLib.Menu
return isOver; return isOver;
} }
public int TilePlayerNr(SMouseEvent mevent) public Guid TilePlayerID(SMouseEvent mevent)
{ {
foreach (CTile tile in _Tiles) foreach (CTile tile in _Tiles)
{ {
@@ -339,7 +340,7 @@ namespace VocaluxeLib.Menu
return tile.ProfileID; return tile.ProfileID;
} }
return -1; return Guid.Empty;
} }
public CStatic TilePlayerAvatar(SMouseEvent mevent) public CStatic TilePlayerAvatar(SMouseEvent mevent)
@@ -374,9 +375,9 @@ namespace VocaluxeLib.Menu
_PrepareTiles(); _PrepareTiles();
} }
public void UseProfile(int id) public void UseProfile(Guid id)
{ {
if (id > -1) if (id != Guid.Empty)
{ {
if (!_UsedProfiles.Contains(id) && CBase.Profiles.IsProfileIDValid(id) && !CBase.Profiles.IsGuest(id)) if (!_UsedProfiles.Contains(id) && CBase.Profiles.IsProfileIDValid(id) && !CBase.Profiles.IsGuest(id))
{ {
@@ -386,22 +387,34 @@ namespace VocaluxeLib.Menu
} }
} }
public void RemoveUsedProfile(int id) public void RemoveUsedProfile(Guid id)
{ {
if (id > -1) if (id != Guid.Empty)
{ {
_UsedProfiles.Remove(id); _UsedProfiles.Remove(id);
UpdateList(); UpdateList();
} }
} }
public int GetRandomUnusedProfile() public Guid GetRandomUnusedProfile()
{ {
if (_VisibleProfiles.Count == 0) Guid id = Guid.Empty;
return -1;
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count); if (_VisibleProfiles.Count == 0)
return _VisibleProfiles[rand]; return id;
if (_VisibleProfiles.Count == _UsedProfiles.Count)
return id;
while (id == Guid.Empty)
{
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
if (_UsedProfiles.Contains(_VisibleProfiles[rand]))
continue;
id = _VisibleProfiles.ElementAt(rand);
}
return id;
} }
private void _PrepareTiles() private void _PrepareTiles()
@@ -416,7 +429,7 @@ namespace VocaluxeLib.Menu
var tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, _ColorEmptyTile, rect) {Aspect = EAspect.Crop}; var tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, _ColorEmptyTile, rect) {Aspect = EAspect.Crop};
var tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.Tiles.Name.Space, rect.Z, _Theme.Tiles.Name.Height, rect.W, EAlignment.Center, var tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.Tiles.Name.Space, rect.Z, _Theme.Tiles.Name.Height, rect.W, EAlignment.Center,
_Theme.Tiles.Name.Style, _Theme.Tiles.Name.Font, _ColorNameTile, ""); _Theme.Tiles.Name.Style, _Theme.Tiles.Name.Font, _ColorNameTile, "");
_Tiles.Add(new CTile(tileStatic, tileText, -1)); _Tiles.Add(new CTile(tileStatic, tileText, Guid.Empty));
} }
} }
_Rect.X = MaxRect.X; _Rect.X = MaxRect.X;
+1
View File
@@ -469,6 +469,7 @@ namespace VocaluxeLib.Menu
Text = new CText(0, 0, 0, _TextH, _MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, _TextColor, "T", _PartyModeID), Text = new CText(0, 0, 0, _TextH, _MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, _TextColor, "T", _PartyModeID),
Img = new CStatic(_PartyModeID) Img = new CStatic(_PartyModeID)
}; };
el.Img.Aspect = EAspect.Crop;
_VisibleElements.Add(el); _VisibleElements.Add(el);
} }
} }
+12 -2
View File
@@ -42,7 +42,7 @@ namespace VocaluxeLib.Profile
#pragma warning restore 649 #pragma warning restore 649
} }
[XmlIgnore] public int ID; [DefaultValue(null)] public Guid ID;
public string PlayerName; public string PlayerName;
[XmlIgnore] public string FilePath; [XmlIgnore] public string FilePath;
@@ -67,12 +67,13 @@ namespace VocaluxeLib.Profile
{ {
Avatar = CBase.Profiles.GetAvatarByFilename(value); Avatar = CBase.Profiles.GetAvatarByFilename(value);
if (Avatar == null) if (Avatar == null)
throw new Exception("Avatar '" + value + "' not found"); CBase.Log.LogError("Avatar '" + value + "' not found");
} }
} }
public CProfile() public CProfile()
{ {
ID = Guid.NewGuid();
PlayerName = String.Empty; PlayerName = String.Empty;
Difficulty = EGameDifficulty.TR_CONFIG_EASY; Difficulty = EGameDifficulty.TR_CONFIG_EASY;
UserRole = EUserRole.TR_USERROLE_NORMAL; UserRole = EUserRole.TR_USERROLE_NORMAL;
@@ -92,6 +93,12 @@ namespace VocaluxeLib.Profile
try try
{ {
xml.Deserialize(FilePath, this); xml.Deserialize(FilePath, this);
//If ID couldn't be loaded, generate a new one and save it
if (ID == Guid.Empty)
{
ID = Guid.NewGuid();
SaveProfile();
}
} }
catch (Exception e) catch (Exception e)
{ {
@@ -112,7 +119,10 @@ namespace VocaluxeLib.Profile
var old = xml.Deserialize<SOldXmlProfile>(FilePath); var old = xml.Deserialize<SOldXmlProfile>(FilePath);
string newXml = ser.Serialize(old.Info); string newXml = ser.Serialize(old.Info);
xml.DeserializeString(newXml, this); xml.DeserializeString(newXml, this);
if (ID == null)
ID = Guid.NewGuid();
ser.Serialize(FilePath, this); ser.Serialize(FilePath, this);
} }
catch (Exception e2) catch (Exception e2)
{ {
+1 -1
View File
@@ -341,7 +341,7 @@ namespace VocaluxeLib
#region Game #region Game
public struct SPlayer public struct SPlayer
{ {
public int ProfileID; public Guid ProfileID;
public double Points; public double Points;
public double PointsLineBonus; public double PointsLineBonus;
public double PointsGoldenNotes; public double PointsGoldenNotes;
+9 -3
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">DebugWin</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">DebugWin</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,11 +10,12 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VocaluxeLib</RootNamespace> <RootNamespace>VocaluxeLib</RootNamespace>
<AssemblyName>VocaluxeLib</AssemblyName> <AssemblyName>VocaluxeLib</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' "> <PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -27,6 +28,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CodeAnalysisRuleSet>..\CheckingRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>..\CheckingRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -38,6 +40,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>WIN</DefineConstants> <DefineConstants>WIN</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -49,6 +52,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -60,6 +64,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>LINUX</DefineConstants> <DefineConstants>LINUX</DefineConstants>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|AnyCPU'">
<OutputPath>..\Output\libs\managed</OutputPath> <OutputPath>..\Output\libs\managed</OutputPath>
@@ -70,6 +75,7 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
+2
View File
@@ -213,6 +213,8 @@ namespace VocaluxeLib.Xml
return value; return value;
} }
} }
if (type == typeof(Guid))
return Guid.Parse(node.InnerText);
if (type == typeof(string)) if (type == typeof(string))
return node == null ? null : node.InnerText; return node == null ? null : node.InnerText;
if (type.IsPrimitive) if (type.IsPrimitive)
+4
View File
@@ -96,6 +96,10 @@ namespace VocaluxeLib.Xml
writer.WriteEndElement(); writer.WriteEndElement();
} }
} }
else if (type == typeof(Guid))
{
writer.WriteElementString(name, value.ToString());
}
else if (type.IsNullable()) else if (type.IsNullable())
_WriteValue(writer, name, type.GetGenericArguments()[0], value, isAttribute, arrayItemName, nameAttribute); _WriteValue(writer, name, type.GetGenericArguments()[0], value, isAttribute, arrayItemName, nameAttribute);
else if (type.IsList() || type.IsArray) else if (type.IsList() || type.IsArray)
+3 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -8,7 +8,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VocaluxeTests</RootNamespace> <RootNamespace>VocaluxeTests</RootNamespace>
<AssemblyName>VocaluxeTests</AssemblyName> <AssemblyName>VocaluxeTests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
@@ -16,6 +16,7 @@
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath> <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest> <IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType> <TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
</startup> </startup>
</configuration> </configuration>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebserverInitalConfig</RootNamespace> <RootNamespace>WebserverInitalConfig</RootNamespace>
<AssemblyName>VocaluxeServerConfig</AssemblyName> <AssemblyName>VocaluxeServerConfig</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
<NuGetPackageImportStamp>ee6e2fa6</NuGetPackageImportStamp> <NuGetPackageImportStamp>ee6e2fa6</NuGetPackageImportStamp>
@@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -32,6 +33,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>Vocaluxe.ico</ApplicationIcon> <ApplicationIcon>Vocaluxe.ico</ApplicationIcon>