1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Merge pull request #119 from peppy/async-workflow

Async Workflow
This commit is contained in:
Dean Herbert 2016-11-03 17:08:00 +09:00 committed by GitHub
commit 6f16a6a6d4
52 changed files with 246 additions and 137 deletions

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
@ -40,6 +43,10 @@ namespace osu.Game.Beatmaps.Drawable
{
case BeatmapGroupState.Expanded:
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();
header.State = PanelSelectedState.Selected;
@ -62,16 +69,6 @@ namespace osu.Game.Beatmaps.Drawable
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
BeatmapPanels = beatmapSet.Beatmaps.Select(b =>
new BeatmapPanel(b)
{
GainedSelection = panelGainedSelection,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.X,
}).ToList();
Children = new[]
{
new FlowContainer
@ -96,20 +93,29 @@ namespace osu.Game.Beatmaps.Drawable
Padding = new MarginPadding { Left = 75 },
Spacing = new Vector2(0, 5),
Direction = FlowDirection.VerticalOnly,
Alpha = 0,
Children = BeatmapPanels
}
}
}
};
}
public override void Load(BaseGame game)
protected override void Load(BaseGame 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)
{
State = BeatmapGroupState.Expanded;

View File

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

View File

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

View File

@ -64,7 +64,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
Size = new Vector2(100);
}
public override void Load(BaseGame game)
protected override void Load(BaseGame 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);
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);
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);
ring.Texture = game.Textures.Get(@"Play/osu/ring@2x");
@ -241,7 +241,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
{
private Texture tex;
public override void Load(BaseGame game)
protected override void Load(BaseGame 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);
disc.Texture = game.Textures.Get(@"Play/osu/disc@2x");
@ -318,7 +318,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
{
private Texture tex;
public override void Load(BaseGame game)
protected override void Load(BaseGame game)
{
base.Load(game);

View File

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

View File

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

View File

@ -12,6 +12,7 @@ using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework;
using System.Threading;
namespace osu.Game.GameModes
{
@ -31,11 +32,32 @@ namespace osu.Game.GameModes
return false;
}
public override void Load(BaseGame game)
BaseGame game;
protected override void Load(BaseGame 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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//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.Track;
using osu.Framework.GameModes;
@ -10,8 +10,6 @@ using osu.Framework.Graphics.Transformations;
using osu.Game.GameModes.Backgrounds;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Configuration;
using osu.Game.Beatmaps;
namespace osu.Game.GameModes.Menu
{
@ -24,12 +22,14 @@ namespace osu.Game.GameModes.Menu
/// </summary>
internal bool DidLoadMenu;
MainMenu mainMenu;
private AudioSample welcome;
private AudioTrack bgm;
protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty();
public override void Load(BaseGame game)
public Intro()
{
base.Load(game);
Children = new Drawable[]
{
logo = new OsuLogo()
@ -41,32 +41,45 @@ namespace osu.Game.GameModes.Menu
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;
}
protected override void LoadComplete()
{
base.LoadComplete();
Scheduler.Add(delegate
{
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
{
bgm.Start();
}, 600);
logo.ScaleTo(0.4f);
logo.FadeOut();
Scheduler.AddDelayed(delegate
{
DidLoadMenu = true;
Push(new MainMenu());
}, 2900);
logo.ScaleTo(0);
logo.ScaleTo(1, 5900, EasingTypes.OutQuint);
logo.FadeIn(30000, EasingTypes.OutQuint);
logo.ScaleTo(1, 4400, EasingTypes.OutQuint);
logo.FadeIn(20000, EasingTypes.OutQuint);
}
protected override void OnSuspending(GameMode next)

View File

@ -1,6 +1,7 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.GameModes;
using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics;
@ -15,6 +16,7 @@ using osu.Game.Graphics.Containers;
using OpenTK;
using osu.Framework;
using osu.Game.Overlays;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Menu
{
@ -23,13 +25,13 @@ namespace osu.Game.GameModes.Menu
private ButtonSystem buttons;
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);
OsuGame osu = (OsuGame)game;
background = new BackgroundModeDefault();
Children = new Drawable[]
{
@ -40,7 +42,6 @@ namespace osu.Game.GameModes.Menu
{
buttons = new ButtonSystem()
{
Alpha = 0,
OnChart = delegate { Push(new ChartListing()); },
OnDirect = delegate { Push(new OnlineListing()); },
OnEdit = delegate { Push(new EditSongSelect()); },
@ -48,13 +49,26 @@ namespace osu.Game.GameModes.Menu
OnMulti = delegate { Push(new Lobby()); },
OnTest = delegate { Push(new TestBrowser()); },
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)

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);
logo.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.FadeOut(500);

View File

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

View File

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

View File

@ -120,7 +120,7 @@ namespace osu.Game.GameModes.Play
TextSize = 80;
}
public override void Load(BaseGame game)
protected override void Load(BaseGame game)
{
base.Load(game);

View File

@ -39,7 +39,7 @@ namespace osu.Game.GameModes.Play
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);

View File

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

View File

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

View File

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

View File

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

View File

@ -121,7 +121,7 @@ namespace osu.Game.GameModes.Play
};
}
public override void Load(BaseGame game)
protected override void Load(BaseGame game)
{
base.Load(game);
@ -219,15 +219,20 @@ namespace osu.Game.GameModes.Play
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);
track.Start();
}
if (track != null)
{
trackManager.SetExclusive(track);
track.Start();
}
});
}
private void addBeatmapSet(BeatmapSetInfo beatmapSet)
@ -235,14 +240,19 @@ namespace osu.Game.GameModes.Play
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
beatmapSet.Beatmaps.ForEach(b => database.GetChildren(b));
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);
if (Beatmap == null)
{
if (beatmapSetFlow.Children.Count() == 1)
{
group.State = BeatmapGroupState.Expanded;
return;
}
}
else
{
@ -250,9 +260,14 @@ namespace osu.Game.GameModes.Play
{
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,7 +30,7 @@ namespace osu.Game.GameModes.Play
private InterpolatingFramedClock playerClock;
private IAdjustableClock sourceClock;
public override void Load(BaseGame game)
protected override void Load(BaseGame game)
{
base.Load(game);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -119,7 +119,7 @@ namespace osu.Game.Graphics.UserInterface
AutoSizeAxes = Axes.Both;
}
public override void Load(BaseGame game)
protected override void Load(BaseGame 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);
@ -131,7 +131,11 @@ namespace osu.Game.Graphics.UserInterface
stars.Add(star);
starContainer.Add(star);
}
}
protected override void LoadComplete()
{
base.LoadComplete();
// Animate initial state from zero.
transformCount(0, Count);
}

View File

@ -32,7 +32,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
Origin = Anchor.BottomRight;
}
public override void Load(BaseGame game)
protected override void Load(BaseGame game)
{
VolumeGlobal.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);
updateFill();

View File

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

View File

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

View File

@ -2,6 +2,7 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Threading;
using osu.Framework.Configuration;
using osu.Framework.GameModes;
using osu.Game.Configuration;
@ -46,7 +47,7 @@ namespace osu.Game
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)
{
@ -64,23 +65,18 @@ namespace osu.Game
Audio.VolumeSample.Weld(Config.GetBindable<double>(OsuConfig.VolumeEffect));
Audio.VolumeTrack.Weld(Config.GetBindable<double>(OsuConfig.VolumeMusic));
PlayMode = Config.GetBindable<PlayMode>(OsuConfig.PlayMode);
Add(new Drawable[] {
new VolumeControlReceptor
{
RelativeSizeAxes = Axes.Both,
ActivateRequested = delegate { volume.Show(); }
},
intro = new Intro
mainContent = new Container
{
Beatmap = Beatmap
RelativeSizeAxes = Axes.Both,
},
Toolbar = new Toolbar
{
OnHome = delegate { MainMenu?.MakeCurrent(); },
OnSettings = Options.ToggleVisibility,
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
},
Chat = new ChatConsole(API),
volume = new VolumeControl
{
VolumeGlobal = Audio.Volume,
@ -93,12 +89,31 @@ namespace osu.Game
}
});
intro.ModePushed += modeAdded;
intro.Exited += modeRemoved;
(intro = new Intro
{
Beatmap = Beatmap
}).Preload(game, d =>
{
mainContent.Add(d);
PlayMode = Config.GetBindable<PlayMode>(OsuConfig.PlayMode);
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
PlayMode.TriggerChange();
intro.ModePushed += modeAdded;
intro.Exited += modeRemoved;
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;
}
@ -117,6 +132,8 @@ namespace osu.Game
public Action<GameMode> ModeChanged;
private Container mainContent;
private void modeChanged(GameMode newMode)
{
// - Ability to change window size

View File

@ -55,7 +55,7 @@ namespace osu.Game
throw new NotImplementedException();
}
public override void Load(BaseGame game)
protected override void Load(BaseGame 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);
initializeChannels();

View File

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

View File

@ -24,6 +24,7 @@ namespace osu.Game.Overlays
public Action<PlayMode> OnPlayModeChange;
private ToolbarModeSelector modeSelector;
private ToolbarButton userButton;
private const int transition_time = 200;
@ -39,13 +40,8 @@ namespace osu.Game.Overlays
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[]
{
new Box
@ -93,10 +89,9 @@ namespace osu.Game.Overlays
{
Icon = FontAwesome.search
},
new ToolbarButton
userButton = new ToolbarButton
{
Icon = FontAwesome.user,
Text = ((OsuGame)game).Config.Get<string>(OsuConfig.Username)
},
new ToolbarButton
{
@ -105,6 +100,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);

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);
DrawableIcon.TextSize *= 1.4f;

View File

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