From 9f78f8607b0fb83299e1255f0333858d3b01c6ec Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 2 Nov 2016 19:07:07 -0400 Subject: [PATCH] Implement General options section --- osu.Desktop.VisualTests/OpenTK.dll.config | 25 +++ .../Tests/TestCaseOptions.cs | 29 +++ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/Overlays/Options.cs | 185 +++++++++++++++++- 4 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 osu.Desktop.VisualTests/OpenTK.dll.config create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseOptions.cs diff --git a/osu.Desktop.VisualTests/OpenTK.dll.config b/osu.Desktop.VisualTests/OpenTK.dll.config new file mode 100644 index 0000000000..5620e3d9e2 --- /dev/null +++ b/osu.Desktop.VisualTests/OpenTK.dll.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs b/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs new file mode 100644 index 0000000000..72cebe745d --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs @@ -0,0 +1,29 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.GameModes.Testing; +using osu.Framework.Graphics; +using osu.Game.Graphics.UserInterface; +using OpenTK.Input; +using osu.Game.Overlays; +using osu.Framework.Graphics.Containers; + +namespace osu.Desktop.VisualTests.Tests +{ + class TestCaseOptions : TestCase + { + public override string Name => @"Options"; + + public override string Description => @"Tests the options overlay"; + + private Options options; + + public override void Reset() + { + base.Reset(); + + Children = new[] { options = new Options() }; + options.ToggleVisibility(); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 65fb72e2a6..36973a358d 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -166,6 +166,7 @@ + diff --git a/osu.Game/Overlays/Options.cs b/osu.Game/Overlays/Options.cs index b413d175c5..19bb73e393 100644 --- a/osu.Game/Overlays/Options.cs +++ b/osu.Game/Overlays/Options.cs @@ -1,26 +1,34 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Diagnostics; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; +using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; +using osu.Framework.Platform; namespace osu.Game.Overlays { public class Options : OverlayContainer { - private const float width = 300; + private const float width = 400; + private FlowContainer optionsContainer; + private BasicStorage storage; protected override void Load(BaseGame game) { base.Load(game); + storage = game.Host.Storage; + Depth = float.MaxValue; RelativeSizeAxes = Axes.Y; Size = new Vector2(width, 1); @@ -32,8 +40,101 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.Both, Colour = new Color4(0.1f, 0.1f, 0.1f, 0.9f) + }, + // TODO: Links on the side to jump to a section + new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = 5, Right = 5, Top = 50 }, + Children = new[] + { + optionsContainer = new FlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FlowDirection.VerticalOnly, + Children = new[] + { + new SpriteText + { + Text = "Options", + TextSize = 40, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }, + new SpriteText + { + Colour = new Color4(235, 117, 139, 255), + Text = "Change the way osu! behaves", + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Margin = new MarginPadding { Bottom = 25 }, + }, + new SpriteText + { + Text = "TODO: SEARCH", + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Margin = new MarginPadding { Bottom = 25 }, + } + } + } + } } }; + addGeneral(); + } + + private void addGeneral() + { + optionsContainer.Add(new OptionsSection + { + Header = "General", + Children = new[] + { + new OptionsSubsection + { + Header = "Sign In", + Children = new[] + { + new SpriteText { Text = "TODO" } + } + }, + new OptionsSubsection + { + Header = "Language", + Children = new Drawable[] + { + new SpriteText { Text = "TODO: Dropdown" }, + new BasicCheckBox + { + Children = new[] { new SpriteText { Text = "Prefer metadata in original language" } } + }, + new BasicCheckBox + { + Children = new[] { new SpriteText { Text = "Use alternative font for chat display" } } + }, + } + }, + new OptionsSubsection + { + Header = "Updates", + Children = new Drawable[] + { + new SpriteText { Text = "TODO: Dropdown" }, + new SpriteText { Text = "Your osu! is up to date" }, // TODO: map this to reality + new Button + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Colour = new Color4(14, 132, 165, 255), + Text = "Open osu! folder", + Action = storage.OpenOsuDirectory, + } + } + } + } + }); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) @@ -59,4 +160,86 @@ namespace osu.Game.Overlays MoveToX(-width, 300, EasingTypes.Out); } } + + class OptionsSection : Container + { + private SpriteText header; + private FlowContainer content; + protected override Container Content => content; + + public string Header + { + get { return header.Text; } + set { header.Text = value.ToUpper(); } + } + + public OptionsSection() + { + const int headerSize = 40, headerMargin = 25; + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; + AddInternal(new[] + { + header = new SpriteText + { + TextSize = headerSize, + Colour = new Color4(88, 218, 254, 255), + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + }, + content = new FlowContainer + { + Margin = new MarginPadding { Top = headerSize + headerMargin, Left = 10 }, + Direction = FlowDirection.VerticalOnly, + Spacing = new Vector2(0, 25), + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }, + }); + } + } + + class OptionsSubsection : Container + { + private SpriteText header; + private Container content; + protected override Container Content => content; + + public string Header + { + get { return header.Text; } + set { header.Text = value.ToUpper(); } + } + + public OptionsSubsection() + { + const int borderWidth = 3, borderMargin = 10; + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + AddInternal(new Drawable[] + { + new Box + { + Colour = new Color4(50, 50, 50, 255), + RelativeSizeAxes = Axes.Y, + Width = borderWidth, + }, + content = new FlowContainer + { + Direction = FlowDirection.VerticalOnly, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Left = borderWidth + borderMargin }, + Children = new[] + { + header = new SpriteText + { + TextSize = 25, + // TODO: Bold + } + } + }, + }); + } + } }