diff --git a/osu-framework b/osu-framework index 5c0e4edbbc..1cb936a4fe 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 5c0e4edbbcdc26ab56c70676856477cd21e7afdc +Subproject commit 1cb936a4fe9e699ee37deb34eed0b04bc06167e3 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index c5d4a7069b..f1d4e72601 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -21,8 +21,7 @@ namespace osu.Desktop.VisualTests.Tests protected override IFrameBasedClock Clock => ourClock; - [BackgroundDependencyLoader] - private void load() + public TestCaseHitObjects() { var swClock = new StopwatchClock(true) { Rate = 1 }; ourClock = new FramedClock(swClock); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs index 578815779d..bdf20ee73c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs @@ -25,8 +25,7 @@ namespace osu.Desktop.Tests protected MusicController mc; - [BackgroundDependencyLoader] - private void load() + public TestCaseMusicController() { ourClock = new FramedClock(); } diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index fb05d7baf8..881a8e9bde 100644 --- a/osu.Desktop.VisualTests/VisualTestGame.cs +++ b/osu.Desktop.VisualTests/VisualTestGame.cs @@ -19,9 +19,12 @@ namespace osu.Desktop.VisualTests { class VisualTestGame : OsuGameBase { - [BackgroundDependencyLoader] - private void load() + protected override void LoadComplete() { + base.LoadComplete(); + + // Have to construct this here, rather than in the constructor, because + // we depend on some dependencies to be loaded within OsuGameBase.load(). Add(new TestBrowser()); } } diff --git a/osu.Game/GameModes/BackgroundMode.cs b/osu.Game/GameModes/BackgroundMode.cs index b46e7bcc78..dd485df9d9 100644 --- a/osu.Game/GameModes/BackgroundMode.cs +++ b/osu.Game/GameModes/BackgroundMode.cs @@ -43,13 +43,18 @@ namespace osu.Game.GameModes public override bool Push(GameMode mode) { - //don't actually push until we've finished loading. - if (!mode.IsLoaded) + // When trying to push a non-loaded GameMode, load it asynchronously and re-invoke Push + // once it's done. + if (mode.LoadState == LoadState.NotLoaded) { mode.Preload(game, d => Push((BackgroundMode)d)); return true; } + // Make sure the in-progress loading is complete before pushing the GameMode. + while (mode.LoadState < LoadState.Loaded) + Thread.Sleep(1); + base.Push(mode); return true; diff --git a/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs b/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs index 4b1a941089..0afb9c3945 100644 --- a/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs +++ b/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs @@ -1,8 +1,6 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //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 @@ -14,11 +12,6 @@ namespace osu.Game.GameModes.Backgrounds public BackgroundModeCustom(string textureName) { this.textureName = textureName; - } - - [BackgroundDependencyLoader] - private void load() - { Add(new Background(textureName)); } diff --git a/osu.Game/GameModes/GameModeWhiteBox.cs b/osu.Game/GameModes/GameModeWhiteBox.cs index dc96a3c19d..60630c5a9b 100644 --- a/osu.Game/GameModes/GameModeWhiteBox.cs +++ b/osu.Game/GameModes/GameModeWhiteBox.cs @@ -78,65 +78,64 @@ namespace osu.Game.GameModes Content.FadeIn(transition_time, EasingTypes.OutExpo); } - [BackgroundDependencyLoader] - private void load() + public GameModeWhiteBox() { Children = new Drawable[] { - box = new Box + box = new Box + { + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.3f), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = getColourFor(GetType()), + Alpha = 1, + BlendingMode = BlendingMode.Additive, + }, + textContainer = new Container + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new[] { - RelativeSizeAxes = Axes.Both, - Size = new Vector2(0.3f), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Colour = getColourFor(GetType()), - Alpha = 1, - BlendingMode = BlendingMode.Additive, - }, - textContainer = new Container - { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Children = new[] + new SpriteText { - new SpriteText - { - Text = GetType().Name, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - TextSize = 50, - }, - new SpriteText - { - Text = GetType().Namespace, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Position = new Vector2(0, 30) - }, - } - }, - popButton = new Button - { - Text = @"Back", - RelativeSizeAxes = Axes.X, - Size = new Vector2(0.1f, 40), - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Colour = new Color4(235, 51, 153, 255), - Alpha = 0, - Action = delegate { - Exit(); - } - }, - childModeButtons = new FlowContainer - { - Direction = FlowDirection.VerticalOnly, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - RelativeSizeAxes = Axes.Both, - Size = new Vector2(0.1f, 1) + Text = GetType().Name, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 50, + }, + new SpriteText + { + Text = GetType().Namespace, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Position = new Vector2(0, 30) + }, } + }, + popButton = new Button + { + Text = @"Back", + RelativeSizeAxes = Axes.X, + Size = new Vector2(0.1f, 40), + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Colour = new Color4(235, 51, 153, 255), + Alpha = 0, + Action = delegate { + Exit(); + } + }, + childModeButtons = new FlowContainer + { + Direction = FlowDirection.VerticalOnly, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.1f, 1) + } }; if (PossibleChildren != null) diff --git a/osu.Game/GameModes/Menu/Button.cs b/osu.Game/GameModes/Menu/Button.cs index 019ade16a0..8509766132 100644 --- a/osu.Game/GameModes/Menu/Button.cs +++ b/osu.Game/GameModes/Menu/Button.cs @@ -47,53 +47,48 @@ namespace osu.Game.GameModes.Menu this.text = text; AutoSizeAxes = Axes.Both; - } - - [BackgroundDependencyLoader] - private void load() - { Alpha = 0; Vector2 boxSize = new Vector2(ButtonSystem.button_width + Math.Abs(extraWidth), ButtonSystem.button_area_height); Children = new Drawable[] { - box = new Box + box = new Box + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = colour, + Scale = new Vector2(0, 1), + Size = boxSize, + Shear = new Vector2(ButtonSystem.wedge_width / boxSize.Y, 0), + EdgeSmoothness = new Vector2(2, 0), + }, + iconText = new Container + { + AutoSizeAxes = Axes.Both, + Position = new Vector2(extraWidth / 2, 0), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Colour = colour, - Scale = new Vector2(0, 1), - Size = boxSize, - Shear = new Vector2(ButtonSystem.wedge_width / boxSize.Y, 0), - EdgeSmoothness = new Vector2(2, 0), - }, - iconText = new Container - { - AutoSizeAxes = Axes.Both, - Position = new Vector2(extraWidth / 2, 0), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Children = new Drawable[] + icon = new TextAwesome { - icon = new TextAwesome - { - Anchor = Anchor.Centre, - TextSize = 30, - Position = new Vector2(0, 0), - Icon = symbol - }, - new SpriteText - { - Direction = FlowDirection.HorizontalOnly, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - TextSize = 16, - Position = new Vector2(0, 35), - Text = text - } + Anchor = Anchor.Centre, + TextSize = 30, + Position = new Vector2(0, 0), + Icon = symbol + }, + new SpriteText + { + Direction = FlowDirection.HorizontalOnly, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 16, + Position = new Vector2(0, 35), + Text = text } } + } }; } diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 1253af10c7..dec776da13 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -52,11 +52,7 @@ namespace osu.Game.GameModes.Menu public ButtonSystem() { RelativeSizeAxes = Axes.Both; - } - [BackgroundDependencyLoader] - private void load() - { Children = new Drawable[] { buttonArea = new Container @@ -105,13 +101,13 @@ namespace osu.Game.GameModes.Menu buttonFlow.Position = new Vector2(wedge_width * 2 - (button_width + osuLogo.SizeForFlow / 4), 0); - buttonsPlay.Add(new Button(@"solo", @"freeplay", FontAwesome.fa_user, new Color4(102, 68, 204, 255), OnSolo, wedge_width, Key.P)); - buttonsPlay.Add(new Button(@"multi", @"multiplayer", FontAwesome.fa_users, new Color4(94, 63, 186, 255), OnMulti, 0, Key.M)); - buttonsPlay.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), OnChart)); + buttonsPlay.Add(new Button(@"solo", @"freeplay", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), wedge_width, Key.P)); + buttonsPlay.Add(new Button(@"multi", @"multiplayer", FontAwesome.fa_users, new Color4(94, 63, 186, 255), () => OnMulti?.Invoke(), 0, Key.M)); + buttonsPlay.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke())); buttonsTopLevel.Add(new Button(@"play", @"play", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, wedge_width, Key.P)); - buttonsTopLevel.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), OnEdit, 0, Key.E)); - buttonsTopLevel.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), OnDirect, 0, Key.D)); + buttonsTopLevel.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E)); + buttonsTopLevel.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), () => OnDirect?.Invoke(), 0, Key.D)); buttonsTopLevel.Add(new Button(@"exit", @"exit", FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q)); buttonFlow.Add(buttonsPlay); diff --git a/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs b/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs index dc351231be..7db68771c0 100644 --- a/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs +++ b/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs @@ -19,11 +19,7 @@ namespace osu.Game.GameModes.Play.Catch Size = new Vector2(512, 0.9f); Anchor = Anchor.BottomCentre; Origin = Anchor.BottomCentre; - } - [BackgroundDependencyLoader] - private void load() - { Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); } } diff --git a/osu.Game/GameModes/Play/ComboCounter.cs b/osu.Game/GameModes/Play/ComboCounter.cs index ec6d30057f..96660afb6a 100644 --- a/osu.Game/GameModes/Play/ComboCounter.cs +++ b/osu.Game/GameModes/Play/ComboCounter.cs @@ -119,11 +119,7 @@ namespace osu.Game.GameModes.Play }; TextSize = 80; - } - [BackgroundDependencyLoader] - private void load() - { DisplayedCountSpriteText.Text = FormatCount(Count); DisplayedCountSpriteText.Anchor = Anchor; DisplayedCountSpriteText.Origin = Origin; diff --git a/osu.Game/GameModes/Play/HitRenderer.cs b/osu.Game/GameModes/Play/HitRenderer.cs index b2038b88b9..0766e0f6b4 100644 --- a/osu.Game/GameModes/Play/HitRenderer.cs +++ b/osu.Game/GameModes/Play/HitRenderer.cs @@ -43,11 +43,14 @@ namespace osu.Game.GameModes.Play protected virtual List Convert(List objects) => Converter.Convert(objects); + public HitRenderer() + { + RelativeSizeAxes = Axes.Both; + } + [BackgroundDependencyLoader] private void load() { - RelativeSizeAxes = Axes.Both; - Children = new Drawable[] { Playfield = CreatePlayfield() diff --git a/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs b/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs index cbd25fd0e9..c5b13fdaeb 100644 --- a/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs +++ b/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs @@ -2,12 +2,9 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; -using osu.Framework; -using osu.Framework.Allocation; namespace osu.Game.GameModes.Play.Mania { @@ -22,11 +19,7 @@ namespace osu.Game.GameModes.Play.Mania Size = new Vector2(columns / 20f, 1f); Anchor = Anchor.BottomCentre; Origin = Anchor.BottomCentre; - } - [BackgroundDependencyLoader] - private void load() - { Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); for (int i = 0; i < columns; i++) diff --git a/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs b/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs index 286e11506e..5fdc4fcc5e 100644 --- a/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs +++ b/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs @@ -33,9 +33,8 @@ namespace osu.Game.GameModes.Play.Osu DisplayedCountSpriteText.Position = value; } } - - [BackgroundDependencyLoader] - private void load() + + public OsuComboCounter() { PopOutSpriteText.Origin = Origin; PopOutSpriteText.Anchor = Anchor; diff --git a/osu.Game/Graphics/Background/Background.cs b/osu.Game/Graphics/Background/Background.cs index d79976a24a..e04c2dc2d2 100644 --- a/osu.Game/Graphics/Background/Background.cs +++ b/osu.Game/Graphics/Background/Background.cs @@ -26,18 +26,19 @@ namespace osu.Game.Graphics.Background this.textureName = textureName; RelativeSizeAxes = Axes.Both; Depth = float.MinValue; + + Add(BackgroundSprite = new Sprite + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = Color4.DarkGray + }); } [BackgroundDependencyLoader] private void load(TextureStore textures) { - Add(BackgroundSprite = new Sprite - { - Texture = textures.Get(textureName), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Colour = Color4.DarkGray - }); + BackgroundSprite.Texture = textures.Get(textureName); } protected override void Update() diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index d3374da381..4fefc6b7b6 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -118,11 +118,7 @@ namespace osu.Game.Graphics.UserInterface TextSize = 40; AutoSizeAxes = Axes.Both; - } - [BackgroundDependencyLoader] - private void load() - { DisplayedCount = Count; DisplayedCountSpriteText.Text = FormatCount(count); diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index 38e3f161ee..097362bc77 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -108,11 +108,7 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.CentreLeft, } }; - } - [BackgroundDependencyLoader] - private void load() - { starContainer.Width = MaxStars * StarSize + Math.Max(MaxStars - 1, 0) * StarSpacing; starContainer.Height = StarSize; diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index 7a4a6d92bd..6163ba3aad 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -18,6 +18,9 @@ namespace osu.Game.Graphics.UserInterface.Volume private VolumeMeter volumeMeterMaster; + private FlowContainer content; + protected override Container Content => content; + public override bool Contains(Vector2 screenSpacePos) => true; private void volumeChanged(object sender, EventArgs e) @@ -31,32 +34,31 @@ namespace osu.Game.Graphics.UserInterface.Volume AutoSizeAxes = Axes.Both; Anchor = Anchor.BottomRight; Origin = Anchor.BottomRight; + + AddInternal(content = new FlowContainer + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Position = new Vector2(10, 30), + Spacing = new Vector2(15, 0), + }); } - [BackgroundDependencyLoader] - private void load() + protected override void LoadComplete() { + base.LoadComplete(); + VolumeGlobal.ValueChanged += volumeChanged; VolumeSample.ValueChanged += volumeChanged; VolumeTrack.ValueChanged += volumeChanged; - Children = new Drawable[] + Add(new[] { - new FlowContainer - { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Position = new Vector2(10, 30), - Spacing = new Vector2(15,0), - Children = new Drawable[] - { - volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal), - new VolumeMeter("Effects", VolumeSample), - new VolumeMeter("Music", VolumeTrack) - } - } - }; + volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal), + new VolumeMeter("Effects", VolumeSample), + new VolumeMeter("Music", VolumeTrack) + }); } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Online/Chat/Display/ChatLine.cs b/osu.Game/Online/Chat/Display/ChatLine.cs index 175d532f63..662a72f533 100644 --- a/osu.Game/Online/Chat/Display/ChatLine.cs +++ b/osu.Game/Online/Chat/Display/ChatLine.cs @@ -20,17 +20,13 @@ namespace osu.Game.Online.Chat.Display { public readonly Message Message; - public ChatLine(Message message) - { - this.Message = message; - } - const float padding = 200; const float text_size = 20; - [BackgroundDependencyLoader] - private void load() + public ChatLine(Message message) { + this.Message = message; + RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index a13f772f2d..85c4f19431 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -80,8 +80,12 @@ namespace osu.Game Audio.VolumeTrack.Weld(Config.GetBindable(OsuConfig.VolumeMusic)); PlayMode = Config.GetBindable(OsuConfig.PlayMode); + } + + protected override void LoadComplete() + { + base.LoadComplete(); - //todo: move to constructor or LoadComplete. Add(new Drawable[] { new VolumeControlReceptor { diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 2c0094a384..2b221b5bab 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -37,10 +37,6 @@ namespace osu.Game public readonly Bindable Beatmap = new Bindable(); - private void Beatmap_ValueChanged(object sender, EventArgs e) - { - } - [BackgroundDependencyLoader] private void load() { @@ -65,15 +61,6 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); - - AddInternal(ratioContainer = new RatioAdjust()); - - Children = new Drawable[] - { - Cursor = new OsuCursorContainer { Depth = float.MaxValue } - }; - - Beatmap.ValueChanged += Beatmap_ValueChanged; OszArchiveReader.Register(); @@ -85,6 +72,19 @@ namespace osu.Game }); } + protected override void LoadComplete() + { + base.LoadComplete(); + + AddInternal(ratioContainer = new RatioAdjust + { + Children = new[] + { + Cursor = new OsuCursorContainer { Depth = float.MaxValue } + } + }); + } + public override void SetHost(BasicGameHost host) { if (Config == null) diff --git a/osu.Game/Overlays/ToolbarModeButton.cs b/osu.Game/Overlays/ToolbarModeButton.cs index 7ae702918e..bd88eae7c9 100644 --- a/osu.Game/Overlays/ToolbarModeButton.cs +++ b/osu.Game/Overlays/ToolbarModeButton.cs @@ -44,9 +44,9 @@ namespace osu.Game.Overlays } } - [BackgroundDependencyLoader] - private void load() + protected override void LoadComplete() { + base.LoadComplete(); DrawableIcon.TextSize *= 1.4f; } } diff --git a/osu.Game/Overlays/ToolbarModeSelector.cs b/osu.Game/Overlays/ToolbarModeSelector.cs index 2a384ea53e..3b17a28f81 100644 --- a/osu.Game/Overlays/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/ToolbarModeSelector.cs @@ -29,11 +29,7 @@ namespace osu.Game.Overlays public ToolbarModeSelector() { RelativeSizeAxes = Axes.Y; - } - [BackgroundDependencyLoader] - private void load() - { Children = new Drawable[] { new Box @@ -59,8 +55,11 @@ namespace osu.Game.Overlays } }; + int amountButtons = 0; foreach (PlayMode m in Enum.GetValues(typeof(PlayMode))) { + ++amountButtons; + var localMode = m; modeButtons.Add(new ToolbarModeButton { @@ -73,8 +72,8 @@ namespace osu.Game.Overlays }); } - RelativeSizeAxes = Axes.Y; - Size = new Vector2(modeButtons.Children.Count() * ToolbarButton.WIDTH + padding * 2, 1); + // We need to set the size within LoadComplete, because + Size = new Vector2(amountButtons * ToolbarButton.WIDTH + padding * 2, 1); } public void SetGameMode(PlayMode mode)