mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 22:06:08 +08:00
Move HitErrorDisplay outside of the HUD
This commit is contained in:
parent
f70a7abea3
commit
70084b5553
@ -36,8 +36,6 @@ namespace osu.Game.Screens.Play
|
|||||||
public readonly ModDisplay ModDisplay;
|
public readonly ModDisplay ModDisplay;
|
||||||
public readonly HoldForMenuButton HoldToQuit;
|
public readonly HoldForMenuButton HoldToQuit;
|
||||||
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
|
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
|
||||||
public readonly HitErrorDisplay LeftHitErrorDisplay;
|
|
||||||
public readonly HitErrorDisplay RightHitErrorDisplay;
|
|
||||||
|
|
||||||
public Bindable<bool> ShowHealthbar = new Bindable<bool>(true);
|
public Bindable<bool> ShowHealthbar = new Bindable<bool>(true);
|
||||||
|
|
||||||
@ -87,8 +85,6 @@ namespace osu.Game.Screens.Play
|
|||||||
HealthDisplay = CreateHealthDisplay(),
|
HealthDisplay = CreateHealthDisplay(),
|
||||||
Progress = CreateProgress(),
|
Progress = CreateProgress(),
|
||||||
ModDisplay = CreateModsContainer(),
|
ModDisplay = CreateModsContainer(),
|
||||||
LeftHitErrorDisplay = CreateHitErrorDisplay(false),
|
|
||||||
RightHitErrorDisplay = CreateHitErrorDisplay(),
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
|
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
|
||||||
@ -261,13 +257,6 @@ namespace osu.Game.Screens.Play
|
|||||||
Margin = new MarginPadding { Top = 20, Right = 10 },
|
Margin = new MarginPadding { Top = 20, Right = 10 },
|
||||||
};
|
};
|
||||||
|
|
||||||
protected virtual HitErrorDisplay CreateHitErrorDisplay(bool reversed = true) => new HitErrorDisplay(reversed)
|
|
||||||
{
|
|
||||||
Anchor = reversed ? Anchor.CentreRight : Anchor.CentreLeft,
|
|
||||||
Origin = reversed ? Anchor.CentreRight : Anchor.CentreLeft,
|
|
||||||
Margin = new MarginPadding { Horizontal = 20 }
|
|
||||||
};
|
|
||||||
|
|
||||||
protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
|
protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
|
||||||
|
|
||||||
protected virtual void BindProcessor(ScoreProcessor processor)
|
protected virtual void BindProcessor(ScoreProcessor processor)
|
||||||
@ -277,17 +266,6 @@ namespace osu.Game.Screens.Play
|
|||||||
ComboCounter?.Current.BindTo(processor.Combo);
|
ComboCounter?.Current.BindTo(processor.Combo);
|
||||||
HealthDisplay?.Current.BindTo(processor.Health);
|
HealthDisplay?.Current.BindTo(processor.Health);
|
||||||
|
|
||||||
var hitWindows = processor.CreateHitWindows();
|
|
||||||
|
|
||||||
visibilityContainer.ForEach(drawable =>
|
|
||||||
{
|
|
||||||
if (drawable is HitErrorDisplay)
|
|
||||||
{
|
|
||||||
processor.NewJudgement += ((HitErrorDisplay)drawable).OnNewJudgement;
|
|
||||||
((HitErrorDisplay)drawable).HitWindows = hitWindows;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (HealthDisplay is StandardHealthDisplay shd)
|
if (HealthDisplay is StandardHealthDisplay shd)
|
||||||
processor.NewJudgement += shd.Flash;
|
processor.NewJudgement += shd.Flash;
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,13 @@ using osuTK;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Configuration;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD
|
namespace osu.Game.Screens.Play.HitErrorDisplay
|
||||||
{
|
{
|
||||||
public class HitErrorDisplay : CompositeDrawable
|
public class HitErrorDisplay : CompositeDrawable
|
||||||
{
|
{
|
||||||
@ -27,29 +24,24 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
private const int bar_width = 3;
|
private const int bar_width = 3;
|
||||||
private const int judgement_line_width = 8;
|
private const int judgement_line_width = 8;
|
||||||
private const int bar_height = 200;
|
private const int bar_height = 200;
|
||||||
private const int fade_duration = 200;
|
|
||||||
private const int arrow_move_duration = 500;
|
private const int arrow_move_duration = 500;
|
||||||
private const int judgement_life_time = 10000;
|
private const int judgement_life_time = 10000;
|
||||||
private const int spacing = 3;
|
private const int spacing = 3;
|
||||||
|
|
||||||
public HitWindows HitWindows { get; set; }
|
private readonly HitWindows hitWindows;
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private Bindable<WorkingBeatmap> beatmap { get; set; }
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private OsuColour colours { get; set; }
|
|
||||||
|
|
||||||
private readonly SpriteIcon arrow;
|
private readonly SpriteIcon arrow;
|
||||||
private readonly FillFlowContainer bar;
|
private readonly FillFlowContainer bar;
|
||||||
private readonly Container judgementsContainer;
|
private readonly Container judgementsContainer;
|
||||||
private readonly Queue<double> judgementOffsets = new Queue<double>();
|
private readonly Queue<double> judgementOffsets = new Queue<double>();
|
||||||
|
|
||||||
private readonly Bindable<ScoreMeterType> type = new Bindable<ScoreMeterType>();
|
public HitErrorDisplay(float overallDifficulty, HitWindows hitWindows, bool reversed = false)
|
||||||
|
|
||||||
public HitErrorDisplay(bool reversed = false)
|
|
||||||
{
|
{
|
||||||
|
this.hitWindows = hitWindows;
|
||||||
|
hitWindows.SetDifficulty(overallDifficulty);
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
Anchor = reversed ? Anchor.CentreRight : Anchor.CentreLeft;
|
||||||
|
Origin = reversed ? Anchor.CentreRight : Anchor.CentreLeft;
|
||||||
|
|
||||||
AddInternal(new FillFlowContainer
|
AddInternal(new FillFlowContainer
|
||||||
{
|
{
|
||||||
@ -94,74 +86,50 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
config.BindWith(OsuSetting.ScoreMeter, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
HitWindows.SetDifficulty(beatmap.Value.BeatmapInfo.BaseDifficulty.OverallDifficulty);
|
|
||||||
|
|
||||||
bar.AddRange(new Drawable[]
|
bar.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = ColourInfo.GradientVertical(colours.Yellow.Opacity(0), colours.Yellow),
|
Colour = ColourInfo.GradientVertical(colours.Yellow.Opacity(0), colours.Yellow),
|
||||||
Height = (float)((getMehHitWindows() - HitWindows.Good) / (getMehHitWindows() * 2))
|
Height = (float)((getMehHitWindows() - hitWindows.Good) / (getMehHitWindows() * 2))
|
||||||
},
|
},
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colours.Green,
|
Colour = colours.Green,
|
||||||
Height = (float)((HitWindows.Good - HitWindows.Great) / (getMehHitWindows() * 2))
|
Height = (float)((hitWindows.Good - hitWindows.Great) / (getMehHitWindows() * 2))
|
||||||
},
|
},
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colours.BlueLight,
|
Colour = colours.BlueLight,
|
||||||
Height = (float)(HitWindows.Great / getMehHitWindows())
|
Height = (float)(hitWindows.Great / getMehHitWindows())
|
||||||
},
|
},
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colours.Green,
|
Colour = colours.Green,
|
||||||
Height = (float)((HitWindows.Good - HitWindows.Great) / (getMehHitWindows() * 2))
|
Height = (float)((hitWindows.Good - hitWindows.Great) / (getMehHitWindows() * 2))
|
||||||
},
|
},
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = ColourInfo.GradientVertical(colours.Yellow, colours.Yellow.Opacity(0)),
|
Colour = ColourInfo.GradientVertical(colours.Yellow, colours.Yellow.Opacity(0)),
|
||||||
Height = (float)((getMehHitWindows() - HitWindows.Good) / (getMehHitWindows() * 2))
|
Height = (float)((getMehHitWindows() - hitWindows.Good) / (getMehHitWindows() * 2))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
type.BindValueChanged(onTypeChanged, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getMehHitWindows()
|
private double getMehHitWindows()
|
||||||
{
|
{
|
||||||
// In case if ruleset has no Meh hit windows (like Taiko)
|
// In case if ruleset has no Meh hit windows (like Taiko)
|
||||||
if (HitWindows.Meh == 0)
|
if (hitWindows.Meh == 0)
|
||||||
return HitWindows.Good + 40;
|
return hitWindows.Good + 40;
|
||||||
|
|
||||||
return HitWindows.Meh;
|
return hitWindows.Meh;
|
||||||
}
|
|
||||||
|
|
||||||
private void onTypeChanged(ValueChangedEvent<ScoreMeterType> type)
|
|
||||||
{
|
|
||||||
switch (type.NewValue)
|
|
||||||
{
|
|
||||||
case ScoreMeterType.None:
|
|
||||||
this.FadeOut(fade_duration, Easing.OutQuint);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ScoreMeterType.HitError:
|
|
||||||
this.FadeIn(fade_duration, Easing.OutQuint);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnNewJudgement(JudgementResult newJudgement)
|
public void OnNewJudgement(JudgementResult newJudgement)
|
@ -0,0 +1,69 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HitErrorDisplay
|
||||||
|
{
|
||||||
|
public class HitErrorDisplayOverlay : Container<HitErrorDisplay>
|
||||||
|
{
|
||||||
|
private const int fade_duration = 200;
|
||||||
|
private const int margin = 10;
|
||||||
|
|
||||||
|
private readonly Bindable<ScoreMeterType> type = new Bindable<ScoreMeterType>();
|
||||||
|
|
||||||
|
public HitErrorDisplayOverlay(ScoreProcessor processor, WorkingBeatmap workingBeatmap)
|
||||||
|
{
|
||||||
|
float overallDifficulty = workingBeatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new HitErrorDisplay(overallDifficulty, processor.CreateHitWindows())
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding { Left = margin }
|
||||||
|
},
|
||||||
|
new HitErrorDisplay(overallDifficulty, processor.CreateHitWindows(), true)
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding { Right = margin }
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
Children.ForEach(t => processor.NewJudgement += t.OnNewJudgement);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
config.BindWith(OsuSetting.ScoreMeter, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
type.BindValueChanged(onTypeChanged, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onTypeChanged(ValueChangedEvent<ScoreMeterType> type)
|
||||||
|
{
|
||||||
|
switch (type.NewValue)
|
||||||
|
{
|
||||||
|
case ScoreMeterType.None:
|
||||||
|
InternalChildren.ForEach(t => t.FadeOut(fade_duration, Easing.OutQuint));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
InternalChildren.ForEach(t => t.FadeIn(fade_duration, Easing.OutQuint));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Play.HitErrorDisplay;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -73,6 +74,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
protected HUDOverlay HUDOverlay { get; private set; }
|
protected HUDOverlay HUDOverlay { get; private set; }
|
||||||
|
|
||||||
|
protected HitErrorDisplayOverlay HitErrorDisplayOverlay { get; private set; }
|
||||||
|
|
||||||
public bool LoadedBeatmapSuccessfully => DrawableRuleset?.Objects.Any() == true;
|
public bool LoadedBeatmapSuccessfully => DrawableRuleset?.Objects.Any() == true;
|
||||||
|
|
||||||
protected GameplayClockContainer GameplayClockContainer { get; private set; }
|
protected GameplayClockContainer GameplayClockContainer { get; private set; }
|
||||||
@ -157,6 +160,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre
|
Origin = Anchor.Centre
|
||||||
},
|
},
|
||||||
|
HitErrorDisplayOverlay = new HitErrorDisplayOverlay(ScoreProcessor, working),
|
||||||
new SkipOverlay(DrawableRuleset.GameplayStartTime)
|
new SkipOverlay(DrawableRuleset.GameplayStartTime)
|
||||||
{
|
{
|
||||||
RequestSeek = GameplayClockContainer.Seek
|
RequestSeek = GameplayClockContainer.Seek
|
||||||
|
Loading…
Reference in New Issue
Block a user