mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Rework EF Core usage in model classes
This commit is contained in:
@ -230,7 +230,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
coverContainer.FadeIn(transition_duration);
|
||||
coverContainer.Children = new[]
|
||||
{
|
||||
new AsyncLoadWrapper(new BeatmapSetCover(value.BeatmapSetInfo)
|
||||
new AsyncLoadWrapper(new BeatmapSetCover(value.BeatmapSet)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -239,9 +239,9 @@ namespace osu.Game.Screens.Multiplayer
|
||||
}) { RelativeSizeAxes = Axes.Both },
|
||||
};
|
||||
|
||||
beatmapTitle.Current = localisation.GetUnicodePreference(value.BeatmapMetadata.TitleUnicode, value.BeatmapMetadata.Title);
|
||||
beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title);
|
||||
beatmapDash.Text = @" - ";
|
||||
beatmapArtist.Current = localisation.GetUnicodePreference(value.BeatmapMetadata.ArtistUnicode, value.BeatmapMetadata.Artist);
|
||||
beatmapArtist.Current = localisation.GetUnicodePreference(value.Metadata.ArtistUnicode, value.Metadata.Artist);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -331,7 +331,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
coverContainer.FadeIn(transition_duration);
|
||||
coverContainer.Children = new[]
|
||||
{
|
||||
new AsyncLoadWrapper(new BeatmapSetCover(value.BeatmapSetInfo)
|
||||
new AsyncLoadWrapper(new BeatmapSetCover(value.BeatmapSet)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
@ -341,10 +341,10 @@ namespace osu.Game.Screens.Multiplayer
|
||||
}) { RelativeSizeAxes = Axes.Both },
|
||||
};
|
||||
|
||||
beatmapTitle.Current = localisation.GetUnicodePreference(value.BeatmapMetadata.TitleUnicode, value.BeatmapMetadata.Title);
|
||||
beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title);
|
||||
beatmapDash.Text = @" - ";
|
||||
beatmapArtist.Current = localisation.GetUnicodePreference(value.BeatmapMetadata.ArtistUnicode, value.BeatmapMetadata.Artist);
|
||||
beatmapAuthor.Text = $"mapped by {value.BeatmapMetadata.Author}";
|
||||
beatmapArtist.Current = localisation.GetUnicodePreference(value.Metadata.ArtistUnicode, value.Metadata.Artist);
|
||||
beatmapAuthor.Text = $"mapped by {value.Metadata.Author}";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -99,18 +99,18 @@ namespace osu.Game.Screens.Play
|
||||
if (beatmap == null)
|
||||
throw new InvalidOperationException("Beatmap was not loaded");
|
||||
|
||||
ruleset = Ruleset.Value ?? beatmap.BeatmapInfo.RulesetInfo;
|
||||
ruleset = Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset;
|
||||
var rulesetInstance = ruleset.CreateInstance();
|
||||
|
||||
try
|
||||
{
|
||||
RulesetContainer = rulesetInstance.CreateRulesetContainerWith(working, ruleset.Id == beatmap.BeatmapInfo.RulesetInfo.Id);
|
||||
RulesetContainer = rulesetInstance.CreateRulesetContainerWith(working, ruleset.Id == beatmap.BeatmapInfo.Ruleset.Id);
|
||||
}
|
||||
catch (BeatmapInvalidForRulesetException)
|
||||
{
|
||||
// we may fail to create a RulesetContainer if the beatmap cannot be loaded with the user's preferred ruleset
|
||||
// let's try again forcing the beatmap's ruleset.
|
||||
ruleset = beatmap.BeatmapInfo.RulesetInfo;
|
||||
ruleset = beatmap.BeatmapInfo.Ruleset;
|
||||
rulesetInstance = ruleset.CreateInstance();
|
||||
RulesetContainer = rulesetInstance.CreateRulesetContainerWith(Beatmap, true);
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ namespace osu.Game.Screens.Play
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(LocalisationEngine localisation)
|
||||
{
|
||||
var metadata = beatmap?.BeatmapInfo?.BeatmapMetadata ?? new BeatmapMetadata();
|
||||
var metadata = beatmap?.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Children = new Drawable[]
|
||||
|
@ -324,9 +324,9 @@ namespace osu.Game.Screens.Ranking
|
||||
title.Colour = artist.Colour = colours.BlueDarker;
|
||||
versionMapper.Colour = colours.Gray8;
|
||||
|
||||
versionMapper.Text = $"{beatmap.Version} - mapped by {beatmap.BeatmapMetadata.Author}";
|
||||
title.Current = localisation.GetUnicodePreference(beatmap.BeatmapMetadata.TitleUnicode, beatmap.BeatmapMetadata.Title);
|
||||
artist.Current = localisation.GetUnicodePreference(beatmap.BeatmapMetadata.ArtistUnicode, beatmap.BeatmapMetadata.Artist);
|
||||
versionMapper.Text = $"{beatmap.Version} - mapped by {beatmap.Metadata.Author}";
|
||||
title.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title);
|
||||
artist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Select
|
||||
internal void UpdateBeatmap(BeatmapInfo beatmap)
|
||||
{
|
||||
// todo: this method should not run more than once for the same BeatmapSetInfo.
|
||||
var set = manager.Refresh(beatmap.BeatmapSetInfo);
|
||||
var set = manager.Refresh(beatmap.BeatmapSet);
|
||||
|
||||
// todo: this method should be smarter as to not recreate panels that haven't changed, etc.
|
||||
var group = groups.Find(b => b.BeatmapSet.Id == set.Id);
|
||||
@ -337,8 +337,8 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
foreach (var b in beatmapSet.Beatmaps)
|
||||
{
|
||||
if (b.BeatmapMetadata == null)
|
||||
b.BeatmapMetadata = beatmapSet.BeatmapMetadata;
|
||||
if (b.Metadata == null)
|
||||
b.Metadata = beatmapSet.Metadata;
|
||||
}
|
||||
|
||||
return new BeatmapGroup(beatmapSet, manager)
|
||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public BeatmapDeleteDialog(BeatmapSetInfo beatmap)
|
||||
{
|
||||
BodyText = $@"{beatmap.BeatmapMetadata?.Artist} - {beatmap.BeatmapMetadata?.Title}";
|
||||
BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}";
|
||||
|
||||
Icon = FontAwesome.fa_trash_o;
|
||||
HeaderText = @"Confirm deletion of";
|
||||
|
@ -188,8 +188,8 @@ namespace osu.Game.Screens.Select
|
||||
ratingsContainer.FadeIn(transition_duration);
|
||||
advanced.Beatmap = Beatmap;
|
||||
description.Text = Beatmap.Version;
|
||||
source.Text = Beatmap.BeatmapMetadata.Source;
|
||||
tags.Text = Beatmap.BeatmapMetadata.Tags;
|
||||
source.Text = Beatmap.Metadata.Source;
|
||||
tags.Text = Beatmap.Metadata.Tags;
|
||||
|
||||
var requestedBeatmap = Beatmap;
|
||||
if (requestedBeatmap.Metrics == null)
|
||||
@ -264,7 +264,7 @@ namespace osu.Game.Screens.Select
|
||||
advanced.Beatmap = new BeatmapInfo
|
||||
{
|
||||
StarDifficulty = 0,
|
||||
BeatmapDifficulty = new BeatmapDifficulty
|
||||
Difficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 0,
|
||||
DrainRate = 0,
|
||||
|
@ -90,7 +90,7 @@ namespace osu.Game.Screens.Select
|
||||
public BufferedWedgeInfo(WorkingBeatmap beatmap)
|
||||
{
|
||||
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
|
||||
BeatmapMetadata metadata = beatmapInfo.BeatmapMetadata ?? beatmap.BeatmapSetInfo?.BeatmapMetadata ?? new BeatmapMetadata();
|
||||
BeatmapMetadata metadata = beatmapInfo.Metadata ?? beatmap.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
|
||||
|
||||
List<InfoLabel> labels = new List<InfoLabel>();
|
||||
|
||||
@ -114,7 +114,7 @@ namespace osu.Game.Screens.Select
|
||||
}));
|
||||
|
||||
//get statistics from the current ruleset.
|
||||
labels.AddRange(beatmapInfo.RulesetInfo.CreateInstance().GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
|
||||
labels.AddRange(beatmapInfo.Ruleset.CreateInstance().GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
|
||||
}
|
||||
|
||||
PixelSnapping = true;
|
||||
|
@ -29,20 +29,20 @@ namespace osu.Game.Screens.Select.Details
|
||||
beatmap = value;
|
||||
|
||||
//mania specific
|
||||
if ((Beatmap?.RulesetInfo?.Id ?? 0) == 3)
|
||||
if ((Beatmap?.Ruleset?.Id ?? 0) == 3)
|
||||
{
|
||||
firstValue.Title = "Key Amount";
|
||||
firstValue.Value = (int)Math.Round(Beatmap?.BeatmapDifficulty?.CircleSize ?? 0);
|
||||
firstValue.Value = (int)Math.Round(Beatmap?.Difficulty?.CircleSize ?? 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
firstValue.Title = "Circle Size";
|
||||
firstValue.Value = Beatmap?.BeatmapDifficulty?.CircleSize ?? 0;
|
||||
firstValue.Value = Beatmap?.Difficulty?.CircleSize ?? 0;
|
||||
}
|
||||
|
||||
hpDrain.Value = beatmap.BeatmapDifficulty?.DrainRate ?? 0;
|
||||
accuracy.Value = beatmap.BeatmapDifficulty?.OverallDifficulty ?? 0;
|
||||
approachRate.Value = beatmap.BeatmapDifficulty?.ApproachRate ?? 0;
|
||||
hpDrain.Value = beatmap.Difficulty?.DrainRate ?? 0;
|
||||
accuracy.Value = beatmap.Difficulty?.OverallDifficulty ?? 0;
|
||||
approachRate.Value = beatmap.Difficulty?.ApproachRate ?? 0;
|
||||
starDifficulty.Value = (float)beatmap.StarDifficulty;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Screens.Select
|
||||
bool match = hasCurrentMode;
|
||||
|
||||
if (!string.IsNullOrEmpty(SearchText))
|
||||
match &= set.BeatmapMetadata.SearchableTerms.Any(term => term.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0);
|
||||
match &= set.Metadata.SearchableTerms.Any(term => term.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0);
|
||||
|
||||
switch (g.State)
|
||||
{
|
||||
@ -45,13 +45,13 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
default:
|
||||
case SortMode.Artist:
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.BeatmapMetadata.Artist, y.BeatmapSet.BeatmapMetadata.Artist, StringComparison.InvariantCultureIgnoreCase));
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase));
|
||||
break;
|
||||
case SortMode.Title:
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.BeatmapMetadata.Title, y.BeatmapSet.BeatmapMetadata.Title, StringComparison.InvariantCultureIgnoreCase));
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase));
|
||||
break;
|
||||
case SortMode.Author:
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.BeatmapMetadata.Author, y.BeatmapSet.BeatmapMetadata.Author, StringComparison.InvariantCultureIgnoreCase));
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author, StringComparison.InvariantCultureIgnoreCase));
|
||||
break;
|
||||
case SortMode.Difficulty:
|
||||
groups.Sort((x, y) => x.BeatmapSet.MaxStarDifficulty.CompareTo(y.BeatmapSet.MaxStarDifficulty));
|
||||
@ -59,4 +59,4 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user