Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public TestSceneGameplayLeaderboard()
AddStep("toggle expanded", () =>
{
if (leaderboard.IsNotNull())
leaderboard.ForceExpand.Value = !leaderboard.ForceExpand.Value;
leaderboard.CollapseDuringGameplay.Value = !leaderboard.CollapseDuringGameplay.Value;
});

AddSliderStep("set player score", 50, 5000000, 1222333, v => playerScore.Value = v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public virtual void SetUpSteps()
public void TestScoreUpdates()
{
AddRepeatStep("update state", UpdateUserStatesRandomly, 100);
AddToggleStep("switch compact mode", expanded => Leaderboard!.ForceExpand.Value = expanded);
AddToggleStep("switch compact mode", collapsed => Leaderboard!.CollapseDuringGameplay.Value = collapsed);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override void SetUpSteps()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
ForceExpand = { Value = true }
CollapseDuringGameplay = { Value = false }
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ public override void SetUpSteps()
Team2Score = { BindTarget = LeaderboardProvider.TeamScores[1] }
}, Add);

LoadComponentAsync(new GameplayMatchScoreDisplay
GameplayMatchScoreDisplay matchScoreDisplay;
LoadComponentAsync(matchScoreDisplay = new GameplayMatchScoreDisplay
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Team1Score = { BindTarget = LeaderboardProvider.TeamScores[0] },
Team2Score = { BindTarget = LeaderboardProvider.TeamScores[1] },
Expanded = { BindTarget = Leaderboard!.ForceExpand },
}, Add);

Leaderboard!.CollapseDuringGameplay.BindValueChanged(_ => matchScoreDisplay.Expanded.Value = !Leaderboard.CollapseDuringGameplay.Value);
});
}
}
Expand Down
11 changes: 11 additions & 0 deletions osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ public static class SkinnableComponentStrings
/// </summary>
public static LocalisableString UseRelativeSize => new TranslatableString(getKey(@"use_relative_size"), @"Use relative size");

/// <summary>
/// "Collapse during gameplay"
/// </summary>
public static LocalisableString CollapseDuringGameplay => new TranslatableString(getKey(@"collapse_during_gameplay"), @"Collapse during gameplay");

/// <summary>
/// "If enabled, the leaderboard will become more compact during active gameplay."
/// </summary>
public static LocalisableString CollapseDuringGameplayDescription =>
new TranslatableString(getKey(@"if_enabled_the_leaderboard_will"), @"If enabled, the leaderboard will become more compact during active gameplay.");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private void load()
});
leaderboardFlow.Insert(0, Leaderboard = new DrawableGameplayLeaderboard
{
ForceExpand = { Value = true }
CollapseDuringGameplay = { Value = false }
});

LoadComponentAsync(new GameplayChatDisplay(room)
Expand Down
10 changes: 6 additions & 4 deletions osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using osu.Framework.Graphics.Containers;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Localisation.SkinComponents;
using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Skinning;
using osuTK;
Expand All @@ -20,15 +21,16 @@ namespace osu.Game.Screens.Play.HUD
{
public partial class DrawableGameplayLeaderboard : CompositeDrawable, ISerialisableDrawable
{
public readonly Bindable<bool> ForceExpand = new Bindable<bool>();

protected readonly FillFlowContainer<DrawableGameplayLeaderboardScore> Flow;

private bool requiresScroll;
private readonly OsuScrollContainer scroll;

public DrawableGameplayLeaderboardScore? TrackedScore { get; private set; }

[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.CollapseDuringGameplay), nameof(SkinnableComponentStrings.CollapseDuringGameplayDescription))]
public Bindable<bool> CollapseDuringGameplay { get; } = new BindableBool(true);

[Resolved]
private Player? player { get; set; }

Expand Down Expand Up @@ -97,7 +99,7 @@ protected override void LoadComplete()
configVisibility.BindValueChanged(_ => Scheduler.AddOnce(updateState));
userPlayingState.BindValueChanged(_ => Scheduler.AddOnce(updateState));
holdingForHUD.BindValueChanged(_ => Scheduler.AddOnce(updateState));
ForceExpand.BindValueChanged(_ => Scheduler.AddOnce(updateState));
CollapseDuringGameplay.BindValueChanged(_ => Scheduler.AddOnce(updateState));
updateState();
}

Expand All @@ -108,7 +110,7 @@ private void updateState()
scroll.ScrollToStart(false);

Flow.FadeTo(player?.Configuration.ShowLeaderboard != false && configVisibility.Value ? 1 : 0, 100, Easing.OutQuint);
expanded.Value = ForceExpand.Value || userPlayingState.Value != LocalUserPlayingState.Playing || holdingForHUD.Value;
expanded.Value = !CollapseDuringGameplay.Value || userPlayingState.Value != LocalUserPlayingState.Playing || holdingForHUD.Value;
}

/// <summary>
Expand Down
Loading