From 181648515b433c56006d1a8d9b2685e20c08fa63 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 24 May 2017 16:05:24 +0300 Subject: [PATCH 01/29] Moving icon to the beat on the TwoLayerButton --- .../Graphics/UserInterface/TwoLayerButton.cs | 118 +++++++++++------- 1 file changed, 71 insertions(+), 47 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 237aaa44a6..4aeaf6965d 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -5,18 +5,21 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using OpenTK; using OpenTK.Graphics; using osu.Game.Graphics.Sprites; using osu.Framework.Extensions.Color4Extensions; +using osu.Game.Graphics.Containers; +using osu.Game.Beatmaps.ControlPoints; +using osu.Framework.Audio.Track; +using System; namespace osu.Game.Graphics.UserInterface { public class TwoLayerButton : ClickableContainer { - private readonly TextAwesome icon; + private readonly IconBeatSyncedContainer iconBeatSyncedContainer; public Box IconLayer; public Box TextLayer; @@ -95,11 +98,10 @@ namespace osu.Game.Graphics.UserInterface }, } }, - icon = new TextAwesome + iconBeatSyncedContainer = new IconBeatSyncedContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, - TextSize = 25, }, } }, @@ -146,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface { set { - icon.Icon = value; + iconBeatSyncedContainer.Icon = value; } } @@ -162,58 +164,16 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(InputState state) { - icon.ClearTransforms(); - ResizeTo(SIZE_EXTENDED, transform_time, EasingTypes.OutElastic); - - int duration = 0; //(int)(Game.Audio.BeatLength / 2); - if (duration == 0) duration = pulse_length; - IconLayer.FadeColour(HoverColour, transform_time, EasingTypes.OutElastic); - const double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration; - double startTime = Time.Current + offset; - - // basic pulse - icon.Transforms.Add(new TransformScale - { - StartValue = new Vector2(1.1f), - EndValue = Vector2.One, - StartTime = startTime, - EndTime = startTime + duration, - Easing = EasingTypes.Out, - LoopCount = -1, - LoopDelay = duration - }); - return true; } protected override void OnHoverLost(InputState state) { - icon.ClearTransforms(); - ResizeTo(SIZE_RETRACTED, transform_time, EasingTypes.OutElastic); - IconLayer.FadeColour(TextLayer.Colour, transform_time, EasingTypes.OutElastic); - - int duration = 0; //(int)(Game.Audio.BeatLength); - if (duration == 0) duration = pulse_length * 2; - - const double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration; - double startTime = Time.Current + offset; - - // slow pulse - icon.Transforms.Add(new TransformScale - { - StartValue = new Vector2(1.1f), - EndValue = Vector2.One, - StartTime = startTime, - EndTime = startTime + duration, - Easing = EasingTypes.Out, - LoopCount = -1, - LoopDelay = duration - }); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) @@ -239,5 +199,69 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } + + private class IconBeatSyncedContainer : BeatSyncedContainer + { + private const double beat_in_time = 60; + + private readonly TextAwesome icon; + private readonly Container amplitudeContainer; + + public FontAwesome Icon { set { icon.Icon = value; } } + + public IconBeatSyncedContainer() + { + EarlyActivationMilliseconds = beat_in_time; + AutoSizeAxes = Axes.Both; + + Children = new Drawable[] + { + amplitudeContainer = new Container + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] + { + icon = new TextAwesome + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 25 + } + } + }, + }; + } + + private int lastBeatIndex; + + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); + + lastBeatIndex = beatIndex; + + var beatLength = timingPoint.BeatLength; + + float amplitudeAdjust = Math.Min(1, 0.4f + amplitudes.Maximum); + + if (beatIndex < 0) return; + + icon.ScaleTo(1 - 0.1f * amplitudeAdjust, beat_in_time, EasingTypes.Out); + using (icon.BeginDelayedSequence(beat_in_time)) + icon.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint); + } + + protected override void Update() + { + base.Update(); + + const float scale_adjust_cutoff = 0.4f; + + var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value?.Track?.CurrentAmplitudes.Maximum ?? 0 : 0; + amplitudeContainer.ScaleTo(1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.1f, 75, EasingTypes.OutQuint); + } + } } } \ No newline at end of file From 2c23703ca6f85f7c792c9dca1392d3cf015212d1 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 26 May 2017 13:46:44 +0300 Subject: [PATCH 02/29] Removed amplitude container --- .../Graphics/UserInterface/TwoLayerButton.cs | 40 ++++--------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 4aeaf6965d..209d9fb468 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface { public class TwoLayerButton : ClickableContainer { - private readonly IconBeatSyncedContainer iconBeatSyncedContainer; + private readonly BouncingIcon bouncingIcon; public Box IconLayer; public Box TextLayer; @@ -98,7 +98,7 @@ namespace osu.Game.Graphics.UserInterface }, } }, - iconBeatSyncedContainer = new IconBeatSyncedContainer + bouncingIcon = new BouncingIcon { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -148,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface { set { - iconBeatSyncedContainer.Icon = value; + bouncingIcon.Icon = value; } } @@ -200,48 +200,34 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } - private class IconBeatSyncedContainer : BeatSyncedContainer + private class BouncingIcon : BeatSyncedContainer { private const double beat_in_time = 60; private readonly TextAwesome icon; - private readonly Container amplitudeContainer; public FontAwesome Icon { set { icon.Icon = value; } } - public IconBeatSyncedContainer() + public BouncingIcon() { EarlyActivationMilliseconds = beat_in_time; AutoSizeAxes = Axes.Both; Children = new Drawable[] { - amplitudeContainer = new Container + icon = new TextAwesome { - AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Children = new Drawable[] - { - icon = new TextAwesome - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - TextSize = 25 - } - } - }, + TextSize = 25 + } }; } - private int lastBeatIndex; - protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) { base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); - lastBeatIndex = beatIndex; - var beatLength = timingPoint.BeatLength; float amplitudeAdjust = Math.Min(1, 0.4f + amplitudes.Maximum); @@ -252,16 +238,6 @@ namespace osu.Game.Graphics.UserInterface using (icon.BeginDelayedSequence(beat_in_time)) icon.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint); } - - protected override void Update() - { - base.Update(); - - const float scale_adjust_cutoff = 0.4f; - - var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value?.Track?.CurrentAmplitudes.Maximum ?? 0 : 0; - amplitudeContainer.ScaleTo(1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.1f, 75, EasingTypes.OutQuint); - } } } } \ No newline at end of file From cbe36259c3eea9bd422aeaea816e22d400893ba6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 07:49:45 -0300 Subject: [PATCH 03/29] 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 d052f093d5984e45ef7fbd45165f939231375c29 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 26 May 2017 14:29:45 +0300 Subject: [PATCH 04/29] Scaling on hover --- osu.Game/Graphics/UserInterface/TwoLayerButton.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 209d9fb468..ebaef661c4 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -167,6 +167,8 @@ namespace osu.Game.Graphics.UserInterface ResizeTo(SIZE_EXTENDED, transform_time, EasingTypes.OutElastic); IconLayer.FadeColour(HoverColour, transform_time, EasingTypes.OutElastic); + bouncingIcon.ScaleTo(1.1f, transform_time, EasingTypes.OutElastic); + return true; } @@ -174,6 +176,8 @@ namespace osu.Game.Graphics.UserInterface { ResizeTo(SIZE_RETRACTED, transform_time, EasingTypes.OutElastic); IconLayer.FadeColour(TextLayer.Colour, transform_time, EasingTypes.OutElastic); + + bouncingIcon.ScaleTo(1, transform_time, EasingTypes.OutElastic); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) From 64612ef34b99250921cf96b5c0dfc85ad40f2ea9 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 26 May 2017 16:10:28 +0200 Subject: [PATCH 05/29] 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 06/29] 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 07/29] 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 08/29] 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 09/29] 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 10/29] 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 11/29] 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 12/29] 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 13/29] 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 14/29] 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 e63108bd75ecdf69169432aeb2bcfdc0e43b76b3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:56:31 +0900 Subject: [PATCH 15/29] Add base for bar lines. --- osu.Game.Rulesets.Mania/Objects/Barline.cs | 9 +++++++++ .../Objects/Drawables/DrawableBarline.cs | 7 +++++++ .../Objects/Drawables/DrawableMajorBarline.cs | 7 +++++++ osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj | 3 +++ 4 files changed, 26 insertions(+) create mode 100644 osu.Game.Rulesets.Mania/Objects/Barline.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs diff --git a/osu.Game.Rulesets.Mania/Objects/Barline.cs b/osu.Game.Rulesets.Mania/Objects/Barline.cs new file mode 100644 index 0000000000..a9ce0559dc --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Barline.cs @@ -0,0 +1,9 @@ +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Mania.Objects +{ + public class Barline : HitObject + { + public bool IsMajor; + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs new file mode 100644 index 0000000000..605b9f83df --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs @@ -0,0 +1,7 @@ +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableBarline + { + + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs new file mode 100644 index 0000000000..607cc66012 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs @@ -0,0 +1,7 @@ +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableMajorBarline + { + + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 7a8ec25fe4..b45ce3c5df 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -62,6 +62,8 @@ + + @@ -70,6 +72,7 @@ + From 6101fe98e1df4a7cf2e3f1dae39aae021facccf5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 12:10:29 +0900 Subject: [PATCH 16/29] Always ApplyDefaults after parsing beatmaps to make sure hit objects are in their most loaded state. --- osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 3 ++ .../Rulesets/Objects/Legacy/ConvertSlider.cs | 34 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index cb1d9d2fcd..c6aac3bb71 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -428,6 +428,9 @@ namespace osu.Game.Beatmaps.Formats break; } } + + foreach (var hitObject in beatmap.HitObjects) + hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.Difficulty); } internal enum LegacySampleBank diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs index 7580404e81..ddee0c3154 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs @@ -6,20 +6,36 @@ using System; using System.Collections.Generic; using OpenTK; using osu.Game.Audio; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Database; namespace osu.Game.Rulesets.Objects.Legacy { internal abstract class ConvertSlider : HitObject, IHasCurve { + /// + /// Scoring distance with a speed-adjusted beat length of 1 second. + /// + private const float base_scoring_distance = 100; + + public readonly SliderCurve Curve = new SliderCurve(); + public List ControlPoints { get; set; } public CurveType CurveType { get; set; } - public double Distance { get; set; } + + public double Distance + { + get { return Curve.Distance; } + set { Curve.Distance = value; } + } public List RepeatSamples { get; set; } public int RepeatCount { get; set; } = 1; - public double EndTime { get; set; } - public double Duration { get; set; } + public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity; + public double Duration => EndTime - StartTime; + + public double Velocity; public Vector2 PositionAt(double progress) { @@ -35,5 +51,17 @@ namespace osu.Game.Rulesets.Objects.Legacy { throw new NotImplementedException(); } + + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(controlPointInfo, difficulty); + + TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); + DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime); + + double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier / difficultyPoint.SpeedMultiplier; + + Velocity = scoringDistance / timingPoint.BeatLength; + } } } From 231b1ae6102f18651a45120c69888c31b22246af Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 12:19:38 +0900 Subject: [PATCH 17/29] We don't need a curve. --- osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs index ddee0c3154..b42cd47abb 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs @@ -18,21 +18,15 @@ namespace osu.Game.Rulesets.Objects.Legacy /// private const float base_scoring_distance = 100; - public readonly SliderCurve Curve = new SliderCurve(); - public List ControlPoints { get; set; } public CurveType CurveType { get; set; } - public double Distance - { - get { return Curve.Distance; } - set { Curve.Distance = value; } - } + public double Distance { get; set; } public List RepeatSamples { get; set; } public int RepeatCount { get; set; } = 1; - public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity; + public double EndTime => StartTime + RepeatCount * Distance / Velocity; public double Duration => EndTime - StartTime; public double Velocity; From c137ee822c98529d3590fdc14f53a976b4bb6fca Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 12:19:51 +0900 Subject: [PATCH 18/29] Give velocity a sane default value. --- osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs index b42cd47abb..8c2aead5ff 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs @@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Objects.Legacy public double EndTime => StartTime + RepeatCount * Distance / Velocity; public double Duration => EndTime - StartTime; - public double Velocity; + public double Velocity = 1; public Vector2 PositionAt(double progress) { From 79d249e5ad428e0fc784e1eaf2a363fcf0873219 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 13:48:31 +0900 Subject: [PATCH 19/29] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index aa3e296968..0f3db5da09 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit aa3e296968873208ca4460b00c0b82fe3aa8ff5c +Subproject commit 0f3db5da09d0e7c4d2ef3057030e018f34ba536e From ee7158aa9514c47dce10209aee6d84aed8fbdf20 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 14:44:42 +0900 Subject: [PATCH 20/29] Implement bar lines. --- osu.Game.Rulesets.Mania/Objects/Barline.cs | 14 +++- .../Objects/Drawables/DrawableBarline.cs | 69 ++++++++++++++++++- .../Objects/Drawables/DrawableMajorBarline.cs | 7 -- .../UI/ManiaHitRenderer.cs | 29 ++++++++ osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 51 ++++++++++---- .../osu.Game.Rulesets.Mania.csproj | 1 - 6 files changed, 146 insertions(+), 25 deletions(-) delete mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs diff --git a/osu.Game.Rulesets.Mania/Objects/Barline.cs b/osu.Game.Rulesets.Mania/Objects/Barline.cs index a9ce0559dc..9b229a8d52 100644 --- a/osu.Game.Rulesets.Mania/Objects/Barline.cs +++ b/osu.Game.Rulesets.Mania/Objects/Barline.cs @@ -1,9 +1,19 @@ +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { - public class Barline : HitObject + public class Barline : ManiaHitObject { - public bool IsMajor; + /// + /// The control point which this bar line is part of. + /// + public TimingControlPoint ControlPoint; + + /// + /// The index of the beat which this bar line represents within the control point. + /// This is a "major" beat at % == 0. + /// + public int BeatIndex; } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs index 605b9f83df..eee32a9da3 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs @@ -1,7 +1,72 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using OpenTK; +using OpenTK.Input; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Objects.Drawables; + namespace osu.Game.Rulesets.Mania.Objects.Drawables { - public class DrawableBarline + /// + /// Visualises a . Although this derives DrawableManiaHitObject, + /// this does not handle input/sound like a normal hit object. + /// + public class DrawableBarline : DrawableManiaHitObject { - + public DrawableBarline(Barline hitObject) + : base(hitObject, null) + { + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; + + Add(new Box + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = 1 + }); + + int signatureRelativeIndex = hitObject.BeatIndex % (int)hitObject.ControlPoint.TimeSignature; + + switch (signatureRelativeIndex) + { + case 0: + Add(new EquilateralTriangle + { + Name = "Left triangle", + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = -9, + Rotation = 90, + BypassAutoSizeAxes = Axes.Both + }); + + Add(new EquilateralTriangle + { + Name = "Right triangle", + Anchor = Anchor.BottomRight, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = 9, + Rotation = -90, + BypassAutoSizeAxes = Axes.Both, + }); + break; + case 1: + case 3: + Alpha = 0.2f; + break; + } + } + + protected override void UpdateState(ArmedState state) + { + } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs deleted file mode 100644 index 607cc66012..0000000000 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace osu.Game.Rulesets.Mania.Objects.Drawables -{ - public class DrawableMajorBarline - { - - } -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 95b7979e43..871306b98c 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -6,9 +6,11 @@ using System.Collections.Generic; using System.Linq; using OpenTK; using OpenTK.Input; +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Lists; +using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Beatmaps; @@ -85,6 +87,33 @@ namespace osu.Game.Rulesets.Mania.UI }; } + [BackgroundDependencyLoader] + private void load() + { + var maniaPlayfield = (ManiaPlayfield)Playfield; + + double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue; + + SortedList timingPoints = Beatmap.ControlPointInfo.TimingPoints; + for (int i = 0; i < timingPoints.Count; i++) + { + TimingControlPoint point = timingPoints[i]; + + double endTime = i < timingPoints.Count - 1 ? timingPoints[i + 1].Time - point.BeatLength : lastObjectTime + point.BeatLength * (int)point.TimeSignature; + + int index = 0; + for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength, index++) + { + maniaPlayfield.Add(new DrawableBarline(new Barline + { + StartTime = t, + ControlPoint = point, + BeatIndex = index + })); + } + } + } + public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index ff763f87c4..dcf725e091 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -21,6 +21,7 @@ using osu.Game.Rulesets.Mania.Timing; using osu.Framework.Input; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; +using osu.Game.Rulesets.Mania.Objects.Drawables; namespace osu.Game.Rulesets.Mania.UI { @@ -77,27 +78,40 @@ namespace osu.Game.Rulesets.Mania.UI { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Both, Masking = true, Children = new Drawable[] { - new Box + new Container { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black - }, - columns = new FillFlowContainer - { - Name = "Columns", + Name = "Masked elements", + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, - Direction = FillDirection.Horizontal, - Padding = new MarginPadding { Left = 1, Right = 1 }, - Spacing = new Vector2(1, 0) + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + columns = new FillFlowContainer + { + Name = "Columns", + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Direction = FillDirection.Horizontal, + Padding = new MarginPadding { Left = 1, Right = 1 }, + Spacing = new Vector2(1, 0) + } + } }, new Container { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = HIT_TARGET_POSITION }, Children = new[] @@ -105,7 +119,10 @@ namespace osu.Game.Rulesets.Mania.UI barlineContainer = new ControlPointContainer(timingChanges) { Name = "Bar lines", - RelativeSizeAxes = Axes.Both, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.Y + // Width is set in the Update method } } } @@ -190,6 +207,7 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); + public void Add(DrawableBarline barline) => barlineContainer.Add(barline); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { @@ -234,6 +252,13 @@ namespace osu.Game.Rulesets.Mania.UI TransformTo(() => TimeSpan, newTimeSpan, duration, easing, new TransformTimeSpan()); } + protected override void Update() + { + // Due to masking differences, it is not possible to get the width of the columns container automatically + // While masking on effectively only the Y-axis, so we need to set the width of the bar line container manually + barlineContainer.Width = columns.Width; + } + private class TransformTimeSpan : Transform { public override double CurrentValue diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index b45ce3c5df..cc5e6dd81e 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -63,7 +63,6 @@ - From 4fce0c11891fdc8fbc7457391a8b9d406574e785 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 15:01:13 +0900 Subject: [PATCH 21/29] Rename Barline -> BarLine. --- osu.Game.Rulesets.Mania/Objects/{Barline.cs => BarLine.cs} | 2 +- .../Drawables/{DrawableBarline.cs => DrawableBarLine.cs} | 6 +++--- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 2 +- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) rename osu.Game.Rulesets.Mania/Objects/{Barline.cs => BarLine.cs} (92%) rename osu.Game.Rulesets.Mania/Objects/Drawables/{DrawableBarline.cs => DrawableBarLine.cs} (92%) diff --git a/osu.Game.Rulesets.Mania/Objects/Barline.cs b/osu.Game.Rulesets.Mania/Objects/BarLine.cs similarity index 92% rename from osu.Game.Rulesets.Mania/Objects/Barline.cs rename to osu.Game.Rulesets.Mania/Objects/BarLine.cs index 9b229a8d52..b635977fd1 100644 --- a/osu.Game.Rulesets.Mania/Objects/Barline.cs +++ b/osu.Game.Rulesets.Mania/Objects/BarLine.cs @@ -3,7 +3,7 @@ using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { - public class Barline : ManiaHitObject + public class BarLine : ManiaHitObject { /// /// The control point which this bar line is part of. diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs similarity index 92% rename from osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs rename to osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index eee32a9da3..9b1e1e4e3d 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -12,12 +12,12 @@ using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Objects.Drawables { /// - /// Visualises a . Although this derives DrawableManiaHitObject, + /// Visualises a . Although this derives DrawableManiaHitObject, /// this does not handle input/sound like a normal hit object. /// - public class DrawableBarline : DrawableManiaHitObject + public class DrawableBarLine : DrawableManiaHitObject { - public DrawableBarline(Barline hitObject) + public DrawableBarLine(BarLine hitObject) : base(hitObject, null) { AutoSizeAxes = Axes.Y; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 871306b98c..4ddb7ad42a 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -104,7 +104,7 @@ namespace osu.Game.Rulesets.Mania.UI int index = 0; for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength, index++) { - maniaPlayfield.Add(new DrawableBarline(new Barline + maniaPlayfield.Add(new DrawableBarLine(new BarLine { StartTime = t, ControlPoint = point, diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index dcf725e091..d1b6fbaf7c 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -207,7 +207,7 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); - public void Add(DrawableBarline barline) => barlineContainer.Add(barline); + public void Add(DrawableBarLine barline) => barlineContainer.Add(barline); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index cc5e6dd81e..3d5614bd90 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -62,7 +62,7 @@ - + @@ -71,7 +71,7 @@ - + From 32550bda4f796c9b8f4694a77d7a3348fb967052 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 15:18:06 +0900 Subject: [PATCH 22/29] Make drawable bar line a bit more sane. --- .../Objects/Drawables/DrawableBarLine.cs | 57 +++++++++---------- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 10 ++-- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index 9b1e1e4e3d..e253989ebc 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -17,8 +17,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// public class DrawableBarLine : DrawableManiaHitObject { - public DrawableBarLine(BarLine hitObject) - : base(hitObject, null) + public DrawableBarLine(BarLine barLine) + : base(barLine, null) { AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; @@ -31,38 +31,35 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Height = 1 }); - int signatureRelativeIndex = hitObject.BeatIndex % (int)hitObject.ControlPoint.TimeSignature; + bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; - switch (signatureRelativeIndex) + if (isMajor) { - case 0: - Add(new EquilateralTriangle - { - Name = "Left triangle", - Anchor = Anchor.BottomLeft, - Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = -9, - Rotation = 90, - BypassAutoSizeAxes = Axes.Both - }); + Add(new EquilateralTriangle + { + Name = "Left triangle", + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = -9, + Rotation = 90, + BypassAutoSizeAxes = Axes.Both + }); - Add(new EquilateralTriangle - { - Name = "Right triangle", - Anchor = Anchor.BottomRight, - Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = 9, - Rotation = -90, - BypassAutoSizeAxes = Axes.Both, - }); - break; - case 1: - case 3: - Alpha = 0.2f; - break; + Add(new EquilateralTriangle + { + Name = "Right triangle", + Anchor = Anchor.BottomRight, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = 9, + Rotation = -90, + BypassAutoSizeAxes = Axes.Both, + }); } + + if (!isMajor && barLine.BeatIndex % 2 == 1) + Alpha = 0.2f; } protected override void UpdateState(ArmedState state) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index d1b6fbaf7c..2e6b63579e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Mania.UI private readonly FlowContainer columns; public IEnumerable Columns => columns.Children; - private readonly ControlPointContainer barlineContainer; + private readonly ControlPointContainer barLineContainer; private List normalColumnColours = new List(); private Color4 specialColumnColour; @@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Mania.UI Padding = new MarginPadding { Top = HIT_TARGET_POSITION }, Children = new[] { - barlineContainer = new ControlPointContainer(timingChanges) + barLineContainer = new ControlPointContainer(timingChanges) { Name = "Bar lines", Anchor = Anchor.TopCentre, @@ -207,7 +207,7 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); - public void Add(DrawableBarLine barline) => barlineContainer.Add(barline); + public void Add(DrawableBarLine barline) => barLineContainer.Add(barline); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { @@ -242,7 +242,7 @@ namespace osu.Game.Rulesets.Mania.UI timeSpan = MathHelper.Clamp(timeSpan, time_span_min, time_span_max); - barlineContainer.TimeSpan = value; + barLineContainer.TimeSpan = value; Columns.ForEach(c => c.ControlPointContainer.TimeSpan = value); } } @@ -256,7 +256,7 @@ namespace osu.Game.Rulesets.Mania.UI { // Due to masking differences, it is not possible to get the width of the columns container automatically // While masking on effectively only the Y-axis, so we need to set the width of the bar line container manually - barlineContainer.Width = columns.Width; + barLineContainer.Width = columns.Width; } private class TransformTimeSpan : Transform From 4b6f2efa76a469cf039712fbaed361ad340697d3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 15:30:05 +0900 Subject: [PATCH 23/29] Cleanups. --- osu.Game.Rulesets.Mania/Objects/BarLine.cs | 3 +- .../Objects/Drawables/DrawableBarLine.cs | 35 +++++++++++-------- .../UI/ManiaHitRenderer.cs | 1 + 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/BarLine.cs b/osu.Game.Rulesets.Mania/Objects/BarLine.cs index b635977fd1..50e326086e 100644 --- a/osu.Game.Rulesets.Mania/Objects/BarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/BarLine.cs @@ -1,5 +1,4 @@ using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { @@ -12,7 +11,7 @@ namespace osu.Game.Rulesets.Mania.Objects /// /// The index of the beat which this bar line represents within the control point. - /// This is a "major" beat at % == 0. + /// This is a "major" bar line if % == 0. /// public int BeatIndex; } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index e253989ebc..7554472507 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -1,10 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK; -using OpenTK.Input; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Objects.Drawables; @@ -17,18 +14,28 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// public class DrawableBarLine : DrawableManiaHitObject { + /// + /// Height of major bar line triangles. + /// + private const float triangle_height = 12; + + /// + /// Offset of the major bar line triangles from the sides of the bar line. + /// + private const float triangle_offset = 9; + public DrawableBarLine(BarLine barLine) - : base(barLine, null) + : base(barLine) { - AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; + Height = 1; Add(new Box { + Name = "Bar line", Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = 1 + RelativeSizeAxes = Axes.Both, }); bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; @@ -40,10 +47,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Name = "Left triangle", Anchor = Anchor.BottomLeft, Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = -9, - Rotation = 90, - BypassAutoSizeAxes = Axes.Both + Size = new Vector2(triangle_height), + X = -triangle_offset, + Rotation = 90 }); Add(new EquilateralTriangle @@ -51,10 +57,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Name = "Right triangle", Anchor = Anchor.BottomRight, Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = 9, - Rotation = -90, - BypassAutoSizeAxes = Axes.Both, + Size = new Vector2(triangle_height), + X = triangle_offset, + Rotation = -90 }); } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 4ddb7ad42a..57477147d5 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -99,6 +99,7 @@ namespace osu.Game.Rulesets.Mania.UI { TimingControlPoint point = timingPoints[i]; + // Stop on the beat before the next timing point, or if there is no next timing point stop slightly past the last object double endTime = i < timingPoints.Count - 1 ? timingPoints[i + 1].Time - point.BeatLength : lastObjectTime + point.BeatLength * (int)point.TimeSignature; int index = 0; From 586fc782cf5ec2da379f518d3924bafe50fd43d5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 16:00:14 +0900 Subject: [PATCH 24/29] Fix line endings. --- osu.Game.Rulesets.Mania/Objects/BarLine.cs | 37 +++-- .../Objects/Drawables/DrawableBarLine.cs | 146 +++++++++--------- 2 files changed, 93 insertions(+), 90 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/BarLine.cs b/osu.Game.Rulesets.Mania/Objects/BarLine.cs index 50e326086e..76a3d3920d 100644 --- a/osu.Game.Rulesets.Mania/Objects/BarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/BarLine.cs @@ -1,18 +1,21 @@ -using osu.Game.Beatmaps.ControlPoints; - -namespace osu.Game.Rulesets.Mania.Objects -{ - public class BarLine : ManiaHitObject - { - /// - /// The control point which this bar line is part of. - /// - public TimingControlPoint ControlPoint; - - /// - /// The index of the beat which this bar line represents within the control point. - /// This is a "major" bar line if % == 0. - /// - public int BeatIndex; - } +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps.ControlPoints; + +namespace osu.Game.Rulesets.Mania.Objects +{ + public class BarLine : ManiaHitObject + { + /// + /// The control point which this bar line is part of. + /// + public TimingControlPoint ControlPoint; + + /// + /// The index of the beat which this bar line represents within the control point. + /// This is a "major" bar line if % == 0. + /// + public int BeatIndex; + } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index 7554472507..0b4d8b2d4e 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -1,74 +1,74 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Game.Rulesets.Objects.Drawables; - -namespace osu.Game.Rulesets.Mania.Objects.Drawables -{ - /// - /// Visualises a . Although this derives DrawableManiaHitObject, - /// this does not handle input/sound like a normal hit object. - /// - public class DrawableBarLine : DrawableManiaHitObject - { - /// - /// Height of major bar line triangles. - /// - private const float triangle_height = 12; - - /// - /// Offset of the major bar line triangles from the sides of the bar line. - /// - private const float triangle_offset = 9; - - public DrawableBarLine(BarLine barLine) - : base(barLine) - { - RelativeSizeAxes = Axes.X; - Height = 1; - - Add(new Box - { - Name = "Bar line", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.Both, - }); - - bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; - - if (isMajor) - { - Add(new EquilateralTriangle - { - Name = "Left triangle", - Anchor = Anchor.BottomLeft, - Origin = Anchor.TopCentre, - Size = new Vector2(triangle_height), - X = -triangle_offset, - Rotation = 90 - }); - - Add(new EquilateralTriangle - { - Name = "Right triangle", - Anchor = Anchor.BottomRight, - Origin = Anchor.TopCentre, - Size = new Vector2(triangle_height), - X = triangle_offset, - Rotation = -90 - }); - } - - if (!isMajor && barLine.BeatIndex % 2 == 1) - Alpha = 0.2f; - } - - protected override void UpdateState(ArmedState state) - { - } - } +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + /// + /// Visualises a . Although this derives DrawableManiaHitObject, + /// this does not handle input/sound like a normal hit object. + /// + public class DrawableBarLine : DrawableManiaHitObject + { + /// + /// Height of major bar line triangles. + /// + private const float triangle_height = 12; + + /// + /// Offset of the major bar line triangles from the sides of the bar line. + /// + private const float triangle_offset = 9; + + public DrawableBarLine(BarLine barLine) + : base(barLine) + { + RelativeSizeAxes = Axes.X; + Height = 1; + + Add(new Box + { + Name = "Bar line", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.Both, + }); + + bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; + + if (isMajor) + { + Add(new EquilateralTriangle + { + Name = "Left triangle", + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopCentre, + Size = new Vector2(triangle_height), + X = -triangle_offset, + Rotation = 90 + }); + + Add(new EquilateralTriangle + { + Name = "Right triangle", + Anchor = Anchor.BottomRight, + Origin = Anchor.TopCentre, + Size = new Vector2(triangle_height), + X = triangle_offset, + Rotation = -90 + }); + } + + if (!isMajor && barLine.BeatIndex % 2 == 1) + Alpha = 0.2f; + } + + protected override void UpdateState(ArmedState state) + { + } + } } \ No newline at end of file From e529ced131563ef930d0eafdc4cf06c3c8026580 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 16:18:01 +0900 Subject: [PATCH 25/29] 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 26/29] 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 27/29] 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 28/29] 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 29/29] 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;