|
| 1 | +// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. |
| 2 | +// See the LICENCE file in the repository root for full licence text. |
| 3 | + |
| 4 | +using System; |
| 5 | +using osu.Framework.Allocation; |
| 6 | +using osu.Framework.Extensions.Color4Extensions; |
| 7 | +using osu.Framework.Graphics; |
| 8 | +using osu.Framework.Graphics.Colour; |
| 9 | +using osu.Framework.Graphics.Containers; |
| 10 | +using osu.Framework.Graphics.Shapes; |
| 11 | +using osu.Game.Collections; |
| 12 | +using osu.Game.Configuration; |
| 13 | +using osu.Game.Graphics.Containers; |
| 14 | +using osu.Game.Graphics.UserInterface; |
| 15 | +using osu.Game.Graphics.UserInterfaceV2; |
| 16 | +using osu.Game.Localisation; |
| 17 | +using osu.Game.Overlays; |
| 18 | +using osu.Game.Resources.Localisation.Web; |
| 19 | +using osu.Game.Screens.Select.Filter; |
| 20 | +using osuTK; |
| 21 | + |
| 22 | +namespace osu.Game.Screens.SelectV2 |
| 23 | +{ |
| 24 | + public partial class BeatmapFilterControl : OverlayContainer |
| 25 | + { |
| 26 | + private ShearedToggleButton showConvertedBeatmapsButton = null!; |
| 27 | + private ShearedDifficultyRangeSlider difficultyRangeSlider = null!; |
| 28 | + |
| 29 | + [Resolved] |
| 30 | + private OsuConfigManager config { get; set; } = null!; |
| 31 | + |
| 32 | + [BackgroundDependencyLoader] |
| 33 | + private void load(OverlayColourProvider colourProvider) |
| 34 | + { |
| 35 | + AutoSizeAxes = Axes.Y; |
| 36 | + |
| 37 | + InternalChildren = new Drawable[] |
| 38 | + { |
| 39 | + new Container |
| 40 | + { |
| 41 | + RelativeSizeAxes = Axes.Both, |
| 42 | + Padding = new MarginPadding { Top = -10f, Right = -40f, Left = -80f }, |
| 43 | + Child = new Container |
| 44 | + { |
| 45 | + RelativeSizeAxes = Axes.Both, |
| 46 | + Masking = true, |
| 47 | + Children = new[] |
| 48 | + { |
| 49 | + new Box |
| 50 | + { |
| 51 | + RelativeSizeAxes = Axes.Both, |
| 52 | + Width = 0.2f, |
| 53 | + Colour = ColourInfo.GradientHorizontal(colourProvider.Background4.Opacity(0f), colourProvider.Background4.Opacity(0.8f)), |
| 54 | + }, |
| 55 | + new Box |
| 56 | + { |
| 57 | + RelativePositionAxes = Axes.X, |
| 58 | + X = 0.2f, |
| 59 | + RelativeSizeAxes = Axes.Both, |
| 60 | + Width = 0.8f, |
| 61 | + Colour = colourProvider.Background4.Opacity(0.8f), |
| 62 | + }, |
| 63 | + }, |
| 64 | + } |
| 65 | + }, |
| 66 | + new ReverseChildIDFillFlowContainer<Drawable> |
| 67 | + { |
| 68 | + RelativeSizeAxes = Axes.X, |
| 69 | + AutoSizeAxes = Axes.Y, |
| 70 | + Direction = FillDirection.Vertical, |
| 71 | + Spacing = new Vector2(0f, 8f), |
| 72 | + Padding = new MarginPadding { Vertical = 15f, Right = 15f, Left = 20f }, |
| 73 | + Shear = new Vector2(OsuGame.SHEAR, 0), |
| 74 | + Children = new Drawable[] |
| 75 | + { |
| 76 | + new Container |
| 77 | + { |
| 78 | + RelativeSizeAxes = Axes.X, |
| 79 | + AutoSizeAxes = Axes.Y, |
| 80 | + Shear = -new Vector2(OsuGame.SHEAR, 0), |
| 81 | + Child = new SongSelectSearchTextBox |
| 82 | + { |
| 83 | + RelativeSizeAxes = Axes.X, |
| 84 | + HoldFocus = true, |
| 85 | + // TODO: pending implementation |
| 86 | + FilterText = "12345 matches", |
| 87 | + }, |
| 88 | + }, |
| 89 | + new GridContainer |
| 90 | + { |
| 91 | + RelativeSizeAxes = Axes.X, |
| 92 | + AutoSizeAxes = Axes.Y, |
| 93 | + Shear = -new Vector2(OsuGame.SHEAR, 0), |
| 94 | + RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, |
| 95 | + ColumnDimensions = new[] |
| 96 | + { |
| 97 | + new Dimension(), |
| 98 | + new Dimension(GridSizeMode.Absolute, 10), |
| 99 | + new Dimension(GridSizeMode.AutoSize), |
| 100 | + }, |
| 101 | + Content = new[] |
| 102 | + { |
| 103 | + new[] |
| 104 | + { |
| 105 | + difficultyRangeSlider = new ShearedDifficultyRangeSlider |
| 106 | + { |
| 107 | + RelativeSizeAxes = Axes.X, |
| 108 | + MinRange = 0.1f, |
| 109 | + }, |
| 110 | + Empty(), |
| 111 | + new Container |
| 112 | + { |
| 113 | + Size = new Vector2(210, 30), |
| 114 | + Child = showConvertedBeatmapsButton = new ShearedToggleButton |
| 115 | + { |
| 116 | + Anchor = Anchor.Centre, |
| 117 | + Origin = Anchor.Centre, |
| 118 | + Text = UserInterfaceStrings.ShowConvertedBeatmaps, |
| 119 | + Height = 30f, |
| 120 | + }, |
| 121 | + }, |
| 122 | + }, |
| 123 | + } |
| 124 | + }, |
| 125 | + new GridContainer |
| 126 | + { |
| 127 | + RelativeSizeAxes = Axes.X, |
| 128 | + AutoSizeAxes = Axes.Y, |
| 129 | + Shear = -new Vector2(OsuGame.SHEAR, 0), |
| 130 | + RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, |
| 131 | + ColumnDimensions = new[] |
| 132 | + { |
| 133 | + new Dimension(maxSize: 210), |
| 134 | + new Dimension(GridSizeMode.Absolute, 10), |
| 135 | + new Dimension(maxSize: 230), |
| 136 | + new Dimension(GridSizeMode.Absolute, 10), |
| 137 | + new Dimension(), |
| 138 | + }, |
| 139 | + Content = new[] |
| 140 | + { |
| 141 | + new[] |
| 142 | + { |
| 143 | + new Container |
| 144 | + { |
| 145 | + RelativeSizeAxes = Axes.X, |
| 146 | + Height = 32f, |
| 147 | + Child = new ShearedDropdown<SortMode>(SortStrings.Default) |
| 148 | + { |
| 149 | + RelativeSizeAxes = Axes.X, |
| 150 | + Items = Enum.GetValues<SortMode>(), |
| 151 | + }, |
| 152 | + }, |
| 153 | + Empty(), |
| 154 | + new Container |
| 155 | + { |
| 156 | + RelativeSizeAxes = Axes.X, |
| 157 | + Height = 32f, |
| 158 | + // todo: pending localisation |
| 159 | + Child = new ShearedDropdown<GroupMode>("Group by") |
| 160 | + { |
| 161 | + RelativeSizeAxes = Axes.X, |
| 162 | + Items = Enum.GetValues<GroupMode>(), |
| 163 | + }, |
| 164 | + }, |
| 165 | + Empty(), |
| 166 | + new Container |
| 167 | + { |
| 168 | + RelativeSizeAxes = Axes.X, |
| 169 | + Height = 32f, |
| 170 | + Child = new ShearedCollectionDropdown |
| 171 | + { |
| 172 | + RelativeSizeAxes = Axes.X, |
| 173 | + }, |
| 174 | + }, |
| 175 | + } |
| 176 | + } |
| 177 | + }, |
| 178 | + }, |
| 179 | + } |
| 180 | + }; |
| 181 | + } |
| 182 | + |
| 183 | + protected override void LoadComplete() |
| 184 | + { |
| 185 | + base.LoadComplete(); |
| 186 | + |
| 187 | + difficultyRangeSlider.LowerBound = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum); |
| 188 | + difficultyRangeSlider.UpperBound = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum); |
| 189 | + config.BindWith(OsuSetting.ShowConvertedBeatmaps, showConvertedBeatmapsButton.Active); |
| 190 | + } |
| 191 | + |
| 192 | + protected override void PopIn() |
| 193 | + { |
| 194 | + this.MoveToX(0, SongSelect.ENTER_DURATION, Easing.OutQuint) |
| 195 | + .FadeIn(SongSelect.ENTER_DURATION / 3, Easing.In); |
| 196 | + } |
| 197 | + |
| 198 | + protected override void PopOut() |
| 199 | + { |
| 200 | + this.MoveToX(150, SongSelect.ENTER_DURATION, Easing.OutQuint) |
| 201 | + .FadeOut(SongSelect.ENTER_DURATION / 3, Easing.In); |
| 202 | + } |
| 203 | + |
| 204 | + private partial class SongSelectSearchTextBox : ShearedFilterTextBox |
| 205 | + { |
| 206 | + protected override InnerSearchTextBox CreateInnerTextBox() => new InnerTextBox(); |
| 207 | + |
| 208 | + private partial class InnerTextBox : InnerFilterTextBox |
| 209 | + { |
| 210 | + public override bool HandleLeftRightArrows => false; |
| 211 | + } |
| 212 | + } |
| 213 | + } |
| 214 | +} |
0 commit comments