2017-08-24 16:28:47 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
namespace osu.Desktop.Tests.Visual
|
|
|
|
{
|
|
|
|
public class TestCaseEditorMenuBar : TestCase
|
|
|
|
{
|
|
|
|
public TestCaseEditorMenuBar()
|
|
|
|
{
|
|
|
|
Add(new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Width = 500,
|
|
|
|
Child = new EditorMenuBar
|
|
|
|
{
|
|
|
|
Items = new[]
|
|
|
|
{
|
|
|
|
new EditorMenuBarItem("File")
|
|
|
|
{
|
2017-08-24 16:43:56 +08:00
|
|
|
Items = new[]
|
2017-08-24 16:28:47 +08:00
|
|
|
{
|
|
|
|
new EditorContextMenuItem("Clear All Notes"),
|
|
|
|
new EditorContextMenuItem("Open Difficulty..."),
|
|
|
|
new EditorContextMenuItem("Save"),
|
|
|
|
new EditorContextMenuItem("Create a new Difficulty..."),
|
|
|
|
new EditorContextMenuSpacer(),
|
|
|
|
new EditorContextMenuItem("Revert to Saved"),
|
|
|
|
new EditorContextMenuItem("Revert to Saved (Full)"),
|
|
|
|
new EditorContextMenuSpacer(),
|
|
|
|
new EditorContextMenuItem("Test Beatmap"),
|
|
|
|
new EditorContextMenuItem("Open AiMod"),
|
|
|
|
new EditorContextMenuSpacer(),
|
|
|
|
new EditorContextMenuItem("Upload Beatmap..."),
|
|
|
|
new EditorContextMenuItem("Export Package"),
|
|
|
|
new EditorContextMenuItem("Export Map Package"),
|
|
|
|
new EditorContextMenuItem("Import from..."),
|
|
|
|
new EditorContextMenuSpacer(),
|
|
|
|
new EditorContextMenuItem("Open Song Folder"),
|
|
|
|
new EditorContextMenuItem("Open .osu in Notepad"),
|
|
|
|
new EditorContextMenuItem("Open .osb in Notepad"),
|
|
|
|
new EditorContextMenuSpacer(),
|
|
|
|
new EditorContextMenuItem("Exit"),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new EditorMenuBarItem("Timing")
|
|
|
|
{
|
|
|
|
Items = new[]
|
|
|
|
{
|
|
|
|
new EditorContextMenuItem("Time Signature"),
|
|
|
|
new EditorContextMenuItem("Metronome Clicks"),
|
|
|
|
new EditorContextMenuSpacer(),
|
|
|
|
new EditorContextMenuItem("Add Timing Section"),
|
|
|
|
new EditorContextMenuItem("Add Inheriting Section"),
|
|
|
|
new EditorContextMenuItem("Reset Current Section"),
|
|
|
|
new EditorContextMenuItem("Delete Timing Section"),
|
|
|
|
new EditorContextMenuItem("Resnap Current Section"),
|
|
|
|
new EditorContextMenuSpacer(),
|
|
|
|
new EditorContextMenuItem("Timing Setup"),
|
|
|
|
new EditorContextMenuSpacer(),
|
|
|
|
new EditorContextMenuItem("Resnap All Notes", MenuItemType.Destructive),
|
|
|
|
new EditorContextMenuItem("Move all notes in time...", MenuItemType.Destructive),
|
|
|
|
new EditorContextMenuItem("Recalculate Slider Lengths", MenuItemType.Destructive),
|
|
|
|
new EditorContextMenuItem("Delete All Timing Sections", MenuItemType.Destructive),
|
|
|
|
new EditorContextMenuSpacer(),
|
|
|
|
new EditorContextMenuItem("Set Current Position as Preview Point"),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new EditorMenuBarItem("Testing")
|
|
|
|
{
|
|
|
|
Items = new[]
|
|
|
|
{
|
|
|
|
new EditorContextMenuItem("Item 1"),
|
|
|
|
new EditorContextMenuItem("Item 2"),
|
|
|
|
new EditorContextMenuItem("Item 3"),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
private class EditorMenuBar : MenuBar
|
|
|
|
{
|
|
|
|
}
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
private class EditorMenuBarItem : MenuBarItem
|
|
|
|
{
|
|
|
|
private const int fade_duration = 250;
|
|
|
|
private const float text_size = 17;
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
private readonly Container background;
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
private Color4 normalColour;
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
public EditorMenuBarItem(string title)
|
|
|
|
: base(title)
|
2017-08-24 16:28:47 +08:00
|
|
|
{
|
2017-08-24 16:31:23 +08:00
|
|
|
Content.Padding = new MarginPadding(8);
|
|
|
|
|
|
|
|
AddInternal(background = new Container
|
2017-08-24 16:28:47 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
2017-08-24 16:31:23 +08:00
|
|
|
Depth = float.MaxValue,
|
|
|
|
Alpha = 0,
|
|
|
|
Child = new Container<Box>
|
|
|
|
{
|
|
|
|
// 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 }
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
background.Colour = colours.Gray3;
|
|
|
|
ContextMenu.Menu.Background.Colour = colours.Gray3;
|
|
|
|
TitleText.Colour = normalColour = colours.BlueLight;
|
|
|
|
}
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
public override void Open()
|
|
|
|
{
|
|
|
|
base.Open();
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
background.FadeIn(fade_duration, Easing.OutQuint);
|
|
|
|
TitleText.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
|
|
|
}
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
public override void Close()
|
|
|
|
{
|
|
|
|
base.Close();
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
background.FadeOut(fade_duration, Easing.OutQuint);
|
|
|
|
TitleText.FadeColour(normalColour, fade_duration, Easing.OutQuint);
|
|
|
|
}
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
protected override SpriteText CreateTitleText() => new OsuSpriteText { TextSize = text_size };
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
protected override ContextMenu<ContextMenuItem> CreateContextMenu() => new OsuContextMenu<ContextMenuItem>
|
|
|
|
{
|
|
|
|
OriginPosition = new Vector2(8, 0)
|
|
|
|
};
|
|
|
|
}
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
private class EditorContextMenuSpacer : EditorContextMenuItem
|
2017-08-24 16:28:47 +08:00
|
|
|
{
|
2017-08-24 16:31:23 +08:00
|
|
|
public override bool HandleInput => false;
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
public EditorContextMenuSpacer()
|
|
|
|
: base(" ")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2017-08-24 16:28:47 +08:00
|
|
|
|
2017-08-24 16:31:23 +08:00
|
|
|
private class EditorContextMenuItem : OsuContextMenuItem
|
2017-08-24 16:28:47 +08:00
|
|
|
{
|
2017-08-24 16:31:23 +08:00
|
|
|
private const int min_text_length = 40;
|
|
|
|
|
|
|
|
public EditorContextMenuItem(string title, MenuItemType type = MenuItemType.Standard)
|
|
|
|
: base(title.PadRight(min_text_length), type)
|
|
|
|
{
|
|
|
|
}
|
2017-08-24 16:43:56 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
BackgroundColour = colours.Gray3;
|
|
|
|
BackgroundColourHover = colours.Gray2;
|
|
|
|
}
|
2017-08-24 16:28:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|