1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 05:27:23 +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", () =>
{
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.
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 hudOverlay = new HUDOverlay(scoreProcessor, drawableRuleset, Array.Empty<Mod>())
var hudOverlay = new HUDOverlay(drawableRuleset, Array.Empty<Mod>())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -79,7 +79,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
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.
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 ScoreProcessor processor;
[Resolved]
private ScoreProcessor processor { get; set; }
public HitErrorDisplay(ScoreProcessor processor, HitWindows hitWindows)
public HitErrorDisplay(HitWindows hitWindows)
{
this.processor = processor;
this.hitWindows = hitWindows;
RelativeSizeAxes = Axes.Both;

View File

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

View File

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