From 42b19cd3b3282b2a90a51e0f1c970352ea8e19ff Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sat, 11 Mar 2017 14:27:18 +0900 Subject: [PATCH] Re-add files. --- osu.Game/Modes/UI/HudOverlay.cs | 77 +++++++++++++++++++++++++ osu.Game/Modes/UI/StandardHudOverlay.cs | 54 +++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 osu.Game/Modes/UI/HudOverlay.cs create mode 100644 osu.Game/Modes/UI/StandardHudOverlay.cs diff --git a/osu.Game/Modes/UI/HudOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs new file mode 100644 index 0000000000..979831f89f --- /dev/null +++ b/osu.Game/Modes/UI/HudOverlay.cs @@ -0,0 +1,77 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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 showKeyCounter; + + protected abstract KeyCounterCollection CreateKeyCounter(); + protected abstract ComboCounter CreateComboCounter(); + protected abstract PercentageCounter CreateAccuracyCounter(); + protected abstract ScoreCounter CreateScoreCounter(); + protected abstract HealthDisplay CreateHealthDisplay(); + + protected HudOverlay() + { + 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(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()); + } + } +} diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs new file mode 100644 index 0000000000..f77191adf7 --- /dev/null +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -0,0 +1,54 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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 }, + }; + } +}