1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-29 13:42:54 +08:00

Merge branch 'master'

This commit is contained in:
Huo Yaoyuan 2016-11-03 20:34:58 +08:00
commit f2a8cc0c29
61 changed files with 340 additions and 197 deletions

@ -1 +1 @@
Subproject commit ded26d83913e11b0c5d91977f94cac8a9457643f Subproject commit 92b49515eeae2f6a7c96247b8c3eda97e5514780

View File

@ -34,7 +34,7 @@ namespace osu.Desktop.VisualTests.Tests
private ChannelDisplay channelDisplay; private ChannelDisplay channelDisplay;
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -19,7 +19,7 @@ namespace osu.Desktop.VisualTests.Tests
protected override IFrameBasedClock Clock => ourClock; protected override IFrameBasedClock Clock => ourClock;
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -24,7 +24,7 @@ namespace osu.Desktop.Tests
protected MusicController mc; protected MusicController mc;
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
ourClock = new FramedClock(); ourClock = new FramedClock();

View File

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

View File

@ -55,6 +55,9 @@ namespace osu.Game.Tests.Beatmaps.IO
var osu = new OsuGameBase(); var osu = new OsuGameBase();
host.Add(osu); host.Add(osu);
while (!osu.IsLoaded)
Thread.Sleep(1);
//reset beatmap database (sqlite and storage backing) //reset beatmap database (sqlite and storage backing)
osu.Beatmaps.Reset(); osu.Beatmaps.Reset();

View File

@ -33,7 +33,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="nunit.framework"> <Reference Include="nunit.framework">
<HintPath>$(SolutionDir)\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath> <HintPath>$(SolutionDir)\packages\NUnit.3.5.0\lib\nunit.framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL"> <Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\ppy.OpenTK.2.0.50727.1339\lib\net45\OpenTK.dll</HintPath> <HintPath>$(SolutionDir)\packages\ppy.OpenTK.2.0.50727.1339\lib\net45\OpenTK.dll</HintPath>

View File

@ -4,7 +4,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework; using osu.Framework;
using osu.Framework.Extensions.IEnumerableExtensions;
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;
@ -28,7 +31,7 @@ namespace osu.Game.Beatmaps.Drawable
private BeatmapGroupState state; private BeatmapGroupState state;
public IEnumerable<BeatmapPanel> BeatmapPanels; public List<BeatmapPanel> BeatmapPanels;
public BeatmapGroupState State public BeatmapGroupState State
{ {
@ -40,12 +43,13 @@ namespace osu.Game.Beatmaps.Drawable
{ {
case BeatmapGroupState.Expanded: case BeatmapGroupState.Expanded:
FadeTo(1, 250); FadeTo(1, 250);
//if (!difficulties.Children.All(d => IsLoaded))
// Task.WhenAll(difficulties.Children.Select(d => d.Preload(Game))).ContinueWith(t => difficulties.Show());
//else
difficulties.Show(); difficulties.Show();
header.State = PanelSelectedState.Selected; header.State = PanelSelectedState.Selected;
if (SelectedPanel == null)
((BeatmapPanel)difficulties.Children.FirstOrDefault()).State = PanelSelectedState.Selected;
break; break;
case BeatmapGroupState.Collapsed: case BeatmapGroupState.Collapsed:
FadeTo(0.5f, 250); FadeTo(0.5f, 250);
@ -65,16 +69,6 @@ namespace osu.Game.Beatmaps.Drawable
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
BeatmapPanels = beatmapSet.Beatmaps.Select(b =>
new BeatmapPanel(this.beatmapSet, b)
{
GainedSelection = panelGainedSelection,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.X,
});
Children = new[] Children = new[]
{ {
new FlowContainer new FlowContainer
@ -99,35 +93,55 @@ namespace osu.Game.Beatmaps.Drawable
Padding = new MarginPadding { Left = 75 }, Padding = new MarginPadding { Left = 75 },
Spacing = new Vector2(0, 5), Spacing = new Vector2(0, 5),
Direction = FlowDirection.VerticalOnly, Direction = FlowDirection.VerticalOnly,
Alpha = 0,
Children = BeatmapPanels
} }
} }
} }
}; };
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
State = BeatmapGroupState.Collapsed;
BeatmapPanels = beatmapSet.Beatmaps.Select(b => new BeatmapPanel(b)
{
GainedSelection = panelGainedSelection,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.X,
}).ToList();
//for the time being, let's completely load the difficulty panels in the background.
//this likely won't scale so well, but allows us to completely async the loading flow.
Task.WhenAll(BeatmapPanels.Select(panel => panel.Preload(game, p => difficulties.Add(panel)))).Wait();
} }
private void headerGainedSelection(BeatmapSetHeader panel) private void headerGainedSelection(BeatmapSetHeader panel)
{ {
State = BeatmapGroupState.Expanded; State = BeatmapGroupState.Expanded;
SelectionChanged?.Invoke(this, SelectedPanel.Beatmap); //we want to make sure one of our children is selected in the case none have been selected yet.
if (SelectedPanel == null)
BeatmapPanels.First().State = PanelSelectedState.Selected;
else
SelectionChanged?.Invoke(this, SelectedPanel.Beatmap);
} }
private void panelGainedSelection(BeatmapPanel panel) private void panelGainedSelection(BeatmapPanel panel)
{ {
State = BeatmapGroupState.Expanded; try
{
if (SelectedPanel == panel) return;
if (SelectedPanel != null) SelectedPanel.State = PanelSelectedState.NotSelected; if (SelectedPanel != null)
SelectedPanel = panel; SelectedPanel.State = PanelSelectedState.NotSelected;
SelectedPanel = panel;
SelectionChanged?.Invoke(this, panel.Beatmap); }
finally
{
State = BeatmapGroupState.Expanded;
SelectionChanged?.Invoke(this, panel.Beatmap);
}
} }
} }

View File

@ -26,7 +26,7 @@ namespace osu.Game.Beatmaps.Drawable
GainedSelection?.Invoke(this); GainedSelection?.Invoke(this);
} }
public BeatmapPanel(BeatmapSetInfo set, BeatmapInfo beatmap) public BeatmapPanel(BeatmapInfo beatmap)
{ {
Beatmap = beatmap; Beatmap = beatmap;
Height *= 0.75f; Height *= 0.75f;
@ -67,7 +67,7 @@ namespace osu.Game.Beatmaps.Drawable
}, },
new SpriteText new SpriteText
{ {
Text = $" mapped by {(beatmap.Metadata ?? set.Metadata).Author}", Text = $" mapped by {(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author}",
TextSize = 16, TextSize = 16,
}, },
} }

View File

@ -23,7 +23,6 @@ namespace osu.Game.Beatmaps.Drawable
Masking = true; Masking = true;
CornerRadius = 10; CornerRadius = 10;
BorderColour = new Color4(221, 255, 255, 0); BorderColour = new Color4(221, 255, 255, 0);
GlowColour = new Color4(102, 204, 255, 100);
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
} }
@ -37,7 +36,6 @@ namespace osu.Game.Beatmaps.Drawable
set set
{ {
if (state == value) return; if (state == value) return;
state = value; state = value;
switch (state) switch (state)
@ -54,16 +52,24 @@ namespace osu.Game.Beatmaps.Drawable
protected virtual void Selected() protected virtual void Selected()
{ {
BorderColour = new Color4(BorderColour.R, BorderColour.G, BorderColour.B, 255); BorderColour = new Color4(BorderColour.R, BorderColour.G, BorderColour.B, 1f);
GlowRadius = 10;
BorderThickness = 2.5f; BorderThickness = 2.5f;
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Glow,
Colour = new Color4(130, 204, 255, 150),
Radius = 20,
Roundness = 10,
};
} }
protected virtual void Deselected() protected virtual void Deselected()
{ {
BorderColour = new Color4(BorderColour.R, BorderColour.G, BorderColour.B, 0); BorderColour = new Color4(BorderColour.R, BorderColour.G, BorderColour.B, 0);
GlowRadius = 0;
BorderThickness = 0; BorderThickness = 0;
EdgeEffect = new EdgeEffect { Type = EdgeEffectType.None };
} }
protected override bool OnClick(InputState state) protected override bool OnClick(InputState state)

View File

@ -28,7 +28,7 @@ namespace osu.Game.Beatmaps.Objects.Catch.Drawable
Position = new Vector2(h.Position, -0.1f); Position = new Vector2(h.Position, -0.1f);
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -37,10 +37,9 @@ namespace osu.Game.Beatmaps.Objects
} }
} }
public override void Load(BaseGame game) protected override void LoadComplete()
{ {
base.Load(game); base.LoadComplete();
UpdateState(state); UpdateState(state);
} }

View File

@ -20,7 +20,7 @@ namespace osu.Game.Beatmaps.Objects.Mania.Drawable
Scale = new Vector2(0.1f); Scale = new Vector2(0.1f);
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
Texture = game.Textures.Get(@"Menu/logo"); Texture = game.Textures.Get(@"Menu/logo");

View File

@ -64,7 +64,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
Size = new Vector2(100); Size = new Vector2(100);
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
@ -131,7 +131,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
}; };
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
number.Texture = game.Textures.Get(@"Play/osu/number@2x"); number.Texture = game.Textures.Get(@"Play/osu/number@2x");
@ -159,7 +159,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
}; };
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
layer3.Texture = game.Textures.Get(@"Play/osu/ring-glow@2x"); layer3.Texture = game.Textures.Get(@"Play/osu/ring-glow@2x");
@ -185,7 +185,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
}; };
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
ring.Texture = game.Textures.Get(@"Play/osu/ring@2x"); ring.Texture = game.Textures.Get(@"Play/osu/ring@2x");
@ -241,7 +241,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
{ {
private Texture tex; private Texture tex;
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
@ -302,7 +302,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
}; };
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
disc.Texture = game.Textures.Get(@"Play/osu/disc@2x"); disc.Texture = game.Textures.Get(@"Play/osu/disc@2x");
@ -318,7 +318,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
{ {
private Texture tex; private Texture tex;
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -23,7 +23,7 @@ namespace osu.Game.Beatmaps.Objects.Taiko.Drawable
Position = new Vector2(1.1f, 0.5f); Position = new Vector2(1.1f, 0.5f);
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps
{ {
public class WorkingBeatmap : IDisposable public class WorkingBeatmap : IDisposable
{ {
private BeatmapInfo beatmapInfo; public BeatmapInfo BeatmapInfo;
public readonly ArchiveReader Reader; public readonly ArchiveReader Reader;
@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps
try try
{ {
using (var stream = new StreamReader(Reader.ReadFile(beatmapInfo.Path))) using (var stream = new StreamReader(Reader.ReadFile(BeatmapInfo.Path)))
beatmap = BeatmapDecoder.GetDecoder(stream)?.Decode(stream); beatmap = BeatmapDecoder.GetDecoder(stream)?.Decode(stream);
} }
catch { } catch { }
@ -44,7 +44,7 @@ namespace osu.Game.Beatmaps
try try
{ {
var trackData = Reader.ReadFile(beatmapInfo.Metadata.AudioFile); var trackData = Reader.ReadFile(BeatmapInfo.Metadata.AudioFile);
if (trackData != null) if (trackData != null)
track = new AudioTrackBass(trackData); track = new AudioTrackBass(trackData);
} }
@ -57,7 +57,7 @@ namespace osu.Game.Beatmaps
public WorkingBeatmap(BeatmapInfo beatmapInfo = null, ArchiveReader reader = null) public WorkingBeatmap(BeatmapInfo beatmapInfo = null, ArchiveReader reader = null)
{ {
this.beatmapInfo = beatmapInfo; this.BeatmapInfo = beatmapInfo;
Reader = reader; Reader = reader;
} }
@ -80,7 +80,7 @@ namespace osu.Game.Beatmaps
public void TransferTo(WorkingBeatmap working) public void TransferTo(WorkingBeatmap working)
{ {
if (track != null && working.beatmapInfo.Metadata.AudioFile == beatmapInfo.Metadata.AudioFile && working.beatmapInfo.BeatmapSet.Path == beatmapInfo.BeatmapSet.Path) if (track != null && working.BeatmapInfo.Metadata.AudioFile == BeatmapInfo.Metadata.AudioFile && working.BeatmapInfo.BeatmapSet.Path == BeatmapInfo.BeatmapSet.Path)
working.track = track; working.track = track;
} }
} }

View File

@ -128,6 +128,9 @@ namespace osu.Game.Database
public ArchiveReader GetReader(BeatmapSetInfo beatmapSet) public ArchiveReader GetReader(BeatmapSetInfo beatmapSet)
{ {
if (string.IsNullOrEmpty(beatmapSet.Path))
return null;
return ArchiveReader.GetReader(storage, beatmapSet.Path); return ArchiveReader.GetReader(storage, beatmapSet.Path);
} }

View File

@ -12,6 +12,7 @@ using OpenTK;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework; using osu.Framework;
using System.Threading;
namespace osu.Game.GameModes namespace osu.Game.GameModes
{ {
@ -31,11 +32,32 @@ namespace osu.Game.GameModes
return false; return false;
} }
public override void Load(BaseGame game) BaseGame game;
protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
this.game = game;
}
Content.Scale *= 1 + (x_movement_amount / DrawSize.X) * 2; public override bool Push(GameMode mode)
{
//don't actually push until we've finished loading.
if (!mode.IsLoaded)
{
mode.Preload(game, d => Push((BackgroundMode)d));
return true;
}
base.Push(mode);
return true;
}
protected override void Update()
{
base.Update();
Content.Scale = new Vector2(1 + (x_movement_amount / DrawSize.X) * 2);
} }
protected override void OnEntering(GameMode last) protected override void OnEntering(GameMode last)

View File

@ -15,7 +15,7 @@ namespace osu.Game.GameModes.Backgrounds
this.textureName = textureName; this.textureName = textureName;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
Add(new Background(textureName)); Add(new Background(textureName));

View File

@ -8,7 +8,7 @@ namespace osu.Game.GameModes.Backgrounds
{ {
public class BackgroundModeDefault : BackgroundMode public class BackgroundModeDefault : BackgroundMode
{ {
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -19,12 +19,12 @@ namespace osu.Game.GameModes.Edit
protected override void OnEntering(GameMode last) protected override void OnEntering(GameMode last)
{ {
base.OnEntering(last); base.OnEntering(last);
Background.FadeColour(Color4.DarkGray, 500); Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500));
} }
protected override bool OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
Background.FadeColour(Color4.White, 500); Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next); return base.OnExiting(next);
} }
} }

View File

@ -77,7 +77,7 @@ namespace osu.Game.GameModes
Content.FadeIn(transition_time, EasingTypes.OutExpo); Content.FadeIn(transition_time, EasingTypes.OutExpo);
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -48,7 +48,7 @@ namespace osu.Game.GameModes.Menu
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
Alpha = 0; Alpha = 0;
@ -128,7 +128,7 @@ namespace osu.Game.GameModes.Menu
LoopDelay = duration * 2 LoopDelay = duration * 2
}); });
icon.Transforms.Add(new TransformPosition() icon.Transforms.Add(new TransformPosition
{ {
StartValue = Vector2.Zero, StartValue = Vector2.Zero,
EndValue = new Vector2(0, -10), EndValue = new Vector2(0, -10),
@ -139,7 +139,7 @@ namespace osu.Game.GameModes.Menu
LoopDelay = duration LoopDelay = duration
}); });
icon.Transforms.Add(new TransformScale() icon.Transforms.Add(new TransformScale
{ {
StartValue = new Vector2(1, 0.9f), StartValue = new Vector2(1, 0.9f),
EndValue = Vector2.One, EndValue = Vector2.One,
@ -150,7 +150,7 @@ namespace osu.Game.GameModes.Menu
LoopDelay = duration LoopDelay = duration
}); });
icon.Transforms.Add(new TransformPosition() icon.Transforms.Add(new TransformPosition
{ {
StartValue = new Vector2(0, -10), StartValue = new Vector2(0, -10),
EndValue = Vector2.Zero, EndValue = Vector2.Zero,
@ -161,7 +161,7 @@ namespace osu.Game.GameModes.Menu
LoopDelay = duration LoopDelay = duration
}); });
icon.Transforms.Add(new TransformScale() icon.Transforms.Add(new TransformScale
{ {
StartValue = Vector2.One, StartValue = Vector2.One,
EndValue = new Vector2(1, 0.9f), EndValue = new Vector2(1, 0.9f),

View File

@ -53,7 +53,7 @@ namespace osu.Game.GameModes.Menu
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -1,7 +1,7 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System.Threading;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.GameModes; using osu.Framework.GameModes;
@ -10,8 +10,6 @@ using osu.Framework.Graphics.Transformations;
using osu.Game.GameModes.Backgrounds; using osu.Game.GameModes.Backgrounds;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework; using osu.Framework;
using osu.Framework.Configuration;
using osu.Game.Beatmaps;
namespace osu.Game.GameModes.Menu namespace osu.Game.GameModes.Menu
{ {
@ -24,12 +22,14 @@ namespace osu.Game.GameModes.Menu
/// </summary> /// </summary>
internal bool DidLoadMenu; internal bool DidLoadMenu;
MainMenu mainMenu;
private AudioSample welcome;
private AudioTrack bgm;
protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty(); protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty();
public override void Load(BaseGame game) public Intro()
{ {
base.Load(game);
Children = new Drawable[] Children = new Drawable[]
{ {
logo = new OsuLogo() logo = new OsuLogo()
@ -41,32 +41,45 @@ namespace osu.Game.GameModes.Menu
Ripple = false Ripple = false
} }
}; };
}
AudioSample welcome = game.Audio.Sample.Get(@"welcome"); protected override void Load(BaseGame game)
{
base.Load(game);
AudioTrack bgm = game.Audio.Track.Get(@"circles"); welcome = game.Audio.Sample.Get(@"welcome");
bgm = game.Audio.Track.Get(@"circles");
bgm.Looping = true; bgm.Looping = true;
}
protected override void LoadComplete()
{
base.LoadComplete();
Scheduler.Add(delegate Scheduler.Add(delegate
{ {
welcome.Play(); welcome.Play();
Scheduler.AddDelayed(delegate
{
bgm.Start();
mainMenu = new MainMenu();
mainMenu.Preload(Game);
Scheduler.AddDelayed(delegate
{
DidLoadMenu = true;
Push(mainMenu);
}, 2300);
}, 600);
}); });
Scheduler.AddDelayed(delegate logo.ScaleTo(0.4f);
{ logo.FadeOut();
bgm.Start();
}, 600);
Scheduler.AddDelayed(delegate logo.ScaleTo(1, 4400, EasingTypes.OutQuint);
{ logo.FadeIn(20000, EasingTypes.OutQuint);
DidLoadMenu = true;
Push(new MainMenu());
}, 2900);
logo.ScaleTo(0);
logo.ScaleTo(1, 5900, EasingTypes.OutQuint);
logo.FadeIn(30000, EasingTypes.OutQuint);
} }
protected override void OnSuspending(GameMode next) protected override void OnSuspending(GameMode next)

View File

@ -1,6 +1,7 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.GameModes; using osu.Framework.GameModes;
using osu.Framework.GameModes.Testing; using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -15,6 +16,7 @@ using osu.Game.Graphics.Containers;
using OpenTK; using OpenTK;
using osu.Framework; using osu.Framework;
using osu.Game.Overlays; using osu.Game.Overlays;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Menu namespace osu.Game.GameModes.Menu
{ {
@ -23,13 +25,13 @@ namespace osu.Game.GameModes.Menu
private ButtonSystem buttons; private ButtonSystem buttons;
public override string Name => @"Main Menu"; public override string Name => @"Main Menu";
protected override BackgroundMode CreateBackground() => new BackgroundModeDefault(); private BackgroundMode background;
public override void Load(BaseGame game) protected override BackgroundMode CreateBackground() => background;
public MainMenu()
{ {
base.Load(game); background = new BackgroundModeDefault();
OsuGame osu = (OsuGame)game;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -40,7 +42,6 @@ namespace osu.Game.GameModes.Menu
{ {
buttons = new ButtonSystem() buttons = new ButtonSystem()
{ {
Alpha = 0,
OnChart = delegate { Push(new ChartListing()); }, OnChart = delegate { Push(new ChartListing()); },
OnDirect = delegate { Push(new OnlineListing()); }, OnDirect = delegate { Push(new OnlineListing()); },
OnEdit = delegate { Push(new EditSongSelect()); }, OnEdit = delegate { Push(new EditSongSelect()); },
@ -48,13 +49,26 @@ namespace osu.Game.GameModes.Menu
OnMulti = delegate { Push(new Lobby()); }, OnMulti = delegate { Push(new Lobby()); },
OnTest = delegate { Push(new TestBrowser()); }, OnTest = delegate { Push(new TestBrowser()); },
OnExit = delegate { Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); }, OnExit = delegate { Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); },
OnSettings = osu.Options.ToggleVisibility,
} }
} }
} }
}; };
}
buttons.FadeIn(500); protected override void Load(BaseGame game)
{
base.Load(game);
background.Preload(game);
OsuGame osu = (OsuGame)game;
buttons.OnSettings = osu.Options.ToggleVisibility;
}
protected override void LoadComplete()
{
base.LoadComplete();
buttons.FadeInFromZero(500);
} }
protected override void OnSuspending(GameMode next) protected override void OnSuspending(GameMode next)

View File

@ -101,12 +101,16 @@ namespace osu.Game.GameModes.Menu
}; };
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
logo.Texture = game.Textures.Get(@"Menu/logo"); logo.Texture = game.Textures.Get(@"Menu/logo");
ripple.Texture = game.Textures.Get(@"Menu/logo"); ripple.Texture = game.Textures.Get(@"Menu/logo");
}
protected override void LoadComplete()
{
base.LoadComplete();
ripple.ScaleTo(1.1f, 500); ripple.ScaleTo(1.1f, 500);
ripple.FadeOut(500); ripple.FadeOut(500);

View File

@ -25,12 +25,13 @@ namespace osu.Game.GameModes.Multiplayer
protected override void OnEntering(GameMode last) protected override void OnEntering(GameMode last)
{ {
base.OnEntering(last); base.OnEntering(last);
Background.FadeColour(Color4.DarkGray, 500);
Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500));
} }
protected override bool OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
Background.FadeColour(Color4.White, 500); Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next); return base.OnExiting(next);
} }
} }

View File

@ -69,7 +69,7 @@ namespace osu.Game.GameModes
OnBeatmapChanged(beatmap.Value); OnBeatmapChanged(beatmap.Value);
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
beatmap = (game as OsuGameBase)?.Beatmap; beatmap = (game as OsuGameBase)?.Beatmap;

View File

@ -19,7 +19,7 @@ namespace osu.Game.GameModes.Play.Catch
protected override bool CanPopOutWhileRolling => true; protected override bool CanPopOutWhileRolling => true;
protected virtual double FadeOutDelay => 1000; protected virtual double FadeOutDelay => 1000;
protected virtual double FadeOutDuration => 300; protected override double FadeOutDuration => 300;
protected override string FormatCount(ulong count) protected override string FormatCount(ulong count)
{ {

View File

@ -20,7 +20,7 @@ namespace osu.Game.GameModes.Play.Catch
Origin = Anchor.BottomCentre; Origin = Anchor.BottomCentre;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -31,6 +31,8 @@ namespace osu.Game.GameModes.Play
protected virtual EasingTypes PopOutEasing => EasingTypes.None; protected virtual EasingTypes PopOutEasing => EasingTypes.None;
protected virtual float PopOutInitialAlpha => 0.75f; protected virtual float PopOutInitialAlpha => 0.75f;
protected virtual double FadeOutDuration => 100;
/// <summary> /// <summary>
/// Duration in milliseconds for the counter roll-up animation for each element. /// Duration in milliseconds for the counter roll-up animation for each element.
/// </summary> /// </summary>
@ -60,7 +62,6 @@ namespace osu.Game.GameModes.Play
} }
} }
protected ulong prevCount;
protected ulong count; protected ulong count;
/// <summary> /// <summary>
@ -119,7 +120,7 @@ namespace osu.Game.GameModes.Play
TextSize = 80; TextSize = 80;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
@ -204,7 +205,7 @@ namespace osu.Game.GameModes.Play
private void updateCount(ulong value, bool rolling = false) private void updateCount(ulong value, bool rolling = false)
{ {
prevCount = count; ulong prevCount = count;
count = value; count = value;
if (!rolling) if (!rolling)
{ {

View File

@ -39,7 +39,7 @@ namespace osu.Game.GameModes.Play
protected virtual List<T> Convert(List<HitObject> objects) => Converter.Convert(objects); protected virtual List<T> Convert(List<HitObject> objects) => Converter.Convert(objects);
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -31,7 +31,7 @@ namespace osu.Game.GameModes.Play.Mania
protected override float PopOutInitialAlpha => 1.0f; protected override float PopOutInitialAlpha => 1.0f;
protected override double PopOutDuration => 300; protected override double PopOutDuration => 300;
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -23,7 +23,7 @@ namespace osu.Game.GameModes.Play.Mania
Origin = Anchor.BottomCentre; Origin = Anchor.BottomCentre;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -19,12 +19,12 @@ namespace osu.Game.GameModes.Play
protected override void OnEntering(GameMode last) protected override void OnEntering(GameMode last)
{ {
base.OnEntering(last); base.OnEntering(last);
Background.FadeColour(Color4.DarkGray, 500); Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500));
} }
protected override bool OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
Background.FadeColour(Color4.White, 500); Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next); return base.OnExiting(next);
} }
} }

View File

@ -33,7 +33,7 @@ namespace osu.Game.GameModes.Play.Osu
} }
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
@ -92,6 +92,11 @@ namespace osu.Game.GameModes.Play.Osu
protected override void OnCountRolling(ulong currentValue, ulong newValue) protected override void OnCountRolling(ulong currentValue, ulong newValue)
{ {
ScheduledPopOutCurrentId++; ScheduledPopOutCurrentId++;
// Hides displayed count if was increasing from 0 to 1 but didn't finish
if (currentValue == 0 && newValue == 0)
DisplayedCountSpriteText.FadeOut(FadeOutDuration);
base.OnCountRolling(currentValue, newValue); base.OnCountRolling(currentValue, newValue);
} }
@ -116,13 +121,17 @@ namespace osu.Game.GameModes.Play.Osu
protected override void OnCountChange(ulong currentValue, ulong newValue) protected override void OnCountChange(ulong currentValue, ulong newValue)
{ {
ScheduledPopOutCurrentId++; ScheduledPopOutCurrentId++;
if (newValue == 0)
DisplayedCountSpriteText.FadeOut();
base.OnCountChange(currentValue, newValue); base.OnCountChange(currentValue, newValue);
} }
protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue) protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue)
{ {
if (newValue == 0) if (newValue == 0)
DisplayedCountSpriteText.FadeOut(PopOutDuration); DisplayedCountSpriteText.FadeOut(FadeOutDuration);
else else
DisplayedCountSpriteText.Show(); DisplayedCountSpriteText.Show();

View File

@ -20,7 +20,7 @@ namespace osu.Game.GameModes.Play.Osu
Origin = Anchor.Centre; Origin = Anchor.Centre;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -35,6 +35,7 @@ namespace osu.Game.GameModes.Play
private ScrollContainer scrollContainer; private ScrollContainer scrollContainer;
private FlowContainer beatmapSetFlow; private FlowContainer beatmapSetFlow;
private TrackManager trackManager; private TrackManager trackManager;
private Container wedgeContainer;
/// <param name="database">Optionally provide a database to use instead of the OsuGame one.</param> /// <param name="database">Optionally provide a database to use instead of the OsuGame one.</param>
public PlaySongSelect(BeatmapDatabase database = null) public PlaySongSelect(BeatmapDatabase database = null)
@ -45,7 +46,7 @@ namespace osu.Game.GameModes.Play
const float bottomToolHeight = 50; const float bottomToolHeight = 50;
Children = new Drawable[] Children = new Drawable[]
{ {
new Container wedgeContainer = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Size = Vector2.One, Size = Vector2.One,
@ -120,7 +121,7 @@ namespace osu.Game.GameModes.Play
}; };
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
@ -147,6 +148,7 @@ namespace osu.Game.GameModes.Play
{ {
base.OnEntering(last); base.OnEntering(last);
ensurePlayingSelected(); ensurePlayingSelected();
wedgeContainer.FadeInFromZero(250);
} }
protected override void OnResuming(GameMode last) protected override void OnResuming(GameMode last)
@ -166,10 +168,13 @@ namespace osu.Game.GameModes.Play
{ {
} }
/// <summary>
/// The global Beatmap was changed.
/// </summary>
protected override void OnBeatmapChanged(WorkingBeatmap beatmap) protected override void OnBeatmapChanged(WorkingBeatmap beatmap)
{ {
base.OnBeatmapChanged(beatmap); base.OnBeatmapChanged(beatmap);
selectBeatmap(beatmap.Beatmap.BeatmapInfo); selectBeatmap(beatmap.BeatmapInfo);
} }
private void selectBeatmap(BeatmapInfo beatmap) private void selectBeatmap(BeatmapInfo beatmap)
@ -177,11 +182,17 @@ namespace osu.Game.GameModes.Play
if (beatmap.Equals(selectedBeatmapInfo)) if (beatmap.Equals(selectedBeatmapInfo))
return; return;
beatmapSetFlow.Children.Cast<BeatmapGroup>().First(b => //this is VERY temporary logic.
beatmapSetFlow.Children.Cast<BeatmapGroup>().Any(b =>
{ {
var panel = b.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap)); var panel = b.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
panel?.TriggerClick(); if (panel != null)
return panel != null; {
panel.State = PanelSelectedState.Selected;
return true;
}
return false;
}); });
} }
@ -192,7 +203,7 @@ namespace osu.Game.GameModes.Play
{ {
selectedBeatmapInfo = beatmap; selectedBeatmapInfo = beatmap;
if (!beatmap.Equals(Beatmap?.Beatmap?.BeatmapInfo)) if (!beatmap.Equals(Beatmap?.BeatmapInfo))
{ {
Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap); Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap);
} }
@ -208,15 +219,20 @@ namespace osu.Game.GameModes.Play
selectedBeatmapGroup = group; selectedBeatmapGroup = group;
} }
private void ensurePlayingSelected() private async Task ensurePlayingSelected()
{ {
var track = Beatmap?.Track; AudioTrack track = null;
if (track != null) await Task.Run(() => track = Beatmap?.Track);
Schedule(delegate
{ {
trackManager.SetExclusive(track); if (track != null)
track.Start(); {
} trackManager.SetExclusive(track);
track.Start();
}
});
} }
private void addBeatmapSet(BeatmapSetInfo beatmapSet) private void addBeatmapSet(BeatmapSetInfo beatmapSet)
@ -224,12 +240,34 @@ namespace osu.Game.GameModes.Play
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID); beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
beatmapSet.Beatmaps.ForEach(b => database.GetChildren(b)); beatmapSet.Beatmaps.ForEach(b => database.GetChildren(b));
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList(); beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList();
Schedule(() => var group = new BeatmapGroup(beatmapSet) { SelectionChanged = selectionChanged };
group.Preload(Game, g =>
{ {
var group = new BeatmapGroup(beatmapSet) { SelectionChanged = selectionChanged };
beatmapSetFlow.Add(group); beatmapSetFlow.Add(group);
if (beatmapSetFlow.Children.Count() == 1)
group.State = BeatmapGroupState.Expanded; if (Beatmap == null)
{
if (beatmapSetFlow.Children.Count() == 1)
{
group.State = BeatmapGroupState.Expanded;
return;
}
}
else
{
if (selectedBeatmapInfo?.Equals(Beatmap.BeatmapInfo) != true)
{
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(Beatmap.BeatmapInfo));
if (panel != null)
{
panel.State = PanelSelectedState.Selected;
return;
}
}
}
group.State = BeatmapGroupState.Collapsed;
}); });
} }

View File

@ -30,18 +30,7 @@ namespace osu.Game.GameModes.Play
private InterpolatingFramedClock playerClock; private InterpolatingFramedClock playerClock;
private IAdjustableClock sourceClock; private IAdjustableClock sourceClock;
protected override bool OnExiting(GameMode next) protected override void Load(BaseGame game)
{
if (next == null)
{
//eagerly dispose as the finalizer runs too late right now.
Beatmap?.Dispose();
}
return base.OnExiting(next);
}
public override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -43,7 +43,7 @@ namespace osu.Game.GameModes.Play.Taiko
protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue) protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue)
{ {
if (newValue == 0) if (newValue == 0)
DisplayedCountSpriteText.FadeOut(AnimationDuration); DisplayedCountSpriteText.FadeOut(FadeOutDuration);
else else
DisplayedCountSpriteText.Show(); DisplayedCountSpriteText.Show();

View File

@ -20,7 +20,7 @@ namespace osu.Game.GameModes.Play.Taiko
Origin = Anchor.Centre; Origin = Anchor.Centre;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -14,12 +14,12 @@ namespace osu.Game.GameModes.Ranking
protected override void OnEntering(GameMode last) protected override void OnEntering(GameMode last)
{ {
base.OnEntering(last); base.OnEntering(last);
Background.FadeColour(Color4.DarkGray, 500); Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500));
} }
protected override bool OnExiting(GameMode next) protected override bool OnExiting(GameMode next)
{ {
Background.FadeColour(Color4.White, 500); Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next); return base.OnExiting(next);
} }
} }

View File

@ -9,6 +9,8 @@ using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework; using osu.Framework;
using System.Threading.Tasks;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Graphics.Background namespace osu.Game.Graphics.Background
{ {
@ -25,7 +27,9 @@ namespace osu.Game.Graphics.Background
Depth = float.MinValue; Depth = float.MinValue;
} }
public override void Load(BaseGame game) Texture texture;
protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -27,7 +27,7 @@ namespace osu.Game.Graphics.Containers
protected override Container Content => content; protected override Container Content => content;
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
} }

View File

@ -37,7 +37,7 @@ namespace osu.Game.Graphics.Cursor
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -59,7 +59,7 @@ namespace osu.Game.Graphics.UserInterface
Name = name; Name = name;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
Children = new Drawable[] Children = new Drawable[]

View File

@ -119,7 +119,7 @@ namespace osu.Game.Graphics.UserInterface
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -107,7 +107,7 @@ namespace osu.Game.Graphics.UserInterface
}; };
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
@ -131,7 +131,11 @@ namespace osu.Game.Graphics.UserInterface
stars.Add(star); stars.Add(star);
starContainer.Add(star); starContainer.Add(star);
} }
}
protected override void LoadComplete()
{
base.LoadComplete();
// Animate initial state from zero. // Animate initial state from zero.
transformCount(0, Count); transformCount(0, Count);
} }

View File

@ -32,7 +32,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
Origin = Anchor.BottomRight; Origin = Anchor.BottomRight;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
VolumeGlobal.ValueChanged += volumeChanged; VolumeGlobal.ValueChanged += volumeChanged;
VolumeSample.ValueChanged += volumeChanged; VolumeSample.ValueChanged += volumeChanged;

View File

@ -57,7 +57,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
}; };
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
updateFill(); updateFill();

View File

@ -59,7 +59,7 @@ namespace osu.Game.Online.Chat.Display
channel.NewMessagesArrived -= newMessages; channel.NewMessagesArrived -= newMessages;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
newMessages(channel.Messages); newMessages(channel.Messages);

View File

@ -27,7 +27,7 @@ namespace osu.Game.Online.Chat.Display
const float padding = 200; const float padding = 200;
const float text_size = 20; const float text_size = 20;
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -2,6 +2,7 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Threading;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.GameModes; using osu.Framework.GameModes;
using osu.Game.Configuration; using osu.Game.Configuration;
@ -47,7 +48,7 @@ namespace osu.Game
host.Size = new Vector2(Config.Get<int>(OsuConfig.Width), Config.Get<int>(OsuConfig.Height)); host.Size = new Vector2(Config.Get<int>(OsuConfig.Width), Config.Get<int>(OsuConfig.Height));
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
if (!Host.IsPrimaryInstance) if (!Host.IsPrimaryInstance)
{ {
@ -65,25 +66,18 @@ namespace osu.Game
Audio.VolumeSample.Weld(Config.GetBindable<double>(OsuConfig.VolumeEffect)); Audio.VolumeSample.Weld(Config.GetBindable<double>(OsuConfig.VolumeEffect));
Audio.VolumeTrack.Weld(Config.GetBindable<double>(OsuConfig.VolumeMusic)); Audio.VolumeTrack.Weld(Config.GetBindable<double>(OsuConfig.VolumeMusic));
PlayMode = Config.GetBindable<PlayMode>(OsuConfig.PlayMode);
Add(new Drawable[] { Add(new Drawable[] {
new VolumeControlReceptor new VolumeControlReceptor
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ActivateRequested = delegate { volume.Show(); } ActivateRequested = delegate { volume.Show(); }
}, },
intro = new Intro mainContent = new Container
{ {
Beatmap = Beatmap RelativeSizeAxes = Axes.Both,
}, },
MusicController = new MusicController(),
Toolbar = new Toolbar
{
OnHome = delegate { MainMenu?.MakeCurrent(); },
OnSettings = Options.ToggleVisibility,
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
OnMusicController = MusicController.ToggleVisibility,
},
Chat = new ChatConsole(API),
volume = new VolumeControl volume = new VolumeControl
{ {
VolumeGlobal = Audio.Volume, VolumeGlobal = Audio.Volume,
@ -96,12 +90,31 @@ namespace osu.Game
} }
}); });
intro.ModePushed += modeAdded; (intro = new Intro
intro.Exited += modeRemoved; {
Beatmap = Beatmap
}).Preload(game, d =>
{
mainContent.Add(d);
PlayMode = Config.GetBindable<PlayMode>(OsuConfig.PlayMode); intro.ModePushed += modeAdded;
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); }; intro.Exited += modeRemoved;
PlayMode.TriggerChange(); intro.DisplayAsRoot();
});
(Chat = new ChatConsole(API)).Preload(game, Add);
(Toolbar = new Toolbar
{
OnHome = delegate { MainMenu?.MakeCurrent(); },
OnSettings = Options.ToggleVisibility,
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
}).Preload(game, t =>
{
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
PlayMode.TriggerChange();
Add(Toolbar);
});
Cursor.Alpha = 0; Cursor.Alpha = 0;
} }
@ -120,6 +133,8 @@ namespace osu.Game
public Action<GameMode> ModeChanged; public Action<GameMode> ModeChanged;
private Container mainContent;
private void modeChanged(GameMode newMode) private void modeChanged(GameMode newMode)
{ {
// - Ability to change window size // - Ability to change window size

View File

@ -54,7 +54,7 @@ namespace osu.Game
{ {
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -55,7 +55,7 @@ namespace osu.Game.Overlays
}); });
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
initializeChannels(); initializeChannels();

View File

@ -44,7 +44,7 @@ namespace osu.Game.Overlays
Position = new Vector2(10, 50); Position = new Vector2(10, 50);
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
var osuGame = game as OsuGameBase; var osuGame = game as OsuGameBase;

View File

@ -17,7 +17,7 @@ namespace osu.Game.Overlays
{ {
private const float width = 300; private const float width = 300;
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);

View File

@ -25,6 +25,7 @@ namespace osu.Game.Overlays
public Action OnMusicController; public Action OnMusicController;
private ToolbarModeSelector modeSelector; private ToolbarModeSelector modeSelector;
private ToolbarButton userButton;
private const int transition_time = 200; private const int transition_time = 200;
@ -40,13 +41,8 @@ namespace osu.Game.Overlays
FadeOut(transition_time, EasingTypes.InQuint); FadeOut(transition_time, EasingTypes.InQuint);
} }
public override void Load(BaseGame game) public Toolbar()
{ {
base.Load(game);
RelativeSizeAxes = Axes.X;
Size = new Vector2(1, height);
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Box
@ -99,10 +95,9 @@ namespace osu.Game.Overlays
{ {
Icon = FontAwesome.search Icon = FontAwesome.search
}, },
new ToolbarButton userButton = new ToolbarButton
{ {
Icon = FontAwesome.user, Icon = FontAwesome.user,
Text = ((OsuGame)game).Config.Get<string>(OsuConfig.Username)
}, },
new ToolbarButton new ToolbarButton
{ {
@ -111,6 +106,15 @@ namespace osu.Game.Overlays
} }
} }
}; };
RelativeSizeAxes = Axes.X;
Size = new Vector2(1, height);
}
protected override void Load(BaseGame game)
{
base.Load(game);
userButton.Text = ((OsuGame)game).Config.Get<string>(OsuConfig.Username);
} }
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode); public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);

View File

@ -43,7 +43,7 @@ namespace osu.Game.Overlays
} }
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
DrawableIcon.TextSize *= 1.4f; DrawableIcon.TextSize *= 1.4f;

View File

@ -30,7 +30,7 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
} }
public override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
@ -90,7 +90,7 @@ namespace osu.Game.Overlays
activeMode.Invalidate(); activeMode.Invalidate();
} }
private Cached<Drawable> activeMode = new Cached<Drawable>(); private Cached activeMode = new Cached();
protected override void UpdateLayout() protected override void UpdateLayout()
{ {