1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 09:43:10 +08:00

Remove unnecessary binding logic from HUDOverlay

This commit is contained in:
Dean Herbert 2021-05-07 17:27:34 +09:00
parent a7acecc52b
commit 1cb10c2a22
6 changed files with 11 additions and 24 deletions

View File

@ -146,7 +146,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
AddStep("create overlay", () => AddStep("create overlay", () =>
{ {
hudOverlay = new HUDOverlay(scoreProcessor, null, Array.Empty<Mod>()); hudOverlay = new HUDOverlay(null, Array.Empty<Mod>());
// Add any key just to display the key counter visually. // Add any key just to display the key counter visually.
hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space)); hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space));

View File

@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.Gameplay
var drawableRuleset = ruleset.CreateDrawableRulesetWith(beatmap); var drawableRuleset = ruleset.CreateDrawableRulesetWith(beatmap);
var hudOverlay = new HUDOverlay(scoreProcessor, drawableRuleset, Array.Empty<Mod>()) var hudOverlay = new HUDOverlay(drawableRuleset, Array.Empty<Mod>())
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -79,7 +79,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
SetContents(() => SetContents(() =>
{ {
hudOverlay = new HUDOverlay(scoreProcessor, null, Array.Empty<Mod>()); hudOverlay = new HUDOverlay(null, Array.Empty<Mod>());
// Add any key just to display the key counter visually. // Add any key just to display the key counter visually.
hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space)); hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space));

View File

@ -22,11 +22,11 @@ namespace osu.Game.Screens.Play.HUD
private readonly HitWindows hitWindows; private readonly HitWindows hitWindows;
private readonly ScoreProcessor processor; [Resolved]
private ScoreProcessor processor { get; set; }
public HitErrorDisplay(ScoreProcessor processor, HitWindows hitWindows) public HitErrorDisplay(HitWindows hitWindows)
{ {
this.processor = processor;
this.hitWindows = hitWindows; this.hitWindows = hitWindows;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;

View File

@ -14,7 +14,6 @@ using osu.Game.Input.Bindings;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
using osuTK; using osuTK;
@ -39,14 +38,11 @@ namespace osu.Game.Screens.Play
public readonly SkinnableHealthDisplay HealthDisplay; public readonly SkinnableHealthDisplay HealthDisplay;
public readonly SongProgress Progress; public readonly SongProgress Progress;
public readonly ModDisplay ModDisplay; public readonly ModDisplay ModDisplay;
public readonly HitErrorDisplay HitErrorDisplay;
public readonly HoldForMenuButton HoldToQuit; public readonly HoldForMenuButton HoldToQuit;
public readonly PlayerSettingsOverlay PlayerSettingsOverlay; public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
public readonly FailingLayer FailingLayer;
public Bindable<bool> ShowHealthbar = new Bindable<bool>(true); public Bindable<bool> ShowHealthbar = new Bindable<bool>(true);
private readonly ScoreProcessor scoreProcessor;
private readonly DrawableRuleset drawableRuleset; private readonly DrawableRuleset drawableRuleset;
private readonly IReadOnlyList<Mod> mods; private readonly IReadOnlyList<Mod> mods;
@ -74,9 +70,8 @@ namespace osu.Game.Screens.Play
private IEnumerable<Drawable> hideTargets => new Drawable[] { visibilityContainer, KeyCounter, topRightElements }; private IEnumerable<Drawable> hideTargets => new Drawable[] { visibilityContainer, KeyCounter, topRightElements };
public HUDOverlay(ScoreProcessor scoreProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods) public HUDOverlay(DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
{ {
this.scoreProcessor = scoreProcessor;
this.drawableRuleset = drawableRuleset; this.drawableRuleset = drawableRuleset;
this.mods = mods; this.mods = mods;
@ -84,7 +79,7 @@ namespace osu.Game.Screens.Play
Children = new Drawable[] Children = new Drawable[]
{ {
FailingLayer = CreateFailingLayer(), CreateFailingLayer(),
visibilityContainer = new Container visibilityContainer = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -104,7 +99,7 @@ namespace osu.Game.Screens.Play
AccuracyCounter = CreateAccuracyCounter(), AccuracyCounter = CreateAccuracyCounter(),
ScoreCounter = CreateScoreCounter(), ScoreCounter = CreateScoreCounter(),
CreateComboCounter(), CreateComboCounter(),
HitErrorDisplay = CreateHitErrorDisplayOverlay(), CreateHitErrorDisplayOverlay(),
} }
}, },
}, },
@ -156,9 +151,6 @@ namespace osu.Game.Screens.Play
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(OsuConfigManager config, NotificationOverlay notificationOverlay) private void load(OsuConfigManager config, NotificationOverlay notificationOverlay)
{ {
if (scoreProcessor != null)
BindScoreProcessor(scoreProcessor);
if (drawableRuleset != null) if (drawableRuleset != null)
{ {
BindDrawableRuleset(drawableRuleset); BindDrawableRuleset(drawableRuleset);
@ -309,15 +301,10 @@ namespace osu.Game.Screens.Play
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
}; };
protected virtual HitErrorDisplay CreateHitErrorDisplayOverlay() => new HitErrorDisplay(scoreProcessor, drawableRuleset?.FirstAvailableHitWindows); protected virtual HitErrorDisplay CreateHitErrorDisplayOverlay() => new HitErrorDisplay(drawableRuleset?.FirstAvailableHitWindows);
protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay(); protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
protected virtual void BindScoreProcessor(ScoreProcessor processor)
{
AccuracyCounter?.Current.BindTo(processor.Accuracy);
}
public bool OnPressed(GlobalAction action) public bool OnPressed(GlobalAction action)
{ {
switch (action) switch (action)

View File

@ -345,7 +345,7 @@ namespace osu.Game.Screens.Play
// display the cursor above some HUD elements. // display the cursor above some HUD elements.
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(), DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(), DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
HUDOverlay = new HUDOverlay(ScoreProcessor, DrawableRuleset, Mods.Value) HUDOverlay = new HUDOverlay(DrawableRuleset, Mods.Value)
{ {
HoldToQuit = HoldToQuit =
{ {