From cbe36259c3eea9bd422aeaea816e22d400893ba6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 07:49:45 -0300 Subject: [PATCH 01/16] Add BreadcrumbControl --- .../Tests/TestCaseBreadcrumbs.cs | 39 ++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + .../UserInterface/BreadcrumbControl.cs | 63 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 4 files changed, 104 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs create mode 100644 osu.Game/Graphics/UserInterface/BreadcrumbControl.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs b/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs new file mode 100644 index 0000000000..658d2f92b1 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs @@ -0,0 +1,39 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Game.Graphics.UserInterface; +using osu.Framework.Graphics; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseBreadcrumbs : TestCase + { + public override string Description => @"breadcrumb > control"; + + public override void Reset() + { + base.Reset(); + + BreadcrumbControl c; + Add(c = new BreadcrumbControl + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Width = 0.5f, + }); + + AddStep(@"first", () => c.Current.Value = BreadcrumbTab.Click); + AddStep(@"second", () => c.Current.Value = BreadcrumbTab.The); + AddStep(@"third", () => c.Current.Value = BreadcrumbTab.Circles); + } + + private enum BreadcrumbTab + { + Click, + The, + Circles, + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 7b7997063b..5a532d7234 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -223,6 +223,7 @@ + diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs new file mode 100644 index 0000000000..be3933f362 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -0,0 +1,63 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.UserInterface; + +namespace osu.Game.Graphics.UserInterface +{ + public class BreadcrumbControl : OsuTabControl + { + public static readonly float padding = 10; + + protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); + + public BreadcrumbControl() + { + Height = 28; + TabContainer.Spacing = new Vector2(padding, 0f); + Current.ValueChanged += tab => + { + foreach (TabItem t in TabContainer.Children) + { + if (!(t is BreadcrumbTabItem)) return; + + var tIndex = TabContainer.IndexOf(t); + var tabIndex = TabContainer.IndexOf(TabMap[tab]); + var hide = tIndex < tabIndex; + var hideChevron = tIndex <= tabIndex; + + t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); + t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); + (t as BreadcrumbTabItem).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); + } + }; + } + + private class BreadcrumbTabItem : OsuTabItem + { + public readonly TextAwesome Chevron; + + //don't allow clicking between transitions and don't make the chevron clickable + protected override bool InternalContains(Vector2 screenSpacePos) => Alpha < 1f ? false : Text.Contains(screenSpacePos); + + public BreadcrumbTabItem(T value) : base(value) + { + Text.TextSize = 18; + Padding = new MarginPadding { Right = padding + 9 }; + Add(Chevron = new TextAwesome + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreLeft, + TextSize = 12, + Icon = FontAwesome.fa_chevron_right, + Margin = new MarginPadding { Left = 10 }, + Alpha = 0f, + }); + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 25b692151f..4d1b1a1b11 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -450,6 +450,7 @@ + From 64612ef34b99250921cf96b5c0dfc85ad40f2ea9 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 26 May 2017 16:10:28 +0200 Subject: [PATCH 02/16] add multimod animation --- osu.Game/Overlays/Mods/ModButton.cs | 44 +++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 831b9082bd..68c1fb8592 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -27,6 +27,7 @@ namespace osu.Game.Overlays.Mods public class ModButton : ModButtonEmpty, IHasTooltip { private ModIcon foregroundIcon; + private ModIcon backgroundIcon; private readonly SpriteText text; private readonly Container iconsContainer; private SampleChannel sampleOn, sampleOff; @@ -35,6 +36,9 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; + private const EasingTypes modSwitchEasing = EasingTypes.InOutQuint; + private const double modSwitchDuration = 100; + private int _selectedIndex = -1; private int selectedIndex { @@ -45,6 +49,9 @@ namespace osu.Game.Overlays.Mods set { if (value == _selectedIndex) return; + + bool beforeSelected = Selected; + _selectedIndex = value; if (value >= Mods.Length) @@ -55,13 +62,30 @@ namespace osu.Game.Overlays.Mods { _selectedIndex = Mods.Length - 1; } - - iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); - iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); + if (beforeSelected ^ Selected) + { + iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); + iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); + } + else + { + foregroundIcon.RotateTo(15f, modSwitchDuration, modSwitchEasing); + backgroundIcon.RotateTo(-15f, modSwitchDuration, modSwitchEasing); + using (foregroundIcon.BeginDelayedSequence(modSwitchDuration)) + { + foregroundIcon.RotateTo(-15f); + foregroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + } + using (backgroundIcon.BeginDelayedSequence(modSwitchDuration)) + { + backgroundIcon.RotateTo(15f); + backgroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + } + } foregroundIcon.Highlighted = Selected; if (mod != null) - displayMod(SelectedMod ?? Mods[0]); + Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : modSwitchDuration); } } @@ -159,6 +183,8 @@ namespace osu.Game.Overlays.Mods private void displayMod(Mod mod) { + if(backgroundIcon != null) + backgroundIcon.Icon = foregroundIcon.Icon; foregroundIcon.Icon = mod.Icon; text.Text = mod.Name; } @@ -170,17 +196,17 @@ namespace osu.Game.Overlays.Mods { iconsContainer.Add(new[] { - new ModIcon(Mods[0]) + backgroundIcon = new ModIcon(Mods[1]) { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, AutoSizeAxes = Axes.Both, Position = new Vector2(1.5f), }, foregroundIcon = new ModIcon(Mods[0]) { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, AutoSizeAxes = Axes.Both, Position = new Vector2(-1.5f), }, From db1dde72de27b276a023932e7ae999986b7882dc Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 26 May 2017 16:29:15 +0200 Subject: [PATCH 03/16] change constant names --- osu.Game/Overlays/Mods/ModButton.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 68c1fb8592..e1545ab1b8 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -36,8 +36,8 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; - private const EasingTypes modSwitchEasing = EasingTypes.InOutQuint; - private const double modSwitchDuration = 100; + private const EasingTypes mod_switch_easing = EasingTypes.InOutQuint; + private const double mod_switch_duration = 100; private int _selectedIndex = -1; private int selectedIndex @@ -69,23 +69,23 @@ namespace osu.Game.Overlays.Mods } else { - foregroundIcon.RotateTo(15f, modSwitchDuration, modSwitchEasing); - backgroundIcon.RotateTo(-15f, modSwitchDuration, modSwitchEasing); - using (foregroundIcon.BeginDelayedSequence(modSwitchDuration)) + foregroundIcon.RotateTo(15f, mod_switch_duration, mod_switch_easing); + backgroundIcon.RotateTo(-15f, mod_switch_duration, mod_switch_easing); + using (foregroundIcon.BeginDelayedSequence(mod_switch_duration)) { foregroundIcon.RotateTo(-15f); - foregroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + foregroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); } - using (backgroundIcon.BeginDelayedSequence(modSwitchDuration)) + using (backgroundIcon.BeginDelayedSequence(mod_switch_duration)) { backgroundIcon.RotateTo(15f); - backgroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); } } foregroundIcon.Highlighted = Selected; if (mod != null) - Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : modSwitchDuration); + Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : mod_switch_duration); } } From fb6ed159ca0042dc11ec2e33e22a030c97e00dba Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:03:51 -0300 Subject: [PATCH 04/16] Use padding for chevron margin --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index be3933f362..a54823e042 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -47,14 +47,14 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { Text.TextSize = 18; - Padding = new MarginPadding { Right = padding + 9 }; + Padding = new MarginPadding { Right = padding + 9 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, Origin = Anchor.CentreLeft, TextSize = 12, Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding { Left = 10 }, + Margin = new MarginPadding { Left = padding }, Alpha = 0f, }); } From 352d3d247bec1cd5be22715f3894d9aa37b74f94 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:21:37 -0300 Subject: [PATCH 05/16] Fix incorrect sizes --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index a54823e042..4ee0ba9e5e 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -17,7 +17,7 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbControl() { - Height = 28; + Height = 26; TabContainer.Spacing = new Vector2(padding, 0f); Current.ValueChanged += tab => { @@ -46,8 +46,8 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { - Text.TextSize = 18; - Padding = new MarginPadding { Right = padding + 9 }; //padding + chevron width + Text.TextSize = 16; + Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, From 4c127a6130368c87f85b98af2e10ca6218f2c0b2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:29:20 -0300 Subject: [PATCH 06/16] CI fixes --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 4ee0ba9e5e..3bc94da07b 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -1,17 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using OpenTK; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface { public class BreadcrumbControl : OsuTabControl { - public static readonly float padding = 10; + public const float padding = 10; protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); @@ -23,8 +21,6 @@ namespace osu.Game.Graphics.UserInterface { foreach (TabItem t in TabContainer.Children) { - if (!(t is BreadcrumbTabItem)) return; - var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); var hide = tIndex < tabIndex; @@ -32,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); - (t as BreadcrumbTabItem).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); + ((BreadcrumbTabItem)t).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } @@ -42,7 +38,7 @@ namespace osu.Game.Graphics.UserInterface public readonly TextAwesome Chevron; //don't allow clicking between transitions and don't make the chevron clickable - protected override bool InternalContains(Vector2 screenSpacePos) => Alpha < 1f ? false : Text.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => Alpha == 1f && Text.Contains(screenSpacePos); public BreadcrumbTabItem(T value) : base(value) { From c9971bb490a60714279b3b965b4ee4734a8f02c5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:32:46 -0300 Subject: [PATCH 07/16] Don't store hideChevron --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 3bc94da07b..b19b1c805e 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -24,11 +24,10 @@ namespace osu.Game.Graphics.UserInterface var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); var hide = tIndex < tabIndex; - var hideChevron = tIndex <= tabIndex; t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); - ((BreadcrumbTabItem)t).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); + ((BreadcrumbTabItem)t).Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } From 33d6b718be955c16a41d9e15b364eb9fae20aceb Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:36:00 -0300 Subject: [PATCH 08/16] padding -> PADDING --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index b19b1c805e..53e8275b56 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -9,14 +9,14 @@ namespace osu.Game.Graphics.UserInterface { public class BreadcrumbControl : OsuTabControl { - public const float padding = 10; + public const float PADDING = 10; protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); public BreadcrumbControl() { Height = 26; - TabContainer.Spacing = new Vector2(padding, 0f); + TabContainer.Spacing = new Vector2(PADDING, 0f); Current.ValueChanged += tab => { foreach (TabItem t in TabContainer.Children) @@ -42,14 +42,14 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { Text.TextSize = 16; - Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width + Padding = new MarginPadding { Right = PADDING + 8 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, Origin = Anchor.CentreLeft, TextSize = 12, Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding { Left = padding }, + Margin = new MarginPadding { Left = PADDING }, Alpha = 0f, }); } From 3699c399679a6273d710c33c436d55da5d0b7898 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:46:09 -0300 Subject: [PATCH 09/16] PADDING -> padding, make private --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 53e8275b56..8fb0affe8d 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -9,14 +9,14 @@ namespace osu.Game.Graphics.UserInterface { public class BreadcrumbControl : OsuTabControl { - public const float PADDING = 10; + private const float padding = 10; protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); public BreadcrumbControl() { Height = 26; - TabContainer.Spacing = new Vector2(PADDING, 0f); + TabContainer.Spacing = new Vector2(padding, 0f); Current.ValueChanged += tab => { foreach (TabItem t in TabContainer.Children) @@ -42,14 +42,14 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { Text.TextSize = 16; - Padding = new MarginPadding { Right = PADDING + 8 }; //padding + chevron width + Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, Origin = Anchor.CentreLeft, TextSize = 12, Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding { Left = PADDING }, + Margin = new MarginPadding { Left = padding }, Alpha = 0f, }); } From e86ccf61b3f70dfd8a22d4838d6789d2d8f94b4c Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 27 May 2017 09:52:02 +0200 Subject: [PATCH 10/16] use recursion --- osu.Game/Overlays/Mods/ModButton.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index e1545ab1b8..70197ba444 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -71,13 +71,11 @@ namespace osu.Game.Overlays.Mods { foregroundIcon.RotateTo(15f, mod_switch_duration, mod_switch_easing); backgroundIcon.RotateTo(-15f, mod_switch_duration, mod_switch_easing); - using (foregroundIcon.BeginDelayedSequence(mod_switch_duration)) + using (iconsContainer.BeginDelayedSequence(mod_switch_duration, true)) { foregroundIcon.RotateTo(-15f); foregroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); - } - using (backgroundIcon.BeginDelayedSequence(mod_switch_duration)) - { + backgroundIcon.RotateTo(15f); backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); } From d4a9813af9cbd12b04df6d5b4f5e81ef16b41028 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 27 May 2017 18:19:09 -0300 Subject: [PATCH 11/16] Cleanup BreadcrumbTabItem visibility code --- .../UserInterface/BreadcrumbControl.cs | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 8fb0affe8d..1c303ee175 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -2,7 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; +using osu.Framework; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface @@ -23,21 +25,44 @@ namespace osu.Game.Graphics.UserInterface { var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); - var hide = tIndex < tabIndex; - t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); - t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); + ((BreadcrumbTabItem)t).State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; ((BreadcrumbTabItem)t).Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } - private class BreadcrumbTabItem : OsuTabItem + private class BreadcrumbTabItem : OsuTabItem, IStateful { public readonly TextAwesome Chevron; //don't allow clicking between transitions and don't make the chevron clickable protected override bool InternalContains(Vector2 screenSpacePos) => Alpha == 1f && Text.Contains(screenSpacePos); + public override bool HandleInput => State == Visibility.Visible; + + private Visibility state; + public Visibility State + { + get { return state; } + set + { + if (value == state) return; + state = value; + + const float transition_duration = 500; + + if (State == Visibility.Visible) + { + FadeIn(transition_duration, EasingTypes.OutQuint); + ScaleTo(new Vector2(1f), transition_duration, EasingTypes.OutQuint); + } + else + { + FadeOut(transition_duration, EasingTypes.OutQuint); + ScaleTo(new Vector2(0.8f, 1f), transition_duration, EasingTypes.OutQuint); + } + } + } public BreadcrumbTabItem(T value) : base(value) { From e529ced131563ef930d0eafdc4cf06c3c8026580 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 16:18:01 +0900 Subject: [PATCH 12/16] Fix mania-specific beatmaps not setting samples correctly. --- .../Beatmaps/ManiaBeatmapConverter.cs | 22 ++++++++++++++++++- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 125d8cdded..0ed2a0ba6f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -13,6 +13,7 @@ using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Database; using osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy; using OpenTK; +using osu.Game.Audio; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -161,9 +162,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps pattern.Add(new HoldNote { StartTime = HitObject.StartTime, - Samples = HitObject.Samples, Duration = endTimeData.Duration, Column = column, + Head = { Samples = sampleInfoListAt(HitObject.StartTime) }, + Tail = { Samples = sampleInfoListAt(endTimeData.EndTime) }, }); } else if (positionData != null) @@ -178,6 +180,24 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return pattern; } + + /// + /// Retrieves the sample info list at a point in time. + /// + /// The time to retrieve the sample info list from. + /// + private SampleInfoList sampleInfoListAt(double time) + { + var curveData = HitObject as IHasCurve; + + if (curveData == null) + return HitObject.Samples; + + double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.RepeatCount; + + int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); + return curveData.RepeatSamples[index]; + } } } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index c241c4cf41..8cd757734c 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -58,6 +58,9 @@ namespace osu.Game.Rulesets.Mania.Objects TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; + + Head.ApplyDefaults(controlPointInfo, difficulty); + Tail.ApplyDefaults(controlPointInfo, difficulty); } /// From 718eeb6df8e0ef6be1cfd78f66f9e52461806fb0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 16:18:07 +0900 Subject: [PATCH 13/16] Use linq to tidy up casting --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 1c303ee175..8d113f4918 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -6,6 +6,7 @@ using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; +using System.Linq; namespace osu.Game.Graphics.UserInterface { @@ -21,13 +22,13 @@ namespace osu.Game.Graphics.UserInterface TabContainer.Spacing = new Vector2(padding, 0f); Current.ValueChanged += tab => { - foreach (TabItem t in TabContainer.Children) + foreach (var t in TabContainer.Children.OfType()) { var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); - ((BreadcrumbTabItem)t).State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; - ((BreadcrumbTabItem)t).Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); + t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; + t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } From 31cc6917bc5b11774a8d557a86902692e9a95e85 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 17:20:55 +0900 Subject: [PATCH 14/16] Tidy up code, improve transition, add directionality --- osu.Game/Overlays/Mods/ModButton.cs | 57 ++++++++++++++++------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 70197ba444..f13b60a3ca 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -36,59 +36,64 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; - private const EasingTypes mod_switch_easing = EasingTypes.InOutQuint; - private const double mod_switch_duration = 100; + private const EasingTypes mod_switch_easing = EasingTypes.InOutSine; + private const double mod_switch_duration = 140; - private int _selectedIndex = -1; - private int selectedIndex + // A selected index of -1 means not selected. + private int selectedIndex = -1; + + protected int SelectedIndex { get { - return _selectedIndex; + return selectedIndex; } set { - if (value == _selectedIndex) return; + if (value == selectedIndex) return; bool beforeSelected = Selected; - _selectedIndex = value; + int direction = value < selectedIndex ? -1 : 1; + + selectedIndex = value; if (value >= Mods.Length) - { - _selectedIndex = -1; - } + selectedIndex = -1; else if (value <= -2) - { - _selectedIndex = Mods.Length - 1; - } + selectedIndex = Mods.Length - 1; + if (beforeSelected ^ Selected) { iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); + displayMod(SelectedMod ?? Mods[0]); } else { - foregroundIcon.RotateTo(15f, mod_switch_duration, mod_switch_easing); - backgroundIcon.RotateTo(-15f, mod_switch_duration, mod_switch_easing); + const float rotate_angle = 16; + + foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing); + backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing); + + backgroundIcon.Icon = SelectedMod.Icon; using (iconsContainer.BeginDelayedSequence(mod_switch_duration, true)) { - foregroundIcon.RotateTo(-15f); + foregroundIcon.RotateTo(-rotate_angle * direction); foregroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); - backgroundIcon.RotateTo(15f); + backgroundIcon.RotateTo(rotate_angle * direction); backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); + + iconsContainer.Schedule(() => displayMod(SelectedMod ?? Mods[0])); } } - foregroundIcon.Highlighted = Selected; - if (mod != null) - Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : mod_switch_duration); + foregroundIcon.Highlighted = Selected; } } - public bool Selected => selectedIndex != -1; - + public bool Selected => SelectedIndex != -1; private Color4 selectedColour; public Color4 SelectedColour @@ -139,7 +144,7 @@ namespace osu.Game.Overlays.Mods // the mods from Mod, only multiple if Mod is a MultiMod - public override Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex); + public override Mod SelectedMod => Mods.ElementAtOrDefault(SelectedIndex); [BackgroundDependencyLoader] private void load(AudioManager audio) @@ -164,19 +169,19 @@ namespace osu.Game.Overlays.Mods public void SelectNext() { - (++selectedIndex == -1 ? sampleOff : sampleOn).Play(); + (++SelectedIndex == -1 ? sampleOff : sampleOn).Play(); Action?.Invoke(SelectedMod); } public void SelectPrevious() { - (--selectedIndex == -1 ? sampleOff : sampleOn).Play(); + (--SelectedIndex == -1 ? sampleOff : sampleOn).Play(); Action?.Invoke(SelectedMod); } public void Deselect() { - selectedIndex = -1; + SelectedIndex = -1; } private void displayMod(Mod mod) From 7960b5cf26ea4209aa57861c83c905e2600a7de0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 18:03:40 +0900 Subject: [PATCH 15/16] More refactoring Also allows rotation when reaching the end of the available mods. --- osu.Game/Overlays/Mods/ModButton.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index f13b60a3ca..9ff19caff3 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; private const EasingTypes mod_switch_easing = EasingTypes.InOutSine; - private const double mod_switch_duration = 140; + private const double mod_switch_duration = 120; // A selected index of -1 means not selected. private int selectedIndex = -1; @@ -52,31 +52,34 @@ namespace osu.Game.Overlays.Mods { if (value == selectedIndex) return; + int direction = value < selectedIndex ? -1 : 1; bool beforeSelected = Selected; - int direction = value < selectedIndex ? -1 : 1; - - selectedIndex = value; + Mod modBefore = SelectedMod ?? Mods[0]; if (value >= Mods.Length) selectedIndex = -1; - else if (value <= -2) + else if (value < -1) selectedIndex = Mods.Length - 1; + else + selectedIndex = value; - if (beforeSelected ^ Selected) + Mod modAfter = SelectedMod ?? Mods[0]; + + if (beforeSelected != Selected) { iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); - displayMod(SelectedMod ?? Mods[0]); } - else + + if (modBefore != modAfter) { const float rotate_angle = 16; foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing); backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing); - backgroundIcon.Icon = SelectedMod.Icon; + backgroundIcon.Icon = modAfter.Icon; using (iconsContainer.BeginDelayedSequence(mod_switch_duration, true)) { foregroundIcon.RotateTo(-rotate_angle * direction); @@ -85,7 +88,7 @@ namespace osu.Game.Overlays.Mods backgroundIcon.RotateTo(rotate_angle * direction); backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); - iconsContainer.Schedule(() => displayMod(SelectedMod ?? Mods[0])); + iconsContainer.Schedule(() => displayMod(modAfter)); } } From e4b876ff5b7e274a12bb80ab2b3f14384cf09f78 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 29 May 2017 18:10:02 +0900 Subject: [PATCH 16/16] Update ModButton.cs --- osu.Game/Overlays/Mods/ModButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 9ff19caff3..f7df67b66d 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -189,7 +189,7 @@ namespace osu.Game.Overlays.Mods private void displayMod(Mod mod) { - if(backgroundIcon != null) + if (backgroundIcon != null) backgroundIcon.Icon = foregroundIcon.Icon; foregroundIcon.Icon = mod.Icon; text.Text = mod.Name;