-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Implement song select v2 difficulty name content component #29415
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
46d41cb
Add base song select components test scene
Joehuu 625c6fc
Implement song select v2 difficulty name content component
Joehuu 2b41f71
Workaround single-frame layout issues with `{Link|Text|Fill}FlowConta…
Joehuu f8796e3
Move resizing width and background logic to `SongSelectComponentsTest…
Joehuu c24f144
Directly resolve `IBindable<WorkingBeatmap>` by making a local varian…
Joehuu 2174510
Move other V2 tests to new test namespace
peppy 11bd0c9
Inline single-frame layout issue comment instead
Joehuu 6f2bc7e
Use `Content` override instead
Joehuu 1665d9a
Fix failing test setup
peppy e603888
Update remaining tests to use new base class (and tidy up `V2` suffixes)
peppy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
osu.Game.Tests/Visual/SongSelectV2/SongSelectComponentsTestScene.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Shapes; | ||
using osu.Framework.Testing; | ||
using osu.Game.Overlays; | ||
|
||
namespace osu.Game.Tests.Visual.SongSelectV2 | ||
{ | ||
public abstract partial class SongSelectComponentsTestScene : OsuTestScene | ||
{ | ||
[Cached] | ||
protected readonly OverlayColourProvider ColourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine); | ||
|
||
protected override Container<Drawable> Content { get; } = new Container | ||
{ | ||
RelativeSizeAxes = Axes.X, | ||
AutoSizeAxes = Axes.Y, | ||
Padding = new MarginPadding(10), | ||
}; | ||
|
||
private Container? resizeContainer; | ||
private float relativeWidth; | ||
|
||
[BackgroundDependencyLoader] | ||
private void load() | ||
{ | ||
base.Content.Child = resizeContainer = new Container | ||
{ | ||
RelativeSizeAxes = Axes.X, | ||
AutoSizeAxes = Axes.Y, | ||
Padding = new MarginPadding(10), | ||
Width = relativeWidth, | ||
Children = new Drawable[] | ||
{ | ||
new Box | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Colour = ColourProvider.Background5, | ||
}, | ||
Content | ||
} | ||
}; | ||
|
||
AddSliderStep("change relative width", 0, 1f, 1f, v => | ||
{ | ||
if (resizeContainer != null) | ||
resizeContainer.Width = v; | ||
|
||
relativeWidth = v; | ||
}); | ||
} | ||
|
||
[SetUpSteps] | ||
public virtual void SetUpSteps() | ||
{ | ||
AddStep("reset dependencies", () => | ||
{ | ||
Beatmap.SetDefault(); | ||
SelectedMods.SetDefault(); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
osu.Game.Tests/Visual/SongSelectV2/TestSceneDifficultyNameContent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Linq; | ||
using NUnit.Framework; | ||
using osu.Framework.Localisation; | ||
using osu.Framework.Testing; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Graphics.Containers; | ||
using osu.Game.Graphics.Sprites; | ||
using osu.Game.Screens.SelectV2.Wedge; | ||
|
||
namespace osu.Game.Tests.Visual.SongSelectV2 | ||
{ | ||
public partial class TestSceneDifficultyNameContent : SongSelectComponentsTestScene | ||
{ | ||
private DifficultyNameContent? difficultyNameContent; | ||
|
||
[Test] | ||
public void TestLocalBeatmap() | ||
{ | ||
AddStep("set component", () => Child = difficultyNameContent = new LocalDifficultyNameContent()); | ||
|
||
AddAssert("difficulty name is not set", () => LocalisableString.IsNullOrEmpty(difficultyNameContent.ChildrenOfType<TruncatingSpriteText>().Single().Text)); | ||
AddAssert("author is not set", () => LocalisableString.IsNullOrEmpty(difficultyNameContent.ChildrenOfType<OsuHoverContainer>().Single().ChildrenOfType<OsuSpriteText>().Single().Text)); | ||
|
||
AddStep("set beatmap", () => Beatmap.Value = CreateWorkingBeatmap(new Beatmap | ||
{ | ||
BeatmapInfo = new BeatmapInfo | ||
{ | ||
DifficultyName = "really long difficulty name that gets truncated", | ||
Metadata = new BeatmapMetadata | ||
{ | ||
Author = { Username = "really long username that is autosized" }, | ||
}, | ||
OnlineID = 1, | ||
} | ||
})); | ||
|
||
AddAssert("difficulty name is set", () => !LocalisableString.IsNullOrEmpty(difficultyNameContent.ChildrenOfType<TruncatingSpriteText>().Single().Text)); | ||
AddAssert("author is set", () => !LocalisableString.IsNullOrEmpty(difficultyNameContent.ChildrenOfType<OsuHoverContainer>().Single().ChildrenOfType<OsuSpriteText>().Single().Text)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Game.Graphics; | ||
using osu.Game.Graphics.Containers; | ||
using osu.Game.Graphics.Sprites; | ||
using osu.Game.Localisation; | ||
using osu.Game.Overlays; | ||
|
||
namespace osu.Game.Screens.SelectV2.Wedge | ||
{ | ||
public abstract partial class DifficultyNameContent : CompositeDrawable | ||
{ | ||
protected OsuSpriteText DifficultyName = null!; | ||
private OsuSpriteText mappedByLabel = null!; | ||
protected OsuHoverContainer MapperLink = null!; | ||
protected OsuSpriteText MapperName = null!; | ||
|
||
protected DifficultyNameContent() | ||
{ | ||
RelativeSizeAxes = Axes.X; | ||
AutoSizeAxes = Axes.Y; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load() | ||
{ | ||
InternalChild = new FillFlowContainer | ||
{ | ||
RelativeSizeAxes = Axes.X, | ||
AutoSizeAxes = Axes.Y, | ||
Direction = FillDirection.Horizontal, | ||
Children = new Drawable[] | ||
{ | ||
DifficultyName = new TruncatingSpriteText | ||
{ | ||
Anchor = Anchor.BottomLeft, | ||
Origin = Anchor.BottomLeft, | ||
Font = OsuFont.GetFont(weight: FontWeight.SemiBold), | ||
}, | ||
mappedByLabel = new OsuSpriteText | ||
{ | ||
Anchor = Anchor.BottomLeft, | ||
Origin = Anchor.BottomLeft, | ||
// TODO: better null display? beatmap carousel panels also just show this text currently. | ||
Text = " mapped by ", | ||
Font = OsuFont.GetFont(size: 14), | ||
}, | ||
// This is not a `LinkFlowContainer` as there are single-frame layout issues when Update() | ||
// is being used for layout, see https://github.com/ppy/osu-framework/issues/3369. | ||
MapperLink = new MapperLinkContainer | ||
{ | ||
Anchor = Anchor.BottomLeft, | ||
Origin = Anchor.BottomLeft, | ||
AutoSizeAxes = Axes.Both, | ||
Child = MapperName = new OsuSpriteText | ||
{ | ||
Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 14), | ||
} | ||
}, | ||
} | ||
}; | ||
} | ||
|
||
protected override void Update() | ||
{ | ||
base.Update(); | ||
|
||
// truncate difficulty name when width exceeds bounds, prioritizing mapper name display | ||
DifficultyName.MaxWidth = Math.Max(DrawWidth - mappedByLabel.DrawWidth | ||
- MapperName.DrawWidth, 0); | ||
} | ||
|
||
private partial class MapperLinkContainer : OsuHoverContainer | ||
{ | ||
[BackgroundDependencyLoader] | ||
private void load(OverlayColourProvider? overlayColourProvider, OsuColour colours) | ||
{ | ||
TooltipText = ContextMenuStrings.ViewProfile; | ||
IdleColour = overlayColourProvider?.Light2 ?? colours.Blue; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using this in many other places? Could probably just do away with this class.
But also, if you're going to make a class like this you probably want to make use of
Content
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it will be used for all the individual components that the wedge has. Just wanted to share the resizing and background logic so it can help find layout issues with limited width.
Totally forgot the
Content
thing.