mirror of
https://github.com/ppy/osu
synced 2025-02-20 20:47:09 +00:00
Retrieve system title from online source
This commit is contained in:
parent
d9299a8a55
commit
a3f720bc62
15
osu.Game/Online/API/Requests/GetSystemTitleRequest.cs
Normal file
15
osu.Game/Online/API/Requests/GetSystemTitleRequest.cs
Normal file
@ -0,0 +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 osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetSystemTitleRequest : OsuJsonWebRequest<APISystemTitle>
|
||||
{
|
||||
public GetSystemTitleRequest()
|
||||
: base(@"https://assets.ppy.sh/lazer-status.json")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
public class APISystemTitle
|
||||
public record APISystemTitle
|
||||
{
|
||||
[JsonProperty(@"image")]
|
||||
public string Image { get; set; } = string.Empty;
|
||||
|
@ -1,7 +1,9 @@
|
||||
// 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 System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -10,6 +12,7 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
@ -57,6 +60,26 @@ namespace osu.Game.Screens.Menu
|
||||
base.LoadComplete();
|
||||
|
||||
Current.BindValueChanged(_ => loadNewImage(), true);
|
||||
|
||||
checkForUpdates();
|
||||
Scheduler.AddDelayed(checkForUpdates, TimeSpan.FromMinutes(15).TotalMilliseconds, true);
|
||||
}
|
||||
|
||||
private void checkForUpdates()
|
||||
{
|
||||
var request = new GetSystemTitleRequest();
|
||||
Task.Run(() => request.Perform())
|
||||
.ContinueWith(r =>
|
||||
{
|
||||
if (r.IsCompletedSuccessfully)
|
||||
Schedule(() => Current.Value = request.ResponseObject);
|
||||
|
||||
// if the request failed, "observe" the exception.
|
||||
// it isn't very important why this failed, as it's only for display.
|
||||
// the inner error will be logged by framework mechanisms anyway.
|
||||
if (r.IsFaulted)
|
||||
_ = r.Exception;
|
||||
});
|
||||
}
|
||||
|
||||
private void loadNewImage()
|
||||
|
Loading…
Reference in New Issue
Block a user