1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 09:03:00 +08:00

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

@ -16,6 +16,7 @@ using osu.Game.Online.API.Requests;
using osu.Game.Online.Chat;
using osu.Game.Online.Chat.Display;
using OpenTK;
using osu.Framework.Allocation;
namespace osu.Desktop.VisualTests.Tests
{
@ -34,11 +35,10 @@ namespace osu.Desktop.VisualTests.Tests
private ChannelDisplay channelDisplay;
protected override void Load(BaseGame game)
[Initializer]
private void Load(APIAccess api)
{
base.Load(game);
api = ((OsuGameBase)game).API;
this.api = api;
}
public override void Reset()

View File

@ -9,6 +9,7 @@ using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.Beatmaps.Objects.Osu.Drawable;
using OpenTK;
using osu.Framework.Allocation;
namespace osu.Desktop.VisualTests.Tests
{
@ -20,10 +21,9 @@ namespace osu.Desktop.VisualTests.Tests
protected override IFrameBasedClock Clock => ourClock;
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
var swClock = new StopwatchClock(true) { Rate = 1 };
ourClock = new FramedClock(swClock);
}

View File

@ -12,6 +12,7 @@ using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.GameModes.Play;
using OpenTK;
using osu.Framework;
using osu.Framework.Allocation;
namespace osu.Desktop.VisualTests.Tests
{
@ -25,12 +26,10 @@ namespace osu.Desktop.VisualTests.Tests
protected override IFrameBasedClock Clock => localClock;
private BaseGame game;
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
this.game = game;
// TODO: Do we even need this here?
}
public override void Reset()
@ -64,9 +63,10 @@ namespace osu.Desktop.VisualTests.Tests
decoder.Process(b);
var player = game.Dependencies.Get<Player>();
player.Beatmap = new WorkingBeatmap(b);
Add(player);
Add(new Player
{
Beatmap = new WorkingBeatmap(b)
});
}
protected override void Update()

View File

@ -13,14 +13,15 @@ using System.Collections.Generic;
using osu.Game.GameModes.Play;
using SQLiteNetExtensions.Extensions;
using osu.Desktop.Platform;
using osu.Framework.Allocation;
namespace osu.Desktop.VisualTests
{
class VisualTestGame : OsuGameBase
{
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
Add(new TestBrowser());
}
}

View File

@ -13,7 +13,8 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Game.Database;
using OpenTK;
using osu.Framework.Allocation;
namespace osu.Game.Beatmaps.Drawable
{
class BeatmapGroup : Container, IStateful<BeatmapGroupState>
@ -99,10 +100,9 @@ namespace osu.Game.Beatmaps.Drawable
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(BaseGame game)
{
base.Load(game);
BeatmapPanels = beatmapSet.Beatmaps.Select(b => new BeatmapPanel(b)
{
GainedSelection = panelGainedSelection,

View File

@ -11,6 +11,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Beatmaps.Objects.Catch.Drawable
{
@ -28,11 +30,10 @@ namespace osu.Game.Beatmaps.Objects.Catch.Drawable
Position = new Vector2(h.Position, -0.1f);
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
Texture = game.Textures.Get(@"Menu/logo");
Texture = textures.Get(@"Menu/logo");
Transforms.Add(new TransformPosition { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) });
Transforms.Add(new TransformAlpha { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });

View File

@ -6,6 +6,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Beatmaps.Objects.Mania.Drawable
{
@ -20,10 +22,10 @@ namespace osu.Game.Beatmaps.Objects.Mania.Drawable
Scale = new Vector2(0.1f);
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
Texture = game.Textures.Get(@"Menu/logo");
Texture = textures.Get(@"Menu/logo");
Transforms.Add(new TransformPositionY() { StartTime = note.StartTime - 200, EndTime = note.StartTime, StartValue = -0.1f, EndValue = 0.9f });
Transforms.Add(new TransformAlpha() { StartTime = note.StartTime + note.Duration + 200, EndTime = note.StartTime + note.Duration + 400, StartValue = 1, EndValue = 0 });

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
using osu.Framework.MathUtils;
using OpenTK;
using osu.Framework.Allocation;
namespace osu.Game.Beatmaps.Objects.Osu.Drawable
{
@ -63,10 +64,9 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
Size = circle.DrawSize;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(BaseGame game)
{
base.Load(game);
approachCircle.Texture = game.Textures.Get(@"Play/osu/approachcircle@2x");
}
@ -149,10 +149,10 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
number.Texture = game.Textures.Get(@"Play/osu/number@2x");
number.Texture = textures.Get(@"Play/osu/number@2x");
}
}
@ -177,10 +177,10 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
layer.Texture = game.Textures.Get(@"Play/osu/ring-glow@2x");
layer.Texture = textures.Get(@"Play/osu/ring-glow@2x");
}
}
@ -203,10 +203,10 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
ring.Texture = game.Textures.Get(@"Play/osu/ring@2x");
ring.Texture = textures.Get(@"Play/osu/ring@2x");
}
}
@ -289,10 +289,10 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
disc.Texture = game.Textures.Get(@"Play/osu/disc@2x");
disc.Texture = textures.Get(@"Play/osu/disc@2x");
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
@ -306,11 +306,10 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
{
private Texture tex;
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
tex = game.Textures.Get(@"Play/osu/triangle@2x");
tex = textures.Get(@"Play/osu/triangle@2x");
for (int i = 0; i < 10; i++)
{

View File

@ -6,6 +6,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Beatmaps.Objects.Taiko.Drawable
{
@ -23,11 +25,10 @@ namespace osu.Game.Beatmaps.Objects.Taiko.Drawable
Position = new Vector2(1.1f, 0.5f);
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
Texture = game.Textures.Get(@"Menu/logo");
Texture = textures.Get(@"Menu/logo");
Transforms.Add(new TransformPositionX { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 1.1f, EndValue = 0.1f });
Transforms.Add(new TransformAlpha { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });

View File

@ -13,6 +13,7 @@ using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework;
using System.Threading;
using osu.Framework.Allocation;
namespace osu.Game.GameModes
{
@ -34,9 +35,9 @@ namespace osu.Game.GameModes
BaseGame game;
protected override void Load(BaseGame game)
[Initializer]
private void Load(BaseGame game)
{
base.Load(game);
this.game = game;
}

View File

@ -2,6 +2,7 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.Allocation;
using osu.Game.Graphics.Background;
namespace osu.Game.GameModes.Backgrounds
@ -15,9 +16,9 @@ namespace osu.Game.GameModes.Backgrounds
this.textureName = textureName;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
Add(new Background(textureName));
}

View File

@ -2,16 +2,16 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.Allocation;
using osu.Game.Graphics.Background;
namespace osu.Game.GameModes.Backgrounds
{
public class BackgroundModeDefault : BackgroundMode
{
protected override void Load(BaseGame game)
[Initializer]
private void Load(BaseGame game)
{
base.Load(game);
Add(new Background());
}
}

View File

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

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
using osu.Game.Graphics;
using System;
using osu.Framework.Allocation;
namespace osu.Game.GameModes.Menu
{
@ -48,9 +49,9 @@ namespace osu.Game.GameModes.Menu
AutoSizeAxes = Axes.Both;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
Alpha = 0;
Vector2 boxSize = new Vector2(ButtonSystem.button_width + Math.Abs(extraWidth), ButtonSystem.button_area_height);

View File

@ -14,6 +14,7 @@ using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework;
using osu.Framework.Allocation;
namespace osu.Game.GameModes.Menu
{
@ -53,10 +54,9 @@ namespace osu.Game.GameModes.Menu
RelativeSizeAxes = Axes.Both;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
Children = new Drawable[]
{
buttonArea = new Container

View File

@ -10,6 +10,8 @@ using osu.Framework.Graphics.Transformations;
using osu.Game.GameModes.Backgrounds;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
namespace osu.Game.GameModes.Menu
{
@ -43,13 +45,12 @@ namespace osu.Game.GameModes.Menu
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(AudioManager audio)
{
base.Load(game);
welcome = audio.Sample.Get(@"welcome");
welcome = game.Audio.Sample.Get(@"welcome");
bgm = game.Audio.Track.Get(@"circles");
bgm = audio.Track.Get(@"circles");
bgm.Looping = true;
}

View File

@ -17,6 +17,8 @@ using OpenTK;
using osu.Framework;
using osu.Game.Overlays;
using System.Threading.Tasks;
using osu.Game.Configuration;
using osu.Framework.Allocation;
namespace osu.Game.GameModes.Menu
{
@ -55,14 +57,11 @@ namespace osu.Game.GameModes.Menu
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(BaseGame game, OptionsOverlay options)
{
base.Load(game);
background.Preload(game);
OsuGame osu = (OsuGame)game;
buttons.OnSettings = osu.Options.ToggleVisibility;
buttons.OnSettings = options.ToggleVisibility;
}
protected override void LoadComplete()

View File

@ -9,6 +9,8 @@ using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
using osu.Framework;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Textures;
namespace osu.Game.GameModes.Menu
{
@ -101,11 +103,11 @@ namespace osu.Game.GameModes.Menu
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(TextureStore textures)
{
base.Load(game);
logo.Texture = game.Textures.Get(@"Menu/logo");
ripple.Texture = game.Textures.Get(@"Menu/logo");
logo.Texture = textures.Get(@"Menu/logo");
ripple.Texture = textures.Get(@"Menu/logo");
}
protected override void LoadComplete()

View File

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

View File

@ -14,6 +14,7 @@ using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Allocation;
namespace osu.Game.GameModes.Play
{
@ -120,13 +121,12 @@ namespace osu.Game.GameModes.Play
TextSize = 80;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
DisplayedCountSpriteText.Text = FormatCount(Count);
DisplayedCountSpriteText.Anchor = this.Anchor;
DisplayedCountSpriteText.Origin = this.Origin;
DisplayedCountSpriteText.Anchor = Anchor;
DisplayedCountSpriteText.Origin = Origin;
StopRolling();
}

View File

@ -8,6 +8,7 @@ using osu.Game.Beatmaps.Objects;
using osu.Framework;
using System;
using System.Linq;
using osu.Framework.Allocation;
namespace osu.Game.GameModes.Play
{
@ -42,10 +43,9 @@ namespace osu.Game.GameModes.Play
protected virtual List<T> Convert(List<HitObject> objects) => Converter.Convert(objects);
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Allocation;
namespace osu.Game.GameModes.Play.Mania
{
@ -23,11 +24,10 @@ namespace osu.Game.GameModes.Play.Mania
Origin = Anchor.BottomCentre;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
Add(new Box() { RelativeSizeAxes = Axes.Both, Alpha = 0.5f });
Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f });
for (int i = 0; i < columns; i++)
Add(new Box()

View File

@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Allocation;
namespace osu.Game.GameModes.Play.Osu
{
@ -33,12 +34,11 @@ namespace osu.Game.GameModes.Play.Osu
}
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
PopOutSpriteText.Origin = this.Origin;
PopOutSpriteText.Anchor = this.Anchor;
PopOutSpriteText.Origin = Origin;
PopOutSpriteText.Anchor = Anchor;
Add(PopOutSpriteText);
}

View File

@ -21,6 +21,8 @@ using osu.Game.Beatmaps.Drawable;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Beatmaps;
using osu.Framework.GameModes;
using osu.Framework.Allocation;
using osu.Framework.Audio;
namespace osu.Game.GameModes.Play
{
@ -126,11 +128,11 @@ namespace osu.Game.GameModes.Play
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game)
{
base.Load(game);
OsuGame osuGame = game as OsuGame;
// TODO: Load(..., [PermitNull] OsuGame osuGame) or some such
var osuGame = game as OsuGame;
if (osuGame != null)
{
playMode = osuGame.PlayMode;
@ -140,11 +142,11 @@ namespace osu.Game.GameModes.Play
}
if (database == null)
database = game.Dependencies.Get<BeatmapDatabase>();
database = beatmaps;
database.BeatmapSetAdded += s => Schedule(() => addBeatmapSet(s));
trackManager = game.Audio.Track;
trackManager = audio.Track;
Task.Factory.StartNew(addBeatmapSets);
}

View File

@ -13,6 +13,8 @@ using osu.Game.Database;
using osu.Framework.Timing;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Allocation;
using osu.Framework.Audio;
namespace osu.Game.GameModes.Play
{
@ -30,17 +32,10 @@ namespace osu.Game.GameModes.Play
private InterpolatingFramedClock playerClock;
private IAdjustableClock sourceClock;
private BeatmapDatabase beatmaps;
public Player(BeatmapDatabase beatmaps)
{
this.beatmaps = beatmaps;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(AudioManager audio, BeatmapDatabase beatmaps)
{
base.Load(game);
try
{
if (Beatmap == null)
@ -57,7 +52,7 @@ namespace osu.Game.GameModes.Play
if (track != null)
{
game.Audio.Track.SetExclusive(track);
audio.Track.SetExclusive(track);
sourceClock = track;
}

View File

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

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)

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Transformations;
using osu.Game.Online.Chat.Display.osu.Online.Social;
using OpenTK;
using osu.Framework;
using osu.Framework.Allocation;
namespace osu.Game.Online.Chat.Display
{
@ -59,9 +60,9 @@ namespace osu.Game.Online.Chat.Display
channel.NewMessagesArrived -= newMessages;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
newMessages(channel.Messages);
}

View File

@ -10,6 +10,7 @@ using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Allocation;
namespace osu.Game.Online.Chat.Display
{
@ -27,10 +28,9 @@ namespace osu.Game.Online.Chat.Display
const float padding = 200;
const float text_size = 20;
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;

View File

@ -20,6 +20,7 @@ using OpenTK.Input;
using osu.Framework.Logging;
using osu.Game.Graphics.UserInterface.Volume;
using osu.Game.Database;
using osu.Framework.Allocation;
namespace osu.Game
{
@ -51,7 +52,8 @@ namespace osu.Game
host.Size = new Vector2(Config.Get<int>(OsuConfig.Width), Config.Get<int>(OsuConfig.Height));
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
if (!Host.IsPrimaryInstance)
{
@ -59,8 +61,6 @@ namespace osu.Game
Environment.Exit(0);
}
base.Load(game);
if (args?.Length > 0)
Schedule(delegate { Dependencies.Get<BeatmapDatabase>().Import(args); });
@ -98,7 +98,7 @@ namespace osu.Game
(intro = new Intro
{
Beatmap = Beatmap
}).Preload(game, d =>
}).Preload(this, d =>
{
mainContent.Add(d);
@ -107,8 +107,8 @@ namespace osu.Game
intro.DisplayAsRoot();
});
(Chat = new ChatConsole(API)).Preload(game, Add);
(MusicController = new MusicController()).Preload(game, Add);
(Chat = new ChatConsole(API)).Preload(this, Add);
(MusicController = new MusicController()).Preload(this, Add);
(Toolbar = new Toolbar
{
@ -116,7 +116,7 @@ namespace osu.Game
OnSettings = Options.ToggleVisibility,
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
OnMusicController = MusicController.ToggleVisibility
}).Preload(game, t =>
}).Preload(this, t =>
{
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
PlayMode.TriggerChange();

View File

@ -1,5 +1,6 @@
using System;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.GameModes;
using osu.Framework.Graphics;
@ -52,10 +53,9 @@ namespace osu.Game
{
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
Dependencies.Cache(this);
Dependencies.Cache<OsuConfigManager>();
Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host));
@ -63,7 +63,7 @@ namespace osu.Game
OszArchiveReader.Register();
//this completely overrides the framework default. will need to change once we make a proper FontStore.
Fonts = new TextureStore() { ScaleAdjust = 0.01f };
Fonts = new FontStore { ScaleAdjust = 0.01f };
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont"));

View File

@ -7,6 +7,7 @@ using System.Linq;
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;
@ -55,9 +56,9 @@ namespace osu.Game.Overlays
});
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
initializeChannels();
}

View File

@ -1,34 +1,32 @@
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Allocation;
using osu.Game.Configuration;
namespace osu.Game.Overlays.Options.General
{
public class LanguageOptions : OptionsSubsection
{
protected override string Header => "Language";
private CheckBoxOption showUnicode, altChatFont;
public LanguageOptions()
{
Children = new Drawable[]
{
new SpriteText { Text = "TODO: Dropdown" },
showUnicode = new CheckBoxOption { LabelText = "Prefer metadata in original language" },
altChatFont = new CheckBoxOption { LabelText = "Use alternative font for chat display" },
};
}
protected override void Load(BaseGame game)
protected override string Header => "Language";
[Initializer]
private void Load(OsuConfigManager config)
{
base.Load(game);
var osuGame = game as OsuGameBase;
if (osuGame != null)
{
showUnicode.Bindable = osuGame.Config.GetBindable<bool>(OsuConfig.ShowUnicode);
altChatFont.Bindable = osuGame.Config.GetBindable<bool>(OsuConfig.AlternativeChatFont);
}
Children = new Drawable[]
{
new SpriteText { Text = "TODO: Dropdown" },
new CheckBoxOption
{
LabelText = "Prefer metadata in original language",
Bindable = config.GetBindable<bool>(OsuConfig.ShowUnicode)
},
new CheckBoxOption
{
LabelText = "Use alternative font for chat display",
Bindable = config.GetBindable<bool>(OsuConfig.AlternativeChatFont)
},
};
}
}
}

View File

@ -1,5 +1,6 @@
using OpenTK;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -27,15 +28,14 @@ namespace osu.Game.Overlays.Options.General
};
}
protected override void Load(BaseGame game)
[Initializer(permitNulls: true)]
private void Load(APIAccess api)
{
base.Load(game);
var osuGame = game as OsuGameBase;
if (osuGame == null)
if (api == null)
return;
loginForm.Children = new Drawable[]
{
new LoginForm(osuGame.API)
new LoginForm(api)
};
}
@ -63,4 +63,4 @@ namespace osu.Game.Overlays.Options.General
}
}
}
}
}

View File

@ -1,4 +1,5 @@
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Platform;
@ -8,28 +9,22 @@ namespace osu.Game.Overlays.Options.General
{
public class UpdateOptions : OptionsSubsection
{
private BasicStorage storage;
protected override string Header => "Updates";
public UpdateOptions()
{
Children = new Drawable[]
{
new SpriteText { Text = "TODO: Dropdown" },
new SpriteText { Text = "Your osu! is up to date" }, // TODO: map this to reality
new OsuButton
{
RelativeSizeAxes = Axes.X,
Text = "Open osu! folder",
Action = () => storage?.OpenInNativeExplorer(),
}
};
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(BasicStorage storage)
{
base.Load(game);
this.storage = game.Host.Storage;
Children = new Drawable[]
{
new SpriteText { Text = "TODO: Dropdown" },
new SpriteText { Text = "Your osu! is up to date" }, // TODO: map this to reality
new OsuButton
{
RelativeSizeAxes = Axes.X,
Text = "Open osu! folder",
Action = () => storage.OpenInNativeExplorer(),
}
};
}
}
}

View File

@ -12,6 +12,7 @@ using osu.Game.Configuration;
using osu.Game.GameModes.Play;
using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Allocation;
namespace osu.Game.Overlays
{
@ -111,10 +112,10 @@ namespace osu.Game.Overlays
Size = new Vector2(1, height);
}
protected override void Load(BaseGame game)
[Initializer]
private void Load(OsuConfigManager config)
{
base.Load(game);
userButton.Text = ((OsuGame)game).Config.Get<string>(OsuConfig.Username);
userButton.Text = config.Get<string>(OsuConfig.Username);
}
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);

View File

@ -6,6 +6,7 @@ using osu.Game.GameModes.Play;
using osu.Game.Graphics;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Allocation;
namespace osu.Game.Overlays
{
@ -43,9 +44,9 @@ namespace osu.Game.Overlays
}
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
DrawableIcon.TextSize *= 1.4f;
}
}

View File

@ -12,6 +12,7 @@ using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Caching;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Allocation;
namespace osu.Game.Overlays
{
@ -30,10 +31,9 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Y;
}
protected override void Load(BaseGame game)
[Initializer]
private void Load()
{
base.Load(game);
Children = new Drawable[]
{
new Box