Exemplo n.º 1
0
        public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            if (e.Repeat)
            {
                return(false);
            }

            switch (e.Action)
            {
            case GlobalAction.HoldForHUD:
                holdingForHUD = true;
                updateVisibility();
                return(true);

            case GlobalAction.ToggleInGameInterface:
                switch (configVisibilityMode.Value)
                {
                case HUDVisibilityMode.Never:
                    configVisibilityMode.Value = HUDVisibilityMode.HideDuringGameplay;
                    break;

                case HUDVisibilityMode.HideDuringGameplay:
                    configVisibilityMode.Value = HUDVisibilityMode.Always;
                    break;

                case HUDVisibilityMode.Always:
                    configVisibilityMode.Value = HUDVisibilityMode.Never;
                    break;
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        public override bool OnPressed(KeyBindingPressEvent <TaikoAction> e)
        {
            if (pressHandledThisFrame)
            {
                return(true);
            }
            if (Judged)
            {
                return(false);
            }

            validActionPressed = HitActions.Contains(e.Action);

            // Only count this as handled if the new judgement is a hit
            var result = UpdateResult(true);

            if (IsHit)
            {
                HitAction = e.Action;
            }

            // Regardless of whether we've hit or not, any secondary key presses in the same frame should be discarded
            // E.g. hitting a non-strong centre as a strong should not fall through and perform a hit on the next note
            pressHandledThisFrame = true;
            return(result);
        }
Exemplo n.º 3
0
        public bool OnPressed(KeyBindingPressEvent<ManiaAction> e)
        {
            if (AllJudged)
                return false;

            if (e.Action != Action.Value)
                return false;

            // do not run any of this logic when rewinding, as it inverts order of presses/releases.
            if (Time.Elapsed < 0)
                return false;

            if (CheckHittable?.Invoke(this, Time.Current) == false)
                return false;

            // The tail has a lenience applied to it which is factored into the miss window (i.e. the miss judgement will be delayed).
            // But the hold cannot ever be started within the late-lenience window, so we should skip trying to begin the hold during that time.
            // Note: Unlike below, we use the tail's start time to determine the time offset.
            if (Time.Current > Tail.HitObject.StartTime && !Tail.HitObject.HitWindows.CanBeHit(Time.Current - Tail.HitObject.StartTime))
                return false;

            beginHoldAt(Time.Current - Head.HitObject.StartTime);

            return Head.UpdateResult();
        }
Exemplo n.º 4
0
        public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            const double keyboard_seek_amount = 5000;

            switch (e.Action)
            {
            case GlobalAction.SeekReplayBackward:
                keyboardSeek(-1);
                return(true);

            case GlobalAction.SeekReplayForward:
                keyboardSeek(1);
                return(true);

            case GlobalAction.TogglePauseReplay:
                if (GameplayClockContainer.IsPaused.Value)
                {
                    GameplayClockContainer.Start();
                }
                else
                {
                    GameplayClockContainer.Stop();
                }
                return(true);
            }

            return(false);

            void keyboardSeek(int direction)
            {
                double target = Math.Clamp(GameplayClockContainer.CurrentTime + direction * keyboard_seek_amount, 0, GameplayState.Beatmap.HitObjects.Last().GetEndTime());

                Seek(target);
            }
        }
Exemplo n.º 5
0
        public override bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            if (!e.Repeat)
            {
                switch (e.Action)
                {
                case GlobalAction.Select:
                    NextButton.TriggerClick();
                    return(true);

                case GlobalAction.Back:
                    if (BackButton.Enabled.Value)
                    {
                        BackButton.TriggerClick();
                        return(true);
                    }

                    // If back button is disabled, we are at the first step.
                    // The base call will handle dismissal of the overlay.
                    break;
                }
            }

            return(base.OnPressed(e));
        }
Exemplo n.º 6
0
        public bool OnPressed(KeyBindingPressEvent <GamebosuAction> action)
        {
            switch (action.Action)
            {
            case GamebosuAction.DPadRight:
                setSelection(1);
                break;

            case GamebosuAction.DPadLeft:
                setSelection(-1);
                break;

            case GamebosuAction.ButtonA:
            case GamebosuAction.ButtonStart:
            case GamebosuAction.ButtonSelect:
                var rom = AvailableRoms.Value.ElementAtOrDefault(selection.Value);

                if (rom == null)
                {
                    goto default;
                }

                confirmSelectSample?.Play();
                RomSelected?.Invoke(rom);
                break;

            default:
                break;
            }

            return(true);
        }
            public override bool OnPressed(KeyBindingPressEvent <PlatformAction> e)
            {
                bool consumed = base.OnPressed(e);

                PlatformActionQueue.Enqueue(consumed);
                return(consumed);
            }
Exemplo n.º 8
0
            public bool OnPressed(KeyBindingPressEvent <TaikoAction> e)
            {
                Drawable target = null;

                if (e.Action == CentreAction)
                {
                    target = Centre;
                    sampleTriggerSource.Play(HitType.Centre);
                }
                else if (e.Action == RimAction)
                {
                    target = Rim;
                    sampleTriggerSource.Play(HitType.Rim);
                }

                if (target != null)
                {
                    const float alpha_amount = 1;

                    const float down_time = 80;
                    const float up_time   = 50;

                    target.Animate(
                        t => t.FadeTo(Math.Min(target.Alpha + alpha_amount, 1), down_time)
                        ).Then(
                        t => t.FadeOut(up_time)
                        );
                }

                return(false);
            }
Exemplo n.º 9
0
        public bool OnPressed(KeyBindingPressEvent <TestBrowserAction> e)
        {
            if (e.Repeat)
            {
                return(false);
            }

            switch (e.Action)
            {
            case TestBrowserAction.Search:
                if (leftContainer.Width == 0)
                {
                    toggleTestList();
                }
                GetContainingInputManager().ChangeFocus(searchTextBox);
                return(true);

            case TestBrowserAction.Reload:
                LoadTest(CurrentTest.GetType());
                return(true);

            case TestBrowserAction.ToggleTestList:
                toggleTestList();
                return(true);
            }

            return(false);
        }
Exemplo n.º 10
0
        public bool OnPressed(KeyBindingPressEvent <PlatformAction> e)
        {
            switch (e.Action)
            {
            case PlatformAction.TabNew:
                currentChannel.Value = channelList.ChannelListingChannel;
                return(true);

            case PlatformAction.DocumentClose:
                channelManager.LeaveChannel(currentChannel.Value);
                return(true);

            case PlatformAction.TabRestore:
                channelManager.JoinLastClosedChannel();
                return(true);

            case PlatformAction.DocumentPrevious:
                cycleChannel(-1);
                return(true);

            case PlatformAction.DocumentNext:
                cycleChannel(1);
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 11
0
        public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            if (e.Repeat)
            {
                return(false);
            }

            switch (e.Action)
            {
            case GlobalAction.Select:
                if (IsLoading)
                {
                    return(true);
                }

                if (SubmitButton.Enabled.Value)
                {
                    SubmitButton.TriggerClick();
                    return(true);
                }
                else
                {
                    SelectBeatmap();
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 12
0
        public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            switch (e.Action)
            {
            case GlobalAction.Back:
                // as we don't want to display the back button, manual handling of exit action is required.
                this.Exit();
                return(true);

            case GlobalAction.EditorComposeMode:
                menuBar.Mode.Value = EditorScreenMode.Compose;
                return(true);

            case GlobalAction.EditorDesignMode:
                menuBar.Mode.Value = EditorScreenMode.Design;
                return(true);

            case GlobalAction.EditorTimingMode:
                menuBar.Mode.Value = EditorScreenMode.Timing;
                return(true);

            case GlobalAction.EditorSetupMode:
                menuBar.Mode.Value = EditorScreenMode.SongSetup;
                return(true);

            case GlobalAction.EditorVerifyMode:
                menuBar.Mode.Value = EditorScreenMode.Verify;
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 13
0
        public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            switch (e.Action)
            {
            case GlobalAction.Back:
                if (TextBox.HasFocus)
                {
                    Schedule(() => TextBox.KillFocus());
                    return(true);
                }

                break;

            case GlobalAction.ToggleChatFocus:
                if (TextBox.HasFocus)
                {
                    Schedule(() => TextBox.KillFocus());
                }
                else
                {
                    expandedFromTextBoxFocus.Value = true;

                    // schedule required to ensure the textbox has become present from above bindable update.
                    Schedule(() => TextBox.TakeFocus());
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 14
0
        public bool OnPressed(KeyBindingPressEvent <PlatformAction> e)
        {
            switch (e.Action)
            {
            case PlatformAction.Cut:
                Cut();
                return(true);

            case PlatformAction.Copy:
                Copy();
                return(true);

            case PlatformAction.Paste:
                Paste();
                return(true);

            case PlatformAction.Undo:
                Undo();
                return(true);

            case PlatformAction.Redo:
                Redo();
                return(true);

            case PlatformAction.Save:
                Save();
                return(true);
            }

            return(false);
        }
Exemplo n.º 15
0
        protected virtual Drawable PropagatePressed(IEnumerable <Drawable> drawables, InputState state, T pressed, float scrollAmount = 0, bool isPrecise = false, bool repeat = false)
        {
            Drawable handled = null;

            // only handle if we are a new non-pressed action (or a concurrency mode that supports multiple simultaneous triggers).
            if (simultaneousMode == SimultaneousBindingMode.All || !pressedActions.Contains(pressed))
            {
                pressedActions.Add(pressed);

                if (scrollAmount != 0)
                {
                    var scrollEvent = new KeyBindingScrollEvent <T>(state, pressed, scrollAmount, isPrecise);
                    handled = drawables.FirstOrDefault(d => triggerKeyBindingEvent(d, scrollEvent));
                }

                if (handled == null)
                {
                    var pressEvent = new KeyBindingPressEvent <T>(state, pressed, repeat);
                    handled = drawables.FirstOrDefault(d => triggerKeyBindingEvent(d, pressEvent));
                }
            }

            if (handled != null)
            {
                Logger.Log($"Pressed ({pressed}) handled by {handled}.", LoggingTarget.Runtime, LogLevel.Debug);
            }

            return(handled);
        }
Exemplo n.º 16
0
        public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            if (e.Repeat)
            {
                return(false);
            }

            switch (e.Action)
            {
            case GlobalAction.MusicPlay:
                if (game.LocalUserPlaying.Value)
                {
                    return(false);
                }

                // use previous state as TogglePause may not update the track's state immediately (state update is run on the audio thread see https://github.com/ppy/osu/issues/9880#issuecomment-674668842)
                bool wasPlaying = musicController.IsPlaying;

                if (musicController.TogglePause())
                {
                    onScreenDisplay?.Display(new MusicActionToast(wasPlaying ? ToastStrings.PauseTrack : ToastStrings.PlayTrack, e.Action));
                }
                return(true);

            case GlobalAction.MusicNext:
                if (beatmap.Disabled)
                {
                    return(false);
                }

                musicController.NextTrack(() => onScreenDisplay?.Display(new MusicActionToast(GlobalActionKeyBindingStrings.MusicNext, e.Action)));

                return(true);

            case GlobalAction.MusicPrev:
                if (beatmap.Disabled)
                {
                    return(false);
                }

                musicController.PreviousTrack(res =>
                {
                    switch (res)
                    {
                    case PreviousTrackResult.Restart:
                        onScreenDisplay?.Display(new MusicActionToast(ToastStrings.RestartTrack, e.Action));
                        break;

                    case PreviousTrackResult.Previous:
                        onScreenDisplay?.Display(new MusicActionToast(GlobalActionKeyBindingStrings.MusicPrev, e.Action));
                        break;
                    }
                });

                return(true);
            }

            return(false);
        }
Exemplo n.º 17
0
 public bool OnPressed(KeyBindingPressEvent <ManiaAction> e)
 {
     if (e.Action == column.Action.Value)
     {
         keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint).Then().ScaleTo(1.3f, 250, Easing.OutQuint);
     }
     return(false);
 }
Exemplo n.º 18
0
 public bool OnPressed(KeyBindingPressEvent <ManiaAction> e)
 {
     if (e.Action == column.Action.Value)
     {
         backgroundOverlay.FadeTo(1, 50, Easing.OutQuint).Then().FadeTo(0.5f, 250, Easing.OutQuint);
     }
     return(false);
 }
Exemplo n.º 19
0
        public bool OnPressed(KeyBindingPressEvent <PlatformAction> e)
        {
            if (e.Action == PlatformAction.Copy)
            {
                host.GetClipboard()?.SetText(formatSelectionAsString());
            }

            return(false);
        }
Exemplo n.º 20
0
        public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            if (e.Action == GlobalAction.Back)
            {
                BeginConfirm();
                return(true);
            }

            return(false);
        }
Exemplo n.º 21
0
            public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
            {
                if (e.Action == GlobalAction.ToggleModSelection && !e.Repeat)
                {
                    TriggerClick();
                    return(true);
                }

                return(false);
            }
Exemplo n.º 22
0
        public bool OnPressed(KeyBindingPressEvent <PlatformAction> e)
        {
            switch (e.Action)
            {
            case PlatformAction.Delete:
                return(DeleteSelected());
            }

            return(false);
        }
Exemplo n.º 23
0
            public bool OnPressed(KeyBindingPressEvent <TestAction> e)
            {
                if (e.Repeat)
                {
                    return(false);
                }

                box.Colour = Color4.White;
                return(true);
            }
Exemplo n.º 24
0
        public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            if (e.Repeat || e.Action != GlobalAction.DeselectAllMods)
            {
                return(false);
            }

            TriggerClick();
            return(true);
        }
Exemplo n.º 25
0
        public bool OnPressed(KeyBindingPressEvent <GamebosuAction> action)
        {
            if (action.Action >= GamebosuAction.ButtonA && GamebosuAction.ButtonIncrementClockRate > action.Action)
            {
                Scheduler.CancelDelayedTasks();
                schedulePush();
            }

            return(true);
        }
Exemplo n.º 26
0
        public bool OnPressed(KeyBindingPressEvent <ManiaAction> e)
        {
            if (e.Action == column.Action.Value)
            {
                upSprite.FadeTo(0);
                downSprite.FadeTo(1);
            }

            return(false);
        }
Exemplo n.º 27
0
        public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            if (e.Action != GlobalAction.QuickRetry)
            {
                return(false);
            }

            BeginConfirm();
            return(true);
        }
Exemplo n.º 28
0
            public override bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
            {
                if (!base.OnPressed(e))
                {
                    return(false);
                }

                TextChanged?.Invoke();
                return(true);
            }
Exemplo n.º 29
0
        public bool OnPressed(KeyBindingPressEvent <ManiaAction> e)
        {
            if (e.Action != Action.Value)
            {
                return(false);
            }

            sampleTriggerSource.Play();
            return(true);
        }
Exemplo n.º 30
0
        public bool OnPressed(KeyBindingPressEvent <PlatformAction> e)
        {
            if (e.Repeat || e.Action != PlatformAction.SelectAll)
            {
                return(false);
            }

            TriggerClick();
            return(true);
        }