1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

Added refresh scoreboard upon deleting local score and formatted the code

This commit is contained in:
wltu 2019-12-17 12:56:30 -08:00
parent bb2b1475cd
commit 8aeef3f59a
3 changed files with 21 additions and 12 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
@ -54,9 +55,11 @@ namespace osu.Game.Online.Leaderboards
private FillFlowContainer<ModIcon> modsContainer;
private List<ScoreComponentLabel> statisticsLabels;
private DialogOverlay dialogOverlay;
public Action RefreshAction { get; set; }
public LeaderboardScore(ScoreInfo score, int rank, bool allowHighlight = true)
{
this.score = score;
@ -367,9 +370,15 @@ namespace osu.Game.Online.Leaderboards
}
}
public MenuItem[] ContextMenuItems => new MenuItem[]
public MenuItem[] ContextMenuItems
{
new OsuMenuItem("Delete", MenuItemType.Destructive, () => dialogOverlay?.Push(new BeatmapClearScoresDialog(this.score, null)))
};
get
{
return (this.allowHighlight) ? null : new MenuItem[]
{
new OsuMenuItem("Delete", MenuItemType.Destructive, () => dialogOverlay?.Push(new BeatmapClearScoresDialog(this.score, () => Schedule(this.RefreshAction))))
};
}
}
}
}

View File

@ -52,11 +52,7 @@ namespace osu.Game.Screens.Select
new PopupDialogOkButton
{
Text = @"Yes. Please.",
Action = () =>
{
Task.Run(() => scoreManager.Delete(score))
.ContinueWith(_ => onCompletion);
}
Action = (() => scoreManager.Delete(score)) + onCompletion
},
new PopupDialogCancelButton
{

View File

@ -15,6 +15,8 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Screens.Select.Leaderboards
{
public class BeatmapLeaderboard : Leaderboard<BeatmapLeaderboardScope, ScoreInfo>
@ -182,12 +184,14 @@ namespace osu.Game.Screens.Select.Leaderboards
return req;
}
protected override LeaderboardScore CreateDrawableScore(ScoreInfo model, int index){
protected override LeaderboardScore CreateDrawableScore(ScoreInfo model, int index)
{
model.Beatmap = beatmap;
return new LeaderboardScore(model, index, IsOnlineScope)
{
Action = () => ScoreSelected?.Invoke(model)
Action = () => ScoreSelected?.Invoke(model),
RefreshAction = () => this.RefreshScores()
};
}
}