1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-01 11:33:03 +08:00

Merge pull request #31435 from peppy/star-range-display-quality

Fix star range display looking a bit bad when changing opacity
This commit is contained in:
Bartłomiej Dach 2025-01-07 14:58:00 +01:00 committed by GitHub
commit 5431a08b35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 94 additions and 44 deletions

View File

@ -3,29 +3,71 @@
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Tests.Visual.OnlinePlay;
using osu.Game.Tests.Resources;
using osuTK;
namespace osu.Game.Tests.Visual.Multiplayer
{
public partial class TestSceneStarRatingRangeDisplay : OnlinePlayTestScene
public partial class TestSceneStarRatingRangeDisplay : OsuTestScene
{
public override void SetUpSteps()
{
base.SetUpSteps();
private readonly Room room = new Room();
AddStep("create display", () =>
protected override void LoadComplete()
{
SelectedRoom.Value = new Room();
base.LoadComplete();
Child = new StarRatingRangeDisplay(SelectedRoom.Value)
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(10),
Children = new Drawable[]
{
new StarRatingRangeDisplay(room)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
Origin = Anchor.Centre,
Scale = new Vector2(5),
},
new StarRatingRangeDisplay(room)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(2),
},
new StarRatingRangeDisplay(room)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(1),
},
new StarRatingRangeDisplay(room)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0.2f,
Scale = new Vector2(5),
},
new StarRatingRangeDisplay(room)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0.2f,
Scale = new Vector2(2),
},
new StarRatingRangeDisplay(room)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0.2f,
Scale = new Vector2(1),
},
}
};
});
}
[Test]
@ -33,10 +75,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
AddStep("set playlist", () =>
{
SelectedRoom.Value!.Playlist =
room.Playlist =
[
new PlaylistItem(new BeatmapInfo { StarRating = min }),
new PlaylistItem(new BeatmapInfo { StarRating = max }),
new PlaylistItem(new BeatmapInfo { StarRating = min }) { ID = TestResources.GetNextTestID() },
new PlaylistItem(new BeatmapInfo { StarRating = max }) { ID = TestResources.GetNextTestID() },
];
});
}

View File

@ -14,7 +14,6 @@ using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Online.Rooms;
using osuTK;
using Container = osu.Framework.Graphics.Containers.Container;
namespace osu.Game.Screens.OnlinePlay.Components
{
@ -30,6 +29,8 @@ namespace osu.Game.Screens.OnlinePlay.Components
private StarRatingDisplay maxDisplay = null!;
private Drawable maxBackground = null!;
private BufferedContainer bufferedContent = null!;
public StarRatingRangeDisplay(Room room)
{
this.room = room;
@ -41,11 +42,15 @@ namespace osu.Game.Screens.OnlinePlay.Components
{
InternalChildren = new Drawable[]
{
new Container
new CircularContainer
{
RelativeSizeAxes = Axes.Both,
AutoSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 1,
// Stops artifacting from boxes drawn behind wrong colour boxes (and edge pixels adding up to higher opacity).
Padding = new MarginPadding(-0.1f),
Child = bufferedContent = new BufferedContainer(pixelSnapping: true, cachedFrameBuffer: true)
{
AutoSizeAxes = Axes.Both,
Children = new[]
{
minBackground = new Box
@ -53,16 +58,14 @@ namespace osu.Game.Screens.OnlinePlay.Components
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f),
Size = new Vector2(1, 0.5f),
},
maxBackground = new Box
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f),
},
}
Size = new Vector2(1, 0.5f),
},
new FillFlowContainer
{
@ -73,6 +76,9 @@ namespace osu.Game.Screens.OnlinePlay.Components
maxDisplay = new StarRatingDisplay(default, StarRatingDisplaySize.Range)
}
}
}
}
},
};
}
@ -121,6 +127,8 @@ namespace osu.Game.Screens.OnlinePlay.Components
minBackground.Colour = colours.ForStarDifficulty(minDifficulty.Stars);
maxBackground.Colour = colours.ForStarDifficulty(maxDifficulty.Stars);
bufferedContent.ForceRedraw();
}
protected override void Dispose(bool isDisposing)