diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs b/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs new file mode 100644 index 0000000000..270fe4b42a --- /dev/null +++ b/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs @@ -0,0 +1,57 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using OpenTK.Graphics; + +namespace osu.Game.Graphics.UserInterface +{ + public class OsuDropDownHeader : DropDownHeader + { + private SpriteText label; + protected override string Label + { + get { return label.Text; } + set { label.Text = value; } + } + + public OsuDropDownHeader() + { + Foreground.Padding = new MarginPadding(4); + + AutoSizeAxes = Axes.None; + Margin = new MarginPadding { Bottom = 4 }; + CornerRadius = 4; + Height = 40; + + Children = new[] + { + label = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, + new TextAwesome + { + Icon = FontAwesome.fa_chevron_down, + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Margin = new MarginPadding { Right = 4 }, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = Color4.Black.Opacity(0.5f); + BackgroundColourHover = colours.PinkDarker; + } + } +} \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs new file mode 100644 index 0000000000..9640b42533 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs @@ -0,0 +1,54 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Graphics.UserInterface; +using OpenTK; + +namespace osu.Game.Graphics.UserInterface +{ + public class OsuDropDownMenu : DropDownMenu + { + protected override DropDownHeader CreateHeader() => new OsuDropDownHeader(); + + protected override IEnumerable> GetDropDownItems(IEnumerable values) + { + return values.Select(v => + { + var field = typeof(U).GetField(Enum.GetName(typeof(U), v)); + return new OsuDropDownMenuItem( + field.GetCustomAttribute()?.Description ?? field.Name, v); + }); + + } + + public OsuDropDownMenu() + { + //TODO: breaks padding; figure why. + //ContentContainer.CornerRadius = 4; + } + + protected override void AnimateOpen() + { + ContentContainer.FadeIn(300, EasingTypes.OutQuint); + } + + protected override void AnimateClose() + { + ContentContainer.FadeOut(300, EasingTypes.OutQuint); + } + + protected override void UpdateContentHeight() + { + if (State == DropDownMenuState.Opened) + ContentContainer.ResizeTo(new Vector2(1, ContentHeight), 300, EasingTypes.OutQuint); + else + ContentContainer.ResizeTo(new Vector2(1, 0), 300, EasingTypes.OutQuint); + } + } +} \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs new file mode 100644 index 0000000000..489767558a --- /dev/null +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs @@ -0,0 +1,57 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using OpenTK.Graphics; + +namespace osu.Game.Graphics.UserInterface +{ + public class OsuDropDownMenuItem : DropDownMenuItem + { + public OsuDropDownMenuItem(string text, U value) : base(text, value) + { + Foreground.Padding = new MarginPadding(2); + + Children = new[] + { + new FlowContainer + { + Direction = FlowDirection.HorizontalOnly, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new TextAwesome + { + Icon = FontAwesome.fa_chevron_right, + Colour = Color4.Black, + TextSize = 12, + Margin = new MarginPadding { Right = 3 }, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + }, + new OsuSpriteText { + Text = text, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + } + } + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = Color4.Black.Opacity(0.5f); + BackgroundColourHover = colours.PinkDarker; + BackgroundColourSelected = Color4.Black.Opacity(0.5f); + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/OptionDropdown.cs b/osu.Game/Overlays/Options/OptionDropdown.cs index 8bd9e313c9..e2c2e7e8bb 100644 --- a/osu.Game/Overlays/Options/OptionDropdown.cs +++ b/osu.Game/Overlays/Options/OptionDropdown.cs @@ -1,23 +1,16 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Reflection; -using OpenTK; -using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options { - public class OptionDropdown : FlowContainer + public class OptionDropDown : FlowContainer { private DropDownMenu dropdown; private SpriteText text; @@ -28,7 +21,6 @@ namespace osu.Game.Overlays.Options set { text.Text = value; - text.Alpha = string.IsNullOrEmpty(value) ? 0 : 1; } } @@ -64,7 +56,7 @@ namespace osu.Game.Overlays.Options base.Dispose(isDisposing); } - public OptionDropdown() + public OptionDropDown() { if (!typeof(T).IsEnum) throw new InvalidOperationException("OptionsDropdown only supports enums as the generic type argument"); @@ -76,7 +68,7 @@ namespace osu.Game.Overlays.Options text = new OsuSpriteText { Alpha = 0, }, - dropdown = new StyledDropDownMenu + dropdown = new OsuDropDownMenu { Margin = new MarginPadding { Top = 5 }, RelativeSizeAxes = Axes.X, @@ -85,137 +77,5 @@ namespace osu.Game.Overlays.Options }; dropdown.ValueChanged += Dropdown_ValueChanged; } - - private class StyledDropDownMenu : DropDownMenu - { - protected override float DropDownListSpacing => 4; - - protected override DropDownComboBox CreateComboBox() - { - return new StyledDropDownComboBox(); - } - - protected override IEnumerable> GetDropDownItems(IEnumerable values) - { - return values.Select(v => - { - var field = typeof(U).GetField(Enum.GetName(typeof(U), v)); - return new StyledDropDownMenuItem( - field.GetCustomAttribute()?.Description ?? field.Name, v); - }); - - } - - public StyledDropDownMenu() - { - ComboBox.CornerRadius = 4; - DropDown.CornerRadius = 4; - } - - protected override void AnimateOpen() - { - foreach (StyledDropDownMenuItem child in DropDownItemsContainer.Children) - { - child.FadeIn(200); - child.ResizeTo(new Vector2(1, 24), 200); - } - DropDown.Show(); - } - - protected override void AnimateClose() - { - foreach (StyledDropDownMenuItem child in DropDownItemsContainer.Children) - { - child.ResizeTo(new Vector2(1, 0), 200); - child.FadeOut(200); - } - } - } - - private class StyledDropDownComboBox : DropDownComboBox - { - private SpriteText label; - protected override string Label - { - get { return label.Text; } - set { label.Text = value; } - } - - public StyledDropDownComboBox() - { - Foreground.Padding = new MarginPadding(4); - - AutoSizeAxes = Axes.None; - Height = 40; - - Children = new[] - { - label = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - }, - new TextAwesome - { - Icon = FontAwesome.fa_chevron_down, - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Margin = new MarginPadding { Right = 4 }, - } - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - BackgroundColour = Color4.Black.Opacity(0.5f); - BackgroundColourHover = colours.PinkDarker; - } - } - - private class StyledDropDownMenuItem : DropDownMenuItem - { - public StyledDropDownMenuItem(string text, U value) : base(text, value) - { - AutoSizeAxes = Axes.None; - Height = 0; - Foreground.Padding = new MarginPadding(2); - - Children = new[] - { - new FlowContainer - { - Direction = FlowDirection.HorizontalOnly, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] - { - new TextAwesome - { - Icon = FontAwesome.fa_chevron_right, - Colour = Color4.Black, - TextSize = 12, - Margin = new MarginPadding { Right = 3 }, - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - }, - new OsuSpriteText { - Text = text, - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - } - } - } - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - BackgroundColour = Color4.Black.Opacity(0.5f); - BackgroundColourHover = colours.PinkDarker; - BackgroundColourSelected = Color4.Black.Opacity(0.5f); - } - } } } diff --git a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs index c40401f0ea..f9cde39eb6 100644 --- a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs @@ -1,12 +1,12 @@ -//Copyright (c) 2007-2016 ppy Pty Ltd . -//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Framework.Configuration; -using osu.Framework.Graphics; -using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; - +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; + namespace osu.Game.Overlays.Options.Sections.Gameplay { public class GeneralOptions : OptionsSubsection @@ -23,12 +23,12 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay LabelText = "Background dim", Bindable = (BindableInt)config.GetBindable(OsuConfig.DimLevel) }, - new OptionDropdown + new OptionDropDown { LabelText = "Progress display", Bindable = config.GetBindable(OsuConfig.ProgressBarType) }, - new OptionDropdown + new OptionDropDown { LabelText = "Score meter type", Bindable = config.GetBindable(OsuConfig.ScoreMeter) diff --git a/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs b/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs index 0438e40761..937845c5ed 100644 --- a/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Options.Sections.General { Children = new Drawable[] { - new OptionDropdown + new OptionDropDown { LabelText = "Release stream", Bindable = config.GetBindable(OsuConfig.ReleaseStream), diff --git a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs index ff1fcf05c3..6f9b24ac07 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs @@ -57,7 +57,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics LabelText = "Softening filter", Bindable = config.GetBindable(OsuConfig.BloomSoftening) }, - new OptionDropdown + new OptionDropDown { LabelText = "Screenshot", Bindable = config.GetBindable(OsuConfig.ScreenshotFormat) diff --git a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs index 2ef84ca8ac..6565352c51 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs @@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics Children = new Drawable[] { // TODO: this needs to be a custom dropdown at some point - new OptionDropdown + new OptionDropDown { LabelText = "Frame limiter", Bindable = config.GetBindable(FrameworkConfig.FrameSync) diff --git a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs index 6a4f26ce25..894fa2a2b3 100644 --- a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Options.Sections.Input LabelText = "Map absolute raw input to the osu! window", Bindable = config.GetBindable(OsuConfig.AbsoluteToOsuWindow) }, - new OptionDropdown + new OptionDropDown { LabelText = "Confine mouse cursor", Bindable = config.GetBindable(OsuConfig.ConfineMouse), diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index f8fa2c951a..3eeffa3206 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -98,6 +98,9 @@ + + + @@ -234,7 +237,7 @@ - + @@ -280,4 +283,4 @@ --> - + \ No newline at end of file