mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 15:17:27 +08:00
Merge pull request #24129 from peppy/toggle-replay-overlay
Remember state of replay settings visibility and allow key customisation
This commit is contained in:
commit
65384d6125
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +129,7 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(InputKey.MouseMiddle, GlobalAction.TogglePauseReplay),
|
||||
new KeyBinding(InputKey.Left, GlobalAction.SeekReplayBackward),
|
||||
new KeyBinding(InputKey.Right, GlobalAction.SeekReplayForward),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.H }, GlobalAction.ToggleReplaySettings),
|
||||
};
|
||||
|
||||
public IEnumerable<KeyBinding> SongSelectKeyBindings => new[]
|
||||
@ -374,5 +375,8 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ExportReplay))]
|
||||
ExportReplay,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleReplaySettings))]
|
||||
ToggleReplaySettings,
|
||||
}
|
||||
}
|
||||
|
@ -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'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}";
|
||||
}
|
||||
}
|
||||
|
@ -324,6 +324,11 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString ToggleChatFocus => new TranslatableString(getKey(@"toggle_chat_focus"), @"Toggle chat focus");
|
||||
|
||||
/// <summary>
|
||||
/// "Toggle replay settings"
|
||||
/// </summary>
|
||||
public static LocalisableString ToggleReplaySettings => new TranslatableString(getKey(@"toggle_replay_settings"), @"Toggle replay settings");
|
||||
|
||||
/// <summary>
|
||||
/// "Save replay"
|
||||
/// </summary>
|
||||
|
@ -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" }
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -37,8 +31,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
Spacing = new Vector2(0, 20),
|
||||
Children = new PlayerSettingsGroup[]
|
||||
{
|
||||
//CollectionSettings = new CollectionSettings(),
|
||||
//DiscussionSettings = new DiscussionSettings(),
|
||||
PlaybackSettings = new PlaybackSettings { Expanded = { Value = false } },
|
||||
VisualSettings = new VisualSettings { Expanded = { Value = false } },
|
||||
new AudioSettings { Expanded = { Value = false } }
|
||||
@ -48,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,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 +179,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 +206,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 +297,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 +319,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)
|
||||
@ -354,6 +356,10 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.ToggleReplaySettings:
|
||||
configSettingsOverlay.Value = !configSettingsOverlay.Value;
|
||||
return true;
|
||||
|
||||
case GlobalAction.HoldForHUD:
|
||||
holdingForHUD.Value = true;
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user