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

General fixes.

This commit is contained in:
smoogipooo 2017-03-11 14:17:07 +09:00
parent c0bb2685bf
commit eef18eea42
4 changed files with 135 additions and 11 deletions

View File

@ -7,9 +7,9 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Modes.Objects;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using System; using System;
using System.Collections.Generic;
namespace osu.Game.Modes.UI namespace osu.Game.Modes.UI
{ {
@ -23,7 +23,7 @@ namespace osu.Game.Modes.UI
private Bindable<bool> showKeyCounter; private Bindable<bool> showKeyCounter;
protected abstract KeyCounterCollection CreateKeyCounter(IEnumerable<KeyCounter> keyCounters); protected abstract KeyCounterCollection CreateKeyCounter();
protected abstract ComboCounter CreateComboCounter(); protected abstract ComboCounter CreateComboCounter();
protected abstract PercentageCounter CreateAccuracyCounter(); protected abstract PercentageCounter CreateAccuracyCounter();
protected abstract ScoreCounter CreateScoreCounter(); protected abstract ScoreCounter CreateScoreCounter();
@ -35,7 +35,7 @@ namespace osu.Game.Modes.UI
Children = new Drawable[] Children = new Drawable[]
{ {
KeyCounter = CreateKeyCounter(ruleset.CreateGameplayKeys()), KeyCounter = CreateKeyCounter(),
ComboCounter = CreateComboCounter(), ComboCounter = CreateComboCounter(),
ScoreCounter = CreateScoreCounter(), ScoreCounter = CreateScoreCounter(),
AccuracyCounter = CreateAccuracyCounter(), AccuracyCounter = CreateAccuracyCounter(),

View File

@ -0,0 +1,77 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Modes.Objects;
using osu.Game.Screens.Play;
using System;
namespace osu.Game.Modes.UI
{
public abstract class HudOverlay : Container
{
public readonly KeyCounterCollection KeyCounter;
public readonly ComboCounter ComboCounter;
public readonly ScoreCounter ScoreCounter;
public readonly PercentageCounter AccuracyCounter;
public readonly HealthDisplay HealthDisplay;
private Bindable<bool> showKeyCounter;
protected abstract KeyCounterCollection CreateKeyCounter();
protected abstract ComboCounter CreateComboCounter();
protected abstract PercentageCounter CreateAccuracyCounter();
protected abstract ScoreCounter CreateScoreCounter();
protected abstract HealthDisplay CreateHealthDisplay();
protected HudOverlay(Ruleset ruleset)
{
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
KeyCounter = CreateKeyCounter(),
ComboCounter = CreateComboCounter(),
ScoreCounter = CreateScoreCounter(),
AccuracyCounter = CreateAccuracyCounter(),
HealthDisplay = CreateHealthDisplay(),
};
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
showKeyCounter = config.GetBindable<bool>(OsuConfig.KeyOverlay);
showKeyCounter.ValueChanged += visibilityChanged;
showKeyCounter.TriggerChange();
}
private void visibilityChanged(object sender, EventArgs e)
{
if (showKeyCounter)
KeyCounter.Show();
else
KeyCounter.Hide();
}
public void BindProcessor(ScoreProcessor processor)
{
//bind processor bindables to combocounter, score display etc.
//TODO: these should be bindable binds, not events!
ScoreCounter?.Current.BindTo(processor.TotalScore);
AccuracyCounter?.Current.BindTo(processor.Accuracy);
ComboCounter?.Current.BindTo(processor.Combo);
HealthDisplay?.Current.BindTo(processor.Health);
}
public void BindHitRenderer(HitRenderer hitRenderer)
{
hitRenderer.InputManager.Add(KeyCounter.GetReceptor());
}
}
}

View File

@ -6,17 +6,11 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using System.Collections.Generic;
namespace osu.Game.Modes.UI namespace osu.Game.Modes.UI
{ {
public class StandardHudOverlay : HudOverlay public class StandardHudOverlay : HudOverlay
{ {
public StandardHudOverlay(Ruleset ruleset)
: base(ruleset)
{
}
protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
@ -39,14 +33,13 @@ namespace osu.Game.Modes.UI
Margin = new MarginPadding { Top = 20 } Margin = new MarginPadding { Top = 20 }
}; };
protected override KeyCounterCollection CreateKeyCounter(IEnumerable<KeyCounter> keyCounters) => new KeyCounterCollection protected override KeyCounterCollection CreateKeyCounter() => new KeyCounterCollection
{ {
IsCounting = true, IsCounting = true,
FadeTime = 50, FadeTime = 50,
Anchor = Anchor.BottomRight, Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight, Origin = Anchor.BottomRight,
Margin = new MarginPadding(10), Margin = new MarginPadding(10),
Children = keyCounters
}; };
protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6) protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6)

View File

@ -0,0 +1,54 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play;
namespace osu.Game.Modes.UI
{
public class StandardHudOverlay : HudOverlay
{
protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, 65),
TextSize = 20,
Margin = new MarginPadding { Right = 5 },
};
protected override ComboCounter CreateComboCounter() => new StandardComboCounter
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
};
protected override HealthDisplay CreateHealthDisplay() => new StandardHealthDisplay
{
Size = new Vector2(1, 5),
RelativeSizeAxes = Axes.X,
Margin = new MarginPadding { Top = 20 }
};
protected override KeyCounterCollection CreateKeyCounter() => new KeyCounterCollection
{
IsCounting = true,
FadeTime = 50,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Margin = new MarginPadding(10),
};
protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
TextSize = 40,
Position = new Vector2(0, 30),
Margin = new MarginPadding { Right = 5 },
};
}
}