mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Changes in line with framework changes
This commit is contained in:
parent
3ffc467704
commit
ee85515d95
@ -1 +1 @@
|
||||
Subproject commit 56ce220e7f631ce2890597e505d073cdfc0233a1
|
||||
Subproject commit 926d7c971d059c7aeb3ccfb09d06910c46aa3a40
|
@ -39,18 +39,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected override void AnimateOpen() => this.FadeIn(fade_duration, Easing.OutQuint);
|
||||
protected override void AnimateClose() => this.FadeOut(fade_duration, Easing.OutQuint);
|
||||
|
||||
protected override FlowContainer<MenuItemRepresentation> CreateItemsFlow()
|
||||
{
|
||||
var flow = base.CreateItemsFlow();
|
||||
flow.Padding = new MarginPadding { Vertical = OsuContextMenuItemRepresentation.MARGIN_VERTICAL };
|
||||
protected override MarginPadding ItemFlowContainerPadding => new MarginPadding { Vertical = DrawableOsuContextMenuItem.MARGIN_VERTICAL };
|
||||
|
||||
return flow;
|
||||
}
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(TItem item) => new DrawableOsuContextMenuItem(this, item);
|
||||
|
||||
protected override MenuItemRepresentation CreateMenuItemRepresentation(TItem model) => new OsuContextMenuItemRepresentation(this, model);
|
||||
|
||||
#region OsuContextMenuItemRepresentation
|
||||
private class OsuContextMenuItemRepresentation : MenuItemRepresentation
|
||||
#region DrawableOsuContextMenuItem
|
||||
private class DrawableOsuContextMenuItem : DrawableMenuItem
|
||||
{
|
||||
private const int margin_horizontal = 17;
|
||||
private const int text_size = 17;
|
||||
@ -63,8 +57,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private OsuSpriteText text;
|
||||
private OsuSpriteText textBold;
|
||||
|
||||
public OsuContextMenuItemRepresentation(Menu<TItem> menu, TItem model)
|
||||
: base(menu, model)
|
||||
public DrawableOsuContextMenuItem(Menu<TItem> menu, TItem item)
|
||||
: base(item)
|
||||
{
|
||||
}
|
||||
|
||||
@ -82,7 +76,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private void updateTextColour()
|
||||
{
|
||||
switch (Model.Type)
|
||||
switch (Item.Type)
|
||||
{
|
||||
case MenuItemType.Standard:
|
||||
textBold.Colour = text.Colour = Color4.White;
|
||||
@ -117,7 +111,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override Drawable CreateText(string title) => new Container
|
||||
protected override Drawable CreateContent() => new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
@ -129,7 +123,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = text_size,
|
||||
Text = title,
|
||||
Text = Item.Text,
|
||||
Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL },
|
||||
},
|
||||
textBold = new OsuSpriteText
|
||||
@ -139,7 +133,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = text_size,
|
||||
Text = title,
|
||||
Text = Item.Text,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL },
|
||||
}
|
||||
|
@ -44,18 +44,40 @@ namespace osu.Game.Graphics.UserInterface
|
||||
#region OsuDropdownMenu
|
||||
protected class OsuDropdownMenu : DropdownMenu
|
||||
{
|
||||
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
|
||||
public OsuDropdownMenu()
|
||||
{
|
||||
CornerRadius = 4;
|
||||
BackgroundColour = Color4.Black.Opacity(0.5f);
|
||||
}
|
||||
|
||||
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
|
||||
protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint);
|
||||
protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint);
|
||||
|
||||
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
|
||||
protected override MarginPadding ItemFlowContainerPadding => new MarginPadding(5);
|
||||
|
||||
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
|
||||
protected override void UpdateMenuHeight()
|
||||
{
|
||||
var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight;
|
||||
this.ResizeHeightTo(State == MenuState.Opened ? actualHeight : 0, 300, Easing.OutQuint);
|
||||
}
|
||||
|
||||
public readonly Bindable<Color4?> AccentColour = new Bindable<Color4?>();
|
||||
|
||||
protected override MenuItemRepresentation CreateMenuItemRepresentation(DropdownMenuItem<T> model)
|
||||
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem<T> item)
|
||||
{
|
||||
var newItem = new OsuDropdownMenuItemRepresentation(this, model);
|
||||
var newItem = new DrawableOsuDropdownMenuItem(item);
|
||||
newItem.AccentColour.BindTo(AccentColour);
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
#region OsuDropdownMenuItemRepresentation
|
||||
protected class OsuDropdownMenuItemRepresentation : DropdownMenuItemRepresentation
|
||||
#region DrawableOsuDropdownMenuItem
|
||||
protected class DrawableOsuDropdownMenuItem : DrawableDropdownMenuItem
|
||||
{
|
||||
public readonly Bindable<Color4?> AccentColour = new Bindable<Color4?>();
|
||||
|
||||
@ -65,8 +87,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private Color4 nonAccentHoverColour;
|
||||
private Color4 nonAccentSelectedColour;
|
||||
|
||||
public OsuDropdownMenuItemRepresentation(Menu<DropdownMenuItem<T>> menu, DropdownMenuItem<T> model)
|
||||
: base(menu, model)
|
||||
public DrawableOsuDropdownMenuItem(DropdownMenuItem<T> item)
|
||||
: base(item)
|
||||
{
|
||||
Foreground.Padding = new MarginPadding(2);
|
||||
|
||||
@ -88,17 +110,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
BackgroundColourHover = newValue ?? nonAccentHoverColour;
|
||||
BackgroundColourSelected = newValue ?? nonAccentSelectedColour;
|
||||
AnimateBackground(IsHovered);
|
||||
AnimateForeground(IsHovered);
|
||||
UpdateBackgroundColour();
|
||||
UpdateForegroundColour();
|
||||
}
|
||||
|
||||
protected override void AnimateForeground(bool hover)
|
||||
protected override void UpdateForegroundColour()
|
||||
{
|
||||
base.AnimateForeground(hover);
|
||||
chevron.Alpha = hover ? 1 : 0;
|
||||
base.UpdateForegroundColour();
|
||||
chevron.Alpha = IsHovered ? 1 : 0;
|
||||
}
|
||||
|
||||
protected override Drawable CreateText(string title) => new FillFlowContainer
|
||||
protected override Drawable CreateContent() => new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Horizontal,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -118,7 +140,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
},
|
||||
Label = new OsuSpriteText
|
||||
{
|
||||
Text = title,
|
||||
Text = Item.Text,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
// 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.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
@ -28,16 +26,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
this.ResizeHeightTo(State == MenuState.Opened ? actualHeight : 0, 300, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override FlowContainer<MenuItemRepresentation> CreateItemsFlow()
|
||||
{
|
||||
var flow = base.CreateItemsFlow();
|
||||
flow.Padding = new MarginPadding(5);
|
||||
|
||||
return flow;
|
||||
}
|
||||
}
|
||||
|
||||
public class OsuMenu : OsuMenu<MenuItem>
|
||||
{
|
||||
protected override MarginPadding ItemFlowContainerPadding => new MarginPadding(5);
|
||||
}
|
||||
}
|
||||
|
@ -48,9 +48,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
var dropDown = Dropdown as OsuTabDropdown;
|
||||
if (dropDown != null)
|
||||
dropDown.AccentColour.Value = value;
|
||||
var dropdown = Dropdown as OsuTabDropdown;
|
||||
if (dropdown != null)
|
||||
dropdown.AccentColour.Value = value;
|
||||
foreach (var item in TabContainer.Children.OfType<OsuTabItem>())
|
||||
item.AccentColour = value;
|
||||
}
|
||||
@ -140,16 +140,20 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected override void OnDeactivated() => fadeInactive();
|
||||
}
|
||||
|
||||
// todo: this needs to go
|
||||
private class OsuTabDropdown : OsuDropdown<T>
|
||||
{
|
||||
public OsuTabDropdown()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu();
|
||||
protected override DropdownMenu CreateMenu()
|
||||
{
|
||||
var menu = new OsuTabDropdownMenu();
|
||||
menu.AccentColour.BindTo(AccentColour);
|
||||
return menu;
|
||||
}
|
||||
|
||||
protected override DropdownHeader CreateHeader()
|
||||
{
|
||||
@ -175,18 +179,24 @@ namespace osu.Game.Graphics.UserInterface
|
||||
MaxHeight = 400;
|
||||
}
|
||||
|
||||
protected override MenuItemRepresentation CreateMenuItemRepresentation(DropdownMenuItem<T> model) => new OsuTabDropdownMenuItemRepresentation(this, model);
|
||||
|
||||
private class OsuTabDropdownMenuItemRepresentation : OsuDropdownMenuItemRepresentation
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem<T> item)
|
||||
{
|
||||
public OsuTabDropdownMenuItemRepresentation(Menu<DropdownMenuItem<T>> menu, DropdownMenuItem<T> model)
|
||||
: base(menu, model)
|
||||
var poop = new DrawableOsuTabDropdownMenuItem(this, item);
|
||||
poop.AccentColour.BindTo(AccentColour);
|
||||
return poop;
|
||||
}
|
||||
|
||||
private class DrawableOsuTabDropdownMenuItem : DrawableOsuDropdownMenuItem
|
||||
{
|
||||
public DrawableOsuTabDropdownMenuItem(Menu<DropdownMenuItem<T>> menu, DropdownMenuItem<T> item)
|
||||
: base(item)
|
||||
{
|
||||
ForegroundColourHover = Color4.Black;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected class OsuTabDropdownHeader : OsuDropdownHeader
|
||||
{
|
||||
public OsuTabDropdownHeader()
|
||||
|
@ -306,20 +306,14 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
BackgroundColour = colours.Gray3;
|
||||
}
|
||||
|
||||
protected override FlowContainer<MenuItemRepresentation> CreateItemsFlow()
|
||||
protected override MarginPadding ItemFlowContainerPadding => new MarginPadding();
|
||||
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem<UserAction> item) => new DrawableUserDropdownMenuItem(this, item);
|
||||
|
||||
private class DrawableUserDropdownMenuItem : DrawableOsuDropdownMenuItem
|
||||
{
|
||||
var flow = base.CreateItemsFlow();
|
||||
flow.Padding = new MarginPadding(0);
|
||||
|
||||
return flow;
|
||||
}
|
||||
|
||||
protected override MenuItemRepresentation CreateMenuItemRepresentation(DropdownMenuItem<UserAction> model) => new UserDropdownMenuItem(this, model);
|
||||
|
||||
private class UserDropdownMenuItem : OsuDropdownMenuItemRepresentation
|
||||
{
|
||||
public UserDropdownMenuItem(Menu<DropdownMenuItem<UserAction>> menu, DropdownMenuItem<UserAction> model)
|
||||
: base(menu, model)
|
||||
public DrawableUserDropdownMenuItem(Menu<DropdownMenuItem<UserAction>> menu, DropdownMenuItem<UserAction> item)
|
||||
: base(item)
|
||||
{
|
||||
Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 10, Right = 5 };
|
||||
Label.Margin = new MarginPadding { Left = UserDropdownHeader.LABEL_LEFT_MARGIN - 11 };
|
||||
|
Loading…
Reference in New Issue
Block a user