mirror of
https://github.com/ppy/osu.git
synced 2025-02-08 21:13:22 +08:00
Move colour selection to the FriendsOnlineStatusItem
This commit is contained in:
parent
06b23b626e
commit
c22f61b2b1
@ -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 Humanizer;
|
using Humanizer;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -28,6 +29,6 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
protected override string GetInfoText() => Value.LatestBuild.Users > 0 ? $"{"user".ToQuantity(Value.LatestBuild.Users, "N0")} online" : null;
|
protected override string GetInfoText() => Value.LatestBuild.Users > 0 ? $"{"user".ToQuantity(Value.LatestBuild.Users, "N0")} online" : null;
|
||||||
|
|
||||||
protected override Color4 GetBarColour() => Value.Colour;
|
protected override Color4 GetBarColour(OsuColour colours) => Value.Colour;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Home.Friends
|
namespace osu.Game.Overlays.Home.Friends
|
||||||
{
|
{
|
||||||
public class FriendsBundle
|
public class FriendsBundle
|
||||||
@ -12,31 +9,11 @@ namespace osu.Game.Overlays.Home.Friends
|
|||||||
|
|
||||||
public int Amount { get; }
|
public int Amount { get; }
|
||||||
|
|
||||||
public Color4 Colour => getColour();
|
|
||||||
|
|
||||||
public FriendsBundle(FriendsOnlineStatus status, int amount)
|
public FriendsBundle(FriendsOnlineStatus status, int amount)
|
||||||
{
|
{
|
||||||
Status = status;
|
Status = status;
|
||||||
Amount = amount;
|
Amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color4 getColour()
|
|
||||||
{
|
|
||||||
switch (Status)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
throw new ArgumentException($@"{Status} status does not provide a colour in {nameof(getColour)}.");
|
|
||||||
|
|
||||||
case FriendsOnlineStatus.All:
|
|
||||||
return Color4.White;
|
|
||||||
|
|
||||||
case FriendsOnlineStatus.Online:
|
|
||||||
return Color4.Lime;
|
|
||||||
|
|
||||||
case FriendsOnlineStatus.Offline:
|
|
||||||
return Color4.Black;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FriendsOnlineStatus
|
public enum FriendsOnlineStatus
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Home.Friends
|
namespace osu.Game.Overlays.Home.Friends
|
||||||
@ -16,6 +18,22 @@ namespace osu.Game.Overlays.Home.Friends
|
|||||||
|
|
||||||
protected override string GetAdditionalText() => Value.Amount.ToString();
|
protected override string GetAdditionalText() => Value.Amount.ToString();
|
||||||
|
|
||||||
protected override Color4 GetBarColour() => Value.Colour;
|
protected override Color4 GetBarColour(OsuColour colours)
|
||||||
|
{
|
||||||
|
switch (Value.Status)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($@"{Value.Status} status does not provide a colour in {nameof(GetBarColour)}.");
|
||||||
|
|
||||||
|
case FriendsOnlineStatus.All:
|
||||||
|
return Color4.White;
|
||||||
|
|
||||||
|
case FriendsOnlineStatus.Online:
|
||||||
|
return colours.GreenLight;
|
||||||
|
|
||||||
|
case FriendsOnlineStatus.Offline:
|
||||||
|
return Color4.Black;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OverlayColourProvider colourProvider)
|
private void load(OverlayColourProvider colourProvider, OsuColour colours)
|
||||||
{
|
{
|
||||||
Size = new Vector2(GetWidth(), 60);
|
Size = new Vector2(GetWidth(), 60);
|
||||||
Padding = new MarginPadding(5);
|
Padding = new MarginPadding(5);
|
||||||
@ -81,7 +81,7 @@ namespace osu.Game.Overlays
|
|||||||
expandingBar = new ExpandingBar
|
expandingBar = new ExpandingBar
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Colour = GetBarColour(),
|
Colour = GetBarColour(colours),
|
||||||
ExpandedSize = 4,
|
ExpandedSize = 4,
|
||||||
CollapsedSize = 2,
|
CollapsedSize = 2,
|
||||||
Expanded = true
|
Expanded = true
|
||||||
@ -98,7 +98,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
protected virtual string GetInfoText() => string.Empty;
|
protected virtual string GetInfoText() => string.Empty;
|
||||||
|
|
||||||
protected abstract Color4 GetBarColour();
|
protected abstract Color4 GetBarColour(OsuColour colours);
|
||||||
|
|
||||||
protected virtual float GetWidth() => tab_width;
|
protected virtual float GetWidth() => tab_width;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user