mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Create drawable and add response to profile.
- Add missing JSON fields to response model - Add missing enum value
This commit is contained in:
@ -7,12 +7,21 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Overlays.Profile.Sections.Recent;
|
|
||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
public class GetUserRecentActivitiesRequest : APIRequest<List<RecentActivity>>
|
public class GetUserRecentActivitiesRequest : APIRequest<List<RecentActivity>>
|
||||||
{
|
{
|
||||||
|
private readonly long userId;
|
||||||
|
private readonly int offset;
|
||||||
|
|
||||||
|
public GetUserRecentActivitiesRequest(long userId, int offset = 0)
|
||||||
|
{
|
||||||
|
this.userId = userId;
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Target => $"users/{userId}/recent_activity?offset={offset}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RecentActivity
|
public class RecentActivity
|
||||||
@ -42,6 +51,9 @@ namespace osu.Game.Online.API.Requests
|
|||||||
[JsonProperty("rank")]
|
[JsonProperty("rank")]
|
||||||
public int Rank;
|
public int Rank;
|
||||||
|
|
||||||
|
[JsonProperty("count")]
|
||||||
|
public int Count;
|
||||||
|
|
||||||
[JsonProperty("mode")]
|
[JsonProperty("mode")]
|
||||||
public string Mode;
|
public string Mode;
|
||||||
|
|
||||||
@ -51,6 +63,9 @@ namespace osu.Game.Online.API.Requests
|
|||||||
[JsonProperty("user")]
|
[JsonProperty("user")]
|
||||||
public RecentActivityUser User;
|
public RecentActivityUser User;
|
||||||
|
|
||||||
|
[JsonProperty("achivementName")]
|
||||||
|
public string AchivementName;
|
||||||
|
|
||||||
public class RecentActivityBeatmap
|
public class RecentActivityBeatmap
|
||||||
{
|
{
|
||||||
[JsonProperty("title")]
|
[JsonProperty("title")]
|
||||||
@ -67,6 +82,9 @@ namespace osu.Game.Online.API.Requests
|
|||||||
|
|
||||||
[JsonProperty("url")]
|
[JsonProperty("url")]
|
||||||
public string Url;
|
public string Url;
|
||||||
|
|
||||||
|
[JsonProperty("previousUsername")]
|
||||||
|
public string PreviousUsername;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +96,7 @@ namespace osu.Game.Online.API.Requests
|
|||||||
BeatmapsetDelete,
|
BeatmapsetDelete,
|
||||||
BeatmapsetRevive,
|
BeatmapsetRevive,
|
||||||
BeatmapsetUpdate,
|
BeatmapsetUpdate,
|
||||||
|
BeatmapsetUpload,
|
||||||
Medal,
|
Medal,
|
||||||
Rank,
|
Rank,
|
||||||
RankLost,
|
RankLost,
|
||||||
|
@ -0,0 +1,117 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Screens.Select.Leaderboards;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||||
|
{
|
||||||
|
public class DrawableRecentActivity : DrawableProfileRow
|
||||||
|
{
|
||||||
|
private RecentActivity activity;
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
public DrawableRecentActivity(RecentActivity activity, User user)
|
||||||
|
{
|
||||||
|
this.activity = activity;
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
LeftFlowContainer.Add(new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = activityToString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
RightFlowContainer.Add(new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = activity.CreatedAt.LocalDateTime.ToShortDateString(),
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
Font = "Exo2.0-RegularItalic",
|
||||||
|
TextSize = 12,
|
||||||
|
Colour = OsuColour.Gray(0xAA),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Drawable CreateLeftVisual()
|
||||||
|
{
|
||||||
|
switch (activity.Type)
|
||||||
|
{
|
||||||
|
case RecentActivityType.Rank:
|
||||||
|
return new DrawableRank(activity.ScoreRank)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Width = 60,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
};
|
||||||
|
|
||||||
|
default:
|
||||||
|
return new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Width = 60,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string activityToString()
|
||||||
|
{
|
||||||
|
switch (activity.Type)
|
||||||
|
{
|
||||||
|
case RecentActivityType.Achievement:
|
||||||
|
return $"{activity.User.Username} unlocked the {activity.AchivementName} achievement!";
|
||||||
|
|
||||||
|
case RecentActivityType.BeatmapPlaycount:
|
||||||
|
return $"{activity.Beatmap.Title} has been played {activity.Count} times!";
|
||||||
|
|
||||||
|
case RecentActivityType.BeatmapsetDelete:
|
||||||
|
return $"{activity.Beatmap.Title} has been deleted.";
|
||||||
|
|
||||||
|
case RecentActivityType.BeatmapsetRevive:
|
||||||
|
return $"{activity.Beatmap.Title} has been revived from eternal slumber by ${activity.User.Username}";
|
||||||
|
|
||||||
|
case RecentActivityType.BeatmapsetUpdate:
|
||||||
|
return $"{activity.User.Username} has updated the beatmap ${activity.Beatmap.Title}";
|
||||||
|
|
||||||
|
case RecentActivityType.BeatmapsetUpload:
|
||||||
|
return $"{activity.User.Username} has submitted a new beatmap ${activity.Beatmap.Title}";
|
||||||
|
|
||||||
|
case RecentActivityType.Medal:
|
||||||
|
return $"{activity.User.Username} has unlocked the {activity.AchivementName} medal!";
|
||||||
|
|
||||||
|
case RecentActivityType.Rank:
|
||||||
|
return $"{activity.User.Username} achieved rank #{activity.Rank} on {activity.Beatmap?.Title}";
|
||||||
|
|
||||||
|
case RecentActivityType.RankLost:
|
||||||
|
return $"{activity.User.Username} has lost first place on {activity.Beatmap.Title}!";
|
||||||
|
|
||||||
|
case RecentActivityType.UserSupportAgain:
|
||||||
|
return $"{activity.User.Username} has once again chosen to support osu! - thanks for your generosity!";
|
||||||
|
|
||||||
|
case RecentActivityType.UserSupportFirst:
|
||||||
|
return $"{activity.User.Username} has become an osu! supporter - thanks for your generosity!";
|
||||||
|
|
||||||
|
case RecentActivityType.UsernameChange:
|
||||||
|
return $"{activity.User.PreviousUsername} has changed their username to {activity.User.Username}";
|
||||||
|
|
||||||
|
case RecentActivityType.UserSupportGift:
|
||||||
|
return $"{activity.User.Username} has received the gift of osu! supporter!";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Overlays.Profile.Sections.Recent;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -17,47 +19,32 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
ItemsPerPage = 5;
|
ItemsPerPage = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
//protected override void ShowMore()
|
protected override void ShowMore()
|
||||||
//{
|
{
|
||||||
// base.ShowMore();
|
base.ShowMore();
|
||||||
|
|
||||||
// var req = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
|
var req = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
|
||||||
|
|
||||||
// req.Success += scores =>
|
req.Success += activities =>
|
||||||
// {
|
{
|
||||||
// foreach (var s in scores)
|
ShowMoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0);
|
||||||
// s.ApplyRuleset(Rulesets.GetRuleset(s.OnlineRulesetID));
|
ShowMoreLoading.Hide();
|
||||||
|
|
||||||
// ShowMoreButton.FadeTo(scores.Count == ItemsPerPage ? 1 : 0);
|
if (!activities.Any() && VisiblePages == 1)
|
||||||
// ShowMoreLoading.Hide();
|
{
|
||||||
|
MissingText.Show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if (!scores.Any() && VisiblePages == 1)
|
MissingText.Hide();
|
||||||
// {
|
|
||||||
// MissingText.Show();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// MissingText.Hide();
|
foreach (RecentActivity activity in activities)
|
||||||
|
{
|
||||||
|
ItemsContainer.Add(new DrawableRecentActivity(activity, User));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// foreach (OnlineScore score in scores)
|
Api.Queue(req);
|
||||||
// {
|
}
|
||||||
// DrawableProfileScore drawableScore;
|
|
||||||
|
|
||||||
// switch (type)
|
|
||||||
// {
|
|
||||||
// default:
|
|
||||||
// drawableScore = new DrawablePerformanceScore(score, includeWeight ? Math.Pow(0.95, ItemsContainer.Count) : (double?)null);
|
|
||||||
// break;
|
|
||||||
// case ScoreType.Recent:
|
|
||||||
// drawableScore = new DrawableTotalScore(score);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// ItemsContainer.Add(drawableScore);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// Api.Queue(req);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,6 +300,7 @@
|
|||||||
<DependentUpon>20180125143340_Settings.cs</DependentUpon>
|
<DependentUpon>20180125143340_Settings.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Migrations\20180131154205_AddMuteBinding.cs" />
|
<Compile Include="Migrations\20180131154205_AddMuteBinding.cs" />
|
||||||
|
<Compile Include="Overlays\Profile\Sections\Recent\DrawableRecentActivity.cs" />
|
||||||
<Compile Include="Overlays\Profile\Sections\Recent\PaginatedRecentActivityContainer.cs" />
|
<Compile Include="Overlays\Profile\Sections\Recent\PaginatedRecentActivityContainer.cs" />
|
||||||
<Compile Include="Overlays\Profile\SupporterIcon.cs" />
|
<Compile Include="Overlays\Profile\SupporterIcon.cs" />
|
||||||
<Compile Include="Online\API\Requests\GetFriendsRequest.cs" />
|
<Compile Include="Online\API\Requests\GetFriendsRequest.cs" />
|
||||||
|
Reference in New Issue
Block a user