1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 07:32:55 +08:00

Merge branch 'master' into remove-nullable-disable-in-the-mods-for-mania-ruleset

This commit is contained in:
Salman Ahmed 2022-07-28 08:21:23 +03:00 committed by GitHub
commit c74ffea236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 65 additions and 29 deletions

View File

@ -9,7 +9,6 @@ using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Screens.Play.HUD;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK; using osuTK;

View File

@ -6,7 +6,6 @@
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Screens.Play.HUD;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK.Graphics; using osuTK.Graphics;

View File

@ -279,12 +279,16 @@ namespace osu.Game.Tests.Database
{ {
var importer = new BeatmapImporter(storage, realm); var importer = new BeatmapImporter(storage, realm);
using var rulesets = new RealmRulesetStore(realm, storage); using var rulesets = new RealmRulesetStore(realm, storage);
string removedFilename = null!;
using var __ = getBeatmapArchive(out string pathOriginal); using var __ = getBeatmapArchive(out string pathOriginal);
using var _ = getBeatmapArchiveWithModifications(out string pathMissingOneBeatmap, directory => using var _ = getBeatmapArchiveWithModifications(out string pathMissingOneBeatmap, directory =>
{ {
// arbitrary beatmap removal // arbitrary beatmap removal
directory.GetFiles("*.osu").First().Delete(); var fileToRemove = directory.GetFiles("*.osu").First();
removedFilename = fileToRemove.Name;
fileToRemove.Delete();
}); });
var importBeforeUpdate = await importer.Import(new ImportTask(pathOriginal)); var importBeforeUpdate = await importer.Import(new ImportTask(pathOriginal));
@ -296,7 +300,9 @@ namespace osu.Game.Tests.Database
importBeforeUpdate.PerformWrite(s => importBeforeUpdate.PerformWrite(s =>
{ {
var beatmapInfo = s.Beatmaps.Last(); // make sure not to add scores to the same beatmap that is removed in the update.
var beatmapInfo = s.Beatmaps.First(b => b.File?.Filename != removedFilename);
scoreTargetBeatmapHash = beatmapInfo.Hash; scoreTargetBeatmapHash = beatmapInfo.Hash;
s.Realm.Add(new ScoreInfo(beatmapInfo, s.Realm.All<RulesetInfo>().First(), new RealmUser())); s.Realm.Add(new ScoreInfo(beatmapInfo, s.Realm.All<RulesetInfo>().First(), new RealmUser()));
}); });

View File

@ -10,6 +10,7 @@ using osu.Framework.Testing;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
using osu.Game.Skinning;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {

View File

@ -3,6 +3,8 @@
#nullable disable #nullable disable
using osu.Framework.Graphics;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osuTK; using osuTK;
@ -12,9 +14,15 @@ namespace osu.Game.Tests.Visual.Online
{ {
public TestSceneExternalLinkButton() public TestSceneExternalLinkButton()
{ {
Child = new ExternalLinkButton("https://osu.ppy.sh/home") Child = new OsuContextMenuContainer
{ {
Size = new Vector2(50) RelativeSizeAxes = Axes.Both,
Child = new ExternalLinkButton("https://osu.ppy.sh/home")
{
Size = new Vector2(50),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
}; };
} }
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -12,7 +10,10 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Localisation;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Overlays;
using osu.Game.Overlays.OSD;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -20,16 +21,19 @@ namespace osu.Game.Graphics.UserInterface
{ {
public class ExternalLinkButton : CompositeDrawable, IHasTooltip, IHasContextMenu public class ExternalLinkButton : CompositeDrawable, IHasTooltip, IHasContextMenu
{ {
public string Link { get; set; } public string? Link { get; set; }
private Color4 hoverColour; private Color4 hoverColour;
[Resolved] [Resolved]
private GameHost host { get; set; } private GameHost host { get; set; } = null!;
[Resolved]
private OnScreenDisplay? onScreenDisplay { get; set; }
private readonly SpriteIcon linkIcon; private readonly SpriteIcon linkIcon;
public ExternalLinkButton(string link = null) public ExternalLinkButton(string? link = null)
{ {
Link = link; Link = link;
Size = new Vector2(12); Size = new Vector2(12);
@ -44,22 +48,6 @@ namespace osu.Game.Graphics.UserInterface
}; };
} }
public MenuItem[] ContextMenuItems
{
get
{
List<MenuItem> items = new List<MenuItem>();
if (Link != null)
{
items.Add(new OsuMenuItem("Open", MenuItemType.Standard, () => host.OpenUrlExternally(Link)));
items.Add(new OsuMenuItem("Copy URL", MenuItemType.Standard, () => host.GetClipboard()?.SetText(Link)));
}
return items.ToArray();
}
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
@ -86,5 +74,35 @@ namespace osu.Game.Graphics.UserInterface
} }
public LocalisableString TooltipText => "view in browser"; public LocalisableString TooltipText => "view in browser";
public MenuItem[] ContextMenuItems
{
get
{
List<MenuItem> items = new List<MenuItem>();
if (Link != null)
{
items.Add(new OsuMenuItem("Open", MenuItemType.Standard, () => host.OpenUrlExternally(Link)));
items.Add(new OsuMenuItem("Copy URL", MenuItemType.Standard, copyUrl));
}
return items.ToArray();
}
}
private void copyUrl()
{
host.GetClipboard()?.SetText(Link);
onScreenDisplay?.Display(new CopyUrlToast(ToastStrings.UrlCopied));
}
private class CopyUrlToast : Toast
{
public CopyUrlToast(LocalisableString value)
: base(UserInterfaceStrings.GeneralHeader, value, "")
{
}
}
} }
} }

View File

@ -44,6 +44,11 @@ namespace osu.Game.Localisation
/// </summary> /// </summary>
public static LocalisableString SkinSaved => new TranslatableString(getKey(@"skin_saved"), @"Skin saved"); public static LocalisableString SkinSaved => new TranslatableString(getKey(@"skin_saved"), @"Skin saved");
/// <summary>
/// "URL copied"
/// </summary>
public static LocalisableString UrlCopied => new TranslatableString(getKey(@"url_copied"), @"URL copied");
private static string getKey(string key) => $@"{prefix}:{key}"; private static string getKey(string key) => $@"{prefix}:{key}";
} }
} }

View File

@ -9,10 +9,10 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning; using osu.Game.Screens.Play.HUD;
using osuTK; using osuTK;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Skinning
{ {
/// <summary> /// <summary>
/// Uses the 'x' symbol and has a pop-out effect while rolling over. /// Uses the 'x' symbol and has a pop-out effect while rolling over.