1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-01 02:40:04 +08:00

Merge pull request #34892 from bdach/shift-click-beatmap-card

Download online beatmap / present local beatmap on shift-clicking beatmap cards
This commit is contained in:
Dean Herbert
2025-09-03 16:19:48 +09:00
committed by GitHub
Unverified
3 changed files with 48 additions and 4 deletions
@@ -7,7 +7,9 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
@@ -35,6 +37,18 @@ namespace osu.Game.Beatmaps.Drawables.Cards
protected readonly BeatmapDownloadTracker DownloadTracker;
private readonly Bindable<bool> preferNoVideo = new BindableBool();
private InputManager? containingInputManager;
[Resolved]
private BeatmapSetOverlay? beatmapSetOverlay { get; set; }
[Resolved]
private BeatmapModelDownloader? beatmaps { get; set; }
[Resolved]
private OsuGame? game { get; set; }
protected BeatmapCard(APIBeatmapSet beatmapSet, bool allowExpansion = true)
: base(HoverSampleSet.Button)
{
@@ -45,10 +59,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards
DownloadTracker = new BeatmapDownloadTracker(beatmapSet);
}
[BackgroundDependencyLoader(true)]
private void load(BeatmapSetOverlay? beatmapSetOverlay)
[BackgroundDependencyLoader]
private void load(OsuConfigManager configManager)
{
Action = () => beatmapSetOverlay?.FetchAndShowBeatmapSet(BeatmapSet.OnlineID);
configManager.BindWith(OsuSetting.PreferNoVideo, preferNoVideo);
AddInternal(DownloadTracker);
}
@@ -60,6 +74,28 @@ namespace osu.Game.Beatmaps.Drawables.Cards
DownloadTracker.State.BindValueChanged(_ => UpdateState());
Expanded.BindValueChanged(_ => UpdateState(), true);
FinishTransforms(true);
containingInputManager = GetContainingInputManager();
Action = () =>
{
if (containingInputManager?.CurrentState.Keyboard.ShiftPressed == true)
{
switch (DownloadTracker.State.Value)
{
case DownloadState.NotDownloaded:
if (!BeatmapSet.Availability.DownloadDisabled)
beatmaps?.Download(BeatmapSet, preferNoVideo.Value);
break;
case DownloadState.LocallyAvailable:
game?.PresentBeatmap(BeatmapSet);
break;
}
}
else
beatmapSetOverlay?.FetchAndShowBeatmapSet(BeatmapSet.OnlineID);
};
}
protected override bool OnHover(HoverEvent e)
+5
View File
@@ -154,6 +154,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString RightMouseAbsoluteScroll => new TranslatableString(getKey(@"right_mouse_absolute_scroll"), @"Try holding your right mouse button near the beatmap carousel to quickly scroll to an absolute position!");
/// <summary>
/// "Shift-click on a beatmap panel in the beatmap listing overlay to quickly download or view the beatmap in song select!"
/// </summary>
public static LocalisableString ShiftClickInBeatmapOverlay => new TranslatableString(getKey(@"shift_click_in_beatmap_overlay"), @"Shift-click on a beatmap panel in the beatmap listing overlay to quickly download or view the beatmap in song select!");
/// <summary>
/// "a tip for you:"
/// </summary>
+4 -1
View File
@@ -118,7 +118,7 @@ namespace osu.Game.Screens.Menu
.FadeOutFromOne(2000, Easing.OutQuint);
}
private const int available_tips = 29;
private const int available_tips = 30;
private LocalisableString getRandomTip()
{
@@ -216,6 +216,9 @@ namespace osu.Game.Screens.Menu
case 28:
return MenuTipStrings.RightMouseAbsoluteScroll;
case 29:
return MenuTipStrings.ShiftClickInBeatmapOverlay;
}
return string.Empty;