1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Remember state of replay settings visibility

This commit is contained in:
Dean Herbert 2023-07-06 00:46:28 +09:00
parent fbab5acac1
commit 95a9b532df
5 changed files with 45 additions and 54 deletions

View File

@ -129,6 +129,7 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.ShowHealthDisplayWhenCantFail, true);
SetDefault(OsuSetting.FadePlayfieldWhenHealthLow, true);
SetDefault(OsuSetting.KeyOverlay, false);
SetDefault(OsuSetting.ReplaySettingsOverlay, true);
SetDefault(OsuSetting.GameplayLeaderboard, true);
SetDefault(OsuSetting.AlwaysPlayFirstComboBreak, true);
@ -382,6 +383,7 @@ namespace osu.Game.Configuration
SafeAreaConsiderations,
ComboColourNormalisationAmount,
ProfileCoverExpanded,
EditorLimitedDistanceSnap
EditorLimitedDistanceSnap,
ReplaySettingsOverlay
}
}

View File

@ -65,10 +65,15 @@ namespace osu.Game.Localisation
public static LocalisableString HUDVisibilityMode => new TranslatableString(getKey(@"hud_visibility_mode"), @"HUD overlay visibility mode");
/// <summary>
/// "Show health display even when you can't fail"
/// "Show health display even when you can&#39;t fail"
/// </summary>
public static LocalisableString ShowHealthDisplayWhenCantFail => new TranslatableString(getKey(@"show_health_display_when_cant_fail"), @"Show health display even when you can't fail");
/// <summary>
/// "Show replay settings overlay"
/// </summary>
public static LocalisableString ShowReplaySettingsOverlay => new TranslatableString(getKey(@"show_replay_settings_overlay"), @"Show replay settings overlay");
/// <summary>
/// "Fade playfield to red when health is low"
/// </summary>
@ -134,6 +139,6 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString ClassicScoreDisplay => new TranslatableString(getKey(@"classic_score_display"), @"Classic");
private static string getKey(string key) => $"{prefix}:{key}";
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -25,10 +25,9 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
},
new SettingsCheckbox
{
ClassicDefault = false,
LabelText = GameplaySettingsStrings.ShowHealthDisplayWhenCantFail,
Current = config.GetBindable<bool>(OsuSetting.ShowHealthDisplayWhenCantFail),
Keywords = new[] { "hp", "bar" }
LabelText = GameplaySettingsStrings.ShowReplaySettingsOverlay,
Current = config.GetBindable<bool>(OsuSetting.ReplaySettingsOverlay),
Keywords = new[] { "hide" },
},
new SettingsCheckbox
{
@ -41,6 +40,13 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
LabelText = GameplaySettingsStrings.AlwaysShowGameplayLeaderboard,
Current = config.GetBindable<bool>(OsuSetting.GameplayLeaderboard),
},
new SettingsCheckbox
{
ClassicDefault = false,
LabelText = GameplaySettingsStrings.ShowHealthDisplayWhenCantFail,
Current = config.GetBindable<bool>(OsuSetting.ShowHealthDisplayWhenCantFail),
Keywords = new[] { "hp", "bar" }
},
};
}
}

View File

@ -3,10 +3,8 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osuTK;
using osu.Game.Screens.Play.PlayerSettings;
using osuTK.Input;
namespace osu.Game.Screens.Play.HUD
{
@ -14,16 +12,12 @@ namespace osu.Game.Screens.Play.HUD
{
private const int fade_duration = 200;
public bool ReplayLoaded;
public readonly PlaybackSettings PlaybackSettings;
public readonly VisualSettings VisualSettings;
public PlayerSettingsOverlay()
{
AlwaysPresent = true;
Anchor = Anchor.TopRight;
Origin = Anchor.TopRight;
AutoSizeAxes = Axes.Both;
@ -46,24 +40,5 @@ namespace osu.Game.Screens.Play.HUD
protected override void PopIn() => this.FadeIn(fade_duration);
protected override void PopOut() => this.FadeOut(fade_duration);
// We want to handle keyboard inputs all the time in order to trigger ToggleVisibility() when not visible
public override bool PropagateNonPositionalInputSubTree => true;
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.Repeat) return false;
if (e.ControlPressed)
{
if (e.Key == Key.H && ReplayLoaded)
{
ToggleVisibility();
return true;
}
}
return base.OnKeyDown(e);
}
}
}

View File

@ -28,6 +28,7 @@ using osu.Game.Screens.Play.HUD.ClicksPerSecond;
using osu.Game.Screens.Play.HUD.JudgementCounter;
using osu.Game.Skinning;
using osuTK;
using MarginPadding = osu.Framework.Graphics.MarginPadding;
namespace osu.Game.Screens.Play
{
@ -78,6 +79,7 @@ namespace osu.Game.Screens.Play
public Bindable<bool> ShowHud { get; } = new BindableBool();
private Bindable<HUDVisibilityMode> configVisibilityMode;
private Bindable<bool> configSettingsOverlay;
private readonly BindableBool replayLoaded = new BindableBool();
@ -178,6 +180,7 @@ namespace osu.Game.Screens.Play
ModDisplay.Current.Value = mods;
configVisibilityMode = config.GetBindable<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode);
configSettingsOverlay = config.GetBindable<bool>(OsuSetting.ReplaySettingsOverlay);
if (configVisibilityMode.Value == HUDVisibilityMode.Never && !hasShownNotificationOnce)
{
@ -204,9 +207,24 @@ namespace osu.Game.Screens.Play
holdingForHUD.BindValueChanged(_ => updateVisibility());
IsPlaying.BindValueChanged(_ => updateVisibility());
configVisibilityMode.BindValueChanged(_ => updateVisibility(), true);
configVisibilityMode.BindValueChanged(_ => updateVisibility());
configSettingsOverlay.BindValueChanged(_ => updateVisibility());
replayLoaded.BindValueChanged(replayLoadedValueChanged, true);
replayLoaded.BindValueChanged(e =>
{
if (e.NewValue)
{
ModDisplay.FadeIn(200);
InputCountController.Margin = new MarginPadding(10) { Bottom = 30 };
}
else
{
ModDisplay.Delay(2000).FadeOut(200);
InputCountController.Margin = new MarginPadding(10);
}
updateVisibility();
}, true);
}
protected override void Update()
@ -280,6 +298,11 @@ namespace osu.Game.Screens.Play
return;
}
if (configSettingsOverlay.Value && replayLoaded.Value)
PlayerSettingsOverlay.Show();
else
PlayerSettingsOverlay.Hide();
switch (configVisibilityMode.Value)
{
case HUDVisibilityMode.Never:
@ -297,26 +320,6 @@ namespace osu.Game.Screens.Play
}
}
private void replayLoadedValueChanged(ValueChangedEvent<bool> e)
{
PlayerSettingsOverlay.ReplayLoaded = e.NewValue;
if (e.NewValue)
{
PlayerSettingsOverlay.Show();
ModDisplay.FadeIn(200);
InputCountController.Margin = new MarginPadding(10) { Bottom = 30 };
}
else
{
PlayerSettingsOverlay.Hide();
ModDisplay.Delay(2000).FadeOut(200);
InputCountController.Margin = new MarginPadding(10);
}
updateVisibility();
}
protected virtual void BindDrawableRuleset(DrawableRuleset drawableRuleset)
{
if (drawableRuleset is ICanAttachHUDPieces attachTarget)