mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 10:52:55 +08:00
Move UserTopScoreContainer into base leaderboard
This commit is contained in:
parent
cccf5b8a35
commit
ed74c39b55
osu.Game.Tests/Visual/SongSelect
osu.Game
Online
Screens
@ -5,9 +5,9 @@ using System;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
|
||||||
using osu.Game.Online.Leaderboards;
|
using osu.Game.Online.Leaderboards;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Select.Leaderboards;
|
using osu.Game.Screens.Select.Leaderboards;
|
||||||
@ -53,53 +53,46 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
private void showPersonalBestWithNullPosition()
|
private void showPersonalBestWithNullPosition()
|
||||||
{
|
{
|
||||||
leaderboard.TopScore = new APILegacyUserTopScoreInfo
|
leaderboard.TopScore = new ScoreInfo
|
||||||
{
|
{
|
||||||
Position = null,
|
Rank = ScoreRank.XH,
|
||||||
Score = new APILegacyScoreInfo
|
Accuracy = 1,
|
||||||
|
MaxCombo = 244,
|
||||||
|
TotalScore = 1707827,
|
||||||
|
Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock() },
|
||||||
|
User = new User
|
||||||
{
|
{
|
||||||
Rank = ScoreRank.XH,
|
Id = 6602580,
|
||||||
Accuracy = 1,
|
Username = @"waaiiru",
|
||||||
MaxCombo = 244,
|
Country = new Country
|
||||||
TotalScore = 1707827,
|
|
||||||
Mods = new[] { new OsuModHidden().Acronym, new OsuModHardRock().Acronym, },
|
|
||||||
User = new User
|
|
||||||
{
|
{
|
||||||
Id = 6602580,
|
FullName = @"Spain",
|
||||||
Username = @"waaiiru",
|
FlagName = @"ES",
|
||||||
Country = new Country
|
|
||||||
{
|
|
||||||
FullName = @"Spain",
|
|
||||||
FlagName = @"ES",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPersonalBest()
|
private void showPersonalBest()
|
||||||
{
|
{
|
||||||
leaderboard.TopScore = new APILegacyUserTopScoreInfo
|
leaderboard.TopScore = new ScoreInfo
|
||||||
{
|
{
|
||||||
Position = 999,
|
Position = 999,
|
||||||
Score = new APILegacyScoreInfo
|
Rank = ScoreRank.XH,
|
||||||
|
Accuracy = 1,
|
||||||
|
MaxCombo = 244,
|
||||||
|
TotalScore = 1707827,
|
||||||
|
Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
|
User = new User
|
||||||
{
|
{
|
||||||
Rank = ScoreRank.XH,
|
Id = 6602580,
|
||||||
Accuracy = 1,
|
Username = @"waaiiru",
|
||||||
MaxCombo = 244,
|
Country = new Country
|
||||||
TotalScore = 1707827,
|
|
||||||
Mods = new[] { new OsuModHidden().Acronym, new OsuModHardRock().Acronym, },
|
|
||||||
User = new User
|
|
||||||
{
|
{
|
||||||
Id = 6602580,
|
FullName = @"Spain",
|
||||||
Username = @"waaiiru",
|
FlagName = @"ES",
|
||||||
Country = new Country
|
|
||||||
{
|
|
||||||
FullName = @"Spain",
|
|
||||||
FlagName = @"ES",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.Leaderboards;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Screens.Select.Leaderboards;
|
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.SongSelect
|
namespace osu.Game.Tests.Visual.SongSelect
|
||||||
@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
public TestSceneUserTopScoreContainer()
|
public TestSceneUserTopScoreContainer()
|
||||||
{
|
{
|
||||||
UserTopScoreContainer topScoreContainer;
|
UserTopScoreContainer<ScoreInfo> topScoreContainer;
|
||||||
|
|
||||||
Add(dialogOverlay = new DialogOverlay
|
Add(dialogOverlay = new DialogOverlay
|
||||||
{
|
{
|
||||||
@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = Color4.DarkGreen,
|
Colour = Color4.DarkGreen,
|
||||||
},
|
},
|
||||||
topScoreContainer = new UserTopScoreContainer
|
topScoreContainer = new UserTopScoreContainer<ScoreInfo>(s => new LeaderboardScore(s, s.Position, false))
|
||||||
{
|
{
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
@ -52,69 +52,60 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
var scores = new[]
|
var scores = new[]
|
||||||
{
|
{
|
||||||
new APILegacyUserTopScoreInfo
|
new ScoreInfo
|
||||||
{
|
{
|
||||||
Position = 999,
|
Position = 999,
|
||||||
Score = new APILegacyScoreInfo
|
Rank = ScoreRank.XH,
|
||||||
|
Accuracy = 1,
|
||||||
|
MaxCombo = 244,
|
||||||
|
TotalScore = 1707827,
|
||||||
|
Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
|
User = new User
|
||||||
{
|
{
|
||||||
Rank = ScoreRank.XH,
|
Id = 6602580,
|
||||||
Accuracy = 1,
|
Username = @"waaiiru",
|
||||||
MaxCombo = 244,
|
Country = new Country
|
||||||
TotalScore = 1707827,
|
|
||||||
Mods = new[] { new OsuModHidden().Acronym, new OsuModHardRock().Acronym, },
|
|
||||||
User = new User
|
|
||||||
{
|
{
|
||||||
Id = 6602580,
|
FullName = @"Spain",
|
||||||
Username = @"waaiiru",
|
FlagName = @"ES",
|
||||||
Country = new Country
|
|
||||||
{
|
|
||||||
FullName = @"Spain",
|
|
||||||
FlagName = @"ES",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
new APILegacyUserTopScoreInfo
|
new ScoreInfo
|
||||||
{
|
{
|
||||||
Position = 110000,
|
Position = 110000,
|
||||||
Score = new APILegacyScoreInfo
|
Rank = ScoreRank.X,
|
||||||
|
Accuracy = 1,
|
||||||
|
MaxCombo = 244,
|
||||||
|
TotalScore = 1707827,
|
||||||
|
User = new User
|
||||||
{
|
{
|
||||||
Rank = ScoreRank.X,
|
Id = 4608074,
|
||||||
Accuracy = 1,
|
Username = @"Skycries",
|
||||||
MaxCombo = 244,
|
Country = new Country
|
||||||
TotalScore = 1707827,
|
|
||||||
User = new User
|
|
||||||
{
|
{
|
||||||
Id = 4608074,
|
FullName = @"Brazil",
|
||||||
Username = @"Skycries",
|
FlagName = @"BR",
|
||||||
Country = new Country
|
|
||||||
{
|
|
||||||
FullName = @"Brazil",
|
|
||||||
FlagName = @"BR",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
new APILegacyUserTopScoreInfo
|
new ScoreInfo
|
||||||
{
|
{
|
||||||
Position = 22333,
|
Position = 22333,
|
||||||
Score = new APILegacyScoreInfo
|
Rank = ScoreRank.S,
|
||||||
|
Accuracy = 1,
|
||||||
|
MaxCombo = 244,
|
||||||
|
TotalScore = 1707827,
|
||||||
|
User = new User
|
||||||
{
|
{
|
||||||
Rank = ScoreRank.S,
|
Id = 1541390,
|
||||||
Accuracy = 1,
|
Username = @"Toukai",
|
||||||
MaxCombo = 244,
|
Country = new Country
|
||||||
TotalScore = 1707827,
|
|
||||||
User = new User
|
|
||||||
{
|
{
|
||||||
Id = 1541390,
|
FullName = @"Canada",
|
||||||
Username = @"Toukai",
|
FlagName = @"CA",
|
||||||
Country = new Country
|
|
||||||
{
|
|
||||||
FullName = @"Canada",
|
|
||||||
FlagName = @"CA",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Online.API.Requests.Responses
|
namespace osu.Game.Online.API.Requests.Responses
|
||||||
{
|
{
|
||||||
@ -22,5 +24,12 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
|
|
||||||
[JsonProperty(@"score")]
|
[JsonProperty(@"score")]
|
||||||
public APILegacyScoreInfo Score;
|
public APILegacyScoreInfo Score;
|
||||||
|
|
||||||
|
public ScoreInfo CreateScoreInfo(RulesetStore rulesets)
|
||||||
|
{
|
||||||
|
var score = Score.CreateScoreInfo(rulesets);
|
||||||
|
score.Position = Position;
|
||||||
|
return score;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
|
|
||||||
private readonly OsuScrollContainer scrollContainer;
|
private readonly OsuScrollContainer scrollContainer;
|
||||||
private readonly Container placeholderContainer;
|
private readonly Container placeholderContainer;
|
||||||
|
private readonly UserTopScoreContainer<TScoreInfo> topScoreContainer;
|
||||||
|
|
||||||
private FillFlowContainer<LeaderboardScore> scrollFlow;
|
private FillFlowContainer<LeaderboardScore> scrollFlow;
|
||||||
|
|
||||||
@ -87,6 +88,21 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TScoreInfo TopScore
|
||||||
|
{
|
||||||
|
get => topScoreContainer.Score.Value;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
topScoreContainer.Hide();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
topScoreContainer.Show();
|
||||||
|
topScoreContainer.Score.Value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual FillFlowContainer<LeaderboardScore> CreateScoreFlow()
|
protected virtual FillFlowContainer<LeaderboardScore> CreateScoreFlow()
|
||||||
=> new FillFlowContainer<LeaderboardScore>
|
=> new FillFlowContainer<LeaderboardScore>
|
||||||
{
|
{
|
||||||
@ -198,8 +214,9 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Child = topScoreContainer = new UserTopScoreContainer<TScoreInfo>(CreateDrawableTopScore)
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -367,5 +384,7 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract LeaderboardScore CreateDrawableScore(TScoreInfo model, int index);
|
protected abstract LeaderboardScore CreateDrawableScore(TScoreInfo model, int index);
|
||||||
|
|
||||||
|
protected abstract LeaderboardScore CreateDrawableTopScore(TScoreInfo model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,31 +9,28 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
|
||||||
using osu.Game.Online.Leaderboards;
|
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Scoring;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Leaderboards
|
namespace osu.Game.Online.Leaderboards
|
||||||
{
|
{
|
||||||
public class UserTopScoreContainer : VisibilityContainer
|
public class UserTopScoreContainer<TScoreInfo> : VisibilityContainer
|
||||||
{
|
{
|
||||||
private const int duration = 500;
|
private const int duration = 500;
|
||||||
|
|
||||||
|
public Bindable<TScoreInfo> Score = new Bindable<TScoreInfo>();
|
||||||
|
|
||||||
private readonly Container scoreContainer;
|
private readonly Container scoreContainer;
|
||||||
|
private readonly Func<TScoreInfo, LeaderboardScore> createScoreDelegate;
|
||||||
public Bindable<APILegacyUserTopScoreInfo> Score = new Bindable<APILegacyUserTopScoreInfo>();
|
|
||||||
|
|
||||||
public Action<ScoreInfo> ScoreSelected;
|
|
||||||
|
|
||||||
protected override bool StartHidden => true;
|
protected override bool StartHidden => true;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private RulesetStore rulesets { get; set; }
|
private RulesetStore rulesets { get; set; }
|
||||||
|
|
||||||
public UserTopScoreContainer()
|
public UserTopScoreContainer(Func<TScoreInfo, LeaderboardScore> createScoreDelegate)
|
||||||
{
|
{
|
||||||
|
this.createScoreDelegate = createScoreDelegate;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
@ -72,7 +69,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
private CancellationTokenSource loadScoreCancellation;
|
private CancellationTokenSource loadScoreCancellation;
|
||||||
|
|
||||||
private void onScoreChanged(ValueChangedEvent<APILegacyUserTopScoreInfo> score)
|
private void onScoreChanged(ValueChangedEvent<TScoreInfo> score)
|
||||||
{
|
{
|
||||||
var newScore = score.NewValue;
|
var newScore = score.NewValue;
|
||||||
|
|
||||||
@ -82,12 +79,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
if (newScore == null)
|
if (newScore == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var scoreInfo = newScore.Score.CreateScoreInfo(rulesets);
|
LoadComponentAsync(createScoreDelegate(newScore), drawableScore =>
|
||||||
|
|
||||||
LoadComponentAsync(new LeaderboardScore(scoreInfo, newScore.Position, false)
|
|
||||||
{
|
|
||||||
Action = () => ScoreSelected?.Invoke(scoreInfo)
|
|
||||||
}, drawableScore =>
|
|
||||||
{
|
{
|
||||||
scoreContainer.Child = drawableScore;
|
scoreContainer.Child = drawableScore;
|
||||||
drawableScore.FadeInFromZero(duration, Easing.OutQuint);
|
drawableScore.FadeInFromZero(duration, Easing.OutQuint);
|
@ -51,6 +51,8 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override LeaderboardScore CreateDrawableScore(APIUserScoreAggregate model, int index) => new MatchLeaderboardScore(model, index);
|
protected override LeaderboardScore CreateDrawableScore(APIUserScoreAggregate model, int index) => new MatchLeaderboardScore(model, index);
|
||||||
|
|
||||||
|
protected override LeaderboardScore CreateDrawableTopScore(APIUserScoreAggregate model) => new MatchLeaderboardScore(model, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MatchLeaderboardScope
|
public enum MatchLeaderboardScope
|
||||||
|
@ -9,7 +9,6 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
|
||||||
using osu.Game.Online.Leaderboards;
|
using osu.Game.Online.Leaderboards;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -41,25 +40,8 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public APILegacyUserTopScoreInfo TopScore
|
|
||||||
{
|
|
||||||
get => topScoreContainer.Score.Value;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == null)
|
|
||||||
topScoreContainer.Hide();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
topScoreContainer.Show();
|
|
||||||
topScoreContainer.Score.Value = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool filterMods;
|
private bool filterMods;
|
||||||
|
|
||||||
private UserTopScoreContainer topScoreContainer;
|
|
||||||
|
|
||||||
private IBindable<WeakReference<ScoreInfo>> itemRemoved;
|
private IBindable<WeakReference<ScoreInfo>> itemRemoved;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -101,11 +83,6 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
UpdateScores();
|
UpdateScores();
|
||||||
};
|
};
|
||||||
|
|
||||||
Content.Add(topScoreContainer = new UserTopScoreContainer
|
|
||||||
{
|
|
||||||
ScoreSelected = s => ScoreSelected?.Invoke(s)
|
|
||||||
});
|
|
||||||
|
|
||||||
itemRemoved = scoreManager.ItemRemoved.GetBoundCopy();
|
itemRemoved = scoreManager.ItemRemoved.GetBoundCopy();
|
||||||
itemRemoved.BindValueChanged(onScoreRemoved);
|
itemRemoved.BindValueChanged(onScoreRemoved);
|
||||||
}
|
}
|
||||||
@ -183,7 +160,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
req.Success += r =>
|
req.Success += r =>
|
||||||
{
|
{
|
||||||
scoresCallback?.Invoke(r.Scores.Select(s => s.CreateScoreInfo(rulesets)));
|
scoresCallback?.Invoke(r.Scores.Select(s => s.CreateScoreInfo(rulesets)));
|
||||||
TopScore = r.UserScore;
|
TopScore = r.UserScore.CreateScoreInfo(rulesets);
|
||||||
};
|
};
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
@ -193,5 +170,10 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
{
|
{
|
||||||
Action = () => ScoreSelected?.Invoke(model)
|
Action = () => ScoreSelected?.Invoke(model)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected override LeaderboardScore CreateDrawableTopScore(ScoreInfo model) => new LeaderboardScore(model, model.Position, false)
|
||||||
|
{
|
||||||
|
Action = () => ScoreSelected?.Invoke(model)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user