mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Add option to hide health bar when mod disallows failing (#5187)
Add option to hide health bar when mod disallows failing Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
@ -13,13 +13,11 @@ using static osu.Game.Input.Handlers.ReplayInputHandler;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Mods
|
namespace osu.Game.Rulesets.Osu.Mods
|
||||||
{
|
{
|
||||||
public class OsuModRelax : ModRelax, IApplicableFailOverride, IUpdatableByPlayfield, IApplicableToDrawableRuleset<OsuHitObject>
|
public class OsuModRelax : ModRelax, IUpdatableByPlayfield, IApplicableToDrawableRuleset<OsuHitObject>
|
||||||
{
|
{
|
||||||
public override string Description => @"You don't need to click. Give your clicking/tapping fingers a break from the heat of things.";
|
public override string Description => @"You don't need to click. Give your clicking/tapping fingers a break from the heat of things.";
|
||||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray();
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray();
|
||||||
|
|
||||||
public bool AllowFail => false;
|
|
||||||
|
|
||||||
public void Update(Playfield playfield)
|
public void Update(Playfield playfield)
|
||||||
{
|
{
|
||||||
bool requiresHold = false;
|
bool requiresHold = false;
|
||||||
|
@ -77,6 +77,7 @@ namespace osu.Game.Configuration
|
|||||||
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
|
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
|
||||||
|
|
||||||
Set(OsuSetting.ShowInterface, true);
|
Set(OsuSetting.ShowInterface, true);
|
||||||
|
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
|
||||||
Set(OsuSetting.KeyOverlay, false);
|
Set(OsuSetting.KeyOverlay, false);
|
||||||
|
|
||||||
Set(OsuSetting.FloatingComments, false);
|
Set(OsuSetting.FloatingComments, false);
|
||||||
@ -131,6 +132,7 @@ namespace osu.Game.Configuration
|
|||||||
KeyOverlay,
|
KeyOverlay,
|
||||||
FloatingComments,
|
FloatingComments,
|
||||||
ShowInterface,
|
ShowInterface,
|
||||||
|
ShowHealthDisplayWhenCantFail,
|
||||||
MouseDisableButtons,
|
MouseDisableButtons,
|
||||||
MouseDisableWheel,
|
MouseDisableWheel,
|
||||||
AudioOffset,
|
AudioOffset,
|
||||||
|
@ -35,6 +35,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
|||||||
Bindable = config.GetBindable<bool>(OsuSetting.ShowInterface)
|
Bindable = config.GetBindable<bool>(OsuSetting.ShowInterface)
|
||||||
},
|
},
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
|
{
|
||||||
|
LabelText = "Show health display even when you can't fail",
|
||||||
|
Bindable = config.GetBindable<bool>(OsuSetting.ShowHealthDisplayWhenCantFail),
|
||||||
|
},
|
||||||
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
LabelText = "Always show key overlay",
|
LabelText = "Always show key overlay",
|
||||||
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
||||||
|
18
osu.Game/Rulesets/Mods/IApplicableToHUD.cs
Normal file
18
osu.Game/Rulesets/Mods/IApplicableToHUD.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// 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.Game.Screens.Play;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mods
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An interface for mods that apply changes to the <see cref="HUDOverlay"/>.
|
||||||
|
/// </summary>
|
||||||
|
public interface IApplicableToHUD : IApplicableMod
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provide a <see cref="HUDOverlay"/>. Called once on initialisation of a play instance.
|
||||||
|
/// </summary>
|
||||||
|
void ApplyToHUD(HUDOverlay overlay);
|
||||||
|
}
|
||||||
|
}
|
29
osu.Game/Rulesets/Mods/ModBlockFail.cs
Normal file
29
osu.Game/Rulesets/Mods/ModBlockFail.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// 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.Bindables;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mods
|
||||||
|
{
|
||||||
|
public abstract class ModBlockFail : Mod, IApplicableFailOverride, IApplicableToHUD, IReadFromConfig
|
||||||
|
{
|
||||||
|
private Bindable<bool> showHealthBar;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// We never fail, 'yo.
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowFail => false;
|
||||||
|
|
||||||
|
public void ReadFromConfig(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
showHealthBar = config.GetBindable<bool>(OsuSetting.ShowHealthDisplayWhenCantFail);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyToHUD(HUDOverlay overlay)
|
||||||
|
{
|
||||||
|
overlay.ShowHealthbar.BindTo(showHealthBar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ using osu.Game.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public abstract class ModNoFail : Mod, IApplicableFailOverride
|
public abstract class ModNoFail : ModBlockFail
|
||||||
{
|
{
|
||||||
public override string Name => "No Fail";
|
public override string Name => "No Fail";
|
||||||
public override string Acronym => "NF";
|
public override string Acronym => "NF";
|
||||||
@ -17,10 +17,5 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
public override double ScoreMultiplier => 0.5;
|
public override double ScoreMultiplier => 0.5;
|
||||||
public override bool Ranked => true;
|
public override bool Ranked => true;
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModAutoplay) };
|
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModAutoplay) };
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// We never fail, 'yo.
|
|
||||||
/// </summary>
|
|
||||||
public bool AllowFail => false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ using osu.Game.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public abstract class ModRelax : Mod
|
public abstract class ModRelax : ModBlockFail
|
||||||
{
|
{
|
||||||
public override string Name => "Relax";
|
public override string Name => "Relax";
|
||||||
public override string Acronym => "RX";
|
public override string Acronym => "RX";
|
||||||
|
@ -23,7 +23,8 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
public class HUDOverlay : Container
|
public class HUDOverlay : Container
|
||||||
{
|
{
|
||||||
private const int duration = 100;
|
private const int duration = 250;
|
||||||
|
private const Easing easing = Easing.OutQuint;
|
||||||
|
|
||||||
public readonly KeyCounterDisplay KeyCounter;
|
public readonly KeyCounterDisplay KeyCounter;
|
||||||
public readonly RollingCounter<int> ComboCounter;
|
public readonly RollingCounter<int> ComboCounter;
|
||||||
@ -35,6 +36,8 @@ namespace osu.Game.Screens.Play
|
|||||||
public readonly HoldForMenuButton HoldToQuit;
|
public readonly HoldForMenuButton HoldToQuit;
|
||||||
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
|
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
|
||||||
|
|
||||||
|
public Bindable<bool> ShowHealthbar = new Bindable<bool>(true);
|
||||||
|
|
||||||
private readonly ScoreProcessor scoreProcessor;
|
private readonly ScoreProcessor scoreProcessor;
|
||||||
private readonly DrawableRuleset drawableRuleset;
|
private readonly DrawableRuleset drawableRuleset;
|
||||||
private readonly IReadOnlyList<Mod> mods;
|
private readonly IReadOnlyList<Mod> mods;
|
||||||
@ -47,6 +50,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public Action<double> RequestSeek;
|
public Action<double> RequestSeek;
|
||||||
|
|
||||||
|
private readonly Container topScoreContainer;
|
||||||
|
|
||||||
public HUDOverlay(ScoreProcessor scoreProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
|
public HUDOverlay(ScoreProcessor scoreProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
|
||||||
{
|
{
|
||||||
this.scoreProcessor = scoreProcessor;
|
this.scoreProcessor = scoreProcessor;
|
||||||
@ -62,11 +67,10 @@ namespace osu.Game.Screens.Play
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Container
|
topScoreContainer = new Container
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Y = 30,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
AutoSizeDuration = 200,
|
AutoSizeDuration = 200,
|
||||||
AutoSizeEasing = Easing.Out,
|
AutoSizeEasing = Easing.Out,
|
||||||
@ -113,8 +117,21 @@ namespace osu.Game.Screens.Play
|
|||||||
ModDisplay.Current.Value = mods;
|
ModDisplay.Current.Value = mods;
|
||||||
|
|
||||||
showHud = config.GetBindable<bool>(OsuSetting.ShowInterface);
|
showHud = config.GetBindable<bool>(OsuSetting.ShowInterface);
|
||||||
showHud.ValueChanged += visible => visibilityContainer.FadeTo(visible.NewValue ? 1 : 0, duration);
|
showHud.BindValueChanged(visible => visibilityContainer.FadeTo(visible.NewValue ? 1 : 0, duration, easing), true);
|
||||||
showHud.TriggerChange();
|
|
||||||
|
ShowHealthbar.BindValueChanged(healthBar =>
|
||||||
|
{
|
||||||
|
if (healthBar.NewValue)
|
||||||
|
{
|
||||||
|
HealthDisplay.FadeIn(duration, easing);
|
||||||
|
topScoreContainer.MoveToY(30, duration, easing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HealthDisplay.FadeOut(duration, easing);
|
||||||
|
topScoreContainer.MoveToY(0, duration, easing);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
if (!showHud.Value && !hasShownNotificationOnce)
|
if (!showHud.Value && !hasShownNotificationOnce)
|
||||||
{
|
{
|
||||||
|
@ -498,6 +498,9 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
GameplayClockContainer.Restart();
|
GameplayClockContainer.Restart();
|
||||||
GameplayClockContainer.FadeInFromZero(750, Easing.OutQuint);
|
GameplayClockContainer.FadeInFromZero(750, Easing.OutQuint);
|
||||||
|
|
||||||
|
foreach (var mod in Mods.Value.OfType<IApplicableToHUD>())
|
||||||
|
mod.ApplyToHUD(HUDOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSuspending(IScreen next)
|
public override void OnSuspending(IScreen next)
|
||||||
|
Reference in New Issue
Block a user