1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 04:02:59 +08:00

Merge branch 'master' into mod-overlay/incompatibility-panels-clickable

This commit is contained in:
Salman Ahmed 2022-04-22 22:19:42 +03:00
commit 5120faa830
5 changed files with 49 additions and 58 deletions

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Overlays.Settings;
using osu.Game.Overlays.Settings.Sections;
using osu.Game.Overlays.Settings.Sections.Input;
using osuTK.Input;
@ -34,6 +35,29 @@ namespace osu.Game.Tests.Visual.Settings
});
}
[Test]
public void TestQuickFiltering()
{
AddStep("set filter", () =>
{
settings.SectionsContainer.ChildrenOfType<SearchTextBox>().First().Current.Value = "scaling";
});
AddUntilStep("wait for items to load", () => settings.SectionsContainer.ChildrenOfType<IFilterable>().Any());
AddAssert("ensure all items match filter", () => settings.SectionsContainer
.ChildrenOfType<SettingsSection>().Where(f => f.IsPresent)
.All(section =>
section.Children.Where(f => f.IsPresent)
.OfType<ISettingsItem>()
.OfType<IFilterable>()
.Where(f => !(f is IHasFilterableChildren))
.All(f => f.FilterTerms.Any(t => t.Contains("scaling")))
));
AddAssert("ensure section is current", () => settings.CurrentSection.Value is GraphicsSection);
}
[Test]
public void ToggleVisibility()
{

View File

@ -7,7 +7,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK;
@ -16,11 +15,11 @@ namespace osu.Game.Beatmaps.Drawables
{
internal class DifficultyIconTooltip : VisibilityContainer, ITooltip<DifficultyIconTooltipContent>
{
private readonly OsuSpriteText difficultyName, starRating;
private readonly Box background;
private readonly FillFlowContainer difficultyFlow;
private OsuSpriteText difficultyName;
private StarRatingDisplay starRating;
public DifficultyIconTooltip()
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AutoSizeAxes = Axes.Both;
Masking = true;
@ -28,9 +27,10 @@ namespace osu.Game.Beatmaps.Drawables
Children = new Drawable[]
{
background = new Box
new Box
{
Alpha = 0.9f,
Colour = colours.Gray3,
RelativeSizeAxes = Axes.Both
},
new FillFlowContainer
@ -40,6 +40,7 @@ namespace osu.Game.Beatmaps.Drawables
AutoSizeEasing = Easing.OutQuint,
Direction = FillDirection.Vertical,
Padding = new MarginPadding(10),
Spacing = new Vector2(5),
Children = new Drawable[]
{
difficultyName = new OsuSpriteText
@ -48,57 +49,27 @@ namespace osu.Game.Beatmaps.Drawables
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Bold),
},
difficultyFlow = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
starRating = new OsuSpriteText
starRating = new StarRatingDisplay(default, StarRatingDisplaySize.Small)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular),
},
new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Margin = new MarginPadding { Left = 4 },
Icon = FontAwesome.Solid.Star,
Size = new Vector2(12),
},
}
}
}
}
};
}
[Resolved]
private OsuColour colours { get; set; }
[BackgroundDependencyLoader]
private void load()
{
background.Colour = colours.Gray3;
}
private readonly IBindable<StarDifficulty> starDifficulty = new Bindable<StarDifficulty>();
private DifficultyIconTooltipContent displayedContent;
public void SetContent(DifficultyIconTooltipContent content)
{
difficultyName.Text = content.BeatmapInfo.DifficultyName;
if (displayedContent != null)
starRating.Current.UnbindFrom(displayedContent.Difficulty);
starDifficulty.UnbindAll();
starDifficulty.BindTo(content.Difficulty);
starDifficulty.BindValueChanged(difficulty =>
{
starRating.Text = $"{difficulty.NewValue.Stars:0.##}";
difficultyFlow.Colour = colours.ForStarDifficulty(difficulty.NewValue.Stars);
}, true);
displayedContent = content;
starRating.Current.BindTarget = displayedContent.Difficulty;
difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName;
}
public void Move(Vector2 pos) => Position = pos;

View File

@ -100,10 +100,9 @@ namespace osu.Game.Overlays.Settings
public IEnumerable<string> Keywords { get; set; }
public bool MatchingFilter
{
set => Alpha = value ? 1 : 0;
}
public override bool IsPresent => base.IsPresent && MatchingFilter;
public bool MatchingFilter { get; set; } = true;
public bool FilteringActive { get; set; }

View File

@ -21,6 +21,8 @@ namespace osu.Game.Overlays.Settings
protected FillFlowContainer FlowContent;
protected override Container<Drawable> Content => FlowContent;
public override bool IsPresent => base.IsPresent && MatchingFilter;
private IBindable<SettingsSection> selectedSection;
private Box dim;
@ -38,10 +40,7 @@ namespace osu.Game.Overlays.Settings
private const int header_size = 24;
private const int border_size = 4;
public bool MatchingFilter
{
set => this.FadeTo(value ? 1 : 0);
}
public bool MatchingFilter { get; set; } = true;
public bool FilteringActive { get; set; }

View File

@ -163,6 +163,7 @@ namespace osu.Game.Overlays
Sidebar?.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint);
searchTextBox.TakeFocus();
searchTextBox.HoldFocus = true;
}
@ -213,7 +214,6 @@ namespace osu.Game.Overlays
loading.Hide();
searchTextBox.Current.BindValueChanged(term => SectionsContainer.SearchTerm = term.NewValue, true);
searchTextBox.TakeFocus();
loadSidebarButtons();
});
@ -284,11 +284,7 @@ namespace osu.Game.Overlays
public string SearchTerm
{
get => SearchContainer.SearchTerm;
set
{
SearchContainer.SearchTerm = value;
InvalidateScrollPosition();
}
set => SearchContainer.SearchTerm = value;
}
protected override FlowContainer<SettingsSection> CreateScrollContentContainer()
@ -307,6 +303,8 @@ namespace osu.Game.Overlays
Colour = colourProvider.Background4,
RelativeSizeAxes = Axes.Both
};
SearchContainer.FilterCompleted += InvalidateScrollPosition;
}
protected override void UpdateAfterChildren()