mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 13:42:59 +08:00
Merge pull request #15682 from peppy/primary-key-consistency
Add `IsManaged` helper method to EF classes to match realm implementation
This commit is contained in:
commit
69fc7782ec
@ -49,7 +49,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
public void TestCreateNewBeatmap()
|
public void TestCreateNewBeatmap()
|
||||||
{
|
{
|
||||||
AddStep("save beatmap", () => Editor.Save());
|
AddStep("save beatmap", () => Editor.Save());
|
||||||
AddAssert("new beatmap persisted", () => EditorBeatmap.BeatmapInfo.ID > 0);
|
AddAssert("new beatmap persisted", () => EditorBeatmap.BeatmapInfo.IsManaged);
|
||||||
AddAssert("new beatmap in database", () => beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID)?.DeletePending == false);
|
AddAssert("new beatmap in database", () => beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID)?.DeletePending == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;
|
public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;
|
||||||
public float CircleSize { get; set; } = DEFAULT_DIFFICULTY;
|
public float CircleSize { get; set; } = DEFAULT_DIFFICULTY;
|
||||||
public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY;
|
public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY;
|
||||||
|
@ -135,7 +135,7 @@ namespace osu.Game.Beatmaps
|
|||||||
var localRulesetInfo = rulesetInfo as RulesetInfo;
|
var localRulesetInfo = rulesetInfo as RulesetInfo;
|
||||||
|
|
||||||
// Difficulty can only be computed if the beatmap and ruleset are locally available.
|
// Difficulty can only be computed if the beatmap and ruleset are locally available.
|
||||||
if (localBeatmapInfo == null || localBeatmapInfo.ID == 0 || localRulesetInfo == null)
|
if (localBeatmapInfo?.IsManaged != true || localRulesetInfo == null)
|
||||||
{
|
{
|
||||||
// If not, fall back to the existing star difficulty (e.g. from an online source).
|
// If not, fall back to the existing star difficulty (e.g. from an online source).
|
||||||
return Task.FromResult<StarDifficulty?>(new StarDifficulty(beatmapInfo.StarRating, (beatmapInfo as IBeatmapOnlineInfo)?.MaxCombo ?? 0));
|
return Task.FromResult<StarDifficulty?>(new StarDifficulty(beatmapInfo.StarRating, (beatmapInfo as IBeatmapOnlineInfo)?.MaxCombo ?? 0));
|
||||||
|
@ -20,6 +20,8 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
public int BeatmapVersion;
|
public int BeatmapVersion;
|
||||||
|
|
||||||
private int? onlineID;
|
private int? onlineID;
|
||||||
|
@ -20,6 +20,8 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|
||||||
[JsonProperty("title_unicode")]
|
[JsonProperty("title_unicode")]
|
||||||
|
@ -11,6 +11,8 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
public int BeatmapSetInfoID { get; set; }
|
public int BeatmapSetInfoID { get; set; }
|
||||||
|
|
||||||
public int FileInfoID { get; set; }
|
public int FileInfoID { get; set; }
|
||||||
|
@ -18,6 +18,8 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
private int? onlineID;
|
private int? onlineID;
|
||||||
|
|
||||||
[Column("OnlineBeatmapSetID")]
|
[Column("OnlineBeatmapSetID")]
|
||||||
|
@ -11,6 +11,8 @@ namespace osu.Game.Configuration
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
public int? RulesetID { get; set; }
|
public int? RulesetID { get; set; }
|
||||||
|
|
||||||
public int? Variant { get; set; }
|
public int? Variant { get; set; }
|
||||||
|
@ -476,7 +476,7 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
Files.Dereference(file.FileInfo);
|
Files.Dereference(file.FileInfo);
|
||||||
|
|
||||||
if (file.ID > 0)
|
if (file.IsManaged)
|
||||||
{
|
{
|
||||||
// This shouldn't be required, but here for safety in case the provided TModel is not being change tracked
|
// This shouldn't be required, but here for safety in case the provided TModel is not being change tracked
|
||||||
// Definitely can be removed once we rework the database backend.
|
// Definitely can be removed once we rework the database backend.
|
||||||
@ -505,7 +505,7 @@ namespace osu.Game.Database
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.ID > 0)
|
if (model.IsManaged)
|
||||||
Update(model);
|
Update(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -737,7 +737,7 @@ namespace osu.Game.Database
|
|||||||
/// <param name="items">The usable items present in the store.</param>
|
/// <param name="items">The usable items present in the store.</param>
|
||||||
/// <returns>Whether the <typeparamref name="TModel"/> exists.</returns>
|
/// <returns>Whether the <typeparamref name="TModel"/> exists.</returns>
|
||||||
protected virtual bool CheckLocalAvailability(TModel model, IQueryable<TModel> items)
|
protected virtual bool CheckLocalAvailability(TModel model, IQueryable<TModel> items)
|
||||||
=> model.ID > 0 && items.Any(i => i.ID == model.ID && i.Files.Any());
|
=> model.IsManaged && items.Any(i => i.ID == model.ID && i.Files.Any());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether import can be skipped after finding an existing import early in the process.
|
/// Whether import can be skipped after finding an existing import early in the process.
|
||||||
|
@ -11,5 +11,7 @@ namespace osu.Game.Database
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
int ID { get; set; }
|
int ID { get; set; }
|
||||||
|
|
||||||
|
bool IsManaged { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ namespace osu.Game.IO
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
public string Hash { get; set; }
|
public string Hash { get; set; }
|
||||||
|
|
||||||
public int ReferenceCount { get; set; }
|
public int ReferenceCount { get; set; }
|
||||||
|
@ -11,6 +11,8 @@ namespace osu.Game.Scoring
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
public int FileInfoID { get; set; }
|
public int FileInfoID { get; set; }
|
||||||
|
|
||||||
public FileInfo FileInfo { get; set; }
|
public FileInfo FileInfo { get; set; }
|
||||||
|
@ -22,6 +22,8 @@ namespace osu.Game.Scoring
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
public ScoreRank Rank { get; set; }
|
public ScoreRank Rank { get; set; }
|
||||||
|
|
||||||
public long TotalScore { get; set; }
|
public long TotalScore { get; set; }
|
||||||
|
@ -807,14 +807,14 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private void delete(BeatmapSetInfo beatmap)
|
private void delete(BeatmapSetInfo beatmap)
|
||||||
{
|
{
|
||||||
if (beatmap == null || beatmap.ID <= 0) return;
|
if (beatmap == null || !beatmap.IsManaged) return;
|
||||||
|
|
||||||
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
|
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearScores(BeatmapInfo beatmapInfo)
|
private void clearScores(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
if (beatmapInfo == null || beatmapInfo.ID <= 0) return;
|
if (beatmapInfo == null || !beatmapInfo.IsManaged) return;
|
||||||
|
|
||||||
dialogOverlay?.Push(new BeatmapClearScoresDialog(beatmapInfo, () =>
|
dialogOverlay?.Push(new BeatmapClearScoresDialog(beatmapInfo, () =>
|
||||||
// schedule done here rather than inside the dialog as the dialog may fade out and never callback.
|
// schedule done here rather than inside the dialog as the dialog may fade out and never callback.
|
||||||
|
@ -57,5 +57,7 @@ namespace osu.Game.Skinning
|
|||||||
string author = Creator == null ? string.Empty : $"({Creator})";
|
string author = Creator == null ? string.Empty : $"({Creator})";
|
||||||
return $"{Name} {author}".Trim();
|
return $"{Name} {author}".Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
public int SkinInfoID { get; set; }
|
public int SkinInfoID { get; set; }
|
||||||
|
|
||||||
public EFSkinInfo SkinInfo { get; set; }
|
public EFSkinInfo SkinInfo { get; set; }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
Loading…
Reference in New Issue
Block a user