From 480e714afc84e16fde0aa4658428e87601802aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Thu, 27 Jun 2013 13:49:35 +0200 Subject: [PATCH 1/3] Improve profile-handling on names-screen, fixes #26 --- Vocaluxe/Base/CProfiles.cs | 5 ++ Vocaluxe/Screens/CScreenNames.cs | 82 ++++++++++-------------------- VocaluxeLib/Menu/CNameSelection.cs | 2 +- 3 files changed, 32 insertions(+), 57 deletions(-) diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs index 5c7ec480..005eefe3 100644 --- a/Vocaluxe/Base/CProfiles.cs +++ b/Vocaluxe/Base/CProfiles.cs @@ -481,6 +481,11 @@ namespace Vocaluxe.Base return _Profiles[profileID].Avatar.ID; } + + public static int GetProfileID(int num) + { + return _Profiles[num].ID; + } #endregion profile properties #region avatar texture diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 1f840fdd..a2cb0278 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -177,23 +177,12 @@ namespace Vocaluxe.Screens //Check, if a player is selected if (_NameSelections[_NameSelection].Selection > -1) { - CProfile[] profiles = CProfiles.GetProfiles(); _SelectedPlayerNr = _NameSelections[_NameSelection].Selection; - if (profiles.Length <= _SelectedPlayerNr) + if (CProfiles.NumProfiles <= _SelectedPlayerNr) return true; - //Update Game-infos with new player - CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = profiles[_SelectedPlayerNr].ID; - //Update config for default players. - CConfig.Players[_SelectingFastPlayerNr - 1] = profiles[_SelectedPlayerNr].FileName; - CConfig.SaveConfig(); - //Update texture and name - _Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = profiles[_SelectedPlayerNr].Avatar.Texture; - _Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = profiles[_SelectedPlayerNr].PlayerName; - //Update profile-warning - _CheckPlayers(); - //Update Tiles-List - _NameSelections[_NameSelection].UpdateList(); + _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedPlayerNr); + _SetInteractionToButton(_Buttons[_ButtonStart]); } //Started selecting with 'P' @@ -449,22 +438,10 @@ namespace Vocaluxe.Screens _Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.GetPlayerName(-1, (_SelectingSwitchNr + 1)); } - CProfile[] profiles = CProfiles.GetProfiles(); - if (profiles.Length <= _SelectedPlayerNr) + if (CProfiles.NumProfiles <= _SelectedPlayerNr) return true; - //Update Game-infos with new player - CGame.Players[i].ProfileID = profiles[_SelectedPlayerNr].ID; - //Update config for default players. - CConfig.Players[i] = profiles[_SelectedPlayerNr].FileName; - CConfig.SaveConfig(); - //Update texture and name - _Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture; - _Texts[_TextPlayer[i]].Text = profiles[_SelectedPlayerNr].PlayerName; - //Update profile-warning - _CheckPlayers(); - //Update Tiles-List - _NameSelections[_NameSelection].UpdateList(); + _UpdateSelectedProfile(i, _SelectedPlayerNr); break; } //Selected player is dropped out of area @@ -494,22 +471,11 @@ namespace Vocaluxe.Screens _SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); if (_SelectedPlayerNr != -1) { - CProfile[] profiles = CProfiles.GetProfiles(); - if (profiles.Length <= _SelectedPlayerNr) + if (CProfiles.NumProfiles <= _SelectedPlayerNr) return true; - //Update Game-infos with new player - CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = profiles[_SelectedPlayerNr].ID; - //Update config for default players. - CConfig.Players[_SelectingFastPlayerNr - 1] = profiles[_SelectedPlayerNr].FileName; - CConfig.SaveConfig(); - //Update texture and name - _Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = profiles[_SelectedPlayerNr].Avatar.Texture; - _Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = profiles[_SelectedPlayerNr].PlayerName; - //Update profile-warning - _CheckPlayers(); - //Update Tiles-List - _NameSelections[_NameSelection].UpdateList(); + _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedPlayerNr); + _SelectingFastPlayerNr++; if (_SelectingFastPlayerNr <= CGame.NumPlayer) _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); @@ -541,22 +507,10 @@ namespace Vocaluxe.Screens { if (CGame.Players[i].ProfileID == -1) { - CProfile[] profiles = CProfiles.GetProfiles(); - if (profiles.Length <= _SelectedPlayerNr) + if (CProfiles.NumProfiles <= _SelectedPlayerNr) return true; - //Update Game-infos with new player - CGame.Players[i].ProfileID = profiles[_SelectedPlayerNr].ID; - //Update config for default players. - CConfig.Players[i] = profiles[_SelectedPlayerNr].FileName; - CConfig.SaveConfig(); - //Update texture and name - _Statics[_StaticPlayerAvatar[i]].Texture = profiles[_SelectedPlayerNr].Avatar.Texture; - _Texts[_TextPlayer[i]].Text = profiles[_SelectedPlayerNr].PlayerName; - //Update profile-warning - _CheckPlayers(); - //Update Tiles-List - _NameSelections[_NameSelection].UpdateList(); + _UpdateSelectedProfile(i, _SelectedPlayerNr); break; } } @@ -760,6 +714,22 @@ namespace Vocaluxe.Screens _CheckPlayers(); } + private void _UpdateSelectedProfile(int playerNum, int profileId) + { + //Update Game-infos with new player + CGame.Players[playerNum].ProfileID = profileId; + //Update config for default players. + CConfig.Players[playerNum] = CProfiles.GetProfileFileName(profileId); + CConfig.SaveConfig(); + //Update texture and name + _Statics[_StaticPlayerAvatar[playerNum]].Texture = CProfiles.GetAvatarTextureFromProfile(profileId); + _Texts[_TextPlayer[playerNum]].Text = CProfiles.GetPlayerName(profileId); + //Update profile-warning + _CheckPlayers(); + //Update Tiles-List + _NameSelections[_NameSelection].UpdateList(); + } + private void _ResetPlayerSelections() { for (int i = 0; i < CGame.NumPlayer; i++) diff --git a/VocaluxeLib/Menu/CNameSelection.cs b/VocaluxeLib/Menu/CNameSelection.cs index 5c3c043f..f427ed4c 100644 --- a/VocaluxeLib/Menu/CNameSelection.cs +++ b/VocaluxeLib/Menu/CNameSelection.cs @@ -515,7 +515,7 @@ namespace VocaluxeLib.Menu } } if (visible) - _VisibleProfiles.Add(i); + _VisibleProfiles.Add(profiles[i].ID); } } From 698449e2897ce39751985c1da5ad57bc877ee10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Thu, 27 Jun 2013 14:26:28 +0200 Subject: [PATCH 2/3] Added missing language-entry. --- Output/Languages/English.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/Output/Languages/English.xml b/Output/Languages/English.xml index 91959371..2d1be43b 100644 --- a/Output/Languages/English.xml +++ b/Output/Languages/English.xml @@ -92,6 +92,7 @@ Author Version Can't load this party-mode. + There are no mics configured! Target audience No teams Number of teams From 748f776a42996ff190067d20e7ed962ac01c672a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Thu, 27 Jun 2013 15:50:31 +0200 Subject: [PATCH 3/3] Reduce some redundant code, bugfix, refs #26 --- Vocaluxe/Screens/CScreenNames.cs | 62 +++++++++++--------------------- 1 file changed, 20 insertions(+), 42 deletions(-) diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index a2cb0278..015a46fa 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -231,15 +231,7 @@ namespace Vocaluxe.Screens case Keys.Delete: //Delete profile-selection - CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = -1; - //Update config for default players. - CConfig.Players[_SelectingFastPlayerNr - 1] = String.Empty; - CConfig.SaveConfig(); - //Update texture and name - _Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = _OriginalPlayerAvatarTextures[_SelectingFastPlayerNr - 1]; - _Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = CProfiles.GetPlayerName(-1, _SelectingFastPlayerNr); - //Update profile-warning - _CheckPlayers(); + _ResetPlayerSelection(_SelectingFastPlayerNr - 1); //Reset all values _SelectingFastPlayerNr = 0; _SelectingKeyboardActive = false; @@ -419,23 +411,11 @@ namespace Vocaluxe.Screens { if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID > -1) { - //Update Game-infos with new player - CGame.Players[_SelectingSwitchNr].ProfileID = CGame.Players[i].ProfileID; - //Update config for default players. - CConfig.Players[_SelectingSwitchNr] = CProfiles.GetProfileFileName(CGame.Players[i].ProfileID); - //Update texture and name - _Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = CProfiles.GetAvatarTextureFromProfile(CGame.Players[i].ProfileID); - _Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID); + _UpdateSelectedProfile(_SelectingSwitchNr, CGame.Players[i].ProfileID); } else if (_SelectingSwitchNr > -1) { - //Update Game-infos with new player - CGame.Players[_SelectingSwitchNr].ProfileID = -1; - //Update config for default players. - CConfig.Players[_SelectingSwitchNr] = string.Empty; - //Update texture and name - _Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = _OriginalPlayerAvatarTextures[_SelectingSwitchNr]; - _Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.GetPlayerName(-1, (_SelectingSwitchNr + 1)); + _ResetPlayerSelection(_SelectingSwitchNr); } if (CProfiles.NumProfiles <= _SelectedPlayerNr) @@ -447,14 +427,7 @@ namespace Vocaluxe.Screens //Selected player is dropped out of area if (_SelectingSwitchNr > -1) { - //Update Game-infos with new player - CGame.Players[_SelectingSwitchNr].ProfileID = -1; - //Update config for default players. - CConfig.Players[_SelectingSwitchNr] = string.Empty; - //Update texture and name - _Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = _OriginalPlayerAvatarTextures[_SelectingSwitchNr]; - _Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.GetPlayerName(-1, (_SelectingSwitchNr + 1)); - _NameSelections[_NameSelection].UpdateList(); + _ResetPlayerSelection(_SelectingSwitchNr); } } _SelectingSwitchNr = -1; @@ -527,17 +500,7 @@ namespace Vocaluxe.Screens { if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) { - CGame.Players[i].ProfileID = -1; - //Update config for default players. - CConfig.Players[i] = String.Empty; - CConfig.SaveConfig(); - //Update texture and name - _Statics[_StaticPlayerAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i]; - _Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(-1, i + 1); - //Update profile-warning - _CheckPlayers(); - //Update Tiles-List - _NameSelections[_NameSelection].UpdateList(); + _ResetPlayerSelection(i); exit = false; } } @@ -745,6 +708,21 @@ namespace Vocaluxe.Screens CConfig.SaveConfig(); } + private void _ResetPlayerSelection(int playerNum) + { + CGame.Players[playerNum].ProfileID = -1; + //Update config for default players. + CConfig.Players[playerNum] = String.Empty; + CConfig.SaveConfig(); + //Update texture and name + _Statics[_StaticPlayerAvatar[playerNum]].Texture = _OriginalPlayerAvatarTextures[playerNum]; + _Texts[_TextPlayer[playerNum]].Text = CProfiles.GetPlayerName(-1, playerNum + 1); + //Update profile-warning + _CheckPlayers(); + //Update Tiles-List + _NameSelections[_NameSelection].UpdateList(); + } + private void _CheckMics() { List playerWithoutMicro = new List();