mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into beatmap-listing-expanded
This commit is contained in:
@ -12,11 +12,11 @@ namespace osu.Game.Online.API
|
||||
/// An API request with a well-defined response type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the response (used for deserialisation).</typeparam>
|
||||
public abstract class APIRequest<T> : APIRequest
|
||||
public abstract class APIRequest<T> : APIRequest where T : class
|
||||
{
|
||||
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);
|
||||
|
||||
public T Result => ((OsuJsonWebRequest<T>)WebRequest).ResponseObject;
|
||||
public T Result => ((OsuJsonWebRequest<T>)WebRequest)?.ResponseObject;
|
||||
|
||||
protected APIRequest()
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public abstract class GetRankingsRequest<TModel> : APIRequest<TModel>
|
||||
public abstract class GetRankingsRequest<TModel> : APIRequest<TModel> where TModel : class
|
||||
{
|
||||
private readonly RulesetInfo ruleset;
|
||||
private readonly int page;
|
||||
|
@ -6,7 +6,7 @@ using osu.Framework.IO.Network;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public abstract class PaginatedAPIRequest<T> : APIRequest<T>
|
||||
public abstract class PaginatedAPIRequest<T> : APIRequest<T> where T : class
|
||||
{
|
||||
private readonly int page;
|
||||
private readonly int itemsPerPage;
|
||||
|
@ -12,5 +12,6 @@ namespace osu.Game.Online.Chat
|
||||
Temporary,
|
||||
PM,
|
||||
Group,
|
||||
System,
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
protected ChannelManager ChannelManager;
|
||||
|
||||
private DrawableChannel drawableChannel;
|
||||
private StandAloneDrawableChannel drawableChannel;
|
||||
|
||||
private readonly bool postingTextbox;
|
||||
|
||||
@ -77,6 +77,9 @@ namespace osu.Game.Online.Chat
|
||||
ChannelManager = manager;
|
||||
}
|
||||
|
||||
protected virtual StandAloneDrawableChannel CreateDrawableChannel(Channel channel) =>
|
||||
new StandAloneDrawableChannel(channel);
|
||||
|
||||
private void postMessage(TextBox sender, bool newtext)
|
||||
{
|
||||
var text = textbox.Text.Trim();
|
||||
@ -92,18 +95,6 @@ namespace osu.Game.Online.Chat
|
||||
textbox.Text = string.Empty;
|
||||
}
|
||||
|
||||
public void Contract()
|
||||
{
|
||||
this.FadeIn(300);
|
||||
this.MoveToY(0, 500, Easing.OutQuint);
|
||||
}
|
||||
|
||||
public void Expand()
|
||||
{
|
||||
this.FadeOut(200);
|
||||
this.MoveToY(100, 500, Easing.In);
|
||||
}
|
||||
|
||||
protected virtual ChatLine CreateMessage(Message message) => new StandAloneMessage(message);
|
||||
|
||||
private void channelChanged(ValueChangedEvent<Channel> e)
|
||||
@ -112,14 +103,14 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
if (e.NewValue == null) return;
|
||||
|
||||
AddInternal(drawableChannel = new StandAloneDrawableChannel(e.NewValue)
|
||||
{
|
||||
CreateChatLineAction = CreateMessage,
|
||||
Padding = new MarginPadding { Bottom = postingTextbox ? textbox_height : 0 }
|
||||
});
|
||||
drawableChannel = CreateDrawableChannel(e.NewValue);
|
||||
drawableChannel.CreateChatLineAction = CreateMessage;
|
||||
drawableChannel.Padding = new MarginPadding { Bottom = postingTextbox ? textbox_height : 0 };
|
||||
|
||||
AddInternal(drawableChannel);
|
||||
}
|
||||
|
||||
protected class StandAloneDrawableChannel : DrawableChannel
|
||||
public class StandAloneDrawableChannel : DrawableChannel
|
||||
{
|
||||
public Func<Message, ChatLine> CreateChatLineAction;
|
||||
|
||||
|
@ -53,17 +53,17 @@ namespace osu.Game.Online
|
||||
manager.ItemRemoved += itemRemoved;
|
||||
}
|
||||
|
||||
private void downloadBegan(ArchiveDownloadRequest<TModel> request)
|
||||
private void downloadBegan(ArchiveDownloadRequest<TModel> request) => Schedule(() =>
|
||||
{
|
||||
if (request.Model.Equals(Model.Value))
|
||||
attachDownload(request);
|
||||
}
|
||||
});
|
||||
|
||||
private void downloadFailed(ArchiveDownloadRequest<TModel> request)
|
||||
private void downloadFailed(ArchiveDownloadRequest<TModel> request) => Schedule(() =>
|
||||
{
|
||||
if (request.Model.Equals(Model.Value))
|
||||
attachDownload(null);
|
||||
}
|
||||
});
|
||||
|
||||
private ArchiveDownloadRequest<TModel> attachedRequest;
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
FillMode = FillMode.Fit;
|
||||
FillAspectRatio = 2;
|
||||
|
||||
var rankColour = getRankColour();
|
||||
var rankColour = OsuColour.ForRank(rank);
|
||||
InternalChild = new DrawSizePreservingFillContainer
|
||||
{
|
||||
TargetDrawSize = new Vector2(64, 32),
|
||||
@ -59,7 +59,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
Padding = new MarginPadding { Top = 5 },
|
||||
Colour = getRankNameColour(),
|
||||
Font = OsuFont.Numeric.With(size: 25),
|
||||
Text = getRankName(),
|
||||
Text = GetRankName(rank),
|
||||
ShadowColour = Color4.Black.Opacity(0.3f),
|
||||
ShadowOffset = new Vector2(0, 0.08f),
|
||||
Shadow = true,
|
||||
@ -69,36 +69,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
};
|
||||
}
|
||||
|
||||
private string getRankName() => rank.GetDescription().TrimEnd('+');
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the grade background colour.
|
||||
/// </summary>
|
||||
private Color4 getRankColour()
|
||||
{
|
||||
switch (rank)
|
||||
{
|
||||
case ScoreRank.XH:
|
||||
case ScoreRank.X:
|
||||
return OsuColour.FromHex(@"ce1c9d");
|
||||
|
||||
case ScoreRank.SH:
|
||||
case ScoreRank.S:
|
||||
return OsuColour.FromHex(@"00a8b5");
|
||||
|
||||
case ScoreRank.A:
|
||||
return OsuColour.FromHex(@"7cce14");
|
||||
|
||||
case ScoreRank.B:
|
||||
return OsuColour.FromHex(@"e3b130");
|
||||
|
||||
case ScoreRank.C:
|
||||
return OsuColour.FromHex(@"f18252");
|
||||
|
||||
default:
|
||||
return OsuColour.FromHex(@"e95353");
|
||||
}
|
||||
}
|
||||
public static string GetRankName(ScoreRank rank) => rank.GetDescription().TrimEnd('+');
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the grade text colour.
|
||||
@ -109,23 +80,23 @@ namespace osu.Game.Online.Leaderboards
|
||||
{
|
||||
case ScoreRank.XH:
|
||||
case ScoreRank.SH:
|
||||
return ColourInfo.GradientVertical(Color4.White, OsuColour.FromHex("afdff0"));
|
||||
return ColourInfo.GradientVertical(Color4.White, Color4Extensions.FromHex("afdff0"));
|
||||
|
||||
case ScoreRank.X:
|
||||
case ScoreRank.S:
|
||||
return ColourInfo.GradientVertical(OsuColour.FromHex(@"ffe7a8"), OsuColour.FromHex(@"ffb800"));
|
||||
return ColourInfo.GradientVertical(Color4Extensions.FromHex(@"ffe7a8"), Color4Extensions.FromHex(@"ffb800"));
|
||||
|
||||
case ScoreRank.A:
|
||||
return OsuColour.FromHex(@"275227");
|
||||
return Color4Extensions.FromHex(@"275227");
|
||||
|
||||
case ScoreRank.B:
|
||||
return OsuColour.FromHex(@"553a2b");
|
||||
return Color4Extensions.FromHex(@"553a2b");
|
||||
|
||||
case ScoreRank.C:
|
||||
return OsuColour.FromHex(@"473625");
|
||||
return Color4Extensions.FromHex(@"473625");
|
||||
|
||||
default:
|
||||
return OsuColour.FromHex(@"512525");
|
||||
return Color4Extensions.FromHex(@"512525");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
scoreLabel = new GlowingSpriteText
|
||||
{
|
||||
TextColour = Color4.White,
|
||||
GlowColour = OsuColour.FromHex(@"83ccfa"),
|
||||
GlowColour = Color4Extensions.FromHex(@"83ccfa"),
|
||||
Text = score.TotalScore.ToString(@"N0"),
|
||||
Font = OsuFont.Numeric.With(size: 23),
|
||||
},
|
||||
@ -325,7 +325,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(icon_size),
|
||||
Rotation = 45,
|
||||
Colour = OsuColour.FromHex(@"3087ac"),
|
||||
Colour = Color4Extensions.FromHex(@"3087ac"),
|
||||
Icon = FontAwesome.Solid.Square,
|
||||
Shadow = true,
|
||||
},
|
||||
@ -334,7 +334,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(icon_size - 6),
|
||||
Colour = OsuColour.FromHex(@"a4edff"),
|
||||
Colour = Color4Extensions.FromHex(@"a4edff"),
|
||||
Icon = statistic.Icon,
|
||||
},
|
||||
},
|
||||
@ -344,7 +344,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextColour = Color4.White,
|
||||
GlowColour = OsuColour.FromHex(@"83ccfa"),
|
||||
GlowColour = Color4Extensions.FromHex(@"83ccfa"),
|
||||
Text = statistic.Value,
|
||||
Font = OsuFont.GetFont(size: 17, weight: FontWeight.Bold),
|
||||
},
|
||||
|
@ -7,23 +7,31 @@ using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Online.Leaderboards
|
||||
{
|
||||
public class UpdateableRank : ModelBackedDrawable<ScoreRank>
|
||||
public class UpdateableRank : ModelBackedDrawable<ScoreRank?>
|
||||
{
|
||||
public ScoreRank Rank
|
||||
public ScoreRank? Rank
|
||||
{
|
||||
get => Model;
|
||||
set => Model = value;
|
||||
}
|
||||
|
||||
public UpdateableRank(ScoreRank rank)
|
||||
public UpdateableRank(ScoreRank? rank)
|
||||
{
|
||||
Rank = rank;
|
||||
}
|
||||
|
||||
protected override Drawable CreateDrawable(ScoreRank rank) => new DrawableRank(rank)
|
||||
protected override Drawable CreateDrawable(ScoreRank? rank)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
if (rank.HasValue)
|
||||
{
|
||||
return new DrawableRank(rank.Value)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user