mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Merge pull request #23563 from timiimit/organize-room-pills
Add common `OnlinePlayPill` for all online room pills
This commit is contained in:
commit
30c31d7418
@ -3,39 +3,14 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public partial class MatchTypePill : OnlinePlayComposite
|
||||
public partial class MatchTypePill : OnlinePlayPill
|
||||
{
|
||||
private OsuTextFlowContainer textFlow;
|
||||
|
||||
public MatchTypePill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = new PillContainer
|
||||
{
|
||||
Child = textFlow = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -45,8 +20,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
|
||||
private void onMatchTypeChanged(ValueChangedEvent<MatchType> type)
|
||||
{
|
||||
textFlow.Clear();
|
||||
textFlow.AddText(type.NewValue.GetLocalisableDescription());
|
||||
TextFlow.Text = type.NewValue.GetLocalisableDescription();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public abstract partial class OnlinePlayPill : OnlinePlayComposite
|
||||
{
|
||||
protected PillContainer Pill { get; private set; } = null!;
|
||||
protected OsuTextFlowContainer TextFlow { get; private set; } = null!;
|
||||
protected virtual FontUsage Font => OsuFont.GetFont(size: 12);
|
||||
|
||||
protected OnlinePlayPill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = Pill = new PillContainer
|
||||
{
|
||||
Child = TextFlow = new OsuTextFlowContainer(s => s.Font = Font)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -5,40 +5,16 @@
|
||||
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// A pill that displays the playlist item count.
|
||||
/// </summary>
|
||||
public partial class PlaylistCountPill : OnlinePlayComposite
|
||||
public partial class PlaylistCountPill : OnlinePlayPill
|
||||
{
|
||||
private OsuTextFlowContainer count;
|
||||
|
||||
public PlaylistCountPill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = new PillContainer
|
||||
{
|
||||
Child = count = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -55,10 +31,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
? Playlist.Count(i => !i.Expired)
|
||||
: PlaylistItemStats.Value.CountActive;
|
||||
|
||||
count.Clear();
|
||||
count.AddText(activeItems.ToLocalisableString(), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
||||
count.AddText(" ");
|
||||
count.AddText("Beatmap".ToQuantity(activeItems, ShowQuantityAs.None));
|
||||
TextFlow.Clear();
|
||||
TextFlow.AddText(activeItems.ToLocalisableString(), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
||||
TextFlow.AddText(" ");
|
||||
TextFlow.AddText("Beatmap".ToQuantity(activeItems, ShowQuantityAs.None));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,39 +3,14 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public partial class QueueModePill : OnlinePlayComposite
|
||||
public partial class QueueModePill : OnlinePlayPill
|
||||
{
|
||||
private OsuTextFlowContainer textFlow;
|
||||
|
||||
public QueueModePill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = new PillContainer
|
||||
{
|
||||
Child = textFlow = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -45,8 +20,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
|
||||
private void onQueueModeChanged(ValueChangedEvent<QueueMode> mode)
|
||||
{
|
||||
textFlow.Clear();
|
||||
textFlow.AddText(mode.NewValue.GetLocalisableDescription());
|
||||
TextFlow.Text = mode.NewValue.GetLocalisableDescription();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,58 +5,30 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public partial class RoomSpecialCategoryPill : OnlinePlayComposite
|
||||
public partial class RoomSpecialCategoryPill : OnlinePlayPill
|
||||
{
|
||||
private SpriteText text;
|
||||
private PillContainer pill;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
public RoomSpecialCategoryPill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = pill = new PillContainer
|
||||
{
|
||||
Background =
|
||||
{
|
||||
Colour = colours.Pink,
|
||||
Alpha = 1
|
||||
},
|
||||
Child = text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 12),
|
||||
Colour = Color4.Black
|
||||
}
|
||||
};
|
||||
}
|
||||
protected override FontUsage Font => base.Font.With(weight: FontWeight.SemiBold);
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Pill.Background.Alpha = 1;
|
||||
TextFlow.Colour = Color4.Black;
|
||||
|
||||
Category.BindValueChanged(c =>
|
||||
{
|
||||
text.Text = c.NewValue.GetLocalisableDescription();
|
||||
|
||||
var backgroundColour = colours.ForRoomCategory(Category.Value);
|
||||
if (backgroundColour != null)
|
||||
pill.Background.Colour = backgroundColour.Value;
|
||||
TextFlow.Text = c.NewValue.GetLocalisableDescription();
|
||||
Pill.Background.Colour = colours.ForRoomCategory(c.NewValue) ?? colours.Pink;
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
@ -8,43 +8,20 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Rooms.RoomStatuses;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// A pill that displays the room's current status.
|
||||
/// </summary>
|
||||
public partial class RoomStatusPill : OnlinePlayComposite
|
||||
public partial class RoomStatusPill : OnlinePlayPill
|
||||
{
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
private PillContainer pill;
|
||||
private SpriteText statusText;
|
||||
|
||||
public RoomStatusPill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = pill = new PillContainer
|
||||
{
|
||||
Child = statusText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 12),
|
||||
Colour = Color4.Black
|
||||
}
|
||||
};
|
||||
}
|
||||
protected override FontUsage Font => base.Font.With(weight: FontWeight.SemiBold);
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
@ -54,15 +31,17 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
Status.BindValueChanged(_ => updateDisplay(), true);
|
||||
|
||||
FinishTransforms(true);
|
||||
|
||||
TextFlow.Colour = Colour4.Black;
|
||||
Pill.Background.Alpha = 1;
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
RoomStatus status = getDisplayStatus();
|
||||
|
||||
pill.Background.Alpha = 1;
|
||||
pill.Background.FadeColour(status.GetAppropriateColour(colours), 100);
|
||||
statusText.Text = status.Message;
|
||||
Pill.Background.FadeColour(status.GetAppropriateColour(colours), 100);
|
||||
TextFlow.Text = status.Message;
|
||||
}
|
||||
|
||||
private RoomStatus getDisplayStatus()
|
||||
|
Loading…
Reference in New Issue
Block a user