Merge remote-tracking branch 'refs/remotes/ppy/master' into beatmap-listing-expanded

This commit is contained in:
Andrei Zavatski
2020-03-06 01:27:51 +03:00
286 changed files with 6276 additions and 2706 deletions

View File

@ -10,27 +10,32 @@ namespace osu.Game.Online.API.Requests
{
public class GetCommentsRequest : APIRequest<CommentBundle>
{
private readonly long id;
private readonly int page;
private readonly long commentableId;
private readonly CommentableType type;
private readonly CommentsSortCriteria sort;
private readonly int page;
private readonly long? parentId;
public GetCommentsRequest(CommentableType type, long id, CommentsSortCriteria sort = CommentsSortCriteria.New, int page = 1)
public GetCommentsRequest(long commentableId, CommentableType type, CommentsSortCriteria sort = CommentsSortCriteria.New, int page = 1, long? parentId = null)
{
this.commentableId = commentableId;
this.type = type;
this.sort = sort;
this.id = id;
this.page = page;
this.parentId = parentId;
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.AddParameter("commentable_id", commentableId.ToString());
req.AddParameter("commentable_type", type.ToString().Underscore().ToLowerInvariant());
req.AddParameter("commentable_id", id.ToString());
req.AddParameter("sort", sort.ToString().ToLowerInvariant());
req.AddParameter("page", page.ToString());
req.AddParameter("sort", sort.ToString().ToLowerInvariant());
if (parentId != null)
req.AddParameter("parent_id", parentId.ToString());
return req;
}

View File

@ -0,0 +1,19 @@
// 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 osu.Game.Online.Multiplayer;
namespace osu.Game.Online.API.Requests
{
public class GetRoomRequest : APIRequest<Room>
{
private readonly int roomId;
public GetRoomRequest(int roomId)
{
this.roomId = roomId;
}
protected override string Target => $"rooms/{roomId}";
}
}

View File

@ -4,8 +4,6 @@
using Newtonsoft.Json;
using osu.Game.Users;
using System;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Online.API.Requests.Responses
{
@ -17,8 +15,6 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"parent_id")]
public long? ParentId { get; set; }
public readonly List<Comment> ChildComments = new List<Comment>();
public Comment ParentComment { get; set; }
[JsonProperty(@"user_id")]
@ -71,7 +67,5 @@ namespace osu.Game.Online.API.Requests.Responses
public bool HasMessage => !string.IsNullOrEmpty(Message);
public bool IsVoted { get; set; }
public int DeletedChildrenCount => ChildComments.Count(c => c.IsDeleted);
}
}

View File

@ -9,31 +9,8 @@ namespace osu.Game.Online.API.Requests.Responses
{
public class CommentBundle
{
private List<Comment> comments;
[JsonProperty(@"comments")]
public List<Comment> Comments
{
get => comments;
set
{
comments = value;
comments.ForEach(child =>
{
if (child.ParentId != null)
{
comments.ForEach(parent =>
{
if (parent.Id == child.ParentId)
{
parent.ChildComments.Add(child);
child.ParentComment = parent;
}
});
}
});
}
}
public List<Comment> Comments { get; set; }
[JsonProperty(@"has_more")]
public bool HasMore { get; set; }
@ -58,6 +35,7 @@ namespace osu.Game.Online.API.Requests.Responses
userVotes = value;
Comments.ForEach(c => c.IsVoted = value.Contains(c.Id));
IncludedComments.ForEach(c => c.IsVoted = value.Contains(c.Id));
}
}
@ -81,6 +59,15 @@ namespace osu.Game.Online.API.Requests.Responses
if (c.EditedById == u.Id)
c.EditedUser = u;
});
IncludedComments.ForEach(c =>
{
if (c.UserId == u.Id)
c.User = u;
if (c.EditedById == u.Id)
c.EditedUser = u;
});
});
}
}

View File

@ -58,7 +58,7 @@ namespace osu.Game.Online.Leaderboards
Spacing = new Vector2(-3, 0),
Padding = new MarginPadding { Top = 5 },
Colour = getRankNameColour(),
Font = OsuFont.GetFont(Typeface.Venera, 25),
Font = OsuFont.Numeric.With(size: 25),
Text = getRankName(),
ShadowColour = Color4.Black.Opacity(0.3f),
ShadowOffset = new Vector2(0, 0.08f),

View File

@ -30,7 +30,7 @@ namespace osu.Game.Online.Leaderboards
private FillFlowContainer<LeaderboardScore> scrollFlow;
private readonly LoadingAnimation loading;
private readonly LoadingSpinner loading;
private ScheduledDelegate showScoresDelegate;
private CancellationTokenSource showScoresCancellationSource;
@ -202,7 +202,7 @@ namespace osu.Game.Online.Leaderboards
}
},
},
loading = new LoadingAnimation(),
loading = new LoadingSpinner(),
placeholderContainer = new Container
{
RelativeSizeAxes = Axes.Both

View File

@ -65,9 +65,7 @@ namespace osu.Game.Online.Multiplayer
public void MapObjects(BeatmapManager beatmaps, RulesetStore rulesets)
{
// If we don't have an api beatmap, the request occurred as a result of room creation, so we can query the local beatmap instead
// Todo: Is this a bug? Room creation only returns the beatmap ID
Beatmap.Value = apiBeatmap == null ? beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == BeatmapID) : apiBeatmap.ToBeatmap(rulesets);
Beatmap.Value = apiBeatmap.ToBeatmap(rulesets);
Ruleset.Value = rulesets.GetRuleset(RulesetID);
Ruleset rulesetInstance = Ruleset.Value.CreateInstance();

View File

@ -59,8 +59,8 @@ namespace osu.Game.Online.Multiplayer
public Bindable<int?> MaxParticipants { get; private set; } = new Bindable<int?>();
[Cached]
[JsonIgnore]
public BindableList<User> Participants { get; private set; } = new BindableList<User>();
[JsonProperty("recent_participants")]
public BindableList<User> RecentParticipants { get; private set; } = new BindableList<User>();
[Cached]
public Bindable<int> ParticipantCount { get; private set; } = new Bindable<int>();
@ -118,25 +118,16 @@ namespace osu.Game.Online.Multiplayer
if (DateTimeOffset.Now >= EndDate.Value)
Status.Value = new RoomStatusEnded();
// transfer local beatmaps across to ensure we have Metadata available (CreateRoomRequest does not give us metadata as expected)
foreach (var item in other.Playlist)
{
var localItem = Playlist.FirstOrDefault(i => i.BeatmapID == item.BeatmapID);
if (localItem != null)
item.Beatmap.Value.Metadata = localItem.Beatmap.Value.Metadata;
}
if (!Playlist.SequenceEqual(other.Playlist))
{
Playlist.Clear();
Playlist.AddRange(other.Playlist);
}
if (!Participants.SequenceEqual(other.Participants))
if (!RecentParticipants.SequenceEqual(other.RecentParticipants))
{
Participants.Clear();
Participants.AddRange(other.Participants);
RecentParticipants.Clear();
RecentParticipants.AddRange(other.RecentParticipants);
}
Position = other.Position;

View File

@ -16,7 +16,7 @@ namespace osu.Game.Online
/// </summary>
public abstract class OnlineViewContainer : Container, IOnlineComponent
{
protected LoadingAnimation LoadingAnimation { get; private set; }
protected LoadingSpinner LoadingSpinner { get; private set; }
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };
@ -41,7 +41,7 @@ namespace osu.Game.Online
{
Content,
placeholder = new LoginPlaceholder(placeholderMessage),
LoadingAnimation = new LoadingAnimation
LoadingSpinner = new LoadingSpinner
{
Alpha = 0,
}
@ -63,19 +63,19 @@ namespace osu.Game.Online
PopContentOut(Content);
placeholder.ScaleTo(0.8f).Then().ScaleTo(1, 3 * transform_duration, Easing.OutQuint);
placeholder.FadeInFromZero(2 * transform_duration, Easing.OutQuint);
LoadingAnimation.Hide();
LoadingSpinner.Hide();
break;
case APIState.Online:
PopContentIn(Content);
placeholder.FadeOut(transform_duration / 2, Easing.OutQuint);
LoadingAnimation.Hide();
LoadingSpinner.Hide();
break;
case APIState.Failing:
case APIState.Connecting:
PopContentOut(Content);
LoadingAnimation.Show();
LoadingSpinner.Show();
placeholder.FadeOut(transform_duration / 2, Easing.OutQuint);
break;
}