Update for fast-player-selection. Press MB or P to start, use mouse or arrow-keys to choose player, select player with LB or Enter. Use [1..6] or MB to skip a player, RB or escape to abort.

I will think about a easy reset-function...
This commit is contained in:
Florian Küpper committed 2013-04-27 12:28:22 +02:00
1 parent 5e9eabbc9c
commit 98ad7a6be0
2 files changed
+125 -48

No files matched your search

+108 -47
View File
@@ -56,8 +56,8 @@ namespace Vocaluxe.Screens
private readonly STexture[] _OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer]; private readonly STexture[] _OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer];
private bool _SelectingKeyboardActive; private bool _SelectingKeyboardActive;
private bool _SelectingKeyboardUnendless; private bool _SelectingFast;
private int _SelectingKeyboardPlayerNr; private int _SelectingFastPlayerNr;
private int _SelectedPlayerNr; private int _SelectedPlayerNr;
public override void Init() public override void Init()
@@ -137,16 +137,16 @@ namespace Vocaluxe.Screens
case Keys.P: case Keys.P:
if (!_SelectingKeyboardActive) if (!_SelectingKeyboardActive)
{ {
_SelectingKeyboardPlayerNr = 1; _SelectingFastPlayerNr = 1;
_SelectingKeyboardUnendless = true; _SelectingFast = true;
} }
else else
{ {
if (_SelectingKeyboardPlayerNr + 1 <= CGame.NumPlayer) if (_SelectingFastPlayerNr + 1 <= CGame.NumPlayer)
_SelectingKeyboardPlayerNr++; _SelectingFastPlayerNr++;
else else
_SelectingKeyboardPlayerNr = 1; _SelectingFastPlayerNr = 1;
_NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr); _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
} }
break; break;
} }
@@ -165,13 +165,13 @@ namespace Vocaluxe.Screens
{ {
_SelectedPlayerNr = _NameSelections[_NameSelection].Selection; _SelectedPlayerNr = _NameSelections[_NameSelection].Selection;
//Update Game-infos with new player //Update Game-infos with new player
CGame.Players[_SelectingKeyboardPlayerNr - 1].ProfileID = _SelectedPlayerNr; CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = _SelectedPlayerNr;
//Update config for default players. //Update config for default players.
CConfig.Players[_SelectingKeyboardPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.SaveConfig(); CConfig.SaveConfig();
//Update texture and name //Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture; _Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture;
_Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; _Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning //Update profile-warning
_CheckPlayers(); _CheckPlayers();
//Update Tiles-List //Update Tiles-List
@@ -179,14 +179,14 @@ namespace Vocaluxe.Screens
_SetInteractionToButton(_Buttons[_ButtonStart]); _SetInteractionToButton(_Buttons[_ButtonStart]);
} }
//Started selecting with 'P' //Started selecting with 'P'
if (_SelectingKeyboardUnendless) if (_SelectingFast)
{ {
if (_SelectingKeyboardPlayerNr == CGame.NumPlayer) if (_SelectingFastPlayerNr == CGame.NumPlayer)
resetSelection = true; resetSelection = true;
else else
{ {
_SelectingKeyboardPlayerNr++; _SelectingFastPlayerNr++;
_NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr); _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
} }
} }
else else
@@ -224,19 +224,19 @@ namespace Vocaluxe.Screens
case Keys.Delete: case Keys.Delete:
//Delete profile-selection //Delete profile-selection
CGame.Players[_SelectingKeyboardPlayerNr - 1].ProfileID = -1; CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = -1;
//Update config for default players. //Update config for default players.
CConfig.Players[_SelectingKeyboardPlayerNr - 1] = String.Empty; CConfig.Players[_SelectingFastPlayerNr - 1] = String.Empty;
CConfig.SaveConfig(); CConfig.SaveConfig();
//Update texture and name //Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingKeyboardPlayerNr - 1]].Texture = _OriginalPlayerAvatarTextures[_SelectingKeyboardPlayerNr - 1]; _Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = _OriginalPlayerAvatarTextures[_SelectingFastPlayerNr - 1];
_Texts[_TextPlayer[_SelectingKeyboardPlayerNr - 1]].Text = CProfiles.GetPlayerName(-1, _SelectingKeyboardPlayerNr); _Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = CProfiles.GetPlayerName(-1, _SelectingFastPlayerNr);
//Update profile-warning //Update profile-warning
_CheckPlayers(); _CheckPlayers();
//Reset all values //Reset all values
_SelectingKeyboardPlayerNr = 0; _SelectingFastPlayerNr = 0;
_SelectingKeyboardActive = false; _SelectingKeyboardActive = false;
_NameSelections[_NameSelection].KeyboardSelection(false, -1); _NameSelections[_NameSelection].FastSelection(false, -1);
//Update Tiles-List //Update Tiles-List
_NameSelections[_NameSelection].UpdateList(); _NameSelections[_NameSelection].UpdateList();
break; break;
@@ -244,32 +244,32 @@ namespace Vocaluxe.Screens
case Keys.F10: case Keys.F10:
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
{ {
CSelectSlide selectSlideDuetPart = _SelectSlides[_SelectSlideDuetPlayer[_SelectingKeyboardPlayerNr - 1]]; CSelectSlide selectSlideDuetPart = _SelectSlides[_SelectSlideDuetPlayer[_SelectingFastPlayerNr - 1]];
selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2; selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2;
//Reset all values //Reset all values
_SelectingKeyboardPlayerNr = 0; _SelectingFastPlayerNr = 0;
_SelectingKeyboardActive = false; _SelectingKeyboardActive = false;
_SelectingKeyboardUnendless = false; _SelectingFast = false;
_NameSelections[_NameSelection].KeyboardSelection(false, -1); _NameSelections[_NameSelection].FastSelection(false, -1);
_SetInteractionToButton(_Buttons[_ButtonStart]); _SetInteractionToButton(_Buttons[_ButtonStart]);
} }
break; break;
} }
if (numberPressed > 0 || resetSelection) if (numberPressed > 0 || resetSelection)
{ {
if (numberPressed == _SelectingKeyboardPlayerNr || resetSelection) if (numberPressed == _SelectingFastPlayerNr || resetSelection)
{ {
//Reset all values //Reset all values
_SelectingKeyboardPlayerNr = 0; _SelectingFastPlayerNr = 0;
_SelectingKeyboardActive = false; _SelectingKeyboardActive = false;
_NameSelections[_NameSelection].KeyboardSelection(false, -1); _NameSelections[_NameSelection].FastSelection(false, -1);
} }
else if (numberPressed <= CConfig.NumPlayer) else if (numberPressed <= CConfig.NumPlayer)
{ {
_SelectingKeyboardPlayerNr = numberPressed; _SelectingFastPlayerNr = numberPressed;
_NameSelections[_NameSelection].KeyboardSelection(true, numberPressed); _NameSelections[_NameSelection].FastSelection(true, numberPressed);
} }
_SelectingKeyboardUnendless = false; _SelectingFast = false;
} }
} }
//Normal Keyboard handling //Normal Keyboard handling
@@ -294,32 +294,32 @@ namespace Vocaluxe.Screens
case Keys.D1: case Keys.D1:
case Keys.NumPad1: case Keys.NumPad1:
_SelectingKeyboardPlayerNr = 1; _SelectingFastPlayerNr = 1;
break; break;
case Keys.D2: case Keys.D2:
case Keys.NumPad2: case Keys.NumPad2:
_SelectingKeyboardPlayerNr = 2; _SelectingFastPlayerNr = 2;
break; break;
case Keys.D3: case Keys.D3:
case Keys.NumPad3: case Keys.NumPad3:
_SelectingKeyboardPlayerNr = 3; _SelectingFastPlayerNr = 3;
break; break;
case Keys.D4: case Keys.D4:
case Keys.NumPad4: case Keys.NumPad4:
_SelectingKeyboardPlayerNr = 4; _SelectingFastPlayerNr = 4;
break; break;
case Keys.D5: case Keys.D5:
case Keys.NumPad5: case Keys.NumPad5:
_SelectingKeyboardPlayerNr = 5; _SelectingFastPlayerNr = 5;
break; break;
case Keys.D6: case Keys.D6:
case Keys.NumPad6: case Keys.NumPad6:
_SelectingKeyboardPlayerNr = 6; _SelectingFastPlayerNr = 6;
break; break;
default: default:
_UpdatePlayerNumber(); _UpdatePlayerNumber();
@@ -327,10 +327,10 @@ namespace Vocaluxe.Screens
} }
if (_SelectingKeyboardPlayerNr > 0 && _SelectingKeyboardPlayerNr <= CConfig.NumPlayer) if (_SelectingFastPlayerNr > 0 && _SelectingFastPlayerNr <= CConfig.NumPlayer)
{ {
_SelectingKeyboardActive = true; _SelectingKeyboardActive = true;
_NameSelections[_NameSelection].KeyboardSelection(true, _SelectingKeyboardPlayerNr); _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
} }
} }
@@ -339,10 +339,15 @@ namespace Vocaluxe.Screens
public override bool HandleMouse(SMouseEvent mouseEvent) public override bool HandleMouse(SMouseEvent mouseEvent)
{ {
base.HandleMouse(mouseEvent); bool stopSelectingFast = false;
if (_SelectingFast)
_NameSelections[_NameSelection].HandleMouse(mouseEvent);
else
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) if (mouseEvent.LBH && _SelectedPlayerNr < 0 && !_SelectingFast)
{ {
//Save mouse-coords //Save mouse-coords
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
@@ -366,7 +371,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) if (mouseEvent.LBH && _SelectedPlayerNr >= 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;
@@ -374,8 +379,8 @@ namespace Vocaluxe.Screens
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y; _OldMouseY = mouseEvent.Y;
} }
// LeftButton isn't hold anymore, but Selec-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) else if (_SelectedPlayerNr >= 0 && !_SelectingFast)
{ {
//Foreach Drop-Area //Foreach Drop-Area
for (int i = 0; i < _StaticPlayer.Length; i++) for (int i = 0; i < _StaticPlayer.Length; i++)
@@ -405,7 +410,37 @@ namespace Vocaluxe.Screens
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
} }
if (mouseEvent.LB && _IsMouseOver(mouseEvent)) if (mouseEvent.LB && _SelectingFast)
{
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{
//Get player-number of tile
_SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
if (_SelectedPlayerNr != -1)
{
//Update Game-infos with new player
CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = _SelectedPlayerNr;
//Update config for default players.
CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture;
_Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
_NameSelections[_NameSelection].UpdateList();
_SelectingFastPlayerNr++;
if (_SelectingFastPlayerNr <= CGame.NumPlayer)
_NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
else
stopSelectingFast = true;
}
else
stopSelectingFast = true;
}
}
else if (mouseEvent.LB && _IsMouseOver(mouseEvent))
{ {
if (_Buttons[_ButtonBack].Selected) if (_Buttons[_ButtonBack].Selected)
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
@@ -417,7 +452,9 @@ namespace Vocaluxe.Screens
_NameSelections[_NameSelection].UpdateList(); _NameSelections[_NameSelection].UpdateList();
} }
if (mouseEvent.RB) if (mouseEvent.RB && _SelectingFast)
stopSelectingFast = true;
else if (mouseEvent.RB)
{ {
bool exit = true; bool exit = true;
//Remove profile-selection //Remove profile-selection
@@ -443,6 +480,22 @@ namespace Vocaluxe.Screens
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
} }
if (mouseEvent.MB && _SelectingFast)
{
_SelectingFastPlayerNr++;
if (_SelectingFastPlayerNr <= CGame.NumPlayer)
_NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
else
stopSelectingFast = true;
}
else if(mouseEvent.MB)
{
_SelectingFast = true;
_SelectingFastPlayerNr = 1;
_SelectingKeyboardActive = true;
_NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
}
//Check mouse-wheel for scrolling //Check mouse-wheel for scrolling
if (mouseEvent.Wheel != 0) if (mouseEvent.Wheel != 0)
{ {
@@ -452,6 +505,14 @@ namespace Vocaluxe.Screens
_NameSelections[_NameSelection].UpdateList(offset); _NameSelections[_NameSelection].UpdateList(offset);
} }
} }
if (stopSelectingFast)
{
_SelectingFast = false;
_SelectingFastPlayerNr = 0;
_SelectingKeyboardActive = false;
_NameSelections[_NameSelection].FastSelection(false, -1);
}
return true; return true;
} }
+17 -1
View File
@@ -346,7 +346,23 @@ namespace VocaluxeLib.Menu
Selection = -1; Selection = -1;
} }
public void KeyboardSelection(bool active, int player) public void HandleMouse(SMouseEvent mevent)
{
for (int i = 0; i < _Tiles.Count; i++ )
{
if (CHelper.IsInBounds(_Tiles[i].Avatar.Rect, mevent))
{
_ActualSelection = i;
if (Offset * _Tiles.Count + _ActualSelection < _VisibleProfiles.Count)
Selection = _VisibleProfiles[Offset * _Tiles.Count + _ActualSelection];
else
Selection = -1;
}
}
}
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 && Selection != -1)