コード例 #1
0
ファイル: TestCaseKeyCounter.cs プロジェクト: weebaka/osu
        public TestCaseKeyCounter()
        {
            KeyCounterCollection kc = new KeyCounterCollection
            {
                Origin     = Anchor.Centre,
                Anchor     = Anchor.Centre,
                IsCounting = true,
                Children   = new KeyCounter[]
                {
                    new KeyCounterKeyboard(Key.Z),
                    new KeyCounterKeyboard(Key.X),
                    new KeyCounterMouse(MouseButton.Left),
                    new KeyCounterMouse(MouseButton.Right),
                },
            };

            AddStep("Add random", () =>
            {
                Key key = (Key)((int)Key.A + RNG.Next(26));
                kc.Add(new KeyCounterKeyboard(key));
            });
            AddSliderStep("Fade time", 0, 200, 50, v => kc.FadeTime = v);

            Add(kc);
        }
コード例 #2
0
ファイル: RulesetInputManager.cs プロジェクト: rootyElf/osu
        public void Attach(KeyCounterCollection keyCounter)
        {
            var receptor = new ActionReceptor(keyCounter);

            Add(receptor);
            keyCounter.SetReceptor(receptor);

            keyCounter.AddRange(KeyBindingContainer.DefaultKeyBindings.Select(b => b.GetAction <T>()).Distinct().Select(b => new KeyCounterAction <T>(b)));
        }
コード例 #3
0
ファイル: TestCaseKeyCounter.cs プロジェクト: nairaner/osu
        public override void Reset()
        {
            base.Reset();

            KeyCounterCollection kc = new KeyCounterCollection
            {
                Origin     = Anchor.Centre,
                Anchor     = Anchor.Centre,
                IsCounting = true,
                Children   = new KeyCounter[]
                {
                    new KeyCounterKeyboard(Key.Z),
                    new KeyCounterKeyboard(Key.X),
                    new KeyCounterMouse(MouseButton.Left),
                    new KeyCounterMouse(MouseButton.Right),
                },
            };
            BindableInt bindable = new BindableInt {
                MinValue = 0, MaxValue = 200, Default = 50
            };

            bindable.ValueChanged += delegate { kc.FadeTime = bindable.Value; };
            AddStep("Add Random", () =>
            {
                Key key = (Key)((int)Key.A + RNG.Next(26));
                kc.Add(new KeyCounterKeyboard(key));
            });

            TestSliderBar <int> sliderBar;

            Add(new Container
            {
                Anchor       = Anchor.TopRight,
                Origin       = Anchor.TopRight,
                AutoSizeAxes = Axes.Both,
                Children     = new Drawable[]
                {
                    new SpriteText {
                        Text = "FadeTime"
                    },
                    sliderBar = new TestSliderBar <int>
                    {
                        Width          = 150,
                        Height         = 10,
                        SelectionColor = Color4.Orange,
                    }
                }
            });

            sliderBar.Current.BindTo(bindable);

            Add(kc);
        }
コード例 #4
0
ファイル: TestCaseKeyCounter.cs プロジェクト: ddevault/osu
        public override void Reset()
        {
            base.Reset();

            KeyCounterCollection kc = new KeyCounterCollection
            {
                Origin     = Anchor.Centre,
                Anchor     = Anchor.Centre,
                IsCounting = true
            };

            Add(kc);
            kc.AddKey(new KeyCounterKeyboard(@"Z", Key.Z));
            kc.AddKey(new KeyCounterKeyboard(@"X", Key.X));
            kc.AddKey(new KeyCounterMouse(@"M1", MouseButton.Left));
            kc.AddKey(new KeyCounterMouse(@"M2", MouseButton.Right));
        }
コード例 #5
0
ファイル: TestCaseKeyCounter.cs プロジェクト: PaoMoXML/osu
        public override void Reset()
        {
            base.Reset();

            KeyCounterCollection kc = new KeyCounterCollection
            {
                Origin     = Anchor.Centre,
                Anchor     = Anchor.Centre,
                IsCounting = true,
                Children   = new KeyCounter[]
                {
                    new KeyCounterKeyboard(@"Z", Key.Z),
                    new KeyCounterKeyboard(@"X", Key.X),
                    new KeyCounterMouse(@"M1", MouseButton.Left),
                    new KeyCounterMouse(@"M2", MouseButton.Right),
                },
            };
            BindableInt bindable = new BindableInt {
                MinValue = 0, MaxValue = 200, Default = 50
            };

            bindable.ValueChanged += delegate { kc.FadeTime = bindable.Value; };
            AddButton("Add Random", () =>
            {
                Key key = (Key)((int)Key.A + RNG.Next(26));
                kc.Add(new KeyCounterKeyboard(key.ToString(), key));
            });
            ButtonsContainer.Add(new SpriteText {
                Text = "FadeTime"
            });
            ButtonsContainer.Add(new TestSliderBar <int>
            {
                Width          = 150,
                Height         = 10,
                SelectionColor = Color4.Orange,
                Bindable       = bindable
            });
            Add(kc);
        }
コード例 #6
0
        public TestCaseKeyCounter()
        {
            KeyCounterKeyboard   rewindTestKeyCounterKeyboard;
            KeyCounterCollection kc = new KeyCounterCollection
            {
                Origin   = Anchor.Centre,
                Anchor   = Anchor.Centre,
                Children = new KeyCounter[]
                {
                    rewindTestKeyCounterKeyboard = new KeyCounterKeyboard(Key.X),
                    new KeyCounterKeyboard(Key.X),
                    new KeyCounterMouse(MouseButton.Left),
                    new KeyCounterMouse(MouseButton.Right),
                },
            };


            AddStep("Add random", () =>
            {
                Key key = (Key)((int)Key.A + RNG.Next(26));
                kc.Add(new KeyCounterKeyboard(key));
            });
            AddSliderStep("Fade time", 0, 200, 50, v => kc.FadeTime = v);

            Key    testKey = ((KeyCounterKeyboard)kc.Children.First()).Key;
            double time1   = 0;

            AddStep($"Press {testKey} key", () =>
            {
                InputManager.PressKey(testKey);
                InputManager.ReleaseKey(testKey);
            });

            AddAssert($"Check {testKey} counter after keypress", () => rewindTestKeyCounterKeyboard.CountPresses == 1);

            AddStep($"Press {testKey} key", () =>
            {
                InputManager.PressKey(testKey);
                InputManager.ReleaseKey(testKey);
                time1 = Clock.CurrentTime;
            });

            AddAssert($"Check {testKey} counter after keypress", () => rewindTestKeyCounterKeyboard.CountPresses == 2);

            IFrameBasedClock oldClock = null;

            AddStep($"Rewind {testKey} counter once", () =>
            {
                oldClock = rewindTestKeyCounterKeyboard.Clock;
                rewindTestKeyCounterKeyboard.Clock = new FramedOffsetClock(new FixedClock(time1 - 10));
            });

            AddAssert($"Check {testKey} counter after rewind", () => rewindTestKeyCounterKeyboard.CountPresses == 1);

            AddStep($"Rewind {testKey} counter to zero", () => rewindTestKeyCounterKeyboard.Clock = new FramedOffsetClock(new FixedClock(0)));

            AddAssert($"Check {testKey} counter after rewind", () => rewindTestKeyCounterKeyboard.CountPresses == 0);

            AddStep("Restore clock", () => rewindTestKeyCounterKeyboard.Clock = oldClock);

            Add(kc);
        }
コード例 #7
0
ファイル: RulesetInputManager.cs プロジェクト: rootyElf/osu
 public ActionReceptor(KeyCounterCollection target)
     : base(target)
 {
 }
コード例 #8
0
 public void Attach(KeyCounterCollection keyCounter) =>
 (KeyBindingInputManager as ICanAttachKeyCounter)?.Attach(keyCounter);