Skip to content

Commit fbfa39e

Browse files
frenzibytepeppy
authored andcommitted
Add filter control area in song select
1 parent 5a2ad7b commit fbfa39e

File tree

3 files changed

+263
-5
lines changed

3 files changed

+263
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 NUnit.Framework;
5+
using osu.Framework.Graphics;
6+
using osu.Framework.Graphics.Containers;
7+
using osu.Game.Screens.SelectV2;
8+
9+
namespace osu.Game.Tests.Visual.SongSelectV2
10+
{
11+
public partial class TestSceneBeatmapFilterControl : SongSelectComponentsTestScene
12+
{
13+
[SetUp]
14+
public void SetUp() => Schedule(() =>
15+
{
16+
Child = new Container
17+
{
18+
RelativeSizeAxes = Axes.X,
19+
AutoSizeAxes = Axes.Y,
20+
Child = new BeatmapFilterControl
21+
{
22+
Anchor = Anchor.TopRight,
23+
Origin = Anchor.TopRight,
24+
Width = 800,
25+
},
26+
};
27+
});
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
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+
}

osu.Game/Screens/SelectV2/SongSelect.cs

+20-5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public abstract partial class SongSelect : ScreenWithBeatmapBackground
5050

5151
private BeatmapCarousel carousel = null!;
5252

53+
private BeatmapFilterControl filterControl = null!;
5354
private BeatmapInfoWedge infoWedge = null!;
5455
private BeatmapWedgesArea wedgesArea = null!;
5556
private FillFlowContainer wedgesContainer = null!;
@@ -118,12 +119,22 @@ private void load()
118119
new Container
119120
{
120121
RelativeSizeAxes = Axes.Both,
121-
Child = carousel = new BeatmapCarousel
122+
Children = new CompositeDrawable[]
122123
{
123-
RequestSelectBeatmap = b => Beatmap.Value = beatmaps.GetWorkingBeatmap(b),
124-
RequestPresentBeatmap = _ => OnStart(),
125-
RelativeSizeAxes = Axes.Both
126-
},
124+
carousel = new BeatmapCarousel
125+
{
126+
RequestSelectBeatmap = b => Beatmap.Value = beatmaps.GetWorkingBeatmap(b),
127+
RequestPresentBeatmap = _ => OnStart(),
128+
RelativeSizeAxes = Axes.Both,
129+
},
130+
filterControl = new BeatmapFilterControl
131+
{
132+
Anchor = Anchor.TopRight,
133+
Origin = Anchor.TopRight,
134+
RelativeSizeAxes = Axes.X,
135+
Width = 1.1f,
136+
},
137+
}
127138
},
128139
},
129140
}
@@ -164,6 +175,7 @@ public override void OnEntering(ScreenTransitionEvent e)
164175

165176
infoWedge.Show();
166177
wedgesArea.Show();
178+
filterControl.Show();
167179

168180
modSelectOverlay.State.BindValueChanged(onModSelectStateChanged, true);
169181
modSelectOverlay.SelectedMods.BindTo(Mods);
@@ -181,6 +193,7 @@ public override void OnResuming(ScreenTransitionEvent e)
181193

182194
infoWedge.Show();
183195
wedgesArea.Show();
196+
filterControl.Show();
184197

185198
// required due to https://github.com/ppy/osu-framework/issues/3218
186199
modSelectOverlay.SelectedMods.Disabled = false;
@@ -197,6 +210,7 @@ public override void OnSuspending(ScreenTransitionEvent e)
197210

198211
infoWedge.Hide();
199212
wedgesArea.Hide();
213+
filterControl.Hide();
200214

201215
carousel.VisuallyFocusSelected = true;
202216

@@ -209,6 +223,7 @@ public override bool OnExiting(ScreenExitEvent e)
209223

210224
infoWedge.Hide();
211225
wedgesArea.Hide();
226+
filterControl.Hide();
212227

213228
return base.OnExiting(e);
214229
}

0 commit comments

Comments
 (0)