Reduce some redundant code, bugfix, refs #26

This commit is contained in:
Florian Küpper committed 2013-06-27 15:50:31 +02:00
1 parent 698449e289
commit 748f776a42
1 file changed
+20 -42
+20 -42
View File
@@ -231,15 +231,7 @@ namespace Vocaluxe.Screens
case Keys.Delete: case Keys.Delete:
//Delete profile-selection //Delete profile-selection
CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = -1; _ResetPlayerSelection(_SelectingFastPlayerNr - 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();
//Reset all values //Reset all values
_SelectingFastPlayerNr = 0; _SelectingFastPlayerNr = 0;
_SelectingKeyboardActive = false; _SelectingKeyboardActive = false;
@@ -419,23 +411,11 @@ namespace Vocaluxe.Screens
{ {
if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID > -1) if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID > -1)
{ {
//Update Game-infos with new player _UpdateSelectedProfile(_SelectingSwitchNr, CGame.Players[i].ProfileID);
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);
} }
else if (_SelectingSwitchNr > -1) else if (_SelectingSwitchNr > -1)
{ {
//Update Game-infos with new player _ResetPlayerSelection(_SelectingSwitchNr);
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));
} }
if (CProfiles.NumProfiles <= _SelectedPlayerNr) if (CProfiles.NumProfiles <= _SelectedPlayerNr)
@@ -447,14 +427,7 @@ namespace Vocaluxe.Screens
//Selected player is dropped out of area //Selected player is dropped out of area
if (_SelectingSwitchNr > -1) if (_SelectingSwitchNr > -1)
{ {
//Update Game-infos with new player _ResetPlayerSelection(_SelectingSwitchNr);
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();
} }
} }
_SelectingSwitchNr = -1; _SelectingSwitchNr = -1;
@@ -527,17 +500,7 @@ namespace Vocaluxe.Screens
{ {
if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent))
{ {
CGame.Players[i].ProfileID = -1; _ResetPlayerSelection(i);
//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();
exit = false; exit = false;
} }
} }
@@ -745,6 +708,21 @@ namespace Vocaluxe.Screens
CConfig.SaveConfig(); 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() private void _CheckMics()
{ {
List<int> playerWithoutMicro = new List<int>(); List<int> playerWithoutMicro = new List<int>();