Skip to content

Commit

Permalink
Merge pull request #31138 from bdach/mark-as-played
Browse files Browse the repository at this point in the history
Implement ability to mark beatmap as played
  • Loading branch information
peppy authored Dec 24, 2024
2 parents df3b300 + a6e00d6 commit 62e536b
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 @@ -378,7 +378,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 62e536b

Please sign in to comment.