1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Merge pull request #24733 from Joehuu/wedge-title-artist-link

Link new song select wedge title and artist to search text box
This commit is contained in:
Dean Herbert 2023-09-07 14:51:43 +09:00 committed by GitHub
commit 281c2f6de1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 24 deletions

View File

@ -141,9 +141,9 @@ namespace osu.Game.Screens.Select
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)),
},
},
},
@ -176,12 +176,6 @@ namespace osu.Game.Screens.Select
},
loading = new LoadingLayer(true)
};
void searchOnSongSelect(string text)
{
if (songSelect != null)
songSelect.FilterControl.CurrentTextSearch.Value = text;
}
}
private void updateStatistics()

View File

@ -15,6 +15,7 @@ using osu.Game.Graphics;
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;
@ -270,38 +271,59 @@ namespace osu.Game.Screens.Select
}
[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;
}
}
}
}

View File

@ -390,6 +390,15 @@ namespace osu.Game.Screens.Select
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>