mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 08:22:56 +08:00
Moved all online score related parsing to its own class
This commit is contained in:
parent
f831832c59
commit
709aa1ed3d
@ -22,11 +22,8 @@ namespace osu.Game.Online.API.Requests
|
|||||||
|
|
||||||
private void onSuccess(GetScoresResponse r)
|
private void onSuccess(GetScoresResponse r)
|
||||||
{
|
{
|
||||||
foreach (Score score in r.Scores)
|
foreach (OnlineScore score in r.Scores)
|
||||||
{
|
score.GetModsFor(beatmap.Ruleset);
|
||||||
score.Beatmap = beatmap;
|
|
||||||
score.Ruleset = beatmap.Ruleset;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override WebRequest CreateWebRequest()
|
protected override WebRequest CreateWebRequest()
|
||||||
@ -43,6 +40,6 @@ namespace osu.Game.Online.API.Requests
|
|||||||
public class GetScoresResponse
|
public class GetScoresResponse
|
||||||
{
|
{
|
||||||
[JsonProperty(@"scores")]
|
[JsonProperty(@"scores")]
|
||||||
public IEnumerable<Score> Scores;
|
public IEnumerable<OnlineScore> Scores;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
osu.Game/Rulesets/Scoring/OnlineScore.cs
Normal file
19
osu.Game/Rulesets/Scoring/OnlineScore.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Scoring
|
||||||
|
{
|
||||||
|
public class OnlineScore : Score
|
||||||
|
{
|
||||||
|
[JsonProperty(@"mods")]
|
||||||
|
private string[] modStrings { get; set; }
|
||||||
|
|
||||||
|
public void GetModsFor(RulesetInfo ruleset)
|
||||||
|
{
|
||||||
|
Mods = ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -28,27 +27,9 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
|
|
||||||
public int Combo { get; set; }
|
public int Combo { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"mods")]
|
|
||||||
private string[] modStrings { get; set; }
|
|
||||||
|
|
||||||
public RulesetInfo Ruleset;
|
public RulesetInfo Ruleset;
|
||||||
|
|
||||||
private Mod[] mods;
|
public Mod[] Mods;
|
||||||
public Mod[] Mods
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// Evaluate the mod strings if necessary
|
|
||||||
return mods ?? (mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray());
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
mods = value;
|
|
||||||
|
|
||||||
// Assign the mod strings
|
|
||||||
modStrings = mods.Select(mod => mod.ShortenedName).ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonProperty(@"user")]
|
[JsonProperty(@"user")]
|
||||||
public User User;
|
public User User;
|
||||||
|
@ -128,6 +128,7 @@
|
|||||||
<Compile Include="Overlays\Profile\Sections\RecentSection.cs" />
|
<Compile Include="Overlays\Profile\Sections\RecentSection.cs" />
|
||||||
<Compile Include="Graphics\Containers\ConstrainedIconContainer.cs" />
|
<Compile Include="Graphics\Containers\ConstrainedIconContainer.cs" />
|
||||||
<Compile Include="Rulesets\Mods\IApplicableToDifficulty.cs" />
|
<Compile Include="Rulesets\Mods\IApplicableToDifficulty.cs" />
|
||||||
|
<Compile Include="Rulesets\Scoring\OnlineScore.cs" />
|
||||||
<Compile Include="Users\UserCoverBackground.cs" />
|
<Compile Include="Users\UserCoverBackground.cs" />
|
||||||
<Compile Include="Overlays\UserProfileOverlay.cs" />
|
<Compile Include="Overlays\UserProfileOverlay.cs" />
|
||||||
<Compile Include="Overlays\Profile\ProfileHeader.cs" />
|
<Compile Include="Overlays\Profile\ProfileHeader.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user