1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 09:23:06 +08:00

Remove all non-load Game access.

This commit is contained in:
Dean Herbert 2016-10-10 17:17:26 +09:00
parent 48bd998f46
commit 4052a665bf
34 changed files with 129 additions and 100 deletions

View File

@ -16,6 +16,7 @@ using System.Diagnostics;
using System.Linq;
using osu.Framework.Graphics.Sprites;
using osu.Game.Online.Chat.Display.osu.Online.Social;
using osu.Framework;
namespace osu.Desktop.Tests
{
@ -31,10 +32,17 @@ namespace osu.Desktop.Tests
private Scheduler scheduler = new Scheduler();
private APIAccess api => ((OsuGameBase)Game).API;
private APIAccess api;
private long? lastMessageId;
public override void Load(BaseGame game)
{
base.Load(game);
api = ((OsuGameBase)game).API;
}
public override void Reset()
{
base.Reset();

View File

@ -9,9 +9,9 @@ namespace osu.Framework.VisualTests
{
class VisualTestGame : OsuGameBase
{
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Add(new TestBrowser());

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Transformations;
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework;
namespace osu.Game.GameModes
{
@ -30,9 +31,9 @@ namespace osu.Game.GameModes
return false;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Content.Scale *= 1 + (x_movement_amount / Size.X) * 2;
}

View File

@ -1,6 +1,7 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Game.Graphics.Background;
namespace osu.Game.GameModes.Backgrounds
@ -14,9 +15,9 @@ namespace osu.Game.GameModes.Backgrounds
this.textureName = textureName;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Add(new Background(textureName));
}

View File

@ -1,15 +1,16 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Game.Graphics.Background;
namespace osu.Game.GameModes.Backgrounds
{
public class BackgroundModeDefault : BackgroundMode
{
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Add(new Background());
}

View File

@ -13,6 +13,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Game.GameModes.Backgrounds;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
namespace osu.Game.GameModes
{
@ -77,9 +78,9 @@ namespace osu.Game.GameModes
Content.FadeIn(transition_time, EasingTypes.OutExpo);
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Children = new Drawable[]
{

View File

@ -16,6 +16,7 @@ using osu.Game.Graphics.Containers;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework;
namespace osu.Game.GameModes.Menu
{
@ -63,9 +64,9 @@ namespace osu.Game.GameModes.Menu
RelativeSizeAxes = Axes.Both;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Children = new Drawable[]
{
@ -346,9 +347,9 @@ namespace osu.Game.GameModes.Menu
this.text = text;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Alpha = 0;
Children = new Drawable[]

View File

@ -23,9 +23,9 @@ namespace osu.Game.GameModes.Menu
protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty();
public override void Load()
public override void Load(Framework.BaseGame game)
{
base.Load();
base.Load(game);
Children = new Drawable[]
{
@ -39,9 +39,9 @@ namespace osu.Game.GameModes.Menu
}
};
AudioSample welcome = Game.Audio.Sample.Get(@"welcome");
AudioSample welcome = game.Audio.Sample.Get(@"welcome");
AudioTrack bgm = Game.Audio.Track.Get(@"circles");
AudioTrack bgm = game.Audio.Track.Get(@"circles");
bgm.Looping = true;
Scheduler.Add(delegate

View File

@ -15,6 +15,7 @@ using osu.Game.GameModes.Multiplayer;
using osu.Game.GameModes.Play;
using osu.Game.Graphics.Containers;
using OpenTK;
using osu.Framework;
namespace osu.Game.GameModes.Menu
{
@ -25,11 +26,11 @@ namespace osu.Game.GameModes.Menu
protected override BackgroundMode CreateBackground() => new BackgroundModeDefault();
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
OsuGame osu = (OsuGame)Game;
OsuGame osu = (OsuGame)game;
Children = new Drawable[]
{

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
using osu.Framework;
namespace osu.Game.GameModes.Menu
{
@ -82,12 +83,12 @@ namespace osu.Game.GameModes.Menu
};
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
logo.Texture = Game.Textures.Get(@"Menu/logo");
ripple.Texture = Game.Textures.Get(@"Menu/logo");
logo.Texture = game.Textures.Get(@"Menu/logo");
ripple.Texture = game.Textures.Get(@"Menu/logo");
ripple.ScaleTo(1.1f, 500);
ripple.FadeOut(500);

View File

@ -10,6 +10,7 @@ using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.Beatmaps.Objects.Catch;
using OpenTK;
using osu.Framework;
namespace osu.Game.GameModes.Play.Catch
{
@ -24,9 +25,6 @@ namespace osu.Game.GameModes.Play.Catch
{
//osu! mode requires all objects to be of CatchBaseHit type.
objects = value.ConvertAll(convertForCatch);
if (Parent != null)
Load();
}
}
@ -50,9 +48,9 @@ namespace osu.Game.GameModes.Play.Catch
return h;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
if (playfield == null)
Add(playfield = new CatchPlayfield());
@ -66,7 +64,7 @@ namespace osu.Game.GameModes.Play.Catch
//render stuff!
Sprite s = new Sprite
{
Texture = Game.Textures.Get(@"Menu/logo"),
Texture = game.Textures.Get(@"Menu/logo"),
Origin = Anchor.Centre,
Scale = new Vector2(0.1f),
RelativePositionAxes = Axes.Y,

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Drawables;
using osu.Framework.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
namespace osu.Game.GameModes.Play.Catch
{
@ -20,9 +21,9 @@ namespace osu.Game.GameModes.Play.Catch
Origin = Anchor.BottomCentre;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f });
}

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics.Drawables;
using osu.Game.Beatmaps.Objects;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
namespace osu.Game.GameModes.Play
{
@ -21,9 +22,9 @@ namespace osu.Game.GameModes.Play
RelativeSizeAxes = Axes.Both;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Add(new Box()
{

View File

@ -10,6 +10,7 @@ using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.Beatmaps.Objects.Mania;
using OpenTK;
using osu.Framework;
namespace osu.Game.GameModes.Play.Mania
{
@ -30,9 +31,6 @@ namespace osu.Game.GameModes.Play.Mania
{
//osu! mode requires all objects to be of ManiaBaseHit type.
objects = value.ConvertAll(convertForMania);
if (Parent != null)
Load();
}
}
@ -56,9 +54,9 @@ namespace osu.Game.GameModes.Play.Mania
return h;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
if (playfield == null)
Add(playfield = new ManiaPlayfield(columns));
@ -72,7 +70,7 @@ namespace osu.Game.GameModes.Play.Mania
//render stuff!
Sprite s = new Sprite
{
Texture = Game.Textures.Get(@"Menu/logo"),
Texture = game.Textures.Get(@"Menu/logo"),
Origin = Anchor.Centre,
Scale = new Vector2(0.1f),
RelativePositionAxes = Axes.Both,

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Drawables;
using osu.Framework.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
namespace osu.Game.GameModes.Play.Mania
{
@ -23,9 +24,9 @@ namespace osu.Game.GameModes.Play.Mania
Origin = Anchor.BottomCentre;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Add(new Box() { RelativeSizeAxes = Axes.Both, Alpha = 0.5f });

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Transformations;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using OpenTK;
using System.Diagnostics;
namespace osu.Game.GameModes.Play.Osu
{
@ -20,17 +21,16 @@ namespace osu.Game.GameModes.Play.Osu
{
set
{
Debug.Assert(objects == null);
//osu! mode requires all objects to be of OsuBaseHit type.
objects = value.ConvertAll(o => (OsuBaseHit)o);
if (Parent != null)
Load();
}
}
public override void Load()
public override void Load(Framework.BaseGame game)
{
base.Load();
base.Load(game);
if (playfield == null)
Add(playfield = new OsuPlayfield());
@ -44,7 +44,7 @@ namespace osu.Game.GameModes.Play.Osu
//render stuff!
Sprite s = new Sprite
{
Texture = Game.Textures.Get(@"Menu/logo"),
Texture = game.Textures.Get(@"Menu/logo"),
Origin = Anchor.Centre,
Scale = new Vector2(0.1f),
Alpha = 0,

View File

@ -5,6 +5,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Drawables;
using OpenTK;
using osu.Framework;
namespace osu.Game.GameModes.Play.Osu
{
@ -18,9 +19,9 @@ namespace osu.Game.GameModes.Play.Osu
Origin = Anchor.Centre;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Add(new Box()
{

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using osu.Framework.Configuration;
using osu.Game.GameModes.Backgrounds;
using osu.Framework;
namespace osu.Game.GameModes.Play
{
@ -19,11 +20,11 @@ namespace osu.Game.GameModes.Play
typeof(Player)
};
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
OsuGame osu = Game as OsuGame;
OsuGame osu = game as OsuGame;
playMode = osu.PlayMode;
playMode.ValueChanged += PlayMode_ValueChanged;

View File

@ -20,6 +20,7 @@ using osu.Game.GameModes.Play.Taiko;
using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Input;
using osu.Framework;
namespace osu.Game.GameModes.Play
{
@ -31,9 +32,9 @@ namespace osu.Game.GameModes.Play
typeof(Results)
};
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
List<HitObject> objects = new List<HitObject>();
@ -54,7 +55,7 @@ namespace osu.Game.GameModes.Play
HitObjects = objects
};
OsuGame osu = Game as OsuGame;
OsuGame osu = game as OsuGame;
switch (osu.PlayMode.Value)
{

View File

@ -1,15 +1,16 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.Graphics.Containers;
namespace osu.Game.GameModes.Play
{
public class Playfield : Container
{
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Masking = true;
}

View File

@ -10,6 +10,7 @@ using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.Beatmaps.Objects.Taiko;
using OpenTK;
using osu.Framework;
namespace osu.Game.GameModes.Play.Taiko
{
@ -24,9 +25,6 @@ namespace osu.Game.GameModes.Play.Taiko
{
//osu! mode requires all objects to be of TaikoBaseHit type.
objects = value.ConvertAll(convertForTaiko);
if (Parent != null)
Load();
}
}
@ -49,9 +47,9 @@ namespace osu.Game.GameModes.Play.Taiko
return h;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
if (playfield == null)
Add(playfield = new TaikoPlayfield());
@ -65,7 +63,7 @@ namespace osu.Game.GameModes.Play.Taiko
//render stuff!
Sprite s = new Sprite
{
Texture = Game.Textures.Get(@"Menu/logo"),
Texture = game.Textures.Get(@"Menu/logo"),
Origin = Anchor.Centre,
Scale = new Vector2(0.2f),
RelativePositionAxes = Axes.Both,

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Drawables;
using osu.Framework.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
namespace osu.Game.GameModes.Play.Taiko
{
@ -20,15 +21,15 @@ namespace osu.Game.GameModes.Play.Taiko
Origin = Anchor.Centre;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f });
Add(new Sprite
{
Texture = Game.Textures.Get(@"Menu/logo"),
Texture = game.Textures.Get(@"Menu/logo"),
Origin = Anchor.Centre,
Scale = new Vector2(0.2f),
RelativePositionAxes = Axes.Both,

View File

@ -8,6 +8,7 @@ using osu.Game.Graphics.Containers;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework;
namespace osu.Game.Graphics.Background
{
@ -24,13 +25,13 @@ namespace osu.Game.Graphics.Background
Depth = float.MinValue;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Add(BackgroundSprite = new Sprite
{
Texture = Game.Textures.Get(textureName),
Texture = game.Textures.Get(textureName),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.DarkGray

View File

@ -2,6 +2,7 @@
using osu.Framework.Graphics;
using osu.Framework.Input;
using OpenTK;
using osu.Framework;
namespace osu.Game.Graphics.Containers
{
@ -26,9 +27,9 @@ namespace osu.Game.Graphics.Containers
protected override Container Content => content;
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
}
protected override bool OnMouseMove(InputState state)

View File

@ -1,6 +1,7 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
@ -35,15 +36,15 @@ namespace osu.Game.Graphics.Cursor
Origin = Anchor.Centre;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Children = new Drawable[]
{
new Sprite
{
Texture = Game.Textures.Get(@"Cursor/cursor")
Texture = game.Textures.Get(@"Cursor/cursor")
}
};
}

View File

@ -3,6 +3,7 @@
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -58,20 +59,20 @@ namespace osu.Game.Graphics.UserInterface
Name = name;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Children = new Drawable[]
{
buttonSprite = new Sprite
{
Texture = Game.Textures.Get(@"KeyCounter/key-up"),
Texture = game.Textures.Get(@"KeyCounter/key-up"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
glowSprite = new Sprite
{
Texture = Game.Textures.Get(@"KeyCounter/key-glow"),
Texture = game.Textures.Get(@"KeyCounter/key-glow"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Drawables;
using osu.Framework.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
namespace osu.Game.Online.Chat.Display
{
@ -21,9 +22,9 @@ namespace osu.Game.Online.Chat.Display
this.msg = msg;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
RelativeSizeAxes = Axes.X;

View File

@ -15,6 +15,7 @@ using osu.Game.Graphics.Background;
using osu.Game.GameModes.Play;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays;
using osu.Framework;
namespace osu.Game
{
@ -33,9 +34,9 @@ namespace osu.Game
host.Size = new Vector2(Config.Get<int>(OsuConfig.Width), Config.Get<int>(OsuConfig.Height));
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
//attach our bindables to the audio subsystem.
Audio.Volume.Weld(Config.GetBindable<double>(OsuConfig.VolumeGlobal));

View File

@ -1,4 +1,5 @@
using osu.Framework.GameModes;
using osu.Framework;
using osu.Framework.GameModes;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
@ -12,7 +13,7 @@ using osu.Game.Overlays;
namespace osu.Game
{
public class OsuGameBase : Framework.Game
public class OsuGameBase : Framework.BaseGame
{
internal OsuConfigManager Config = new OsuConfigManager();
@ -27,9 +28,9 @@ namespace osu.Game
public CursorContainer Cursor;
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
//this completely overrides the framework default. will need to change once we make a proper FontStore.
Fonts = new TextureStore() { ScaleAdjust = 0.01f };

View File

@ -9,6 +9,7 @@ using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Input;
using OpenTK.Input;
using osu.Framework;
namespace osu.Game.Overlays
{
@ -16,9 +17,9 @@ namespace osu.Game.Overlays
{
const float width = 300;
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Depth = float.MaxValue;
RelativeSizeAxes = Axes.Y;

View File

@ -12,6 +12,7 @@ using System;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Timing;
using osu.Game.GameModes.Play;
using osu.Framework;
namespace osu.Game.Overlays
{
@ -42,9 +43,9 @@ namespace osu.Game.Overlays
}
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
RelativeSizeAxes = Axes.X;
Size = new Vector2(1, height);
@ -97,7 +98,7 @@ namespace osu.Game.Overlays
new ToolbarButton
{
Icon = FontAwesome.user,
Text = ((OsuGame)Game).Config.Get<string>(OsuConfig.Username)
Text = ((OsuGame)game).Config.Get<string>(OsuConfig.Username)
},
new ToolbarButton
{

View File

@ -5,6 +5,7 @@ using osu.Framework.Extensions;
using osu.Game.GameModes.Play;
using osu.Game.Graphics;
using OpenTK.Graphics;
using osu.Framework;
namespace osu.Game.Overlays
{
@ -42,9 +43,9 @@ namespace osu.Game.Overlays
}
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
DrawableIcon.TextSize *= 1.4f;
}
}

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Transformations;
using osu.Game.GameModes.Play;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
namespace osu.Game.Overlays
{
@ -29,9 +30,9 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Y;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Children = new Drawable[]
{

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Drawables;
using osu.Framework.Input;
using osu.Framework.Graphics.Transformations;
using osu.Framework;
namespace osu.Game
{
@ -24,9 +25,9 @@ namespace osu.Game
RelativeSizeAxes = Axes.Both;
}
public override void Load()
public override void Load(BaseGame game)
{
base.Load();
base.Load(game);
Children = new Drawable[]
{
meterContainer = new Container {