From 3054697f988fda25d8f8f2883b0751f4fb198843 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 13 Apr 2017 10:04:12 +0900 Subject: [PATCH] Expose AccentColour/GlowColour from hud elements, and set from HudOverlay. --- .../UserInterface/PercentageCounter.cs | 6 --- .../Graphics/UserInterface/RollingCounter.cs | 9 ++++- .../Graphics/UserInterface/ScoreCounter.cs | 6 --- .../UserInterface/SimpleComboCounter.cs | 7 +--- osu.Game/Modes/UI/StandardHealthDisplay.cs | 40 +++++++++++++------ osu.Game/Modes/UI/StandardHudOverlay.cs | 18 +++++++++ 6 files changed, 54 insertions(+), 32 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs index d9438af17e..63c27426c0 100644 --- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs +++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs @@ -31,12 +31,6 @@ namespace osu.Game.Graphics.UserInterface Current.Value = DisplayedCount = 1.0f; } - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - DisplayedCountSpriteText.Colour = colours.BlueLighter; - } - protected override string FormatCount(double count) { return $@"{count:P2}"; diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 4b244fc540..f8ab9f0ff3 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -10,10 +10,11 @@ using osu.Game.Graphics.Sprites; using System; using System.Collections.Generic; using System.Diagnostics; +using OpenTK.Graphics; namespace osu.Game.Graphics.UserInterface { - public abstract class RollingCounter : Container + public abstract class RollingCounter : Container, IHasAccentColour { /// /// The current value. @@ -80,6 +81,12 @@ namespace osu.Game.Graphics.UserInterface } } + public Color4 AccentColour + { + get { return DisplayedCountSpriteText.Colour; } + set { DisplayedCountSpriteText.Colour = value; } + } + /// /// Skeleton of a numeric counter which value rolls over time. /// diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index 1221d2b0c2..b035dbb547 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -35,12 +35,6 @@ namespace osu.Game.Graphics.UserInterface LeadingZeroes = leading; } - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - DisplayedCountSpriteText.Colour = colours.BlueLighter; - } - protected override double GetProportionalDuration(double currentValue, double newValue) { return currentValue > newValue ? currentValue - newValue : newValue - currentValue; diff --git a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs index c9891885bd..1b0526a668 100644 --- a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Transforms; @@ -38,12 +39,6 @@ namespace osu.Game.Graphics.UserInterface Current.Value = Current + amount; } - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - DisplayedCountSpriteText.Colour = colours.BlueLighter; - } - protected class TransformCount : Transform { public override int CurrentValue diff --git a/osu.Game/Modes/UI/StandardHealthDisplay.cs b/osu.Game/Modes/UI/StandardHealthDisplay.cs index d49e32ea8b..2fdfd02194 100644 --- a/osu.Game/Modes/UI/StandardHealthDisplay.cs +++ b/osu.Game/Modes/UI/StandardHealthDisplay.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -12,10 +13,35 @@ using osu.Game.Graphics; namespace osu.Game.Modes.UI { - public class StandardHealthDisplay : HealthDisplay + public class StandardHealthDisplay : HealthDisplay, IHasAccentColour { private readonly Container fill; + public Color4 AccentColour + { + get { return fill.Colour; } + set { fill.Colour = value; } + } + + private Color4 glowColour; + public Color4 GlowColour + { + get { return glowColour; } + set + { + if (glowColour == value) + return; + glowColour = value; + + fill.EdgeEffect = new EdgeEffect + { + Colour = glowColour, + Radius = 8, + Type = EdgeEffectType.Glow + }; + } + } + public StandardHealthDisplay() { Children = new Drawable[] @@ -41,18 +67,6 @@ namespace osu.Game.Modes.UI }; } - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - fill.Colour = colours.BlueLighter; - fill.EdgeEffect = new EdgeEffect - { - Colour = colours.BlueDarker.Opacity(0.6f), - Radius = 8, - Type = EdgeEffectType.Glow - }; - } - protected override void SetHealth(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); } } diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs index 87ec631b35..cb8e6c1808 100644 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -2,8 +2,11 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; +using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Play; @@ -53,5 +56,20 @@ namespace osu.Game.Modes.UI TextSize = 40, Position = new Vector2(0, 30), }; + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + ComboCounter.AccentColour = colours.BlueLighter; + AccuracyCounter.AccentColour = colours.BlueLighter; + ScoreCounter.AccentColour = colours.BlueLighter; + + var shd = HealthDisplay as StandardHealthDisplay; + if (shd != null) + { + shd.AccentColour = colours.BlueLighter; + shd.GlowColour = colours.BlueDarker.Opacity(0.6f); + } + } } }