Fix profile-id-check.

This commit is contained in:
flokuep committed 2013-06-27 16:38:14 +02:00
1 parent b444438862
commit e093610eaf
2 files changed
+32 -31

No files matched your search

+22 -21
View File
@@ -62,7 +62,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 _SelectedPlayerNr = -1; private int _SelectedProfileID = -1;
private bool _AvatarsChanged; private bool _AvatarsChanged;
private bool _ProfilesChanged; private bool _ProfilesChanged;
@@ -177,11 +177,12 @@ namespace Vocaluxe.Screens
//Check, if a player is selected //Check, if a player is selected
if (_NameSelections[_NameSelection].Selection > -1) if (_NameSelections[_NameSelection].Selection > -1)
{ {
_SelectedPlayerNr = _NameSelections[_NameSelection].Selection; _SelectedProfileID = _NameSelections[_NameSelection].Selection;
if (CProfiles.NumProfiles <= _SelectedPlayerNr)
if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
_UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedPlayerNr); _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedProfileID);
_SetInteractionToButton(_Buttons[_ButtonStart]); _SetInteractionToButton(_Buttons[_ButtonStart]);
} }
@@ -346,7 +347,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 && _SelectedPlayerNr < 0 && !_SelectingFast) if (mouseEvent.LBH && _SelectedProfileID < 0 && !_SelectingFast)
{ {
//Save mouse-coords //Save mouse-coords
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
@@ -355,8 +356,8 @@ namespace Vocaluxe.Screens
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{ {
//Get player-number of tile //Get player-number of tile
_SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
if (_SelectedPlayerNr != -1) if (_SelectedProfileID != -1)
{ {
//Update of Drag/Drop-Texture //Update of Drag/Drop-Texture
CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent); CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
@@ -374,7 +375,7 @@ namespace Vocaluxe.Screens
if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent))
{ {
_SelectingSwitchNr = i; _SelectingSwitchNr = i;
_SelectedPlayerNr = CGame.Players[i].ProfileID; _SelectedProfileID = CGame.Players[i].ProfileID;
//Update of Drag/Drop-Texture //Update of Drag/Drop-Texture
CStatic selectedPlayer = _Statics[_StaticPlayerAvatar[i]]; CStatic selectedPlayer = _Statics[_StaticPlayerAvatar[i]];
_ChooseAvatarStatic.Visible = true; _ChooseAvatarStatic.Visible = true;
@@ -389,7 +390,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 && _SelectedPlayerNr >= 0 && !_SelectingFast) if (mouseEvent.LBH && _SelectedProfileID >= 0 && !_SelectingFast)
{ {
//Update coords for Drag/Drop-Texture //Update coords for Drag/Drop-Texture
_ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX; _ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX;
@@ -398,7 +399,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 (_SelectedPlayerNr >= 0 && !_SelectingFast) else if (_SelectedProfileID >= 0 && !_SelectingFast)
{ {
//Foreach Drop-Area //Foreach Drop-Area
for (int i = 0; i < _StaticPlayer.Length; i++) for (int i = 0; i < _StaticPlayer.Length; i++)
@@ -418,10 +419,10 @@ namespace Vocaluxe.Screens
_ResetPlayerSelection(_SelectingSwitchNr); _ResetPlayerSelection(_SelectingSwitchNr);
} }
if (CProfiles.NumProfiles <= _SelectedPlayerNr) if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
_UpdateSelectedProfile(i, _SelectedPlayerNr); _UpdateSelectedProfile(i, _SelectedProfileID);
break; break;
} }
//Selected player is dropped out of area //Selected player is dropped out of area
@@ -431,7 +432,7 @@ namespace Vocaluxe.Screens
} }
} }
_SelectingSwitchNr = -1; _SelectingSwitchNr = -1;
_SelectedPlayerNr = -1; _SelectedProfileID = -1;
//Reset variables //Reset variables
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
} }
@@ -441,13 +442,13 @@ namespace Vocaluxe.Screens
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{ {
//Get player-number of tile //Get player-number of tile
_SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
if (_SelectedPlayerNr != -1) if (_SelectedProfileID != -1)
{ {
if (CProfiles.NumProfiles <= _SelectedPlayerNr) if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
_UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedPlayerNr); _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedProfileID);
_SelectingFastPlayerNr++; _SelectingFastPlayerNr++;
if (_SelectingFastPlayerNr <= CGame.NumPlayer) if (_SelectingFastPlayerNr <= CGame.NumPlayer)
@@ -473,17 +474,17 @@ namespace Vocaluxe.Screens
if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast) if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast)
{ {
_SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
if (_SelectedPlayerNr > -1) if (_SelectedProfileID > -1)
{ {
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
{ {
if (CGame.Players[i].ProfileID == -1) if (CGame.Players[i].ProfileID == -1)
{ {
if (CProfiles.NumProfiles <= _SelectedPlayerNr) if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
_UpdateSelectedProfile(i, _SelectedPlayerNr); _UpdateSelectedProfile(i, _SelectedProfileID);
break; break;
} }
} }
+10 -10
View File
@@ -44,15 +44,15 @@ namespace VocaluxeLib.Menu
{ {
private class CTile private class CTile
{ {
public int PlayerNr; public int ProfileID;
public readonly CStatic Avatar; public readonly CStatic Avatar;
public readonly CText Name; public readonly CText Name;
public CTile(CStatic av, CText tex, int pl) public CTile(CStatic av, CText tex, int pID)
{ {
Avatar = av; Avatar = av;
Name = tex; Name = tex;
PlayerNr = pl; ProfileID = pID;
} }
} }
@@ -281,7 +281,7 @@ namespace VocaluxeLib.Menu
case Keys.Right: case Keys.Right:
if (_ActualSelection + 1 < _Tiles.Count) if (_ActualSelection + 1 < _Tiles.Count)
{ {
if (_Tiles[_ActualSelection + 1].PlayerNr != -1) if (_Tiles[_ActualSelection + 1].ProfileID != -1)
_ActualSelection++; _ActualSelection++;
} }
else else
@@ -316,7 +316,7 @@ namespace VocaluxeLib.Menu
case Keys.Down: case Keys.Down:
if (_ActualSelection + _NumW < _Tiles.Count) if (_ActualSelection + _NumW < _Tiles.Count)
{ {
if (_Tiles[_ActualSelection + _NumW].PlayerNr != -1) if (_Tiles[_ActualSelection + _NumW].ProfileID != -1)
_ActualSelection += _NumW; _ActualSelection += _NumW;
} }
else else
@@ -326,11 +326,11 @@ namespace VocaluxeLib.Menu
if (offset != Offset) if (offset != Offset)
{ {
_ActualSelection = _ActualSelection - _Tiles.Count + _NumW; _ActualSelection = _ActualSelection - _Tiles.Count + _NumW;
if (_Tiles[_ActualSelection].PlayerNr == -1) if (_Tiles[_ActualSelection].ProfileID == -1)
{ {
for (int i = _Tiles.Count - 1; i >= 0; i--) for (int i = _Tiles.Count - 1; i >= 0; i--)
{ {
if (_Tiles[i].PlayerNr != -1) if (_Tiles[i].ProfileID != -1)
{ {
_ActualSelection = i; _ActualSelection = i;
break; break;
@@ -412,14 +412,14 @@ namespace VocaluxeLib.Menu
_Tiles[i].Avatar.Texture = CBase.Profiles.GetProfiles()[_VisibleProfiles[i + offset * _Tiles.Count]].Avatar.Texture; _Tiles[i].Avatar.Texture = CBase.Profiles.GetProfiles()[_VisibleProfiles[i + offset * _Tiles.Count]].Avatar.Texture;
_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.GetProfiles()[_VisibleProfiles[i + offset * _Tiles.Count]].PlayerName; _Tiles[i].Name.Text = CBase.Profiles.GetProfiles()[_VisibleProfiles[i + offset * _Tiles.Count]].PlayerName;
_Tiles[i].PlayerNr = _VisibleProfiles[i + offset * _Tiles.Count]; _Tiles[i].ProfileID = _VisibleProfiles[i + offset * _Tiles.Count];
} }
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].PlayerNr = -1; _Tiles[i].ProfileID = -1;
} }
} }
Offset = offset; Offset = offset;
@@ -441,7 +441,7 @@ namespace VocaluxeLib.Menu
foreach (CTile tile in _Tiles) foreach (CTile tile in _Tiles)
{ {
if (CHelper.IsInBounds(tile.Avatar.Rect, mevent)) if (CHelper.IsInBounds(tile.Avatar.Rect, mevent))
return tile.PlayerNr; return tile.ProfileID;
} }
return -1; return -1;