mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 15:43:22 +08:00
Enable NRT to ScoreManager
This commit is contained in:
parent
d34834af05
commit
f282152f99
@ -287,6 +287,8 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
var score = scoreManager.Query(s => s.ID == id);
|
var score = scoreManager.Query(s => s.ID == id);
|
||||||
|
|
||||||
|
if (score != null)
|
||||||
|
{
|
||||||
scoreManager.PopulateMaximumStatistics(score);
|
scoreManager.PopulateMaximumStatistics(score);
|
||||||
|
|
||||||
// Can't use async overload because we're not on the update thread.
|
// Can't use async overload because we're not on the update thread.
|
||||||
@ -295,6 +297,7 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
r.Find<ScoreInfo>(id)!.MaximumStatisticsJson = JsonConvert.SerializeObject(score.MaximumStatistics);
|
r.Find<ScoreInfo>(id)!.MaximumStatisticsJson = JsonConvert.SerializeObject(score.MaximumStatistics);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
++processedCount;
|
++processedCount;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -28,7 +26,7 @@ namespace osu.Game.Scoring
|
|||||||
public class ScoreManager : ModelManager<ScoreInfo>, IModelImporter<ScoreInfo>
|
public class ScoreManager : ModelManager<ScoreInfo>, IModelImporter<ScoreInfo>
|
||||||
{
|
{
|
||||||
private readonly Func<BeatmapManager> beatmaps;
|
private readonly Func<BeatmapManager> beatmaps;
|
||||||
private readonly OsuConfigManager configManager;
|
private readonly OsuConfigManager? configManager;
|
||||||
private readonly ScoreImporter scoreImporter;
|
private readonly ScoreImporter scoreImporter;
|
||||||
private readonly LegacyScoreExporter scoreExporter;
|
private readonly LegacyScoreExporter scoreExporter;
|
||||||
|
|
||||||
@ -43,7 +41,7 @@ namespace osu.Game.Scoring
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api,
|
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api,
|
||||||
OsuConfigManager configManager = null)
|
OsuConfigManager? configManager = null)
|
||||||
: base(storage, realm)
|
: base(storage, realm)
|
||||||
{
|
{
|
||||||
this.beatmaps = beatmaps;
|
this.beatmaps = beatmaps;
|
||||||
@ -67,7 +65,7 @@ namespace osu.Game.Scoring
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="query">The query.</param>
|
/// <param name="query">The query.</param>
|
||||||
/// <returns>The first result for the provided query, or null if no results were found.</returns>
|
/// <returns>The first result for the provided query, or null if no results were found.</returns>
|
||||||
public ScoreInfo Query(Expression<Func<ScoreInfo, bool>> query)
|
public ScoreInfo? Query(Expression<Func<ScoreInfo, bool>> query)
|
||||||
{
|
{
|
||||||
return Realm.Run(r => r.All<ScoreInfo>().FirstOrDefault(query)?.Detach());
|
return Realm.Run(r => r.All<ScoreInfo>().FirstOrDefault(query)?.Detach());
|
||||||
}
|
}
|
||||||
@ -104,7 +102,7 @@ namespace osu.Game.Scoring
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="score">The <see cref="ScoreInfo"/> to provide the total score of.</param>
|
/// <param name="score">The <see cref="ScoreInfo"/> to provide the total score of.</param>
|
||||||
/// <param name="configManager">The config.</param>
|
/// <param name="configManager">The config.</param>
|
||||||
public TotalScoreBindable(ScoreInfo score, OsuConfigManager configManager)
|
public TotalScoreBindable(ScoreInfo score, OsuConfigManager? configManager)
|
||||||
{
|
{
|
||||||
configManager?.BindWith(OsuSetting.ScoreDisplayMode, scoringMode);
|
configManager?.BindWith(OsuSetting.ScoreDisplayMode, scoringMode);
|
||||||
scoringMode.BindValueChanged(mode => Value = score.GetDisplayScore(mode.NewValue), true);
|
scoringMode.BindValueChanged(mode => Value = score.GetDisplayScore(mode.NewValue), true);
|
||||||
@ -126,7 +124,7 @@ namespace osu.Game.Scoring
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete([CanBeNull] Expression<Func<ScoreInfo, bool>> filter = null, bool silent = false)
|
public void Delete(Expression<Func<ScoreInfo, bool>>? filter = null, bool silent = false)
|
||||||
{
|
{
|
||||||
Realm.Run(r =>
|
Realm.Run(r =>
|
||||||
{
|
{
|
||||||
@ -165,9 +163,9 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
public Task Export(ScoreInfo score) => scoreExporter.ExportAsync(score.ToLive(Realm));
|
public Task Export(ScoreInfo score) => scoreExporter.ExportAsync(score.ToLive(Realm));
|
||||||
|
|
||||||
public Task<Live<ScoreInfo>> ImportAsUpdate(ProgressNotification notification, ImportTask task, ScoreInfo original) => scoreImporter.ImportAsUpdate(notification, task, original);
|
public Task<Live<ScoreInfo>?> ImportAsUpdate(ProgressNotification notification, ImportTask task, ScoreInfo original) => scoreImporter.ImportAsUpdate(notification, task, original);
|
||||||
|
|
||||||
public Live<ScoreInfo> Import(ScoreInfo item, ArchiveReader archive = null, ImportParameters parameters = default, CancellationToken cancellationToken = default) =>
|
public Live<ScoreInfo>? Import(ScoreInfo item, ArchiveReader? archive = null, ImportParameters parameters = default, CancellationToken cancellationToken = default) =>
|
||||||
scoreImporter.ImportModel(item, archive, parameters, cancellationToken);
|
scoreImporter.ImportModel(item, archive, parameters, cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -182,7 +180,7 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
#region Implementation of IPresentImports<ScoreInfo>
|
#region Implementation of IPresentImports<ScoreInfo>
|
||||||
|
|
||||||
public Action<IEnumerable<Live<ScoreInfo>>> PresentImport
|
public Action<IEnumerable<Live<ScoreInfo>>>? PresentImport
|
||||||
{
|
{
|
||||||
set => scoreImporter.PresentImport = value;
|
set => scoreImporter.PresentImport = value;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (state.NewValue != DownloadState.LocallyAvailable) return;
|
if (state.NewValue != DownloadState.LocallyAvailable) return;
|
||||||
|
|
||||||
scoreManager.Export(importedScore);
|
if (importedScore != null) scoreManager.Export(importedScore);
|
||||||
|
|
||||||
this.state.ValueChanged -= exportWhenReady;
|
this.state.ValueChanged -= exportWhenReady;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user