Skip to content

Commit

Permalink
Implement ability to mark beatmap as played
Browse files Browse the repository at this point in the history
Reported at https://osu.ppy.sh/community/forums/topics/2015478?n=1.

Would you believe it that this button that has been there for literal
years never did anything?

Implemented at a per-beatmap level. Also additionally added to context
menu (at @peppy's suggestion), and also copy reworded from "Delete from
unplayed" to "Mark as played" because double negation hurt my tiny
brain.
  • Loading branch information
bdach committed Dec 16, 2024
1 parent ae10301 commit a6e00d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions osu.Game/Beatmaps/BeatmapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,16 @@ static string createBeatmapFilenameFromMetadata(BeatmapInfo beatmapInfo)
}
}

public void MarkPlayed(BeatmapInfo beatmapSetInfo) => Realm.Run(r =>
{
using var transaction = r.BeginWrite();

var beatmap = r.Find<BeatmapInfo>(beatmapSetInfo.ID)!;
beatmap.LastPlayed = DateTimeOffset.Now;

transaction.Commit();
});

#region Implementation of ICanAcceptFiles

public Task Import(params string[] paths) => beatmapImporter.Import(paths);
Expand Down
8 changes: 7 additions & 1 deletion osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public partial class DrawableCarouselBeatmap : DrawableCarouselItem, IHasContext
[Resolved]
private OsuGame? game { get; set; }

[Resolved]
private BeatmapManager? manager { get; set; }

private IBindable<StarDifficulty?> starDifficultyBindable = null!;
private CancellationTokenSource? starDifficultyCancellationSource;

Expand All @@ -98,7 +101,7 @@ public DrawableCarouselBeatmap(CarouselBeatmap panel)
}

[BackgroundDependencyLoader]
private void load(BeatmapManager? manager, SongSelect? songSelect)
private void load(SongSelect? songSelect)
{
Header.Height = height;

Expand Down Expand Up @@ -300,6 +303,9 @@ public MenuItem[] ContextMenuItems
if (beatmapInfo.GetOnlineURL(api, ruleset.Value) is string url)
items.Add(new OsuMenuItem(CommonStrings.CopyLink, MenuItemType.Standard, () => game?.CopyUrlToClipboard(url)));

if (manager != null)
items.Add(new OsuMenuItem("Mark as played", MenuItemType.Standard, () => manager.MarkPlayed(beatmapInfo)));

if (hideRequested != null)
items.Add(new OsuMenuItem(WebCommonStrings.ButtonsHide.ToSentence(), MenuItemType.Destructive, () => hideRequested(beatmapInfo)));

Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Screens/Select/SongSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog

BeatmapOptions.AddButton(@"Manage", @"collections", FontAwesome.Solid.Book, colours.Green, () => manageCollectionsDialog?.Show());
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => DeleteBeatmap(Beatmap.Value.BeatmapSetInfo));
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null);
BeatmapOptions.AddButton(@"Mark", @"as played", FontAwesome.Regular.TimesCircle, colours.Purple, () => beatmaps.MarkPlayed(Beatmap.Value.BeatmapInfo));
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, colours.Purple, () => ClearScores(Beatmap.Value.BeatmapInfo));
}

Expand Down

0 comments on commit a6e00d6

Please sign in to comment.