mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Parse the mods of a leaderboard's score
This commit is contained in:
@ -58,6 +58,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
private class DummyRuleset : Ruleset
|
||||
{
|
||||
public override IEnumerable<Mod> GetAllMods() => new Mod[] { };
|
||||
|
||||
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
||||
|
||||
public override Mod GetAutoplayMod() => new ModAutoplay();
|
||||
|
@ -16,6 +16,11 @@ namespace osu.Game.Rulesets.Mods
|
||||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The shortened name of this mod.
|
||||
/// </summary>
|
||||
public abstract string ShortenedName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The icon of this mod.
|
||||
/// </summary>
|
||||
|
@ -24,6 +24,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public class ModAutoplay : Mod
|
||||
{
|
||||
public override string Name => "Autoplay";
|
||||
public override string ShortenedName => "AT";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_auto;
|
||||
public override string Description => "Watch a perfect automated play through the song";
|
||||
public override double ScoreMultiplier => 0;
|
||||
|
@ -8,6 +8,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public class ModCinema : ModAutoplay
|
||||
{
|
||||
public override string Name => "Cinema";
|
||||
public override string ShortenedName => "CN";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_cinema;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModDaycore : ModHalfTime
|
||||
{
|
||||
public override string Name => "Daycore";
|
||||
public override string ShortenedName => "DC";
|
||||
public override FontAwesome Icon => FontAwesome.fa_question;
|
||||
public override string Description => "whoaaaaa";
|
||||
|
||||
|
@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public class ModDoubleTime : Mod, IApplicableToClock
|
||||
{
|
||||
public override string Name => "Double Time";
|
||||
public override string ShortenedName => "DT";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_doubletime;
|
||||
public override ModType Type => ModType.DifficultyIncrease;
|
||||
public override string Description => "Zoooooooooom";
|
||||
|
@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModEasy : Mod, IApplicableToDifficulty
|
||||
{
|
||||
public override string Name => "Easy";
|
||||
public override string ShortenedName => "EZ";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_easy;
|
||||
public override ModType Type => ModType.DifficultyReduction;
|
||||
public override string Description => "Reduces overall difficulty - larger circles, more forgiving HP drain, less accuracy required.";
|
||||
|
@ -8,6 +8,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModFlashlight : Mod
|
||||
{
|
||||
public override string Name => "Flashlight";
|
||||
public override string ShortenedName => "FL";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_flashlight;
|
||||
public override ModType Type => ModType.DifficultyIncrease;
|
||||
public override string Description => "Restricted view area.";
|
||||
|
@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModHalfTime : Mod, IApplicableToClock
|
||||
{
|
||||
public override string Name => "Half Time";
|
||||
public override string ShortenedName => "HT";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_halftime;
|
||||
public override ModType Type => ModType.DifficultyReduction;
|
||||
public override string Description => "Less zoom";
|
||||
|
@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModHardRock : Mod, IApplicableToDifficulty
|
||||
{
|
||||
public override string Name => "Hard Rock";
|
||||
public override string ShortenedName => "HR";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hardrock;
|
||||
public override ModType Type => ModType.DifficultyIncrease;
|
||||
public override string Description => "Everything just got a bit harder...";
|
||||
|
@ -8,6 +8,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModHidden : Mod
|
||||
{
|
||||
public override string Name => "Hidden";
|
||||
public override string ShortenedName => "HD";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden;
|
||||
public override ModType Type => ModType.DifficultyIncrease;
|
||||
public override bool Ranked => true;
|
||||
|
@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModNightcore : ModDoubleTime
|
||||
{
|
||||
public override string Name => "Nightcore";
|
||||
public override string ShortenedName => "NC";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_nightcore;
|
||||
public override string Description => "uguuuuuuuu";
|
||||
|
||||
|
@ -9,6 +9,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModNoFail : Mod
|
||||
{
|
||||
public override string Name => "NoFail";
|
||||
public override string ShortenedName => "NF";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_nofail;
|
||||
public override ModType Type => ModType.DifficultyReduction;
|
||||
public override string Description => "You can't fail, no matter what.";
|
||||
|
@ -6,6 +6,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModPerfect : ModSuddenDeath
|
||||
{
|
||||
public override string Name => "Perfect";
|
||||
public override string ShortenedName => "PF";
|
||||
public override string Description => "SS or quit.";
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModRelax : Mod
|
||||
{
|
||||
public override string Name => "Relax";
|
||||
public override string ShortenedName => "RX";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_relax;
|
||||
public override double ScoreMultiplier => 0;
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(ModNoFail), typeof(ModSuddenDeath) };
|
||||
|
@ -9,6 +9,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public abstract class ModSuddenDeath : Mod
|
||||
{
|
||||
public override string Name => "Sudden Death";
|
||||
public override string ShortenedName => "SD";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_suddendeath;
|
||||
public override ModType Type => ModType.DifficultyIncrease;
|
||||
public override string Description => "Miss a note and fail.";
|
||||
|
@ -6,6 +6,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public class MultiMod : Mod
|
||||
{
|
||||
public override string Name => string.Empty;
|
||||
public override string ShortenedName => string.Empty;
|
||||
public override string Description => string.Empty;
|
||||
public override double ScoreMultiplier => 0.0;
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
// 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.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Overlays.Settings;
|
||||
@ -19,8 +19,21 @@ namespace osu.Game.Rulesets
|
||||
|
||||
public virtual IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { };
|
||||
|
||||
public abstract IEnumerable<Mod> GetAllMods();
|
||||
|
||||
public abstract IEnumerable<Mod> GetModsFor(ModType type);
|
||||
|
||||
public Mod GetModByShortenedName(string shortenedName)
|
||||
{
|
||||
foreach(Mod mod in GetAllMods())
|
||||
{
|
||||
if (string.Equals(mod.ShortenedName, shortenedName))
|
||||
return mod;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract Mod GetAutoplayMod();
|
||||
|
||||
protected Ruleset(RulesetInfo rulesetInfo)
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -27,10 +28,31 @@ namespace osu.Game.Rulesets.Scoring
|
||||
|
||||
public int Combo { get; set; }
|
||||
|
||||
private string[] modStrings;
|
||||
[JsonProperty(@"mods")]
|
||||
protected string[] ModStrings { get; set; } //todo: parse to Mod objects
|
||||
protected string[] ModStrings {
|
||||
get { return modStrings; }
|
||||
set
|
||||
{
|
||||
modStrings = value;
|
||||
|
||||
public RulesetInfo Ruleset { get; set; }
|
||||
if (ruleset != null)
|
||||
handleModString();
|
||||
}
|
||||
}
|
||||
|
||||
private RulesetInfo ruleset;
|
||||
public RulesetInfo Ruleset
|
||||
{
|
||||
get { return ruleset; }
|
||||
set
|
||||
{
|
||||
ruleset = value;
|
||||
|
||||
if (modStrings != null)
|
||||
handleModString();
|
||||
}
|
||||
}
|
||||
|
||||
public Mod[] Mods { get; set; }
|
||||
|
||||
@ -80,5 +102,17 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
|
||||
public Dictionary<string, dynamic> Statistics = new Dictionary<string, dynamic>();
|
||||
|
||||
private void handleModString()
|
||||
{
|
||||
List<Mod> modList = new List<Mod>();
|
||||
|
||||
Ruleset rulesetInstance = Ruleset.CreateInstance();
|
||||
|
||||
foreach (string modShortenedName in modStrings)
|
||||
modList.Add(rulesetInstance.GetModByShortenedName(modShortenedName));
|
||||
|
||||
Mods = modList.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -55,6 +55,8 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
i = 0;
|
||||
foreach (var s in scores)
|
||||
{
|
||||
s.Ruleset = beatmap.Ruleset;
|
||||
|
||||
var ls = new LeaderboardScore(s, 1 + i)
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
|
@ -256,8 +256,23 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
foreach (Mod mod in Score.Mods)
|
||||
{
|
||||
// TODO: Get actual mod colours
|
||||
modsContainer.Add(new ScoreModIcon(mod.Icon, OsuColour.FromHex(@"ffcc22")));
|
||||
Color4 modColor;
|
||||
|
||||
switch (mod.Type)
|
||||
{
|
||||
default:
|
||||
case ModType.DifficultyIncrease:
|
||||
modColor = OsuColour.FromHex(@"ffcc22");
|
||||
break;
|
||||
case ModType.DifficultyReduction:
|
||||
modColor = OsuColour.FromHex(@"88b300");
|
||||
break;
|
||||
case ModType.Special:
|
||||
modColor = OsuColour.FromHex(@"66ccff");
|
||||
break;
|
||||
}
|
||||
|
||||
modsContainer.Add(new ScoreModIcon(mod.Icon, modColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user