mirror of
https://github.com/osukey/osukey.git
synced 2025-05-01 19:57:25 +09:00
Make used pills inherit from a common one
This commit is contained in:
parent
10d6f9ea5a
commit
04893064f0
@ -13,29 +13,8 @@ using osu.Game.Online.Rooms;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
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()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
@ -5,40 +5,17 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A pill that displays the playlist item count.
|
/// A pill that displays the playlist item count.
|
||||||
/// </summary>
|
/// </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()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -55,10 +32,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
? Playlist.Count(i => !i.Expired)
|
? Playlist.Count(i => !i.Expired)
|
||||||
: PlaylistItemStats.Value.CountActive;
|
: PlaylistItemStats.Value.CountActive;
|
||||||
|
|
||||||
count.Clear();
|
textFlow.Clear();
|
||||||
count.AddText(activeItems.ToLocalisableString(), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
textFlow.AddText(activeItems.ToLocalisableString(), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
||||||
count.AddText(" ");
|
textFlow.AddText(" ");
|
||||||
count.AddText("Beatmap".ToQuantity(activeItems, ShowQuantityAs.None));
|
textFlow.AddText("Beatmap".ToQuantity(activeItems, ShowQuantityAs.None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,39 +3,14 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
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()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
@ -5,54 +5,26 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||||
{
|
{
|
||||||
public partial class RoomSpecialCategoryPill : OnlinePlayComposite
|
public partial class RoomSpecialCategoryPill : OnlinePlayPill
|
||||||
{
|
{
|
||||||
private SpriteText text;
|
|
||||||
private PillContainer pill;
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
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 void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
pill.Background.Colour = colours.Pink;
|
||||||
|
pill.Background.Alpha = 1;
|
||||||
|
|
||||||
Category.BindValueChanged(c =>
|
Category.BindValueChanged(c =>
|
||||||
{
|
{
|
||||||
text.Text = c.NewValue.GetLocalisableDescription();
|
textFlow.Clear();
|
||||||
|
textFlow.AddText(c.NewValue.GetLocalisableDescription());
|
||||||
|
|
||||||
var backgroundColour = colours.ForRoomCategory(Category.Value);
|
var backgroundColour = colours.ForRoomCategory(Category.Value);
|
||||||
if (backgroundColour != null)
|
if (backgroundColour != null)
|
||||||
|
@ -6,46 +6,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Online.Rooms.RoomStatuses;
|
using osu.Game.Online.Rooms.RoomStatuses;
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A pill that displays the room's current status.
|
/// A pill that displays the room's current status.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class RoomStatusPill : OnlinePlayComposite
|
public partial class RoomStatusPill : OnlinePlayPill
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
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 void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -62,7 +36,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
|
|
||||||
pill.Background.Alpha = 1;
|
pill.Background.Alpha = 1;
|
||||||
pill.Background.FadeColour(status.GetAppropriateColour(colours), 100);
|
pill.Background.FadeColour(status.GetAppropriateColour(colours), 100);
|
||||||
statusText.Text = status.Message;
|
|
||||||
|
textFlow.Clear();
|
||||||
|
textFlow.AddText(status.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RoomStatus getDisplayStatus()
|
private RoomStatus getDisplayStatus()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user