mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 14:43:22 +08:00
Merge pull request #1265 from peppy/more_context_menus
Add some more context menus; remove global ContextMenuContainer
This commit is contained in:
commit
24e14ec62a
@ -1 +1 @@
|
|||||||
Subproject commit 7347c386dcd10eb799b1ce1512536879328109f9
|
Subproject commit 3f4545aae82650dc87cac7dd5df64e6e47918da1
|
@ -200,10 +200,9 @@ namespace osu.Game
|
|||||||
globalBinding = new GlobalKeyBindingInputManager(this)
|
globalBinding = new GlobalKeyBindingInputManager(this)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = new OsuTooltipContainer(Cursor)
|
Child = content = new OsuTooltipContainer(Cursor)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = content = new OsuContextMenuContainer { RelativeSizeAxes = Axes.Both },
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -13,6 +12,9 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Chat
|
namespace osu.Game.Overlays.Chat
|
||||||
{
|
{
|
||||||
@ -63,8 +65,6 @@ namespace osu.Game.Overlays.Chat
|
|||||||
private const float message_padding = 200;
|
private const float message_padding = 200;
|
||||||
private const float text_size = 20;
|
private const float text_size = 20;
|
||||||
|
|
||||||
private Action<User> loadProfile;
|
|
||||||
|
|
||||||
private Color4 customUsernameColour;
|
private Color4 customUsernameColour;
|
||||||
|
|
||||||
private OsuSpriteText timestamp;
|
private OsuSpriteText timestamp;
|
||||||
@ -100,10 +100,9 @@ namespace osu.Game.Overlays.Chat
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuColour colours, UserProfileOverlay profile)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
customUsernameColour = colours.ChatBlue;
|
customUsernameColour = colours.ChatBlue;
|
||||||
loadProfile = u => profile?.ShowUser(u);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool senderHasBackground => !string.IsNullOrEmpty(message.Sender.Colour);
|
private bool senderHasBackground => !string.IsNullOrEmpty(message.Sender.Colour);
|
||||||
@ -171,13 +170,12 @@ namespace osu.Game.Overlays.Chat
|
|||||||
FixedWidth = true,
|
FixedWidth = true,
|
||||||
TextSize = text_size * 0.75f,
|
TextSize = text_size * 0.75f,
|
||||||
},
|
},
|
||||||
new ClickableContainer
|
new MessageSender(message.Sender)
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Child = effectedUsername,
|
Child = effectedUsername,
|
||||||
Action = () => loadProfile(message.Sender),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -210,5 +208,26 @@ namespace osu.Game.Overlays.Chat
|
|||||||
username.Text = $@"{message.Sender.Username}" + (senderHasBackground ? "" : ":");
|
username.Text = $@"{message.Sender.Username}" + (senderHasBackground ? "" : ":");
|
||||||
contentFlow.Text = message.Content;
|
contentFlow.Text = message.Content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class MessageSender : ClickableContainer, IHasContextMenu
|
||||||
|
{
|
||||||
|
private readonly User sender;
|
||||||
|
|
||||||
|
public MessageSender(User sender)
|
||||||
|
{
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(UserProfileOverlay profile)
|
||||||
|
{
|
||||||
|
Action = () => profile?.ShowUser(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||||
|
{
|
||||||
|
new OsuMenuItem("View Profile", MenuItemType.Highlighted, Action),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,23 +10,13 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Chat
|
namespace osu.Game.Overlays.Chat
|
||||||
{
|
{
|
||||||
public class DrawableChannel : Container
|
public class DrawableChannel : Container
|
||||||
{
|
{
|
||||||
private class ChatLineContainer : FillFlowContainer<ChatLine>
|
|
||||||
{
|
|
||||||
protected override int Compare(Drawable x, Drawable y)
|
|
||||||
{
|
|
||||||
var xC = (ChatLine)x;
|
|
||||||
var yC = (ChatLine)y;
|
|
||||||
|
|
||||||
return xC.Message.CompareTo(yC.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly Channel Channel;
|
public readonly Channel Channel;
|
||||||
private readonly ChatLineContainer flow;
|
private readonly ChatLineContainer flow;
|
||||||
private readonly ScrollContainer scroll;
|
private readonly ScrollContainer scroll;
|
||||||
@ -45,12 +35,17 @@ namespace osu.Game.Overlays.Chat
|
|||||||
// Some chat lines have effects that slightly protrude to the bottom,
|
// Some chat lines have effects that slightly protrude to the bottom,
|
||||||
// which we do not want to mask away, hence the padding.
|
// which we do not want to mask away, hence the padding.
|
||||||
Padding = new MarginPadding { Bottom = 5 },
|
Padding = new MarginPadding { Bottom = 5 },
|
||||||
Child = flow = new ChatLineContainer
|
Child = new OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
Padding = new MarginPadding { Left = 20, Right = 20 },
|
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Direction = FillDirection.Vertical,
|
Child = flow = new ChatLineContainer
|
||||||
|
{
|
||||||
|
Padding = new MarginPadding { Left = 20, Right = 20 },
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -124,5 +119,16 @@ namespace osu.Game.Overlays.Chat
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd());
|
private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd());
|
||||||
|
|
||||||
|
private class ChatLineContainer : FillFlowContainer<ChatLine>
|
||||||
|
{
|
||||||
|
protected override int Compare(Drawable x, Drawable y)
|
||||||
|
{
|
||||||
|
var xC = (ChatLine)x;
|
||||||
|
var yC = (ChatLine)y;
|
||||||
|
|
||||||
|
return xC.Message.CompareTo(yC.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Overlays.Settings.Sections.General;
|
using osu.Game.Overlays.Settings.Sections.General;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Cursor;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Overlays
|
|||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
Alpha = 0.6f,
|
Alpha = 0.6f,
|
||||||
},
|
},
|
||||||
new Container
|
new OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
Width = 360,
|
Width = 360,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
|
@ -366,10 +366,6 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
BackgroundColour = colours.Gray3;
|
BackgroundColour = colours.Gray3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum UserAction
|
private enum UserAction
|
||||||
|
@ -9,6 +9,7 @@ using OpenTK.Graphics;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
@ -63,12 +64,17 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
ScrollFlow.Children = new[]
|
ScrollFlow.Children = new[]
|
||||||
{
|
{
|
||||||
panelFlow = new FillFlowContainer<UserPanel>
|
new OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Margin = new MarginPadding { Top = 20 },
|
Child = panelFlow = new FillFlowContainer<UserPanel>
|
||||||
Spacing = new Vector2(10f),
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Margin = new MarginPadding { Top = 20 },
|
||||||
|
Spacing = new Vector2(10f),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ using osu.Framework.Threading;
|
|||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Cursor;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
{
|
{
|
||||||
@ -86,9 +87,14 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
public BeatmapCarousel()
|
public BeatmapCarousel()
|
||||||
{
|
{
|
||||||
Add(scrollableContent = new Container<Panel>
|
Add(new OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = scrollableContent = new Container<Panel>
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,10 +13,13 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
|
||||||
namespace osu.Game.Users
|
namespace osu.Game.Users
|
||||||
{
|
{
|
||||||
public class UserPanel : ClickableContainer
|
public class UserPanel : ClickableContainer, IHasContextMenu
|
||||||
{
|
{
|
||||||
private readonly User user;
|
private readonly User user;
|
||||||
private const float height = 100;
|
private const float height = 100;
|
||||||
@ -31,6 +34,8 @@ namespace osu.Game.Users
|
|||||||
|
|
||||||
public new Action Action;
|
public new Action Action;
|
||||||
|
|
||||||
|
protected Action ViewProfile;
|
||||||
|
|
||||||
public UserPanel(User user)
|
public UserPanel(User user)
|
||||||
{
|
{
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@ -171,7 +176,7 @@ namespace osu.Game.Users
|
|||||||
Status.ValueChanged += displayStatus;
|
Status.ValueChanged += displayStatus;
|
||||||
Status.ValueChanged += status => statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint);
|
Status.ValueChanged += status => statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint);
|
||||||
|
|
||||||
base.Action = () =>
|
base.Action = ViewProfile = () =>
|
||||||
{
|
{
|
||||||
Action?.Invoke();
|
Action?.Invoke();
|
||||||
profile?.ShowUser(user);
|
profile?.ShowUser(user);
|
||||||
@ -203,5 +208,10 @@ namespace osu.Game.Users
|
|||||||
statusMessage.Text = status.Message;
|
statusMessage.Text = status.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||||
|
{
|
||||||
|
new OsuMenuItem("View Profile", MenuItemType.Highlighted, ViewProfile),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user