mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Merge branch 'master' of https://github.com/ppy/osu into songs-folder-check
This commit is contained in:
commit
44e9fb638c
@ -5,16 +5,19 @@ using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
{
|
||||
public abstract partial class BeatmapCard : OsuClickableContainer
|
||||
public abstract partial class BeatmapCard : OsuClickableContainer, IHasContextMenu
|
||||
{
|
||||
public const float TRANSITION_DURATION = 400;
|
||||
public const float CORNER_RADIUS = 10;
|
||||
@ -96,5 +99,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
throw new ArgumentOutOfRangeException(nameof(size), size, @"Unsupported card size");
|
||||
}
|
||||
}
|
||||
|
||||
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem(ContextMenuStrings.ViewBeatmap, MenuItemType.Highlighted, Action),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
24
osu.Game/Localisation/ContextMenuStrings.cs
Normal file
24
osu.Game/Localisation/ContextMenuStrings.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Localisation;
|
||||
|
||||
namespace osu.Game.Localisation
|
||||
{
|
||||
public static class ContextMenuStrings
|
||||
{
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.ContextMenu";
|
||||
|
||||
/// <summary>
|
||||
/// "View profile"
|
||||
/// </summary>
|
||||
public static LocalisableString ViewProfile => new TranslatableString(getKey(@"view_profile"), @"View profile");
|
||||
|
||||
/// <summary>
|
||||
/// "View beatmap"
|
||||
/// </summary>
|
||||
public static LocalisableString ViewBeatmap => new TranslatableString(getKey(@"view_beatmap"), @"View beatmap");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -91,11 +90,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
},
|
||||
},
|
||||
},
|
||||
new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = new Container
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
@ -158,13 +153,12 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
Padding = new MarginPadding { Left = buttons_height + buttons_spacing },
|
||||
Spacing = new Vector2(buttons_spacing),
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
loading = new LoadingSpinner
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
|
@ -17,9 +17,11 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -148,11 +150,11 @@ namespace osu.Game.Overlays.Chat
|
||||
|
||||
List<MenuItem> items = new List<MenuItem>
|
||||
{
|
||||
new OsuMenuItem("View Profile", MenuItemType.Highlighted, openUserProfile)
|
||||
new OsuMenuItem(ContextMenuStrings.ViewProfile, MenuItemType.Highlighted, openUserProfile)
|
||||
};
|
||||
|
||||
if (!user.Equals(api.LocalUser.Value))
|
||||
items.Add(new OsuMenuItem("Start Chat", MenuItemType.Standard, openUserChannel));
|
||||
items.Add(new OsuMenuItem(UsersStrings.CardSendMessage, MenuItemType.Standard, openUserChannel));
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online;
|
||||
|
||||
@ -38,15 +39,23 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ScrollbarVisible = false,
|
||||
Child = new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Header.With(h => h.Depth = float.MinValue),
|
||||
content = new PopoverContainer
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y
|
||||
@ -54,6 +63,8 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
Loading = new LoadingLayer(true)
|
||||
});
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -14,8 +13,11 @@ using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Users
|
||||
{
|
||||
@ -27,11 +29,11 @@ namespace osu.Game.Users
|
||||
/// Perform an action in addition to showing the user's profile.
|
||||
/// This should be used to perform auxiliary tasks and not as a primary action for clicking a user panel (to maintain a consistent UX).
|
||||
/// </summary>
|
||||
public new Action Action;
|
||||
public new Action? Action;
|
||||
|
||||
protected Action ViewProfile { get; private set; }
|
||||
protected Action ViewProfile { get; private set; } = null!;
|
||||
|
||||
protected Drawable Background { get; private set; }
|
||||
protected Drawable Background { get; private set; } = null!;
|
||||
|
||||
protected UserPanel(APIUser user)
|
||||
: base(HoverSampleSet.Button)
|
||||
@ -41,14 +43,23 @@ namespace osu.Game.Users
|
||||
User = user;
|
||||
}
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private UserProfileOverlay profileOverlay { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
protected OverlayColourProvider ColourProvider { get; private set; }
|
||||
[Resolved]
|
||||
private UserProfileOverlay? profileOverlay { get; set; }
|
||||
|
||||
[Resolved]
|
||||
protected OsuColour Colours { get; private set; }
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private ChannelManager? channelManager { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private ChatOverlay? chatOverlay { get; set; }
|
||||
|
||||
[Resolved]
|
||||
protected OverlayColourProvider? ColourProvider { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
protected OsuColour Colours { get; private set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
@ -79,7 +90,6 @@ namespace osu.Game.Users
|
||||
};
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
protected abstract Drawable CreateLayout();
|
||||
|
||||
protected OsuSpriteText CreateUsername() => new OsuSpriteText
|
||||
@ -89,9 +99,26 @@ namespace osu.Game.Users
|
||||
Text = User.Username,
|
||||
};
|
||||
|
||||
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||
public MenuItem[] ContextMenuItems
|
||||
{
|
||||
new OsuMenuItem("View Profile", MenuItemType.Highlighted, ViewProfile),
|
||||
get
|
||||
{
|
||||
List<MenuItem> items = new List<MenuItem>
|
||||
{
|
||||
new OsuMenuItem(ContextMenuStrings.ViewProfile, MenuItemType.Highlighted, ViewProfile)
|
||||
};
|
||||
|
||||
if (!User.Equals(api.LocalUser.Value))
|
||||
{
|
||||
items.Add(new OsuMenuItem(UsersStrings.CardSendMessage, MenuItemType.Standard, () =>
|
||||
{
|
||||
channelManager?.OpenPrivateChannel(User);
|
||||
chatOverlay?.Show();
|
||||
}));
|
||||
}
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user