1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:52:55 +08:00

Merge pull request #18437 from peppy/fa-playlist-category

Add featured artist playlist category
This commit is contained in:
Dean Herbert 2022-05-28 01:28:21 +09:00 committed by GitHub
commit 03d9ca0d8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 59 additions and 10 deletions

View File

@ -124,13 +124,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
Status = { Value = new RoomStatusOpen() },
Category = { Value = RoomCategory.Spotlight },
}),
createLoungeRoom(new Room
{
Name = { Value = "Featured artist room" },
Status = { Value = new RoomStatusOpen() },
Category = { Value = RoomCategory.FeaturedArtist },
}),
}
};
});
AddUntilStep("wait for panel load", () => rooms.Count == 5);
AddUntilStep("wait for panel load", () => rooms.Count == 6);
AddUntilStep("correct status text", () => rooms.ChildrenOfType<OsuSpriteText>().Count(s => s.Text.ToString().StartsWith("Currently playing", StringComparison.Ordinal)) == 2);
AddUntilStep("correct status text", () => rooms.ChildrenOfType<OsuSpriteText>().Count(s => s.Text.ToString().StartsWith("Ready to play", StringComparison.Ordinal)) == 3);
AddUntilStep("correct status text", () => rooms.ChildrenOfType<OsuSpriteText>().Count(s => s.Text.ToString().StartsWith("Ready to play", StringComparison.Ordinal)) == 4);
}
[Test]

View File

@ -4,6 +4,7 @@
using System;
using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Beatmaps;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
@ -188,6 +189,24 @@ namespace osu.Game.Graphics
}
}
/// <summary>
/// Retrieves the main accent colour for a <see cref="RoomCategory"/>.
/// </summary>
public Color4? ForRoomCategory(RoomCategory roomCategory)
{
switch (roomCategory)
{
case RoomCategory.Spotlight:
return Green2;
case RoomCategory.FeaturedArtist:
return Blue2;
default:
return null;
}
}
/// <summary>
/// Returns a foreground text colour that is supposed to contrast well with
/// the supplied <paramref name="backgroundColour"/>.

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.ComponentModel;
namespace osu.Game.Online.Rooms
{
public enum RoomCategory
@ -8,5 +10,8 @@ namespace osu.Game.Online.Rooms
// used for osu-web deserialization so names shouldn't be changed.
Normal,
Spotlight,
[Description("Featured Artist")]
FeaturedArtist,
}
}

View File

@ -30,8 +30,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
{
status.BindValueChanged(s =>
{
this.FadeColour(category.Value == RoomCategory.Spotlight ? colours.Pink : s.NewValue.GetAppropriateColour(colours)
, transitionDuration);
this.FadeColour(colours.ForRoomCategory(category.Value) ?? s.NewValue.GetAppropriateColour(colours), transitionDuration);
}, true);
}
}

View File

@ -237,7 +237,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
roomCategory.BindTo(Room.Category);
roomCategory.BindValueChanged(c =>
{
if (c.NewValue == RoomCategory.Spotlight)
if (c.NewValue > RoomCategory.Normal)
specialCategoryPill.Show();
else
specialCategoryPill.Hide();

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
@ -13,6 +14,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
public class RoomSpecialCategoryPill : OnlinePlayComposite
{
private SpriteText text;
private PillContainer pill;
[Resolved]
private OsuColour colours { get; set; }
public RoomSpecialCategoryPill()
{
@ -20,9 +25,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load()
{
InternalChild = new PillContainer
InternalChild = pill = new PillContainer
{
Background =
{
@ -43,7 +48,14 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
base.LoadComplete();
Category.BindValueChanged(c => text.Text = c.NewValue.ToString(), true);
Category.BindValueChanged(c =>
{
text.Text = c.NewValue.GetLocalisableDescription();
var backgroundColour = colours.ForRoomCategory(Category.Value);
if (backgroundColour != null)
pill.Background.Colour = backgroundColour.Value;
}, true);
}
}
}

View File

@ -128,7 +128,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
foreach (var room in roomFlow)
{
roomFlow.SetLayoutPosition(room, room.Room.Category.Value == RoomCategory.Spotlight
roomFlow.SetLayoutPosition(room, room.Room.Category.Value > RoomCategory.Normal
// Always show spotlight playlists at the top of the listing.
? float.MinValue
: -(room.Room.RoomID.Value ?? 0));

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -49,6 +50,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
case PlaylistsCategory.Spotlight:
criteria.Category = @"spotlight";
break;
case PlaylistsCategory.FeaturedArtist:
criteria.Category = @"featured_artist";
break;
}
return criteria;
@ -73,7 +78,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{
Any,
Normal,
Spotlight
Spotlight,
[Description("Featured Artist")]
FeaturedArtist,
}
}
}