Refactor OsuColour into injected instance class

Which should allow you to change the color palette in the future for
skinning purposes.
This commit is contained in:
Drew DeVault
2017-01-12 23:49:05 -05:00
parent fa007e632d
commit f5f545df62
12 changed files with 248 additions and 210 deletions

View File

@ -4,54 +4,58 @@ using osu.Framework.Graphics.Colour;
namespace osu.Game.Graphics namespace osu.Game.Graphics
{ {
public static class OsuColour public static class OsuColourExtensions
{ {
public static Color4 Opacity(this Color4 color, float a) => new Color4(color.R, color.G, color.B, a); public static Color4 Opacity(this Color4 color, float a) => new Color4(color.R, color.G, color.B, a);
public static Color4 Opacity(this Color4 color, byte a) => new Color4(color.R, color.G, color.B, a / 255f); public static Color4 Opacity(this Color4 color, byte a) => new Color4(color.R, color.G, color.B, a / 255f);
}
public class OsuColour
{
public static Color4 Gray(float amt) => new Color4(amt, amt, amt, 1f); public static Color4 Gray(float amt) => new Color4(amt, amt, amt, 1f);
public static Color4 Gray(byte amt) => new Color4(amt, amt, amt, 255); public static Color4 Gray(byte amt) => new Color4(amt, amt, amt, 255);
private static Color4 FromHex(string hex) private static Color4 FromHex(string hex)
{ {
return new Color4( return new Color4(
Convert.ToByte(hex.Substring(1, 2), 16), Convert.ToByte(hex.Substring(0, 2), 16),
Convert.ToByte(hex.Substring(3, 2), 16), Convert.ToByte(hex.Substring(2, 2), 16),
Convert.ToByte(hex.Substring(5, 2), 16), Convert.ToByte(hex.Substring(4, 2), 16),
255); 255);
} }
// See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less // See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less
public static readonly Color4 PurpleLighter = FromHex(@"eeeeff"); public Color4 PurpleLighter = FromHex(@"eeeeff");
public static readonly Color4 PurpleLight = FromHex(@"aa88ff"); public Color4 PurpleLight = FromHex(@"aa88ff");
public static readonly Color4 Purple = FromHex(@"8866ee"); public Color4 Purple = FromHex(@"8866ee");
public static readonly Color4 PurpleDark = FromHex(@"6644cc"); public Color4 PurpleDark = FromHex(@"6644cc");
public static readonly Color4 PurpleDarker = FromHex(@"441188"); public Color4 PurpleDarker = FromHex(@"441188");
public static readonly Color4 PinkLighter = FromHex(@"ffddee"); public Color4 PinkLighter = FromHex(@"ffddee");
public static readonly Color4 PinkLight = FromHex(@"ff99cc"); public Color4 PinkLight = FromHex(@"ff99cc");
public static readonly Color4 Pink = FromHex(@"ff66aa"); public Color4 Pink = FromHex(@"ff66aa");
public static readonly Color4 PinkDark = FromHex(@"cc5288"); public Color4 PinkDark = FromHex(@"cc5288");
public static readonly Color4 PinkDarker = FromHex(@"bb1177"); public Color4 PinkDarker = FromHex(@"bb1177");
public static readonly Color4 BlueLighter = FromHex(@"ddffff"); public Color4 BlueLighter = FromHex(@"ddffff");
public static readonly Color4 BlueLight = FromHex(@"99eeff"); public Color4 BlueLight = FromHex(@"99eeff");
public static readonly Color4 Blue = FromHex(@"66ccff"); public Color4 Blue = FromHex(@"66ccff");
public static readonly Color4 BlueDark = FromHex(@"44aadd"); public Color4 BlueDark = FromHex(@"44aadd");
public static readonly Color4 BlueDarker = FromHex(@"2299bb"); public Color4 BlueDarker = FromHex(@"2299bb");
public static readonly Color4 YellowLighter = FromHex(@"ffffdd"); public Color4 YellowLighter = FromHex(@"ffffdd");
public static readonly Color4 YellowLight = FromHex(@"ffdd55"); public Color4 YellowLight = FromHex(@"ffdd55");
public static readonly Color4 Yellow = FromHex(@"ffcc22"); public Color4 Yellow = FromHex(@"ffcc22");
public static readonly Color4 YellowDark = FromHex(@"eeaa00"); public Color4 YellowDark = FromHex(@"eeaa00");
public static readonly Color4 YellowDarker = FromHex(@"cc6600"); public Color4 YellowDarker = FromHex(@"cc6600");
public static readonly Color4 GreenLighter = FromHex(@"eeffcc"); public Color4 GreenLighter = FromHex(@"eeffcc");
public static readonly Color4 GreenLight = FromHex(@"b3d944"); public Color4 GreenLight = FromHex(@"b3d944");
public static readonly Color4 Green = FromHex(@"88b300"); public Color4 Green = FromHex(@"88b300");
public static readonly Color4 GreenDark = FromHex(@"668800"); public Color4 GreenDark = FromHex(@"668800");
public static readonly Color4 GreenDarker = FromHex(@"445500"); public Color4 GreenDarker = FromHex(@"445500");
public static readonly Color4 Red = FromHex(@"fc4549"); public Color4 Red = FromHex(@"fc4549");
} }
} }

View File

@ -34,55 +34,6 @@ namespace osu.Game.Graphics.UserInterface
public BackButton() public BackButton()
{ {
Size = size_retracted; Size = size_retracted;
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Width = 0.4f,
Children = new Drawable[]
{
leftBox = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.PinkDark,
Shear = new Vector2(shear, 0),
},
icon = new TextAwesome
{
Anchor = Anchor.Centre,
TextSize = 25,
Icon = FontAwesome.fa_osu_left_o
},
}
},
new Container
{
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
RelativeSizeAxes = Axes.Both,
Width = 0.6f,
Children = new Drawable[]
{
rightBox = new Box
{
Colour = OsuColour.Pink,
Origin = Anchor.TopLeft,
Anchor = Anchor.TopLeft,
RelativeSizeAxes = Axes.Both,
Shear = new Vector2(shear, 0),
EdgeSmoothness = new Vector2(1.5f, 0),
},
new SpriteText
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Text = @"Back",
}
}
}
};
} }
public override bool Contains(Vector2 screenSpacePos) => leftBox.Contains(screenSpacePos) || rightBox.Contains(screenSpacePos); public override bool Contains(Vector2 screenSpacePos) => leftBox.Contains(screenSpacePos) || rightBox.Contains(screenSpacePos);
@ -140,9 +91,57 @@ namespace osu.Game.Graphics.UserInterface
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio, OsuColour colours)
{ {
sampleClick = audio.Sample.Get(@"Menu/menuback"); sampleClick = audio.Sample.Get(@"Menu/menuback");
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Width = 0.4f,
Children = new Drawable[]
{
leftBox = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.PinkDark,
Shear = new Vector2(shear, 0),
},
icon = new TextAwesome
{
Anchor = Anchor.Centre,
TextSize = 25,
Icon = FontAwesome.fa_osu_left_o
},
}
},
new Container
{
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
RelativeSizeAxes = Axes.Both,
Width = 0.6f,
Children = new Drawable[]
{
rightBox = new Box
{
Colour = colours.Pink,
Origin = Anchor.TopLeft,
Anchor = Anchor.TopLeft,
RelativeSizeAxes = Axes.Both,
Shear = new Vector2(shear, 0),
EdgeSmoothness = new Vector2(1.5f, 0),
},
new SpriteText
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Text = @"Back",
}
}
}
};
} }
protected override bool OnClick(InputState state) protected override bool OnClick(InputState state)

View File

@ -3,6 +3,7 @@
using System; using System;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
@ -12,7 +13,12 @@ namespace osu.Game.Graphics.UserInterface
public OsuButton() public OsuButton()
{ {
Height = 25; Height = 25;
Colour = OsuColour.BlueDark; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = colours.BlueDark;
} }
} }
} }

View File

@ -13,6 +13,7 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.IO; using osu.Game.Beatmaps.IO;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.Processing; using osu.Game.Graphics.Processing;
using osu.Game.Online.API; using osu.Game.Online.API;
@ -41,6 +42,7 @@ namespace osu.Game
Dependencies.Cache(this); Dependencies.Cache(this);
Dependencies.Cache(Config); Dependencies.Cache(Config);
Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host));
Dependencies.Cache(new OsuColour());
//this completely overrides the framework default. will need to change once we make a proper FontStore. //this completely overrides the framework default. will need to change once we make a proper FontStore.
Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }, true); Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }, true);

View File

@ -65,7 +65,31 @@ namespace osu.Game.Overlays
Origin = Anchor.TopRight; Origin = Anchor.TopRight;
Position = start_position; Position = start_position;
Margin = new MarginPadding(10); Margin = new MarginPadding(10);
}
protected override bool OnDragStart(InputState state) => true;
protected override bool OnDrag(InputState state)
{
Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value);
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
change *= (float)Math.Pow(change.Length, 0.7f) / change.Length;
MoveTo(start_position + change);
return base.OnDrag(state);
}
protected override bool OnDragEnd(InputState state)
{
MoveTo(start_position, 800, EasingTypes.OutElastic);
return base.OnDragEnd(state);
}
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame, BeatmapDatabase beatmaps, AudioManager audio,
TextureStore textures, OsuColour colours)
{
Children = new Drawable[] Children = new Drawable[]
{ {
title = new SpriteText title = new SpriteText
@ -171,34 +195,11 @@ namespace osu.Game.Overlays
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Height = 10, Height = 10,
Colour = OsuColour.Yellow, Colour = colours.Yellow,
SeekRequested = seek SeekRequested = seek
} }
}; };
}
protected override bool OnDragStart(InputState state) => true;
protected override bool OnDrag(InputState state)
{
Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value);
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
change *= (float)Math.Pow(change.Length, 0.7f) / change.Length;
MoveTo(start_position + change);
return base.OnDrag(state);
}
protected override bool OnDragEnd(InputState state)
{
MoveTo(start_position, 800, EasingTypes.OutElastic);
return base.OnDragEnd(state);
}
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame, BeatmapDatabase beatmaps, AudioManager audio, TextureStore textures)
{
this.beatmaps = beatmaps; this.beatmaps = beatmaps;
trackManager = osuGame.Audio.Track; trackManager = osuGame.Audio.Track;
config = osuGame.Config; config = osuGame.Config;

View File

@ -141,6 +141,7 @@ namespace osu.Game.Overlays.Options
private Box fill; private Box fill;
const float border_width = 3; const float border_width = 3;
private Color4 glowingColour, idleColour;
public Light() public Light()
{ {
@ -148,16 +149,6 @@ namespace osu.Game.Overlays.Options
Masking = true; Masking = true;
Colour = OsuColour.Pink;
EdgeEffect = new EdgeEffect
{
Colour = OsuColour.PinkDarker,
Type = EdgeEffectType.Glow,
Radius = 10,
Roundness = 8,
};
CornerRadius = Height / 2; CornerRadius = Height / 2;
Masking = true; Masking = true;
BorderColour = Color4.White; BorderColour = Color4.White;
@ -173,19 +164,33 @@ namespace osu.Game.Overlays.Options
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = idleColour = colours.Pink;
EdgeEffect = new EdgeEffect
{
Colour = glowingColour = colours.PinkDarker,
Type = EdgeEffectType.Glow,
Radius = 10,
Roundness = 8,
};
}
public bool Glowing public bool Glowing
{ {
set set
{ {
if (value) if (value)
{ {
FadeColour(OsuColour.PinkLighter, 500, EasingTypes.OutQuint); FadeColour(glowingColour, 500, EasingTypes.OutQuint);
FadeGlowTo(1, 500, EasingTypes.OutQuint); FadeGlowTo(1, 500, EasingTypes.OutQuint);
} }
else else
{ {
FadeGlowTo(0, 500); FadeGlowTo(0, 500);
FadeColour(OsuColour.Pink, 500); FadeColour(idleColour, 500);
} }
} }
} }

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -131,9 +132,6 @@ namespace osu.Game.Overlays.Options
private class StyledDropDownComboBox : DropDownComboBox private class StyledDropDownComboBox : DropDownComboBox
{ {
protected override Color4 BackgroundColour => Color4.Black.Opacity(0.5f);
protected override Color4 BackgroundColourHover => OsuColour.PinkDarker;
private SpriteText label; private SpriteText label;
protected override string Label protected override string Label
{ {
@ -157,14 +155,17 @@ namespace osu.Game.Overlays.Options
} }
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Black.Opacity(0.5f);
BackgroundColourHover = colours.PinkDarker;
}
} }
private class StyledDropDownMenuItem<U> : DropDownMenuItem<U> private class StyledDropDownMenuItem<U> : DropDownMenuItem<U>
{ {
protected override Color4 BackgroundColour => Color4.Black.Opacity(0.5f);
protected override Color4 BackgroundColourSelected => Color4.Black.Opacity(0.5f);
protected override Color4 BackgroundColourHover => OsuColour.PinkDarker;
public StyledDropDownMenuItem(string text, U value) : base(text, value) public StyledDropDownMenuItem(string text, U value) : base(text, value)
{ {
AutoSizeAxes = Axes.None; AutoSizeAxes = Axes.None;
@ -193,6 +194,14 @@ namespace osu.Game.Overlays.Options
} }
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Black.Opacity(0.5f);
BackgroundColourHover = colours.PinkDarker;
BackgroundColourSelected = Color4.Black.Opacity(0.5f);
}
} }
} }
} }

View File

@ -3,6 +3,7 @@
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
@ -19,14 +20,16 @@ namespace osu.Game.Overlays.Options
public abstract FontAwesome Icon { get; } public abstract FontAwesome Icon { get; }
public abstract string Header { get; } public abstract string Header { get; }
private SpriteText headerLabel;
public OptionsSection() public OptionsSection()
{ {
Margin = new MarginPadding { Top = 20 }; Margin = new MarginPadding { Top = 20 };
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
const int headerSize = 26, headerMargin = 25; const int headerSize = 26, headerMargin = 25;
const int borderSize = 2; const int borderSize = 2;
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
AddInternal(new Drawable[] AddInternal(new Drawable[]
{ {
new Box new Box
@ -48,10 +51,9 @@ namespace osu.Game.Overlays.Options
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Children = new[] Children = new[]
{ {
new SpriteText headerLabel = new SpriteText
{ {
TextSize = headerSize, TextSize = headerSize,
Colour = OsuColour.Pink,
Text = Header, Text = Header,
}, },
content = new FlowContainer content = new FlowContainer
@ -66,5 +68,11 @@ namespace osu.Game.Overlays.Options
}, },
}); });
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
headerLabel.Colour = colours.Pink;
}
} }
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -88,11 +89,16 @@ namespace osu.Game.Overlays.Options
Width = 5, Width = 5,
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Colour = OsuColour.Pink
} }
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
selectionIndicator.Colour = colours.Pink;
}
protected override bool OnClick(InputState state) protected override bool OnClick(InputState state)
{ {
Action?.Invoke(); Action?.Invoke();

View File

@ -17,6 +17,7 @@ using osu.Framework.Graphics.Transformations;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Graphics; using osu.Game.Graphics;
using System.Linq;
namespace osu.Game.Overlays.Options namespace osu.Game.Overlays.Options
{ {
@ -85,7 +86,6 @@ namespace osu.Game.Overlays.Options
RelativeSizeAxes = Axes.None, RelativeSizeAxes = Axes.None,
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Colour = OsuColour.Pink,
}, },
rightBox = new Box rightBox = new Box
{ {
@ -93,7 +93,6 @@ namespace osu.Game.Overlays.Options
RelativeSizeAxes = Axes.None, RelativeSizeAxes = Axes.None,
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Colour = OsuColour.Pink,
Alpha = 0.5f, Alpha = 0.5f,
}, },
nub = new Container nub = new Container
@ -105,13 +104,11 @@ namespace osu.Game.Overlays.Options
AutoSizeAxes = Axes.None, AutoSizeAxes = Axes.None,
RelativeSizeAxes = Axes.None, RelativeSizeAxes = Axes.None,
Masking = true, Masking = true,
BorderColour = OsuColour.Pink,
BorderThickness = 3, BorderThickness = 3,
Children = new[] Children = new[]
{ {
new Box new Box
{ {
Colour = OsuColour.Pink.Opacity(0),
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
} }
} }
@ -120,9 +117,13 @@ namespace osu.Game.Overlays.Options
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio, OsuColour colours)
{ {
sample = audio.Sample.Get(@"Sliderbar/sliderbar"); sample = audio.Sample.Get(@"Sliderbar/sliderbar");
leftBox.Colour = colours.Pink;
rightBox.Colour = colours.Pink;
nub.BorderColour = colours.Pink;
(nub.Children.First() as Box).Colour = colours.Pink.Opacity(0);
} }
private void playSample() private void playSample()

View File

@ -46,6 +46,13 @@ namespace osu.Game.Overlays
private float lastKnownScroll; private float lastKnownScroll;
public OptionsOverlay() public OptionsOverlay()
{
RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
}
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuGame game, OsuColour colours)
{ {
sections = new OptionsSection[] sections = new OptionsSection[]
{ {
@ -59,10 +66,6 @@ namespace osu.Game.Overlays
new OnlineSection(), new OnlineSection(),
new MaintenanceSection(), new MaintenanceSection(),
}; };
RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Box
@ -95,7 +98,7 @@ namespace osu.Game.Overlays
}, },
new SpriteText new SpriteText
{ {
Colour = OsuColour.Pink, Colour = colours.Pink,
Text = "Change the way osu! behaves", Text = "Change the way osu! behaves",
TextSize = 18, TextSize = 18,
Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 }, Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 },
@ -124,11 +127,7 @@ namespace osu.Game.Overlays
).ToArray() ).ToArray()
} }
}; };
}
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuGame game)
{
scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 }; scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 };
} }

View File

@ -81,7 +81,34 @@ namespace osu.Game.Screens.Select
} }
} }
public PlaySongSelect() Player player;
private void start()
{
if (player != null)
return;
//in the future we may want to move this logic to a PlayerLoader gamemode or similar, so we can rely on the SongSelect transition
//and provide a better loading experience (at the moment song select is still accepting input during preload).
player = new Player
{
BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap,
PreferredPlayMode = playMode.Value
};
player.Preload(Game, delegate
{
if (!Push(player))
{
player = null;
//error occured?
}
});
}
[BackgroundDependencyLoader(permitNulls: true)]
private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game,
OsuGame osuGame, OsuColour colours)
{ {
const float carouselWidth = 640; const float carouselWidth = 640;
const float bottomToolHeight = 50; const float bottomToolHeight = 50;
@ -143,42 +170,13 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Width = 100, Width = 100,
Text = "Play", Text = "Play",
Colour = OsuColour.Pink, Colour = colours.Pink,
Action = start Action = start
}, },
} }
} }
}; };
}
Player player;
private void start()
{
if (player != null)
return;
//in the future we may want to move this logic to a PlayerLoader gamemode or similar, so we can rely on the SongSelect transition
//and provide a better loading experience (at the moment song select is still accepting input during preload).
player = new Player
{
BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap,
PreferredPlayMode = playMode.Value
};
player.Preload(Game, delegate
{
if (!Push(player))
{
player = null;
//error occured?
}
});
}
[BackgroundDependencyLoader(permitNulls: true)]
private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game, OsuGame osuGame)
{
if (osuGame != null) if (osuGame != null)
{ {
playMode = osuGame.PlayMode; playMode = osuGame.PlayMode;