Save selected players to config and load them on start.

This commit is contained in:
Florian Kuepper committed 2012-04-06 11:40:45 +02:00
1 parent 1f29aa7759
commit c428dbb404
3 files changed
+52

No files matched your search

+37
View File
@@ -206,6 +206,7 @@ namespace Vocaluxe.Base
public static EOffOn Tabs = EOffOn.TR_CONFIG_OFF;
public static string Language = "English";
public static EOffOn LyricsOnTop = EOffOn.TR_CONFIG_OFF;
public static string[] Players = new string[CSettings.MaxNumPlayer];
// Video
public static EVideoDecoder VideoDecoder = EVideoDecoder.FFmpeg;
@@ -370,6 +371,12 @@ namespace Vocaluxe.Base
}
CLanguage.SetLanguage(Language);
//Read players from config
for (i = 1; i <= CSettings.MaxNumPlayer; i++)
{
CHelper.GetValueFromXML("//root/Game/Players/Player" + i.ToString(), navigator, ref Players[i-1], string.Empty);
}
#endregion Game
#region Video
@@ -577,6 +584,13 @@ namespace Vocaluxe.Base
writer.WriteComment("Lyrics also on Top of screen: " + ListStrings(Enum.GetNames(typeof(EOffOn))));
writer.WriteElementString("LyricsOnTop", Enum.GetName(typeof(EOffOn), LyricsOnTop));
writer.WriteComment("Default profile for players 1..." + CSettings.MaxNumPlayer.ToString() + ":");
writer.WriteStartElement("Players");
for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
{
writer.WriteElementString("Player" + i.ToString(), Path.GetFileName(Players[i - 1]));
}
writer.WriteEndElement();
#endregion Game
@@ -945,6 +959,29 @@ namespace Vocaluxe.Base
return _Result;
}
/// <summary>
/// Use saved players from config now for games
/// </summary>
public static void UsePlayers()
{
for (int i = 0; i < CProfiles.Profiles.Length; i++)
{
for (int j = 0; j < CSettings.MaxNumPlayer; j++)
{
if (Players[j] != string.Empty)
{
if (Path.GetFileName(CProfiles.Profiles[i].ProfileFile) == Players[j])
{
//Update Game-infos with player
CGame.Player[j].Name = CProfiles.Profiles[i].PlayerName;
CGame.Player[j].Difficulty = CProfiles.Profiles[i].Difficulty;
CGame.Player[j].ProfileID = i;
}
}
}
}
}
}
+2
View File
@@ -102,6 +102,8 @@ namespace Vocaluxe.Base
_GameMode.Init();
_Player = new SPlayer[CSettings.MaxNumPlayer];
ResetPlayer();
CConfig.UsePlayers();
}
public static void SetGameMode(EGameMode Mode)
+13
View File
@@ -133,6 +133,9 @@ namespace Vocaluxe.Screens
CGame.Player[selectingKeyboardPlayerNr-1].Name = CProfiles.Profiles[SelectedPlayerNr].PlayerName;
CGame.Player[selectingKeyboardPlayerNr-1].Difficulty = CProfiles.Profiles[SelectedPlayerNr].Difficulty;
CGame.Player[selectingKeyboardPlayerNr-1].ProfileID = SelectedPlayerNr;
//Update config for default players.
CConfig.Players[selectingKeyboardPlayerNr - 1] = CProfiles.Profiles[SelectedPlayerNr].ProfileFile;
CConfig.SaveConfig();
//Update texture and name
Statics[htStatics(StaticPlayerAvatar[selectingKeyboardPlayerNr-1])].Texture = NameSelections[htNameSelections(NameSelection)].TilePlayerAvatar(SelectedPlayerNr).Texture;
Texts[htTexts(TextPlayer[selectingKeyboardPlayerNr-1])].Text = CProfiles.Profiles[SelectedPlayerNr].PlayerName;
@@ -372,6 +375,9 @@ namespace Vocaluxe.Screens
CGame.Player[i].Name = CProfiles.Profiles[SelectedPlayerNr].PlayerName;
CGame.Player[i].Difficulty = CProfiles.Profiles[SelectedPlayerNr].Difficulty;
CGame.Player[i].ProfileID = SelectedPlayerNr;
//Update config for default players.
CConfig.Players[i] = CProfiles.Profiles[SelectedPlayerNr].ProfileFile;
CConfig.SaveConfig();
//Update texture and name
Statics[htStatics(StaticPlayerAvatar[i])].Texture = chooseAvatarStatic.Texture;
Texts[htTexts(TextPlayer[i])].Text = CProfiles.Profiles[SelectedPlayerNr].PlayerName;
@@ -442,6 +448,13 @@ namespace Vocaluxe.Screens
UpdateSlides();
UpdatePlayerNumber();
CheckMics();
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
//Update texture and name
Statics[htStatics(StaticPlayerAvatar[i])].Texture = CProfiles.Profiles[CGame.Player[i].ProfileID].Avatar.Texture;
Texts[htTexts(TextPlayer[i])].Text = CProfiles.Profiles[CGame.Player[i].ProfileID].PlayerName;
}
}
public override bool Draw()