Beispiel #1
0
        public TestCaseKeyBindings()
        {
            Child = manual = new ManualInputManager
            {
                Child = new GridContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Content          = new[]
                    {
                        new Drawable[]
                        {
                            none      = new KeyBindingTester(SimultaneousBindingMode.None),
                            noneExact = new KeyBindingTester(SimultaneousBindingMode.NoneExact)
                        },
                        new Drawable[]
                        {
                            unique = new KeyBindingTester(SimultaneousBindingMode.Unique),
                            all    = new KeyBindingTester(SimultaneousBindingMode.All)
                        },
                    }
                }
            };

            AddStep("return input", () => manual.UseParentInput = true);
        }
        public void SetUp()
        {
            Clear();

            rng = new Random(1337);

            Menu menu;

            Add(inputManager = new ManualInputManager
            {
                UseParentState = false,
                Children       = new Drawable[]
                {
                    new CursorContainer(),
                    new Container
                    {
                        RelativeSizeAxes = Axes.Both,
                        Child            = menu = createMenu()
                    }
                }
            });

            menus = new MenuStructure(menu);
            inputManager.MoveMouseTo(Vector2.Zero);
        }
 protected ManualInputManagerTestScene()
 {
     base.Content.Add(InputManager = new ManualInputManager
     {
         UseParentInput = true,
         Child          = content = new MenuCursorContainer {
             RelativeSizeAxes = Axes.Both
         },
     });
 }
Beispiel #4
0
        public TestCaseMouseStates()
        {
            Children = new Drawable[]
            {
                manual = new ManualInputManager
                {
                    FillMode         = FillMode.Fit,
                    FillAspectRatio  = 1,
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(0.7f),
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = new Color4(1, 1, 1, 0.2f),
                        },
                        actionContainer = new FrameworkActionContainer
                        {
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(0.7f),
                            Anchor           = Anchor.Centre,
                            Origin           = Anchor.Centre,
                            Children         = new Drawable[]
                            {
                                new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = new Color4(1, 1, 1, 0.2f),
                                },
                                marginBox = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Anchor           = Anchor.Centre,
                                    Origin           = Anchor.Centre,
                                    Size             = new Vector2(0.8f),
                                    Colour           = Color4.SkyBlue.Opacity(0.1f),
                                },
                                s2 = new StateTracker(2),
                            }
                        },
                        s1 = new StateTracker(1),
                    }
                },
                new StateTracker(0)
            };

            AddStep("return input", () => manual.UseParentState = true);

            // TODO: blocking event testing
        }
Beispiel #5
0
        public void SetUp()
        {
            Clear();

            rng = new Random(1337);

            Menu menu;

            Add(inputManager = new ManualInputManager
            {
                Children = new Drawable[]
                {
                    new CursorContainer(),
                    new Container
                    {
                        RelativeSizeAxes = Axes.Both,
                        Child            = menu = createMenu()
                    }
                }
            });

            menus = new MenuStructure(menu);
        }
        public void TestNonCurrentScreenDoesNotAcceptInput()
        {
            ManualInputManager inputManager = null;

            AddStep("override stack", () =>
            {
                // we can't use the [SetUp] screen stack as we need to change the ctor parameters.
                Clear();

                Add(inputManager = new ManualInputManager
                {
                    Child = stack = new ScreenStack(baseScreen = new TestScreen())
                    {
                        RelativeSizeAxes = Axes.Both
                    }
                });
            });

            TestScreen     screen1 = null;
            TestScreenSlow screen2 = null;

            pushAndEnsureCurrent(() => screen1 = new TestScreen());
            AddStep("Click center of screen", () => clickScreen(inputManager, screen1));
            AddAssert("screen 1 clicked", () => screen1.ClickCount == 1);

            AddStep("push slow", () => screen1.Push(screen2 = new TestScreenSlow()));
            AddStep("Click center of screen", () => inputManager.Click(MouseButton.Left));
            AddAssert("screen 1 not clicked", () => screen1.ClickCount == 1);
            AddAssert("Screen 2 not clicked", () => screen2.ClickCount == 0 && !screen2.IsLoaded);

            AddStep("Allow screen to load", () => screen2.AllowLoad.Set());
            AddUntilStep("ensure current", () => screen2.IsCurrentScreen());
            AddStep("Click center of screen", () => clickScreen(inputManager, screen2));
            AddAssert("screen 1 not clicked", () => screen1.ClickCount == 1);
            AddAssert("Screen 2 clicked", () => screen2.ClickCount == 1 && screen2.IsLoaded);
        }
 private void clickScreen(ManualInputManager inputManager, TestScreen screen)
 {
     inputManager.MoveMouseTo(screen);
     inputManager.Click(MouseButton.Left);
 }
Beispiel #8
0
        public TestCaseCursors()
        {
            Child = inputManager = new ManualInputManager
            {
                Child = cursorOverrideContainer = new CursorOverrideContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Children         = new[]
                    {
                        // Middle user
                        cursorBoxes[0] = new CustomCursorBox(Color4.Green)
                        {
                            Anchor           = Anchor.Centre,
                            Origin           = Anchor.Centre,
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(0.5f),
                        },
                        // Top-left user
                        cursorBoxes[1] = new CustomCursorBox(Color4.Blue)
                        {
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(0.4f)
                        },
                        // Bottom-right user
                        cursorBoxes[2] = new CustomCursorBox(Color4.Red)
                        {
                            Anchor           = Anchor.BottomRight,
                            Origin           = Anchor.BottomRight,
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(0.4f)
                        },
                        // Bottom-left local
                        cursorBoxes[3] = new CustomCursorBox(Color4.Magenta, false)
                        {
                            Anchor           = Anchor.BottomLeft,
                            Origin           = Anchor.BottomLeft,
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(0.4f)
                        },
                        // Top-right local
                        cursorBoxes[4] = new CustomCursorBox(Color4.Cyan, false)
                        {
                            Anchor           = Anchor.TopRight,
                            Origin           = Anchor.TopRight,
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(0.4f)
                        },
                        // Left-local
                        cursorBoxes[5] = new CustomCursorBox(Color4.Yellow, false)
                        {
                            Anchor           = Anchor.CentreLeft,
                            Origin           = Anchor.CentreLeft,
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(0.2f, 1),
                        },
                    }
                }
            };

            returnUserInput();

            AddToggleStep("Smooth transitions", b => cursorBoxes.ForEach(box => box.SmoothTransition = b));

            testUserCursor();
            testLocalCursor();
            testUserCursorOverride();
            testMultipleLocalCursors();
            returnUserInput();
        }
Beispiel #9
0
        protected OsuManualInputManagerTestScene()
        {
            MenuCursorContainer cursorContainer;

            CompositeDrawable mainContent = cursorContainer = new MenuCursorContainer {
                RelativeSizeAxes = Axes.Both
            };

            cursorContainer.Child = content = new OsuTooltipContainer(cursorContainer.Cursor)
            {
                RelativeSizeAxes = Axes.Both
            };

            if (CreateNestedActionContainer)
            {
                mainContent = new GlobalActionContainer(null).WithChild(mainContent);
            }

            base.Content.AddRange(new Drawable[]
            {
                InputManager = new ManualInputManager
                {
                    UseParentInput = true,
                    Child          = mainContent
                },
                new Container
                {
                    AutoSizeAxes = Axes.Both,
                    Anchor       = Anchor.TopRight,
                    Origin       = Anchor.TopRight,
                    Margin       = new MarginPadding(5),
                    CornerRadius = 5,
                    Masking      = true,
                    Children     = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Color4.Black,
                            RelativeSizeAxes = Axes.Both,
                            Alpha            = 0.5f,
                        },
                        new FillFlowContainer
                        {
                            AutoSizeAxes = Axes.Both,
                            Direction    = FillDirection.Vertical,
                            Margin       = new MarginPadding(5),
                            Spacing      = new Vector2(5),
                            Children     = new Drawable[]
                            {
                                new OsuSpriteText
                                {
                                    Anchor = Anchor.TopCentre,
                                    Origin = Anchor.TopCentre,
                                    Text   = "Input Priority"
                                },
                                new FillFlowContainer
                                {
                                    AutoSizeAxes = Axes.Both,
                                    Anchor       = Anchor.TopCentre,
                                    Origin       = Anchor.TopCentre,
                                    Margin       = new MarginPadding(5),
                                    Spacing      = new Vector2(5),
                                    Direction    = FillDirection.Horizontal,

                                    Children = new Drawable[]
                                    {
                                        buttonLocal = new TriangleButton
                                        {
                                            Text   = "local",
                                            Size   = new Vector2(50, 30),
                                            Action = returnUserInput
                                        },
                                        buttonTest = new TriangleButton
                                        {
                                            Text   = "test",
                                            Size   = new Vector2(50, 30),
                                            Action = returnTestInput
                                        },
                                    }
                                },
                            }
                        },
                    }
                },
            });
        }
 protected ManualInputManagerTestCase()
 {
     base.Content.Add(InputManager = new ManualInputManager());
     AddStep("return user input", () => InputManager.UseParentInput = true);
 }
Beispiel #11
0
        protected VignetteManualInputManagerTestScene()
        {
            base.Content.AddRange(new Drawable[]
            {
                InputManager = new ManualInputManager
                {
                    UseParentInput = true,
                    Child          = new GlobalActionContainer(null)
                    {
                        RelativeSizeAxes = Axes.Both,
                        Child            = content = new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                    },
                },
                new Container
                {
                    Depth        = float.MinValue,
                    AutoSizeAxes = Axes.Both,
                    Anchor       = Anchor.TopRight,
                    Origin       = Anchor.TopRight,
                    Margin       = new MarginPadding(5),
                    CornerRadius = 5,
                    Masking      = true,
                    Children     = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Color4.Black,
                            RelativeSizeAxes = Axes.Both,
                            Alpha            = 0.5f,
                        },
                        new FillFlowContainer
                        {
                            AutoSizeAxes = Axes.Both,
                            Direction    = FillDirection.Vertical,
                            Margin       = new MarginPadding(5),
                            Spacing      = new Vector2(5),
                            Children     = new Drawable[]
                            {
                                new SpriteText
                                {
                                    Anchor = Anchor.TopCentre,
                                    Origin = Anchor.TopCentre,
                                    Text   = "Input Priority"
                                },
                                new FillFlowContainer
                                {
                                    AutoSizeAxes = Axes.Both,
                                    Anchor       = Anchor.TopCentre,
                                    Origin       = Anchor.TopCentre,
                                    Margin       = new MarginPadding(5),
                                    Spacing      = new Vector2(5),
                                    Direction    = FillDirection.Horizontal,

                                    Children = new Drawable[]
                                    {
                                        buttonLocal = new BasicButton
                                        {
                                            Text   = "local",
                                            Size   = new Vector2(50, 30),
                                            Action = returnUserInput
                                        },
                                        buttonTest = new BasicButton
                                        {
                                            Text   = "test",
                                            Size   = new Vector2(50, 30),
                                            Action = returnTestInput
                                        },
                                    }
                                },
                            }
                        },
                    }
                },
            });
        }
Beispiel #12
0
 protected KanojoWorksManualInputManagerTestScene()
 {
     base.Content.AddRange(new Drawable[]
     {
         InputManager = new ManualInputManager
         {
             UseParentInput                                  = true,
             Child                                           = new GlobalInputContainer()
                                          .WithChild(content = new DrawSizePreservingFillContainer())
         },
         new Container
         {
             AutoSizeAxes = Axes.Both,
             Anchor       = Anchor.TopRight,
             Origin       = Anchor.TopRight,
             Margin       = new MarginPadding(10),
             Children     = new Drawable[]
             {
                 new Box
                 {
                     Colour           = Colour4.Black,
                     RelativeSizeAxes = Axes.Both,
                     Alpha            = 0.5f
                 },
                 new FillFlowContainer
                 {
                     AutoSizeAxes = Axes.Both,
                     Direction    = FillDirection.Vertical,
                     Margin       = new MarginPadding(5),
                     Spacing      = new Vector2(5),
                     Children     = new Drawable[]
                     {
                         new SpriteText
                         {
                             Anchor = Anchor.TopCentre,
                             Origin = Anchor.TopCentre,
                             Text   = "Input Priority"
                         },
                         new FillFlowContainer
                         {
                             AutoSizeAxes = Axes.Both,
                             Anchor       = Anchor.TopCentre,
                             Origin       = Anchor.TopCentre,
                             Margin       = new MarginPadding(5),
                             Spacing      = new Vector2(5),
                             Direction    = FillDirection.Horizontal,
                             Children     = new Drawable[]
                             {
                                 buttonLocal = new KanojoWorksButton
                                 {
                                     Text             = "local",
                                     Size             = new Vector2(50, 30),
                                     Masking          = true,
                                     CornerRadius     = 5,
                                     BackgroundColour = Colour4.BlueViolet,
                                     Action           = returnUserInput
                                 },
                                 buttonTest = new KanojoWorksButton
                                 {
                                     Text             = "test",
                                     Size             = new Vector2(50, 30),
                                     Masking          = true,
                                     CornerRadius     = 5,
                                     BackgroundColour = Colour4.BlueViolet,
                                     Action           = returnTestInput
                                 }
                             }
                         }
                     }
                 }
             }
         }
     });
 }
 protected ManualInputManagerTestCase()
 {
     base.Content.Add(InputManager = new ManualInputManager());
     ReturnUserInput();
 }
Beispiel #14
0
 protected ManualInputManagerTestCase()
 {
     base.Content.Add(InputManager = new ManualInputManager {
         UseParentInput = true
     });
 }