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

75 lines
2.2 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 System.Drawing;
using osu.Framework.Framework;
using osu.Game.Configuration;
using osu.Game.GameModes.Menu;
using osu.Game.Graphics.Cursor;
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;
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();
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-26 11:28:23 +08:00
AddProcessingContainer(new RatioAdjust());
//Add(new FontTest());
Add(new MainMenu());
Add(new CursorContainer());
}
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-01 18:06:09 +08:00
public override bool Invalidate(bool affectsSize = true, bool affectsPosition = true, Drawable source = null)
2016-08-26 11:28:23 +08:00
{
2016-09-01 18:06:09 +08:00
if (!base.Invalidate(affectsSize, affectsPosition, source)) return false;
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
}
}
}