Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link new song select wedge title and artist to search text box #24733

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 3 additions & 9 deletions osu.Game/Screens/Select/BeatmapDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ public BeatmapDetails()
LayoutEasing = Easing.OutQuad,
Children = new[]
{
description = new MetadataSectionDescription(searchOnSongSelect),
source = new MetadataSectionSource(searchOnSongSelect),
tags = new MetadataSectionTags(searchOnSongSelect),
description = new MetadataSectionDescription(query => songSelect?.Search(query)),
source = new MetadataSectionSource(query => songSelect?.Search(query)),
tags = new MetadataSectionTags(query => songSelect?.Search(query)),
},
},
},
Expand Down Expand Up @@ -176,12 +176,6 @@ public BeatmapDetails()
},
loading = new LoadingLayer(true)
};

void searchOnSongSelect(string text)
{
if (songSelect != null)
songSelect.FilterControl.CurrentTextSearch.Value = text;
}
}

private void updateStatistics()
Expand Down
52 changes: 37 additions & 15 deletions osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using osu.Game.Graphics.Sprites;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;

Expand Down Expand Up @@ -270,38 +271,59 @@ public WedgeInfoText(WorkingBeatmap working)
}

[BackgroundDependencyLoader]
private void load()
private void load(SongSelect? songSelect, LocalisationManager localisation)
{
var metadata = working.Metadata;

var titleText = new RomanisableString(metadata.TitleUnicode, metadata.Title);
var artistText = new RomanisableString(metadata.ArtistUnicode, metadata.Artist);

Child = new FillFlowContainer
{
Name = "Top-left aligned metadata",
Direction = FillDirection.Vertical,
Padding = new MarginPadding { Left = text_margin, Right = text_margin + shear_width, Top = 12 },
Padding = new MarginPadding { Left = text_margin, Top = 12 },
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Children = new Drawable[]
{
TitleLabel = new TruncatingSpriteText
new OsuHoverContainer
{
Shadow = true,
Text = new RomanisableString(metadata.TitleUnicode, metadata.Title),
Font = OsuFont.TorusAlternate.With(size: 40, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Both,
Action = () => songSelect?.Search(titleText.GetPreferred(localisation.CurrentParameters.Value.PreferOriginalScript)),
Child = TitleLabel = new TruncatingSpriteText
{
Shadow = true,
Text = titleText,
Font = OsuFont.TorusAlternate.With(size: 40, weight: FontWeight.SemiBold),
},
},
ArtistLabel = new TruncatingSpriteText
new OsuHoverContainer
{
// TODO : figma design has a diffused shadow, instead of the solid one present here, not possible currently as far as i'm aware.
Shadow = true,
Text = new RomanisableString(metadata.ArtistUnicode, metadata.Artist),
// Not sure if this should be semi bold or medium
Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X,
}
AutoSizeAxes = Axes.Both,
Action = () => songSelect?.Search(artistText.GetPreferred(localisation.CurrentParameters.Value.PreferOriginalScript)),
Child = ArtistLabel = new TruncatingSpriteText
{
// TODO : figma design has a diffused shadow, instead of the solid one present here, not possible currently as far as i'm aware.
Shadow = true,
Text = artistText,
// Not sure if this should be semi bold or medium
Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold),
},
},
}
};
}

protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();

// best effort to confine the auto-sized text to wedge bounds
// the artist label doesn't have an extra text_margin as it doesn't touch the right metadata
TitleLabel.MaxWidth = DrawWidth - text_margin * 2 - shear_width;
ArtistLabel.MaxWidth = DrawWidth - text_margin - shear_width;
}
}
}
}
9 changes: 9 additions & 0 deletions osu.Game/Screens/Select/SongSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,15 @@ public void Edit(BeatmapInfo? beatmapInfo = null)
this.Push(new EditorLoader());
}

/// <summary>
/// Set the query to the search text box.
/// </summary>
/// <param name="query">The string to search.</param>
public void Search(string query)
{
FilterControl.CurrentTextSearch.Value = query;
}

/// <summary>
/// Call to make a selection and perform the default action for this SongSelect.
/// </summary>
Expand Down