1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Merge pull request #7537 from mcendu/mod-text

Make iconless mods display acronyms
This commit is contained in:
Dean Herbert 2020-01-18 14:57:35 +09:00 committed by GitHub
commit bf7f2300af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 140 additions and 44 deletions

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override string Name => "Fade In";
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 string Description => @"Keys appear out of nowhere!";
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 Acronym => "RD";
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 double ScoreMultiplier => 1;

View File

@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{
public override string Name => "Autopilot";
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 string Description => @"Automatic cursor movement - just follow the rhythm.";
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 Acronym => "BL";
public override IconUsage Icon => FontAwesome.Solid.Adjust;
public override IconUsage? Icon => FontAwesome.Solid.Adjust;
public override ModType Type => ModType.DifficultyIncrease;
public override bool Ranked => false;

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Osu.Mods
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!";

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Osu.Mods
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!";

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{
public override string Name => "Spin In";
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 string Description => "Circles spin in. No approach circles.";
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 Acronym => "SO";
public override IconUsage Icon => OsuIcon.ModSpunout;
public override IconUsage? Icon => OsuIcon.ModSpunout;
public override ModType Type => ModType.DifficultyReduction;
public override string Description => @"Spinners will be automatically completed.";
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 Acronym => "TP";
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 double ScoreMultiplier => 1;
}

View File

@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{
public override string Name => "Traceable";
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 string Description => "Put your faith in the approach circles...";
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 Acronym => "TR";
public override IconUsage Icon => FontAwesome.Solid.ArrowsAlt;
public override IconUsage? Icon => FontAwesome.Solid.ArrowsAlt;
public override ModType Type => ModType.Fun;
public override string Description => "Everything rotates. EVERYTHING.";
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 Acronym => "WG";
public override IconUsage Icon => FontAwesome.Solid.Certificate;
public override IconUsage? Icon => FontAwesome.Solid.Certificate;
public override ModType Type => ModType.Fun;
public override string Description => "They just won't stay still...";
public override double ScoreMultiplier => 1;

View File

@ -0,0 +1,62 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneModButton : OsuTestScene
{
public TestSceneModButton()
{
Children = new Drawable[]
{
new ModButton(new MultiMod(new TestMod1(), new TestMod2(), new TestMod3(), new TestMod4()))
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
}
};
}
private class TestMod1 : TestMod
{
public override string Name => "Test mod 1";
public override string Acronym => "M1";
}
private class TestMod2 : TestMod
{
public override string Name => "Test mod 2";
public override string Acronym => "M2";
public override IconUsage? Icon => FontAwesome.Solid.Exclamation;
}
private class TestMod3 : TestMod
{
public override string Name => "Test mod 3";
public override string Acronym => "M3";
public override IconUsage? Icon => FontAwesome.Solid.ArrowRight;
}
private class TestMod4 : TestMod
{
public override string Name => "Test mod 4";
public override string Acronym => "M4";
}
private abstract class TestMod : Mod, IApplicableMod
{
public override double ScoreMultiplier => 1.0;
}
}
}

View File

@ -80,7 +80,7 @@ namespace osu.Game.Overlays.Mods
foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing);
backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing);
backgroundIcon.Icon = modAfter.Icon;
backgroundIcon.Mod = modAfter;
using (BeginDelayedSequence(mod_switch_duration, true))
{
@ -218,8 +218,8 @@ namespace osu.Game.Overlays.Mods
private void displayMod(Mod mod)
{
if (backgroundIcon != null)
backgroundIcon.Icon = foregroundIcon.Icon;
foregroundIcon.Icon = mod.Icon;
backgroundIcon.Mod = foregroundIcon.Mod;
foregroundIcon.Mod = mod;
text.Text = mod.Name;
Colour = mod.HasImplementation ? Color4.White : Color4.Gray;
}

View File

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

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Autoplay";
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 string Description => "Watch a perfect automated play through the song.";
public override double ScoreMultiplier => 1;

View File

@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Cinema";
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 void ApplyToHUD(HUDOverlay overlay)

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Daycore";
public override string Acronym => "DC";
public override IconUsage Icon => FontAwesome.Solid.Question;
public override IconUsage? Icon => null;
public override string Description => "Whoaaaaa...";
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 IconUsage Icon => FontAwesome.Solid.Hammer;
public override IconUsage? Icon => FontAwesome.Solid.Hammer;
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 Acronym => "DT";
public override IconUsage Icon => OsuIcon.ModDoubletime;
public override IconUsage? Icon => OsuIcon.ModDoubletime;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Zoooooooooom...";
public override bool Ranked => true;

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Easy";
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 double ScoreMultiplier => 0.5;
public override bool Ranked => true;

View File

@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Flashlight";
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 string Description => "Restricted view area.";
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 Acronym => "HT";
public override IconUsage Icon => OsuIcon.ModHalftime;
public override IconUsage? Icon => OsuIcon.ModHalftime;
public override ModType Type => ModType.DifficultyReduction;
public override string Description => "Less zoom...";
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 Acronym => "HR";
public override IconUsage Icon => OsuIcon.ModHardrock;
public override IconUsage? Icon => OsuIcon.ModHardrock;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Everything just got a bit harder...";
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 Acronym => "HD";
public override IconUsage Icon => OsuIcon.ModHidden;
public override IconUsage? Icon => OsuIcon.ModHidden;
public override ModType Type => ModType.DifficultyIncrease;
public override bool Ranked => true;

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Nightcore";
public override string Acronym => "NC";
public override IconUsage Icon => OsuIcon.ModNightcore;
public override IconUsage? Icon => OsuIcon.ModNightcore;
public override string Description => "Uguuuuuuuu...";
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 Acronym => "NF";
public override IconUsage Icon => OsuIcon.ModNofail;
public override IconUsage? Icon => OsuIcon.ModNofail;
public override ModType Type => ModType.DifficultyReduction;
public override string Description => "You can't fail, no matter what.";
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 Acronym => "NM";
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;
}
}

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Perfect";
public override string Acronym => "PF";
public override IconUsage Icon => OsuIcon.ModPerfect;
public override IconUsage? Icon => OsuIcon.ModPerfect;
public override string Description => "SS or quit.";
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 Acronym => "RX";
public override IconUsage Icon => OsuIcon.ModRelax;
public override IconUsage? Icon => OsuIcon.ModRelax;
public override ModType Type => ModType.Automation;
public override double ScoreMultiplier => 1;
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 Acronym => "SD";
public override IconUsage Icon => OsuIcon.ModSuddendeath;
public override IconUsage? Icon => OsuIcon.ModSuddendeath;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Miss and fail.";
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 Acronym => "WD";
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;
[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 Acronym => "WU";
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;
[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.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Mods;
using osuTK;
using osu.Framework.Bindables;
@ -20,25 +21,30 @@ namespace osu.Game.Rulesets.UI
public readonly BindableBool Selected = new BindableBool();
private readonly SpriteIcon modIcon;
private readonly SpriteText modAcronym;
private readonly SpriteIcon background;
private const float size = 80;
public IconUsage Icon
{
get => modIcon.Icon;
set => modIcon.Icon = value;
}
private readonly ModType type;
public virtual string TooltipText { get; }
protected Mod Mod { get; private set; }
private Mod mod;
public Mod Mod
{
get => mod;
set
{
mod = value;
updateMod(value);
}
}
public ModIcon(Mod mod)
{
Mod = mod ?? throw new ArgumentNullException(nameof(mod));
this.mod = mod ?? throw new ArgumentNullException(nameof(mod));
type = mod.Type;
@ -56,15 +62,43 @@ namespace osu.Game.Rulesets.UI
Icon = OsuIcon.ModBg,
Shadow = true,
},
modAcronym = new OsuSpriteText
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Colour = OsuColour.Gray(84),
Alpha = 0,
Font = OsuFont.Numeric.With(null, 22f),
UseFullGlyphHeight = false,
Text = mod.Acronym
},
modIcon = new SpriteIcon
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Colour = OsuColour.Gray(84),
Size = new Vector2(size - 35),
Icon = mod.Icon
Size = new Vector2(45),
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;