A game framework written with osu! in mind.
at master 66 lines 2.5 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using osu.Framework.Allocation; 5using osu.Framework.Graphics; 6using osu.Framework.Graphics.Containers; 7using osu.Framework.Graphics.Sprites; 8using osu.Framework.Graphics.UserInterface; 9 10namespace osu.Framework.Testing.Drawables.Sections 11{ 12 public class ToolbarRateSection : ToolbarSection 13 { 14 [BackgroundDependencyLoader] 15 private void load(TestBrowser browser) 16 { 17 Padding = new MarginPadding { Horizontal = 5 }; 18 19 BasicSliderBar<double> rateAdjustSlider; 20 SpriteText rateText; 21 ClickableContainer clickableReset; 22 23 InternalChild = new GridContainer 24 { 25 RelativeSizeAxes = Axes.Both, 26 ColumnDimensions = new[] 27 { 28 new Dimension(GridSizeMode.AutoSize), 29 new Dimension(GridSizeMode.AutoSize), 30 new Dimension(), 31 }, 32 Content = new[] 33 { 34 new Drawable[] 35 { 36 new SpriteText 37 { 38 Padding = new MarginPadding(5) { Right = 0 }, 39 Text = "Rate:", 40 Font = FrameworkFont.Condensed 41 }, 42 clickableReset = new ClickableContainer 43 { 44 AutoSizeAxes = Axes.Both, 45 Child = rateText = new SpriteText 46 { 47 Padding = new MarginPadding(5), 48 Width = 45, 49 Colour = FrameworkColour.Yellow, 50 Font = FrameworkFont.Condensed 51 }, 52 }, 53 rateAdjustSlider = new BasicSliderBar<double> 54 { 55 RelativeSizeAxes = Axes.Both, 56 Current = browser.PlaybackRate 57 }, 58 } 59 } 60 }; 61 62 rateAdjustSlider.Current.BindValueChanged(e => rateText.Text = e.NewValue.ToString("0%"), true); 63 clickableReset.Action = () => rateAdjustSlider.Current.SetDefault(); 64 } 65 } 66}