mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 07:22:54 +08:00
Refactors/renames
This commit is contained in:
parent
831cd3ed59
commit
3727955911
@ -127,7 +127,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
|
||||
var beatmapManager = osu.Dependencies.Get<BeatmapManager>();
|
||||
|
||||
score.BeatmapInfo = beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
|
||||
score.Beatmap = beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
|
||||
score.Ruleset = new OsuRuleset().RulesetInfo;
|
||||
|
||||
var scoreManager = osu.Dependencies.Get<ScoreManager>();
|
||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Online.API.Requests
|
||||
private void onSuccess(APIScores r)
|
||||
{
|
||||
foreach (APIScoreInfo score in r.Scores)
|
||||
score.ApplyBeatmap(beatmap);
|
||||
score.Beatmap = beatmap;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
|
@ -33,9 +33,6 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
set => User = value;
|
||||
}
|
||||
|
||||
[JsonProperty(@"mode_int")]
|
||||
public int OnlineRulesetID { get; set; }
|
||||
|
||||
[JsonProperty(@"score_id")]
|
||||
private long onlineScoreID
|
||||
{
|
||||
@ -51,7 +48,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
[JsonProperty(@"beatmap")]
|
||||
private BeatmapInfo beatmap
|
||||
{
|
||||
set => BeatmapInfo = value;
|
||||
set => Beatmap = value;
|
||||
}
|
||||
|
||||
[JsonProperty(@"beatmapset")]
|
||||
@ -60,10 +57,10 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
set
|
||||
{
|
||||
// extract the set ID to its correct place.
|
||||
BeatmapInfo.BeatmapSet = new BeatmapSetInfo { OnlineBeatmapSetID = value.ID };
|
||||
Beatmap.BeatmapSet = new BeatmapSetInfo { OnlineBeatmapSetID = value.ID };
|
||||
value.ID = 0;
|
||||
|
||||
BeatmapInfo.Metadata = value;
|
||||
Beatmap.Metadata = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,21 +95,32 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty(@"mode_int")]
|
||||
public int OnlineRulesetID { get; set; }
|
||||
|
||||
[JsonProperty(@"mods")]
|
||||
private string[] modStrings { get; set; }
|
||||
|
||||
public void ApplyBeatmap(BeatmapInfo beatmap)
|
||||
public override BeatmapInfo Beatmap
|
||||
{
|
||||
BeatmapInfo = beatmap;
|
||||
ApplyRuleset(beatmap.Ruleset);
|
||||
get => base.Beatmap;
|
||||
set
|
||||
{
|
||||
base.Beatmap = value;
|
||||
Ruleset = value.Ruleset;
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyRuleset(RulesetInfo ruleset)
|
||||
public override RulesetInfo Ruleset
|
||||
{
|
||||
Ruleset = ruleset;
|
||||
get => base.Ruleset;
|
||||
set
|
||||
{
|
||||
base.Ruleset = value;
|
||||
|
||||
// Evaluate the mod string
|
||||
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();
|
||||
// Evaluate the mod string
|
||||
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ namespace osu.Game
|
||||
return;
|
||||
}
|
||||
|
||||
var databasedBeatmap = BeatmapManager.QueryBeatmap(b => b.ID == score.BeatmapInfo.ID);
|
||||
var databasedBeatmap = BeatmapManager.QueryBeatmap(b => b.ID == score.Beatmap.ID);
|
||||
|
||||
if (databasedBeatmap == null)
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
RightFlowContainer.Add(text);
|
||||
RightFlowContainer.SetLayoutPosition(text, 1);
|
||||
|
||||
LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.BeatmapInfo));
|
||||
LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.Beatmap));
|
||||
LeftFlowContainer.Add(new DrawableDate(Score.Date));
|
||||
|
||||
foreach (Mod mod in Score.Mods)
|
||||
|
@ -9,6 +9,7 @@ using osu.Game.Users;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
{
|
||||
@ -29,6 +30,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
ItemsContainer.Direction = FillDirection.Vertical;
|
||||
}
|
||||
|
||||
private ScoreManager scoreManager;
|
||||
|
||||
protected override void ShowMore()
|
||||
{
|
||||
base.ShowMore();
|
||||
@ -37,7 +40,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
request.Success += scores => Schedule(() =>
|
||||
{
|
||||
foreach (var s in scores)
|
||||
s.ApplyRuleset(Rulesets.GetRuleset(s.OnlineRulesetID));
|
||||
s.Ruleset = Rulesets.GetRuleset(s.RulesetID);
|
||||
|
||||
ShowMoreButton.FadeTo(scores.Count == ItemsPerPage ? 1 : 0);
|
||||
ShowMoreLoading.Hide();
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Scoring.Legacy
|
||||
throw new BeatmapNotFoundException();
|
||||
|
||||
currentBeatmap = workingBeatmap.Beatmap;
|
||||
score.ScoreInfo.BeatmapInfo = currentBeatmap.BeatmapInfo;
|
||||
score.ScoreInfo.Beatmap = currentBeatmap.BeatmapInfo;
|
||||
|
||||
score.ScoreInfo.User = score.Replay.User = new User { Username = sr.ReadString() };
|
||||
score.ScoreInfo.MD5Hash = sr.ReadString();
|
||||
|
@ -36,27 +36,49 @@ namespace osu.Game.Scoring
|
||||
|
||||
public int RulesetID { get; set; }
|
||||
|
||||
public RulesetInfo Ruleset { get; set; }
|
||||
public virtual RulesetInfo Ruleset { get; set; }
|
||||
|
||||
[NotMapped, JsonIgnore]
|
||||
private Mod[] mods;
|
||||
|
||||
[NotMapped]
|
||||
public Mod[] Mods
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ModsString == null)
|
||||
if (mods != null) return mods;
|
||||
|
||||
if (modsJson == null)
|
||||
return Array.Empty<Mod>();
|
||||
|
||||
var deserialized = JsonConvert.DeserializeObject<string[]>(ModsString);
|
||||
return Ruleset.CreateInstance().GetAllMods().Where(mod => deserialized.Any(d => d == mod.ShortenedName)).ToArray();
|
||||
return getModsFromRuleset(JsonConvert.DeserializeObject<DeserializedMod[]>(modsJson));
|
||||
}
|
||||
set
|
||||
{
|
||||
mods = value;
|
||||
ModsJson = null;
|
||||
}
|
||||
set => ModsString = JsonConvert.SerializeObject(value.Select(m => m.ShortenedName).ToArray());
|
||||
}
|
||||
|
||||
public string ModsString { get; set; }
|
||||
private Mod[] getModsFromRuleset(DeserializedMod[] mods) => Ruleset.CreateInstance().GetAllMods().Where(mod => mods.Any(d => d.ShortenedName == mod.ShortenedName)).ToArray();
|
||||
|
||||
private string modsJson;
|
||||
|
||||
[Column("Mods")]
|
||||
public string ModsJson
|
||||
{
|
||||
get => modsJson ?? JsonConvert.SerializeObject(Mods);
|
||||
set
|
||||
{
|
||||
modsJson = value;
|
||||
|
||||
// we potentially can't update this yet due to Ruleset being late-bound, so instead update on read as necessary.
|
||||
mods = null;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped, JsonIgnore]
|
||||
public User User;
|
||||
|
||||
[Column("User")]
|
||||
public string UserString
|
||||
{
|
||||
get => User?.Username;
|
||||
@ -65,22 +87,25 @@ namespace osu.Game.Scoring
|
||||
|
||||
public int BeatmapInfoID { get; set; }
|
||||
|
||||
public BeatmapInfo BeatmapInfo { get; set; }
|
||||
public virtual BeatmapInfo Beatmap { get; set; }
|
||||
|
||||
public long? OnlineScoreID { get; set; }
|
||||
|
||||
public DateTimeOffset Date { get; set; }
|
||||
|
||||
[NotMapped, JsonIgnore]
|
||||
public Dictionary<HitResult, object> Statistics = new Dictionary<HitResult, object>();
|
||||
|
||||
public string StatisticsString
|
||||
[Column("Statistics")]
|
||||
public string StatisticsJson
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Statistics);
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
Statistics.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
Statistics = JsonConvert.DeserializeObject<Dictionary<HitResult, object>>(value);
|
||||
}
|
||||
@ -95,5 +120,13 @@ namespace osu.Game.Scoring
|
||||
public List<ScoreFileInfo> Files { get; set; }
|
||||
|
||||
public bool DeletePending { get; set; }
|
||||
|
||||
[Serializable]
|
||||
protected class DeserializedMod : Mod
|
||||
{
|
||||
public override string Name { get; } = string.Empty;
|
||||
public override string ShortenedName { get; } = string.Empty;
|
||||
public override double ScoreMultiplier { get; } = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Scoring
|
||||
protected override IQueryable<ScoreInfo> AddIncludesForConsumption(IQueryable<ScoreInfo> query)
|
||||
=> base.AddIncludesForConsumption(query)
|
||||
.Include(s => s.Files).ThenInclude(f => f.FileInfo)
|
||||
.Include(s => s.BeatmapInfo)
|
||||
.Include(s => s.Beatmap)
|
||||
.Include(s => s.Ruleset);
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
var score = new ScoreInfo
|
||||
{
|
||||
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
||||
Beatmap = Beatmap.Value.BeatmapInfo,
|
||||
Ruleset = ruleset
|
||||
};
|
||||
ScoreProcessor.PopulateScore(score);
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Screens.Ranking
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Beatmap = Beatmap.BeatmapInfo ?? Score.BeatmapInfo,
|
||||
Beatmap = Beatmap.BeatmapInfo ?? Score.Beatmap,
|
||||
Scale = new Vector2(0.7f)
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user