diff --git a/osu.Game/Configuration/GameplayLeaderboardVisibilityMode.cs b/osu.Game/Configuration/GameplayLeaderboardVisibilityMode.cs new file mode 100644 index 000000000000..c37c276b72df --- /dev/null +++ b/osu.Game/Configuration/GameplayLeaderboardVisibilityMode.cs @@ -0,0 +1,20 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Localisation; +using osu.Game.Localisation; + +namespace osu.Game.Configuration +{ + public enum GameplayLeaderboardVisibilityMode + { + [LocalisableDescription(typeof(GameplaySettingsStrings), nameof(GameplaySettingsStrings.ShowLeaderboardAlways))] + Always, + + [LocalisableDescription(typeof(GameplaySettingsStrings), nameof(GameplaySettingsStrings.ShowLeaderboardMultiplayer))] + Multiplayer, + + [LocalisableDescription(typeof(GameplaySettingsStrings), nameof(GameplaySettingsStrings.ShowLeaderboardNever))] + Never, + } +} diff --git a/osu.Game/Configuration/GameplayLeaderboardVisibilityModeExtensions.cs b/osu.Game/Configuration/GameplayLeaderboardVisibilityModeExtensions.cs new file mode 100644 index 000000000000..254612c3b9fd --- /dev/null +++ b/osu.Game/Configuration/GameplayLeaderboardVisibilityModeExtensions.cs @@ -0,0 +1,19 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Configuration +{ + public static class GameplayLeaderboardVisibilityModeExtensions + { + public static bool ShouldDisplay(this GameplayLeaderboardVisibilityMode mode, bool isMultiplayer) + { + return mode switch + { + GameplayLeaderboardVisibilityMode.Never => false, + GameplayLeaderboardVisibilityMode.Multiplayer => isMultiplayer, + GameplayLeaderboardVisibilityMode.Always => true, + _ => false, + }; + } + } +} diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 47ea527afeba..fd4183d3843b 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -152,7 +152,8 @@ protected override void InitialiseDefaults() SetDefault(OsuSetting.KeyOverlay, false); SetDefault(OsuSetting.ReplaySettingsOverlay, true); SetDefault(OsuSetting.ReplayPlaybackControlsExpanded, true); - SetDefault(OsuSetting.GameplayLeaderboard, true); + SetDefault(OsuSetting.GameplayLeaderboard, true); // legacy migration only + SetDefault(OsuSetting.GameplayLeaderboardVisibilityMode, GameplayLeaderboardVisibilityMode.Always); SetDefault(OsuSetting.AlwaysPlayFirstComboBreak, true); SetDefault(OsuSetting.FloatingComments, false); @@ -267,11 +268,11 @@ public override TrackedSettings CreateTrackedSettings() value: disabledState ? CommonStrings.Disabled.ToLower() : CommonStrings.Enabled.ToLower(), shortcut: LookupKeyBindings(GlobalAction.ToggleGameplayMouseButtons)) ), - new TrackedSetting(OsuSetting.GameplayLeaderboard, state => new SettingDescription( - rawValue: state, - name: GlobalActionKeyBindingStrings.ToggleInGameLeaderboard, - value: state ? CommonStrings.Enabled.ToLower() : CommonStrings.Disabled.ToLower(), - shortcut: LookupKeyBindings(GlobalAction.ToggleInGameLeaderboard)) + new TrackedSetting(OsuSetting.GameplayLeaderboardVisibilityMode, visibilityMode => new SettingDescription( + rawValue: visibilityMode, + name: GlobalActionKeyBindingStrings.CycleInGameLeaderboardVisibilityMode, + value: visibilityMode.GetLocalisableDescription(), + shortcut: LookupKeyBindings(GlobalAction.CycleInGameLeaderboardVisibilityMode)) ), new TrackedSetting(OsuSetting.HUDVisibilityMode, visibilityMode => new SettingDescription( rawValue: visibilityMode, @@ -338,7 +339,7 @@ public enum OsuSetting LightenDuringBreaks, ShowStoryboard, KeyOverlay, - GameplayLeaderboard, + GameplayLeaderboard, // only used for migrating to `GameplayLeaderboardVisibilityMode` PositionalHitsoundsLevel, AlwaysPlayFirstComboBreak, FloatingComments, @@ -469,5 +470,7 @@ public enum OsuSetting DashboardSortMode, DashboardDisplayStyle, + + GameplayLeaderboardVisibilityMode, } } diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index 3d6cc0dab585..0d8861b0c52c 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -177,7 +177,7 @@ public static IEnumerable GetGlobalActionsFor(GlobalActionCategory new KeyBinding(new[] { InputKey.F3 }, GlobalAction.DecreaseScrollSpeed), new KeyBinding(new[] { InputKey.F4 }, GlobalAction.IncreaseScrollSpeed), new KeyBinding(new[] { InputKey.Shift, InputKey.Tab }, GlobalAction.ToggleInGameInterface), - new KeyBinding(InputKey.Tab, GlobalAction.ToggleInGameLeaderboard), + new KeyBinding(InputKey.Tab, GlobalAction.CycleInGameLeaderboardVisibilityMode), new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay), new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD), new KeyBinding(InputKey.Enter, GlobalAction.ToggleChatFocus), @@ -442,8 +442,8 @@ public enum GlobalAction [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleReplaySettings))] ToggleReplaySettings, - [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleInGameLeaderboard))] - ToggleInGameLeaderboard, + [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.CycleInGameLeaderboardVisibilityMode))] + CycleInGameLeaderboardVisibilityMode, [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorToggleRotateControl))] EditorToggleRotateControl, diff --git a/osu.Game/Localisation/GameplaySettingsStrings.cs b/osu.Game/Localisation/GameplaySettingsStrings.cs index 6c4ccfb5728b..2aa5ea72f35f 100644 --- a/osu.Game/Localisation/GameplaySettingsStrings.cs +++ b/osu.Game/Localisation/GameplaySettingsStrings.cs @@ -85,9 +85,24 @@ public static class GameplaySettingsStrings public static LocalisableString AlwaysShowKeyOverlay => new TranslatableString(getKey(@"key_overlay"), @"Always show key overlay"); /// - /// "Always show gameplay leaderboard" + /// "Gameplay leaderboard visibility mode" /// - public static LocalisableString AlwaysShowGameplayLeaderboard => new TranslatableString(getKey(@"gameplay_leaderboard"), @"Always show gameplay leaderboard"); + public static LocalisableString GameplayLeaderboardVisibilityMode => new TranslatableString(getKey(@"gameplay_leaderboard_visibility_mode"), @"Gameplay leaderboard visibility mode"); + + /// + /// "Always" + /// + public static LocalisableString ShowLeaderboardAlways => new TranslatableString(getKey(@"show_leaderboard_always"), @"Always"); + + /// + /// "Multiplayer" + /// + public static LocalisableString ShowLeaderboardMultiplayer => new TranslatableString(getKey(@"show_leaderboard_multiplayer"), @"Multiplayer"); + + /// + /// "Disabled" + /// + public static LocalisableString ShowLeaderboardNever => new TranslatableString(getKey(@"show_leaderboard_never"), @"Disabled"); /// /// "Always show hold for menu button" diff --git a/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs b/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs index 34ef8fb4ffa4..05053cd15b4e 100644 --- a/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs +++ b/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs @@ -250,9 +250,9 @@ public static class GlobalActionKeyBindingStrings public static LocalisableString ToggleInGameInterface => new TranslatableString(getKey(@"toggle_in_game_interface"), @"Toggle in-game interface"); /// - /// "Toggle in-game leaderboard" + /// "Cycle in-game leaderboard visibility mode" /// - public static LocalisableString ToggleInGameLeaderboard => new TranslatableString(getKey(@"toggle_in_game_leaderboard"), @"Toggle in-game leaderboard"); + public static LocalisableString CycleInGameLeaderboardVisibilityMode => new TranslatableString(getKey(@"cycle_in_game_leaderboard_visibility_mode"), @"Cycle in-game leaderboard visibility mode"); /// /// "Toggle mod select" diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 1fac9e9ee4ca..25bc4be856c6 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1376,6 +1376,16 @@ private void applyConfigMigrations() dialogOverlay.Push(new MigrateNewAudioDialog(wasAlreadyUsing)); } + + if (combined < 20260723) + { + bool oldValue = LocalConfig.Get(OsuSetting.GameplayLeaderboard); + + LocalConfig.SetValue( + OsuSetting.GameplayLeaderboardVisibilityMode, + oldValue ? GameplayLeaderboardVisibilityMode.Always : GameplayLeaderboardVisibilityMode.Never + ); + } } private void handleBackButton() diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs index 711e10da47ae..3c3b7ea645d4 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs @@ -41,10 +41,10 @@ private void load(OsuConfigManager config) { Keywords = new[] { "counter" }, }, - new SettingsItemV2(new FormCheckBox + new SettingsItemV2(new FormEnumDropdown { - Caption = GameplaySettingsStrings.AlwaysShowGameplayLeaderboard, - Current = config.GetBindable(OsuSetting.GameplayLeaderboard), + Caption = GameplaySettingsStrings.GameplayLeaderboardVisibilityMode, + Current = config.GetBindable(OsuSetting.GameplayLeaderboardVisibilityMode) }), new SettingsItemV2(new FormCheckBox { diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPositionDisplay.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPositionDisplay.cs index f2cbc41d16a9..9311161e694d 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPositionDisplay.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPositionDisplay.cs @@ -28,7 +28,7 @@ public partial class MultiplayerPositionDisplay : VisibilityContainer { private readonly IBindable user = new Bindable(); private readonly IBindableList scores = new BindableList(); - private readonly BindableBool showLeaderboard = new BindableBool(); + private readonly Bindable leaderboardVisibility = new Bindable(); private readonly IBindable localUserPlayingState = new Bindable(); private readonly Bindable position = new Bindable(); @@ -52,7 +52,7 @@ private void load(IGameplayLeaderboardProvider leaderboardProvider, IAPIProvider { scores.BindTo(leaderboardProvider.Scores); user.BindTo(api.LocalUser); - configManager.BindWith(OsuSetting.GameplayLeaderboard, showLeaderboard); + configManager.BindWith(OsuSetting.GameplayLeaderboardVisibilityMode, leaderboardVisibility); localUserPlayingState.BindTo(gameplayState.PlayingState); AutoSizeAxes = Axes.Y; @@ -105,7 +105,7 @@ protected override void LoadComplete() user.BindValueChanged(_ => updateScoreBindings()); scores.BindCollectionChanged((_, __) => updateScoreBindings(), true); - showLeaderboard.BindValueChanged(_ => updateVisibility()); + leaderboardVisibility.BindValueChanged(_ => updateVisibility()); localUserPlayingState.BindValueChanged(_ => updateVisibility(), true); State.BindValueChanged(_ => updatePosition()); @@ -126,7 +126,7 @@ protected override void PopOut() private void updateVisibility() { - bool shouldDisplay = userScore != null && (showLeaderboard.Value || localUserPlayingState.Value == LocalUserPlayingState.Break); + bool shouldDisplay = userScore != null && (leaderboardVisibility.Value.ShouldDisplay(isMultiplayer: true) || localUserPlayingState.Value == LocalUserPlayingState.Break); State.Value = shouldDisplay ? Visibility.Visible : Visibility.Hidden; } diff --git a/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs index cd3ee730187e..be95c16394df 100644 --- a/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs @@ -42,7 +42,7 @@ public partial class DrawableGameplayLeaderboard : CompositeDrawable, ISerialisa private IGameplayLeaderboardProvider leaderboardProvider { get; set; } = null!; private readonly IBindableList scores = new BindableList(); - private readonly Bindable configVisibility = new Bindable(); + private readonly Bindable configVisibility = new Bindable(); private readonly IBindable userPlayingState = new Bindable(); private readonly IBindable holdingForHUD = new Bindable(); @@ -81,7 +81,7 @@ public DrawableGameplayLeaderboard() [BackgroundDependencyLoader] private void load(OsuConfigManager config, GameplayState? gameplayState, HUDOverlay? hudOverlay) { - config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility); + config.BindWith(OsuSetting.GameplayLeaderboardVisibilityMode, configVisibility); if (gameplayState != null) userPlayingState.BindTo(gameplayState.PlayingState); @@ -115,7 +115,8 @@ private void updateState() if (Flow.Alpha < 1) scroll.ScrollToStart(false); - Flow.FadeTo(player?.Configuration.ShowLeaderboard != false && (configVisibility.Value || AlwaysShown) ? 1 : 0, 100, Easing.OutQuint); + Flow.FadeTo(player?.Configuration.ShowLeaderboard != false && configVisibility.Value.ShouldDisplay(leaderboardProvider is MultiplayerLeaderboardProvider) ? 1 : 0, 100, Easing.OutQuint); + expanded.Value = !CollapseDuringGameplay.Value || userPlayingState.Value != LocalUserPlayingState.Playing || holdingForHUD.Value; } diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 7da996c20897..302a72a40cb2 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -75,7 +75,7 @@ protected override bool ShouldBeConsideredForInput(Drawable child) public Bindable ShowHud { get; } = new BindableBool(); private Bindable configVisibilityMode; - private Bindable configLeaderboardVisibility; + private Bindable configLeaderboardVisibilityMode; private readonly BindableBool replayLoaded = new BindableBool(); @@ -194,7 +194,7 @@ private void load(OsuConfigManager config, RealmKeyBindingStore keyBindingStore, ModDisplay.Current.Value = mods; configVisibilityMode = config.GetBindable(OsuSetting.HUDVisibilityMode); - configLeaderboardVisibility = config.GetBindable(OsuSetting.GameplayLeaderboard); + configLeaderboardVisibilityMode = config.GetBindable(OsuSetting.GameplayLeaderboardVisibilityMode); if (configVisibilityMode.Value == HUDVisibilityMode.Never && !hasShownNotificationOnce) { @@ -415,8 +415,21 @@ public bool OnPressed(KeyBindingPressEvent e) return true; - case GlobalAction.ToggleInGameLeaderboard: - configLeaderboardVisibility.Value = !configLeaderboardVisibility.Value; + case GlobalAction.CycleInGameLeaderboardVisibilityMode: + switch (configLeaderboardVisibilityMode.Value) + { + case GameplayLeaderboardVisibilityMode.Never: + configLeaderboardVisibilityMode.Value = GameplayLeaderboardVisibilityMode.Always; + break; + + case GameplayLeaderboardVisibilityMode.Always: + configLeaderboardVisibilityMode.Value = GameplayLeaderboardVisibilityMode.Multiplayer; + break; + + case GameplayLeaderboardVisibilityMode.Multiplayer: + configLeaderboardVisibilityMode.Value = GameplayLeaderboardVisibilityMode.Never; + break; + } return true; }