1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 18:53:21 +08:00

nullable-ize Mod.Icon

This commit is contained in:
mcendu 2020-01-14 21:22:00 +08:00
parent abdebcfddc
commit 5d160376c0
No known key found for this signature in database
GPG Key ID: FBCD5D45163D6364
32 changed files with 69 additions and 40 deletions

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{ {
public override string Name => "Fade In"; public override string Name => "Fade In";
public override string Acronym => "FI"; public override string Acronym => "FI";
public override IconUsage Icon => OsuIcon.ModHidden; public override IconUsage? Icon => OsuIcon.ModHidden;
public override ModType Type => ModType.DifficultyIncrease; public override ModType Type => ModType.DifficultyIncrease;
public override string Description => @"Keys appear out of nowhere!"; public override string Description => @"Keys appear out of nowhere!";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;

View File

@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Mods
public override string Name => "Random"; public override string Name => "Random";
public override string Acronym => "RD"; public override string Acronym => "RD";
public override ModType Type => ModType.Conversion; public override ModType Type => ModType.Conversion;
public override IconUsage Icon => OsuIcon.Dice; public override IconUsage? Icon => OsuIcon.Dice;
public override string Description => @"Shuffle around the keys!"; public override string Description => @"Shuffle around the keys!";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;

View File

@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
public override string Name => "Autopilot"; public override string Name => "Autopilot";
public override string Acronym => "AP"; public override string Acronym => "AP";
public override IconUsage Icon => OsuIcon.ModAutopilot; public override IconUsage? Icon => OsuIcon.ModAutopilot;
public override ModType Type => ModType.Automation; public override ModType Type => ModType.Automation;
public override string Description => @"Automatic cursor movement - just follow the rhythm."; public override string Description => @"Automatic cursor movement - just follow the rhythm.";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;

View File

@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public override string Description => "Play with blinds on your screen."; public override string Description => "Play with blinds on your screen.";
public override string Acronym => "BL"; public override string Acronym => "BL";
public override IconUsage Icon => FontAwesome.Solid.Adjust; public override IconUsage? Icon => FontAwesome.Solid.Adjust;
public override ModType Type => ModType.DifficultyIncrease; public override ModType Type => ModType.DifficultyIncrease;
public override bool Ranked => false; public override bool Ranked => false;

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public override string Acronym => "DF"; public override string Acronym => "DF";
public override IconUsage Icon => FontAwesome.Solid.CompressArrowsAlt; public override IconUsage? Icon => FontAwesome.Solid.CompressArrowsAlt;
public override string Description => "Hit them at the right size!"; public override string Description => "Hit them at the right size!";

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public override string Acronym => "GR"; public override string Acronym => "GR";
public override IconUsage Icon => FontAwesome.Solid.ArrowsAltV; public override IconUsage? Icon => FontAwesome.Solid.ArrowsAltV;
public override string Description => "Hit them at the right size!"; public override string Description => "Hit them at the right size!";

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
public override string Name => "Spin In"; public override string Name => "Spin In";
public override string Acronym => "SI"; public override string Acronym => "SI";
public override IconUsage Icon => FontAwesome.Solid.Undo; public override IconUsage? Icon => FontAwesome.Solid.Undo;
public override ModType Type => ModType.Fun; public override ModType Type => ModType.Fun;
public override string Description => "Circles spin in. No approach circles."; public override string Description => "Circles spin in. No approach circles.";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
public override string Name => "Spun Out"; public override string Name => "Spun Out";
public override string Acronym => "SO"; public override string Acronym => "SO";
public override IconUsage Icon => OsuIcon.ModSpunout; public override IconUsage? Icon => OsuIcon.ModSpunout;
public override ModType Type => ModType.DifficultyReduction; public override ModType Type => ModType.DifficultyReduction;
public override string Description => @"Spinners will be automatically completed."; public override string Description => @"Spinners will be automatically completed.";
public override double ScoreMultiplier => 0.9; public override double ScoreMultiplier => 0.9;

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public override string Name => "Target"; public override string Name => "Target";
public override string Acronym => "TP"; public override string Acronym => "TP";
public override ModType Type => ModType.Conversion; public override ModType Type => ModType.Conversion;
public override IconUsage Icon => OsuIcon.ModTarget; public override IconUsage? Icon => OsuIcon.ModTarget;
public override string Description => @"Practice keeping up with the beat of the song."; public override string Description => @"Practice keeping up with the beat of the song.";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;
} }

View File

@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
public override string Name => "Traceable"; public override string Name => "Traceable";
public override string Acronym => "TC"; public override string Acronym => "TC";
public override IconUsage Icon => FontAwesome.Brands.SnapchatGhost; public override IconUsage? Icon => FontAwesome.Brands.SnapchatGhost;
public override ModType Type => ModType.Fun; public override ModType Type => ModType.Fun;
public override string Description => "Put your faith in the approach circles..."; public override string Description => "Put your faith in the approach circles...";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;

View File

@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
public override string Name => "Transform"; public override string Name => "Transform";
public override string Acronym => "TR"; public override string Acronym => "TR";
public override IconUsage Icon => FontAwesome.Solid.ArrowsAlt; public override IconUsage? Icon => FontAwesome.Solid.ArrowsAlt;
public override ModType Type => ModType.Fun; public override ModType Type => ModType.Fun;
public override string Description => "Everything rotates. EVERYTHING."; public override string Description => "Everything rotates. EVERYTHING.";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;

View File

@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
public override string Name => "Wiggle"; public override string Name => "Wiggle";
public override string Acronym => "WG"; public override string Acronym => "WG";
public override IconUsage Icon => FontAwesome.Solid.Certificate; public override IconUsage? Icon => FontAwesome.Solid.Certificate;
public override ModType Type => ModType.Fun; public override ModType Type => ModType.Fun;
public override string Description => "They just won't stay still..."; public override string Description => "They just won't stay still...";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;

View File

@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mods
/// The icon of this mod. /// The icon of this mod.
/// </summary> /// </summary>
[JsonIgnore] [JsonIgnore]
public virtual IconUsage Icon => FontAwesome.Solid.Question; public virtual IconUsage? Icon => null;
/// <summary> /// <summary>
/// The type of this mod. /// The type of this mod.

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Autoplay"; public override string Name => "Autoplay";
public override string Acronym => "AT"; public override string Acronym => "AT";
public override IconUsage Icon => OsuIcon.ModAuto; public override IconUsage? Icon => OsuIcon.ModAuto;
public override ModType Type => ModType.Automation; public override ModType Type => ModType.Automation;
public override string Description => "Watch a perfect automated play through the song."; public override string Description => "Watch a perfect automated play through the song.";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;

View File

@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Cinema"; public override string Name => "Cinema";
public override string Acronym => "CN"; public override string Acronym => "CN";
public override IconUsage Icon => OsuIcon.ModCinema; public override IconUsage? Icon => OsuIcon.ModCinema;
public override string Description => "Watch the video without visual distractions."; public override string Description => "Watch the video without visual distractions.";
public void ApplyToHUD(HUDOverlay overlay) public void ApplyToHUD(HUDOverlay overlay)

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Daycore"; public override string Name => "Daycore";
public override string Acronym => "DC"; public override string Acronym => "DC";
public override IconUsage Icon => FontAwesome.Solid.Question; public override IconUsage? Icon => FontAwesome.Solid.Question;
public override string Description => "Whoaaaaa..."; public override string Description => "Whoaaaaa...";
private readonly BindableNumber<double> tempoAdjust = new BindableDouble(1); private readonly BindableNumber<double> tempoAdjust = new BindableDouble(1);

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Mods
public override ModType Type => ModType.Conversion; public override ModType Type => ModType.Conversion;
public override IconUsage Icon => FontAwesome.Solid.Hammer; public override IconUsage? Icon => FontAwesome.Solid.Hammer;
public override double ScoreMultiplier => 1.0; public override double ScoreMultiplier => 1.0;

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Double Time"; public override string Name => "Double Time";
public override string Acronym => "DT"; public override string Acronym => "DT";
public override IconUsage Icon => OsuIcon.ModDoubletime; public override IconUsage? Icon => OsuIcon.ModDoubletime;
public override ModType Type => ModType.DifficultyIncrease; public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Zoooooooooom..."; public override string Description => "Zoooooooooom...";
public override bool Ranked => true; public override bool Ranked => true;

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Easy"; public override string Name => "Easy";
public override string Acronym => "EZ"; public override string Acronym => "EZ";
public override IconUsage Icon => OsuIcon.ModEasy; public override IconUsage? Icon => OsuIcon.ModEasy;
public override ModType Type => ModType.DifficultyReduction; public override ModType Type => ModType.DifficultyReduction;
public override double ScoreMultiplier => 0.5; public override double ScoreMultiplier => 0.5;
public override bool Ranked => true; public override bool Ranked => true;

View File

@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Flashlight"; public override string Name => "Flashlight";
public override string Acronym => "FL"; public override string Acronym => "FL";
public override IconUsage Icon => OsuIcon.ModFlashlight; public override IconUsage? Icon => OsuIcon.ModFlashlight;
public override ModType Type => ModType.DifficultyIncrease; public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Restricted view area."; public override string Description => "Restricted view area.";
public override bool Ranked => true; public override bool Ranked => true;

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Half Time"; public override string Name => "Half Time";
public override string Acronym => "HT"; public override string Acronym => "HT";
public override IconUsage Icon => OsuIcon.ModHalftime; public override IconUsage? Icon => OsuIcon.ModHalftime;
public override ModType Type => ModType.DifficultyReduction; public override ModType Type => ModType.DifficultyReduction;
public override string Description => "Less zoom..."; public override string Description => "Less zoom...";
public override bool Ranked => true; public override bool Ranked => true;

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Hard Rock"; public override string Name => "Hard Rock";
public override string Acronym => "HR"; public override string Acronym => "HR";
public override IconUsage Icon => OsuIcon.ModHardrock; public override IconUsage? Icon => OsuIcon.ModHardrock;
public override ModType Type => ModType.DifficultyIncrease; public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Everything just got a bit harder..."; public override string Description => "Everything just got a bit harder...";
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModDifficultyAdjust) }; public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModDifficultyAdjust) };

View File

@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Hidden"; public override string Name => "Hidden";
public override string Acronym => "HD"; public override string Acronym => "HD";
public override IconUsage Icon => OsuIcon.ModHidden; public override IconUsage? Icon => OsuIcon.ModHidden;
public override ModType Type => ModType.DifficultyIncrease; public override ModType Type => ModType.DifficultyIncrease;
public override bool Ranked => true; public override bool Ranked => true;

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Nightcore"; public override string Name => "Nightcore";
public override string Acronym => "NC"; public override string Acronym => "NC";
public override IconUsage Icon => OsuIcon.ModNightcore; public override IconUsage? Icon => OsuIcon.ModNightcore;
public override string Description => "Uguuuuuuuu..."; public override string Description => "Uguuuuuuuu...";
private readonly BindableNumber<double> tempoAdjust = new BindableDouble(1); private readonly BindableNumber<double> tempoAdjust = new BindableDouble(1);

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "No Fail"; public override string Name => "No Fail";
public override string Acronym => "NF"; public override string Acronym => "NF";
public override IconUsage Icon => OsuIcon.ModNofail; public override IconUsage? Icon => OsuIcon.ModNofail;
public override ModType Type => ModType.DifficultyReduction; public override ModType Type => ModType.DifficultyReduction;
public override string Description => "You can't fail, no matter what."; public override string Description => "You can't fail, no matter what.";
public override double ScoreMultiplier => 0.5; public override double ScoreMultiplier => 0.5;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mods
public override string Name => "No Mod"; public override string Name => "No Mod";
public override string Acronym => "NM"; public override string Acronym => "NM";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;
public override IconUsage Icon => FontAwesome.Solid.Ban; public override IconUsage? Icon => FontAwesome.Solid.Ban;
public override ModType Type => ModType.System; public override ModType Type => ModType.System;
} }
} }

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Perfect"; public override string Name => "Perfect";
public override string Acronym => "PF"; public override string Acronym => "PF";
public override IconUsage Icon => OsuIcon.ModPerfect; public override IconUsage? Icon => OsuIcon.ModPerfect;
public override string Description => "SS or quit."; public override string Description => "SS or quit.";
protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result) => result.Type != result.Judgement.MaxResult; protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result) => result.Type != result.Judgement.MaxResult;

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Relax"; public override string Name => "Relax";
public override string Acronym => "RX"; public override string Acronym => "RX";
public override IconUsage Icon => OsuIcon.ModRelax; public override IconUsage? Icon => OsuIcon.ModRelax;
public override ModType Type => ModType.Automation; public override ModType Type => ModType.Automation;
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(ModNoFail), typeof(ModSuddenDeath) }; public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(ModNoFail), typeof(ModSuddenDeath) };

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mods
{ {
public override string Name => "Sudden Death"; public override string Name => "Sudden Death";
public override string Acronym => "SD"; public override string Acronym => "SD";
public override IconUsage Icon => OsuIcon.ModSuddendeath; public override IconUsage? Icon => OsuIcon.ModSuddendeath;
public override ModType Type => ModType.DifficultyIncrease; public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Miss and fail."; public override string Description => "Miss and fail.";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Mods
public override string Name => "Wind Down"; public override string Name => "Wind Down";
public override string Acronym => "WD"; public override string Acronym => "WD";
public override string Description => "Sloooow doooown..."; public override string Description => "Sloooow doooown...";
public override IconUsage Icon => FontAwesome.Solid.ChevronCircleDown; public override IconUsage? Icon => FontAwesome.Solid.ChevronCircleDown;
public override double ScoreMultiplier => 1.0; public override double ScoreMultiplier => 1.0;
[SettingSource("Final rate", "The speed increase to ramp towards")] [SettingSource("Final rate", "The speed increase to ramp towards")]

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Mods
public override string Name => "Wind Up"; public override string Name => "Wind Up";
public override string Acronym => "WU"; public override string Acronym => "WU";
public override string Description => "Can you keep up?"; public override string Description => "Can you keep up?";
public override IconUsage Icon => FontAwesome.Solid.ChevronCircleUp; public override IconUsage? Icon => FontAwesome.Solid.ChevronCircleUp;
public override double ScoreMultiplier => 1.0; public override double ScoreMultiplier => 1.0;
[SettingSource("Final rate", "The speed increase to ramp towards")] [SettingSource("Final rate", "The speed increase to ramp towards")]

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osuTK; using osuTK;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -20,16 +21,11 @@ namespace osu.Game.Rulesets.UI
public readonly BindableBool Selected = new BindableBool(); public readonly BindableBool Selected = new BindableBool();
private readonly SpriteIcon modIcon; private readonly SpriteIcon modIcon;
private readonly SpriteText modAcronym;
private readonly SpriteIcon background; private readonly SpriteIcon background;
private const float size = 80; private const float size = 80;
public IconUsage Icon
{
get => modIcon.Icon;
set => modIcon.Icon = value;
}
private readonly ModType type; private readonly ModType type;
public virtual string TooltipText { get; } public virtual string TooltipText { get; }
@ -39,12 +35,16 @@ namespace osu.Game.Rulesets.UI
public Mod Mod public Mod Mod
{ {
get => mod; get => mod;
set => mod = value; set
{
mod = value;
updateMod(value);
}
} }
public ModIcon(Mod mod) public ModIcon(Mod mod)
{ {
Mod = mod ?? throw new ArgumentNullException(nameof(mod)); this.mod = mod ?? throw new ArgumentNullException(nameof(mod));
type = mod.Type; type = mod.Type;
@ -62,15 +62,44 @@ namespace osu.Game.Rulesets.UI
Icon = OsuIcon.ModBg, Icon = OsuIcon.ModBg,
Shadow = true, Shadow = true,
}, },
modAcronym = new OsuSpriteText
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Colour = OsuColour.Gray(84),
Alpha = 0,
Font = OsuFont.Numeric.With(null, size - 55),
UseFullGlyphHeight = false,
Text = mod.Acronym
},
modIcon = new SpriteIcon modIcon = new SpriteIcon
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Colour = OsuColour.Gray(84), Colour = OsuColour.Gray(84),
Size = new Vector2(size - 35), Size = new Vector2(size - 35),
Icon = mod.Icon Icon = FontAwesome.Solid.Question
}, },
}; };
updateMod(mod);
}
private void updateMod(Mod value)
{
modAcronym.Text = value.Acronym;
modIcon.Icon = value.Icon ?? FontAwesome.Solid.Question;
if (value.Icon is null)
{
modIcon.FadeOut();
modAcronym.FadeIn();
return;
}
modIcon.FadeIn();
modAcronym.FadeOut();
} }
private Color4 backgroundColour; private Color4 backgroundColour;