diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index d481a446b8..c6e07c3a79 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -47,7 +47,7 @@ namespace osu.Game string[] args; - public OptionsOverlay Options; + private OptionsOverlay options; public OsuGame(string[] args = null) { @@ -61,7 +61,7 @@ namespace osu.Game host.Size = new Vector2(Config.Get(OsuConfig.Width), Config.Get(OsuConfig.Height)); } - public void ToggleOptions() => Options.ToggleVisibility(); + public void ToggleOptions() => options.ToggleVisibility(); [BackgroundDependencyLoader] private void load() @@ -118,15 +118,17 @@ namespace osu.Game //overlay elements (chat = new ChatOverlay { Depth = 0 }).Preload(this, overlayContent.Add); - (Options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add); + (options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add); (musicController = new MusicController() { Depth = -3 }).Preload(this, overlayContent.Add); + + Dependencies.Cache(options); + Dependencies.Cache(musicController); + (Toolbar = new Toolbar { Depth = -2, OnHome = delegate { mainMenu?.MakeCurrent(); }, - OnSettings = Options.ToggleVisibility, OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, - OnMusicController = musicController.ToggleVisibility }).Preload(this, t => { PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); }; @@ -134,9 +136,9 @@ namespace osu.Game overlayContent.Add(Toolbar); }); - Options.StateChanged += delegate + options.StateChanged += delegate { - switch (Options.State) + switch (options.State) { case Visibility.Hidden: intro.MoveToX(0, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint); @@ -164,7 +166,7 @@ namespace osu.Game switch (args.Key) { case Key.O: - Options.ToggleVisibility(); + options.ToggleVisibility(); return true; } } diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index a1af1d3293..df6168b6c5 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -2,7 +2,6 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; @@ -22,10 +21,8 @@ namespace osu.Game.Overlays.Toolbar { private const float height = 50; - public Action OnSettings; public Action OnHome; public Action OnPlayModeChange; - public Action OnMusicController; private ToolbarModeSelector modeSelector; private Box solidBackground; @@ -87,18 +84,9 @@ namespace osu.Game.Overlays.Toolbar AutoSizeAxes = Axes.X, Children = new Drawable[] { - new ToolbarButton + new ToolbarSettingsButton(), + new ToolbarHomeButton() { - Icon = FontAwesome.fa_gear, - TooltipMain = "Settings", - TooltipSub = "Change your settings", - Action = () => OnSettings?.Invoke() - }, - new ToolbarButton - { - Icon = FontAwesome.fa_home, - TooltipMain = "Home", - TooltipSub = "Return to the main menu", Action = () => OnHome?.Invoke() }, modeSelector = new ToolbarModeSelector @@ -116,11 +104,7 @@ namespace osu.Game.Overlays.Toolbar AutoSizeAxes = Axes.X, Children = new [] { - new ToolbarButton - { - Icon = FontAwesome.fa_music, - Action = () => OnMusicController?.Invoke() - }, + new ToolbarMusicButton(), new ToolbarButton { Icon = FontAwesome.fa_search diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index 9949a81c89..70462fa5fe 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -133,7 +133,7 @@ namespace osu.Game.Overlays.Toolbar protected override bool OnClick(InputState state) { Action?.Invoke(); - HoverBackground.FlashColour(new Color4(255, 255, 255, 180), 800, EasingTypes.OutQuint); + HoverBackground.FlashColour(new Color4(255, 255, 255, 100), 500, EasingTypes.OutQuint); return true; } diff --git a/osu.Game/Overlays/Toolbar/ToolbarHomeButton.cs b/osu.Game/Overlays/Toolbar/ToolbarHomeButton.cs new file mode 100644 index 0000000000..259abc0739 --- /dev/null +++ b/osu.Game/Overlays/Toolbar/ToolbarHomeButton.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 osu.Framework.Allocation; +using osu.Game.Graphics; +using osu.Game.Screens.Menu; + +namespace osu.Game.Overlays.Toolbar +{ + class ToolbarHomeButton : ToolbarButton + { + public ToolbarHomeButton() + { + Icon = FontAwesome.fa_home; + TooltipMain = "Home"; + TooltipSub = "Return to the main menu"; + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs b/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs new file mode 100644 index 0000000000..9409532df8 --- /dev/null +++ b/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs @@ -0,0 +1,23 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Toolbar +{ + class ToolbarMusicButton : ToolbarToggleButton + { + public ToolbarMusicButton() + { + Icon = FontAwesome.fa_music; + } + + [BackgroundDependencyLoader] + private void load(MusicController music) + { + StateContainer = music; + Action = music.ToggleVisibility; + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs b/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs new file mode 100644 index 0000000000..67fb4feb6f --- /dev/null +++ b/osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs @@ -0,0 +1,25 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Toolbar +{ + class ToolbarSettingsButton : ToolbarToggleButton + { + public ToolbarSettingsButton() + { + Icon = FontAwesome.fa_gear; + TooltipMain = "Settings"; + TooltipSub = "Change your settings"; + } + + [BackgroundDependencyLoader] + private void load(OptionsOverlay options) + { + StateContainer = options; + Action = options.ToggleVisibility; + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Toolbar/ToolbarToggleButton.cs b/osu.Game/Overlays/Toolbar/ToolbarToggleButton.cs new file mode 100644 index 0000000000..72fc87b310 --- /dev/null +++ b/osu.Game/Overlays/Toolbar/ToolbarToggleButton.cs @@ -0,0 +1,71 @@ +//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.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Game.Configuration; +using osu.Game.Online.API; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Overlays.Toolbar +{ + class ToolbarToggleButton : ToolbarButton + { + private Box StateBackground; + + private OverlayContainer stateContainer; + + public OverlayContainer StateContainer + { + get { return stateContainer; } + set + { + stateContainer = value; + stateContainer.StateChanged += stateChanged; + } + } + + public ToolbarToggleButton() + { + Add(StateBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(150, 150, 150, 180), + BlendingMode = BlendingMode.Additive, + Depth = 2, + Alpha = 0, + }); + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + if (stateContainer != null) + stateContainer.StateChanged -= stateChanged; + } + + private void stateChanged(OverlayContainer c, Visibility state) + { + switch (state) + { + case Visibility.Hidden: + StateBackground.FadeOut(200); + break; + case Visibility.Visible: + StateBackground.FadeIn(200); + break; + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 6f56037026..4478590e42 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -92,6 +92,10 @@ + + + +