mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Merge branch 'master' into spinner-speed-fix
This commit is contained in:
commit
7736445659
@ -51,10 +51,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
hitObjectPosition = hitObject.PositionBindable.GetBoundCopy();
|
hitObjectPosition = hitObject.PositionBindable.GetBoundCopy();
|
||||||
hitObjectPosition.BindValueChanged(_ => updateConnectingPath());
|
hitObjectPosition.BindValueChanged(_ => Scheduler.AddOnce(updateConnectingPath));
|
||||||
|
|
||||||
pathVersion = hitObject.Path.Version.GetBoundCopy();
|
pathVersion = hitObject.Path.Version.GetBoundCopy();
|
||||||
pathVersion.BindValueChanged(_ => updateConnectingPath());
|
pathVersion.BindValueChanged(_ => Scheduler.AddOnce(updateConnectingPath));
|
||||||
|
|
||||||
updateConnectingPath();
|
updateConnectingPath();
|
||||||
}
|
}
|
||||||
|
@ -244,6 +244,15 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
else if (slidingSample.IsPlaying)
|
else if (slidingSample.IsPlaying)
|
||||||
slidingSample.Stop();
|
slidingSample.Stop();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateAfterChildren()
|
||||||
|
{
|
||||||
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
|
// During slider path editing, the PlaySliderBody is scheduled to refresh once on Update.
|
||||||
|
// It is crucial to perform the code below in UpdateAfterChildren. This ensures that the SliderBody has the opportunity
|
||||||
|
// to update its Size and PathOffset beforehand, ensuring correct placement.
|
||||||
|
|
||||||
double completionProgress = Math.Clamp((Time.Current - HitObject.StartTime) / HitObject.Duration, 0, 1);
|
double completionProgress = Math.Clamp((Time.Current - HitObject.StartTime) / HitObject.Duration, 0, 1);
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
repeatCount = value;
|
repeatCount = value;
|
||||||
updateNestedPositions();
|
endPositionCache.Invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
public Slider()
|
public Slider()
|
||||||
{
|
{
|
||||||
SamplesBindable.CollectionChanged += (_, _) => UpdateNestedSamples();
|
SamplesBindable.CollectionChanged += (_, _) => UpdateNestedSamples();
|
||||||
Path.Version.ValueChanged += _ => updateNestedPositions();
|
Path.Version.ValueChanged += _ => endPositionCache.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
|
||||||
|
@ -14,16 +14,16 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class SliderEndCircle : HitCircle
|
public abstract class SliderEndCircle : HitCircle
|
||||||
{
|
{
|
||||||
private readonly Slider slider;
|
protected readonly Slider Slider;
|
||||||
|
|
||||||
protected SliderEndCircle(Slider slider)
|
protected SliderEndCircle(Slider slider)
|
||||||
{
|
{
|
||||||
this.slider = slider;
|
Slider = slider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int RepeatIndex { get; set; }
|
public int RepeatIndex { get; set; }
|
||||||
|
|
||||||
public double SpanDuration => slider.SpanDuration;
|
public double SpanDuration => Slider.SpanDuration;
|
||||||
|
|
||||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The first end circle should fade in with the slider.
|
// The first end circle should fade in with the slider.
|
||||||
TimePreempt += StartTime - slider.StartTime;
|
TimePreempt += StartTime - Slider.StartTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
ScaleBindable.BindValueChanged(scale => PathRadius = OsuHitObject.OBJECT_RADIUS * scale.NewValue, true);
|
ScaleBindable.BindValueChanged(scale => PathRadius = OsuHitObject.OBJECT_RADIUS * scale.NewValue, true);
|
||||||
|
|
||||||
pathVersion = drawableSlider.PathVersion.GetBoundCopy();
|
pathVersion = drawableSlider.PathVersion.GetBoundCopy();
|
||||||
pathVersion.BindValueChanged(_ => Refresh());
|
pathVersion.BindValueChanged(_ => Scheduler.AddOnce(Refresh));
|
||||||
|
|
||||||
AccentColourBindable = drawableObject.AccentColour.GetBoundCopy();
|
AccentColourBindable = drawableObject.AccentColour.GetBoundCopy();
|
||||||
AccentColourBindable.BindValueChanged(accent => AccentColour = GetBodyAccentColour(skin, accent.NewValue), true);
|
AccentColourBindable.BindValueChanged(accent => AccentColour = GetBodyAccentColour(skin, accent.NewValue), true);
|
||||||
|
@ -18,10 +18,12 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Judgements;
|
using osu.Game.Rulesets.Osu.Judgements;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.Taiko;
|
using osu.Game.Rulesets.Taiko;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Scoring.Legacy;
|
using osu.Game.Scoring.Legacy;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
|
||||||
@ -385,6 +387,42 @@ namespace osu.Game.Tests.Rulesets.Scoring
|
|||||||
Assert.That(scoreProcessor.Accuracy.Value, Is.Not.EqualTo(1));
|
Assert.That(scoreProcessor.Accuracy.Value, Is.Not.EqualTo(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNormalGrades()
|
||||||
|
{
|
||||||
|
scoreProcessor.ApplyBeatmap(new Beatmap());
|
||||||
|
|
||||||
|
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.X));
|
||||||
|
|
||||||
|
scoreProcessor.Accuracy.Value = 0.99f;
|
||||||
|
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.S));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSilverGrades()
|
||||||
|
{
|
||||||
|
scoreProcessor.ApplyBeatmap(new Beatmap());
|
||||||
|
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.X));
|
||||||
|
|
||||||
|
scoreProcessor.Mods.Value = new[] { new OsuModHidden() };
|
||||||
|
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.XH));
|
||||||
|
|
||||||
|
scoreProcessor.Accuracy.Value = 0.99f;
|
||||||
|
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.SH));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSilverGradesModsAppliedFirst()
|
||||||
|
{
|
||||||
|
scoreProcessor.Mods.Value = new[] { new OsuModHidden() };
|
||||||
|
scoreProcessor.ApplyBeatmap(new Beatmap());
|
||||||
|
|
||||||
|
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.XH));
|
||||||
|
|
||||||
|
scoreProcessor.Accuracy.Value = 0.99f;
|
||||||
|
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.SH));
|
||||||
|
}
|
||||||
|
|
||||||
private class TestJudgement : Judgement
|
private class TestJudgement : Judgement
|
||||||
{
|
{
|
||||||
public override HitResult MaxResult { get; }
|
public override HitResult MaxResult { get; }
|
||||||
|
@ -35,6 +35,7 @@ using osu.Game.Screens.OnlinePlay.Lounge;
|
|||||||
using osu.Game.Screens.OnlinePlay.Match.Components;
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Screens.Select.Carousel;
|
using osu.Game.Screens.Select.Carousel;
|
||||||
@ -834,6 +835,24 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
AddAssert("exit dialog is shown", () => Game.Dependencies.Get<IDialogOverlay>().CurrentDialog is ConfirmExitDialog);
|
AddAssert("exit dialog is shown", () => Game.Dependencies.Get<IDialogOverlay>().CurrentDialog is ConfirmExitDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestQuickSkinEditorDoesntNukeSkin()
|
||||||
|
{
|
||||||
|
AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
|
||||||
|
|
||||||
|
AddStep("open", () => InputManager.Key(Key.Space));
|
||||||
|
AddStep("skin", () => InputManager.Key(Key.E));
|
||||||
|
AddStep("editor", () => InputManager.Key(Key.S));
|
||||||
|
AddStep("and close immediately", () => InputManager.Key(Key.Escape));
|
||||||
|
|
||||||
|
AddStep("open again", () => InputManager.Key(Key.S));
|
||||||
|
|
||||||
|
Player player = null;
|
||||||
|
|
||||||
|
AddUntilStep("wait for player", () => (player = Game.ScreenStack.CurrentScreen as Player) != null);
|
||||||
|
AddUntilStep("wait for gameplay still has health bar", () => player.ChildrenOfType<ArgonHealthDisplay>().Any());
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestTouchScreenDetectionAtSongSelect()
|
public void TestTouchScreenDetectionAtSongSelect()
|
||||||
{
|
{
|
||||||
|
@ -164,7 +164,8 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.X,
|
||||||
|
Height = 28,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Spacing = new Vector2(10f, 0f),
|
Spacing = new Vector2(10f, 0f),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
|
|
||||||
protected override bool StartHidden => true;
|
protected override bool StartHidden => true;
|
||||||
|
|
||||||
private Drawable targetScreen = null!;
|
private Drawable? targetScreen;
|
||||||
|
|
||||||
private OsuTextFlowContainer headerText = null!;
|
private OsuTextFlowContainer headerText = null!;
|
||||||
|
|
||||||
@ -541,8 +541,14 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
if (!hasBegunMutating)
|
if (!hasBegunMutating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (targetScreen?.IsLoaded != true)
|
||||||
|
return;
|
||||||
|
|
||||||
SkinComponentsContainer[] targetContainers = availableTargets.ToArray();
|
SkinComponentsContainer[] targetContainers = availableTargets.ToArray();
|
||||||
|
|
||||||
|
if (!targetContainers.All(c => c.ComponentsLoaded))
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (var t in targetContainers)
|
foreach (var t in targetContainers)
|
||||||
currentSkin.Value.UpdateDrawableTarget(t);
|
currentSkin.Value.UpdateDrawableTarget(t);
|
||||||
|
|
||||||
|
@ -136,10 +136,15 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
globallyReenableBeatmapSkinSetting();
|
globallyReenableBeatmapSkinSetting();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PresentGameplay()
|
public void PresentGameplay() => presentGameplay(false);
|
||||||
|
|
||||||
|
private void presentGameplay(bool attemptedBeatmapSwitch)
|
||||||
{
|
{
|
||||||
performer?.PerformFromScreen(screen =>
|
performer?.PerformFromScreen(screen =>
|
||||||
{
|
{
|
||||||
|
if (State.Value != Visibility.Visible)
|
||||||
|
return;
|
||||||
|
|
||||||
if (beatmap.Value is DummyWorkingBeatmap)
|
if (beatmap.Value is DummyWorkingBeatmap)
|
||||||
{
|
{
|
||||||
// presume we don't have anything good to play and just bail.
|
// presume we don't have anything good to play and just bail.
|
||||||
@ -149,8 +154,12 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
// If we're playing the intro, switch away to another beatmap.
|
// If we're playing the intro, switch away to another beatmap.
|
||||||
if (beatmap.Value.BeatmapSetInfo.Protected)
|
if (beatmap.Value.BeatmapSetInfo.Protected)
|
||||||
{
|
{
|
||||||
music.NextTrack();
|
if (!attemptedBeatmapSwitch)
|
||||||
Schedule(PresentGameplay);
|
{
|
||||||
|
music.NextTrack();
|
||||||
|
Schedule(() => presentGameplay(true));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,11 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsHit => Type.IsHit();
|
public bool IsHit => Type.IsHit();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The increase in health resulting from this judgement result.
|
||||||
|
/// </summary>
|
||||||
|
public double HealthIncrease => Judgement.HealthIncreaseFor(this);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="JudgementResult"/>.
|
/// Creates a new <see cref="JudgementResult"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="result">The <see cref="JudgementResult"/>.</param>
|
/// <param name="result">The <see cref="JudgementResult"/>.</param>
|
||||||
/// <returns>The health increase.</returns>
|
/// <returns>The health increase.</returns>
|
||||||
protected virtual double GetHealthIncreaseFor(JudgementResult result) => result.Judgement.HealthIncreaseFor(result);
|
protected virtual double GetHealthIncreaseFor(JudgementResult result) => result.HealthIncrease;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default conditions for failing.
|
/// The default conditions for failing.
|
||||||
|
@ -186,16 +186,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
Ruleset = ruleset;
|
Ruleset = ruleset;
|
||||||
|
|
||||||
Combo.ValueChanged += combo => HighestCombo.Value = Math.Max(HighestCombo.Value, combo.NewValue);
|
Combo.ValueChanged += combo => HighestCombo.Value = Math.Max(HighestCombo.Value, combo.NewValue);
|
||||||
Accuracy.ValueChanged += accuracy =>
|
Accuracy.ValueChanged += _ => updateRank();
|
||||||
{
|
|
||||||
// Once failed, we shouldn't update the rank anymore.
|
|
||||||
if (rank.Value == ScoreRank.F)
|
|
||||||
return;
|
|
||||||
|
|
||||||
rank.Value = RankFromAccuracy(accuracy.NewValue);
|
|
||||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
|
||||||
rank.Value = mod.AdjustRank(Rank.Value, accuracy.NewValue);
|
|
||||||
};
|
|
||||||
|
|
||||||
Mods.ValueChanged += mods =>
|
Mods.ValueChanged += mods =>
|
||||||
{
|
{
|
||||||
@ -205,6 +196,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
scoreMultiplier *= m.ScoreMultiplier;
|
scoreMultiplier *= m.ScoreMultiplier;
|
||||||
|
|
||||||
updateScore();
|
updateScore();
|
||||||
|
updateRank();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,6 +364,17 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
TotalScore.Value = (long)Math.Round(ComputeTotalScore(comboProgress, accuracyProcess, currentBonusPortion) * scoreMultiplier);
|
TotalScore.Value = (long)Math.Round(ComputeTotalScore(comboProgress, accuracyProcess, currentBonusPortion) * scoreMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateRank()
|
||||||
|
{
|
||||||
|
// Once failed, we shouldn't update the rank anymore.
|
||||||
|
if (rank.Value == ScoreRank.F)
|
||||||
|
return;
|
||||||
|
|
||||||
|
rank.Value = RankFromAccuracy(Accuracy.Value);
|
||||||
|
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||||
|
rank.Value = mod.AdjustRank(Rank.Value, Accuracy.Value);
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual double ComputeTotalScore(double comboProgress, double accuracyProgress, double bonusPortion)
|
protected virtual double ComputeTotalScore(double comboProgress, double accuracyProgress, double bonusPortion)
|
||||||
{
|
{
|
||||||
return 500000 * Accuracy.Value * comboProgress +
|
return 500000 * Accuracy.Value * comboProgress +
|
||||||
@ -417,8 +420,8 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
TotalScore.Value = 0;
|
TotalScore.Value = 0;
|
||||||
Accuracy.Value = 1;
|
Accuracy.Value = 1;
|
||||||
Combo.Value = 0;
|
Combo.Value = 0;
|
||||||
rank.Value = ScoreRank.X;
|
|
||||||
HighestCombo.Value = 0;
|
HighestCombo.Value = 0;
|
||||||
|
updateRank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -2,23 +2,19 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Caching;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Lines;
|
|
||||||
using osu.Framework.Layout;
|
using osu.Framework.Layout;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Screens.Play.HUD.ArgonHealthDisplayParts;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -40,16 +36,14 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
[SettingSource("Use relative size")]
|
[SettingSource("Use relative size")]
|
||||||
public BindableBool UseRelativeSize { get; } = new BindableBool(true);
|
public BindableBool UseRelativeSize { get; } = new BindableBool(true);
|
||||||
|
|
||||||
private BarPath mainBar = null!;
|
private ArgonHealthDisplayBar mainBar = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to show a glow at the end of the main bar, or red "damage" area when missing.
|
/// Used to show a glow at the end of the main bar, or red "damage" area when missing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private BarPath glowBar = null!;
|
private ArgonHealthDisplayBar glowBar = null!;
|
||||||
|
|
||||||
private BackgroundPath background = null!;
|
private Container content = null!;
|
||||||
|
|
||||||
private SliderPath barPath = null!;
|
|
||||||
|
|
||||||
private static readonly Colour4 main_bar_colour = Colour4.White;
|
private static readonly Colour4 main_bar_colour = Colour4.White;
|
||||||
private static readonly Colour4 main_bar_glow_colour = Color4Extensions.FromHex("#7ED7FD").Opacity(0.5f);
|
private static readonly Colour4 main_bar_glow_colour = Color4Extensions.FromHex("#7ED7FD").Opacity(0.5f);
|
||||||
@ -58,23 +52,17 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
private bool displayingMiss => resetMissBarDelegate != null;
|
private bool displayingMiss => resetMissBarDelegate != null;
|
||||||
|
|
||||||
private readonly List<Vector2> vertices = new List<Vector2>();
|
|
||||||
|
|
||||||
private double glowBarValue;
|
private double glowBarValue;
|
||||||
|
|
||||||
private double healthBarValue;
|
private double healthBarValue;
|
||||||
|
|
||||||
public const float MAIN_PATH_RADIUS = 10f;
|
public const float MAIN_PATH_RADIUS = 10f;
|
||||||
|
|
||||||
private const float curve_start_offset = 70;
|
|
||||||
private const float curve_end_offset = 40;
|
|
||||||
private const float padding = MAIN_PATH_RADIUS * 2;
|
private const float padding = MAIN_PATH_RADIUS * 2;
|
||||||
private const float curve_smoothness = 10;
|
private const float glow_path_radius = 40f;
|
||||||
|
private const float main_path_glow_portion = 0.6f;
|
||||||
|
|
||||||
private readonly LayoutValue drawSizeLayout = new LayoutValue(Invalidation.DrawSize);
|
private readonly LayoutValue drawSizeLayout = new LayoutValue(Invalidation.DrawSize);
|
||||||
|
|
||||||
private readonly Cached pathVerticesCache = new Cached();
|
|
||||||
|
|
||||||
public ArgonHealthDisplay()
|
public ArgonHealthDisplay()
|
||||||
{
|
{
|
||||||
AddLayout(drawSizeLayout);
|
AddLayout(drawSizeLayout);
|
||||||
@ -92,36 +80,39 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
InternalChild = new Container
|
InternalChild = content = new Container
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
background = new BackgroundPath
|
new ArgonHealthDisplayBackground
|
||||||
{
|
{
|
||||||
PathRadius = MAIN_PATH_RADIUS,
|
RelativeSizeAxes = Axes.Both
|
||||||
},
|
},
|
||||||
glowBar = new BarPath
|
new Container
|
||||||
{
|
{
|
||||||
BarColour = Color4.White,
|
RelativeSizeAxes = Axes.Both,
|
||||||
GlowColour = main_bar_glow_colour,
|
// since we are using bigger path radius we need to expand the draw area outwards to preserve the curve placement
|
||||||
Blending = BlendingParameters.Additive,
|
Padding = new MarginPadding(MAIN_PATH_RADIUS - glow_path_radius),
|
||||||
Colour = ColourInfo.GradientHorizontal(Color4.White.Opacity(0.8f), Color4.White),
|
Child = glowBar = new ArgonHealthDisplayBar
|
||||||
PathRadius = 40f,
|
{
|
||||||
// Kinda hacky, but results in correct positioning with increased path radius.
|
RelativeSizeAxes = Axes.Both,
|
||||||
Margin = new MarginPadding(-30f),
|
BarColour = Color4.White,
|
||||||
GlowPortion = 0.9f,
|
GlowColour = main_bar_glow_colour,
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
Colour = ColourInfo.GradientHorizontal(Color4.White.Opacity(0.8f), Color4.White),
|
||||||
|
PathRadius = glow_path_radius,
|
||||||
|
GlowPortion = (glow_path_radius - MAIN_PATH_RADIUS * (1f - main_path_glow_portion)) / glow_path_radius,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mainBar = new BarPath
|
mainBar = new ArgonHealthDisplayBar
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.None,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Blending = BlendingParameters.Additive,
|
Blending = BlendingParameters.Additive,
|
||||||
BarColour = main_bar_colour,
|
BarColour = main_bar_colour,
|
||||||
GlowColour = main_bar_glow_colour,
|
GlowColour = main_bar_glow_colour,
|
||||||
PathRadius = MAIN_PATH_RADIUS,
|
PathRadius = MAIN_PATH_RADIUS,
|
||||||
GlowPortion = 0.6f,
|
GlowPortion = main_path_glow_portion
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -142,10 +133,15 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
UseRelativeSize.BindValueChanged(v => RelativeSizeAxes = v.NewValue ? Axes.X : Axes.None, true);
|
UseRelativeSize.BindValueChanged(v => RelativeSizeAxes = v.NewValue ? Axes.X : Axes.None, true);
|
||||||
Width = previousWidth;
|
Width = previousWidth;
|
||||||
|
|
||||||
BarHeight.BindValueChanged(_ => updatePath(), true);
|
BarHeight.BindValueChanged(_ => updateContentSize(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onNewJudgement(JudgementResult result) => pendingMissAnimation |= !result.IsHit;
|
private void onNewJudgement(JudgementResult result)
|
||||||
|
{
|
||||||
|
// Check the health increase because cases like osu!catch bananas fire `IgnoreMiss`,
|
||||||
|
// which counts as a miss but doesn't actually subtract any health.
|
||||||
|
pendingMissAnimation |= !result.IsHit && result.HealthIncrease < 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
@ -153,7 +149,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
if (!drawSizeLayout.IsValid)
|
if (!drawSizeLayout.IsValid)
|
||||||
{
|
{
|
||||||
updatePath();
|
updateContentSize();
|
||||||
drawSizeLayout.Validate();
|
drawSizeLayout.Validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +160,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
mainBar.Alpha = (float)Interpolation.DampContinuously(mainBar.Alpha, Current.Value > 0 ? 1 : 0, 40, Time.Elapsed);
|
mainBar.Alpha = (float)Interpolation.DampContinuously(mainBar.Alpha, Current.Value > 0 ? 1 : 0, 40, Time.Elapsed);
|
||||||
glowBar.Alpha = (float)Interpolation.DampContinuously(glowBar.Alpha, glowBarValue > 0 ? 1 : 0, 40, Time.Elapsed);
|
glowBar.Alpha = (float)Interpolation.DampContinuously(glowBar.Alpha, glowBarValue > 0 ? 1 : 0, 40, Time.Elapsed);
|
||||||
|
|
||||||
updatePathVertices();
|
updatePathProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void HealthChanged(bool increase)
|
protected override void HealthChanged(bool increase)
|
||||||
@ -194,10 +190,9 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
if (!displayingMiss)
|
if (!displayingMiss)
|
||||||
{
|
{
|
||||||
// TODO: REMOVE THIS. It's recreating textures.
|
glowBar.TransformTo(nameof(ArgonHealthDisplayBar.GlowColour), Colour4.White, 30, Easing.OutQuint)
|
||||||
glowBar.TransformTo(nameof(BarPath.GlowColour), Colour4.White, 30, Easing.OutQuint)
|
|
||||||
.Then()
|
.Then()
|
||||||
.TransformTo(nameof(BarPath.GlowColour), main_bar_glow_colour, 300, Easing.OutQuint);
|
.TransformTo(nameof(ArgonHealthDisplayBar.GlowColour), main_bar_glow_colour, 300, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,13 +207,11 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
finishMissDisplay();
|
finishMissDisplay();
|
||||||
}, out resetMissBarDelegate);
|
}, out resetMissBarDelegate);
|
||||||
|
|
||||||
// TODO: REMOVE THIS. It's recreating textures.
|
glowBar.TransformTo(nameof(ArgonHealthDisplayBar.BarColour), new Colour4(255, 147, 147, 255), 100, Easing.OutQuint).Then()
|
||||||
glowBar.TransformTo(nameof(BarPath.BarColour), new Colour4(255, 147, 147, 255), 100, Easing.OutQuint).Then()
|
.TransformTo(nameof(ArgonHealthDisplayBar.BarColour), new Colour4(255, 93, 93, 255), 800, Easing.OutQuint);
|
||||||
.TransformTo(nameof(BarPath.BarColour), new Colour4(255, 93, 93, 255), 800, Easing.OutQuint);
|
|
||||||
|
|
||||||
// TODO: REMOVE THIS. It's recreating textures.
|
glowBar.TransformTo(nameof(ArgonHealthDisplayBar.GlowColour), new Colour4(253, 0, 0, 255).Lighten(0.2f))
|
||||||
glowBar.TransformTo(nameof(BarPath.GlowColour), new Colour4(253, 0, 0, 255).Lighten(0.2f))
|
.TransformTo(nameof(ArgonHealthDisplayBar.GlowColour), new Colour4(253, 0, 0, 255), 800, Easing.OutQuint);
|
||||||
.TransformTo(nameof(BarPath.GlowColour), new Colour4(253, 0, 0, 255), 800, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishMissDisplay()
|
private void finishMissDisplay()
|
||||||
@ -228,53 +221,22 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
if (Current.Value > 0)
|
if (Current.Value > 0)
|
||||||
{
|
{
|
||||||
// TODO: REMOVE THIS. It's recreating textures.
|
glowBar.TransformTo(nameof(ArgonHealthDisplayBar.BarColour), main_bar_colour, 300, Easing.In);
|
||||||
glowBar.TransformTo(nameof(BarPath.BarColour), main_bar_colour, 300, Easing.In);
|
glowBar.TransformTo(nameof(ArgonHealthDisplayBar.GlowColour), main_bar_glow_colour, 300, Easing.In);
|
||||||
glowBar.TransformTo(nameof(BarPath.GlowColour), main_bar_glow_colour, 300, Easing.In);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetMissBarDelegate?.Cancel();
|
resetMissBarDelegate?.Cancel();
|
||||||
resetMissBarDelegate = null;
|
resetMissBarDelegate = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePath()
|
private void updateContentSize()
|
||||||
{
|
{
|
||||||
float usableWidth = DrawWidth - padding;
|
float usableWidth = DrawWidth - padding;
|
||||||
|
|
||||||
if (usableWidth < 0) enforceMinimumWidth();
|
if (usableWidth < 0) enforceMinimumWidth();
|
||||||
|
|
||||||
// the display starts curving at `curve_start_offset` units from the right and ends curving at `curve_end_offset`.
|
content.Size = new Vector2(DrawWidth, BarHeight.Value + padding);
|
||||||
// to ensure that the curve is symmetric when it starts being narrow enough, add a `curve_end_offset` to the left side too.
|
updatePathProgress();
|
||||||
const float rescale_cutoff = curve_start_offset + curve_end_offset;
|
|
||||||
|
|
||||||
float barLength = Math.Max(DrawWidth - padding, rescale_cutoff);
|
|
||||||
float curveStart = barLength - curve_start_offset;
|
|
||||||
float curveEnd = barLength - curve_end_offset;
|
|
||||||
|
|
||||||
Vector2 diagonalDir = (new Vector2(curveEnd, BarHeight.Value) - new Vector2(curveStart, 0)).Normalized();
|
|
||||||
|
|
||||||
barPath = new SliderPath(new[]
|
|
||||||
{
|
|
||||||
new PathControlPoint(new Vector2(0, 0), PathType.LINEAR),
|
|
||||||
new PathControlPoint(new Vector2(curveStart - curve_smoothness, 0), PathType.BEZIER),
|
|
||||||
new PathControlPoint(new Vector2(curveStart, 0)),
|
|
||||||
new PathControlPoint(new Vector2(curveStart, 0) + diagonalDir * curve_smoothness, PathType.LINEAR),
|
|
||||||
new PathControlPoint(new Vector2(curveEnd, BarHeight.Value) - diagonalDir * curve_smoothness, PathType.BEZIER),
|
|
||||||
new PathControlPoint(new Vector2(curveEnd, BarHeight.Value)),
|
|
||||||
new PathControlPoint(new Vector2(curveEnd + curve_smoothness, BarHeight.Value), PathType.LINEAR),
|
|
||||||
new PathControlPoint(new Vector2(barLength, BarHeight.Value)),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (DrawWidth - padding < rescale_cutoff)
|
|
||||||
rescalePathProportionally();
|
|
||||||
|
|
||||||
barPath.GetPathToProgress(vertices, 0.0, 1.0);
|
|
||||||
|
|
||||||
background.Vertices = vertices;
|
|
||||||
mainBar.Vertices = vertices;
|
|
||||||
glowBar.Vertices = vertices;
|
|
||||||
|
|
||||||
updatePathVertices();
|
|
||||||
|
|
||||||
void enforceMinimumWidth()
|
void enforceMinimumWidth()
|
||||||
{
|
{
|
||||||
@ -287,35 +249,12 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
RelativeSizeAxes = relativeAxes;
|
RelativeSizeAxes = relativeAxes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rescalePathProportionally()
|
|
||||||
{
|
|
||||||
foreach (var point in barPath.ControlPoints)
|
|
||||||
point.Position = new Vector2(point.Position.X / barLength * (DrawWidth - padding), point.Position.Y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePathVertices()
|
private void updatePathProgress()
|
||||||
{
|
{
|
||||||
barPath.GetPathToProgress(vertices, 0.0, healthBarValue);
|
mainBar.ProgressRange = new Vector2(0f, (float)healthBarValue);
|
||||||
if (vertices.Count == 0) vertices.Add(Vector2.Zero);
|
glowBar.ProgressRange = new Vector2((float)healthBarValue, (float)Math.Max(glowBarValue, healthBarValue));
|
||||||
Vector2 initialVertex = vertices[0];
|
|
||||||
for (int i = 0; i < vertices.Count; i++)
|
|
||||||
vertices[i] -= initialVertex;
|
|
||||||
|
|
||||||
mainBar.Vertices = vertices;
|
|
||||||
mainBar.Position = initialVertex;
|
|
||||||
|
|
||||||
barPath.GetPathToProgress(vertices, healthBarValue, Math.Max(glowBarValue, healthBarValue));
|
|
||||||
if (vertices.Count == 0) vertices.Add(Vector2.Zero);
|
|
||||||
initialVertex = vertices[0];
|
|
||||||
for (int i = 0; i < vertices.Count; i++)
|
|
||||||
vertices[i] -= initialVertex;
|
|
||||||
|
|
||||||
glowBar.Vertices = vertices;
|
|
||||||
glowBar.Position = initialVertex;
|
|
||||||
|
|
||||||
pathVerticesCache.Validate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
@ -325,67 +264,5 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
if (HealthProcessor.IsNotNull())
|
if (HealthProcessor.IsNotNull())
|
||||||
HealthProcessor.NewJudgement -= onNewJudgement;
|
HealthProcessor.NewJudgement -= onNewJudgement;
|
||||||
}
|
}
|
||||||
|
|
||||||
private partial class BackgroundPath : SmoothPath
|
|
||||||
{
|
|
||||||
private static readonly Color4 colour_white = Color4.White.Opacity(0.8f);
|
|
||||||
private static readonly Color4 colour_black = Color4.Black.Opacity(0.2f);
|
|
||||||
|
|
||||||
protected override Color4 ColourAt(float position)
|
|
||||||
{
|
|
||||||
if (position <= 0.16f)
|
|
||||||
return colour_white;
|
|
||||||
|
|
||||||
return Interpolation.ValueAt(position,
|
|
||||||
colour_white,
|
|
||||||
colour_black,
|
|
||||||
-0.5f, 1f, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private partial class BarPath : SmoothPath
|
|
||||||
{
|
|
||||||
private Colour4 barColour;
|
|
||||||
|
|
||||||
public Colour4 BarColour
|
|
||||||
{
|
|
||||||
get => barColour;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (barColour == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
barColour = value;
|
|
||||||
InvalidateTexture();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Colour4 glowColour;
|
|
||||||
|
|
||||||
public Colour4 GlowColour
|
|
||||||
{
|
|
||||||
get => glowColour;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (glowColour == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
glowColour = value;
|
|
||||||
InvalidateTexture();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float GlowPortion { get; init; }
|
|
||||||
|
|
||||||
private static readonly Colour4 transparent_black = Colour4.Black.Opacity(0.0f);
|
|
||||||
|
|
||||||
protected override Color4 ColourAt(float position)
|
|
||||||
{
|
|
||||||
if (position >= GlowPortion)
|
|
||||||
return BarColour;
|
|
||||||
|
|
||||||
return Interpolation.ValueAt(position, transparent_black, GlowColour, 0.0, GlowPortion, Easing.InQuint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
// 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 System.Runtime.InteropServices;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Rendering;
|
||||||
|
using osu.Framework.Graphics.Shaders;
|
||||||
|
using osu.Framework.Graphics.Shaders.Types;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD.ArgonHealthDisplayParts
|
||||||
|
{
|
||||||
|
public partial class ArgonHealthDisplayBackground : Box
|
||||||
|
{
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(ShaderManager shaders)
|
||||||
|
{
|
||||||
|
TextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, "ArgonBarPathBackground");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawNode CreateDrawNode() => new ArgonBarPathDrawNode(this);
|
||||||
|
|
||||||
|
private class ArgonBarPathDrawNode : SpriteDrawNode
|
||||||
|
{
|
||||||
|
protected new ArgonHealthDisplayBackground Source => (ArgonHealthDisplayBackground)base.Source;
|
||||||
|
|
||||||
|
private IUniformBuffer<ArgonBarPathBackgroundParameters>? parametersBuffer;
|
||||||
|
|
||||||
|
public ArgonBarPathDrawNode(ArgonHealthDisplayBackground source)
|
||||||
|
: base(source)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector2 size;
|
||||||
|
|
||||||
|
public override void ApplyState()
|
||||||
|
{
|
||||||
|
base.ApplyState();
|
||||||
|
size = Source.DrawSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void BindUniformResources(IShader shader, IRenderer renderer)
|
||||||
|
{
|
||||||
|
base.BindUniformResources(shader, renderer);
|
||||||
|
|
||||||
|
parametersBuffer ??= renderer.CreateUniformBuffer<ArgonBarPathBackgroundParameters>();
|
||||||
|
parametersBuffer.Data = new ArgonBarPathBackgroundParameters { Size = size };
|
||||||
|
|
||||||
|
shader.BindUniformBlock("m_ArgonBarPathBackgroundParameters", parametersBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool CanDrawOpaqueInterior => false;
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
parametersBuffer?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
|
private record struct ArgonBarPathBackgroundParameters
|
||||||
|
{
|
||||||
|
public UniformVector2 Size;
|
||||||
|
private readonly UniformPadding8 pad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,181 @@
|
|||||||
|
// 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 System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Rendering;
|
||||||
|
using osu.Framework.Graphics.Shaders;
|
||||||
|
using osu.Framework.Graphics.Shaders.Types;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD.ArgonHealthDisplayParts
|
||||||
|
{
|
||||||
|
public partial class ArgonHealthDisplayBar : Box
|
||||||
|
{
|
||||||
|
private Vector2 progressRange = new Vector2(0f, 1f);
|
||||||
|
|
||||||
|
public Vector2 ProgressRange
|
||||||
|
{
|
||||||
|
get => progressRange;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (progressRange == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
progressRange = value;
|
||||||
|
Invalidate(Invalidation.DrawNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float radius = 10f;
|
||||||
|
|
||||||
|
public float PathRadius
|
||||||
|
{
|
||||||
|
get => radius;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (radius == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
radius = value;
|
||||||
|
Invalidate(Invalidation.DrawNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float glowPortion;
|
||||||
|
|
||||||
|
public float GlowPortion
|
||||||
|
{
|
||||||
|
get => glowPortion;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (glowPortion == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
glowPortion = value;
|
||||||
|
Invalidate(Invalidation.DrawNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Colour4 barColour = Color4.White;
|
||||||
|
|
||||||
|
public Colour4 BarColour
|
||||||
|
{
|
||||||
|
get => barColour;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (barColour == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
barColour = value;
|
||||||
|
Invalidate(Invalidation.DrawNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Colour4 glowColour = Color4.White.Opacity(0);
|
||||||
|
|
||||||
|
public Colour4 GlowColour
|
||||||
|
{
|
||||||
|
get => glowColour;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (glowColour == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
glowColour = value;
|
||||||
|
Invalidate(Invalidation.DrawNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(ShaderManager shaders)
|
||||||
|
{
|
||||||
|
TextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, "ArgonBarPath");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawNode CreateDrawNode() => new ArgonBarPathDrawNode(this);
|
||||||
|
|
||||||
|
private class ArgonBarPathDrawNode : SpriteDrawNode
|
||||||
|
{
|
||||||
|
protected new ArgonHealthDisplayBar Source => (ArgonHealthDisplayBar)base.Source;
|
||||||
|
|
||||||
|
private IUniformBuffer<ArgonBarPathParameters>? parametersBuffer;
|
||||||
|
|
||||||
|
public ArgonBarPathDrawNode(ArgonHealthDisplayBar source)
|
||||||
|
: base(source)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector2 size;
|
||||||
|
private Vector2 progressRange;
|
||||||
|
private float pathRadius;
|
||||||
|
private float glowPortion;
|
||||||
|
private Color4 barColour;
|
||||||
|
private Color4 glowColour;
|
||||||
|
|
||||||
|
public override void ApplyState()
|
||||||
|
{
|
||||||
|
base.ApplyState();
|
||||||
|
|
||||||
|
size = Source.DrawSize;
|
||||||
|
progressRange = new Vector2(Math.Min(Source.progressRange.X, Source.progressRange.Y), Source.progressRange.Y);
|
||||||
|
pathRadius = Source.PathRadius;
|
||||||
|
glowPortion = Source.GlowPortion;
|
||||||
|
barColour = Source.barColour;
|
||||||
|
glowColour = Source.glowColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Draw(IRenderer renderer)
|
||||||
|
{
|
||||||
|
if (pathRadius == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
base.Draw(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void BindUniformResources(IShader shader, IRenderer renderer)
|
||||||
|
{
|
||||||
|
base.BindUniformResources(shader, renderer);
|
||||||
|
|
||||||
|
parametersBuffer ??= renderer.CreateUniformBuffer<ArgonBarPathParameters>();
|
||||||
|
parametersBuffer.Data = new ArgonBarPathParameters
|
||||||
|
{
|
||||||
|
BarColour = new Vector4(barColour.R, barColour.G, barColour.B, barColour.A),
|
||||||
|
GlowColour = new Vector4(glowColour.R, glowColour.G, glowColour.B, glowColour.A),
|
||||||
|
GlowPortion = glowPortion,
|
||||||
|
Size = size,
|
||||||
|
ProgressRange = progressRange,
|
||||||
|
PathRadius = pathRadius
|
||||||
|
};
|
||||||
|
|
||||||
|
shader.BindUniformBlock("m_ArgonBarPathParameters", parametersBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool CanDrawOpaqueInterior => false;
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
parametersBuffer?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
|
private record struct ArgonBarPathParameters
|
||||||
|
{
|
||||||
|
public UniformVector4 BarColour;
|
||||||
|
public UniformVector4 GlowColour;
|
||||||
|
public UniformVector2 Size;
|
||||||
|
public UniformVector2 ProgressRange;
|
||||||
|
public UniformFloat PathRadius;
|
||||||
|
public UniformFloat GlowPortion;
|
||||||
|
private readonly UniformPadding8 pad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -37,7 +37,7 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Realm" Version="11.5.0" />
|
<PackageReference Include="Realm" Version="11.5.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2024.114.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2024.114.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.1228.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.116.0" />
|
||||||
<PackageReference Include="Sentry" Version="3.40.0" />
|
<PackageReference Include="Sentry" Version="3.40.0" />
|
||||||
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
||||||
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user