Skip to content

Commit 62e536b

Browse files
authored
Merge pull request #31138 from bdach/mark-as-played
Implement ability to mark beatmap as played
2 parents df3b300 + a6e00d6 commit 62e536b

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

osu.Game/Beatmaps/BeatmapManager.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,16 @@ static string createBeatmapFilenameFromMetadata(BeatmapInfo beatmapInfo)
533533
}
534534
}
535535

536+
public void MarkPlayed(BeatmapInfo beatmapSetInfo) => Realm.Run(r =>
537+
{
538+
using var transaction = r.BeginWrite();
539+
540+
var beatmap = r.Find<BeatmapInfo>(beatmapSetInfo.ID)!;
541+
beatmap.LastPlayed = DateTimeOffset.Now;
542+
543+
transaction.Commit();
544+
});
545+
536546
#region Implementation of ICanAcceptFiles
537547

538548
public Task Import(params string[] paths) => beatmapImporter.Import(paths);

osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public partial class DrawableCarouselBeatmap : DrawableCarouselItem, IHasContext
8888
[Resolved]
8989
private OsuGame? game { get; set; }
9090

91+
[Resolved]
92+
private BeatmapManager? manager { get; set; }
93+
9194
private IBindable<StarDifficulty?> starDifficultyBindable = null!;
9295
private CancellationTokenSource? starDifficultyCancellationSource;
9396

@@ -98,7 +101,7 @@ public DrawableCarouselBeatmap(CarouselBeatmap panel)
98101
}
99102

100103
[BackgroundDependencyLoader]
101-
private void load(BeatmapManager? manager, SongSelect? songSelect)
104+
private void load(SongSelect? songSelect)
102105
{
103106
Header.Height = height;
104107

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

306+
if (manager != null)
307+
items.Add(new OsuMenuItem("Mark as played", MenuItemType.Standard, () => manager.MarkPlayed(beatmapInfo)));
308+
303309
if (hideRequested != null)
304310
items.Add(new OsuMenuItem(WebCommonStrings.ButtonsHide.ToSentence(), MenuItemType.Destructive, () => hideRequested(beatmapInfo)));
305311

osu.Game/Screens/Select/SongSelect.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog
378378

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

0 commit comments

Comments
 (0)