Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions osu.Game/Localisation/DeleteConfirmationContentStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public static class DeleteConfirmationContentStrings
/// </summary>
public static LocalisableString Scores => new TranslatableString(getKey(@"scores"), @"Are you sure you want to delete all scores? This cannot be undone!");

/// <summary>
/// "Are you sure you want to delete all guest scores? This cannot be undone!"
/// </summary>
public static LocalisableString GuestScores => new TranslatableString(getKey(@"guest_scores"), @"Are you sure you want to delete all guest scores? This cannot be undone!");

/// <summary>
/// "Are you sure you want to delete all mod presets?"
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions osu.Game/Localisation/MaintenanceSettingsStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public static class MaintenanceSettingsStrings
/// </summary>
public static LocalisableString DeleteAllScores => new TranslatableString(getKey(@"delete_all_scores"), @"Delete ALL scores");

/// <summary>
/// "Delete Guest scores"
/// </summary>
public static LocalisableString DeleteGuestScores => new TranslatableString(getKey(@"delete_guest_scores"), @"Delete Guest scores");

Comment on lines +67 to +71
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <summary>
/// "Delete Guest scores"
/// </summary>
public static LocalisableString DeleteGuestScores => new TranslatableString(getKey(@"delete_guest_scores"), @"Delete Guest scores");
/// <summary>
/// "Delete guest scores"
/// </summary>
public static LocalisableString DeleteGuestScores => new TranslatableString(getKey(@"delete_guest_scores"), @"Delete guest scores");

/// <summary>
/// "Delete ALL skins"
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions osu.Game/Overlays/Settings/Sections/Maintenance/ScoreSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public partial class ScoreSettings : SettingsSubsection
protected override LocalisableString Header => CommonStrings.Scores;

private SettingsButtonV2 deleteScoresButton = null!;
private SettingsButtonV2 deleteGuestScoresButton = null!;

[BackgroundDependencyLoader]
private void load(ScoreManager scores, IDialogOverlay? dialogOverlay)
Expand All @@ -30,6 +31,18 @@ private void load(ScoreManager scores, IDialogOverlay? dialogOverlay)
}, DeleteConfirmationContentStrings.Scores));
}
});
Add(deleteGuestScoresButton = new DangerousSettingsButtonV2
{
Text = MaintenanceSettingsStrings.DeleteGuestScores,
Action = () =>
{
dialogOverlay?.Push(new MassDeleteConfirmationDialog(() =>
{
deleteGuestScoresButton.Enabled.Value = false;
Task.Run(() => scores.DeleteGuest()).ContinueWith(_ => Schedule(() => deleteGuestScoresButton.Enabled.Value = true));
}, DeleteConfirmationContentStrings.GuestScores));
}
});
}
}
}
15 changes: 15 additions & 0 deletions osu.Game/Scoring/ScoreManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.IO.Archives;
using osu.Game.Models;

Check failure on line 18 in osu.Game/Scoring/ScoreManager.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 18 in osu.Game/Scoring/ScoreManager.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using osu.Game.Models;

using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring.Legacy;
using Realms;

namespace osu.Game.Scoring
{
Expand Down Expand Up @@ -166,6 +169,18 @@
}
}

public void DeleteGuest(bool silent = false)
{
Realm.Run(r =>
{
var guestScores = r.All<ScoreInfo>()
.Filter(@"DeletePending == false AND RealmUser.OnlineID == $0", APIUser.SYSTEM_USER_ID)
.ToList();

Delete(guestScores, silent);
});
}

public void Delete(Expression<Func<ScoreInfo, bool>>? filter = null, bool silent = false)
{
Realm.Run(r =>
Expand Down
Loading