mirror of https://github.com/ppy/osu
Move `LeaderboardFlow` to `HUDOverlay` to share positioning logic
This commit is contained in:
parent
5894d2f0bc
commit
678eec1c67
|
@ -9,8 +9,6 @@
|
|||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
@ -21,7 +19,6 @@
|
|||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
{
|
||||
|
@ -44,7 +41,6 @@ public class MultiplayerPlayer : RoomSubmittingPlayer
|
|||
private readonly MultiplayerRoomUser[] users;
|
||||
|
||||
private LoadingLayer loadingDisplay;
|
||||
private FillFlowContainer leaderboardFlow;
|
||||
|
||||
private MultiplayerGameplayLeaderboard multiplayerLeaderboard;
|
||||
|
||||
|
@ -73,17 +69,10 @@ private void load()
|
|||
if (!LoadedBeatmapSuccessfully)
|
||||
return;
|
||||
|
||||
HUDOverlay.Add(leaderboardFlow = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(5)
|
||||
});
|
||||
|
||||
LoadComponentAsync(new GameplayChatDisplay(Room)
|
||||
{
|
||||
Expanded = { BindTarget = LeaderboardExpandedState },
|
||||
}, chat => leaderboardFlow.Insert(2, chat));
|
||||
}, chat => HUDOverlay.LeaderboardFlow.Insert(2, chat));
|
||||
|
||||
HUDOverlay.Add(loadingDisplay = new LoadingLayer(true) { Depth = float.MaxValue });
|
||||
}
|
||||
|
@ -94,7 +83,7 @@ protected override void AddLeaderboardToHUD(GameplayLeaderboard leaderboard)
|
|||
{
|
||||
Debug.Assert(leaderboard == multiplayerLeaderboard);
|
||||
|
||||
leaderboardFlow.Insert(0, leaderboard);
|
||||
HUDOverlay.LeaderboardFlow.Insert(0, leaderboard);
|
||||
|
||||
if (multiplayerLeaderboard.TeamScores.Count >= 2)
|
||||
{
|
||||
|
@ -103,7 +92,7 @@ protected override void AddLeaderboardToHUD(GameplayLeaderboard leaderboard)
|
|||
Team1Score = { BindTarget = multiplayerLeaderboard.TeamScores.First().Value },
|
||||
Team2Score = { BindTarget = multiplayerLeaderboard.TeamScores.Last().Value },
|
||||
Expanded = { BindTarget = HUDOverlay.ShowHud },
|
||||
}, scoreDisplay => leaderboardFlow.Insert(1, scoreDisplay));
|
||||
}, scoreDisplay => HUDOverlay.LeaderboardFlow.Insert(1, scoreDisplay));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,23 +158,6 @@ private void failAndBail(string message = null)
|
|||
Schedule(() => PerformExit(false));
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (!LoadedBeatmapSuccessfully)
|
||||
return;
|
||||
|
||||
adjustLeaderboardPosition();
|
||||
}
|
||||
|
||||
private void adjustLeaderboardPosition()
|
||||
{
|
||||
const float padding = 44; // enough margin to avoid the hit error display.
|
||||
|
||||
leaderboardFlow.Position = new Vector2(padding, padding + HUDOverlay.TopScoringElementsHeight);
|
||||
}
|
||||
|
||||
private void onGameplayStarted() => Scheduler.Add(() =>
|
||||
{
|
||||
if (!this.IsCurrentScreen())
|
||||
|
|
|
@ -79,9 +79,15 @@ public class HUDOverlay : Container, IKeyBindingHandler<GlobalAction>
|
|||
|
||||
private readonly SkinnableTargetContainer mainComponents;
|
||||
|
||||
/// <summary>
|
||||
/// A flow which sits at the left side of the screen to house leaderboard (and related) components.
|
||||
/// Will automatically be positioned to avoid colliding with top scoring elements.
|
||||
/// </summary>
|
||||
public readonly FillFlowContainer LeaderboardFlow;
|
||||
|
||||
private readonly List<Drawable> hideTargets;
|
||||
|
||||
public HUDOverlay(DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
|
||||
public HUDOverlay(DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods, bool alwaysShowLeaderboard = true)
|
||||
{
|
||||
this.drawableRuleset = drawableRuleset;
|
||||
this.mods = mods;
|
||||
|
@ -126,10 +132,19 @@ public HUDOverlay(DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
|
|||
HoldToQuit = CreateHoldForMenuButton(),
|
||||
}
|
||||
},
|
||||
clicksPerSecondCalculator = new ClicksPerSecondCalculator()
|
||||
LeaderboardFlow = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(5)
|
||||
},
|
||||
clicksPerSecondCalculator = new ClicksPerSecondCalculator(),
|
||||
};
|
||||
|
||||
hideTargets = new List<Drawable> { mainComponents, KeyCounter, topRightElements };
|
||||
|
||||
if (alwaysShowLeaderboard)
|
||||
hideTargets.Add(LeaderboardFlow);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
|
@ -174,13 +189,6 @@ protected override void LoadComplete()
|
|||
replayLoaded.BindValueChanged(replayLoadedValueChanged, true);
|
||||
}
|
||||
|
||||
public void Add(Drawable drawable, bool hideWithHUD)
|
||||
{
|
||||
base.Add(drawable);
|
||||
if (hideWithHUD)
|
||||
hideTargets.Add(drawable);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
@ -220,6 +228,14 @@ protected override void Update()
|
|||
bottomRightElements.Y = BottomScoringElementsHeight = -MathHelper.Clamp(DrawHeight - ToLocalSpace(highestBottomScreenSpace.Value).Y, 0, DrawHeight - bottomRightElements.DrawHeight);
|
||||
else
|
||||
bottomRightElements.Y = 0;
|
||||
|
||||
adjustLeaderboardPosition();
|
||||
}
|
||||
|
||||
private void adjustLeaderboardPosition()
|
||||
{
|
||||
const float padding = 44; // enough margin to avoid the hit error display.
|
||||
LeaderboardFlow.Position = new Vector2(padding, padding + TopScoringElementsHeight);
|
||||
}
|
||||
|
||||
private void updateVisibility()
|
||||
|
|
|
@ -420,7 +420,7 @@ private Drawable createOverlayComponents(IWorkingBeatmap working)
|
|||
// display the cursor above some HUD elements.
|
||||
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
||||
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
|
||||
HUDOverlay = new HUDOverlay(DrawableRuleset, GameplayState.Mods)
|
||||
HUDOverlay = new HUDOverlay(DrawableRuleset, GameplayState.Mods, Configuration.AlwaysShowLeaderboard)
|
||||
{
|
||||
HoldToQuit =
|
||||
{
|
||||
|
@ -843,14 +843,9 @@ private void loadLeaderboard()
|
|||
});
|
||||
}
|
||||
|
||||
protected virtual GameplayLeaderboard CreateGameplayLeaderboard() => new SoloGameplayLeaderboard(Score.ScoreInfo.User)
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Margin = new MarginPadding { Bottom = 75, Left = 20 },
|
||||
};
|
||||
protected virtual GameplayLeaderboard CreateGameplayLeaderboard() => new SoloGameplayLeaderboard(Score.ScoreInfo.User);
|
||||
|
||||
protected virtual void AddLeaderboardToHUD(GameplayLeaderboard leaderboard) => HUDOverlay.Add(leaderboard, !Configuration.AlwaysShowLeaderboard);
|
||||
protected virtual void AddLeaderboardToHUD(GameplayLeaderboard leaderboard) => HUDOverlay.LeaderboardFlow.Add(leaderboard);
|
||||
|
||||
private void updateLeaderboardExpandedState() =>
|
||||
LeaderboardExpandedState.Value = !LocalUserPlaying.Value || HUDOverlay.HoldingForHUD.Value;
|
||||
|
|
Loading…
Reference in New Issue