From ddcd5ec286577b06c162d8985af3326af344494d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Oct 2016 20:39:32 +0900 Subject: [PATCH 01/46] Add basic layout for toolbar. --- osu.Game/GameModes/Menu/ButtonSystem.cs | 2 - osu.Game/Overlays/Toolbar.cs | 132 +++++++++++++++++++++++- 2 files changed, 127 insertions(+), 7 deletions(-) diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index a4fbf37886..0b01965394 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -701,6 +701,4 @@ namespace osu.Game.GameModes.Menu { } } - - } diff --git a/osu.Game/Overlays/Toolbar.cs b/osu.Game/Overlays/Toolbar.cs index 2db9f1ba96..cd1c65915a 100644 --- a/osu.Game/Overlays/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar.cs @@ -1,22 +1,23 @@ //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.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Drawables; using OpenTK; using OpenTK.Graphics; +using osu.Game.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Configuration; namespace osu.Game.Overlays { public class Toolbar : Container { const float height = 50; + private FlowContainer leftFlow; + private FlowContainer rightFlow; public override void Load() { @@ -31,8 +32,129 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.Both, Colour = new Color4(0.1f, 0.1f, 0.1f, 0.9f) + }, + leftFlow = new FlowContainer + { + Direction = FlowDirection.HorizontalOnly, + RelativeSizeAxes = Axes.Y, + Size = new Vector2(0, 1), + Children = new [] + { + new ToolbarButton(FontAwesome.gear), + new ToolbarButton(FontAwesome.home), + new ToolbarModeButton(FontAwesome.fa_osu_osu_o, @"osu!"), + new ToolbarModeButton(FontAwesome.fa_osu_taiko_o, @"taiko"), + new ToolbarModeButton(FontAwesome.fa_osu_fruits_o, @"catch"), + new ToolbarModeButton(FontAwesome.fa_osu_mania_o, @"mania"), + } + }, + rightFlow = new FlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Direction = FlowDirection.HorizontalOnly, + RelativeSizeAxes = Axes.Y, + Size = new Vector2(0, 1), + Children = new [] + { + new ToolbarButton(FontAwesome.search), + new ToolbarButton(FontAwesome.user, ((OsuGame)Game).Config.Get(OsuConfig.Username)), + new ToolbarButton(FontAwesome.bars), + } } }; } + + public class ToolbarModeButton : ToolbarButton + { + public ToolbarModeButton(FontAwesome icon, string text = null) : base(icon, text) + { + } + + public override void Load() + { + base.Load(); + Icon.TextSize = height * 0.7f; + } + } + + public class ToolbarButton : FlowContainer + { + public TextAwesome Icon; + public SpriteText Text; + private Box background; + private Drawable paddingLeft; + private Drawable paddingRight; + private Drawable paddingIcon; + + public new float Padding + { + get { return paddingLeft.Size.X; } + set + { + paddingLeft.Size = new Vector2(value, 1); + paddingRight.Size = new Vector2(value, 1); + } + } + + public ToolbarButton(FontAwesome icon, string text = null) + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(20, 20, 20, 140), + }; + + this.Icon = new TextAwesome() + { + Icon = icon, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }; + + this.Text = new SpriteText + { + Text = text, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }; + + paddingLeft = new Container { RelativeSizeAxes = Axes.Y }; + paddingRight = new Container { RelativeSizeAxes = Axes.Y }; + paddingIcon = new Container { Size = new Vector2(string.IsNullOrEmpty(text) ? 0 : 5, 0) }; + + Padding = 10; + } + + protected override bool OnHover(InputState state) + { + background.FadeColour(new Color4(130, 130, 130, 160), 100); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + background.FadeColour(new Color4(20, 20, 20, 140), 100); + base.OnHoverLost(state); + } + + public override void Load() + { + base.Load(); + + RelativeSizeAxes = Axes.Y; + Direction = FlowDirection.HorizontalOnly; + + Children = new Drawable[] + { + background, + paddingLeft, + Icon, + paddingIcon, + Text, + paddingRight, + }; + } + } } } From 51cf13460fcd053d05cbbebb6318fa6edbfb7d68 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Oct 2016 23:56:25 +0900 Subject: [PATCH 02/46] Remove performance overlay. --- osu.Game/OsuGame.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 9ba587a195..c26627d1c4 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -29,8 +29,6 @@ namespace osu.Game { base.Load(); - ShowPerformanceOverlay = true; - Add(new Drawable[] { new ParallaxContainer { From 11403a922a2eb24971e5193c72faf672134cc569 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Oct 2016 17:15:03 +0900 Subject: [PATCH 03/46] Make Home, Settings and PlayMode buttons work. --- osu.Game/Configuration/OsuConfigManager.cs | 6 +- osu.Game/GameModes/Menu/MainMenu.cs | 2 +- osu.Game/GameModes/Play/PlayMode.cs | 20 +++ osu.Game/OsuGame.cs | 17 ++- osu.Game/Overlays/Toolbar.cs | 170 +++++++++++++++++---- osu.Game/osu.Game.csproj | 1 + 6 files changed, 185 insertions(+), 31 deletions(-) create mode 100644 osu.Game/GameModes/Play/PlayMode.cs diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 0873669399..9991394913 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -2,6 +2,7 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Configuration; +using osu.Game.GameModes.Play; using osu.Game.Online.API; namespace osu.Game.Configuration @@ -17,6 +18,8 @@ namespace osu.Game.Configuration Set(OsuConfig.Username, string.Empty); Set(OsuConfig.Password, string.Empty); Set(OsuConfig.Token, string.Empty); + + Set(OsuConfig.PlayMode, PlayMode.Osu); } } @@ -27,6 +30,7 @@ namespace osu.Game.Configuration MouseSensitivity, Username, Password, - Token + Token, + PlayMode } } diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index e4c66a27a4..fa99abed91 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -17,7 +17,7 @@ using OpenTK; namespace osu.Game.GameModes.Menu { - internal class MainMenu : GameMode + public class MainMenu : GameMode { private ButtonSystem buttons; public override string Name => @"Main Menu"; diff --git a/osu.Game/GameModes/Play/PlayMode.cs b/osu.Game/GameModes/Play/PlayMode.cs new file mode 100644 index 0000000000..bf7c141ca4 --- /dev/null +++ b/osu.Game/GameModes/Play/PlayMode.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.ComponentModel; + +namespace osu.Game.GameModes.Play +{ + public enum PlayMode + { + [Description(@"osu!")] + Osu = 0, + [Description(@"taiko")] + Taiko = 1, + [Description(@"catch")] + Catch = 2, + [Description(@"mania")] + Mania = 3 + } +} diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index c26627d1c4..4148854513 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1,6 +1,7 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Configuration; using osu.Game.Configuration; using osu.Game.GameModes.Menu; using OpenTK; @@ -17,6 +18,9 @@ namespace osu.Game public class OsuGame : OsuGameBase { public Toolbar Toolbar; + public MainMenu MainMenu; + + public Bindable PlayMode; public override void SetHost(BasicGameHost host) { @@ -36,9 +40,18 @@ namespace osu.Game new Background() } }, - new MainMenu(), - Toolbar = new Toolbar(), + MainMenu = new MainMenu(), + Toolbar = new Toolbar + { + OnHome = delegate { MainMenu.MakeCurrent(); }, + OnSettings = delegate { Options.PoppedOut = !Options.PoppedOut; }, + OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, + }, }); + + PlayMode = Config.GetBindable(OsuConfig.PlayMode); + PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); }; + PlayMode.TriggerChange(); } public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) diff --git a/osu.Game/Overlays/Toolbar.cs b/osu.Game/Overlays/Toolbar.cs index cd1c65915a..b953f455e9 100644 --- a/osu.Game/Overlays/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar.cs @@ -10,6 +10,10 @@ using osu.Game.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using osu.Game.Configuration; +using System; +using System.Linq; +using osu.Game.GameModes.Play; +using osu.Framework.Extensions; namespace osu.Game.Overlays { @@ -18,6 +22,12 @@ namespace osu.Game.Overlays const float height = 50; private FlowContainer leftFlow; private FlowContainer rightFlow; + private FlowContainer modeButtons; + + public Action OnSettings; + public Action OnHome; + public Action OnPlayModeChange; + public override void Load() { @@ -26,6 +36,27 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.X; Size = new Vector2(1, height); + modeButtons = new FlowContainer + { + RelativeSizeAxes = Axes.Y, + Direction = FlowDirection.HorizontalOnly + }; + + foreach (PlayMode m in Enum.GetValues(typeof(PlayMode))) + { + var localMode = m; + modeButtons.Add(new ToolbarModeButton + { + Mode = m, + Action = delegate + { + SetGameMode(localMode); + OnPlayModeChange?.Invoke(localMode); + } + }); + } + + Children = new Drawable[] { new Box @@ -37,15 +68,19 @@ namespace osu.Game.Overlays { Direction = FlowDirection.HorizontalOnly, RelativeSizeAxes = Axes.Y, - Size = new Vector2(0, 1), Children = new [] { - new ToolbarButton(FontAwesome.gear), - new ToolbarButton(FontAwesome.home), - new ToolbarModeButton(FontAwesome.fa_osu_osu_o, @"osu!"), - new ToolbarModeButton(FontAwesome.fa_osu_taiko_o, @"taiko"), - new ToolbarModeButton(FontAwesome.fa_osu_fruits_o, @"catch"), - new ToolbarModeButton(FontAwesome.fa_osu_mania_o, @"mania"), + new ToolbarButton + { + Icon = FontAwesome.gear, + Action = OnSettings + }, + new ToolbarButton + { + Icon = FontAwesome.home, + Action = OnHome + }, + modeButtons } }, rightFlow = new FlowContainer @@ -57,32 +92,96 @@ namespace osu.Game.Overlays Size = new Vector2(0, 1), Children = new [] { - new ToolbarButton(FontAwesome.search), - new ToolbarButton(FontAwesome.user, ((OsuGame)Game).Config.Get(OsuConfig.Username)), - new ToolbarButton(FontAwesome.bars), + new ToolbarButton + { + Icon = FontAwesome.search + }, + new ToolbarButton + { + Icon = FontAwesome.user, + Text = ((OsuGame)Game).Config.Get(OsuConfig.Username) + }, + new ToolbarButton + { + Icon = FontAwesome.bars + }, } } }; } + public void SetGameMode(PlayMode mode) + { + foreach (var m in modeButtons.Children.Cast()) + { + m.Active = m.Mode == mode; + } + } + public class ToolbarModeButton : ToolbarButton { - public ToolbarModeButton(FontAwesome icon, string text = null) : base(icon, text) + private PlayMode mode; + public PlayMode Mode { + get { return mode; } + set + { + mode = value; + Text = mode.GetDescription(); + Icon = getModeIcon(mode); + } + } + + public bool Active + { + set + { + Background.Colour = value ? new Color4(100, 100, 100, 140) : new Color4(20, 20, 20, 140); + } + } + + private FontAwesome getModeIcon(PlayMode mode) + { + switch (mode) + { + default: return FontAwesome.fa_osu_osu_o; + case PlayMode.Taiko: return FontAwesome.fa_osu_taiko_o; + case PlayMode.Catch: return FontAwesome.fa_osu_fruits_o; + case PlayMode.Mania: return FontAwesome.fa_osu_mania_o; + } } public override void Load() { base.Load(); - Icon.TextSize = height * 0.7f; + DrawableIcon.TextSize = height * 0.7f; } } public class ToolbarButton : FlowContainer { - public TextAwesome Icon; - public SpriteText Text; - private Box background; + public FontAwesome Icon + { + get { return DrawableIcon.Icon; } + set { DrawableIcon.Icon = value; } + } + + public string Text + { + get { return DrawableText.Text; } + set + { + DrawableText.Text = value; + paddingIcon.Alpha = string.IsNullOrEmpty(value) ? 0 : 1; + } + } + + public Action Action; + + protected TextAwesome DrawableIcon; + protected SpriteText DrawableText; + protected Box Background; + protected Box HoverBackground; private Drawable paddingLeft; private Drawable paddingRight; private Drawable paddingIcon; @@ -97,44 +196,60 @@ namespace osu.Game.Overlays } } - public ToolbarButton(FontAwesome icon, string text = null) + public ToolbarButton() { - background = new Box + Background = new Box { RelativeSizeAxes = Axes.Both, Colour = new Color4(20, 20, 20, 140), }; - this.Icon = new TextAwesome() + HoverBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Additive = true, + Colour = new Color4(20, 20, 20, 0), + Alpha = 0, + }; + + DrawableIcon = new TextAwesome() { - Icon = icon, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }; - this.Text = new SpriteText + DrawableText = new SpriteText { - Text = text, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }; paddingLeft = new Container { RelativeSizeAxes = Axes.Y }; paddingRight = new Container { RelativeSizeAxes = Axes.Y }; - paddingIcon = new Container { Size = new Vector2(string.IsNullOrEmpty(text) ? 0 : 5, 0) }; + paddingIcon = new Container + { + Size = new Vector2(5, 0), + Alpha = 0 + }; Padding = 10; } + protected override bool OnClick(InputState state) + { + Action?.Invoke(); + return base.OnClick(state); + } + protected override bool OnHover(InputState state) { - background.FadeColour(new Color4(130, 130, 130, 160), 100); + HoverBackground.FadeTo(0.4f, 200); return base.OnHover(state); } protected override void OnHoverLost(InputState state) { - background.FadeColour(new Color4(20, 20, 20, 140), 100); + HoverBackground.FadeTo(0, 200); base.OnHoverLost(state); } @@ -147,11 +262,12 @@ namespace osu.Game.Overlays Children = new Drawable[] { - background, + Background, + HoverBackground, paddingLeft, - Icon, + DrawableIcon, paddingIcon, - Text, + DrawableText, paddingRight, }; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 513a101744..d0143ac3da 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -81,6 +81,7 @@ + From c2d4672b8deadc8ddfc471b31cada648cbf837ed Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Oct 2016 19:40:56 +0900 Subject: [PATCH 04/46] Add osu! prefix to mode descriptions. --- osu.Game/GameModes/Play/PlayMode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/GameModes/Play/PlayMode.cs b/osu.Game/GameModes/Play/PlayMode.cs index bf7c141ca4..8234baa523 100644 --- a/osu.Game/GameModes/Play/PlayMode.cs +++ b/osu.Game/GameModes/Play/PlayMode.cs @@ -10,11 +10,11 @@ namespace osu.Game.GameModes.Play { [Description(@"osu!")] Osu = 0, - [Description(@"taiko")] + [Description(@"osu!taiko")] Taiko = 1, - [Description(@"catch")] + [Description(@"osu!catch")] Catch = 2, - [Description(@"mania")] + [Description(@"osu!mania")] Mania = 3 } } From cc525805685536e51e5cfd305c3cd0ff3b23da44 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Oct 2016 19:41:18 +0900 Subject: [PATCH 05/46] Implement mode selector highlight line. --- osu.Game/Overlays/Toolbar.cs | 201 ++--------------------- osu.Game/Overlays/ToolbarButton.cs | 177 ++++++++++++++++++++ osu.Game/Overlays/ToolbarModeButton.cs | 51 ++++++ osu.Game/Overlays/ToolbarModeSelector.cs | 105 ++++++++++++ osu.Game/osu.Game.csproj | 3 + 5 files changed, 348 insertions(+), 189 deletions(-) create mode 100644 osu.Game/Overlays/ToolbarButton.cs create mode 100644 osu.Game/Overlays/ToolbarModeButton.cs create mode 100644 osu.Game/Overlays/ToolbarModeSelector.cs diff --git a/osu.Game/Overlays/Toolbar.cs b/osu.Game/Overlays/Toolbar.cs index b953f455e9..569de8d208 100644 --- a/osu.Game/Overlays/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar.cs @@ -17,17 +17,17 @@ using osu.Framework.Extensions; namespace osu.Game.Overlays { - public class Toolbar : Container + public partial class Toolbar : Container { const float height = 50; private FlowContainer leftFlow; private FlowContainer rightFlow; - private FlowContainer modeButtons; public Action OnSettings; public Action OnHome; public Action OnPlayModeChange; + private ToolbarModeSelector modeSelector; public override void Load() { @@ -36,51 +36,35 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.X; Size = new Vector2(1, height); - modeButtons = new FlowContainer - { - RelativeSizeAxes = Axes.Y, - Direction = FlowDirection.HorizontalOnly - }; - - foreach (PlayMode m in Enum.GetValues(typeof(PlayMode))) - { - var localMode = m; - modeButtons.Add(new ToolbarModeButton - { - Mode = m, - Action = delegate - { - SetGameMode(localMode); - OnPlayModeChange?.Invoke(localMode); - } - }); - } - - Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, - Colour = new Color4(0.1f, 0.1f, 0.1f, 0.9f) + Colour = new Color4(0.1f, 0.1f, 0.1f, 0.4f) }, leftFlow = new FlowContainer { Direction = FlowDirection.HorizontalOnly, RelativeSizeAxes = Axes.Y, - Children = new [] + Children = new Drawable[] { new ToolbarButton { Icon = FontAwesome.gear, - Action = OnSettings + Action = OnSettings, + TooltipMain = "Settings" }, new ToolbarButton { Icon = FontAwesome.home, + TooltipMain = "Home", Action = OnHome }, - modeButtons + modeSelector = new ToolbarModeSelector + { + OnPlayModeChange = this.OnPlayModeChange + } } }, rightFlow = new FlowContainer @@ -110,167 +94,6 @@ namespace osu.Game.Overlays }; } - public void SetGameMode(PlayMode mode) - { - foreach (var m in modeButtons.Children.Cast()) - { - m.Active = m.Mode == mode; - } - } - - public class ToolbarModeButton : ToolbarButton - { - private PlayMode mode; - public PlayMode Mode - { - get { return mode; } - set - { - mode = value; - Text = mode.GetDescription(); - Icon = getModeIcon(mode); - } - } - - public bool Active - { - set - { - Background.Colour = value ? new Color4(100, 100, 100, 140) : new Color4(20, 20, 20, 140); - } - } - - private FontAwesome getModeIcon(PlayMode mode) - { - switch (mode) - { - default: return FontAwesome.fa_osu_osu_o; - case PlayMode.Taiko: return FontAwesome.fa_osu_taiko_o; - case PlayMode.Catch: return FontAwesome.fa_osu_fruits_o; - case PlayMode.Mania: return FontAwesome.fa_osu_mania_o; - } - } - - public override void Load() - { - base.Load(); - DrawableIcon.TextSize = height * 0.7f; - } - } - - public class ToolbarButton : FlowContainer - { - public FontAwesome Icon - { - get { return DrawableIcon.Icon; } - set { DrawableIcon.Icon = value; } - } - - public string Text - { - get { return DrawableText.Text; } - set - { - DrawableText.Text = value; - paddingIcon.Alpha = string.IsNullOrEmpty(value) ? 0 : 1; - } - } - - public Action Action; - - protected TextAwesome DrawableIcon; - protected SpriteText DrawableText; - protected Box Background; - protected Box HoverBackground; - private Drawable paddingLeft; - private Drawable paddingRight; - private Drawable paddingIcon; - - public new float Padding - { - get { return paddingLeft.Size.X; } - set - { - paddingLeft.Size = new Vector2(value, 1); - paddingRight.Size = new Vector2(value, 1); - } - } - - public ToolbarButton() - { - Background = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = new Color4(20, 20, 20, 140), - }; - - HoverBackground = new Box - { - RelativeSizeAxes = Axes.Both, - Additive = true, - Colour = new Color4(20, 20, 20, 0), - Alpha = 0, - }; - - DrawableIcon = new TextAwesome() - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - }; - - DrawableText = new SpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - }; - - paddingLeft = new Container { RelativeSizeAxes = Axes.Y }; - paddingRight = new Container { RelativeSizeAxes = Axes.Y }; - paddingIcon = new Container - { - Size = new Vector2(5, 0), - Alpha = 0 - }; - - Padding = 10; - } - - protected override bool OnClick(InputState state) - { - Action?.Invoke(); - return base.OnClick(state); - } - - protected override bool OnHover(InputState state) - { - HoverBackground.FadeTo(0.4f, 200); - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - HoverBackground.FadeTo(0, 200); - base.OnHoverLost(state); - } - - public override void Load() - { - base.Load(); - - RelativeSizeAxes = Axes.Y; - Direction = FlowDirection.HorizontalOnly; - - Children = new Drawable[] - { - Background, - HoverBackground, - paddingLeft, - DrawableIcon, - paddingIcon, - DrawableText, - paddingRight, - }; - } - } + public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode); } } diff --git a/osu.Game/Overlays/ToolbarButton.cs b/osu.Game/Overlays/ToolbarButton.cs new file mode 100644 index 0000000000..8a09747ee6 --- /dev/null +++ b/osu.Game/Overlays/ToolbarButton.cs @@ -0,0 +1,177 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Overlays +{ + public class ToolbarButton : Container + { + public const float WIDTH = 60; + + public FontAwesome Icon + { + get { return DrawableIcon.Icon; } + set { DrawableIcon.Icon = value; } + } + + public string Text + { + get { return DrawableText.Text; } + set + { + DrawableText.Text = value; + paddingIcon.Alpha = string.IsNullOrEmpty(value) ? 0 : 1; + } + } + + public string TooltipMain + { + get { return tooltip1.Text; } + set + { + tooltip1.Text = value; + } + } + + public string TooltipSub + { + get { return tooltip2.Text; } + set + { + tooltip2.Text = value; + } + } + + public Action Action; + protected TextAwesome DrawableIcon; + protected SpriteText DrawableText; + protected Box HoverBackground; + private Drawable paddingLeft; + private Drawable paddingRight; + private Drawable paddingIcon; + private FlowContainer tooltipContainer; + private SpriteText tooltip1; + private SpriteText tooltip2; + + public new float Padding + { + get { return paddingLeft.Size.X; } + set + { + paddingLeft.Size = new Vector2(value, 1); + paddingRight.Size = new Vector2(value, 1); + tooltipContainer.Position = new Vector2(value, tooltipContainer.Position.Y); + } + } + + public ToolbarButton() + { + HoverBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Additive = true, + Colour = new Color4(60, 60, 60, 255), + Alpha = 0, + }; + + DrawableIcon = new TextAwesome + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }; + + DrawableText = new SpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }; + + tooltipContainer = new FlowContainer + { + Direction = FlowDirection.VerticalOnly, + Anchor = Anchor.BottomLeft, + Position = new Vector2(0, -5), + Alpha = 0, + Children = new[] + { + tooltip1 = new SpriteText() + { + TextSize = 22, + }, + tooltip2 = new SpriteText + { + TextSize = 15 + } + } + }; + + paddingLeft = new Container { RelativeSizeAxes = Axes.Y }; + paddingRight = new Container { RelativeSizeAxes = Axes.Y }; + paddingIcon = new Container + { + Size = new Vector2(5, 0), + Alpha = 0 + }; + + Padding = 10; + RelativeSizeAxes = Axes.Y; + Size = new Vector2(WIDTH, 1); + } + + public override void Load() + { + base.Load(); + + Children = new Drawable[] + { + HoverBackground, + new FlowContainer + { + Direction = FlowDirection.HorizontalOnly, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.Y, + Children = new Drawable[] + { + paddingLeft, + DrawableIcon, + paddingIcon, + DrawableText, + paddingRight + }, + }, + tooltipContainer + }; + } + + protected override bool OnClick(InputState state) + { + Action?.Invoke(); + HoverBackground.FlashColour(Color4.White, 400); + return base.OnClick(state); + } + + protected override bool OnHover(InputState state) + { + HoverBackground.FadeTo(0.4f, 200); + tooltipContainer.FadeIn(100); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + HoverBackground.FadeTo(0, 200); + tooltipContainer.FadeOut(100); + base.OnHoverLost(state); + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/ToolbarModeButton.cs b/osu.Game/Overlays/ToolbarModeButton.cs new file mode 100644 index 0000000000..a8519e3436 --- /dev/null +++ b/osu.Game/Overlays/ToolbarModeButton.cs @@ -0,0 +1,51 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Extensions; +using osu.Game.GameModes.Play; +using osu.Game.Graphics; +using OpenTK.Graphics; + +namespace osu.Game.Overlays +{ + public class ToolbarModeButton : ToolbarButton + { + private PlayMode mode; + public PlayMode Mode + { + get { return mode; } + set + { + mode = value; + TooltipMain = mode.GetDescription(); + TooltipSub = $"Play some {mode.GetDescription()}"; + Icon = getModeIcon(mode); + } + } + + public bool Active + { + set + { + //Background.Colour = value ? new Color4(100, 100, 100, 255) : new Color4(20, 20, 20, 255); + } + } + + private FontAwesome getModeIcon(PlayMode mode) + { + switch (mode) + { + default: return FontAwesome.fa_osu_osu_o; + case PlayMode.Taiko: return FontAwesome.fa_osu_taiko_o; + case PlayMode.Catch: return FontAwesome.fa_osu_fruits_o; + case PlayMode.Mania: return FontAwesome.fa_osu_mania_o; + } + } + + public override void Load() + { + base.Load(); + DrawableIcon.TextSize *= 1.4f; + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/ToolbarModeSelector.cs b/osu.Game/Overlays/ToolbarModeSelector.cs new file mode 100644 index 0000000000..8dbd5e5f2f --- /dev/null +++ b/osu.Game/Overlays/ToolbarModeSelector.cs @@ -0,0 +1,105 @@ +//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.Framework.Cached; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Transformations; +using osu.Game.GameModes.Play; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Overlays +{ + class ToolbarModeSelector : Container + { + const float padding = 10; + + private FlowContainer modeButtons; + private Box modeButtonLine; + private ToolbarModeButton activeButton; + + public Action OnPlayModeChange; + + + public ToolbarModeSelector() + { + RelativeSizeAxes = Axes.Y; + } + + public override void Load() + { + base.Load(); + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(20, 20, 20, 255) + }, + modeButtons = new FlowContainer + { + RelativeSizeAxes = Axes.Y, + Direction = FlowDirection.HorizontalOnly, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }, + modeButtonLine = new Box + { + RelativeSizeAxes = Axes.X, + Size = new Vector2(0.3f, 3), + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopCentre, + Colour = Color4.White + } + }; + + foreach (PlayMode m in Enum.GetValues(typeof(PlayMode))) + { + var localMode = m; + modeButtons.Add(new ToolbarModeButton + { + Mode = m, + Action = delegate + { + SetGameMode(localMode); + OnPlayModeChange?.Invoke(localMode); + } + }); + } + + RelativeSizeAxes = Axes.Y; + Size = new Vector2(modeButtons.Children.Count() * ToolbarButton.WIDTH + padding * 2, 1); + } + + public void SetGameMode(PlayMode mode) + { + foreach (ToolbarModeButton m in modeButtons.Children.Cast()) + { + bool isActive = m.Mode == mode; + m.Active = isActive; + if (isActive) + activeButton = m; + } + + activeMode.Invalidate(); + } + + Cached activeMode = new Cached(); + + protected override void UpdateLayout() + { + base.UpdateLayout(); + + if (!activeMode.EnsureValid()) + activeMode.Refresh(() => modeButtonLine.MoveToX(activeButton.Position.X + activeButton.Size.X / 2 + padding, 200, EasingTypes.OutQuint)); + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d0143ac3da..8ef0f07fa7 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -120,6 +120,9 @@ + + + From 836083667f20a3fa6e6f07ac43b99739fd6a4b75 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Oct 2016 19:57:32 +0900 Subject: [PATCH 06/46] Clean up a bit. --- osu.Game/Overlays/Toolbar.cs | 19 +++++++------------ osu.Game/Overlays/ToolbarModeSelector.cs | 6 +----- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/osu.Game/Overlays/Toolbar.cs b/osu.Game/Overlays/Toolbar.cs index 569de8d208..f30105beab 100644 --- a/osu.Game/Overlays/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar.cs @@ -7,21 +7,15 @@ using osu.Framework.Graphics.Drawables; using OpenTK; using OpenTK.Graphics; using osu.Game.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; using osu.Game.Configuration; using System; -using System.Linq; using osu.Game.GameModes.Play; -using osu.Framework.Extensions; namespace osu.Game.Overlays { - public partial class Toolbar : Container + public class Toolbar : Container { const float height = 50; - private FlowContainer leftFlow; - private FlowContainer rightFlow; public Action OnSettings; public Action OnHome; @@ -43,7 +37,7 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both, Colour = new Color4(0.1f, 0.1f, 0.1f, 0.4f) }, - leftFlow = new FlowContainer + new FlowContainer { Direction = FlowDirection.HorizontalOnly, RelativeSizeAxes = Axes.Y, @@ -53,27 +47,28 @@ namespace osu.Game.Overlays { Icon = FontAwesome.gear, Action = OnSettings, - TooltipMain = "Settings" + TooltipMain = "Settings", + TooltipSub = "Change your settings", }, new ToolbarButton { Icon = FontAwesome.home, TooltipMain = "Home", + TooltipSub = "Return to the main menu", Action = OnHome }, modeSelector = new ToolbarModeSelector { - OnPlayModeChange = this.OnPlayModeChange + OnPlayModeChange = OnPlayModeChange } } }, - rightFlow = new FlowContainer + new FlowContainer { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Direction = FlowDirection.HorizontalOnly, RelativeSizeAxes = Axes.Y, - Size = new Vector2(0, 1), Children = new [] { new ToolbarButton diff --git a/osu.Game/Overlays/ToolbarModeSelector.cs b/osu.Game/Overlays/ToolbarModeSelector.cs index 8dbd5e5f2f..c429dd5a24 100644 --- a/osu.Game/Overlays/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/ToolbarModeSelector.cs @@ -2,10 +2,7 @@ //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.Framework.Cached; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -27,7 +24,6 @@ namespace osu.Game.Overlays public Action OnPlayModeChange; - public ToolbarModeSelector() { RelativeSizeAxes = Axes.Y; @@ -92,7 +88,7 @@ namespace osu.Game.Overlays activeMode.Invalidate(); } - Cached activeMode = new Cached(); + private Cached activeMode = new Cached(); protected override void UpdateLayout() { From 3891f467a34562d2d921fe996654802d0b29ab0b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Oct 2016 20:00:55 +0900 Subject: [PATCH 07/46] Fix being able to click two toolbar buttons at once. --- osu.Game/Overlays/ToolbarButton.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/ToolbarButton.cs b/osu.Game/Overlays/ToolbarButton.cs index 8a09747ee6..46e99f2699 100644 --- a/osu.Game/Overlays/ToolbarButton.cs +++ b/osu.Game/Overlays/ToolbarButton.cs @@ -157,21 +157,20 @@ namespace osu.Game.Overlays { Action?.Invoke(); HoverBackground.FlashColour(Color4.White, 400); - return base.OnClick(state); + return true; } protected override bool OnHover(InputState state) { HoverBackground.FadeTo(0.4f, 200); tooltipContainer.FadeIn(100); - return base.OnHover(state); + return true; } protected override void OnHoverLost(InputState state) { HoverBackground.FadeTo(0, 200); tooltipContainer.FadeOut(100); - base.OnHoverLost(state); } } } \ No newline at end of file From a768e4ec16b7d1bf4c8be14d2b8d5d779adbc1e4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Oct 2016 03:27:29 +0900 Subject: [PATCH 08/46] Framework update. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 4d78fdfbe0..7c15499b5e 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 4d78fdfbe01e3ecb213c19a3f3243c80a71bb668 +Subproject commit 7c15499b5ef49bed580b2ee851952826b9c5d39a From 03aea04a00b3a0350ad2fd17d9061436be14ba28 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Oct 2016 16:35:10 +0900 Subject: [PATCH 09/46] Add BackgroundMode stack. --- osu.Game/GameModes/BackgroundMode.cs | 97 ++++++++++++++++++++++ osu.Game/GameModes/GameModeWhiteBox.cs | 42 ++++++---- osu.Game/GameModes/Menu/MainMenu.cs | 17 ++-- osu.Game/GameModes/OsuGameMode.cs | 72 ++++++++++++++++ osu.Game/Graphics/Background/Background.cs | 8 +- osu.Game/OsuGame.cs | 6 -- osu.Game/osu.Game.csproj | 2 + 7 files changed, 216 insertions(+), 28 deletions(-) create mode 100644 osu.Game/GameModes/BackgroundMode.cs create mode 100644 osu.Game/GameModes/OsuGameMode.cs diff --git a/osu.Game/GameModes/BackgroundMode.cs b/osu.Game/GameModes/BackgroundMode.cs new file mode 100644 index 0000000000..bb478dbe7d --- /dev/null +++ b/osu.Game/GameModes/BackgroundMode.cs @@ -0,0 +1,97 @@ +//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.Framework.GameModes; +using osu.Framework.Graphics.Transformations; +using osu.Game.Graphics.Background; +using OpenTK; + +namespace osu.Game.GameModes +{ + public abstract class BackgroundMode : GameMode, IEquatable + { + public virtual bool Equals(BackgroundMode other) + { + return other?.GetType() == GetType(); + } + + const float transition_length = 500; + const float x_movement_amount = 50; + + public override void Load() + { + base.Load(); + + Content.Scale *= 1 + (x_movement_amount / Size.X) * 2; + } + + protected override void OnEntering(GameMode last) + { + Content.FadeOut(); + Content.MoveToX(x_movement_amount); + + Content.FadeIn(transition_length, EasingTypes.InOutQuart); + Content.MoveToX(0, transition_length, EasingTypes.InOutQuart); + + base.OnEntering(last); + } + + protected override void OnSuspending(GameMode next) + { + Content.MoveToX(-x_movement_amount, transition_length, EasingTypes.InOutQuart); + base.OnSuspending(next); + } + + protected override void OnExiting(GameMode next) + { + Content.FadeOut(transition_length, EasingTypes.OutExpo); + Content.MoveToX(x_movement_amount, transition_length, EasingTypes.OutExpo); + + base.OnExiting(next); + } + + protected override void OnResuming(GameMode last) + { + Content.MoveToX(0, transition_length, EasingTypes.OutExpo); + base.OnResuming(last); + } + } + + public class BackgroundModeDefault : BackgroundMode + { + public override void Load() + { + base.Load(); + + Add(new Background()); + } + } + + public class BackgroundModeCustom : BackgroundMode + { + private readonly string textureName; + + public BackgroundModeCustom(string textureName) + { + this.textureName = textureName; + } + + public override void Load() + { + base.Load(); + + Add(new Background(textureName)); + } + + public override bool Equals(BackgroundMode other) + { + return base.Equals(other) && textureName == ((BackgroundModeCustom)other).textureName; + } + + } +} diff --git a/osu.Game/GameModes/GameModeWhiteBox.cs b/osu.Game/GameModes/GameModeWhiteBox.cs index 4bca922b22..a36c46885c 100644 --- a/osu.Game/GameModes/GameModeWhiteBox.cs +++ b/osu.Game/GameModes/GameModeWhiteBox.cs @@ -15,7 +15,7 @@ using OpenTK.Graphics; namespace osu.Game.GameModes { - public class GameModeWhiteBox : GameMode + public class GameModeWhiteBox : OsuGameMode { private Button popButton; @@ -25,9 +25,14 @@ namespace osu.Game.GameModes private FlowContainer childModeButtons; private Container textContainer; + private Box box; - protected override double OnEntering(GameMode last) + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Menu/songselect"); + + protected override void OnEntering(GameMode last) { + base.OnEntering(last); + //only show the pop button if we are entered form another gamemode. if (last != null) popButton.Alpha = 1; @@ -35,31 +40,40 @@ namespace osu.Game.GameModes Content.Alpha = 0; textContainer.Position = new Vector2(Size.X / 16, 0); - Content.Delay(300); + box.ScaleTo(0.2f); + box.RotateTo(-20); + + Content.Delay(300, true); + + box.ScaleTo(1, transition_time, EasingTypes.OutElastic); + box.RotateTo(0, transition_time / 2, EasingTypes.OutQuint); + textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo); Content.FadeIn(transition_time, EasingTypes.OutExpo); - return 0;// transition_time * 1000; } - protected override double OnExiting(GameMode next) + protected override void OnExiting(GameMode next) { + base.OnExiting(next); + textContainer.MoveTo(new Vector2((Size.X / 16), 0), transition_time, EasingTypes.OutExpo); Content.FadeOut(transition_time, EasingTypes.OutExpo); - return transition_time; } - protected override double OnSuspending(GameMode next) + protected override void OnSuspending(GameMode next) { + base.OnSuspending(next); + textContainer.MoveTo(new Vector2(-(Size.X / 16), 0), transition_time, EasingTypes.OutExpo); Content.FadeOut(transition_time, EasingTypes.OutExpo); - return transition_time; } - protected override double OnResuming(GameMode last) + protected override void OnResuming(GameMode last) { + base.OnResuming(last); + textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo); Content.FadeIn(transition_time, EasingTypes.OutExpo); - return transition_time; } public override void Load() @@ -68,15 +82,15 @@ namespace osu.Game.GameModes Children = new Drawable[] { - new Box + box = new Box { RelativeSizeAxes = Axes.Both, - Size = new Vector2(0.7f), + Size = new Vector2(0.3f), Anchor = Anchor.Centre, Origin = Anchor.Centre, Colour = getColourFor(GetType()), - Alpha = 0.6f, - Additive = true + Alpha = 1, + Additive = false }, textContainer = new AutoSizeContainer { diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index fa99abed91..599639ca82 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -17,13 +17,17 @@ using OpenTK; namespace osu.Game.GameModes.Menu { - public class MainMenu : GameMode + public class MainMenu : OsuGameMode { private ButtonSystem buttons; public override string Name => @"Main Menu"; + protected override bool IsTopLevel => true; + //private AudioTrack bgm; + protected override BackgroundMode CreateBackground() => new BackgroundModeDefault(); + public override void Load() { base.Load(); @@ -64,27 +68,28 @@ namespace osu.Game.GameModes.Menu }; } - protected override double OnSuspending(GameMode next) + protected override void OnSuspending(GameMode next) { + base.OnSuspending(next); + const float length = 400; buttons.State = ButtonSystem.MenuState.EnteringMode; Content.FadeOut(length, EasingTypes.InSine); Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine); - - return base.OnSuspending(next); } - protected override double OnResuming(GameMode last) + protected override void OnResuming(GameMode last) { + base.OnResuming(last); + const float length = 300; buttons.State = ButtonSystem.MenuState.TopLevel; Content.FadeIn(length, EasingTypes.OutQuint); Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint); - return base.OnResuming(last); } } } diff --git a/osu.Game/GameModes/OsuGameMode.cs b/osu.Game/GameModes/OsuGameMode.cs new file mode 100644 index 0000000000..a0ac4d4567 --- /dev/null +++ b/osu.Game/GameModes/OsuGameMode.cs @@ -0,0 +1,72 @@ +//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.Framework.GameModes; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Background; + +namespace osu.Game.GameModes +{ + public class OsuGameMode : GameMode + { + internal BackgroundMode Background { get; private set; } + + /// + /// Override to create a BackgroundMode for the current GameMode. + /// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause. + /// + protected virtual BackgroundMode CreateBackground() => null; + + protected override void OnEntering(GameMode last) + { + OsuGameMode lastOsu = last as OsuGameMode; + + BackgroundMode bg = CreateBackground(); + + if (lastOsu?.Background != null) + { + if (bg == null || lastOsu.Background.Equals(bg)) + //we can keep the previous mode's background. + Background = lastOsu.Background; + else + { + lastOsu.Background.Push(Background = bg); + } + } + else if (bg != null) + { + bg.Depth = float.MinValue; + AddTopLevel(Background = bg); + } + + + base.OnEntering(last); + } + + protected override void OnExiting(GameMode next) + { + OsuGameMode nextOsu = next as OsuGameMode; + + if (Background != null && !Background.Equals(nextOsu?.Background)) + Background.Exit(); + + base.OnExiting(next); + } + + protected override void OnResuming(GameMode last) + { + base.OnResuming(last); + } + + protected override void OnSuspending(GameMode next) + { + base.OnSuspending(next); + } + + } +} diff --git a/osu.Game/Graphics/Background/Background.cs b/osu.Game/Graphics/Background/Background.cs index f9bcc0bd15..b9e975f5db 100644 --- a/osu.Game/Graphics/Background/Background.cs +++ b/osu.Game/Graphics/Background/Background.cs @@ -15,9 +15,13 @@ namespace osu.Game.Graphics.Background { protected Sprite BackgroundSprite; - public Background() + string textureName; + + public Background(string textureName = @"Menu/background") { + this.textureName = textureName; RelativeSizeAxes = Axes.Both; + Depth = float.MinValue; } public override void Load() @@ -26,7 +30,7 @@ namespace osu.Game.Graphics.Background Add(BackgroundSprite = new Sprite { - Texture = Game.Textures.Get(@"Menu/background"), + Texture = Game.Textures.Get(textureName), Anchor = Anchor.Centre, Origin = Anchor.Centre, Colour = Color4.DarkGray diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 4148854513..27b474bb82 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -34,12 +34,6 @@ namespace osu.Game base.Load(); Add(new Drawable[] { - new ParallaxContainer - { - Children = new [] { - new Background() - } - }, MainMenu = new MainMenu(), Toolbar = new Toolbar { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 8ef0f07fa7..806420e26c 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -69,6 +69,7 @@ + @@ -78,6 +79,7 @@ + From 698c1ef1ae8b75bdb3dd2c9f6545a3a92158ee0a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Oct 2016 18:16:16 +0900 Subject: [PATCH 10/46] Fix width of toolbar buttons with text. --- osu.Game/Overlays/ToolbarButton.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game/Overlays/ToolbarButton.cs b/osu.Game/Overlays/ToolbarButton.cs index 46e99f2699..815f31590b 100644 --- a/osu.Game/Overlays/ToolbarButton.cs +++ b/osu.Game/Overlays/ToolbarButton.cs @@ -153,6 +153,14 @@ namespace osu.Game.Overlays }; } + protected override void Update() + { + base.Update(); + + //todo: find a way to avoid using this (autosize needs to be able to ignore certain drawables.. in this case the tooltip) + Size = new Vector2(WIDTH + DrawableText.Size.X, 1); + } + protected override bool OnClick(InputState state) { Action?.Invoke(); From 4eb310c3a58b8d2a56f5584c5963f61876e59afe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Oct 2016 18:16:42 +0900 Subject: [PATCH 11/46] Remove unused button state. --- osu.Game/GameModes/BackgroundMode.cs | 2 -- osu.Game/GameModes/Menu/ButtonSystem.cs | 6 ------ 2 files changed, 8 deletions(-) diff --git a/osu.Game/GameModes/BackgroundMode.cs b/osu.Game/GameModes/BackgroundMode.cs index bb478dbe7d..e8c25d3f82 100644 --- a/osu.Game/GameModes/BackgroundMode.cs +++ b/osu.Game/GameModes/BackgroundMode.cs @@ -84,7 +84,6 @@ namespace osu.Game.GameModes public override void Load() { base.Load(); - Add(new Background(textureName)); } @@ -92,6 +91,5 @@ namespace osu.Game.GameModes { return base.Equals(other) && textureName == ((BackgroundModeCustom)other).textureName; } - } } diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 0b01965394..bbf6f40a02 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -632,9 +632,6 @@ namespace osu.Game.GameModes.Menu FadeOut(800); break; } - break; - case ButtonState.Contracted2: - break; case ButtonState.Expanded: const int expand_duration = 500; @@ -647,15 +644,12 @@ namespace osu.Game.GameModes.Menu FadeOut(explode_duration / 4 * 3); break; } - - } } public enum ButtonState { Contracted, - Contracted2, Expanded, Exploded } From c0f25a26834b26e380b0a15ba5a478b6a646ea58 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Oct 2016 20:03:52 +0900 Subject: [PATCH 12/46] Improve white-boxed game modes. --- osu-resources | 2 +- .../{SongSelectEdit.cs => EditSongSelect.cs} | 4 +++- osu.Game/GameModes/Edit/Editor.cs | 15 +++++++++++++++ osu.Game/GameModes/GameModeWhiteBox.cs | 2 +- osu.Game/GameModes/Menu/MainMenu.cs | 4 ++-- osu.Game/GameModes/Multiplayer/Match.cs | 16 ++++++++++++++++ .../GameModes/Multiplayer/MatchSongSelect.cs | 3 +++ osu.Game/GameModes/OsuGameMode.cs | 11 +++++++++-- osu.Game/GameModes/Play/ModSelect.cs | 15 +++++++++++++++ .../{SongSelectPlay.cs => PlaySongSelect.cs} | 4 +++- osu.Game/GameModes/Play/Player.cs | 2 ++ osu.Game/GameModes/Play/Results.cs | 15 +++++++++++++++ osu.Game/Graphics/Background/Background.cs | 2 +- osu.Game/osu.Game.csproj | 4 ++-- 14 files changed, 88 insertions(+), 11 deletions(-) rename osu.Game/GameModes/Edit/{SongSelectEdit.cs => EditSongSelect.cs} (68%) rename osu.Game/GameModes/Play/{SongSelectPlay.cs => PlaySongSelect.cs} (69%) diff --git a/osu-resources b/osu-resources index cc107f9bcf..6d9bbe6c83 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit cc107f9bcfc8efeeff88f19c2df8cec9755eda39 +Subproject commit 6d9bbe6c838e4b89b69d5ad49b37b434aa62281e diff --git a/osu.Game/GameModes/Edit/SongSelectEdit.cs b/osu.Game/GameModes/Edit/EditSongSelect.cs similarity index 68% rename from osu.Game/GameModes/Edit/SongSelectEdit.cs rename to osu.Game/GameModes/Edit/EditSongSelect.cs index a6c0f9fdf5..3578aecb35 100644 --- a/osu.Game/GameModes/Edit/SongSelectEdit.cs +++ b/osu.Game/GameModes/Edit/EditSongSelect.cs @@ -6,10 +6,12 @@ using System.Collections.Generic; namespace osu.Game.GameModes.Edit { - class SongSelectEdit : GameModeWhiteBox + class EditSongSelect : GameModeWhiteBox { protected override IEnumerable PossibleChildren => new[] { typeof(Editor) }; + + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); } } diff --git a/osu.Game/GameModes/Edit/Editor.cs b/osu.Game/GameModes/Edit/Editor.cs index 779aa105f9..c7027a9479 100644 --- a/osu.Game/GameModes/Edit/Editor.cs +++ b/osu.Game/GameModes/Edit/Editor.cs @@ -6,10 +6,25 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.GameModes; +using OpenTK.Graphics; namespace osu.Game.GameModes.Edit { class Editor : GameModeWhiteBox { + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + + protected override void OnEntering(GameMode last) + { + base.OnEntering(last); + Background.FadeColour(Color4.DarkGray, 500); + } + + protected override void OnExiting(GameMode next) + { + base.OnExiting(next); + Background.FadeColour(Color4.White, 500); + } } } diff --git a/osu.Game/GameModes/GameModeWhiteBox.cs b/osu.Game/GameModes/GameModeWhiteBox.cs index a36c46885c..4eb8945f04 100644 --- a/osu.Game/GameModes/GameModeWhiteBox.cs +++ b/osu.Game/GameModes/GameModeWhiteBox.cs @@ -27,7 +27,7 @@ namespace osu.Game.GameModes private Container textContainer; private Box box; - protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Menu/songselect"); + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg2"); protected override void OnEntering(GameMode last) { diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index 599639ca82..a5122d1d7b 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -50,8 +50,8 @@ namespace osu.Game.GameModes.Menu { OnChart = delegate { Push(new ChartListing()); }, OnDirect = delegate { Push(new OnlineListing()); }, - OnEdit = delegate { Push(new SongSelectEdit()); }, - OnSolo = delegate { Push(new SongSelectPlay()); }, + OnEdit = delegate { Push(new EditSongSelect()); }, + OnSolo = delegate { Push(new PlaySongSelect()); }, OnMulti = delegate { Push(new Lobby()); }, OnTest = delegate { Push(new TestBrowser()); }, OnExit = delegate { diff --git a/osu.Game/GameModes/Multiplayer/Match.cs b/osu.Game/GameModes/Multiplayer/Match.cs index e8a476a37d..5e31976764 100644 --- a/osu.Game/GameModes/Multiplayer/Match.cs +++ b/osu.Game/GameModes/Multiplayer/Match.cs @@ -6,7 +6,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.GameModes; using osu.Game.GameModes.Play; +using OpenTK.Graphics; namespace osu.Game.GameModes.Multiplayer { @@ -16,5 +18,19 @@ namespace osu.Game.GameModes.Multiplayer typeof(MatchSongSelect), typeof(Player), }; + + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + + protected override void OnEntering(GameMode last) + { + base.OnEntering(last); + Background.FadeColour(Color4.DarkGray, 500); + } + + protected override void OnExiting(GameMode next) + { + base.OnExiting(next); + Background.FadeColour(Color4.White, 500); + } } } diff --git a/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs b/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs index f58ce5f7d1..eebf8868e8 100644 --- a/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs +++ b/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs @@ -6,10 +6,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.GameModes; +using OpenTK.Graphics; namespace osu.Game.GameModes.Multiplayer { class MatchSongSelect : GameModeWhiteBox { + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); } } diff --git a/osu.Game/GameModes/OsuGameMode.cs b/osu.Game/GameModes/OsuGameMode.cs index a0ac4d4567..ad4a5b416b 100644 --- a/osu.Game/GameModes/OsuGameMode.cs +++ b/osu.Game/GameModes/OsuGameMode.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using osu.Framework.GameModes; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Background; +using osu.Game.Graphics.Containers; namespace osu.Game.GameModes { @@ -40,8 +41,14 @@ namespace osu.Game.GameModes } else if (bg != null) { - bg.Depth = float.MinValue; - AddTopLevel(Background = bg); + AddTopLevel(new ParallaxContainer + { + Depth = float.MinValue, + Children = new[] + { + Background = bg + } + }); } diff --git a/osu.Game/GameModes/Play/ModSelect.cs b/osu.Game/GameModes/Play/ModSelect.cs index 5254f9b1a0..e6db9dd60a 100644 --- a/osu.Game/GameModes/Play/ModSelect.cs +++ b/osu.Game/GameModes/Play/ModSelect.cs @@ -6,10 +6,25 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using OpenTK.Graphics; +using osu.Framework.GameModes; namespace osu.Game.GameModes.Play { class ModSelect : GameModeWhiteBox { + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + + protected override void OnEntering(GameMode last) + { + base.OnEntering(last); + Background.FadeColour(Color4.DarkGray, 500); + } + + protected override void OnExiting(GameMode next) + { + base.OnExiting(next); + Background.FadeColour(Color4.White, 500); + } } } diff --git a/osu.Game/GameModes/Play/SongSelectPlay.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs similarity index 69% rename from osu.Game/GameModes/Play/SongSelectPlay.cs rename to osu.Game/GameModes/Play/PlaySongSelect.cs index f2547a028b..6ac557534d 100644 --- a/osu.Game/GameModes/Play/SongSelectPlay.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -6,8 +6,10 @@ using System.Collections.Generic; namespace osu.Game.GameModes.Play { - class SongSelectPlay : GameModeWhiteBox + class PlaySongSelect : GameModeWhiteBox { + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + protected override IEnumerable PossibleChildren => new[] { typeof(ModSelect), typeof(Player) diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index 37663dbc2f..f73ac0506a 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -11,6 +11,8 @@ namespace osu.Game.GameModes.Play { class Player : GameModeWhiteBox { + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + protected override IEnumerable PossibleChildren => new[] { typeof(Results) }; diff --git a/osu.Game/GameModes/Play/Results.cs b/osu.Game/GameModes/Play/Results.cs index cbfe4f1c4b..18811fd4d1 100644 --- a/osu.Game/GameModes/Play/Results.cs +++ b/osu.Game/GameModes/Play/Results.cs @@ -6,10 +6,25 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.GameModes; +using OpenTK.Graphics; namespace osu.Game.GameModes.Play { class Results : GameModeWhiteBox { + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + + protected override void OnEntering(GameMode last) + { + base.OnEntering(last); + Background.FadeColour(Color4.DarkGray, 500); + } + + protected override void OnExiting(GameMode next) + { + base.OnExiting(next); + Background.FadeColour(Color4.White, 500); + } } } diff --git a/osu.Game/Graphics/Background/Background.cs b/osu.Game/Graphics/Background/Background.cs index b9e975f5db..8333d975f9 100644 --- a/osu.Game/Graphics/Background/Background.cs +++ b/osu.Game/Graphics/Background/Background.cs @@ -17,7 +17,7 @@ namespace osu.Game.Graphics.Background string textureName; - public Background(string textureName = @"Menu/background") + public Background(string textureName = @"Backgrounds/bg1") { this.textureName = textureName; RelativeSizeAxes = Axes.Both; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 806420e26c..5b9dacf34c 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -86,7 +86,7 @@ - + @@ -97,7 +97,7 @@ - + From b588f28856a574e0b8c1293a5f17737b20b64796 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Oct 2016 20:49:31 +0900 Subject: [PATCH 13/46] Make play modes display playfield. --- osu.Game/GameModes/Play/HitRenderer.cs | 8 ++- osu.Game/GameModes/Play/Player.cs | 79 +++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/osu.Game/GameModes/Play/HitRenderer.cs b/osu.Game/GameModes/Play/HitRenderer.cs index 4a03e7b060..6016c93a34 100644 --- a/osu.Game/GameModes/Play/HitRenderer.cs +++ b/osu.Game/GameModes/Play/HitRenderer.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Drawables; using osu.Game.Beatmaps.Objects; using OpenTK; +using OpenTK.Graphics; namespace osu.Game.GameModes.Play { @@ -24,7 +25,12 @@ namespace osu.Game.GameModes.Play { base.Load(); - Add(new Box() { RelativeSizeAxes = Axes.Both, Alpha = 0.1f, Scale = new Vector2(0.99f) }); + Add(new Box() + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.8f, + Colour = new Color4(5, 5, 5, 255), + }); } } } diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index f73ac0506a..26da692457 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -6,6 +6,17 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.Graphics; +using osu.Framework.MathUtils; +using osu.Framework.Timing; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Objects; +using osu.Game.Beatmaps.Objects.Osu; +using osu.Game.GameModes.Play.Catch; +using osu.Game.GameModes.Play.Mania; +using osu.Game.GameModes.Play.Osu; +using osu.Game.GameModes.Play.Taiko; +using OpenTK; namespace osu.Game.GameModes.Play { @@ -16,5 +27,71 @@ namespace osu.Game.GameModes.Play protected override IEnumerable PossibleChildren => new[] { typeof(Results) }; + + public override void Load() + { + base.Load(); + + List objects = new List(); + + double time = Time + 1000; + for (int i = 0; i < 100; i++) + { + objects.Add(new Circle() + { + StartTime = time, + Position = new Vector2(RNG.Next(0, 512), RNG.Next(0, 384)) + }); + + time += RNG.Next(50, 500); + } + + Beatmap beatmap = new Beatmap + { + HitObjects = objects + }; + + OsuGame osu = Game as OsuGame; + + switch (osu.PlayMode.Value) + { + case PlayMode.Osu: + Add(new OsuHitRenderer + { + Objects = beatmap.HitObjects, + Scale = new Vector2(0.8f), + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }); + break; + case PlayMode.Taiko: + Add(new TaikoHitRenderer + { + Objects = beatmap.HitObjects, + Scale = new Vector2(0.8f), + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }); + break; + case PlayMode.Catch: + Add(new CatchHitRenderer + { + Objects = beatmap.HitObjects, + Scale = new Vector2(0.8f), + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }); + break; + case PlayMode.Mania: + Add(new ManiaHitRenderer + { + Objects = beatmap.HitObjects, + Scale = new Vector2(0.8f), + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }); + break; + } + } } -} +} \ No newline at end of file From 2ca7a74e63a4edf51b493183676a9b3a65b85218 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 22:54:37 +0900 Subject: [PATCH 14/46] Bring framework up-to-date. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 7c15499b5e..db23910e6c 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 7c15499b5ef49bed580b2ee851952826b9c5d39a +Subproject commit db23910e6cbd14b321103811857a368db01b26b1 From 9ed4da556ee8e3b36862f3755350a4e54c0d1164 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 8 Oct 2016 15:50:46 +0900 Subject: [PATCH 15/46] Update framework version. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index db23910e6c..6b884e1b80 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit db23910e6cbd14b321103811857a368db01b26b1 +Subproject commit 6b884e1b80444c5249754634a4b5529c50b52934 From e5dc8bad2f464f322da41b0177661d3808dcadb6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Oct 2016 17:48:38 +0900 Subject: [PATCH 16/46] Bring up-to-date with latest framework. --- osu.Desktop.VisualTests/Program.cs | 2 +- osu.Desktop/Program.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Program.cs b/osu.Desktop.VisualTests/Program.cs index b8583229b8..43d79d92d2 100644 --- a/osu.Desktop.VisualTests/Program.cs +++ b/osu.Desktop.VisualTests/Program.cs @@ -13,7 +13,7 @@ namespace osu.Framework.VisualTests public static void Main(string[] args) { BasicGameHost host = Host.GetSuitableHost(); - host.Load(new VisualTestGame()); + host.Add(new VisualTestGame()); host.Run(); } } diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index 3f745f3b84..ca085e8648 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -14,7 +14,7 @@ namespace osu.Desktop public static void Main() { BasicGameHost host = Host.GetSuitableHost(); - host.Load(new OsuGame()); + host.Add(new OsuGame()); host.Run(); } } From 75c97a62e3a01f012286b95b95b08d5e3ee6e4e4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Oct 2016 17:44:13 +0900 Subject: [PATCH 17/46] Add main menu music back. --- osu.Game/GameModes/Menu/MainMenu.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index a5122d1d7b..b257e9996c 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -24,7 +24,7 @@ namespace osu.Game.GameModes.Menu protected override bool IsTopLevel => true; - //private AudioTrack bgm; + private AudioTrack bgm; protected override BackgroundMode CreateBackground() => new BackgroundModeDefault(); @@ -37,8 +37,10 @@ namespace osu.Game.GameModes.Menu AudioSample welcome = Game.Audio.Sample.Get(@"welcome"); welcome.Play(); - //bgm = Game.Audio.Track.Get(@"circles"); - //bgm.Start(); + bgm = Game.Audio.Track.Get(@"circles"); + bgm.Looping = true; + bgm.Start(); + Children = new Drawable[] { new ParallaxContainer From a23ca25e7d08592f9db079540b6eb9f5e1fcb902 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Oct 2016 17:49:29 +0900 Subject: [PATCH 18/46] Remove unusable "tests" button from main menu system. --- osu.Game/GameModes/Menu/ButtonSystem.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index bbf6f40a02..6a0c2bc29e 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -115,7 +115,6 @@ namespace osu.Game.GameModes.Menu 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))); From 9b76a0ffb8157d67c362b7ffc012749bc2f79258 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Oct 2016 21:09:18 +0900 Subject: [PATCH 19/46] Expose CursorContainer. --- osu.Game/OsuGameBase.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 3eeebfc29a..0f0a9116a0 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -25,6 +25,8 @@ namespace osu.Game private RatioAdjust ratioContainer; + public CursorContainer Cursor; + public override void Load() { base.Load(); @@ -49,7 +51,7 @@ namespace osu.Game Children = new Drawable[] { Options = new Options(), - new OsuCursorContainer() + Cursor = new OsuCursorContainer() } } }); From d6042bd689a91c4b10d4074c0dd1558590f441dd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Oct 2016 21:10:01 +0900 Subject: [PATCH 20/46] Add intro and begin to create central logic nest. --- osu.Game/GameModes/Menu/Intro.cs | 34 +++++++++++++++++++++++ osu.Game/GameModes/Menu/MainMenu.cs | 14 +++------- osu.Game/OsuGame.cs | 42 ++++++++++++++++++++++++++--- osu.Game/osu.Game.csproj | 1 + 4 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 osu.Game/GameModes/Menu/Intro.cs diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs new file mode 100644 index 0000000000..7d20f65469 --- /dev/null +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -0,0 +1,34 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Audio.Sample; +using osu.Framework.Audio.Track; +using osu.Framework.GameModes; + +namespace osu.Game.GameModes.Menu +{ + class Intro : OsuGameMode + { + public override void Load() + { + base.Load(); + + AudioSample welcome = Game.Audio.Sample.Get(@"welcome"); + welcome.Play(); + + AudioTrack bgm = Game.Audio.Track.Get(@"circles"); + bgm.Looping = true; + + Game.Scheduler.AddDelayed(delegate + { + bgm.Start(); + }, 600); + + Game.Scheduler.AddDelayed(delegate + { + Push(new MainMenu()); + }, 2900); + } + } +} diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index b257e9996c..dcb3498e6a 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -22,10 +22,6 @@ namespace osu.Game.GameModes.Menu private ButtonSystem buttons; public override string Name => @"Main Menu"; - protected override bool IsTopLevel => true; - - private AudioTrack bgm; - protected override BackgroundMode CreateBackground() => new BackgroundModeDefault(); public override void Load() @@ -34,13 +30,6 @@ namespace osu.Game.GameModes.Menu OsuGame osu = (OsuGame)Game; - AudioSample welcome = Game.Audio.Sample.Get(@"welcome"); - welcome.Play(); - - bgm = Game.Audio.Track.Get(@"circles"); - bgm.Looping = true; - bgm.Start(); - Children = new Drawable[] { new ParallaxContainer @@ -50,6 +39,7 @@ 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()); }, @@ -68,6 +58,8 @@ namespace osu.Game.GameModes.Menu } } }; + + buttons.FadeIn(500); } protected override void OnSuspending(GameMode next) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 27b474bb82..bc14defda0 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1,7 +1,9 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Configuration; +using osu.Framework.GameModes; using osu.Game.Configuration; using osu.Game.GameModes.Menu; using OpenTK; @@ -18,7 +20,8 @@ namespace osu.Game public class OsuGame : OsuGameBase { public Toolbar Toolbar; - public MainMenu MainMenu; + public MainMenu MainMenu => intro?.ChildGameMode as MainMenu; + private Intro intro; public Bindable PlayMode; @@ -34,18 +37,51 @@ namespace osu.Game base.Load(); Add(new Drawable[] { - MainMenu = new MainMenu(), + intro = new Intro(), Toolbar = new Toolbar { - OnHome = delegate { MainMenu.MakeCurrent(); }, + OnHome = delegate { MainMenu?.MakeCurrent(); }, OnSettings = delegate { Options.PoppedOut = !Options.PoppedOut; }, OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, + Alpha = 0.001f //fixes invalidation fuckup }, }); + intro.ModePushed += modeAdded; + PlayMode = Config.GetBindable(OsuConfig.PlayMode); PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); }; PlayMode.TriggerChange(); + + Cursor.Alpha = 0; + } + + public Action ModeChanged; + + private void modeChanged(GameMode newMode) + { + //central game mode change logic. + if (newMode is Player) + Toolbar.FadeOut(100); + else + Toolbar.FadeIn(100); + + Cursor.FadeIn(100); + + ModeChanged?.Invoke(newMode); + } + + private void modeAdded(GameMode newMode) + { + newMode.ModePushed += modeAdded; + newMode.Exited += modeRemoved; + + modeChanged(newMode); + } + + private void modeRemoved(GameMode newMode) + { + modeChanged(newMode); } public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 5b9dacf34c..a82dc20f60 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -73,6 +73,7 @@ + From d1dfa120d127c0fa1a38c24348c3037b6574f46f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Oct 2016 23:32:35 +0900 Subject: [PATCH 21/46] Move BackgroundModes to their own files. --- osu.Game/GameModes/BackgroundMode.cs | 32 ------------------- .../Backgrounds/BackgroundModeCustom.cs | 28 ++++++++++++++++ .../Backgrounds/BackgroundModeDefault.cs | 17 ++++++++++ .../Backgrounds/BackgroundModeEmpty.cs | 10 ++++++ osu.Game/GameModes/Edit/EditSongSelect.cs | 1 + osu.Game/GameModes/Edit/Editor.cs | 1 + osu.Game/GameModes/GameModeWhiteBox.cs | 1 + osu.Game/GameModes/Menu/Intro.cs | 3 ++ osu.Game/GameModes/Menu/MainMenu.cs | 1 + osu.Game/GameModes/Multiplayer/Match.cs | 1 + .../GameModes/Multiplayer/MatchSongSelect.cs | 1 + osu.Game/GameModes/Play/ModSelect.cs | 1 + osu.Game/GameModes/Play/PlaySongSelect.cs | 1 + osu.Game/GameModes/Play/Results.cs | 1 + osu.Game/osu.Game.csproj | 3 ++ 15 files changed, 70 insertions(+), 32 deletions(-) create mode 100644 osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs create mode 100644 osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs create mode 100644 osu.Game/GameModes/Backgrounds/BackgroundModeEmpty.cs diff --git a/osu.Game/GameModes/BackgroundMode.cs b/osu.Game/GameModes/BackgroundMode.cs index e8c25d3f82..ee7a016b05 100644 --- a/osu.Game/GameModes/BackgroundMode.cs +++ b/osu.Game/GameModes/BackgroundMode.cs @@ -8,7 +8,6 @@ using System.Text; using System.Threading.Tasks; using osu.Framework.GameModes; using osu.Framework.Graphics.Transformations; -using osu.Game.Graphics.Background; using OpenTK; namespace osu.Game.GameModes @@ -61,35 +60,4 @@ namespace osu.Game.GameModes base.OnResuming(last); } } - - public class BackgroundModeDefault : BackgroundMode - { - public override void Load() - { - base.Load(); - - Add(new Background()); - } - } - - public class BackgroundModeCustom : BackgroundMode - { - private readonly string textureName; - - public BackgroundModeCustom(string textureName) - { - this.textureName = textureName; - } - - public override void Load() - { - base.Load(); - Add(new Background(textureName)); - } - - public override bool Equals(BackgroundMode other) - { - return base.Equals(other) && textureName == ((BackgroundModeCustom)other).textureName; - } - } } diff --git a/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs b/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs new file mode 100644 index 0000000000..ae8e2d916e --- /dev/null +++ b/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs @@ -0,0 +1,28 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Graphics.Background; + +namespace osu.Game.GameModes.Backgrounds +{ + public class BackgroundModeCustom : BackgroundMode + { + private readonly string textureName; + + public BackgroundModeCustom(string textureName) + { + this.textureName = textureName; + } + + public override void Load() + { + base.Load(); + Add(new Background(textureName)); + } + + public override bool Equals(BackgroundMode other) + { + return base.Equals(other) && textureName == ((BackgroundModeCustom)other).textureName; + } + } +} \ No newline at end of file diff --git a/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs b/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs new file mode 100644 index 0000000000..0683a267a5 --- /dev/null +++ b/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs @@ -0,0 +1,17 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Graphics.Background; + +namespace osu.Game.GameModes.Backgrounds +{ + public class BackgroundModeDefault : BackgroundMode + { + public override void Load() + { + base.Load(); + + Add(new Background()); + } + } +} \ No newline at end of file diff --git a/osu.Game/GameModes/Backgrounds/BackgroundModeEmpty.cs b/osu.Game/GameModes/Backgrounds/BackgroundModeEmpty.cs new file mode 100644 index 0000000000..6f38c03010 --- /dev/null +++ b/osu.Game/GameModes/Backgrounds/BackgroundModeEmpty.cs @@ -0,0 +1,10 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.GameModes.Backgrounds +{ + public class BackgroundModeEmpty : BackgroundMode + { + + } +} \ No newline at end of file diff --git a/osu.Game/GameModes/Edit/EditSongSelect.cs b/osu.Game/GameModes/Edit/EditSongSelect.cs index 3578aecb35..c4686b03ac 100644 --- a/osu.Game/GameModes/Edit/EditSongSelect.cs +++ b/osu.Game/GameModes/Edit/EditSongSelect.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using osu.Game.GameModes.Backgrounds; namespace osu.Game.GameModes.Edit { diff --git a/osu.Game/GameModes/Edit/Editor.cs b/osu.Game/GameModes/Edit/Editor.cs index c7027a9479..9330d57ec6 100644 --- a/osu.Game/GameModes/Edit/Editor.cs +++ b/osu.Game/GameModes/Edit/Editor.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using osu.Framework.GameModes; +using osu.Game.GameModes.Backgrounds; using OpenTK.Graphics; namespace osu.Game.GameModes.Edit diff --git a/osu.Game/GameModes/GameModeWhiteBox.cs b/osu.Game/GameModes/GameModeWhiteBox.cs index 4eb8945f04..25f22f8278 100644 --- a/osu.Game/GameModes/GameModeWhiteBox.cs +++ b/osu.Game/GameModes/GameModeWhiteBox.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Drawables; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.UserInterface; +using osu.Game.GameModes.Backgrounds; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index 7d20f65469..40f4a93d87 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -5,11 +5,14 @@ using System; using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; using osu.Framework.GameModes; +using osu.Game.GameModes.Backgrounds; namespace osu.Game.GameModes.Menu { class Intro : OsuGameMode { + protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty(); + public override void Load() { base.Load(); diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index dcb3498e6a..962dde2fbc 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -7,6 +7,7 @@ using osu.Framework.GameModes; using osu.Framework.GameModes.Testing; using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; +using osu.Game.GameModes.Backgrounds; using osu.Game.GameModes.Charts; using osu.Game.GameModes.Direct; using osu.Game.GameModes.Edit; diff --git a/osu.Game/GameModes/Multiplayer/Match.cs b/osu.Game/GameModes/Multiplayer/Match.cs index 5e31976764..330cb94374 100644 --- a/osu.Game/GameModes/Multiplayer/Match.cs +++ b/osu.Game/GameModes/Multiplayer/Match.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using osu.Framework.GameModes; +using osu.Game.GameModes.Backgrounds; using osu.Game.GameModes.Play; using OpenTK.Graphics; diff --git a/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs b/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs index eebf8868e8..da86641c04 100644 --- a/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs +++ b/osu.Game/GameModes/Multiplayer/MatchSongSelect.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using osu.Framework.GameModes; +using osu.Game.GameModes.Backgrounds; using OpenTK.Graphics; namespace osu.Game.GameModes.Multiplayer diff --git a/osu.Game/GameModes/Play/ModSelect.cs b/osu.Game/GameModes/Play/ModSelect.cs index e6db9dd60a..bbdc7bf6ce 100644 --- a/osu.Game/GameModes/Play/ModSelect.cs +++ b/osu.Game/GameModes/Play/ModSelect.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using OpenTK.Graphics; using osu.Framework.GameModes; +using osu.Game.GameModes.Backgrounds; namespace osu.Game.GameModes.Play { diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index 6ac557534d..3346ae137d 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using osu.Game.GameModes.Backgrounds; namespace osu.Game.GameModes.Play { diff --git a/osu.Game/GameModes/Play/Results.cs b/osu.Game/GameModes/Play/Results.cs index 18811fd4d1..d7ba02c40f 100644 --- a/osu.Game/GameModes/Play/Results.cs +++ b/osu.Game/GameModes/Play/Results.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using osu.Framework.GameModes; +using osu.Game.GameModes.Backgrounds; using OpenTK.Graphics; namespace osu.Game.GameModes.Play diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index a82dc20f60..7a4195cc3e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -70,6 +70,9 @@ + + + From 10468a566c16a427822a83c96aa363eefa5d4091 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Oct 2016 23:32:56 +0900 Subject: [PATCH 22/46] Add some comments about future usage. --- osu.Game/OsuGame.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index bc14defda0..de9d3c208f 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -10,6 +10,7 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.OS; +using osu.Game.GameModes; using osu.Game.Graphics.Background; using osu.Game.GameModes.Play; using osu.Game.Graphics.Containers; @@ -60,11 +61,19 @@ namespace osu.Game private void modeChanged(GameMode newMode) { + // - Ability to change window size + // - Ability to adjust music playback + // - Frame limiter changes + //central game mode change logic. if (newMode is Player) + { Toolbar.FadeOut(100); + } else + { Toolbar.FadeIn(100); + } Cursor.FadeIn(100); From 5ff9d828eb208932586970ac8351562501653a01 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Oct 2016 23:33:09 +0900 Subject: [PATCH 23/46] Add KeyCounter to Player for fun. --- osu.Game/GameModes/Play/Player.cs | 23 +++++++++++++++---- .../UserInterface/KeyCounterCollection.cs | 10 +++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index 26da692457..3a8685b501 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -12,11 +12,14 @@ using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Osu; +using osu.Game.GameModes.Backgrounds; using osu.Game.GameModes.Play.Catch; using osu.Game.GameModes.Play.Mania; using osu.Game.GameModes.Play.Osu; using osu.Game.GameModes.Play.Taiko; +using osu.Game.Graphics.UserInterface; using OpenTK; +using OpenTK.Input; namespace osu.Game.GameModes.Play { @@ -59,7 +62,6 @@ namespace osu.Game.GameModes.Play Add(new OsuHitRenderer { Objects = beatmap.HitObjects, - Scale = new Vector2(0.8f), Anchor = Anchor.Centre, Origin = Anchor.Centre }); @@ -68,7 +70,6 @@ namespace osu.Game.GameModes.Play Add(new TaikoHitRenderer { Objects = beatmap.HitObjects, - Scale = new Vector2(0.8f), Anchor = Anchor.Centre, Origin = Anchor.Centre }); @@ -77,7 +78,6 @@ namespace osu.Game.GameModes.Play Add(new CatchHitRenderer { Objects = beatmap.HitObjects, - Scale = new Vector2(0.8f), Anchor = Anchor.Centre, Origin = Anchor.Centre }); @@ -86,12 +86,27 @@ namespace osu.Game.GameModes.Play Add(new ManiaHitRenderer { Objects = beatmap.HitObjects, - Scale = new Vector2(0.8f), Anchor = Anchor.Centre, Origin = Anchor.Centre }); break; } + + Add(new KeyCounterCollection + { + IsCounting = true, + FadeTime = 50, + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Position = new Vector2(10, 50), + Counters = new KeyCounter[] + { + new KeyCounterKeyboard(@"Z", Key.Z), + new KeyCounterKeyboard(@"X", Key.X), + new KeyCounterMouse(@"M1", MouseButton.Left), + new KeyCounterMouse(@"M2", MouseButton.Right), + } + }); } } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/KeyCounterCollection.cs b/osu.Game/Graphics/UserInterface/KeyCounterCollection.cs index ee1447c03b..288d1e2018 100644 --- a/osu.Game/Graphics/UserInterface/KeyCounterCollection.cs +++ b/osu.Game/Graphics/UserInterface/KeyCounterCollection.cs @@ -16,7 +16,15 @@ namespace osu.Game.Graphics.UserInterface } private List counters = new List(); - public IReadOnlyList Counters => counters; + public IEnumerable Counters + { + get { return counters; } + set + { + foreach (var k in value) + AddKey(k); + } + } public void AddKey(KeyCounter key) { From e25e7319e916cae828e81d3add2112c1cdd9348e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Oct 2016 23:33:28 +0900 Subject: [PATCH 24/46] Add sample usage of PlayMode bindable. --- osu.Game/GameModes/Play/PlaySongSelect.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index 3346ae137d..c790036d7f 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -15,5 +15,18 @@ namespace osu.Game.GameModes.Play typeof(ModSelect), typeof(Player) }; + + public override void Load() + { + base.Load(); + + OsuGame osu = Game as OsuGame; + + osu.PlayMode.ValueChanged += PlayMode_ValueChanged; + } + + private void PlayMode_ValueChanged(object sender, EventArgs e) + { + } } } From bdb72d7b8210edb08098f8aca3b8c9d225d46fcc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 03:05:26 +0900 Subject: [PATCH 25/46] Add basic VolumeControl and saving of volume to config. --- osu.Game/Configuration/OsuConfigManager.cs | 9 +- osu.Game/OsuGame.cs | 11 +++ osu.Game/VolumeControl.cs | 99 ++++++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 osu.Game/VolumeControl.cs diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 9991394913..e1b3397c42 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -20,6 +20,10 @@ namespace osu.Game.Configuration Set(OsuConfig.Token, string.Empty); Set(OsuConfig.PlayMode, PlayMode.Osu); + + Set(OsuConfig.VolumeGlobal, 0.8, 0, 1); + Set(OsuConfig.VolumeMusic, 1.0, 0, 1); + Set(OsuConfig.VolumeEffect, 1.0, 0, 1); } } @@ -31,6 +35,9 @@ namespace osu.Game.Configuration Username, Password, Token, - PlayMode + PlayMode, + VolumeGlobal, + VolumeEffect, + VolumeMusic } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index de9d3c208f..cd3ddd32fe 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -37,6 +37,11 @@ namespace osu.Game { base.Load(); + //attach out bindables to the audio subsystem. + Audio.Volume.Weld(Config.GetBindable(OsuConfig.VolumeGlobal)); + Audio.VolumeSample.Weld(Config.GetBindable(OsuConfig.VolumeEffect)); + Audio.VolumeTrack.Weld(Config.GetBindable(OsuConfig.VolumeMusic)); + Add(new Drawable[] { intro = new Intro(), Toolbar = new Toolbar @@ -46,6 +51,12 @@ namespace osu.Game OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, Alpha = 0.001f //fixes invalidation fuckup }, + new VolumeControl + { + VolumeGlobal = Audio.Volume, + VolumeSample = Audio.VolumeSample, + VolumeTrack = Audio.VolumeTrack + } }); intro.ModePushed += modeAdded; diff --git a/osu.Game/VolumeControl.cs b/osu.Game/VolumeControl.cs new file mode 100644 index 0000000000..ea899e6ea5 --- /dev/null +++ b/osu.Game/VolumeControl.cs @@ -0,0 +1,99 @@ +using System; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Input; +using osu.Framework.Graphics.Transformations; + +namespace osu.Game +{ + internal class VolumeControl : Container + { + private Box meterFill; + private Container meterContainer; + + public BindableDouble VolumeGlobal { get; set; } + public BindableDouble VolumeSample { get; set; } + public BindableDouble VolumeTrack { get; set; } + + public VolumeControl() + { + RelativeSizeAxes = Axes.Both; + } + + public override void Load() + { + base.Load(); + Children = new Drawable[] + { + meterContainer = new Container { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Position = new Vector2(10, 10), + Size = new Vector2(40, 180), + Children = new Drawable[] + { + new Box + { + Colour = Color4.Black, + RelativeSizeAxes = Axes.Both, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.5f, 0.9f), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] + { + new Box + { + Colour = Color4.DarkGray, + RelativeSizeAxes = Axes.Both, + }, + meterFill = new Box + { + Colour = Color4.White, + RelativeSizeAxes = Axes.Both, + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre + }, + } + } + } + } + }; + } + + protected override bool OnWheelDown(InputState state) + { + appear(); + + VolumeGlobal.Value -= 0.05f; + meterFill.ScaleTo(new Vector2(1, (float)VolumeGlobal.Value), 300, EasingTypes.OutQuint); + + return base.OnWheelDown(state); + } + + protected override bool OnWheelUp(InputState state) + { + appear(); + + VolumeGlobal.Value += 0.05f; + meterFill.ScaleTo(new Vector2(1, (float)VolumeGlobal.Value), 300, EasingTypes.OutQuint); + + return base.OnWheelUp(state); + } + + private void appear() + { + meterContainer.ClearTransformations(); + meterContainer.FadeIn(100); + meterContainer.Delay(1000); + meterContainer.FadeOut(100); + } + } +} \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7a4195cc3e..e9fa92d984 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -131,6 +131,7 @@ + From 065b193b158bbefe4869c3638cf82f926a592ef2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 03:27:24 +0900 Subject: [PATCH 26/46] Fix the initial state of VolumeControl being wrong. --- osu.Game/VolumeControl.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game/VolumeControl.cs b/osu.Game/VolumeControl.cs index ea899e6ea5..0ea9aab67e 100644 --- a/osu.Game/VolumeControl.cs +++ b/osu.Game/VolumeControl.cs @@ -34,6 +34,7 @@ namespace osu.Game Origin = Anchor.BottomRight, Position = new Vector2(10, 10), Size = new Vector2(40, 180), + Alpha = 0, Children = new Drawable[] { new Box @@ -66,6 +67,8 @@ namespace osu.Game } } }; + + updateFill(); } protected override bool OnWheelDown(InputState state) @@ -73,7 +76,7 @@ namespace osu.Game appear(); VolumeGlobal.Value -= 0.05f; - meterFill.ScaleTo(new Vector2(1, (float)VolumeGlobal.Value), 300, EasingTypes.OutQuint); + updateFill(); return base.OnWheelDown(state); } @@ -83,11 +86,16 @@ namespace osu.Game appear(); VolumeGlobal.Value += 0.05f; - meterFill.ScaleTo(new Vector2(1, (float)VolumeGlobal.Value), 300, EasingTypes.OutQuint); + updateFill(); return base.OnWheelUp(state); } + private void updateFill() + { + meterFill.ScaleTo(new Vector2(1, (float)VolumeGlobal.Value), 300, EasingTypes.OutQuint); + } + private void appear() { meterContainer.ClearTransformations(); From a5adbc06151ceddf43194c61e7e9ef709b78d04d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 12:49:53 +0900 Subject: [PATCH 27/46] Update namespace references. --- osu.Desktop.VisualTests/Program.cs | 2 +- osu.Desktop/Program.cs | 2 +- osu.Game/OsuGame.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Program.cs b/osu.Desktop.VisualTests/Program.cs index 43d79d92d2..1cfa440dd9 100644 --- a/osu.Desktop.VisualTests/Program.cs +++ b/osu.Desktop.VisualTests/Program.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Desktop; -using osu.Framework.OS; +using osu.Framework.Platform; namespace osu.Framework.VisualTests { diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index ca085e8648..fe7423924c 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Desktop; -using osu.Framework.OS; +using osu.Framework.Platform; using osu.Game; namespace osu.Desktop diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index cd3ddd32fe..6f0becdab2 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -9,7 +9,7 @@ using osu.Game.GameModes.Menu; using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; -using osu.Framework.OS; +using osu.Framework.Platform; using osu.Game.GameModes; using osu.Game.Graphics.Background; using osu.Game.GameModes.Play; From 4f2bb25853585f5c0c6cece842002951298aa1be Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 15:27:08 +0900 Subject: [PATCH 28/46] Remove "Deploy" configuration. --- .../osu.Desktop.VisualTests.csproj | 12 ------------ osu.Desktop/osu.Desktop.csproj | 12 ------------ osu.sln | 13 ------------- 3 files changed, 37 deletions(-) diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index b731d53b4b..f96ce5261a 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -78,18 +78,6 @@ - - bin\Deploy\ - CuttingEdge - true - true - true - AnyCPU - false - prompt - AllRules.ruleset - false - diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 21f7fbf3a3..f54139692e 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -77,18 +77,6 @@ osu!.res - - bin\Deploy\ - CuttingEdge - true - true - true - AnyCPU - false - prompt - AllRules.ruleset - false - diff --git a/osu.sln b/osu.sln index 891d22b6d3..e3c4d8468d 100644 --- a/osu.sln +++ b/osu.sln @@ -22,44 +22,31 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Deploy|Any CPU = Deploy|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Deploy|Any CPU.ActiveCfg = Deploy|Any CPU - {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Deploy|Any CPU.Build.0 = Deploy|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.Build.0 = Release|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Deploy|Any CPU.Build.0 = Debug|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.ActiveCfg = Release|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.Build.0 = Release|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU - {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Deploy|Any CPU.Build.0 = Debug|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Release|Any CPU.ActiveCfg = Release|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Release|Any CPU.Build.0 = Release|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU - {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Deploy|Any CPU.Build.0 = Debug|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.ActiveCfg = Release|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.Build.0 = Release|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Debug|Any CPU.Build.0 = Debug|Any CPU - {65DC628F-A640-4111-AB35-3A5652BC1E17}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU - {65DC628F-A640-4111-AB35-3A5652BC1E17}.Deploy|Any CPU.Build.0 = Debug|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Release|Any CPU.ActiveCfg = Release|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Release|Any CPU.Build.0 = Release|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Debug|Any CPU.Build.0 = Debug|Any CPU - {69051C69-12AE-4E7D-A3E6-460D2E282312}.Deploy|Any CPU.ActiveCfg = Deploy|Any CPU - {69051C69-12AE-4E7D-A3E6-460D2E282312}.Deploy|Any CPU.Build.0 = Deploy|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Release|Any CPU.ActiveCfg = Release|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection From 656aee41e25b116e9664df3b23a10ac0e774aed2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 15:44:26 +0900 Subject: [PATCH 29/46] Never Prefer32bit. --- osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj | 2 +- osu.Desktop/osu.Desktop.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index f96ce5261a..c54140b267 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -58,7 +58,7 @@ true AllRules.ruleset false - true + false none diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index f54139692e..5553f12019 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -58,7 +58,7 @@ true AllRules.ruleset false - true + false none From b2d899feb5baeeb9c3ab47f7b43e0f984ce07520 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 17:07:23 +0900 Subject: [PATCH 30/46] Add basic intro sequence. --- osu.Game/GameModes/Menu/ButtonSystem.cs | 94 +---------------- osu.Game/GameModes/Menu/Intro.cs | 33 ++++++ osu.Game/GameModes/Menu/OsuLogo.cs | 132 ++++++++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 4 files changed, 169 insertions(+), 91 deletions(-) create mode 100644 osu.Game/GameModes/Menu/OsuLogo.cs diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 6a0c2bc29e..dcb13dbbab 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -19,7 +19,7 @@ using OpenTK.Input; namespace osu.Game.GameModes.Menu { - public class ButtonSystem : Container + public partial class ButtonSystem : Container { public Action OnEdit; public Action OnExit; @@ -103,8 +103,9 @@ namespace osu.Game.GameModes.Menu } } }, - osuLogo = new OsuLogo(onOsuLogo) + osuLogo = new OsuLogo { + Action = onOsuLogo, Origin = Anchor.Centre, Anchor = Anchor.Centre } @@ -273,95 +274,6 @@ namespace osu.Game.GameModes.Menu base.Update(); } - /// - /// osu! logo and its attachments (pulsing, visualiser etc.) - /// - class OsuLogo : AutoSizeContainer - { - private Sprite logo; - private Container logoBounceContainer; - private MenuVisualisation vis; - private Action clickAction; - - public float SizeForFlow => logo == null ? 0 : logo.Size.X * logo.Scale.X * logoBounceContainer.Scale.X * 0.8f; - - public override void Load() - { - base.Load(); - - Sprite ripple; - - Children = new Drawable[] - { - logoBounceContainer = new AutoSizeContainer - { - Children = new Drawable[] - { - logo = new Sprite() - { - Texture = Game.Textures.Get(@"Menu/logo"), - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }, - ripple = new Sprite() - { - Texture = Game.Textures.Get(@"Menu/logo"), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Alpha = 0.4f - }, - vis = new MenuVisualisation - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = logo.Size, - Additive = true, - Alpha = 0.2f, - } - } - } - }; - - ripple.ScaleTo(1.1f, 500); - ripple.FadeOut(500); - ripple.Loop(300); - } - - public OsuLogo(Action action) - { - clickAction = action; - } - - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) - { - logoBounceContainer.ScaleTo(1.1f, 1000, EasingTypes.Out); - return true; - } - - protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) - { - logoBounceContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic); - return true; - } - - protected override bool OnClick(InputState state) - { - clickAction?.Invoke(); - return true; - } - - protected override bool OnHover(InputState state) - { - logoBounceContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic); - return true; - } - - protected override void OnHoverLost(InputState state) - { - logoBounceContainer.ScaleTo(1, 500, EasingTypes.OutElastic); - } - } - /// /// A flow container with an origin based on one of its contained drawables. /// diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index 40f4a93d87..5bc41572e3 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -5,24 +5,46 @@ using System; using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; using osu.Framework.GameModes; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Transformations; using osu.Game.GameModes.Backgrounds; +using OpenTK.Graphics; namespace osu.Game.GameModes.Menu { class Intro : OsuGameMode { + private OsuLogo logo; protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty(); public override void Load() { base.Load(); + Children = new Drawable[] + { + logo = new OsuLogo() + { + Alpha = 0, + Additive = true, + Interactive = false, + Colour = Color4.DarkGray, + Ripple = false + } + }; + AudioSample welcome = Game.Audio.Sample.Get(@"welcome"); welcome.Play(); AudioTrack bgm = Game.Audio.Track.Get(@"circles"); bgm.Looping = true; + Game.Scheduler.Add(delegate + { + welcome.Play(); + }, true); + + Game.Scheduler.AddDelayed(delegate { bgm.Start(); @@ -32,6 +54,17 @@ namespace osu.Game.GameModes.Menu { Push(new MainMenu()); }, 2900); + + logo.ScaleTo(0); + + logo.ScaleTo(1,5900, EasingTypes.OutQuint); + logo.FadeIn(30000, EasingTypes.OutQuint); + } + + protected override void OnSuspending(GameMode next) + { + Content.FadeOut(300); + base.OnSuspending(next); } } } diff --git a/osu.Game/GameModes/Menu/OsuLogo.cs b/osu.Game/GameModes/Menu/OsuLogo.cs new file mode 100644 index 0000000000..5e50ae5db4 --- /dev/null +++ b/osu.Game/GameModes/Menu/OsuLogo.cs @@ -0,0 +1,132 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Input; + +namespace osu.Game.GameModes.Menu +{ + /// + /// osu! logo and its attachments (pulsing, visualiser etc.) + /// + public partial class OsuLogo : AutoSizeContainer + { + private Sprite logo; + private Container logoBounceContainer; + private ButtonSystem.MenuVisualisation vis; + + public Action Action; + + public float SizeForFlow => logo == null ? 0 : logo.Size.X * logo.Scale.X * logoBounceContainer.Scale.X * 0.8f; + + private Sprite ripple; + + private Container rippleContainer; + + public bool Ripple + { + get { return rippleContainer.Alpha > 0; } + set + { + rippleContainer.Alpha = value ? 1 : 0; + } + } + + public bool Interactive = true; + + public OsuLogo() + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + + Children = new Drawable[] + { + logoBounceContainer = new AutoSizeContainer + { + Children = new Drawable[] + { + logo = new Sprite() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }, + rippleContainer = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] + { + ripple = new Sprite() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Additive = true, + Alpha = 0.05f + } + } + }, + vis = new ButtonSystem.MenuVisualisation + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = logo.Size, + Additive = true, + Alpha = 0.2f, + } + } + } + }; + } + + public override void Load() + { + base.Load(); + + logo.Texture = Game.Textures.Get(@"Menu/logo"); + ripple.Texture = Game.Textures.Get(@"Menu/logo"); + + ripple.ScaleTo(1.1f, 500); + ripple.FadeOut(500); + ripple.Loop(300); + } + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + if (!Interactive) return false; + + logoBounceContainer.ScaleTo(1.1f, 1000, EasingTypes.Out); + return true; + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + + logoBounceContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic); + return true; + } + + protected override bool OnClick(InputState state) + { + if (!Interactive) return false; + + Action?.Invoke(); + return true; + } + + protected override bool OnHover(InputState state) + { + if (!Interactive) return false; + logoBounceContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic); + return true; + } + + protected override void OnHoverLost(InputState state) + { + logoBounceContainer.ScaleTo(1, 500, EasingTypes.OutElastic); + } + } +} \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index e9fa92d984..7852d68e33 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -79,6 +79,7 @@ + From c5ac851ba9f280b9bea3b8aa98cee6184f048056 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 18:34:37 +0900 Subject: [PATCH 31/46] Add the ability to exit the game using escape. --- osu.Game/GameModes/Menu/ButtonSystem.cs | 9 +++++++++ osu.Game/GameModes/Menu/Intro.cs | 11 +++++++++++ osu.Game/GameModes/Menu/MainMenu.cs | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index dcb13dbbab..87a78c335d 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -125,6 +125,15 @@ namespace osu.Game.GameModes.Menu protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { + if (args.Key == Key.Escape) + { + if (State == MenuState.Initial) + return false; + + State = MenuState.Initial; + return true; + } + osuLogo.TriggerClick(state); return true; } diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index 5bc41572e3..4a7e338cfe 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -66,5 +66,16 @@ namespace osu.Game.GameModes.Menu Content.FadeOut(300); base.OnSuspending(next); } + + protected override void OnResuming(GameMode last) + { + //this is an exit + Game.Scheduler.AddDelayed(delegate + { + Game.Exit(); + }, 300); + + base.OnResuming(last); + } } } diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index 962dde2fbc..5b8900a5e5 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -49,7 +49,7 @@ namespace osu.Game.GameModes.Menu OnTest = delegate { Push(new TestBrowser()); }, OnExit = delegate { Game.Scheduler.AddDelayed(delegate { - Game.Host.Exit(); + Exit(); }, ButtonSystem.EXIT_DELAY); }, OnSettings = delegate { From c5228b63cbc7abf7971f0a9f35eeaf31780c23cb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 18:46:05 +0900 Subject: [PATCH 32/46] Unify and smiplify exit logic. Now only OsuGame calls the final Exit. --- osu.Game/GameModes/Menu/Intro.cs | 7 ++----- osu.Game/GameModes/Menu/MainMenu.cs | 6 +----- osu.Game/GameModes/OsuGameMode.cs | 11 ----------- osu.Game/OsuGame.cs | 4 ++++ 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index 4a7e338cfe..4339ec9b29 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -69,11 +69,8 @@ namespace osu.Game.GameModes.Menu protected override void OnResuming(GameMode last) { - //this is an exit - Game.Scheduler.AddDelayed(delegate - { - Game.Exit(); - }, 300); + //we are just an intro. if we are resumed, we just want to exit after a short delay (to allow the last mode to transition out). + Game.Scheduler.AddDelayed(Exit, 300); base.OnResuming(last); } diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index 5b8900a5e5..3ee28f5d03 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -47,11 +47,7 @@ namespace osu.Game.GameModes.Menu OnSolo = delegate { Push(new PlaySongSelect()); }, OnMulti = delegate { Push(new Lobby()); }, OnTest = delegate { Push(new TestBrowser()); }, - OnExit = delegate { - Game.Scheduler.AddDelayed(delegate { - Exit(); - }, ButtonSystem.EXIT_DELAY); - }, + OnExit = delegate { Game.Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); }, OnSettings = delegate { osu.Options.PoppedOut = !osu.Options.PoppedOut; }, diff --git a/osu.Game/GameModes/OsuGameMode.cs b/osu.Game/GameModes/OsuGameMode.cs index ad4a5b416b..8d63de1489 100644 --- a/osu.Game/GameModes/OsuGameMode.cs +++ b/osu.Game/GameModes/OsuGameMode.cs @@ -64,16 +64,5 @@ namespace osu.Game.GameModes base.OnExiting(next); } - - protected override void OnResuming(GameMode last) - { - base.OnResuming(last); - } - - protected override void OnSuspending(GameMode next) - { - base.OnSuspending(next); - } - } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 6f0becdab2..056c754d41 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -60,6 +60,7 @@ namespace osu.Game }); intro.ModePushed += modeAdded; + intro.Exited += modeRemoved; PlayMode = Config.GetBindable(OsuConfig.PlayMode); PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); }; @@ -89,6 +90,9 @@ namespace osu.Game Cursor.FadeIn(100); ModeChanged?.Invoke(newMode); + + if (newMode == null) + Host.Exit(); } private void modeAdded(GameMode newMode) From 08728b84d16a3a26a72713f742a5cd507c85de2e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 18:58:20 +0900 Subject: [PATCH 33/46] Make sure intro can't be exited unless the main menu has displayed once. --- osu.Game/GameModes/BackgroundMode.cs | 6 ++++-- osu.Game/GameModes/Edit/Editor.cs | 4 ++-- osu.Game/GameModes/GameModeWhiteBox.cs | 6 +++--- osu.Game/GameModes/Menu/Intro.cs | 9 +++++++++ osu.Game/GameModes/Multiplayer/Match.cs | 4 ++-- osu.Game/GameModes/OsuGameMode.cs | 4 ++-- osu.Game/GameModes/Play/ModSelect.cs | 4 ++-- osu.Game/GameModes/Play/Results.cs | 4 ++-- 8 files changed, 26 insertions(+), 15 deletions(-) diff --git a/osu.Game/GameModes/BackgroundMode.cs b/osu.Game/GameModes/BackgroundMode.cs index ee7a016b05..a34ec2d40b 100644 --- a/osu.Game/GameModes/BackgroundMode.cs +++ b/osu.Game/GameModes/BackgroundMode.cs @@ -9,6 +9,8 @@ using System.Threading.Tasks; using osu.Framework.GameModes; using osu.Framework.Graphics.Transformations; using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Input; namespace osu.Game.GameModes { @@ -46,12 +48,12 @@ namespace osu.Game.GameModes base.OnSuspending(next); } - protected override void OnExiting(GameMode next) + protected override bool OnExiting(GameMode next) { Content.FadeOut(transition_length, EasingTypes.OutExpo); Content.MoveToX(x_movement_amount, transition_length, EasingTypes.OutExpo); - base.OnExiting(next); + return base.OnExiting(next); } protected override void OnResuming(GameMode last) diff --git a/osu.Game/GameModes/Edit/Editor.cs b/osu.Game/GameModes/Edit/Editor.cs index 9330d57ec6..fbefb38752 100644 --- a/osu.Game/GameModes/Edit/Editor.cs +++ b/osu.Game/GameModes/Edit/Editor.cs @@ -22,10 +22,10 @@ namespace osu.Game.GameModes.Edit Background.FadeColour(Color4.DarkGray, 500); } - protected override void OnExiting(GameMode next) + protected override bool OnExiting(GameMode next) { - base.OnExiting(next); Background.FadeColour(Color4.White, 500); + return base.OnExiting(next); } } } diff --git a/osu.Game/GameModes/GameModeWhiteBox.cs b/osu.Game/GameModes/GameModeWhiteBox.cs index 25f22f8278..46250d9a91 100644 --- a/osu.Game/GameModes/GameModeWhiteBox.cs +++ b/osu.Game/GameModes/GameModeWhiteBox.cs @@ -53,12 +53,12 @@ namespace osu.Game.GameModes Content.FadeIn(transition_time, EasingTypes.OutExpo); } - protected override void OnExiting(GameMode next) + protected override bool OnExiting(GameMode next) { - base.OnExiting(next); - textContainer.MoveTo(new Vector2((Size.X / 16), 0), transition_time, EasingTypes.OutExpo); Content.FadeOut(transition_time, EasingTypes.OutExpo); + + return base.OnExiting(next); } protected override void OnSuspending(GameMode next) diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index 4339ec9b29..c2f0599fdd 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -15,6 +15,8 @@ namespace osu.Game.GameModes.Menu class Intro : OsuGameMode { private OsuLogo logo; + private bool didLoadMenu; + protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty(); public override void Load() @@ -52,6 +54,7 @@ namespace osu.Game.GameModes.Menu Game.Scheduler.AddDelayed(delegate { + didLoadMenu = true; Push(new MainMenu()); }, 2900); @@ -67,6 +70,12 @@ namespace osu.Game.GameModes.Menu base.OnSuspending(next); } + protected override bool OnExiting(GameMode next) + { + //cancel exiting if we haven't loaded the menu yet. + return !didLoadMenu; + } + protected override void OnResuming(GameMode last) { //we are just an intro. if we are resumed, we just want to exit after a short delay (to allow the last mode to transition out). diff --git a/osu.Game/GameModes/Multiplayer/Match.cs b/osu.Game/GameModes/Multiplayer/Match.cs index 330cb94374..0b12ade697 100644 --- a/osu.Game/GameModes/Multiplayer/Match.cs +++ b/osu.Game/GameModes/Multiplayer/Match.cs @@ -28,10 +28,10 @@ namespace osu.Game.GameModes.Multiplayer Background.FadeColour(Color4.DarkGray, 500); } - protected override void OnExiting(GameMode next) + protected override bool OnExiting(GameMode next) { - base.OnExiting(next); Background.FadeColour(Color4.White, 500); + return base.OnExiting(next); } } } diff --git a/osu.Game/GameModes/OsuGameMode.cs b/osu.Game/GameModes/OsuGameMode.cs index 8d63de1489..b0755cbca0 100644 --- a/osu.Game/GameModes/OsuGameMode.cs +++ b/osu.Game/GameModes/OsuGameMode.cs @@ -55,14 +55,14 @@ namespace osu.Game.GameModes base.OnEntering(last); } - protected override void OnExiting(GameMode next) + protected override bool OnExiting(GameMode next) { OsuGameMode nextOsu = next as OsuGameMode; if (Background != null && !Background.Equals(nextOsu?.Background)) Background.Exit(); - base.OnExiting(next); + return base.OnExiting(next); } } } diff --git a/osu.Game/GameModes/Play/ModSelect.cs b/osu.Game/GameModes/Play/ModSelect.cs index bbdc7bf6ce..525fdeeb94 100644 --- a/osu.Game/GameModes/Play/ModSelect.cs +++ b/osu.Game/GameModes/Play/ModSelect.cs @@ -22,10 +22,10 @@ namespace osu.Game.GameModes.Play Background.FadeColour(Color4.DarkGray, 500); } - protected override void OnExiting(GameMode next) + protected override bool OnExiting(GameMode next) { - base.OnExiting(next); Background.FadeColour(Color4.White, 500); + return base.OnExiting(next); } } } diff --git a/osu.Game/GameModes/Play/Results.cs b/osu.Game/GameModes/Play/Results.cs index d7ba02c40f..4974966aa9 100644 --- a/osu.Game/GameModes/Play/Results.cs +++ b/osu.Game/GameModes/Play/Results.cs @@ -22,10 +22,10 @@ namespace osu.Game.GameModes.Play Background.FadeColour(Color4.DarkGray, 500); } - protected override void OnExiting(GameMode next) + protected override bool OnExiting(GameMode next) { - base.OnExiting(next); Background.FadeColour(Color4.White, 500); + return base.OnExiting(next); } } } From f2f3b69eee5290e4048830531fceb57d7bbfc770 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 18:58:59 +0900 Subject: [PATCH 34/46] BackgroundModes shouldn't handle the escape key themselves. --- osu.Game/GameModes/BackgroundMode.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/GameModes/BackgroundMode.cs b/osu.Game/GameModes/BackgroundMode.cs index a34ec2d40b..1f90448e55 100644 --- a/osu.Game/GameModes/BackgroundMode.cs +++ b/osu.Game/GameModes/BackgroundMode.cs @@ -24,6 +24,12 @@ namespace osu.Game.GameModes const float transition_length = 500; const float x_movement_amount = 50; + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + //we don't want to handle escape key. + return false; + } + public override void Load() { base.Load(); From 243d2cdec5ff8279d2dbabf600a008290fef1773 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 19:12:36 +0900 Subject: [PATCH 35/46] Block window closing while intro is playing. --- osu.Game/GameModes/Menu/Intro.cs | 10 +++++++--- osu.Game/OsuGame.cs | 11 +++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index c2f0599fdd..4f4aaf7704 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -15,7 +15,11 @@ namespace osu.Game.GameModes.Menu class Intro : OsuGameMode { private OsuLogo logo; - private bool didLoadMenu; + + /// + /// Whether we have loaded the menu previously. + /// + internal bool DidLoadMenu; protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty(); @@ -54,7 +58,7 @@ namespace osu.Game.GameModes.Menu Game.Scheduler.AddDelayed(delegate { - didLoadMenu = true; + DidLoadMenu = true; Push(new MainMenu()); }, 2900); @@ -73,7 +77,7 @@ namespace osu.Game.GameModes.Menu protected override bool OnExiting(GameMode next) { //cancel exiting if we haven't loaded the menu yet. - return !didLoadMenu; + return !DidLoadMenu; } protected override void OnResuming(GameMode last) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 056c754d41..9caa431bf8 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -95,6 +95,17 @@ namespace osu.Game Host.Exit(); } + protected override bool OnExiting() + { + if (!intro.DidLoadMenu || intro.ChildGameMode != null) + { + intro.MakeCurrent(); + return true; + } + + return base.OnExiting(); + } + private void modeAdded(GameMode newMode) { newMode.ModePushed += modeAdded; From 93f326bb9b1691b986b94929d7e11a996c16aabe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 19:14:21 +0900 Subject: [PATCH 36/46] Fix welcome sound being played twice. --- osu.Game/GameModes/Menu/Intro.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index 4f4aaf7704..30ca6f931c 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -40,7 +40,6 @@ namespace osu.Game.GameModes.Menu }; AudioSample welcome = Game.Audio.Sample.Get(@"welcome"); - welcome.Play(); AudioTrack bgm = Game.Audio.Track.Get(@"circles"); bgm.Looping = true; From 27a26cfaaf59c9ff90a433104d21fb9dc7869386 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 20:35:44 +0900 Subject: [PATCH 37/46] Ensure the correct background state is restored when skipping multiple levels --- osu.Game/GameModes/OsuGameMode.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/GameModes/OsuGameMode.cs b/osu.Game/GameModes/OsuGameMode.cs index b0755cbca0..d81d30f0d5 100644 --- a/osu.Game/GameModes/OsuGameMode.cs +++ b/osu.Game/GameModes/OsuGameMode.cs @@ -60,7 +60,13 @@ namespace osu.Game.GameModes OsuGameMode nextOsu = next as OsuGameMode; if (Background != null && !Background.Equals(nextOsu?.Background)) - Background.Exit(); + { + if (nextOsu != null) + //We need to use MakeCurrent in case we are jumping up multiple game modes. + nextOsu.Background.MakeCurrent(); + else + Background.Exit(); + } return base.OnExiting(next); } From 556420ee58f45c657b8111fd9123d01e3c10ed32 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2016 20:38:52 +0900 Subject: [PATCH 38/46] Add proper toolbar state handling. --- osu.Game/OsuGame.cs | 8 +++++--- osu.Game/Overlays/Toolbar.cs | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 9caa431bf8..a524a4f925 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -59,6 +59,8 @@ namespace osu.Game } }); + Toolbar.SetState(ToolbarState.Hidden, true); + intro.ModePushed += modeAdded; intro.Exited += modeRemoved; @@ -78,13 +80,13 @@ namespace osu.Game // - Frame limiter changes //central game mode change logic. - if (newMode is Player) + if (newMode is Player || newMode is Intro) { - Toolbar.FadeOut(100); + Toolbar.SetState(ToolbarState.Hidden); } else { - Toolbar.FadeIn(100); + Toolbar.SetState(ToolbarState.Visible); } Cursor.FadeIn(100); diff --git a/osu.Game/Overlays/Toolbar.cs b/osu.Game/Overlays/Toolbar.cs index f30105beab..46bc2be0d6 100644 --- a/osu.Game/Overlays/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar.cs @@ -9,6 +9,8 @@ using OpenTK.Graphics; using osu.Game.Graphics; using osu.Game.Configuration; using System; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Timing; using osu.Game.GameModes.Play; namespace osu.Game.Overlays @@ -23,6 +25,23 @@ namespace osu.Game.Overlays private ToolbarModeSelector modeSelector; + public void SetState(ToolbarState state, bool instant = false) + { + int time = instant ? 0 : 200; + + switch (state) + { + case ToolbarState.Hidden: + MoveToY(-Size.Y, time, EasingTypes.InQuint); + FadeOut(time); + break; + case ToolbarState.Visible: + MoveToY(0, time, EasingTypes.OutQuint); + FadeIn(time); + break; + } + } + public override void Load() { base.Load(); @@ -91,4 +110,10 @@ namespace osu.Game.Overlays public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode); } + + public enum ToolbarState + { + Visible, + Hidden, + } } From 0c793dfe698b51d88db8a948eb7662a0b72ddcaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sat, 8 Oct 2016 11:33:24 +0200 Subject: [PATCH 39/46] Use own Scheduler instead of Game.Scheduler. --- osu-framework | 2 +- osu.Game/GameModes/Menu/Intro.cs | 8 ++++---- osu.Game/GameModes/Menu/MainMenu.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu-framework b/osu-framework index 6b884e1b80..306e2898ed 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 6b884e1b80444c5249754634a4b5529c50b52934 +Subproject commit 306e2898edc2ef7ed3b45e45e055601f0115d6ea diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index 30ca6f931c..78e0d15b0e 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -44,18 +44,18 @@ namespace osu.Game.GameModes.Menu AudioTrack bgm = Game.Audio.Track.Get(@"circles"); bgm.Looping = true; - Game.Scheduler.Add(delegate + Scheduler.Add(delegate { welcome.Play(); }, true); - Game.Scheduler.AddDelayed(delegate + Scheduler.AddDelayed(delegate { bgm.Start(); }, 600); - Game.Scheduler.AddDelayed(delegate + Scheduler.AddDelayed(delegate { DidLoadMenu = true; Push(new MainMenu()); @@ -82,7 +82,7 @@ namespace osu.Game.GameModes.Menu protected override void OnResuming(GameMode last) { //we are just an intro. if we are resumed, we just want to exit after a short delay (to allow the last mode to transition out). - Game.Scheduler.AddDelayed(Exit, 300); + Scheduler.AddDelayed(Exit, 300); base.OnResuming(last); } diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index 3ee28f5d03..e74c83e03d 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -47,7 +47,7 @@ namespace osu.Game.GameModes.Menu OnSolo = delegate { Push(new PlaySongSelect()); }, OnMulti = delegate { Push(new Lobby()); }, OnTest = delegate { Push(new TestBrowser()); }, - OnExit = delegate { Game.Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); }, + OnExit = delegate { Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); }, OnSettings = delegate { osu.Options.PoppedOut = !osu.Options.PoppedOut; }, From 5a507838d619f7157ed761d8e80c4afd11d96727 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 8 Oct 2016 19:12:31 +0900 Subject: [PATCH 40/46] Fix event not being unbound. --- osu.Game/GameModes/Play/PlaySongSelect.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index c790036d7f..06f7d8f914 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -3,12 +3,15 @@ using System; using System.Collections.Generic; +using osu.Framework.Configuration; using osu.Game.GameModes.Backgrounds; namespace osu.Game.GameModes.Play { class PlaySongSelect : GameModeWhiteBox { + private Bindable playMode; + protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); protected override IEnumerable PossibleChildren => new[] { @@ -22,7 +25,15 @@ namespace osu.Game.GameModes.Play OsuGame osu = Game as OsuGame; - osu.PlayMode.ValueChanged += PlayMode_ValueChanged; + playMode = osu.PlayMode; + playMode.ValueChanged += PlayMode_ValueChanged; + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + playMode.ValueChanged -= PlayMode_ValueChanged; } private void PlayMode_ValueChanged(object sender, EventArgs e) From 5ff37670388d75799241f853e31ed7ce37247895 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 8 Oct 2016 19:18:50 +0900 Subject: [PATCH 41/46] Fix typo in comment. --- osu.Game/OsuGame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index a524a4f925..87c6c30c51 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -37,7 +37,7 @@ namespace osu.Game { base.Load(); - //attach out bindables to the audio subsystem. + //attach our bindables to the audio subsystem. Audio.Volume.Weld(Config.GetBindable(OsuConfig.VolumeGlobal)); Audio.VolumeSample.Weld(Config.GetBindable(OsuConfig.VolumeEffect)); Audio.VolumeTrack.Weld(Config.GetBindable(OsuConfig.VolumeMusic)); From 9d54d4f9bb8702f8619eaa23c09f0861c9e8dcae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 9 Oct 2016 07:10:54 +0200 Subject: [PATCH 42/46] Update framework version. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 306e2898ed..c3a7ebd979 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 306e2898edc2ef7ed3b45e45e055601f0115d6ea +Subproject commit c3a7ebd979c9a6b19871dc84337905f97c56a6aa From 0a10bf9a516817ebe718606e3542c6281e88827b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 9 Oct 2016 20:06:07 +0900 Subject: [PATCH 43/46] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index c3a7ebd979..1f770847b2 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit c3a7ebd979c9a6b19871dc84337905f97c56a6aa +Subproject commit 1f770847b245e6d250e63e60c24e9e84131d15e7 From 36bb4a39880d6d3bba50c96fc63d3bdb7e6bdb81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 9 Oct 2016 11:55:38 +0200 Subject: [PATCH 44/46] Don't call Container.Add within KeyCounterCollection.Reset. --- .../Tests/TestCaseKeyCounter.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs index 87642f3004..7be7d24860 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs @@ -19,17 +19,22 @@ namespace osu.Desktop.Tests { base.Reset(); - KeyCounterCollection kc = new KeyCounterCollection + Children = new[] { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - IsCounting = true + new KeyCounterCollection + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + IsCounting = true, + Counters = new KeyCounter[] + { + new KeyCounterKeyboard(@"Z", Key.Z), + new KeyCounterKeyboard(@"X", Key.X), + new KeyCounterMouse(@"M1", MouseButton.Left), + new KeyCounterMouse(@"M2", MouseButton.Right), + }, + }, }; - Add(kc); - kc.AddKey(new KeyCounterKeyboard(@"Z", Key.Z)); - kc.AddKey(new KeyCounterKeyboard(@"X", Key.X)); - kc.AddKey(new KeyCounterMouse(@"M1", MouseButton.Left)); - kc.AddKey(new KeyCounterMouse(@"M2", MouseButton.Right)); } } } From bcb5a02221087ec1909c6769bf87106b9d3312f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 9 Oct 2016 11:55:52 +0200 Subject: [PATCH 45/46] Don't rely on return value of Container.Add. --- osu.Game/GameModes/Menu/ButtonSystem.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 87a78c335d..93701e6c18 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -113,14 +113,17 @@ 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(new Button(@"solo", @"freeplay", FontAwesome.user, new Color4(102, 68, 204, 255), OnSolo, wedge_width, Key.P)); + buttonsPlay.Add(new Button(@"multi", @"multiplayer", FontAwesome.users, new Color4(94, 63, 186, 255), OnMulti, 0, Key.M)); + buttonsPlay.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), OnChart)); - 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(@"exit", @"exit", FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q))); + buttonsTopLevel.Add(new Button(@"play", @"play", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, wedge_width, Key.P)); + buttonsTopLevel.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), OnEdit, 0, Key.E)); + buttonsTopLevel.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), OnDirect, 0, Key.D)); + buttonsTopLevel.Add(new Button(@"exit", @"exit", FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q)); + + buttonFlow.Add(buttonsPlay); + buttonFlow.Add(buttonsTopLevel); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) From dd04b33232e889ef4988b838d546d1c05deed719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 9 Oct 2016 11:56:41 +0200 Subject: [PATCH 46/46] Use AddInternal instead of AddTopLevel. --- osu.Game/GameModes/OsuGameMode.cs | 3 +-- .../Graphics/Containers/ParallaxContainer.cs | 16 ++++++++-------- .../UserInterface/KeyCounterCollection.cs | 15 ++++++++------- osu.Game/OsuGameBase.cs | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/osu.Game/GameModes/OsuGameMode.cs b/osu.Game/GameModes/OsuGameMode.cs index d81d30f0d5..b0928d8214 100644 --- a/osu.Game/GameModes/OsuGameMode.cs +++ b/osu.Game/GameModes/OsuGameMode.cs @@ -41,7 +41,7 @@ namespace osu.Game.GameModes } else if (bg != null) { - AddTopLevel(new ParallaxContainer + AddInternal(new ParallaxContainer { Depth = float.MinValue, Children = new[] @@ -51,7 +51,6 @@ namespace osu.Game.GameModes }); } - base.OnEntering(last); } diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 3c6cb18162..183b0c054a 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -14,21 +14,21 @@ namespace osu.Game.Graphics.Containers public ParallaxContainer() { RelativeSizeAxes = Axes.Both; + AddInternal(content = new Container() + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }); } - private Container content = new Container() - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }; + private Container content; - protected override Container AddTarget => content; + protected override Container Content => content; public override void Load() { base.Load(); - Add(content); } protected override bool OnMouseMove(InputState state) diff --git a/osu.Game/Graphics/UserInterface/KeyCounterCollection.cs b/osu.Game/Graphics/UserInterface/KeyCounterCollection.cs index 288d1e2018..c9d22d2f06 100644 --- a/osu.Game/Graphics/UserInterface/KeyCounterCollection.cs +++ b/osu.Game/Graphics/UserInterface/KeyCounterCollection.cs @@ -22,18 +22,19 @@ namespace osu.Game.Graphics.UserInterface set { foreach (var k in value) - AddKey(k); + addKey(k); + + Children = value; } } - public void AddKey(KeyCounter key) + private void addKey(KeyCounter key) { counters.Add(key); - key.IsCounting = this.IsCounting; - key.FadeTime = this.FadeTime; - key.KeyDownTextColor = this.KeyDownTextColor; - key.KeyUpTextColor = this.KeyUpTextColor; - base.Add(key); + key.IsCounting = IsCounting; + key.FadeTime = FadeTime; + key.KeyDownTextColor = KeyDownTextColor; + key.KeyUpTextColor = KeyUpTextColor; } public void ResetCount() diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 0f0a9116a0..bd3990d5ef 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -21,7 +21,7 @@ namespace osu.Game public Options Options; public APIAccess API; - protected override Container AddTarget => ratioContainer?.IsLoaded == true ? ratioContainer : base.AddTarget; + protected override Container Content => ratioContainer?.IsLoaded == true ? ratioContainer : base.Content; private RatioAdjust ratioContainer;