Add proper user data retrieval on connect.

This commit is contained in:
Dean Herbert
2016-12-01 16:44:24 +09:00
parent d7ab74363d
commit 6ccce88a0e
6 changed files with 44 additions and 6 deletions

View File

@ -16,12 +16,14 @@ using osu.Game.Database;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.Processing;
using osu.Game.IPC;
using osu.Game.Online;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Online.API.Requests;
namespace osu.Game
{
public class OsuGameBase : BaseGame
public class OsuGameBase : BaseGame, IOnlineComponent
{
internal OsuConfigManager Config;
@ -43,7 +45,7 @@ namespace osu.Game
Dependencies.Cache(this);
Dependencies.Cache(Config);
Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host));
//this completely overrides the framework default. will need to change once we make a proper FontStore.
Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }, true);
@ -74,12 +76,12 @@ namespace osu.Game
Token = Config.Get<string>(OsuConfig.Token)
});
API.OnStateChange += apiStateChanged;
API.Register(this);
}
private void apiStateChanged(APIState oldState, APIState newState)
public void APIStateChanged(APIAccess api, APIState state)
{
switch (newState)
switch (state)
{
case APIState.Online:
Config.Set(OsuConfig.Username, Config.Get<bool>(OsuConfig.SaveUsername) ? API.Username : string.Empty);