Convert everything to DI pattern

This commit is contained in:
Drew DeVault
2016-11-08 18:13:20 -05:00
parent dc03f36793
commit ee24cd310c
44 changed files with 233 additions and 224 deletions

View File

@ -10,6 +10,8 @@ using OpenTK.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework;
using System.Threading.Tasks;
using osu.Framework.Graphics.Textures;
using osu.Framework.Allocation;
namespace osu.Game.Graphics.Background
{
@ -26,13 +28,12 @@ namespace osu.Game.Graphics.Background
Depth = float.MinValue;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
Add(BackgroundSprite = new Sprite
{
Texture = game.Textures.Get(textureName),
Texture = textures.Get(textureName),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.DarkGray

View File

@ -3,6 +3,7 @@ using osu.Framework.Graphics;
using osu.Framework.Input;
using OpenTK;
using osu.Framework;
using osu.Framework.Allocation;
namespace osu.Game.Graphics.Containers
{
@ -15,21 +16,21 @@ namespace osu.Game.Graphics.Containers
public ParallaxContainer()
{
RelativeSizeAxes = Axes.Both;
AddInternal(content = new Container()
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
}
private Container content;
protected override Container<Drawable> Content => content;
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
AddInternal(content = new Container()
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
}
protected override bool OnMouseMove(InputState state)

View File

@ -2,10 +2,12 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
@ -37,15 +39,14 @@ namespace osu.Game.Graphics.Cursor
AutoSizeAxes = Axes.Both;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
Children = new Drawable[]
{
new Sprite
{
Texture = game.Textures.Get(@"Cursor/cursor")
Texture = textures.Get(@"Cursor/cursor")
}
};
}

View File

@ -4,9 +4,11 @@
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Graphics.UserInterface
{
@ -59,20 +61,20 @@ namespace osu.Game.Graphics.UserInterface
Name = name;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
Children = new Drawable[]
{
buttonSprite = new Sprite
{
Texture = game.Textures.Get(@"KeyCounter/key-up"),
Texture = textures.Get(@"KeyCounter/key-up"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
glowSprite = new Sprite
{
Texture = game.Textures.Get(@"KeyCounter/key-glow"),
Texture = textures.Get(@"KeyCounter/key-glow"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0

View File

@ -12,6 +12,7 @@ using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Allocation;
namespace osu.Game.Graphics.UserInterface
{
@ -119,15 +120,14 @@ namespace osu.Game.Graphics.UserInterface
AutoSizeAxes = Axes.Both;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
DisplayedCount = Count;
DisplayedCountSpriteText.Text = FormatCount(count);
DisplayedCountSpriteText.Anchor = this.Anchor;
DisplayedCountSpriteText.Origin = this.Origin;
DisplayedCountSpriteText.Anchor = Anchor;
DisplayedCountSpriteText.Origin = Origin;
}
protected override void LoadComplete()

View File

@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Allocation;
namespace osu.Game.Graphics.UserInterface
{
@ -109,10 +110,9 @@ namespace osu.Game.Graphics.UserInterface
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
starContainer.Width = MaxStars * StarSize + Math.Max(MaxStars - 1, 0) * StarSpacing;
starContainer.Height = StarSize;

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Threading;
using OpenTK;
using osu.Framework.Allocation;
namespace osu.Game.Graphics.UserInterface.Volume
{
@ -32,7 +33,8 @@ namespace osu.Game.Graphics.UserInterface.Volume
Origin = Anchor.BottomRight;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
VolumeGlobal.ValueChanged += volumeChanged;
VolumeSample.ValueChanged += volumeChanged;
@ -55,8 +57,6 @@ namespace osu.Game.Graphics.UserInterface.Volume
}
}
};
base.Load(game);
}
protected override void Dispose(bool isDisposing)