post works💪

This commit is contained in:
2022-12-11 22:46:21 +09:00
parent b9721e6f4e
commit 387f434257
10 changed files with 1121 additions and 11 deletions

View File

@ -24,7 +24,7 @@ using osu.Game.Users;
namespace osu.Game.Online.MisskeyAPI
{
public class APIAccess : Component, IAPIProvider
public partial class APIAccess : Component, IAPIProvider
{
private readonly OsuConfigManager config;
@ -108,7 +108,7 @@ namespace osu.Game.Online.MisskeyAPI
if (queue.Count == 0)
{
log.Add(@"Queueing a ping request");
Queue(new Requests.I());
Queue(new Requests.I(AccessToken));
}
break;
@ -149,7 +149,7 @@ namespace osu.Game.Online.MisskeyAPI
}
}
var userReq = new Requests.I();
var userReq = new Requests.I(AccessToken);
userReq.Failure += ex =>
{

View File

@ -23,9 +23,6 @@ namespace osu.Game.Online.MisskeyAPI
{
protected override WebRequest CreateWebRequest() => new JsonWebRequest<T>(Uri);
/// <summary>
/// The deserialised response object. May be null if the request or deserialisation failed.
/// 逆シリアル化された応答オブジェクト。リクエストまたは逆シリアル化が失敗した場合、null になることがあります。
@ -140,11 +137,11 @@ namespace osu.Game.Online.MisskeyAPI
WebRequest.AddHeader("x-api-version", API.APIVersion.ToString(CultureInfo.InvariantCulture));
Body ??= new Dictionary<string, string>();
if (!string.IsNullOrEmpty(API.AccessToken))
Body.Add("i", API.AccessToken);
WebRequest.AddRaw(JsonConvert.SerializeObject(Body));
// Body ??= new Dictionary<string, string>();
//
// if (!string.IsNullOrEmpty(API.AccessToken))
// Body.Add("i", API.AccessToken);
// WebRequest.AddRaw(JsonConvert.SerializeObject(Body));
if (isFailing) return;

View File

@ -0,0 +1,47 @@
// Copyright (c) sim1222 <kokt@sim1222.com>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Net.Http;
using Newtonsoft.Json;
using osu.Framework.IO.Network;
using osu.Framework.Logging;
namespace osu.Game.Online.MisskeyAPI.Requests.Notes
{
public class Create : APIRequest<MisskeyAPI.Responses.Types.Note>
{
private string text;
private string i;
public Create(string i, string Text)
{
this.text = Text;
this.i = i;
}
private class ReqBody
{
public string? text;
public string? i;
};
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.Method = HttpMethod.Post;
var body = new ReqBody()
{
text = text,
i = i
};
var json = JsonConvert.SerializeObject(body);
Logger.Log(json, LoggingTarget.Network, LogLevel.Debug);
req.AddRaw(json);
return req;
}
protected override string Target => @"notes/create";
// protected override string Uri => @"https://apicheck.sim1222.workers.dev/notes/create";
}
}

View File

@ -0,0 +1,53 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>, sim1222 <kokt@sim1222.com>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Net.Http;
using JetBrains.Annotations;
using Newtonsoft.Json;
using osu.Framework.IO.Network;
using Realms;
namespace osu.Game.Online.MisskeyAPI.Requests.Notes
{
public class HybridTimeline : APIRequest<MisskeyAPI.Requests.Responses.Notes.HybridTimeline>
{
private readonly string i;
private readonly string sinceId;
private readonly string untilId;
public HybridTimeline(
string i,
string sinceId = "",
string untilId = ""
)
{
this.i = i;
this.sinceId = sinceId;
this.untilId = untilId;
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.Method = HttpMethod.Post;
var body = new Dictionary<string, string>
{
{ "i", i },
};
if (sinceId != "")
body.Add("sinceId", sinceId);
if (untilId != "")
body.Add("untilId", untilId);
req.AddRaw(JsonConvert.SerializeObject(body));
return req;
}
protected override string Target => @"notes/hybrid-timeline";
}
}

View File

@ -0,0 +1,267 @@
// Copyright (c) sim1222 <kokt@sim1222.com>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace osu.Game.Online.MisskeyAPI.Requests.Responses.Notes
{
public class Channel
{
}
public class Emoji
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
}
public class File
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("createdAt")]
public DateTime? CreatedAt { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("md5")]
public string Md5 { get; set; }
[JsonProperty("size")]
public int? Size { get; set; }
[JsonProperty("isSensitive")]
public bool? IsSensitive { get; set; }
[JsonProperty("blurhash")]
public string Blurhash { get; set; }
[JsonProperty("properties")]
public Properties Properties { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("thumbnailUrl")]
public string ThumbnailUrl { get; set; }
[JsonProperty("comment")]
public string Comment { get; set; }
[JsonProperty("folderId")]
public string FolderId { get; set; }
[JsonProperty("folder")]
public Folder Folder { get; set; }
[JsonProperty("userId")]
public string UserId { get; set; }
[JsonProperty("user")]
public User User { get; set; }
}
public class Folder
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("createdAt")]
public DateTime? CreatedAt { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("foldersCount")]
public int? FoldersCount { get; set; }
[JsonProperty("filesCount")]
public int? FilesCount { get; set; }
[JsonProperty("parentId")]
public string ParentId { get; set; }
[JsonProperty("parent")]
public Parent Parent { get; set; }
}
public class MyReaction
{
}
public class Parent
{
}
public class Poll
{
}
public class Properties
{
[JsonProperty("width")]
public int? Width { get; set; }
[JsonProperty("height")]
public int? Height { get; set; }
[JsonProperty("orientation")]
public int? Orientation { get; set; }
[JsonProperty("avgColor")]
public string AvgColor { get; set; }
}
public class Reactions
{
}
public class Renote
{
}
public class Reply
{
}
public class HybridTimeline
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("createdAt")]
public DateTime? CreatedAt { get; set; }
[JsonProperty("text")]
public string Text { get; set; }
[JsonProperty("cw")]
public string Cw { get; set; }
[JsonProperty("userId")]
public string UserId { get; set; }
[JsonProperty("user")]
public User User { get; set; }
[JsonProperty("replyId")]
public string ReplyId { get; set; }
[JsonProperty("renoteId")]
public string RenoteId { get; set; }
[JsonProperty("reply")]
public Reply Reply { get; set; }
[JsonProperty("renote")]
public Renote Renote { get; set; }
[JsonProperty("isHidden")]
public bool? IsHidden { get; set; }
[JsonProperty("visibility")]
public string Visibility { get; set; }
[JsonProperty("mentions")]
public List<string> Mentions { get; set; }
[JsonProperty("visibleUserIds")]
public List<string> VisibleUserIds { get; set; }
[JsonProperty("fileIds")]
public List<string> FileIds { get; set; }
[JsonProperty("files")]
public List<File> Files { get; set; }
[JsonProperty("tags")]
public List<string> Tags { get; set; }
[JsonProperty("poll")]
public Poll Poll { get; set; }
[JsonProperty("channelId")]
public string ChannelId { get; set; }
[JsonProperty("channel")]
public Channel Channel { get; set; }
[JsonProperty("localOnly")]
public bool? LocalOnly { get; set; }
[JsonProperty("emojis")]
public List<Emoji> Emojis { get; set; }
[JsonProperty("reactions")]
public Reactions Reactions { get; set; }
[JsonProperty("renoteCount")]
public int? RenoteCount { get; set; }
[JsonProperty("repliesCount")]
public int? RepliesCount { get; set; }
[JsonProperty("uri")]
public string Uri { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("myReaction")]
public MyReaction MyReaction { get; set; }
}
public class User
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("username")]
public string Username { get; set; }
[JsonProperty("host")]
public string Host { get; set; }
[JsonProperty("avatarUrl")]
public string AvatarUrl { get; set; }
[JsonProperty("avatarBlurhash")]
public object AvatarBlurhash { get; set; }
[JsonProperty("avatarColor")]
public object AvatarColor { get; set; }
[JsonProperty("isAdmin")]
public bool? IsAdmin { get; set; }
[JsonProperty("isModerator")]
public bool? IsModerator { get; set; }
[JsonProperty("isBot")]
public bool? IsBot { get; set; }
[JsonProperty("isCat")]
public bool? IsCat { get; set; }
[JsonProperty("emojis")]
public List<Emoji> Emojis { get; set; }
[JsonProperty("onlineStatus")]
public string OnlineStatus { get; set; }
}
}

View File

@ -0,0 +1,101 @@
// 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;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.Drawables.Cards;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
namespace osu.Game.Screens.Misskey.Components
{
public abstract partial class DrawableNoteCard : OsuClickableContainer
{
public const float TRANSITION_DURATION = 400;
public const float CORNER_RADIUS = 10;
protected const float WIDTH = 430;
public IBindable<bool> Expanded { get; }
public readonly APIBeatmapSet BeatmapSet;
protected readonly Bindable<BeatmapSetFavouriteState> FavouriteState;
protected abstract Drawable IdleContent { get; }
protected abstract Drawable DownloadInProgressContent { get; }
protected readonly BeatmapDownloadTracker DownloadTracker;
protected DrawableNoteCard(APIBeatmapSet beatmapSet, bool allowExpansion = true)
: base(HoverSampleSet.Button)
{
Expanded = new BindableBool { Disabled = !allowExpansion };
BeatmapSet = beatmapSet;
FavouriteState = new Bindable<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
DownloadTracker = new BeatmapDownloadTracker(beatmapSet);
}
[BackgroundDependencyLoader(true)]
private void load(BeatmapSetOverlay? beatmapSetOverlay)
{
Action = () => beatmapSetOverlay?.FetchAndShowBeatmapSet(BeatmapSet.OnlineID);
AddInternal(DownloadTracker);
}
protected override void LoadComplete()
{
base.LoadComplete();
DownloadTracker.State.BindValueChanged(_ => UpdateState());
Expanded.BindValueChanged(_ => UpdateState(), true);
FinishTransforms(true);
}
protected override bool OnHover(HoverEvent e)
{
UpdateState();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
UpdateState();
base.OnHoverLost(e);
}
protected virtual void UpdateState()
{
bool showProgress = DownloadTracker.State.Value == DownloadState.Downloading || DownloadTracker.State.Value == DownloadState.Importing;
IdleContent.FadeTo(showProgress ? 0 : 1, TRANSITION_DURATION, Easing.OutQuint);
DownloadInProgressContent.FadeTo(showProgress ? 1 : 0, TRANSITION_DURATION, Easing.OutQuint);
}
/// <summary>
/// Creates a beatmap card of the given <paramref name="size"/> for the supplied <paramref name="beatmapSet"/>.
/// </summary>
public static BeatmapCard Create(APIBeatmapSet beatmapSet, BeatmapCardSize size, bool allowExpansion = true)
{
switch (size)
{
case BeatmapCardSize.Normal:
return new BeatmapCardNormal(beatmapSet, allowExpansion);
case BeatmapCardSize.Extra:
return new BeatmapCardExtra(beatmapSet, allowExpansion);
default:
throw new ArgumentOutOfRangeException(nameof(size), size, @"Unsupported card size");
}
}
}
}

View File

@ -0,0 +1,101 @@
// Copyright (c) sim1222 <kokt@sim1222.com>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.Drawables.Cards;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
namespace osu.Game.Screens.Misskey.Components
{
public abstract partial class NoteCard : OsuClickableContainer
{
public const float TRANSITION_DURATION = 400;
public const float CORNER_RADIUS = 10;
protected const float WIDTH = 430;
public IBindable<bool> Expanded { get; }
public readonly APIBeatmapSet BeatmapSet;
protected readonly Bindable<BeatmapSetFavouriteState> FavouriteState;
protected abstract Drawable IdleContent { get; }
protected abstract Drawable DownloadInProgressContent { get; }
protected readonly BeatmapDownloadTracker DownloadTracker;
protected NoteCard(APIBeatmapSet beatmapSet, bool allowExpansion = true)
: base(HoverSampleSet.Button)
{
Expanded = new BindableBool { Disabled = !allowExpansion };
BeatmapSet = beatmapSet;
FavouriteState = new Bindable<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
DownloadTracker = new BeatmapDownloadTracker(beatmapSet);
}
[BackgroundDependencyLoader(true)]
private void load(BeatmapSetOverlay? beatmapSetOverlay)
{
Action = () => beatmapSetOverlay?.FetchAndShowBeatmapSet(BeatmapSet.OnlineID);
AddInternal(DownloadTracker);
}
protected override void LoadComplete()
{
base.LoadComplete();
DownloadTracker.State.BindValueChanged(_ => UpdateState());
Expanded.BindValueChanged(_ => UpdateState(), true);
FinishTransforms(true);
}
protected override bool OnHover(HoverEvent e)
{
UpdateState();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
UpdateState();
base.OnHoverLost(e);
}
protected virtual void UpdateState()
{
bool showProgress = DownloadTracker.State.Value == DownloadState.Downloading || DownloadTracker.State.Value == DownloadState.Importing;
IdleContent.FadeTo(showProgress ? 0 : 1, TRANSITION_DURATION, Easing.OutQuint);
DownloadInProgressContent.FadeTo(showProgress ? 1 : 0, TRANSITION_DURATION, Easing.OutQuint);
}
/// <summary>
/// Creates a beatmap card of the given <paramref name="size"/> for the supplied <paramref name="beatmapSet"/>.
/// </summary>
public static BeatmapCard Create(APIBeatmapSet beatmapSet, BeatmapCardSize size, bool allowExpansion = true)
{
switch (size)
{
case BeatmapCardSize.Normal:
return new BeatmapCardNormal(beatmapSet, allowExpansion);
case BeatmapCardSize.Extra:
return new BeatmapCardExtra(beatmapSet, allowExpansion);
default:
throw new ArgumentOutOfRangeException(nameof(size), size, @"Unsupported card size");
}
}
}
}

View File

@ -0,0 +1,298 @@
// 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.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Beatmaps.Drawables.Cards;
using osu.Game.Beatmaps.Drawables.Cards.Statistics;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapSet;
using osuTK;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Screens.Misskey.Components
{
public partial class NoteCardNormal : DrawableNoteCard
{
protected override Drawable IdleContent => idleBottomContent;
protected override Drawable DownloadInProgressContent => downloadProgressBar;
private const float height = 100;
[Cached]
private readonly BeatmapCardContent content;
private BeatmapCardThumbnail thumbnail = null!;
private CollapsibleButtonContainer buttonContainer = null!;
private FillFlowContainer<BeatmapCardStatistic> statisticsContainer = null!;
private FillFlowContainer idleBottomContent = null!;
private BeatmapCardDownloadProgressBar downloadProgressBar = null!;
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
public NoteCardNormal(APIBeatmapSet beatmapSet, bool allowExpansion = true)
: base(beatmapSet, allowExpansion)
{
content = new BeatmapCardContent(height);
}
[BackgroundDependencyLoader]
private void load()
{
Width = WIDTH;
Height = height;
FillFlowContainer leftIconArea = null!;
FillFlowContainer titleBadgeArea = null!;
GridContainer artistContainer = null!;
Child = content.With(c =>
{
c.MainContent = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
thumbnail = new BeatmapCardThumbnail(BeatmapSet)
{
Name = @"Left (icon) area",
Size = new Vector2(height),
Padding = new MarginPadding { Right = CORNER_RADIUS },
Child = leftIconArea = new FillFlowContainer
{
Margin = new MarginPadding(5),
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(1)
}
},
buttonContainer = new CollapsibleButtonContainer(BeatmapSet)
{
X = height - CORNER_RADIUS,
Width = WIDTH - height + CORNER_RADIUS,
FavouriteState = { BindTarget = FavouriteState },
ButtonsCollapsedWidth = CORNER_RADIUS,
ButtonsExpandedWidth = 30,
Children = new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new GridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(GridSizeMode.AutoSize),
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize)
},
Content = new[]
{
new Drawable[]
{
new OsuSpriteText
{
Text = new RomanisableString(BeatmapSet.TitleUnicode, BeatmapSet.Title),
Font = OsuFont.Default.With(size: 22.5f, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X,
Truncate = true
},
titleBadgeArea = new FillFlowContainer
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
}
}
}
},
artistContainer = new GridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(GridSizeMode.AutoSize)
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize)
},
Content = new[]
{
new[]
{
new OsuSpriteText
{
Text = createArtistText(),
Font = OsuFont.Default.With(size: 17.5f, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X,
Truncate = true
},
Empty()
},
}
},
new LinkFlowContainer(s =>
{
s.Shadow = false;
s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold);
}).With(d =>
{
d.AutoSizeAxes = Axes.Both;
d.Margin = new MarginPadding { Top = 2 };
d.AddText("mapped by ", t => t.Colour = colourProvider.Content2);
d.AddUserLink(BeatmapSet.Author);
}),
}
},
new Container
{
Name = @"Bottom content",
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Children = new Drawable[]
{
idleBottomContent = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 3),
AlwaysPresent = true,
Children = new Drawable[]
{
statisticsContainer = new FillFlowContainer<BeatmapCardStatistic>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10, 0),
Alpha = 0,
AlwaysPresent = true,
ChildrenEnumerable = createStatistics()
},
new BeatmapCardExtraInfoRow(BeatmapSet)
}
},
downloadProgressBar = new BeatmapCardDownloadProgressBar
{
RelativeSizeAxes = Axes.X,
Height = 6,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
State = { BindTarget = DownloadTracker.State },
Progress = { BindTarget = DownloadTracker.Progress }
}
}
}
}
}
}
};
c.ExpandedContent = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = 10, Vertical = 13 },
Child = new BeatmapCardDifficultyList(BeatmapSet)
};
c.Expanded.BindTarget = Expanded;
});
if (BeatmapSet.HasVideo)
leftIconArea.Add(new VideoIconPill { IconSize = new Vector2(20) });
if (BeatmapSet.HasStoryboard)
leftIconArea.Add(new StoryboardIconPill { IconSize = new Vector2(20) });
if (BeatmapSet.FeaturedInSpotlight)
{
titleBadgeArea.Add(new SpotlightBeatmapBadge
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Margin = new MarginPadding { Left = 5 }
});
}
if (BeatmapSet.HasExplicitContent)
{
titleBadgeArea.Add(new ExplicitContentBeatmapBadge
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Margin = new MarginPadding { Left = 5 }
});
}
if (BeatmapSet.TrackId != null)
{
artistContainer.Content[0][1] = new FeaturedArtistBeatmapBadge
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Margin = new MarginPadding { Left = 5 }
};
}
}
private LocalisableString createArtistText()
{
var romanisableArtist = new RomanisableString(BeatmapSet.ArtistUnicode, BeatmapSet.Artist);
return BeatmapsetsStrings.ShowDetailsByArtist(romanisableArtist);
}
private IEnumerable<BeatmapCardStatistic> createStatistics()
{
var hypesStatistic = HypesStatistic.CreateFor(BeatmapSet);
if (hypesStatistic != null)
yield return hypesStatistic;
var nominationsStatistic = NominationsStatistic.CreateFor(BeatmapSet);
if (nominationsStatistic != null)
yield return nominationsStatistic;
yield return new FavouritesStatistic(BeatmapSet) { Current = FavouriteState };
yield return new PlayCountStatistic(BeatmapSet);
var dateStatistic = BeatmapCardDateStatistic.CreateFor(BeatmapSet);
if (dateStatistic != null)
yield return dateStatistic;
}
protected override void UpdateState()
{
base.UpdateState();
bool showDetails = IsHovered || Expanded.Value;
buttonContainer.ShowDetails.Value = showDetails;
thumbnail.Dimmed.Value = showDetails;
statisticsContainer.FadeTo(showDetails ? 1 : 0, TRANSITION_DURATION, Easing.OutQuint);
}
}
}

View File

@ -0,0 +1,159 @@
// 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;
using osu.Framework.Allocation;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.MisskeyAPI;
using osu.Game.Misskey.Overlays.Settings;
using osu.Game.Online.MisskeyAPI.Requests.Notes;
using osu.Game.Overlays;
using osu.Game.Overlays.OSD;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Screens.Misskey;
using osuTK;
namespace osu.Game.Screens.Misskey.Components
{
public partial class PostForm : FillFlowContainer
{
private OnScreenDisplay? onScreenDisplay { get; set; }
private partial class ResToast : Toast
{
public ResToast(string value, string desc)
: base("Info", value, desc)
{
}
}
private TextBox cwBox = null!;
private TextBox textBox = null!;
private ShakeContainer shakeSignIn = null!;
[Resolved]
private IAPIProvider api { get; set; } = null!;
public Action? RequestHide;
private void post()
{
if (string.IsNullOrEmpty(textBox.Text))
{
shakeSignIn.Shake();
return;
}
var createReq = new Create(api.AccessToken, textBox.Text);
createReq.Success += _ =>
{
textBox.Text = string.Empty;
cwBox.Text = string.Empty;
onScreenDisplay?.Display(new ResToast("投稿しました", createReq.CompletionState.ToString()));
};
api.Queue(createReq);
onScreenDisplay?.Display(new ResToast("送信しています", ""));
}
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuConfigManager config, AccountCreationOverlay accountCreation)
{
Direction = FillDirection.Vertical;
Spacing = new Vector2(0, 5);
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
ErrorTextFlowContainer errorText;
// LinkFlowContainer forgottenPaswordLink;
Children = new Drawable[]
{
cwBox = new OsuTextBox
{
PlaceholderText = "CW",
RelativeSizeAxes = Axes.X,
TabbableContentContainer = this
},
textBox = new OsuTextBox
{
PlaceholderText = "お気持ち表明してください",
RelativeSizeAxes = Axes.X,
TabbableContentContainer = this,
},
errorText = new ErrorTextFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
},
// new SettingsCheckbox
// {
// LabelText = "Remember username",
// Current = config.GetBindable<bool>(OsuSetting.SaveUsername),
// },
// new SettingsCheckbox
// {
// LabelText = "Stay signed in",
// Current = config.GetBindable<bool>(OsuSetting.SavePassword),
// },
// forgottenPaswordLink = new LinkFlowContainer
// {
// Padding = new MarginPadding { Left = SettingsPanel.CONTENT_MARGINS },
// RelativeSizeAxes = Axes.X,
// AutoSizeAxes = Axes.Y,
// },
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
shakeSignIn = new ShakeContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = new SettingsButton
{
Text = "ノート",
Action = () => post()
},
}
}
},
// new SettingsButton
// {
// Text = "Register",
// Action = () =>
// {
// RequestHide?.Invoke();
// accountCreation.Show();
// }
// }
};
// forgottenPaswordLink.AddLink(LayoutStrings.PopupLoginLoginForgot, $"https://simkey.net/about");
textBox.OnCommit += (_, _) => post();
if (api.LastLoginError?.Message is string error)
errorText.AddErrors(new[] { error });
}
public override bool AcceptsFocus => true;
protected override bool OnClick(ClickEvent e) => true;
// protected override void OnFocus(FocusEvent e)
// {
// Schedule(() => { GetContainingInputManager().ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); });
// }
}
}

View File

@ -0,0 +1,87 @@
// 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.
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osuTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Misskey.Overlays.Login;
using osu.Game.Screens.Misskey.Components;
using osuTK;
namespace osu.Game.Screens.Misskey
{
public partial class MisskeyPost : OsuScreen
{
private PostForm form;
private const float transition_time = 400;
public override bool HideOverlaysOnEnter => false;
private Container contentContainer;
private const float duration = 300;
private const float button_height = 50;
private const float button_vertical_margin = 15;
//private LoginPanel loginPanel;
[Resolved]
private OsuColour colours { get; set; }
[BackgroundDependencyLoader(true)]
private void load()
{
InternalChild = contentContainer = new Container
{
Masking = true,
CornerRadius = 10,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(0.5f, 0.4f),
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.6f,
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Masking = true,
AutoSizeDuration = transition_time,
AutoSizeEasing = Easing.OutQuint,
Children = new Drawable[]
{
form = new PostForm
{
Padding = new MarginPadding(10),
RequestHide = Hide,
},
new Box
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Height = 3,
Colour = colours.Yellow,
Alpha = 1,
},
}
}
}
};
}
}
}