From 154226b9a3ce3b3ea8002b4c1a27bf111c598c3e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Sep 2016 20:13:58 +0900 Subject: [PATCH] Basic white-boxing of all game modes. --- osu.Game/GameModes/Charts/ChartInfo.cs | 15 ++ osu.Game/GameModes/Charts/ChartListing.cs | 15 ++ osu.Game/GameModes/Direct/OnlineListing.cs | 9 ++ osu.Game/GameModes/Edit/Editor.cs | 15 ++ osu.Game/GameModes/Edit/SongSelectEdit.cs | 15 ++ osu.Game/GameModes/GameModeWhiteBox.cs | 138 ++++++++++++++++++ osu.Game/GameModes/Menu/ButtonSystem.cs | 62 +++----- osu.Game/GameModes/Menu/MainMenu.cs | 19 ++- osu.Game/GameModes/Multiplayer/Lobby.cs | 19 +++ osu.Game/GameModes/Multiplayer/Match.cs | 20 +++ osu.Game/GameModes/Multiplayer/MatchCreate.cs | 18 +++ .../GameModes/Multiplayer/MatchSongSelect.cs | 15 ++ osu.Game/GameModes/Play/ModSelect.cs | 15 ++ osu.Game/GameModes/Play/Player.cs | 18 +++ osu.Game/GameModes/Play/Results.cs | 15 ++ osu.Game/GameModes/Play/SongSelectPlay.cs | 16 ++ osu.Game/OsuGameBase.cs | 4 + osu.Game/Overlays/Options.cs | 75 ++++++++++ osu.Game/osu.Game.csproj | 15 ++ 19 files changed, 472 insertions(+), 46 deletions(-) create mode 100644 osu.Game/GameModes/Charts/ChartInfo.cs create mode 100644 osu.Game/GameModes/Charts/ChartListing.cs create mode 100644 osu.Game/GameModes/Direct/OnlineListing.cs create mode 100644 osu.Game/GameModes/Edit/Editor.cs create mode 100644 osu.Game/GameModes/Edit/SongSelectEdit.cs create mode 100644 osu.Game/GameModes/GameModeWhiteBox.cs create mode 100644 osu.Game/GameModes/Multiplayer/Lobby.cs create mode 100644 osu.Game/GameModes/Multiplayer/Match.cs create mode 100644 osu.Game/GameModes/Multiplayer/MatchCreate.cs create mode 100644 osu.Game/GameModes/Multiplayer/MatchSongSelect.cs create mode 100644 osu.Game/GameModes/Play/ModSelect.cs create mode 100644 osu.Game/GameModes/Play/Player.cs create mode 100644 osu.Game/GameModes/Play/Results.cs create mode 100644 osu.Game/GameModes/Play/SongSelectPlay.cs create mode 100644 osu.Game/Overlays/Options.cs diff --git a/osu.Game/GameModes/Charts/ChartInfo.cs b/osu.Game/GameModes/Charts/ChartInfo.cs new file mode 100644 index 0000000000..67a11e632a --- /dev/null +++ b/osu.Game/GameModes/Charts/ChartInfo.cs @@ -0,0 +1,15 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.GameModes.Charts +{ + class ChartInfo : GameModeWhiteBox + { + } +} diff --git a/osu.Game/GameModes/Charts/ChartListing.cs b/osu.Game/GameModes/Charts/ChartListing.cs new file mode 100644 index 0000000000..7be9d09bcf --- /dev/null +++ b/osu.Game/GameModes/Charts/ChartListing.cs @@ -0,0 +1,15 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; + +namespace osu.Game.GameModes.Charts +{ + class ChartListing : GameModeWhiteBox + { + protected override IEnumerable PossibleChildren => new[] { + typeof(ChartInfo) + }; + } +} diff --git a/osu.Game/GameModes/Direct/OnlineListing.cs b/osu.Game/GameModes/Direct/OnlineListing.cs new file mode 100644 index 0000000000..c30017cb77 --- /dev/null +++ b/osu.Game/GameModes/Direct/OnlineListing.cs @@ -0,0 +1,9 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.GameModes.Direct +{ + class OnlineListing : GameModeWhiteBox + { + } +} diff --git a/osu.Game/GameModes/Edit/Editor.cs b/osu.Game/GameModes/Edit/Editor.cs new file mode 100644 index 0000000000..779aa105f9 --- /dev/null +++ b/osu.Game/GameModes/Edit/Editor.cs @@ -0,0 +1,15 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.GameModes.Edit +{ + class Editor : GameModeWhiteBox + { + } +} diff --git a/osu.Game/GameModes/Edit/SongSelectEdit.cs b/osu.Game/GameModes/Edit/SongSelectEdit.cs new file mode 100644 index 0000000000..a6c0f9fdf5 --- /dev/null +++ b/osu.Game/GameModes/Edit/SongSelectEdit.cs @@ -0,0 +1,15 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; + +namespace osu.Game.GameModes.Edit +{ + class SongSelectEdit : GameModeWhiteBox + { + protected override IEnumerable PossibleChildren => new[] { + typeof(Editor) + }; + } +} diff --git a/osu.Game/GameModes/GameModeWhiteBox.cs b/osu.Game/GameModes/GameModeWhiteBox.cs new file mode 100644 index 0000000000..b46987ee1b --- /dev/null +++ b/osu.Game/GameModes/GameModeWhiteBox.cs @@ -0,0 +1,138 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using osu.Framework.GameModes; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.MathUtils; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.GameModes +{ + public class GameModeWhiteBox : GameMode + { + private Button popButton; + + const int transition_time = 1000; + + protected virtual IEnumerable PossibleChildren => null; + + private FlowContainer childModeButtons; + + protected override double OnEntering(GameMode last) + { + //only show the pop button if we are entered form another gamemode. + popButton.Alpha = 1; + + MoveTo(new Vector2(ActualSize.X, 0)); + MoveTo(Vector2.Zero, transition_time, EasingTypes.OutQuint); + return transition_time; + } + + protected override double OnExiting(GameMode next) + { + MoveTo(new Vector2(ActualSize.X, 0), transition_time, EasingTypes.OutQuint); + return transition_time; + } + + protected override double OnSuspending(GameMode next) + { + Content.MoveTo(new Vector2(-ActualSize.X, 0), transition_time, EasingTypes.OutQuint); + return transition_time; + } + + protected override double OnResuming(GameMode last) + { + Content.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutQuint); + return transition_time; + } + + public override void Load() + { + base.Load(); + + Children = new Drawable[] + { + new Box + { + SizeMode = InheritMode.XY, + Size = new Vector2(1), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = getColourFor(GetType()) + }, + new SpriteText + { + Text = GetType().Name, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 50, + }, + new SpriteText + { + Text = GetType().Namespace, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Position = new Vector2(0, 30) + }, + popButton = new Button + { + Text = @"Back", + SizeMode = InheritMode.X, + Size = new Vector2(0.1f, 40), + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Colour = new Color4(235, 51, 153, 255), + Alpha = 0, + Action = delegate { + Exit(); + } + }, + childModeButtons = new FlowContainer + { + Direction = FlowDirection.VerticalOnly, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + SizeMode = InheritMode.XY, + Size = new Vector2(0.1f, 1) + } + }; + + if (PossibleChildren != null) + { + foreach (Type t in PossibleChildren) + { + childModeButtons.Add(new Button + { + Text = $@"{t.Name}", + SizeMode = InheritMode.X, + Size = new Vector2(1, 40), + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Colour = getColourFor(t), + Action = delegate + { + Push(Activator.CreateInstance(t) as GameMode); + } + }); + } + } + } + + private Color4 getColourFor(Type type) + { + int hash = type.Name.GetHashCode(); + byte r = (byte)MathHelper.Clamp(((hash & 0xFF0000) >> 16) * 0.8f, 20, 255); + byte g = (byte)MathHelper.Clamp(((hash & 0x00FF00) >> 8) * 0.8f, 20, 255); + byte b = (byte)MathHelper.Clamp((hash & 0x0000FF) * 0.8f, 20, 255); + return new Color4(r, g, b, 255); + } + } +} diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index a24af25863..6a74b9aa75 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -21,6 +21,15 @@ namespace osu.Game.GameModes.Menu { public class ButtonSystem : OsuLargeComponent { + public Action OnEdit; + public Action OnExit; + public Action OnDirect; + public Action OnSolo; + public Action OnSettings; + public Action OnMulti; + public Action OnChart; + public Action OnTest; + private FlowContainerWithOrigin buttonFlow; const float button_area_height = 128; @@ -71,7 +80,7 @@ namespace osu.Game.GameModes.Menu Padding = new Vector2(-wedge_width, 0), Children = new Drawable[] { - settingsButton = new Button(@"settings", @"options", FontAwesome.gear, new Color4(85, 85, 85, 255), onSettings, -wedge_width, Key.O), + settingsButton = new Button(@"settings", @"options", FontAwesome.gear, new Color4(85, 85, 85, 255), OnSettings, -wedge_width, Key.O), backButton = new Button(@"back", @"back", FontAwesome.fa_osu_left_o, new Color4(51, 58, 94, 255), onBack, -wedge_width, Key.Escape), iconFacade = new Container //need a container to make the osu! icon flow properly. { @@ -91,14 +100,14 @@ namespace osu.Game.GameModes.Menu buttonFlow.Position = new Vector2(wedge_width * 2 - (button_width + osuLogo.SizeForFlow / 4), 0); - buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"solo", @"freeplay", FontAwesome.user, new Color4(102, 68, 204, 255), onSolo, wedge_width, Key.P))); - buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"multi", @"multiplayer", FontAwesome.users, new Color4(94, 63, 186, 255), onMulti, 0, Key.M))); - buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), onChart))); - buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"tests", @"tests", FontAwesome.terminal, new Color4(80, 53, 160, 255), onTest, 0, Key.T))); + buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"solo", @"freeplay", FontAwesome.user, new Color4(102, 68, 204, 255), OnSolo, wedge_width, Key.P))); + buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"multi", @"multiplayer", FontAwesome.users, new Color4(94, 63, 186, 255), OnMulti, 0, Key.M))); + buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), OnChart))); + buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"tests", @"tests", FontAwesome.terminal, new Color4(80, 53, 160, 255), OnTest, 0, Key.T))); buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"play", @"play", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, wedge_width, Key.P))); - buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), onEdit, 0, Key.E))); - buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), onDirect, 0, Key.D))); + buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), OnEdit, 0, Key.E))); + buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), OnDirect, 0, Key.D))); buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"exit", @"exit", FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q))); } @@ -108,31 +117,15 @@ namespace osu.Game.GameModes.Menu return true; } - private void onSettings() - { - //OsuGame.Options.LoginOnly = false; - //OsuGame.Options.Expanded = true; - } - private void onPlay() { State = MenuState.Play; } - private void onEdit() - { - //OsuGame.ChangeMode(OsuModes.SelectEdit); - } - - private void onDirect() - { - //OsuGame.ChangeMode(OsuModes.OnlineSelection); - } - private void onExit() { - //OsuGame.ChangeMode(OsuModes.Exit); State = MenuState.Exit; + OnExit?.Invoke(); } private void onBack() @@ -140,27 +133,6 @@ namespace osu.Game.GameModes.Menu State = MenuState.TopLevel; } - private void onSolo() - { - //OsuGame.ChangeMode(OsuModes.SelectPlay); - } - - private void onMulti() - { - //OsuGame.ChangeMode(OsuModes.Lobby); - } - - private void onChart() - { - //OsuGame.ChangeMode(OsuModes.Charts); - } - - private void onTest() - { - - //OsuGame.ChangeMode(OsuModes.FieldTest); - } - private void onOsuLogo() { switch (state) diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index 6cc4c0ac8f..163a09bc17 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -4,7 +4,13 @@ using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; using osu.Framework.GameModes; +using osu.Framework.GameModes.Testing; using osu.Framework.Graphics; +using osu.Game.GameModes.Charts; +using osu.Game.GameModes.Direct; +using osu.Game.GameModes.Edit; +using osu.Game.GameModes.Multiplayer; +using osu.Game.GameModes.Play; namespace osu.Game.GameModes.Menu { @@ -19,10 +25,21 @@ namespace osu.Game.GameModes.Menu base.Load(); AudioSample welcome = Game.Audio.Sample.Get(@"welcome"); + welcome.Play(); Children = new Drawable[] { - new ButtonSystem(), + new ButtonSystem() + { + OnChart = delegate { Push(new ChartListing()); }, + OnDirect = delegate { Push(new OnlineListing()); }, + OnEdit = delegate { Push(new SongSelectEdit()); }, + OnSolo = delegate { Push(new SongSelectPlay()); }, + OnMulti = delegate { Push(new Lobby()); }, + OnTest = delegate { Push(new TestBrowser()); }, + OnExit = delegate { Game.Host.Exit(); }, + OnSettings = delegate { (Game as OsuGame).Options.PoppedOut = !(Game as OsuGame).Options.PoppedOut; }, + } }; } } diff --git a/osu.Game/GameModes/Multiplayer/Lobby.cs b/osu.Game/GameModes/Multiplayer/Lobby.cs new file mode 100644 index 0000000000..6700736234 --- /dev/null +++ b/osu.Game/GameModes/Multiplayer/Lobby.cs @@ -0,0 +1,19 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.GameModes.Multiplayer +{ + class Lobby : GameModeWhiteBox + { + protected override IEnumerable PossibleChildren => new[] { + typeof(MatchCreate), + typeof(Match) + }; + } +} diff --git a/osu.Game/GameModes/Multiplayer/Match.cs b/osu.Game/GameModes/Multiplayer/Match.cs new file mode 100644 index 0000000000..e8a476a37d --- /dev/null +++ b/osu.Game/GameModes/Multiplayer/Match.cs @@ -0,0 +1,20 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Game.GameModes.Play; + +namespace osu.Game.GameModes.Multiplayer +{ + class Match : GameModeWhiteBox + { + protected override IEnumerable PossibleChildren => new[] { + typeof(MatchSongSelect), + typeof(Player), + }; + } +} diff --git a/osu.Game/GameModes/Multiplayer/MatchCreate.cs b/osu.Game/GameModes/Multiplayer/MatchCreate.cs new file mode 100644 index 0000000000..8d134d170e --- /dev/null +++ b/osu.Game/GameModes/Multiplayer/MatchCreate.cs @@ -0,0 +1,18 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.GameModes.Multiplayer +{ + class MatchCreate : GameModeWhiteBox + { + protected override IEnumerable PossibleChildren => new[] { + typeof(Match) + }; + } +} diff --git a/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs b/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs new file mode 100644 index 0000000000..f58ce5f7d1 --- /dev/null +++ b/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs @@ -0,0 +1,15 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.GameModes.Multiplayer +{ + class MatchSongSelect : GameModeWhiteBox + { + } +} diff --git a/osu.Game/GameModes/Play/ModSelect.cs b/osu.Game/GameModes/Play/ModSelect.cs new file mode 100644 index 0000000000..5254f9b1a0 --- /dev/null +++ b/osu.Game/GameModes/Play/ModSelect.cs @@ -0,0 +1,15 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.GameModes.Play +{ + class ModSelect : GameModeWhiteBox + { + } +} diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs new file mode 100644 index 0000000000..37663dbc2f --- /dev/null +++ b/osu.Game/GameModes/Play/Player.cs @@ -0,0 +1,18 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.GameModes.Play +{ + class Player : GameModeWhiteBox + { + protected override IEnumerable PossibleChildren => new[] { + typeof(Results) + }; + } +} diff --git a/osu.Game/GameModes/Play/Results.cs b/osu.Game/GameModes/Play/Results.cs new file mode 100644 index 0000000000..cbfe4f1c4b --- /dev/null +++ b/osu.Game/GameModes/Play/Results.cs @@ -0,0 +1,15 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.GameModes.Play +{ + class Results : GameModeWhiteBox + { + } +} diff --git a/osu.Game/GameModes/Play/SongSelectPlay.cs b/osu.Game/GameModes/Play/SongSelectPlay.cs new file mode 100644 index 0000000000..f2547a028b --- /dev/null +++ b/osu.Game/GameModes/Play/SongSelectPlay.cs @@ -0,0 +1,16 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; + +namespace osu.Game.GameModes.Play +{ + class SongSelectPlay : GameModeWhiteBox + { + protected override IEnumerable PossibleChildren => new[] { + typeof(ModSelect), + typeof(Player) + }; + } +} diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 20e7153575..e725180493 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -7,6 +7,7 @@ using osu.Game.Configuration; using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Processing; using osu.Game.Online.API; +using osu.Game.Overlays; namespace osu.Game { @@ -16,6 +17,8 @@ namespace osu.Game protected override string MainResourceFile => @"osu.Game.Resources.dll"; + public Options Options; + internal APIAccess API; protected override Container AddTarget => ratioContainer?.IsLoaded == true ? ratioContainer : base.AddTarget; @@ -45,6 +48,7 @@ namespace osu.Game { Children = new Drawable[] { + Options = new Options(), new OsuCursorContainer() } } diff --git a/osu.Game/Overlays/Options.cs b/osu.Game/Overlays/Options.cs new file mode 100644 index 0000000000..284b4ff3d0 --- /dev/null +++ b/osu.Game/Overlays/Options.cs @@ -0,0 +1,75 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Transformations; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Input; +using OpenTK.Input; + +namespace osu.Game.Overlays +{ + public class Options : Container + { + const float width = 300; + + public override void Load() + { + base.Load(); + + Depth = float.MaxValue; + SizeMode = InheritMode.Y; + Size = new Vector2(width, 1); + Position = new Vector2(-width, 0); + + Children = new Drawable[] + { + new Box + { + SizeMode = InheritMode.XY, + Colour = new Color4(0.1f, 0.1f, 0.1f, 0.9f) + } + }; + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + switch (args.Key) + { + case Key.Escape: + if (!poppedOut) return false; + + PoppedOut = false; + return true; + } + return base.OnKeyDown(state, args); + } + + private bool poppedOut; + + public bool PoppedOut + { + get { return poppedOut; } + + set + { + if (value == poppedOut) return; + + poppedOut = value; + + if (poppedOut) + { + MoveTo(new Vector2(0, 0), 300, EasingTypes.Out); + } + else + { + MoveTo(new Vector2(-width, 0), 300, EasingTypes.Out); + } + + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2b3c2fd30f..eb1cc03218 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -46,8 +46,22 @@ + + + + + + + + + + + + + + @@ -69,6 +83,7 @@ +