2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-08-28 16:55:50 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2018-11-06 17:28:22 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2017-08-28 16:55:50 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-05-25 21:19:24 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-11-06 17:28:22 +08:00
|
|
|
|
namespace osu.Game.Screens.Edit.Components.Menus
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
public partial class EditorMenuBar : OsuMenu
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
public EditorMenuBar()
|
2017-09-07 19:36:32 +08:00
|
|
|
|
: base(Direction.Horizontal, true)
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-27 20:53:33 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-10-07 00:38:13 +08:00
|
|
|
|
MaskingContainer.CornerRadius = 0;
|
2017-09-27 20:53:33 +08:00
|
|
|
|
ItemsContainer.Padding = new MarginPadding { Left = 100 };
|
2022-05-25 21:19:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
BackgroundColour = colourProvider.Background3;
|
2017-09-06 20:14:29 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override Framework.Graphics.UserInterface.Menu CreateSubMenu() => new SubMenu();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableEditorBarMenuItem(item);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
private partial class DrawableEditorBarMenuItem : DrawableOsuMenuItem
|
|
|
|
|
{
|
|
|
|
|
public DrawableEditorBarMenuItem(MenuItem item)
|
2017-08-28 16:55:50 +08:00
|
|
|
|
: base(item)
|
|
|
|
|
{
|
2017-09-27 20:53:33 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-29 14:09:56 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2022-05-25 21:19:24 +08:00
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2017-09-27 20:53:33 +08:00
|
|
|
|
{
|
2022-05-25 21:19:24 +08:00
|
|
|
|
ForegroundColour = colourProvider.Light3;
|
|
|
|
|
BackgroundColour = colourProvider.Background2;
|
|
|
|
|
ForegroundColourHover = colourProvider.Content1;
|
|
|
|
|
BackgroundColourHover = colourProvider.Background1;
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-05-25 21:19:24 +08:00
|
|
|
|
protected override void LoadComplete()
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2022-05-25 21:19:24 +08:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
Foreground.Anchor = Anchor.CentreLeft;
|
|
|
|
|
Foreground.Origin = Anchor.CentreLeft;
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override void UpdateBackgroundColour()
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
if (State == MenuItemState.Selected)
|
2017-09-29 14:09:56 +08:00
|
|
|
|
Background.FadeColour(BackgroundColourHover);
|
2017-09-06 20:14:29 +08:00
|
|
|
|
else
|
|
|
|
|
base.UpdateBackgroundColour();
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override void UpdateForegroundColour()
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
if (State == MenuItemState.Selected)
|
2017-09-29 14:09:56 +08:00
|
|
|
|
Foreground.FadeColour(ForegroundColourHover);
|
2017-09-06 20:14:29 +08:00
|
|
|
|
else
|
|
|
|
|
base.UpdateForegroundColour();
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-27 20:53:33 +08:00
|
|
|
|
protected override DrawableOsuMenuItem.TextContainer CreateTextContainer() => new TextContainer();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-27 20:53:33 +08:00
|
|
|
|
private new partial class TextContainer : DrawableOsuMenuItem.TextContainer
|
|
|
|
|
{
|
|
|
|
|
public TextContainer()
|
|
|
|
|
{
|
2022-05-25 21:19:24 +08:00
|
|
|
|
NormalText.Font = OsuFont.TorusAlternate;
|
|
|
|
|
BoldText.Font = OsuFont.TorusAlternate.With(weight: FontWeight.Bold);
|
2017-09-27 20:53:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-06 20:14:29 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
private partial class SubMenu : OsuMenu
|
|
|
|
|
{
|
|
|
|
|
public SubMenu()
|
|
|
|
|
: base(Direction.Vertical)
|
|
|
|
|
{
|
2022-05-25 21:19:24 +08:00
|
|
|
|
ItemsContainer.Padding = new MarginPadding();
|
|
|
|
|
|
|
|
|
|
MaskingContainer.CornerRadius = 0;
|
2017-09-06 20:14:29 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2022-05-25 21:19:24 +08:00
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2022-05-25 21:19:24 +08:00
|
|
|
|
BackgroundColour = colourProvider.Background2;
|
2017-09-06 20:14:29 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override Framework.Graphics.UserInterface.Menu CreateSubMenu() => new SubMenu();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-11-03 15:00:07 +08:00
|
|
|
|
protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item)
|
2017-09-06 20:14:29 +08:00
|
|
|
|
{
|
2020-11-03 15:00:07 +08:00
|
|
|
|
switch (item)
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2020-11-03 15:00:07 +08:00
|
|
|
|
case EditorMenuItemSpacer spacer:
|
|
|
|
|
return new DrawableSpacer(spacer);
|
2022-05-25 21:19:24 +08:00
|
|
|
|
|
2022-05-27 12:45:07 +08:00
|
|
|
|
case StatefulMenuItem stateful:
|
|
|
|
|
return new EditorStatefulMenuItem(stateful);
|
|
|
|
|
|
2022-05-25 21:19:24 +08:00
|
|
|
|
default:
|
|
|
|
|
return new EditorMenuItem(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-27 12:45:07 +08:00
|
|
|
|
|
|
|
|
|
private partial class EditorStatefulMenuItem : DrawableStatefulMenuItem
|
|
|
|
|
{
|
|
|
|
|
public EditorStatefulMenuItem(StatefulMenuItem item)
|
|
|
|
|
: base(item)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
BackgroundColour = colourProvider.Background2;
|
|
|
|
|
BackgroundColourHover = colourProvider.Background1;
|
|
|
|
|
|
|
|
|
|
Foreground.Padding = new MarginPadding { Vertical = 2 };
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-25 21:19:24 +08:00
|
|
|
|
|
|
|
|
|
private partial class EditorMenuItem : DrawableOsuMenuItem
|
|
|
|
|
{
|
|
|
|
|
public EditorMenuItem(MenuItem item)
|
|
|
|
|
: base(item)
|
|
|
|
|
{
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-05-25 21:19:24 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
BackgroundColour = colourProvider.Background2;
|
|
|
|
|
BackgroundColourHover = colourProvider.Background1;
|
|
|
|
|
|
|
|
|
|
Foreground.Padding = new MarginPadding { Vertical = 2 };
|
|
|
|
|
}
|
2020-11-03 15:00:07 +08:00
|
|
|
|
}
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2020-11-03 15:00:07 +08:00
|
|
|
|
private partial class DrawableSpacer : DrawableOsuMenuItem
|
|
|
|
|
{
|
|
|
|
|
public DrawableSpacer(MenuItem item)
|
|
|
|
|
: base(item)
|
|
|
|
|
{
|
2022-05-25 21:19:24 +08:00
|
|
|
|
Scale = new Vector2(1, 0.3f);
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-11-03 15:00:07 +08:00
|
|
|
|
protected override bool OnHover(HoverEvent e) => true;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2020-11-03 15:00:07 +08:00
|
|
|
|
protected override bool OnClick(ClickEvent e) => true;
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|