mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 22:22:54 +08:00
Update in-line with framework changes.
This commit is contained in:
parent
66db3389f6
commit
fc6c682d88
@ -1 +1 @@
|
||||
Subproject commit 2958d6fda1be252a0f479609090e72814b177c91
|
||||
Subproject commit 2cb3e59c8bc7e67edef4dfe7f9c7dfc01db386a7
|
@ -3,8 +3,9 @@
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
@ -66,30 +67,30 @@ namespace osu.Desktop.Tests.Visual
|
||||
);
|
||||
}
|
||||
|
||||
private class MyContextMenuContainer : Container, IHasOsuContextMenu
|
||||
private class MyContextMenuContainer : Container, IHasContextMenu
|
||||
{
|
||||
public OsuContextMenuItem[] ContextMenuItems => new[]
|
||||
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||
{
|
||||
new OsuContextMenuItem(@"Some option"),
|
||||
new OsuContextMenuItem(@"Highlighted option", MenuItemType.Highlighted),
|
||||
new OsuContextMenuItem(@"Another option"),
|
||||
new OsuContextMenuItem(@"Choose me please"),
|
||||
new OsuContextMenuItem(@"And me too"),
|
||||
new OsuContextMenuItem(@"Trying to fill"),
|
||||
new OsuContextMenuItem(@"Destructive option", MenuItemType.Destructive),
|
||||
new OsuMenuItem(@"Some option"),
|
||||
new OsuMenuItem(@"Highlighted option", MenuItemType.Highlighted),
|
||||
new OsuMenuItem(@"Another option"),
|
||||
new OsuMenuItem(@"Choose me please"),
|
||||
new OsuMenuItem(@"And me too"),
|
||||
new OsuMenuItem(@"Trying to fill"),
|
||||
new OsuMenuItem(@"Destructive option", MenuItemType.Destructive),
|
||||
};
|
||||
}
|
||||
|
||||
private class AnotherContextMenuContainer : Container, IHasOsuContextMenu
|
||||
private class AnotherContextMenuContainer : Container, IHasContextMenu
|
||||
{
|
||||
public OsuContextMenuItem[] ContextMenuItems => new[]
|
||||
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||
{
|
||||
new OsuContextMenuItem(@"Simple option"),
|
||||
new OsuContextMenuItem(@"Simple very very long option"),
|
||||
new OsuContextMenuItem(@"Change width", MenuItemType.Highlighted, () => this.ResizeWidthTo(Width * 2, 100, Easing.OutQuint)),
|
||||
new OsuContextMenuItem(@"Change height", MenuItemType.Highlighted, () => this.ResizeHeightTo(Height * 2, 100, Easing.OutQuint)),
|
||||
new OsuContextMenuItem(@"Change width back", MenuItemType.Destructive, () => this.ResizeWidthTo(Width / 2, 100, Easing.OutQuint)),
|
||||
new OsuContextMenuItem(@"Change height back", MenuItemType.Destructive, () => this.ResizeHeightTo(Height / 2, 100, Easing.OutQuint)),
|
||||
new OsuMenuItem(@"Simple option"),
|
||||
new OsuMenuItem(@"Simple very very long option"),
|
||||
new OsuMenuItem(@"Change width", MenuItemType.Highlighted, () => this.ResizeWidthTo(Width * 2, 100, Easing.OutQuint)),
|
||||
new OsuMenuItem(@"Change height", MenuItemType.Highlighted, () => this.ResizeHeightTo(Height * 2, 100, Easing.OutQuint)),
|
||||
new OsuMenuItem(@"Change width back", MenuItemType.Destructive, () => this.ResizeWidthTo(Width / 2, 100, Easing.OutQuint)),
|
||||
new OsuMenuItem(@"Change height back", MenuItemType.Destructive, () => this.ResizeHeightTo(Height / 2, 100, Easing.OutQuint)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
public interface IHasOsuContextMenu : IHasContextMenu<OsuContextMenuItem>
|
||||
{
|
||||
}
|
||||
}
|
@ -7,8 +7,8 @@ using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
public class OsuContextMenuContainer : ContextMenuContainer<OsuContextMenuItem>
|
||||
public class OsuContextMenuContainer : ContextMenuContainer
|
||||
{
|
||||
protected override Menu<OsuContextMenuItem> CreateMenu() => new OsuContextMenu<OsuContextMenuItem>();
|
||||
protected override Menu CreateMenu() => new OsuContextMenu();
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
@ -15,8 +16,7 @@ using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuContextMenu<TItem> : OsuMenu<TItem>
|
||||
where TItem : OsuContextMenuItem
|
||||
public class OsuContextMenu : OsuMenu
|
||||
{
|
||||
private const int fade_duration = 250;
|
||||
|
||||
@ -42,7 +42,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override MarginPadding ItemFlowContainerPadding => new MarginPadding { Vertical = DrawableOsuContextMenuItem.MARGIN_VERTICAL };
|
||||
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(TItem item) => new DrawableOsuContextMenuItem(this, item);
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuContextMenuItem(item);
|
||||
|
||||
#region DrawableOsuContextMenuItem
|
||||
private class DrawableOsuContextMenuItem : DrawableMenuItem
|
||||
@ -57,9 +57,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private TextContainer text;
|
||||
|
||||
public DrawableOsuContextMenuItem(Menu<TItem> menu, TItem item)
|
||||
public DrawableOsuContextMenuItem(MenuItem item)
|
||||
: base(item)
|
||||
{
|
||||
if (!(Item is OsuMenuItem))
|
||||
throw new ArgumentException($"{nameof(item)} must be a {nameof(OsuMenuItem)}.");
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -76,7 +78,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private void updateTextColour()
|
||||
{
|
||||
switch (Item.Type)
|
||||
switch (((OsuMenuItem)Item).Type)
|
||||
{
|
||||
case MenuItemType.Standard:
|
||||
text.Colour = Color4.White;
|
||||
|
@ -68,7 +68,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
public readonly Bindable<Color4?> AccentColour = new Bindable<Color4?>();
|
||||
|
||||
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem<T> item)
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item)
|
||||
{
|
||||
var newItem = new DrawableOsuDropdownMenuItem(item);
|
||||
newItem.AccentColour.BindTo(AccentColour);
|
||||
@ -86,7 +86,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private Color4 nonAccentHoverColour;
|
||||
private Color4 nonAccentSelectedColour;
|
||||
|
||||
public DrawableOsuDropdownMenuItem(DropdownMenuItem<T> item)
|
||||
public DrawableOsuDropdownMenuItem(MenuItem item)
|
||||
: base(item)
|
||||
{
|
||||
Foreground.Padding = new MarginPadding(2);
|
||||
|
@ -8,8 +8,7 @@ using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuMenu<TItem> : Menu<TItem>
|
||||
where TItem : MenuItem
|
||||
public class OsuMenu : Menu
|
||||
{
|
||||
public OsuMenu()
|
||||
{
|
||||
|
@ -6,17 +6,17 @@ using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuContextMenuItem : MenuItem
|
||||
public class OsuMenuItem : MenuItem
|
||||
{
|
||||
public readonly MenuItemType Type;
|
||||
|
||||
public OsuContextMenuItem(string text, MenuItemType type = MenuItemType.Standard)
|
||||
public OsuMenuItem(string text, MenuItemType type = MenuItemType.Standard)
|
||||
: base(text)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public OsuContextMenuItem(string text, MenuItemType type, Action action)
|
||||
public OsuMenuItem(string text, MenuItemType type, Action action)
|
||||
: base(text, action)
|
||||
{
|
||||
Type = type;
|
@ -179,16 +179,16 @@ namespace osu.Game.Graphics.UserInterface
|
||||
MaxHeight = 400;
|
||||
}
|
||||
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem<T> item)
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item)
|
||||
{
|
||||
var result = new DrawableOsuTabDropdownMenuItem(this, item);
|
||||
var result = new DrawableOsuTabDropdownMenuItem(item);
|
||||
result.AccentColour.BindTo(AccentColour);
|
||||
return result;
|
||||
}
|
||||
|
||||
private class DrawableOsuTabDropdownMenuItem : DrawableOsuDropdownMenuItem
|
||||
{
|
||||
public DrawableOsuTabDropdownMenuItem(Menu<DropdownMenuItem<T>> menu, DropdownMenuItem<T> item)
|
||||
public DrawableOsuTabDropdownMenuItem(MenuItem item)
|
||||
: base(item)
|
||||
{
|
||||
ForegroundColourHover = Color4.Black;
|
||||
|
@ -308,11 +308,11 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
|
||||
protected override MarginPadding ItemFlowContainerPadding => new MarginPadding();
|
||||
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem<UserAction> item) => new DrawableUserDropdownMenuItem(this, item);
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableUserDropdownMenuItem(item);
|
||||
|
||||
private class DrawableUserDropdownMenuItem : DrawableOsuDropdownMenuItem
|
||||
{
|
||||
public DrawableUserDropdownMenuItem(Menu<DropdownMenuItem<UserAction>> menu, DropdownMenuItem<UserAction> item)
|
||||
public DrawableUserDropdownMenuItem(MenuItem item)
|
||||
: base(item)
|
||||
{
|
||||
Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 10, Right = 5 };
|
||||
|
@ -84,7 +84,6 @@
|
||||
<Compile Include="Graphics\Containers\OsuClickableContainer.cs" />
|
||||
<Compile Include="Graphics\Containers\OsuFocusedOverlayContainer.cs" />
|
||||
<Compile Include="Graphics\Containers\OsuScrollContainer.cs" />
|
||||
<Compile Include="Graphics\Cursor\IHasOsuContextMenu.cs" />
|
||||
<Compile Include="Graphics\Cursor\OsuContextMenuContainer.cs" />
|
||||
<Compile Include="Graphics\Containers\OsuTextFlowContainer.cs" />
|
||||
<Compile Include="Graphics\UserInterface\IconButton.cs" />
|
||||
@ -92,7 +91,7 @@
|
||||
<Compile Include="Graphics\UserInterface\LineGraph.cs" />
|
||||
<Compile Include="Graphics\UserInterface\MenuItemType.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuContextMenu.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuContextMenuItem.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuMenuItem.cs" />
|
||||
<Compile Include="Input\Bindings\DatabasedKeyBinding.cs" />
|
||||
<Compile Include="Input\Bindings\DatabasedKeyBindingInputManager.cs" />
|
||||
<Compile Include="Input\KeyBindingStore.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user