mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 09:57:21 +09:00
Move LeaderboardFlow
to HUDOverlay
to share positioning logic
This commit is contained in:
parent
5894d2f0bc
commit
678eec1c67
@ -9,8 +9,6 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -21,7 +19,6 @@ using osu.Game.Screens.Play;
|
|||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||||
{
|
{
|
||||||
@ -44,7 +41,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
private readonly MultiplayerRoomUser[] users;
|
private readonly MultiplayerRoomUser[] users;
|
||||||
|
|
||||||
private LoadingLayer loadingDisplay;
|
private LoadingLayer loadingDisplay;
|
||||||
private FillFlowContainer leaderboardFlow;
|
|
||||||
|
|
||||||
private MultiplayerGameplayLeaderboard multiplayerLeaderboard;
|
private MultiplayerGameplayLeaderboard multiplayerLeaderboard;
|
||||||
|
|
||||||
@ -73,17 +69,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
if (!LoadedBeatmapSuccessfully)
|
if (!LoadedBeatmapSuccessfully)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HUDOverlay.Add(leaderboardFlow = new FillFlowContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Spacing = new Vector2(5)
|
|
||||||
});
|
|
||||||
|
|
||||||
LoadComponentAsync(new GameplayChatDisplay(Room)
|
LoadComponentAsync(new GameplayChatDisplay(Room)
|
||||||
{
|
{
|
||||||
Expanded = { BindTarget = LeaderboardExpandedState },
|
Expanded = { BindTarget = LeaderboardExpandedState },
|
||||||
}, chat => leaderboardFlow.Insert(2, chat));
|
}, chat => HUDOverlay.LeaderboardFlow.Insert(2, chat));
|
||||||
|
|
||||||
HUDOverlay.Add(loadingDisplay = new LoadingLayer(true) { Depth = float.MaxValue });
|
HUDOverlay.Add(loadingDisplay = new LoadingLayer(true) { Depth = float.MaxValue });
|
||||||
}
|
}
|
||||||
@ -94,7 +83,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
{
|
{
|
||||||
Debug.Assert(leaderboard == multiplayerLeaderboard);
|
Debug.Assert(leaderboard == multiplayerLeaderboard);
|
||||||
|
|
||||||
leaderboardFlow.Insert(0, leaderboard);
|
HUDOverlay.LeaderboardFlow.Insert(0, leaderboard);
|
||||||
|
|
||||||
if (multiplayerLeaderboard.TeamScores.Count >= 2)
|
if (multiplayerLeaderboard.TeamScores.Count >= 2)
|
||||||
{
|
{
|
||||||
@ -103,7 +92,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
Team1Score = { BindTarget = multiplayerLeaderboard.TeamScores.First().Value },
|
Team1Score = { BindTarget = multiplayerLeaderboard.TeamScores.First().Value },
|
||||||
Team2Score = { BindTarget = multiplayerLeaderboard.TeamScores.Last().Value },
|
Team2Score = { BindTarget = multiplayerLeaderboard.TeamScores.Last().Value },
|
||||||
Expanded = { BindTarget = HUDOverlay.ShowHud },
|
Expanded = { BindTarget = HUDOverlay.ShowHud },
|
||||||
}, scoreDisplay => leaderboardFlow.Insert(1, scoreDisplay));
|
}, scoreDisplay => HUDOverlay.LeaderboardFlow.Insert(1, scoreDisplay));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,23 +158,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
Schedule(() => PerformExit(false));
|
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(() =>
|
private void onGameplayStarted() => Scheduler.Add(() =>
|
||||||
{
|
{
|
||||||
if (!this.IsCurrentScreen())
|
if (!this.IsCurrentScreen())
|
||||||
|
@ -79,9 +79,15 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private readonly SkinnableTargetContainer mainComponents;
|
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;
|
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.drawableRuleset = drawableRuleset;
|
||||||
this.mods = mods;
|
this.mods = mods;
|
||||||
@ -126,10 +132,19 @@ namespace osu.Game.Screens.Play
|
|||||||
HoldToQuit = CreateHoldForMenuButton(),
|
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 };
|
hideTargets = new List<Drawable> { mainComponents, KeyCounter, topRightElements };
|
||||||
|
|
||||||
|
if (alwaysShowLeaderboard)
|
||||||
|
hideTargets.Add(LeaderboardFlow);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
@ -174,13 +189,6 @@ namespace osu.Game.Screens.Play
|
|||||||
replayLoaded.BindValueChanged(replayLoadedValueChanged, true);
|
replayLoaded.BindValueChanged(replayLoadedValueChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(Drawable drawable, bool hideWithHUD)
|
|
||||||
{
|
|
||||||
base.Add(drawable);
|
|
||||||
if (hideWithHUD)
|
|
||||||
hideTargets.Add(drawable);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -220,6 +228,14 @@ namespace osu.Game.Screens.Play
|
|||||||
bottomRightElements.Y = BottomScoringElementsHeight = -MathHelper.Clamp(DrawHeight - ToLocalSpace(highestBottomScreenSpace.Value).Y, 0, DrawHeight - bottomRightElements.DrawHeight);
|
bottomRightElements.Y = BottomScoringElementsHeight = -MathHelper.Clamp(DrawHeight - ToLocalSpace(highestBottomScreenSpace.Value).Y, 0, DrawHeight - bottomRightElements.DrawHeight);
|
||||||
else
|
else
|
||||||
bottomRightElements.Y = 0;
|
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()
|
private void updateVisibility()
|
||||||
|
@ -420,7 +420,7 @@ namespace osu.Game.Screens.Play
|
|||||||
// display the cursor above some HUD elements.
|
// display the cursor above some HUD elements.
|
||||||
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
||||||
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
|
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
|
||||||
HUDOverlay = new HUDOverlay(DrawableRuleset, GameplayState.Mods)
|
HUDOverlay = new HUDOverlay(DrawableRuleset, GameplayState.Mods, Configuration.AlwaysShowLeaderboard)
|
||||||
{
|
{
|
||||||
HoldToQuit =
|
HoldToQuit =
|
||||||
{
|
{
|
||||||
@ -843,14 +843,9 @@ namespace osu.Game.Screens.Play
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual GameplayLeaderboard CreateGameplayLeaderboard() => new SoloGameplayLeaderboard(Score.ScoreInfo.User)
|
protected virtual GameplayLeaderboard CreateGameplayLeaderboard() => new SoloGameplayLeaderboard(Score.ScoreInfo.User);
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
Margin = new MarginPadding { Bottom = 75, Left = 20 },
|
|
||||||
};
|
|
||||||
|
|
||||||
protected virtual void AddLeaderboardToHUD(GameplayLeaderboard leaderboard) => HUDOverlay.Add(leaderboard, !Configuration.AlwaysShowLeaderboard);
|
protected virtual void AddLeaderboardToHUD(GameplayLeaderboard leaderboard) => HUDOverlay.LeaderboardFlow.Add(leaderboard);
|
||||||
|
|
||||||
private void updateLeaderboardExpandedState() =>
|
private void updateLeaderboardExpandedState() =>
|
||||||
LeaderboardExpandedState.Value = !LocalUserPlaying.Value || HUDOverlay.HoldingForHUD.Value;
|
LeaderboardExpandedState.Value = !LocalUserPlaying.Value || HUDOverlay.HoldingForHUD.Value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user