public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable) =>
 adjustments.RemoveAdjustment(type, adjustBindable);
Ejemplo n.º 2
0
        private void load(Storage storage, GameHost host)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            exit = host.Exit;

            rateBindable = new BindableDouble(1)
            {
                MinValue = 0,
                MaxValue = 2,
            };

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                leftContainer = new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(test_list_width, 1),
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Color4.DimGray,
                            RelativeSizeAxes = Axes.Both
                        },
                        new FillFlowContainer
                        {
                            Direction        = FillDirection.Vertical,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                searchTextBox = new TextBox
                                {
                                    OnCommit = delegate
                                    {
                                        var firstVisible = leftFlowContainer.FirstOrDefault(b => b.IsPresent);
                                        if (firstVisible != null)
                                        {
                                            LoadTest(firstVisible.TestType);
                                        }
                                    },
                                    Height           = 20,
                                    RelativeSizeAxes = Axes.X,
                                    PlaceholderText  = "type to search"
                                },
                                new ScrollContainer
                                {
                                    Padding = new MarginPadding {
                                        Top = 3, Bottom = 20
                                    },
                                    RelativeSizeAxes         = Axes.Both,
                                    ScrollbarOverlapsContent = false,
                                    Child = leftFlowContainer = new SearchContainer <TestCaseButton>
                                    {
                                        Padding          = new MarginPadding(3),
                                        Direction        = FillDirection.Vertical,
                                        Spacing          = new Vector2(0, 5),
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                    }
                                }
                            }
                        }
                    }
                },
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = test_list_width
                    },
                    Children = new Drawable[]
                    {
                        toolbar = new Toolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                            Depth            = -1,
                        },
                        testContentContainer = new Container
                        {
                            Clock            = framedClock,
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = 50
                            },
                            Child = compilingNotice = new Container
                            {
                                Alpha        = 0,
                                Anchor       = Anchor.Centre,
                                Origin       = Anchor.Centre,
                                Masking      = true,
                                Depth        = float.MinValue,
                                CornerRadius = 5,
                                AutoSizeAxes = Axes.Both,
                                Children     = new Drawable[]
                                {
                                    new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Colour           = Color4.Black,
                                    },
                                    new SpriteText
                                    {
                                        TextSize = 30,
                                        Text     = @"Compiling new version..."
                                    }
                                },
                            }
                        }
                    }
                }
            };

            searchTextBox.Current.ValueChanged += newValue => leftFlowContainer.SearchTerm = newValue;

            backgroundCompiler = new DynamicClassCompiler <TestCase>
            {
                CompilationStarted  = compileStarted,
                CompilationFinished = compileFinished,
            };
            try
            {
                backgroundCompiler.Start();
            }
            catch
            {
                //it's okay for this to fail for now.
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AssemblyDropdown.AddDropdownItem(asm.GetName().Name, asm);
            }

            toolbar.AssemblyDropdown.Current.ValueChanged += updateList;
            toolbar.RunAllSteps.Current.ValueChanged      += v => runTests(null);
            toolbar.RateAdjustSlider.Current.BindTo(rateBindable);

            rateBindable.ValueChanged += v => rateAdjustClock.Rate = v;
            rateBindable.TriggerChange();
        }
Ejemplo n.º 3
0
        public TestCaseSliderbar()
        {
            sliderBarValue = new BindableDouble(8)
            {
                MinValue = -10,
                MaxValue = 10
            };
            sliderBarValue.ValueChanged += sliderBarValueChanged;

            sliderbarText = new SpriteText
            {
                Text     = $"Selected value: {sliderBarValue.Value}",
                Position = new Vector2(25, 0)
            };

            SliderBar <double> sliderBar = new BasicSliderBar <double>
            {
                Size           = new Vector2(200, 10),
                Position       = new Vector2(25, 25),
                Color          = Color4.White,
                SelectionColor = Color4.Pink,
                KeyboardStep   = 1
            };

            sliderBar.Current.BindTo(sliderBarValue);

            Add(sliderBar);
            Add(sliderbarText);

            Add(sliderBar = new BasicSliderBar <double>
            {
                Size           = new Vector2(200, 10),
                RangePadding   = 20,
                Position       = new Vector2(25, 45),
                Color          = Color4.White,
                SelectionColor = Color4.Pink,
                KeyboardStep   = 1,
            });

            sliderBar.Current.BindTo(sliderBarValue);

            AddSliderStep("Value", -10.0, 10.0, -10.0, v => sliderBarValue.Value = v);

            AddStep("Click at x = 50", () => sliderBar.TriggerOnClick(new InputState
            {
                Mouse = new MouseState
                {
                    Position = sliderBar.ToScreenSpace(sliderBar.DrawSize / 4)
                },
                Keyboard = new KeyboardState {
                    Keys = new OpenTK.Input.Key[0]
                }
            }));

            AddAssert("Value == -6,25", () => sliderBarValue == -6.25);

            AddStep("Press left arrow key", () =>
            {
                var before          = sliderBar.IsHovered;
                sliderBar.IsHovered = true;
                sliderBar.TriggerOnKeyDown(null, new KeyDownEventArgs
                {
                    Key = OpenTK.Input.Key.Left,
                });
                sliderBar.IsHovered = before;
            });

            AddAssert("Value == -7,25", () => sliderBarValue == -7.25);

            AddStep("Click at x = 150 with shift", () =>
            {
                var drawSize = sliderBar.DrawSize;
                drawSize.X  *= 0.75f;
                sliderBar.TriggerOnClick(new InputState
                {
                    Mouse = new MouseState
                    {
                        Position = sliderBar.ToScreenSpace(drawSize)
                    },
                    Keyboard = new KeyboardState {
                        Keys = new [] { OpenTK.Input.Key.LShift }
                    }
                });
            });

            AddAssert("Value == 6", () => sliderBarValue == 6);
        }
 public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable) =>
 adjustments.AddAdjustment(type, adjustBindable);
        public void TestAdjustmentsRemovedWhenReset()
        {
            // ReSharper disable once NotAccessedVariable
            // Bindable - need to store the reference.
            BindableDouble volumeAdjustment = null;

            AddStep("add adjustment", () => track.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment = new BindableDouble {
                Value = 0.5
            }));
            AddAssert("track volume is 0.5", () => Precision.AlmostEquals(0.5, track.AggregateVolume.Value));

            AddStep("reset", () => track.Reset());
            AddAssert("track volume is 1", () => Precision.AlmostEquals(1, track.Volume.Value));
        }
Ejemplo n.º 6
0
        public TestSceneSliderBar()
        {
            sliderBarValue = new BindableDouble
            {
                MinValue = -10,
                MaxValue = 10
            };
            sliderBarValue.ValueChanged += sliderBarValueChanged;

            Add(new FillFlowContainer
            {
                RelativeSizeAxes = Axes.Both,
                Direction        = FillDirection.Vertical,
                Padding          = new MarginPadding(5),
                Spacing          = new Vector2(5, 5),
                Children         = new Drawable[]
                {
                    sliderBarText = new SpriteText
                    {
                        Text = $"Value of Bindable: {sliderBarValue.Value}",
                    },
                    new SpriteText
                    {
                        Text = "BasicSliderBar:",
                    },
                    sliderBar = new BasicSliderBar <double>
                    {
                        Size             = new Vector2(200, 50),
                        BackgroundColour = Color4.White,
                        SelectionColour  = Color4.Pink,
                        KeyboardStep     = 1,
                        Current          = sliderBarValue
                    },
                    new SpriteText
                    {
                        Text = "w/ RangePadding:",
                    },
                    new BasicSliderBar <double>
                    {
                        Size             = new Vector2(200, 10),
                        RangePadding     = 20,
                        BackgroundColour = Color4.White,
                        SelectionColour  = Color4.Pink,
                        KeyboardStep     = 1,
                        Current          = sliderBarValue
                    },
                    new SpriteText
                    {
                        Text = "w/ TransferValueOnCommit:",
                    },
                    transferOnCommitSliderBar = new BasicSliderBar <double>
                    {
                        TransferValueOnCommit = true,
                        Size             = new Vector2(200, 10),
                        BackgroundColour = Color4.White,
                        SelectionColour  = Color4.Pink,
                        KeyboardStep     = 1,
                        Current          = sliderBarValue
                    },
                }
            });
        }
Ejemplo n.º 7
0
        private void Load()
        {
            cachedMap.Play();

            var sliderBarValue = new BindableDouble(cachedMap.BindableTrack.Value?.Volume.Value ?? gameini.Get <double>(SettingsConfig.Volume))
            {
                MinValue = 0, MaxValue = 1, Precision = 0.25d
            };

            sliderBarValue.ValueChanged += (e) =>
            {
                if (cachedMap.BindableTrack.Value != null)
                {
                    cachedMap.BindableTrack.Value.Volume.Value = e.NewValue;
                }

                gameini.GetBindable <double>(SettingsConfig.Volume).Value = e.NewValue;
                gameini.Save();
            };

            InternalChildren = new Drawable[]
            {
                focusedOverlayContainer = new RBfocusedOverlayContainer(Color4.Black.Opacity(0.9f), true)
                {
                    Depth            = float.MinValue,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(1f),
                },
                new Box
                {
                    Depth            = 0,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(1f),
                    Colour           = Color4.Gray.Opacity(0.6f),
                },
                new SpriteText
                {
                    Depth  = 0,
                    Anchor = Anchor.TopCentre,
                    Origin = Anchor.TopCentre,
                    Size   = new Vector2(120f),
                    Colour = Color4.Gray.Opacity(0.9f),
                    Text   = "Settings",
                    Font   = new FontUsage("Roboto", 40f)
                },
                new SpriteText
                {
                    Depth  = 0,
                    Anchor = Anchor.CentreLeft,
                    Origin = Anchor.CentreLeft,
                    Size   = new Vector2(160f, 100f),
                    Colour = Color4.Gray.Opacity(0.9f),
                    Text   = "Keybindings:",
                    X      = 10f,
                    Font   = new FontUsage("Roboto", 40f)
                },
                new SpriteText
                {
                    Depth  = 0,
                    Anchor = Anchor.CentreLeft,
                    Origin = Anchor.CentreLeft,
                    Size   = new Vector2(160f, 100f),
                    RelativePositionAxes = Axes.Y,
                    Colour = Color4.Gray.Opacity(0.9f),
                    Text   = "Audio:",
                    X      = 10f,
                    Y      = -0.3f,
                    Font   = new FontUsage("Roboto", 40f)
                },
                key[0] = GetSprite(0.05f, 0.03f, $"{gameini.GetBindable<string>(SettingsConfig.KeyBindingUp).Value}"),
                key[1] = GetSprite(0.14f, 0.03f, $"{gameini.GetBindable<string>(SettingsConfig.KeyBindingLeft).Value}"),
                key[2] = GetSprite(0.23f, 0.03f, $"{gameini.GetBindable<string>(SettingsConfig.KeyBindingDown).Value}"),
                key[3] = GetSprite(0.32f, 0.03f, $"{gameini.GetBindable<string>(SettingsConfig.KeyBindingRight).Value}"),
                GetClickBox(0.01f, 0.03f, 0),
                GetClickBox(0.1f, 0.03f, 1),
                GetClickBox(0.19f, 0.03f, 2),
                GetClickBox(0.28f, 0.03f, 3),
                new BasicSliderBar <double>
                {
                    Anchor               = Anchor.CentreLeft,
                    Origin               = Anchor.CentreLeft,
                    RelativeSizeAxes     = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size                  = new Vector2(0.2f, 0.02f),
                    Y                     = -0.2f,
                    BackgroundColour      = Color4.White,
                    SelectionColour       = Color4.Pink,
                    KeyboardStep          = 1,
                    TransferValueOnCommit = false,
                    Current               = sliderBarValue
                }
            };
        }
Ejemplo n.º 8
0
 public HardwareCorrectionOffsetClock(IClock source, BindableDouble pauseRateAdjust)
     : base(source)
 {
     this.pauseRateAdjust = pauseRateAdjust;
 }
Ejemplo n.º 9
0
        public TestCaseScrollingHitObjects()
        {
            OsuSpriteText             timeRangeText;
            SpeedAdjustmentCollection adjustmentCollection;

            timeRangeBindable = new BindableDouble(2000)
            {
                MinValue = 200,
                MaxValue = 4000,
            };

            SliderBar <double> timeRange;

            Add(timeRange = new BasicSliderBar <double>
            {
                Size           = new Vector2(200, 20),
                SelectionColor = Color4.Pink,
                KeyboardStep   = 100
            });

            Add(timeRangeText = new OsuSpriteText
            {
                X        = 210,
                TextSize = 16,
            });

            timeRange.Current.BindTo(timeRangeBindable);
            timeRangeBindable.ValueChanged += v => timeRangeText.Text = $"Visible Range: {v:#,#.#}";
            timeRangeBindable.ValueChanged += v => bottomLabel.Text = $"t minus {v:#,#}";

            Add(new Drawable[]
            {
                new Container
                {
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.Centre,
                    Size     = new Vector2(100, 500),
                    Children = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Alpha            = 0.25f
                        },
                        adjustmentCollection = new SpeedAdjustmentCollection(Axes.Y)
                        {
                            RelativeSizeAxes = Axes.Both,
                            VisibleTimeRange = timeRangeBindable,
                            Masking          = true,
                        },
                        new OsuSpriteText
                        {
                            Text     = "t minus 0",
                            Margin   = new MarginPadding(2),
                            TextSize = 14,
                            Anchor   = Anchor.TopRight,
                        },
                        bottomLabel = new OsuSpriteText
                        {
                            Text     = "t minus x",
                            Margin   = new MarginPadding(2),
                            TextSize = 14,
                            Anchor   = Anchor.BottomRight,
                            Origin   = Anchor.BottomLeft,
                        },
                        topTime = new OsuSpriteText
                        {
                            Margin   = new MarginPadding(2),
                            TextSize = 14,
                            Anchor   = Anchor.TopLeft,
                            Origin   = Anchor.TopRight,
                        },
                        bottomTime = new OsuSpriteText
                        {
                            Margin   = new MarginPadding(2),
                            TextSize = 14,
                            Anchor   = Anchor.BottomLeft,
                            Origin   = Anchor.BottomRight,
                        },
                    }
                }
            });

            timeRangeBindable.TriggerChange();

            adjustmentCollection.Add(new TestSpeedAdjustmentContainer(new MultiplierControlPoint()));

            AddStep("Add hit object", () => adjustmentCollection.Add(new TestDrawableHitObject(new HitObject {
                StartTime = Time.Current + 2000
            })));
        }