Exemplo n.º 1
0
    private void CombatKeyHandler(MessageKeyStateChangeArgs args)
    {
        if (!args.down)
        {
            UiSystems.KeyManager.InputState = 0;
            if (UiSystems.KeyManager.HandleKeyEvent(args))
            {
                return; // TODO: This is new, previously it fell through here
            }

            // End turn for current player
            if (args.key == DIK.DIK_RETURN || args.key == DIK.DIK_SPACE)
            {
                var currentActor = GameSystems.D20.Initiative.CurrentActor;
                UiSystems.CharSheet.CurrentPage = 0;
                UiSystems.CharSheet.Hide(UiSystems.CharSheet.State);

                if (GameSystems.Party.IsInParty(currentActor))
                {
                    if (!GameSystems.D20.Actions.IsCurrentlyPerforming(currentActor))
                    {
                        if (!UiSystems.InGameSelect.IsPicking && !UiSystems.RadialMenu.IsOpen)
                        {
                            GameSystems.Combat.AdvanceTurn(currentActor);
                            Logger.Info("Advancing turn for {0}", currentActor);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    private void HandleNormalKeyStateChange(IGameViewport viewport, MessageKeyStateChangeArgs args)
    {
        if (args.down)
        {
            return;
        }

        var leader = GameSystems.Party.GetConsciousLeader();

        if (leader != null)
        {
            if (GameSystems.D20.Hotkeys.IsReservedHotkey(args.key))
            {
                if (Tig.Keyboard.IsKeyPressed(VirtualKey.VK_LCONTROL) ||
                    Tig.Keyboard.IsKeyPressed(VirtualKey.VK_RCONTROL))
                {
                    // trying to assign hotkey to reserved hotkey
                    GameSystems.D20.Hotkeys.HotkeyReservedPopup(args.key);
                    return;
                }
            }
            else if (GameSystems.D20.Hotkeys.IsNormalNonreservedHotkey(args.key))
            {
                if (Tig.Keyboard.IsKeyPressed(VirtualKey.VK_LCONTROL) ||
                    Tig.Keyboard.IsKeyPressed(VirtualKey.VK_RCONTROL))
                {
                    // assign hotkey
                    var leaderLoc = leader.GetLocationFull();
                    var screenPos = viewport.WorldToScreen(leaderLoc.ToInches3D());

                    UiSystems.RadialMenu.Spawn(viewport, (int)screenPos.X, (int)screenPos.Y);
                    UiSystems.RadialMenu.HandleKeyMessage(args);
                    return;
                }

                GameSystems.D20.Actions.TurnBasedStatusInit(leader);
                leader = GameSystems.Party.GetConsciousLeader(); // in case the leader changes somehow...
                Logger.Info("Intgame: Resetting sequence.");
                GameSystems.D20.Actions.CurSeqReset(leader);

                GameSystems.D20.Actions.GlobD20ActnInit();
                if (GameSystems.D20.Hotkeys.RadmenuHotkeySthg(GameSystems.Party.GetConsciousLeader(), args.key))
                {
                    GameSystems.D20.Actions.ActionAddToSeq();
                    GameSystems.D20.Actions.sequencePerform();
                    PlayVoiceConfirmationSound(leader);
                    GameSystems.D20.RadialMenu.ClearActiveRadialMenu();
                    return;
                }
            }
        }

        UiSystems.KeyManager.InputState = 0;
        UiSystems.KeyManager.HandleKeyEvent(args);
    }
Exemplo n.º 3
0
 public Message(MessageKeyStateChangeArgs keyArgs) : this(MessageType.KEYSTATECHANGE)
 {
     KeyStateChangeArgs = keyArgs;
 }
Exemplo n.º 4
0
    private bool HandleShortcut(MessageKeyStateChangeArgs arg)
    {
        if (arg.down)
        {
            // We handle these on key-down because we are interested in key-repeats
            switch (arg.key)
            {
            case DIK.DIK_LEFT:
            case DIK.DIK_NUMPAD4:
                if (--_caretPosition < 0)
                {
                    _caretPosition = 0;
                }

                UpdateInput(_currentInput);
                break;

            case DIK.DIK_RIGHT:
            case DIK.DIK_NUMPAD6:
                if (++_caretPosition > _currentInput.Length)
                {
                    _caretPosition = _currentInput.Length;
                }
                UpdateInput(_currentInput);
                break;

            case DIK.DIK_HOME:
                _caretPosition = 0;
                UpdateInput(_currentInput);
                break;

            case DIK.DIK_END:
                _caretPosition = _currentInput.Length;
                UpdateInput(_currentInput);
                break;

            case DIK.DIK_DELETE:
            case DIK.DIK_DECIMAL:
                if (_caretPosition < _currentInput.Length)
                {
                    UpdateInput(_currentInput.Remove(_caretPosition, 1));
                }

                break;

            case DIK.DIK_BACKSPACE:
                if (_caretPosition > 0)
                {
                    --_caretPosition;
                    UpdateInput(_currentInput.Remove(_caretPosition, 1));
                }

                break;
            }
        }
        else
        {
            switch (arg.key)
            {
            case DIK.DIK_RETURN:
                Confirm();
                break;

            case DIK.DIK_ESCAPE:
                Cancel();
                break;
            }
        }

        return(true);
    }