1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00
osu-lazer/osu.Game/OsuGame.cs

83 lines
2.5 KiB
C#
Raw Normal View History

2016-08-26 11:28:23 +08:00
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
2016-08-26 16:27:49 +08:00
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-08-26 11:28:23 +08:00
2016-09-01 18:06:09 +08:00
using System;
2016-08-31 18:49:34 +08:00
using System.Collections.Generic;
2016-08-26 11:28:23 +08:00
using osu.Game.Configuration;
using osu.Game.GameModes.Menu;
using osu.Game.Graphics.Processing;
2016-08-31 18:49:34 +08:00
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
2016-09-01 18:06:09 +08:00
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
2016-08-26 11:28:23 +08:00
namespace osu.Game
{
public class OsuGame : Framework.Game
{
internal OsuConfigManager Config = new OsuConfigManager();
protected override string MainResourceFile => @"osu.Game.Resources.dll";
2016-08-31 18:49:34 +08:00
internal APIAccess API;
2016-08-26 11:28:23 +08:00
public override void Load()
{
base.Load();
//this completely overrides the framework default. will need to change once we make a proper FontStore.
Fonts = new TextureStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular")) { ScaleAdjust = 0.01f };
2016-09-01 18:06:09 +08:00
Parent.Size = new Vector2(Config.Get<int>(OsuConfig.Width), Config.Get<int>(OsuConfig.Height));
2016-08-26 11:28:23 +08:00
2016-08-31 18:49:34 +08:00
API = new APIAccess()
{
Username = Config.Get<string>(OsuConfig.Username),
Password = Config.Get<string>(OsuConfig.Password),
Token = Config.Get<string>(OsuConfig.Token)
};
//var req = new ListChannelsRequest();
//req.Success += content =>
//{
//};
//API.Queue(req);
2016-08-31 18:49:34 +08:00
Children = new Drawable[]
{
new RatioAdjust
{
Children = new Drawable[]
{
new MainMenu(),
new CursorContainer()
}
}
};
2016-08-26 11:28:23 +08:00
}
2016-08-31 18:49:34 +08:00
protected override void Dispose(bool isDisposing)
{
//refresh token may have changed.
Config.Set(OsuConfig.Token, API.Token);
base.Dispose(isDisposing);
}
2016-09-11 01:23:26 +08:00
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
2016-08-26 11:28:23 +08:00
{
2016-09-11 01:23:26 +08:00
if (!base.Invalidate(invalidation, source, shallPropagate)) return false;
2016-09-01 18:06:09 +08:00
if (Parent != null)
{
Parent.Width = Config.Set(OsuConfig.Width, ActualSize.X).Value;
Parent.Height = Config.Set(OsuConfig.Height, ActualSize.Y).Value;
}
return true;
2016-08-26 11:28:23 +08:00
}
}
}