diff --git a/osu-framework b/osu-framework index ea56eab4a2..24af3b161d 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit ea56eab4a2bb4c9723052586ed30c687898fecb0 +Subproject commit 24af3b161da9447b678edd8ec32193df54f71e3b diff --git a/osu.Game/Graphics/UserInterface/BackButton.cs b/osu.Game/Graphics/UserInterface/BackButton.cs index b42cb7fc4a..0cf442ff39 100644 --- a/osu.Game/Graphics/UserInterface/BackButton.cs +++ b/osu.Game/Graphics/UserInterface/BackButton.cs @@ -4,52 +4,91 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; namespace osu.Game.Graphics.UserInterface { // Basic back button as it was on stable (kinda). No skinning possible for now - class BackButton : ExtendableButton + class BackButton : ClickableContainer { private TextAwesome icon; - private Vector2 iconPos = new Vector2(20, 0); + private Vector2 iconPos; + + private Box bgBox; + private Box textBox; + private Container textContainer; + private SpriteText spriteText; + + public Vector2 ExtendLength; + public Vector2 InitialExtendLength; + + private const double transformTime = 300.0; public BackButton() { - InitialExtendLenght = new Vector2(40, 0); - ExtendLenght = new Vector2(60, 0); + // [ should be set or should be relative? + InitialExtendLength = new Vector2(40, 0); + ExtendLength = new Vector2(60, 0); + iconPos = new Vector2(20, 0); - RelativeSizeAxes = Axes.Y; Width = 80; - //Height = 40; // should be set or should be relative? - - Text = @"Back"; - - BGColour = new Color4(195, 40, 140, 255); - Colour = new Color4(238, 51, 153, 255); + //Height = 40; + // ] should be set or should be relative? Children = new Drawable[] { + bgBox = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(195, 40, 140, 255), + }, icon = new TextAwesome { Anchor = Anchor.CentreLeft, TextSize = 25, Position = iconPos, Icon = FontAwesome.fa_osu_left_o + }, + textContainer = new Container + { + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + RelativeSizeAxes = Axes.Both, + Position = Position + InitialExtendLength, + Children = new Drawable[] + { + textBox = new Box + { + Colour = new Color4(238, 51, 153, 255), + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + RelativeSizeAxes = Axes.Both, + Shear = new Vector2(0.1f, 0), + EdgeSmoothness = new Vector2(1.5f, 0), + }, + spriteText = new SpriteText + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Text = @"Back", + } + } } }; - // HACK: because it never uses InitialExtendLenght that we give to it on creation - textContainer.Position = Position + InitialExtendLenght; + // HACK: because it never uses InitialExtendLength that we give to it on creation + textContainer.Position = Position + InitialExtendLength; } protected override bool OnHover(InputState state) { - bool result = base.OnHover(state); - icon.ClearTransformations(); + textContainer.ClearTransformations(); - icon.MoveToX(iconPos.X + 10, 150, EasingTypes.OutElastic); + textContainer.MoveTo(Position + ExtendLength, transformTime, EasingTypes.OutElastic); + icon.MoveToX(iconPos.X + 10, transformTime, EasingTypes.OutElastic); int duration = 0; //(int)(Game.Audio.BeatLength / 2); if (duration == 0) duration = 250; @@ -69,15 +108,34 @@ namespace osu.Game.Graphics.UserInterface LoopDelay = duration }); - return result; + return true; } protected override void OnHoverLost(InputState state) { icon.ClearTransformations(); - icon.MoveToX(iconPos.X, 150, EasingTypes.OutElastic); + textContainer.ClearTransformations(); - base.OnHoverLost(state); + textContainer.MoveTo(Position + InitialExtendLength, transformTime, EasingTypes.OutElastic); + icon.MoveToX(iconPos.X, transformTime, EasingTypes.OutElastic); + } + + protected override bool OnClick(InputState state) + { + var flash = new Box + { + RelativeSizeAxes = RelativeSizeAxes + }; + + Add(flash); + + flash.Colour = textBox.Colour; + flash.BlendingMode = BlendingMode.Additive; + flash.Alpha = 0.3f; + flash.FadeOutFromOne(200); + flash.Expire(); + + return base.OnClick(state); } } } diff --git a/osu.Game/Graphics/UserInterface/ExtendableButton.cs b/osu.Game/Graphics/UserInterface/ExtendableButton.cs deleted file mode 100644 index 4b1b08cd7c..0000000000 --- a/osu.Game/Graphics/UserInterface/ExtendableButton.cs +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) 2007-2016 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE - -using osu.Framework.Input; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Transformations; -using OpenTK; -using OpenTK.Graphics; - -namespace osu.Game.Graphics.UserInterface -{ - public class ExtendableButton : ClickableContainer - { - public Color4 BGColour - { - get { return bgBox.Colour; } - set { bgBox.Colour = value; } - } - public new Color4 Colour - { - get { return textBox.Colour; } - set { textBox.Colour = value; } - } - public new Vector2 Shear - { - get { return textBox.Shear; } - set { textBox.Shear = value; } - } - public string Text - { - get { return spriteText?.Text; } - set - { - if (spriteText != null) - spriteText.Text = value; - } - } - - private Box bgBox; - private Box textBox; - public Container textContainer; - private SpriteText spriteText; - - public Vector2 ExtendLenght = new Vector2(80,0); // this one can be defaulted - public Vector2 InitialExtendLenght/* = new Vector2(40, 0)*/; // but this one unfortunately cant - - public ExtendableButton(float initialExtendLenghtX = 20, float initialExtendLenghtY = 0) - { - InitialExtendLenght = new Vector2(initialExtendLenghtX, initialExtendLenghtY); // because it just wont use defined settings when creating - - Children = new Drawable[] - { - bgBox = new Box - { - RelativeSizeAxes = Axes.Both, - }, - textContainer = new Container - { - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - RelativeSizeAxes = Axes.Both, - Position = Position + InitialExtendLenght, - Children = new Drawable[] - { - textBox = new Box - { - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - RelativeSizeAxes = Axes.Both, - Shear = new Vector2(0.1f, 0), // should be relative? - EdgeSmoothness = new Vector2(1, 1), // should be based on which side is being cut? - }, - spriteText = new SpriteText - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - } - } - } - }; - } - - protected override bool OnHover(InputState state) - { - textContainer.ClearTransformations(); - textContainer.MoveTo(Position + ExtendLenght, 150, EasingTypes.OutElastic); - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - base.OnHoverLost(state); - textContainer.ClearTransformations(); - textContainer.MoveTo(Position + InitialExtendLenght, 150, EasingTypes.OutElastic); - } - - protected override bool OnClick(InputState state) - { - var flash = new Box - { - RelativeSizeAxes = Axes.Both - }; - - Add(flash); - - flash.Colour = textBox.Colour; - flash.BlendingMode = BlendingMode.Additive; - flash.Alpha = 0.3f; - flash.FadeOutFromOne(200); - flash.Expire(); - - return base.OnClick(state); - } - } -} diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 9688b36a99..66f6e9c2d8 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -123,8 +123,9 @@ namespace osu.Game.Screens.Select }, new BackButton { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.Y, Action = () => Exit() }, new Button diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index ed7e83e0eb..f1bdd47b68 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -66,7 +66,6 @@ -