From b17d9ac06ea649b977ead563b7b5e4ecefe70ab9 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 28 Aug 2017 17:55:50 +0900 Subject: [PATCH] Move EditorMenuBar into the Edit namespace, and fix a minor styling issue. --- osu-framework | 2 +- .../Visual/TestCaseEditorMenuBar.cs | 145 +-------------- osu.Game/Graphics/UserInterface/OsuMenu.cs | 5 +- osu.Game/Screens/Edit/Editor.cs | 174 ++++++++++++++++++ osu.Game/Screens/Edit/Menus/EditorMenuBar.cs | 131 +++++++++++++ .../Screens/Edit/Menus/EditorMenuBarItem.cs | 15 ++ osu.Game/Screens/Edit/Menus/EditorMenuItem.cs | 23 +++ .../Edit/Menus/EditorMenuItemSpacer.cs | 13 ++ osu.Game/osu.Game.csproj | 4 + 9 files changed, 365 insertions(+), 147 deletions(-) create mode 100644 osu.Game/Screens/Edit/Menus/EditorMenuBar.cs create mode 100644 osu.Game/Screens/Edit/Menus/EditorMenuBarItem.cs create mode 100644 osu.Game/Screens/Edit/Menus/EditorMenuItem.cs create mode 100644 osu.Game/Screens/Edit/Menus/EditorMenuItemSpacer.cs diff --git a/osu-framework b/osu-framework index f6a1df24ee..c7457f0ce9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit f6a1df24eeef78e89f2d6e24fe1b43756eaae51e +Subproject commit c7457f0ce9ef3f663ee800f6b7fc574e9abff1da diff --git a/osu.Desktop.Tests/Visual/TestCaseEditorMenuBar.cs b/osu.Desktop.Tests/Visual/TestCaseEditorMenuBar.cs index 95d34543bb..9ff4f4c591 100644 --- a/osu.Desktop.Tests/Visual/TestCaseEditorMenuBar.cs +++ b/osu.Desktop.Tests/Visual/TestCaseEditorMenuBar.cs @@ -1,19 +1,10 @@ // 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.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface; using osu.Framework.Testing; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Edit.Menus; namespace osu.Desktop.Tests.Visual { @@ -90,139 +81,5 @@ namespace osu.Desktop.Tests.Visual } }); } - - private class EditorMenuBar : MenuBar - { - protected override DrawableMenuBarItem CreateDrawableMenuBarItem(MenuItem item) => new DrawableEditorMenuBarItem(item); - - private class DrawableEditorMenuBarItem : DrawableMenuBarItem - { - private const int fade_duration = 250; - private const float text_size = 17; - - private readonly Container background; - - private Color4 normalColour; - - public DrawableEditorMenuBarItem(MenuItem item) - : base(item) - { - - Text.Padding = new MarginPadding(8); - - AddInternal(background = new Container - { - RelativeSizeAxes = Axes.Both, - Masking = true, - Depth = float.MaxValue, - Alpha = 0, - Child = new Container - { - // The following is done so we can have top rounded corners but not bottom corners - RelativeSizeAxes = Axes.Both, - Height = 2, - Masking = true, - CornerRadius = 5, - Child = new Box { RelativeSizeAxes = Axes.Both } - } - }); - - Menu.OnOpen += menuOpen; - Menu.OnClose += menuClose; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - background.Colour = colours.Gray3; - Text.Colour = normalColour = colours.BlueLight; - } - - private void menuOpen() - { - background.FadeIn(fade_duration, Easing.OutQuint); - Text.FadeColour(Color4.White, fade_duration, Easing.OutQuint); - } - - private void menuClose() - { - background.FadeOut(fade_duration, Easing.OutQuint); - Text.FadeColour(normalColour, fade_duration, Easing.OutQuint); - } - - protected override SpriteText CreateText() => new OsuSpriteText { TextSize = text_size }; - - protected override Menu CreateMenu() => new EditorMenu(); - - private class EditorMenu : OsuMenu - { - public EditorMenu() - { - Anchor = Anchor.BottomLeft; - BypassAutoSizeAxes = Axes.Both; - OriginPosition = new Vector2(8, 0); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - BackgroundColour = colours.Gray3; - } - - protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableEditorMenuItem(item); - - private class DrawableEditorMenuItem : DrawableOsuMenuItem - { - public override bool HandleInput => !isSpacer; - private readonly bool isSpacer; - - public DrawableEditorMenuItem(MenuItem item) - : base(item) - { - - isSpacer = item is EditorMenuSpacer; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - BackgroundColour = colours.Gray3; - BackgroundColourHover = colours.Gray2; - } - } - } - } - } - - private class EditorMenuBarItem : MenuItem - { - public EditorMenuBarItem(string text) - : base(text) - { - } - } - - private class EditorMenuItem : OsuMenuItem - { - private const int min_text_length = 40; - - public EditorMenuItem(string text, MenuItemType type = MenuItemType.Standard) - : base(text.PadRight(min_text_length), type) - { - } - - public EditorMenuItem(string text, MenuItemType type, Action action) - : base(text.PadRight(min_text_length), type, action) - { - } - } - - private class EditorMenuSpacer : EditorMenuItem - { - public EditorMenuSpacer() - : base(" ") - { - } - } } } diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index efc6998ca7..e0bb23df5d 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -105,9 +105,10 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } - protected override Drawable CreateContent() => text = new TextContainer(); + protected sealed override Drawable CreateContent() => text = CreateTextContainer(); + protected virtual TextContainer CreateTextContainer() => new TextContainer(); - private class TextContainer : Container, IHasText + protected class TextContainer : Container, IHasText { public string Text { diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 9f33d624e2..0454609689 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -8,6 +8,11 @@ using osu.Framework.Screens; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Select; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Edit.Menus; namespace osu.Game.Screens.Edit { @@ -17,6 +22,175 @@ namespace osu.Game.Screens.Edit protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); + internal override bool ShowOverlays => false; + + public Editor() + { + Add(new Container + { + RelativeSizeAxes = Axes.X, + Height = 40, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex("111") + }, + new EditorMenuBar + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + X = 100, + Items = new[] + { + new EditorMenuBarItem("File") + { + Items = new[] + { + new EditorMenuItem("Clear all notes"), + new EditorMenuItem("Open difficulty..."), + new EditorMenuItem("Save"), + new EditorMenuItem("Create new difficulty..."), + new EditorMenuSpacer(), + new EditorMenuItem("Revert to saved"), + new EditorMenuItem("Revert to saved (full"), + new EditorMenuSpacer(), + new EditorMenuItem("Test beatmap"), + new EditorMenuItem("Open AiMod"), + new EditorMenuSpacer(), + new EditorMenuItem("Upload Beatmap..."), + new EditorMenuItem("Export package"), + new EditorMenuItem("Export map package"), + new EditorMenuItem("Import from..."), + new EditorMenuSpacer(), + new EditorMenuItem("Open song folder"), + new EditorMenuItem("Open .osu in Notepad"), + new EditorMenuItem("Open .osb in Notepad"), + new EditorMenuSpacer(), + new EditorMenuItem("Exit", MenuItemType.Standard, Exit) + } + }, + new EditorMenuBarItem("Edit") + { + Items = new[] + { + new EditorMenuItem("Undo"), + new EditorMenuItem("Redo"), + new EditorMenuSpacer(), + new EditorMenuItem("Cut"), + new EditorMenuItem("Copy"), + new EditorMenuItem("Paste"), + new EditorMenuItem("Delete"), + new EditorMenuSpacer(), + new EditorMenuItem("Select all"), + new EditorMenuItem("Clone"), + new EditorMenuSpacer(), + new EditorMenuItem("Reverse selection"), + new EditorMenuItem("Flip horizontally"), + new EditorMenuItem("Flip vertically"), + new EditorMenuItem("Rotate 90deg clockwise"), + new EditorMenuItem("Rotate 90deg anticlockwise"), + new EditorMenuItem("Rotate by..."), + new EditorMenuItem("Scale by..."), + new EditorMenuSpacer(), + new EditorMenuItem("Reset selected objects' samples"), + new EditorMenuItem("Reset all samples", MenuItemType.Destructive), + new EditorMenuItem("Reset combo colours", MenuItemType.Destructive), + new EditorMenuItem("Reset breaks", MenuItemType.Destructive), + new EditorMenuSpacer(), + new EditorMenuItem("Nudge backward"), + new EditorMenuItem("Nudge forward") + } + }, + new EditorMenuBarItem("View") + { + Items = new[] + { + new EditorMenuItem("Compose"), + new EditorMenuItem("Design"), + new EditorMenuItem("Timing"), + new EditorMenuSpacer(), + new EditorMenuItem("Song setup..."), + new EditorMenuItem("Timing setup..."), + new EditorMenuSpacer(), + new EditorMenuItem("Volume"), + new EditorMenuItem("Grid level"), + new EditorMenuItem("Show video"), + new EditorMenuItem("Show sample name"), + new EditorMenuItem("Snaking sliders"), + new EditorMenuItem("Hit animations"), + new EditorMenuItem("Follow points"), + new EditorMenuItem("Stacking") + } + }, + new EditorMenuBarItem("Compose") + { + Items = new[] + { + new EditorMenuItem("Snap divisor"), + new EditorMenuItem("Audio rate"), + new EditorMenuItem("Grid snapping"), + new EditorMenuSpacer(), + new EditorMenuItem("Create polygon cricles..."), + new EditorMenuItem("Convert slider to stream"), + new EditorMenuItem("Enable live mapping mode"), + new EditorMenuItem("Sample import") + } + }, + new EditorMenuBarItem("Design") + { + Items = new[] + { + new EditorMenuItem("Move all elements in time...") + } + }, + new EditorMenuBarItem("Timing") + { + Items = new[] + { + new EditorMenuItem("Time signature"), + new EditorMenuItem("Metronome clicks"), + new EditorMenuSpacer(), + new EditorMenuItem("Add timing section"), + new EditorMenuItem("Add inheriting section"), + new EditorMenuItem("Reset current section"), + new EditorMenuItem("Delete timing section"), + new EditorMenuItem("Resnap current section"), + new EditorMenuSpacer(), + new EditorMenuItem("Timing setup..."), + new EditorMenuSpacer(), + new EditorMenuItem("Resnap all notes", MenuItemType.Destructive), + new EditorMenuItem("Move all notes in time...", MenuItemType.Destructive), + new EditorMenuItem("Recalculate slider lengths", MenuItemType.Destructive), + new EditorMenuItem("Delete all timing sections", MenuItemType.Destructive), + new EditorMenuSpacer(), + new EditorMenuItem("Set current position as preview point") + } + }, + new EditorMenuBarItem("Web") + { + Items = new[] + { + new EditorMenuItem("This Beatmap's information page"), + new EditorMenuItem("This Beatmap's thread"), + new EditorMenuItem("Quick reply") + } + }, + new EditorMenuBarItem("Help") + { + Items = new[] + { + new EditorMenuItem("Show in-game help"), + new EditorMenuItem("View FAQ") + } + } + } + } + } + }); + } + protected override void OnResuming(Screen last) { Beatmap.Value.Track?.Stop(); diff --git a/osu.Game/Screens/Edit/Menus/EditorMenuBar.cs b/osu.Game/Screens/Edit/Menus/EditorMenuBar.cs new file mode 100644 index 0000000000..9fd8669922 --- /dev/null +++ b/osu.Game/Screens/Edit/Menus/EditorMenuBar.cs @@ -0,0 +1,131 @@ +// Copyright (c) 2007-2017 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.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Screens.Edit.Menus +{ + public class EditorMenuBar : MenuBar + { + protected override DrawableMenuBarItem CreateDrawableMenuBarItem(MenuItem item) => new DrawableEditorMenuBarItem(item); + + private class DrawableEditorMenuBarItem : DrawableMenuBarItem + { + private const int fade_duration = 250; + private const float text_size = 14; + + private readonly Container background; + + private Color4 normalColour; + + public DrawableEditorMenuBarItem(MenuItem item) + : base(item) + { + Text.Padding = new MarginPadding(8); + + AddInternal(background = new Container + { + RelativeSizeAxes = Axes.Both, + Masking = true, + Depth = float.MaxValue, + Alpha = 0, + Child = new Container + { + // The following is done so we can have top rounded corners but not bottom corners + RelativeSizeAxes = Axes.Both, + Height = 2, + Masking = true, + CornerRadius = 5, + Child = new Box { RelativeSizeAxes = Axes.Both } + } + }); + + Menu.OnOpen += menuOpen; + Menu.OnClose += menuClose; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + background.Colour = colours.Gray3; + Text.Colour = normalColour = colours.BlueLight; + } + + private void menuOpen() + { + background.FadeIn(fade_duration, Easing.OutQuint); + Text.FadeColour(Color4.White, fade_duration, Easing.OutQuint); + } + + private void menuClose() + { + background.FadeOut(fade_duration, Easing.OutQuint); + Text.FadeColour(normalColour, fade_duration, Easing.OutQuint); + } + + protected override SpriteText CreateText() => new OsuSpriteText { TextSize = text_size }; + + protected override Framework.Graphics.UserInterface.Menu CreateMenu() => new EditorMenu(); + + private class EditorMenu : OsuMenu + { + public EditorMenu() + { + Anchor = Anchor.BottomLeft; + BypassAutoSizeAxes = Axes.Both; + OriginPosition = new Vector2(8, 0); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = colours.Gray3; + } + + protected override MarginPadding ItemFlowContainerPadding => new MarginPadding { Top = 5, Bottom = 5 }; + + protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableEditorMenuItem(item); + + private class DrawableEditorMenuItem : DrawableOsuMenuItem + { + public override bool HandleInput => !isSpacer; + private readonly bool isSpacer; + + public DrawableEditorMenuItem(MenuItem item) + : base(item) + { + isSpacer = item is EditorMenuSpacer; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = colours.Gray3; + BackgroundColourHover = colours.Gray2; + } + + protected override TextContainer CreateTextContainer() => new EditorTextContainer(); + + private class EditorTextContainer : TextContainer + { + public EditorTextContainer() + { + BoldText.TextSize = text_size; + NormalText.TextSize = text_size; + } + } + } + } + } + } +} diff --git a/osu.Game/Screens/Edit/Menus/EditorMenuBarItem.cs b/osu.Game/Screens/Edit/Menus/EditorMenuBarItem.cs new file mode 100644 index 0000000000..201bc6e5c3 --- /dev/null +++ b/osu.Game/Screens/Edit/Menus/EditorMenuBarItem.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.UserInterface; + +namespace osu.Game.Screens.Edit.Menus +{ + public class EditorMenuBarItem : MenuItem + { + public EditorMenuBarItem(string text) + : base(text) + { + } + } +} diff --git a/osu.Game/Screens/Edit/Menus/EditorMenuItem.cs b/osu.Game/Screens/Edit/Menus/EditorMenuItem.cs new file mode 100644 index 0000000000..c7e36522cf --- /dev/null +++ b/osu.Game/Screens/Edit/Menus/EditorMenuItem.cs @@ -0,0 +1,23 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Screens.Edit.Menus +{ + public class EditorMenuItem : OsuMenuItem + { + private const int min_text_length = 40; + + public EditorMenuItem(string text, MenuItemType type = MenuItemType.Standard) + : base(text.PadRight(min_text_length), type) + { + } + + public EditorMenuItem(string text, MenuItemType type, Action action) + : base(text.PadRight(min_text_length), type, action) + { + } + } +} diff --git a/osu.Game/Screens/Edit/Menus/EditorMenuItemSpacer.cs b/osu.Game/Screens/Edit/Menus/EditorMenuItemSpacer.cs new file mode 100644 index 0000000000..0e01992846 --- /dev/null +++ b/osu.Game/Screens/Edit/Menus/EditorMenuItemSpacer.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Screens.Edit.Menus +{ + public class EditorMenuSpacer : EditorMenuItem + { + public EditorMenuSpacer() + : base(" ") + { + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 325cfba986..05ba3e25ab 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -133,6 +133,10 @@ + + + +