1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 22:27:25 +08:00

Merge branch 'master' into song-progress-graph

This commit is contained in:
Dan Balasescu 2017-04-15 01:29:02 +09:00 committed by GitHub
commit 3de3b94978
7 changed files with 136 additions and 31 deletions

View File

@ -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<T> : Container
public abstract class RollingCounter<T> : Container, IHasAccentColour
{
/// <summary>
/// The current value.
@ -80,6 +81,12 @@ namespace osu.Game.Graphics.UserInterface
}
}
public Color4 AccentColour
{
get { return DisplayedCountSpriteText.Colour; }
set { DisplayedCountSpriteText.Colour = value; }
}
/// <summary>
/// Skeleton of a numeric counter which value rolls over time.
/// </summary>
@ -109,8 +116,6 @@ namespace osu.Game.Graphics.UserInterface
base.LoadComplete();
DisplayedCountSpriteText.Text = FormatCount(Current);
DisplayedCountSpriteText.Anchor = Anchor;
DisplayedCountSpriteText.Origin = Origin;
}
/// <summary>

View File

@ -15,6 +15,8 @@ namespace osu.Game.Graphics.UserInterface
protected override double RollingDuration => 1000;
protected override EasingTypes RollingEasing => EasingTypes.Out;
public bool UseCommaSeparator;
/// <summary>
/// How many leading zeroes the counter has.
/// </summary>
@ -41,7 +43,12 @@ namespace osu.Game.Graphics.UserInterface
protected override string FormatCount(double count)
{
return ((long)count).ToString("D" + LeadingZeroes);
string format = new string('0', (int)LeadingZeroes);
if (UseCommaSeparator)
for (int i = format.Length - 3; i > 0; i -= 3)
format = format.Insert(i, @",");
return ((long)count).ToString(format);
}
public override void Increment(double amount)

View File

@ -0,0 +1,61 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transforms;
using osu.Framework.MathUtils;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// Used as an accuracy counter. Represented visually as a percentage.
/// </summary>
public class SimpleComboCounter : RollingCounter<int>
{
protected override Type TransformType => typeof(TransformCounterCount);
protected override double RollingDuration => 750;
public SimpleComboCounter()
{
Current.Value = DisplayedCount = 0;
}
protected override string FormatCount(int count)
{
return $@"{count}x";
}
protected override double GetProportionalDuration(int currentValue, int newValue)
{
return Math.Abs(currentValue - newValue) * RollingDuration * 100.0f;
}
public override void Increment(int amount)
{
Current.Value = Current + amount;
}
private class TransformCounterCount : Transform<int>
{
public override int CurrentValue
{
get
{
double time = Time?.Current ?? 0;
if (time < StartTime) return StartValue;
if (time >= EndTime) return EndValue;
return (int)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
}
}
public override void Apply(Drawable d)
{
base.Apply(d);
((SimpleComboCounter)d).DisplayedCount = CurrentValue;
}
}
}
}

View File

@ -22,9 +22,9 @@ namespace osu.Game.Modes.UI
private readonly Container content;
public readonly KeyCounterCollection KeyCounter;
public readonly ComboCounter ComboCounter;
public readonly RollingCounter<int> ComboCounter;
public readonly ScoreCounter ScoreCounter;
public readonly PercentageCounter AccuracyCounter;
public readonly RollingCounter<double> AccuracyCounter;
public readonly HealthDisplay HealthDisplay;
public readonly SongProgress Progress;
@ -34,8 +34,8 @@ namespace osu.Game.Modes.UI
private static bool hasShownNotificationOnce;
protected abstract KeyCounterCollection CreateKeyCounter();
protected abstract ComboCounter CreateComboCounter();
protected abstract PercentageCounter CreateAccuracyCounter();
protected abstract RollingCounter<int> CreateComboCounter();
protected abstract RollingCounter<double> CreateAccuracyCounter();
protected abstract ScoreCounter CreateScoreCounter();
protected abstract HealthDisplay CreateHealthDisplay();
protected abstract SongProgress CreateProgress();

View File

@ -3,8 +3,6 @@
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -12,10 +10,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 +64,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);
}
}

View File

@ -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;
@ -11,19 +14,22 @@ namespace osu.Game.Modes.UI
{
public class StandardHudOverlay : HudOverlay
{
protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter
protected override RollingCounter<double> CreateAccuracyCounter() => new PercentageCounter
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, 65),
Origin = Anchor.TopRight,
Position = new Vector2(0, 35),
TextSize = 20,
Margin = new MarginPadding { Right = 5 },
Margin = new MarginPadding { Right = 140 },
};
protected override ComboCounter CreateComboCounter() => new StandardComboCounter
protected override RollingCounter<int> CreateComboCounter() => new SimpleComboCounter
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopLeft,
Position = new Vector2(0, 35),
Margin = new MarginPadding { Left = 140 },
TextSize = 20,
};
protected override HealthDisplay CreateHealthDisplay() => new StandardHealthDisplay
@ -49,7 +55,6 @@ namespace osu.Game.Modes.UI
Origin = Anchor.TopCentre,
TextSize = 40,
Position = new Vector2(0, 30),
Margin = new MarginPadding { Right = 5 },
};
protected override SongProgress CreateProgress() => new SongProgress()
@ -58,5 +63,20 @@ namespace osu.Game.Modes.UI
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
};
[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);
}
}
}
}

View File

@ -92,6 +92,7 @@
<Compile Include="Graphics\UserInterface\OsuPasswordTextBox.cs" />
<Compile Include="Graphics\UserInterface\OsuSliderBar.cs" />
<Compile Include="Graphics\UserInterface\OsuTextBox.cs" />
<Compile Include="Graphics\UserInterface\SimpleComboCounter.cs" />
<Compile Include="Graphics\UserInterface\TwoLayerButton.cs" />
<Compile Include="Input\Handlers\ReplayInputHandler.cs" />
<Compile Include="IO\Legacy\ILegacySerializable.cs" />