mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Expose currently selected language from IAPIProvider
This commit is contained in:
parent
1a90f71540
commit
ab790ec96a
@ -18,6 +18,7 @@ using osu.Framework.Extensions.ObjectExtensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Notifications;
|
using osu.Game.Online.Notifications;
|
||||||
@ -28,6 +29,7 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
public partial class APIAccess : Component, IAPIProvider
|
public partial class APIAccess : Component, IAPIProvider
|
||||||
{
|
{
|
||||||
|
private readonly OsuGameBase game;
|
||||||
private readonly OsuConfigManager config;
|
private readonly OsuConfigManager config;
|
||||||
|
|
||||||
private readonly string versionHash;
|
private readonly string versionHash;
|
||||||
@ -52,6 +54,8 @@ namespace osu.Game.Online.API
|
|||||||
public IBindableList<APIUser> Friends => friends;
|
public IBindableList<APIUser> Friends => friends;
|
||||||
public IBindable<UserActivity> Activity => activity;
|
public IBindable<UserActivity> Activity => activity;
|
||||||
|
|
||||||
|
public Language Language => game.CurrentLanguage.Value;
|
||||||
|
|
||||||
private Bindable<APIUser> localUser { get; } = new Bindable<APIUser>(createGuestUser());
|
private Bindable<APIUser> localUser { get; } = new Bindable<APIUser>(createGuestUser());
|
||||||
|
|
||||||
private BindableList<APIUser> friends { get; } = new BindableList<APIUser>();
|
private BindableList<APIUser> friends { get; } = new BindableList<APIUser>();
|
||||||
@ -64,8 +68,9 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
private readonly Logger log;
|
private readonly Logger log;
|
||||||
|
|
||||||
public APIAccess(OsuConfigManager config, EndpointConfiguration endpointConfiguration, string versionHash)
|
public APIAccess(OsuGameBase game, OsuConfigManager config, EndpointConfiguration endpointConfiguration, string versionHash)
|
||||||
{
|
{
|
||||||
|
this.game = game;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.versionHash = versionHash;
|
this.versionHash = versionHash;
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Notifications;
|
using osu.Game.Online.Notifications;
|
||||||
using osu.Game.Tests;
|
using osu.Game.Tests;
|
||||||
@ -29,6 +30,8 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
|
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
|
||||||
|
|
||||||
|
public Language Language => Language.en;
|
||||||
|
|
||||||
public string AccessToken => "token";
|
public string AccessToken => "token";
|
||||||
|
|
||||||
public bool IsLoggedIn => State.Value == APIState.Online;
|
public bool IsLoggedIn => State.Value == APIState.Online;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Notifications;
|
using osu.Game.Online.Notifications;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -27,6 +28,11 @@ namespace osu.Game.Online.API
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
IBindable<UserActivity> Activity { get; }
|
IBindable<UserActivity> Activity { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The language supplied by this provider to API requests.
|
||||||
|
/// </summary>
|
||||||
|
Language Language { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve the OAuth access token.
|
/// Retrieve the OAuth access token.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -296,7 +296,6 @@ namespace osu.Game
|
|||||||
|
|
||||||
MessageFormatter.WebsiteRootUrl = endpoints.WebsiteRootUrl;
|
MessageFormatter.WebsiteRootUrl = endpoints.WebsiteRootUrl;
|
||||||
|
|
||||||
dependencies.CacheAs(API ??= new APIAccess(LocalConfig, endpoints, VersionHash));
|
|
||||||
frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
|
frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
|
||||||
frameworkLocale.BindValueChanged(_ => updateLanguage());
|
frameworkLocale.BindValueChanged(_ => updateLanguage());
|
||||||
|
|
||||||
@ -305,6 +304,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
CurrentLanguage.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToCultureCode());
|
CurrentLanguage.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToCultureCode());
|
||||||
|
|
||||||
|
dependencies.CacheAs(API ??= new APIAccess(this, LocalConfig, endpoints, VersionHash));
|
||||||
|
|
||||||
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
|
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user