1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 14:12:55 +08:00

Don't use Mods enum for handling incompatible mods.

This commit is contained in:
Dean Herbert 2017-03-06 18:16:21 +09:00
parent a7d7abe70e
commit 45f500920c
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
7 changed files with 46 additions and 35 deletions

View File

@ -1,6 +1,8 @@
// 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;
namespace osu.Game.Modes.Catch
{
public class CatchModNoFail : ModNoFail
@ -17,7 +19,7 @@ namespace osu.Game.Modes.Catch
{
public override string Description => @"Play with no approach circles and fading notes for a slight score advantage.";
public override double ScoreMultiplier => 1.06;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
}
public class CatchModHardRock : ModHardRock
@ -54,7 +56,7 @@ namespace osu.Game.Modes.Catch
public class CatchModFlashlight : ModFlashlight
{
public override double ScoreMultiplier => 1.12;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
}
public class CatchModPerfect : ModPerfect

View File

@ -1,6 +1,7 @@
// 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 osu.Game.Graphics;
namespace osu.Game.Modes.Mania
@ -19,7 +20,7 @@ namespace osu.Game.Modes.Mania
{
public override string Description => @"The notes fade out before you hit them!";
public override double ScoreMultiplier => 1.0;
public override Mods[] DisablesMods => new Mods[] { Mods.Flashlight };
public override Type[] IncompatibleMods => new[] { typeof(ModFlashlight) };
}
public class ManiaModHardRock : ModHardRock
@ -51,7 +52,7 @@ namespace osu.Game.Modes.Mania
public class ManiaModFlashlight : ModFlashlight
{
public override double ScoreMultiplier => 1.0;
public override Mods[] DisablesMods => new Mods[] { Mods.Hidden };
public override Type[] IncompatibleMods => new[] { typeof(ModHidden) };
}
public class ManiaModPerfect : ModPerfect
@ -66,7 +67,7 @@ namespace osu.Game.Modes.Mania
public override string Description => @"";
public override double ScoreMultiplier => 1;
public override bool Ranked => true;
public override Mods[] DisablesMods => new Mods[] { Mods.Flashlight };
public override Type[] IncompatibleMods => new[] { typeof(ModFlashlight) };
}
public class ManiaModRandom : Mod
@ -76,7 +77,7 @@ namespace osu.Game.Modes.Mania
public override string Description => @"Shuffle around the notes!";
public override double ScoreMultiplier => 1;
public override bool Ranked => false;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
}
public abstract class ManiaKeyMod : Mod
@ -86,7 +87,7 @@ namespace osu.Game.Modes.Mania
public override string Description => @"";
public override double ScoreMultiplier => 1; // TODO: Implement the mania key mod score multiplier
public override bool Ranked => true;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
}
public class ManiaModKey1 : ManiaKeyMod
@ -150,6 +151,6 @@ namespace osu.Game.Modes.Mania
public override string Description => @"Double the key amount, double the fun!";
public override double ScoreMultiplier => 1;
public override bool Ranked => true;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
}
}

View File

@ -1,13 +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.Linq;
using osu.Game.Graphics;
namespace osu.Game.Modes.Osu
{
public class OsuModNoFail : ModNoFail
{
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
}
public class OsuModEasy : ModEasy
@ -19,7 +21,7 @@ namespace osu.Game.Modes.Osu
{
public override string Description => @"Play with no approach circles and fading notes for a slight score advantage.";
public override double ScoreMultiplier => 1.06;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
}
public class OsuModHardRock : ModHardRock
@ -30,7 +32,7 @@ namespace osu.Game.Modes.Osu
public class OsuModSuddenDeath : ModSuddenDeath
{
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
}
public class OsuModDoubleTime : ModDoubleTime
@ -41,6 +43,7 @@ namespace osu.Game.Modes.Osu
public class OsuModRelax : ModRelax
{
public override string Description => "You don't need to click.\nGive your clicking/tapping finger a break from the heat of things.";
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
}
public class OsuModHalfTime : ModHalfTime
@ -56,12 +59,12 @@ namespace osu.Game.Modes.Osu
public class OsuModFlashlight : ModFlashlight
{
public override double ScoreMultiplier => 1.12;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
}
public class OsuModPerfect : ModPerfect
{
}
public class OsuModSpunOut : Mod
@ -71,7 +74,7 @@ namespace osu.Game.Modes.Osu
public override string Description => @"Spinners will be automatically completed";
public override double ScoreMultiplier => 0.9;
public override bool Ranked => true;
public override Mods[] DisablesMods => new Mods[] { Mods.Autoplay, Mods.Cinema, Mods.Autopilot };
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(ModCinema), typeof(OsuModAutopilot) };
}
public class OsuModAutopilot : Mod
@ -81,7 +84,12 @@ namespace osu.Game.Modes.Osu
public override string Description => @"Automatic cursor movement - just follow the rhythm.";
public override double ScoreMultiplier => 0;
public override bool Ranked => false;
public override Mods[] DisablesMods => new Mods[] { Mods.SpunOut, Mods.Relax, Mods.SuddenDeath, Mods.Perfect, Mods.NoFail, Mods.Autoplay, Mods.Cinema };
public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModPerfect), typeof(ModNoFail), typeof(ModAutoplay), typeof(ModCinema) };
}
public class OsuModeAutoplay : ModAutoplay
{
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
}
public class OsuModTarget : Mod
@ -91,6 +99,6 @@ namespace osu.Game.Modes.Osu
public override string Description => @"";
public override double ScoreMultiplier => 1;
public override bool Ranked => false;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
}
}

View File

@ -81,7 +81,7 @@ namespace osu.Game.Modes.Osu
{
Mods = new Mod[]
{
new ModAutoplay(),
new OsuModeAutoplay(),
new ModCinema(),
},
},

View File

@ -1,6 +1,8 @@
// 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;
namespace osu.Game.Modes.Taiko
{
public class TaikoModNoFail : ModNoFail
@ -17,7 +19,7 @@ namespace osu.Game.Modes.Taiko
{
public override string Description => @"The notes fade out before you hit them!";
public override double ScoreMultiplier => 1.06;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
}
public class TaikoModHardRock : ModHardRock
@ -54,7 +56,7 @@ namespace osu.Game.Modes.Taiko
public class TaikoModFlashlight : ModFlashlight
{
public override double ScoreMultiplier => 1.12;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
}
public class TaikoModPerfect : ModPerfect

View File

@ -40,7 +40,7 @@ namespace osu.Game.Modes
/// <summary>
/// The mods this mod cannot be enabled with.
/// </summary>
public abstract Mods[] DisablesMods { get; }
public abstract Type[] IncompatibleMods { get; }
}
public class MultiMod : Mod
@ -50,7 +50,7 @@ namespace osu.Game.Modes
public override string Description => @"";
public override double ScoreMultiplier => 0.0;
public override bool Ranked => false;
public override Mods[] DisablesMods => new Mods[] { };
public override Type[] IncompatibleMods => new Type[] { };
public Mod[] Mods;
}
@ -62,7 +62,7 @@ namespace osu.Game.Modes
public override string Description => @"You can't fail, no matter what.";
public override double ScoreMultiplier => 0.5;
public override bool Ranked => true;
public override Mods[] DisablesMods => new Mods[] { Mods.Relax, Mods.Autopilot, Mods.SuddenDeath, Mods.Perfect };
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModPerfect) };
}
public abstract class ModEasy : Mod
@ -72,7 +72,7 @@ namespace osu.Game.Modes
public override string Description => @"Reduces overall difficulty - larger circles, more forgiving HP drain, less accuracy required.";
public override double ScoreMultiplier => 0.5;
public override bool Ranked => true;
public override Mods[] DisablesMods => new Mods[] { Mods.HardRock };
public override Type[] IncompatibleMods => new[] { typeof(ModHardRock) };
}
public abstract class ModHidden : Mod
@ -87,7 +87,7 @@ namespace osu.Game.Modes
public override Mods Name => Mods.HardRock;
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hardrock;
public override string Description => @"Everything just got a bit harder...";
public override Mods[] DisablesMods => new Mods[] { Mods.Easy };
public override Type[] IncompatibleMods => new[] { typeof(ModEasy) };
}
public abstract class ModSuddenDeath : Mod
@ -97,7 +97,7 @@ namespace osu.Game.Modes
public override string Description => @"Miss a note and fail.";
public override double ScoreMultiplier => 1;
public override bool Ranked => true;
public override Mods[] DisablesMods => new Mods[] { Mods.NoFail, Mods.Relax, Mods.Autopilot, Mods.Autoplay, Mods.Cinema };
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay), typeof(ModCinema) };
}
public abstract class ModDoubleTime : Mod
@ -106,7 +106,7 @@ namespace osu.Game.Modes
public override FontAwesome Icon => FontAwesome.fa_osu_mod_doubletime;
public override string Description => @"Zoooooooooom";
public override bool Ranked => true;
public override Mods[] DisablesMods => new Mods[] { Mods.HalfTime };
public override Type[] IncompatibleMods => new[] { typeof(ModHalfTime) };
}
public abstract class ModRelax : Mod
@ -115,7 +115,7 @@ namespace osu.Game.Modes
public override FontAwesome Icon => FontAwesome.fa_osu_mod_relax;
public override double ScoreMultiplier => 0;
public override bool Ranked => false;
public override Mods[] DisablesMods => new Mods[] { Mods.Autopilot, Mods.Autoplay, Mods.Cinema, Mods.NoFail, Mods.SuddenDeath, Mods.Perfect };
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(ModCinema), typeof(ModNoFail), typeof(ModSuddenDeath), typeof(ModPerfect) };
}
public abstract class ModHalfTime : Mod
@ -124,7 +124,7 @@ namespace osu.Game.Modes
public override FontAwesome Icon => FontAwesome.fa_osu_mod_halftime;
public override string Description => @"Less zoom";
public override bool Ranked => true;
public override Mods[] DisablesMods => new Mods[] { Mods.DoubleTime, Mods.Nightcore };
public override Type[] IncompatibleMods => new[] { typeof(ModDoubleTime), typeof(ModNightcore) };
}
public abstract class ModNightcore : ModDoubleTime
@ -149,7 +149,7 @@ namespace osu.Game.Modes
public override string Description => @"Watch a perfect automated play through the song";
public override double ScoreMultiplier => 0;
public override bool Ranked => false;
public override Mods[] DisablesMods => new Mods[] { Mods.Relax, Mods.Autopilot, Mods.SpunOut, Mods.SuddenDeath, Mods.Perfect };
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModPerfect) };
}
public abstract class ModPerfect : ModSuddenDeath

View File

@ -124,7 +124,7 @@ namespace osu.Game.Overlays.Mods
}
}
public void DeselectMod(Modes.Mods modName)
public void DeselectType(Type modType)
{
foreach (ModSection section in modSectionsContainer.Children)
{
@ -132,7 +132,7 @@ namespace osu.Game.Overlays.Mods
{
foreach (Mod mod in button.Mods)
{
if (mod.Name == modName)
if (modType.IsInstanceOfType(mod))
{
button.Deselect();
return;
@ -146,10 +146,8 @@ namespace osu.Game.Overlays.Mods
{
if (selectedMod != null)
{
foreach (Modes.Mods disableMod in selectedMod.DisablesMods)
{
DeselectMod(disableMod);
}
foreach (Type t in selectedMod.IncompatibleMods)
DeselectType(t);
}
refreshSelectedMods();