1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 20:32:55 +08:00

Merge branch 'master' into update-icons

This commit is contained in:
Dan Balasescu 2020-09-03 20:19:51 +09:00 committed by GitHub
commit 4d9a5f7ba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 144 additions and 138 deletions

View File

@ -5,9 +5,9 @@ using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Select.Leaderboards;
@ -53,53 +53,46 @@ namespace osu.Game.Tests.Visual.SongSelect
private void showPersonalBestWithNullPosition()
{
leaderboard.TopScore = new APILegacyUserTopScoreInfo
leaderboard.TopScore = new ScoreInfo
{
Position = null,
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,
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
Mods = new[] { new OsuModHidden().Acronym, new OsuModHardRock().Acronym, },
User = new User
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
FullName = @"Spain",
FlagName = @"ES",
},
FullName = @"Spain",
FlagName = @"ES",
},
}
},
};
}
private void showPersonalBest()
{
leaderboard.TopScore = new APILegacyUserTopScoreInfo
leaderboard.TopScore = new ScoreInfo
{
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,
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
Mods = new[] { new OsuModHidden().Acronym, new OsuModHardRock().Acronym, },
User = new User
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
FullName = @"Spain",
FlagName = @"ES",
},
FullName = @"Spain",
FlagName = @"ES",
},
}
},
};
}

View File

@ -6,11 +6,11 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.SongSelect
@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual.SongSelect
public TestSceneUserTopScoreContainer()
{
UserTopScoreContainer topScoreContainer;
UserTopScoreContainer<ScoreInfo> topScoreContainer;
Add(dialogOverlay = new DialogOverlay
{
@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.SongSelect
RelativeSizeAxes = Axes.Both,
Colour = Color4.DarkGreen,
},
topScoreContainer = new UserTopScoreContainer
topScoreContainer = new UserTopScoreContainer<ScoreInfo>(s => new LeaderboardScore(s, s.Position, false))
{
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
@ -52,69 +52,60 @@ namespace osu.Game.Tests.Visual.SongSelect
var scores = new[]
{
new APILegacyUserTopScoreInfo
new ScoreInfo
{
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,
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
Mods = new[] { new OsuModHidden().Acronym, new OsuModHardRock().Acronym, },
User = new User
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
FullName = @"Spain",
FlagName = @"ES",
},
FullName = @"Spain",
FlagName = @"ES",
},
}
},
},
new APILegacyUserTopScoreInfo
new ScoreInfo
{
Position = 110000,
Score = new APILegacyScoreInfo
Rank = ScoreRank.X,
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
User = new User
{
Rank = ScoreRank.X,
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
User = new User
Id = 4608074,
Username = @"Skycries",
Country = new Country
{
Id = 4608074,
Username = @"Skycries",
Country = new Country
{
FullName = @"Brazil",
FlagName = @"BR",
},
FullName = @"Brazil",
FlagName = @"BR",
},
}
},
},
new APILegacyUserTopScoreInfo
new ScoreInfo
{
Position = 22333,
Score = new APILegacyScoreInfo
Rank = ScoreRank.S,
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
User = new User
{
Rank = ScoreRank.S,
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
User = new User
Id = 1541390,
Username = @"Toukai",
Country = new Country
{
Id = 1541390,
Username = @"Toukai",
Country = new Country
{
FullName = @"Canada",
FlagName = @"CA",
},
FullName = @"Canada",
FlagName = @"CA",
},
}
},
}
};

View File

@ -3,6 +3,8 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Rulesets;
using osu.Game.Scoring;
namespace osu.Game.Online.API.Requests.Responses
{
@ -22,5 +24,12 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"score")]
public APILegacyScoreInfo Score;
public ScoreInfo CreateScoreInfo(RulesetStore rulesets)
{
var score = Score.CreateScoreInfo(rulesets);
score.Position = Position;
return score;
}
}
}

View File

@ -33,6 +33,9 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty("user")]
public User User { get; set; }
[JsonProperty("position")]
public int? Position { get; set; }
public ScoreInfo CreateScoreInfo() =>
new ScoreInfo
{
@ -40,6 +43,7 @@ namespace osu.Game.Online.API.Requests.Responses
PP = PP,
TotalScore = TotalScore,
User = User,
Position = Position
};
}
}

View File

@ -27,6 +27,7 @@ namespace osu.Game.Online.Leaderboards
private readonly OsuScrollContainer scrollContainer;
private readonly Container placeholderContainer;
private readonly UserTopScoreContainer<TScoreInfo> topScoreContainer;
private FillFlowContainer<LeaderboardScore> scrollFlow;
@ -87,6 +88,20 @@ namespace osu.Game.Online.Leaderboards
}
}
public TScoreInfo TopScore
{
get => topScoreContainer.Score.Value;
set
{
topScoreContainer.Score.Value = value;
if (value == null)
topScoreContainer.Hide();
else
topScoreContainer.Show();
}
}
protected virtual FillFlowContainer<LeaderboardScore> CreateScoreFlow()
=> new FillFlowContainer<LeaderboardScore>
{
@ -198,8 +213,9 @@ namespace osu.Game.Online.Leaderboards
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Child = topScoreContainer = new UserTopScoreContainer<TScoreInfo>(CreateDrawableTopScore)
},
}
},
},
},
},
@ -367,5 +383,7 @@ namespace osu.Game.Online.Leaderboards
}
protected abstract LeaderboardScore CreateDrawableScore(TScoreInfo model, int index);
protected abstract LeaderboardScore CreateDrawableTopScore(TScoreInfo model);
}
}

View File

@ -9,31 +9,29 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets;
using osu.Game.Scoring;
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;
public Bindable<TScoreInfo> Score = new Bindable<TScoreInfo>();
private readonly Container scoreContainer;
public Bindable<APILegacyUserTopScoreInfo> Score = new Bindable<APILegacyUserTopScoreInfo>();
public Action<ScoreInfo> ScoreSelected;
private readonly Func<TScoreInfo, LeaderboardScore> createScoreDelegate;
protected override bool StartHidden => true;
[Resolved]
private RulesetStore rulesets { get; set; }
public UserTopScoreContainer()
public UserTopScoreContainer(Func<TScoreInfo, LeaderboardScore> createScoreDelegate)
{
this.createScoreDelegate = createScoreDelegate;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@ -72,7 +70,7 @@ namespace osu.Game.Screens.Select.Leaderboards
private CancellationTokenSource loadScoreCancellation;
private void onScoreChanged(ValueChangedEvent<APILegacyUserTopScoreInfo> score)
private void onScoreChanged(ValueChangedEvent<TScoreInfo> score)
{
var newScore = score.NewValue;
@ -82,12 +80,7 @@ namespace osu.Game.Screens.Select.Leaderboards
if (newScore == null)
return;
var scoreInfo = newScore.Score.CreateScoreInfo(rulesets);
LoadComponentAsync(new LeaderboardScore(scoreInfo, newScore.Position, false)
{
Action = () => ScoreSelected?.Invoke(scoreInfo)
}, drawableScore =>
LoadComponentAsync(createScoreDelegate(newScore), drawableScore =>
{
scoreContainer.Child = drawableScore;
drawableScore.FadeInFromZero(duration, Easing.OutQuint);

View File

@ -0,0 +1,18 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.Multiplayer
{
public class APILeaderboard
{
[JsonProperty("leaderboard")]
public List<APIUserScoreAggregate> Leaderboard;
[JsonProperty("user_score")]
public APIUserScoreAggregate UserScore;
}
}

View File

@ -1,17 +1,15 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.Multiplayer
{
public class GetRoomScoresRequest : APIRequest<List<APIUserScoreAggregate>>
public class GetRoomLeaderboardRequest : APIRequest<APILeaderboard>
{
private readonly int roomId;
public GetRoomScoresRequest(int roomId)
public GetRoomLeaderboardRequest(int roomId)
{
this.roomId = roomId;
}

View File

@ -14,8 +14,6 @@ namespace osu.Game.Screens.Multi.Match.Components
{
public class MatchLeaderboard : Leaderboard<MatchLeaderboardScope, APIUserScoreAggregate>
{
public Action<IEnumerable<APIUserScoreAggregate>> ScoresLoaded;
[Resolved(typeof(Room), nameof(Room.RoomID))]
private Bindable<int?> roomId { get; set; }
@ -39,18 +37,20 @@ namespace osu.Game.Screens.Multi.Match.Components
if (roomId.Value == null)
return null;
var req = new GetRoomScoresRequest(roomId.Value ?? 0);
var req = new GetRoomLeaderboardRequest(roomId.Value ?? 0);
req.Success += r =>
{
scoresCallback?.Invoke(r);
ScoresLoaded?.Invoke(r);
scoresCallback?.Invoke(r.Leaderboard);
TopScore = r.UserScore;
};
return req;
}
protected override LeaderboardScore CreateDrawableScore(APIUserScoreAggregate model, int index) => new MatchLeaderboardScore(model, index);
protected override LeaderboardScore CreateDrawableTopScore(APIUserScoreAggregate model) => new MatchLeaderboardScore(model, model.Position, false);
}
public enum MatchLeaderboardScope

View File

@ -14,8 +14,8 @@ namespace osu.Game.Screens.Multi.Match.Components
{
private readonly APIUserScoreAggregate score;
public MatchLeaderboardScore(APIUserScoreAggregate score, int rank)
: base(score.CreateScoreInfo(), rank)
public MatchLeaderboardScore(APIUserScoreAggregate score, int? rank, bool allowHighlight = true)
: base(score.CreateScoreInfo(), rank, allowHighlight)
{
this.score = score;
}

View File

@ -172,7 +172,7 @@ namespace osu.Game.Screens.Multi.Match
new Dimension(GridSizeMode.AutoSize),
new Dimension(),
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.Relative, size: 0.4f, minSize: 240),
new Dimension(GridSizeMode.Relative, size: 0.4f, minSize: 120),
}
},
null

View File

@ -9,7 +9,6 @@ using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets;
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 UserTopScoreContainer topScoreContainer;
private IBindable<WeakReference<ScoreInfo>> itemRemoved;
/// <summary>
@ -101,11 +83,6 @@ namespace osu.Game.Screens.Select.Leaderboards
UpdateScores();
};
Content.Add(topScoreContainer = new UserTopScoreContainer
{
ScoreSelected = s => ScoreSelected?.Invoke(s)
});
itemRemoved = scoreManager.ItemRemoved.GetBoundCopy();
itemRemoved.BindValueChanged(onScoreRemoved);
}
@ -183,7 +160,7 @@ namespace osu.Game.Screens.Select.Leaderboards
req.Success += r =>
{
scoresCallback?.Invoke(r.Scores.Select(s => s.CreateScoreInfo(rulesets)));
TopScore = r.UserScore;
TopScore = r.UserScore?.CreateScoreInfo(rulesets);
};
return req;
@ -193,5 +170,10 @@ namespace osu.Game.Screens.Select.Leaderboards
{
Action = () => ScoreSelected?.Invoke(model)
};
protected override LeaderboardScore CreateDrawableTopScore(ScoreInfo model) => new LeaderboardScore(model, model.Position, false)
{
Action = () => ScoreSelected?.Invoke(model)
};
}
}