mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 16:43:04 +08:00
Remove pill inheritance
This commit is contained in:
parent
a8cbffa57e
commit
435b4b0e6e
@ -5,21 +5,27 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Components
|
namespace osu.Game.Screens.OnlinePlay.Components
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Abstract class for "pill" components displayed as part of <see cref="DrawableRoom"/>s.
|
/// Displays contents in a "pill".
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class RoomInfoPill : OnlinePlayComposite
|
public class PillContainer : Container
|
||||||
{
|
{
|
||||||
private const float padding = 8;
|
private const float padding = 8;
|
||||||
|
|
||||||
protected Drawable Background { get; private set; }
|
public Drawable Background { get; private set; }
|
||||||
|
|
||||||
protected RoomInfoPill()
|
protected override Container<Drawable> Content { get; } = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
};
|
||||||
|
|
||||||
|
public PillContainer()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
Height = 16;
|
Height = 16;
|
||||||
@ -58,21 +64,12 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
},
|
},
|
||||||
Content = new[]
|
Content = new[]
|
||||||
{
|
{
|
||||||
new[]
|
new[] { Content }
|
||||||
{
|
|
||||||
CreateContent().With(d =>
|
|
||||||
{
|
|
||||||
d.Anchor = Anchor.Centre;
|
|
||||||
d.Origin = Anchor.Centre;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Drawable CreateContent();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
@ -11,10 +12,29 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A pill that displays the playlist item count.
|
/// A pill that displays the playlist item count.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PlaylistCountPill : RoomInfoPill
|
public class PlaylistCountPill : OnlinePlayComposite
|
||||||
{
|
{
|
||||||
private OsuTextFlowContainer count;
|
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();
|
||||||
@ -28,12 +48,5 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
count.AddText(Playlist.Count.ToString(), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
count.AddText(Playlist.Count.ToString(), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
||||||
count.AddText(" Maps");
|
count.AddText(" Maps");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable CreateContent() => count = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,35 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A pill that displays the room's current status.
|
/// A pill that displays the room's current status.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RoomStatusPill : RoomInfoPill
|
public class RoomStatusPill : OnlinePlayComposite
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
private bool firstDisplay = true;
|
private bool firstDisplay = true;
|
||||||
|
private PillContainer pill;
|
||||||
private SpriteText statusText;
|
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();
|
||||||
@ -36,19 +57,11 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
{
|
{
|
||||||
RoomStatus status = EndDate.Value < DateTimeOffset.Now ? new RoomStatusEnded() : Status.Value ?? new RoomStatusOpen();
|
RoomStatus status = EndDate.Value < DateTimeOffset.Now ? new RoomStatusEnded() : Status.Value ?? new RoomStatusOpen();
|
||||||
|
|
||||||
Background.Alpha = 1;
|
pill.Background.Alpha = 1;
|
||||||
Background.FadeColour(status.GetAppropriateColour(colours), firstDisplay ? 0 : 100);
|
pill.Background.FadeColour(status.GetAppropriateColour(colours), firstDisplay ? 0 : 100);
|
||||||
statusText.Text = status.Message;
|
statusText.Text = status.Message;
|
||||||
|
|
||||||
firstDisplay = false;
|
firstDisplay = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable CreateContent() => statusText = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 12),
|
|
||||||
Colour = Color4.Black
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user