Example #1
0
        public override bool HandleInput(SKeyEvent keyEvent)
        {
            base.HandleInput(keyEvent);

            if (!keyEvent.KeyPressed)
            {
                switch (keyEvent.Key)
                {
                case Keys.Escape:
                case Keys.Back:
                    _SaveConfig();
                    CGraphics.FadeTo(EScreen.Options);
                    break;

                case Keys.S:
                    CParty.SetNormalGameMode();
                    _SaveConfig();
                    CGraphics.FadeTo(EScreen.Song);
                    break;

                case Keys.Enter:
                    if (_Buttons[_ButtonExit].Selected)
                    {
                        _SaveConfig();
                        CGraphics.FadeTo(EScreen.Options);
                    }
                    else if (_Buttons[_ButtonServer].Selected)
                    {
                        CGraphics.ShowPopup(EPopupScreens.PopupServerQR);
                    }
                    break;

                case Keys.Left:
                    _SaveConfig();
                    break;

                case Keys.Right:
                    _SaveConfig();
                    break;
                }
            }
            return(true);
        }
Example #2
0
        public override bool HandleMouse(SMouseEvent mouseEvent)
        {
            base.HandleMouse(mouseEvent);

            if (mouseEvent.RB)
            {
                _SaveConfig();
                CGraphics.FadeTo(EScreen.Options);
            }

            if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent))
            {
                if (_Buttons[_ButtonExit].Selected)
                {
                    CGraphics.FadeTo(EScreen.Options);
                    _SaveConfig();
                }
                else if (_Buttons[_ButtonServer].Selected)
                {
                    CGraphics.ShowPopup(EPopupScreens.PopupServerQR);
                }
            }
            return(true);
        }
Example #3
0
        public override bool HandleMouse(SMouseEvent mouseEvent)
        {
            bool stopSelectingFast = false;

            if (_SelectingFast)
            {
                _NameSelections[_NameSelection].HandleMouse(mouseEvent);
            }
            else
            {
                base.HandleMouse(mouseEvent);
            }

            //Check if LeftButton is hold and Select-Mode inactive
            if (mouseEvent.LBH && _SelectedProfileID == Guid.Empty && !_SelectingFast)
            {
                //Save mouse-coords
                _OldMouseX = mouseEvent.X;
                _OldMouseY = mouseEvent.Y;
                //Check if mouse if over tile
                if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
                {
                    //Get player-number of tile
                    _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
                    if (_SelectedProfileID != Guid.Empty)
                    {
                        //Update of Drag/Drop-Texture
                        CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
                        _ChooseAvatarStatic.Visible = true;
                        _ChooseAvatarStatic.MaxRect = selectedPlayer.Rect;
                        _ChooseAvatarStatic.Z       = CSettings.ZNear;
                        _ChooseAvatarStatic.Color   = new SColorF(1, 1, 1, 1);
                        _ChooseAvatarStatic.Texture = selectedPlayer.Texture;
                    }
                }
                else
                {
                    for (int i = 0; i < CGame.NumPlayers; i++)
                    {
                        if (CHelper.IsInBounds(_Statics[_PlayerStatic[i]].Rect, mouseEvent))
                        {
                            _SelectingSwitchNr = i;
                            _SelectedProfileID = CGame.Players[i].ProfileID;
                            //Update of Drag/Drop-Texture
                            CStatic selectedPlayer = _Statics[_PlayerStaticAvatar[i]];
                            _ChooseAvatarStatic.Visible = true;
                            _ChooseAvatarStatic.MaxRect = selectedPlayer.Rect;
                            _ChooseAvatarStatic.Z       = CSettings.ZNear;
                            _ChooseAvatarStatic.Color   = new SColorF(1, 1, 1, 1);
                            _ChooseAvatarStatic.Texture = selectedPlayer.Texture;
                            break;
                        }
                    }
                }
            }

            //Check if LeftButton is hold and Select-Mode active
            if (mouseEvent.LBH && _SelectedProfileID != Guid.Empty && !_SelectingFast)
            {
                //Update coords for Drag/Drop-Texture
                _ChooseAvatarStatic.X += mouseEvent.X - _OldMouseX;
                _ChooseAvatarStatic.Y += mouseEvent.Y - _OldMouseY;
                _OldMouseX             = mouseEvent.X;
                _OldMouseY             = mouseEvent.Y;
            }
            // LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar
            else if (_SelectedProfileID != Guid.Empty && !_SelectingFast)
            {
                //Foreach Drop-Area
                for (int i = 0; i < _PlayerStatic.Length; i++)
                {
                    //Check first, if area is "Active"
                    if (!_Statics[_PlayerStatic[i]].Visible)
                    {
                        continue;
                    }
                    //Check if Mouse is in area
                    if (CHelper.IsInBounds(_Statics[_PlayerStatic[i]].Rect, mouseEvent))
                    {
                        if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID != Guid.Empty)
                        {
                            _UpdateSelectedProfile(_SelectingSwitchNr, CGame.Players[i].ProfileID);
                        }
                        else if (_SelectingSwitchNr > -1)
                        {
                            _ResetPlayerSelection(_SelectingSwitchNr);
                        }

                        if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
                        {
                            return(true);
                        }

                        _UpdateSelectedProfile(i, _SelectedProfileID);
                        break;
                    }
                    //Selected player is dropped out of area
                    if (_SelectingSwitchNr > -1)
                    {
                        _ResetPlayerSelection(_SelectingSwitchNr);
                    }
                }
                _SelectingSwitchNr = -1;
                _SelectedProfileID = Guid.Empty;
                //Reset variables
                _ChooseAvatarStatic.Visible = false;
            }

            if (mouseEvent.LB && _SelectingFast)
            {
                if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
                {
                    //Get player-number of tile
                    _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
                    if (_SelectedProfileID != Guid.Empty)
                    {
                        if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
                        {
                            return(true);
                        }

                        _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedProfileID);

                        _SelectingFastPlayerNr++;
                        if (_SelectingFastPlayerNr <= CGame.NumPlayers)
                        {
                            _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
                        }
                        else
                        {
                            stopSelectingFast = true;
                        }
                    }
                    else
                    {
                        stopSelectingFast = true;
                    }
                }
            }
            else if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent))
            {
                if (_Buttons[_ButtonBack].Selected)
                {
                    CGraphics.FadeTo(EScreen.Song);
                }
                else if (_Buttons[_ButtonStart].Selected)
                {
                    _StartSong();
                }
                else if (_Buttons[_ButtonNewProfile].Selected)
                {
                    CGraphics.ShowPopup(EPopupScreens.PopupNewPlayer);
                }
                else if (_Buttons["ButtonScrollUp"].Selected)
                {
                    _NameSelections[_NameSelection].UpdateList(_NameSelections[_NameSelection].Offset - 1);
                }
                else if (_Buttons["ButtonScrollDown"].Selected)
                {
                    _NameSelections[_NameSelection].UpdateList(_NameSelections[_NameSelection].Offset + 1);
                }
                else
                {
                    _UpdatePlayerNumber();
                }
                //Update Tiles-List
                _NameSelections[_NameSelection].UpdateList();
            }

            if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast)
            {
                _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
                if (_SelectedProfileID != Guid.Empty)
                {
                    for (int i = 0; i < CGame.NumPlayers; i++)
                    {
                        if (CGame.Players[i].ProfileID == Guid.Empty)
                        {
                            if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
                            {
                                return(true);
                            }

                            _UpdateSelectedProfile(i, _SelectedProfileID);
                            break;
                        }
                    }
                }
            }

            if (mouseEvent.RB && _SelectingFast)
            {
                stopSelectingFast = true;
            }
            else if (mouseEvent.RB)
            {
                bool exit = true;
                //Remove profile-selection
                for (int i = 0; i < CConfig.Config.Game.NumPlayers; i++)
                {
                    if (CHelper.IsInBounds(_Statics[_PlayerStatic[i]].Rect, mouseEvent))
                    {
                        _ResetPlayerSelection(i);
                        exit = false;
                    }
                }
                if (exit)
                {
                    CGraphics.FadeTo(EScreen.Song);
                }
            }

            if (mouseEvent.MB && _SelectingFast)
            {
                _SelectingFastPlayerNr++;
                if (_SelectingFastPlayerNr <= CGame.NumPlayers)
                {
                    _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
                }
                else
                {
                    stopSelectingFast = true;
                }
            }
            else if (mouseEvent.MB)
            {
                _ResetPlayerSelections();
                _SelectingFast           = true;
                _SelectingFastPlayerNr   = 1;
                _SelectingKeyboardActive = true;
                _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
            }

            //Check mouse-wheel for scrolling
            if (mouseEvent.Wheel != 0)
            {
                if (CHelper.IsInBounds(_NameSelections[_NameSelection].Rect, mouseEvent))
                {
                    int offset = _NameSelections[_NameSelection].Offset + mouseEvent.Wheel;
                    _NameSelections[_NameSelection].UpdateList(offset);
                }
            }

            if (stopSelectingFast)
            {
                _SelectingFast           = false;
                _SelectingFastPlayerNr   = 0;
                _SelectingKeyboardActive = false;
                _NameSelections[_NameSelection].FastSelection(false, -1);
            }
            return(true);
        }
Example #4
0
        public override bool HandleInput(SKeyEvent keyEvent)
        {
            switch (keyEvent.Key)
            {
            case Keys.Add:
                if (CConfig.Config.Game.NumPlayers + 1 <= CSettings.MaxNumPlayer)
                {
                    _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.Config.Game.NumPlayers;
                    _UpdatePlayerNumber();
                    //Update Tiles-List
                    _NameSelections[_NameSelection].UpdateList();
                }
                break;

            case Keys.Subtract:
                if (CConfig.Config.Game.NumPlayers - 1 > 0)
                {
                    _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.Config.Game.NumPlayers - 2;
                    _UpdatePlayerNumber();
                    //Update Tiles-List
                    _NameSelections[_NameSelection].UpdateList();
                }
                break;

            case Keys.P:
                if (!_SelectingKeyboardActive)
                {
                    _SelectingFastPlayerNr = 1;
                    _SelectingFast         = true;
                    _ResetPlayerSelections();
                }
                else
                {
                    if (_SelectingFastPlayerNr + 1 <= CGame.NumPlayers)
                    {
                        _SelectingFastPlayerNr++;
                    }
                    else
                    {
                        _SelectingFastPlayerNr = 1;
                    }
                    _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
                }
                break;

            case Keys.N:
                CGraphics.ShowPopup(EPopupScreens.PopupNewPlayer);
                break;
            }
            //Check if selecting with keyboard is active
            if (_SelectingKeyboardActive)
            {
                //Handle left/right/up/down
                _NameSelections[_NameSelection].HandleInput(keyEvent);
                int  numberPressed  = -1;
                bool resetSelection = false;
                switch (keyEvent.Key)
                {
                case Keys.Enter:
                    //Check, if a player is selected
                    if (_NameSelections[_NameSelection].SelectedID != Guid.Empty)
                    {
                        _SelectedProfileID = _NameSelections[_NameSelection].SelectedID;

                        if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
                        {
                            return(true);
                        }

                        _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedProfileID);
                    }
                    //Started selecting with 'P'
                    if (_SelectingFast)
                    {
                        if (_SelectingFastPlayerNr == CGame.NumPlayers)
                        {
                            resetSelection = true;
                            _SelectElement(_Buttons[_ButtonStart]);
                        }
                        else
                        {
                            _SelectingFastPlayerNr++;
                            _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
                        }
                    }
                    else
                    {
                        resetSelection = true;
                    }
                    break;

                case Keys.D1:
                case Keys.NumPad1:
                    numberPressed = 1;
                    break;

                case Keys.D2:
                case Keys.NumPad2:
                    numberPressed = 2;
                    break;

                case Keys.D3:
                case Keys.NumPad3:
                    numberPressed = 3;
                    break;

                case Keys.D4:
                case Keys.NumPad4:
                    numberPressed = 4;
                    break;

                case Keys.D5:
                case Keys.NumPad5:
                    numberPressed = 5;
                    break;

                case Keys.D6:
                case Keys.NumPad6:
                    numberPressed = 6;
                    break;

                case Keys.Escape:
                    resetSelection = true;
                    _SelectElement(_SelectSlides[_SelectSlidePlayerNumber]);
                    break;

                case Keys.Delete:
                    //Delete profile-selection
                    _ResetPlayerSelection(_SelectingFastPlayerNr - 1);
                    //Reset all values
                    _SelectingFastPlayerNr   = 0;
                    _SelectingKeyboardActive = false;
                    _NameSelections[_NameSelection].FastSelection(false, -1);
                    //Update Tiles-List
                    _NameSelections[_NameSelection].UpdateList();
                    break;

                case Keys.F10:
                    if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet)
                    {
                        CSelectSlide selectSlideDuetPart = _SelectSlides[_PlayerSelectSlideDuet[_SelectingFastPlayerNr - 1]];
                        selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2;
                        //Reset all values
                        _SelectingFastPlayerNr   = 0;
                        _SelectingKeyboardActive = false;
                        _SelectingFast           = false;
                        _NameSelections[_NameSelection].FastSelection(false, -1);
                        _SelectElement(_Buttons[_ButtonStart]);
                    }
                    break;
                }
                if (numberPressed > 0 || resetSelection)
                {
                    if (numberPressed == _SelectingFastPlayerNr || resetSelection)
                    {
                        //Reset all values
                        _SelectingFastPlayerNr   = 0;
                        _SelectingKeyboardActive = false;
                        _SelectElement(_SelectSlides[_SelectSlidePlayerNumber]);
                        _NameSelections[_NameSelection].FastSelection(false, -1);
                    }
                    else if (numberPressed <= CConfig.Config.Game.NumPlayers)
                    {
                        _SelectingFastPlayerNr = numberPressed;
                        _NameSelections[_NameSelection].FastSelection(true, numberPressed);
                    }
                    _SelectingFast = false;
                    if (_PreviousPlayerSelection > -1)
                    {
                        _SelectElement(_Buttons[_PlayerButton[_PreviousPlayerSelection]]);
                        _PreviousPlayerSelection = -1;
                    }
                }
            }
            //Normal Keyboard handling
            else
            {
                base.HandleInput(keyEvent);
                switch (keyEvent.Key)
                {
                case Keys.Escape:
                case Keys.Back:
                    CGraphics.FadeTo(EScreen.Song);
                    break;

                case Keys.Enter:

                    if (_Buttons[_ButtonBack].Selected)
                    {
                        CGraphics.FadeTo(EScreen.Song);
                    }
                    else if (_Buttons[_ButtonStart].Selected)
                    {
                        _StartSong();
                    }
                    else if (_Buttons[_ButtonNewProfile].Selected)
                    {
                        CGraphics.ShowPopup(EPopupScreens.PopupNewPlayer);
                    }
                    for (int p = 0; p < CGame.NumPlayers; p++)
                    {
                        if (_Buttons[_PlayerButton[p]].Selected)
                        {
                            _PreviousPlayerSelection = p;
                            _SelectingFastPlayerNr   = p + 1;
                        }
                    }
                    break;

                case Keys.D1:
                case Keys.NumPad1:
                    _SelectingFastPlayerNr = 1;
                    break;

                case Keys.D2:
                case Keys.NumPad2:
                    _SelectingFastPlayerNr = 2;
                    break;

                case Keys.D3:
                case Keys.NumPad3:
                    _SelectingFastPlayerNr = 3;
                    break;

                case Keys.D4:
                case Keys.NumPad4:
                    _SelectingFastPlayerNr = 4;
                    break;

                case Keys.D5:
                case Keys.NumPad5:
                    _SelectingFastPlayerNr = 5;
                    break;

                case Keys.D6:
                case Keys.NumPad6:
                    _SelectingFastPlayerNr = 6;
                    break;

                default:
                    _UpdatePlayerNumber();
                    break;
                }

                if (_SelectingFastPlayerNr > 0 && _SelectingFastPlayerNr <= CConfig.Config.Game.NumPlayers)
                {
                    _SelectingKeyboardActive = true;
                    _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
                }
                if (_NameSelections[_NameSelection].Selected && !_SelectingKeyboardActive)
                {
                    _SelectingKeyboardActive = true;
                    _SelectingFast           = true;
                    _SelectingFastPlayerNr   = 1;
                    _SelectingKeyboardActive = true;
                    _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
                }
            }

            return(true);
        }