1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 09:23:06 +08:00

CreateModSections -> GetModsFor(PlayMode), fixed deselect not working in ModSelectOverlay, added MultiMod for multiple mods in one mod, fixed issues with SelectedColour in ModSection

This commit is contained in:
DrabWeb 2017-03-02 01:07:28 -04:00
parent 6c680825ed
commit 1eee587c18
15 changed files with 339 additions and 502 deletions

View File

@ -56,4 +56,9 @@ namespace osu.Game.Modes.Catch
public override double ScoreMultiplier => 1.12;
public override Mods[] DisablesMods => new Mods[] { };
}
public class CatchModPerfect : ModPerfect
{
}
}

View File

@ -33,110 +33,60 @@ namespace osu.Game.Modes.Catch
new CatchModFlashlight(),
};
public override IEnumerable<ModSection> CreateModSections() => new ModSection[]
public override IEnumerable<Mod> GetModsFor(ModType type)
{
new DifficultyReductionSection
switch (type)
{
Buttons = new[]
{
new ModButton
case ModType.DifficultyReduction:
return new Mod[]
{
ToggleKey = Key.Q,
Mods = new Mod[]
{
new CatchModEasy(),
},
},
new ModButton
new CatchModEasy(),
new CatchModNoFail(),
new CatchModHalfTime(),
};
case ModType.DifficultyIncrease:
return new Mod[]
{
ToggleKey = Key.W,
Mods = new Mod[]
new CatchModHardRock(),
new MultiMod
{
new CatchModNoFail(),
Mods = new Mod[]
{
new CatchModPerfect(),
new CatchModSuddenDeath(),
},
},
},
new ModButton
new MultiMod
{
Mods = new Mod[]
{
new CatchModDoubleTime(),
new CatchModNightcore(),
},
},
new CatchModHidden(),
new CatchModFlashlight(),
};
case ModType.Special:
return new Mod[]
{
ToggleKey = Key.E,
Mods = new Mod[]
new CatchModRelax(),
new MultiMod
{
new CatchModHalfTime(),
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
},
},
},
new DifficultyIncreaseSection
{
Buttons = new ModButton[]
{
new ModButton
{
ToggleKey = Key.A,
Mods = new Mod[]
{
new CatchModHardRock(),
},
},
new ModButton
{
ToggleKey = Key.S,
Mods = new Mod[]
{
new CatchModSuddenDeath(),
new ModPerfect(),
},
},
new ModButton
{
ToggleKey = Key.D,
Mods = new Mod[]
{
new CatchModDoubleTime(),
new CatchModNightcore(),
},
},
new ModButton
{
ToggleKey = Key.F,
Mods = new Mod[]
{
new CatchModHidden(),
},
},
new ModButton
{
ToggleKey = Key.G,
Mods = new Mod[]
{
new CatchModFlashlight(),
},
},
},
},
new AssistedSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new CatchModRelax(),
},
},
new ModButton
{
ToggleKey = Key.B,
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
}
},
};
};
default:
return new Mod[] { };
}
}
protected override PlayMode PlayMode => PlayMode.Catch;

View File

@ -54,6 +54,11 @@ namespace osu.Game.Modes.Mania
public override Mods[] DisablesMods => new Mods[] { Mods.Hidden };
}
public class ManiaModPerfect : ModPerfect
{
}
public class ManiaModFadeIn : Mod
{
public override Mods Name => Mods.FadeIn;

View File

@ -44,134 +44,76 @@ namespace osu.Game.Modes.Mania
new ManiaModKeyCoop(),
};
public override IEnumerable<ModSection> CreateModSections() => new ModSection[]
public override IEnumerable<Mod> GetModsFor(ModType type)
{
new DifficultyReductionSection
switch (type)
{
Buttons = new[]
{
new ModButton
case ModType.DifficultyReduction:
return new Mod[]
{
ToggleKey = Key.Q,
Mods = new Mod[]
{
new ManiaModEasy(),
},
},
new ModButton
new ManiaModEasy(),
new ManiaModNoFail(),
new ManiaModHalfTime(),
};
case ModType.DifficultyIncrease:
return new Mod[]
{
ToggleKey = Key.W,
Mods = new Mod[]
new ManiaModHardRock(),
new MultiMod
{
new ManiaModNoFail(),
Mods = new Mod[]
{
new ManiaModPerfect(),
new ManiaModSuddenDeath(),
},
},
},
new ModButton
new MultiMod
{
Mods = new Mod[]
{
new ManiaModDoubleTime(),
new ManiaModNightcore(),
},
},
new ManiaModHidden(),
new ManiaModFlashlight(),
};
case ModType.Special:
return new Mod[]
{
ToggleKey = Key.E,
Mods = new Mod[]
new MultiMod
{
new ManiaModHalfTime(),
Mods = new Mod[]
{
new ManiaModKey4(),
new ManiaModKey5(),
new ManiaModKey6(),
new ManiaModKey7(),
new ManiaModKey8(),
new ManiaModKey9(),
new ManiaModKey1(),
new ManiaModKey2(),
new ManiaModKey3(),
},
},
},
},
},
new DifficultyIncreaseSection
{
Buttons = new ModButton[]
{
new ModButton
{
ToggleKey = Key.A,
Mods = new Mod[]
new ManiaModKeyCoop(),
new ManiaModRandom(),
new MultiMod
{
new ManiaModHardRock(),
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
},
new ModButton
{
ToggleKey = Key.S,
Mods = new Mod[]
{
new ManiaModSuddenDeath(),
new ModPerfect(),
},
},
new ModButton
{
ToggleKey = Key.D,
Mods = new Mod[]
{
new ManiaModDoubleTime(),
new ManiaModNightcore(),
},
},
new ModButton
{
ToggleKey = Key.F,
Mods = new Mod[]
{
new ManiaModHidden(),
},
},
new ModButton
{
ToggleKey = Key.G,
Mods = new Mod[]
{
new ManiaModFlashlight(),
},
},
},
},
new AssistedSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new ManiaModKey4(),
new ManiaModKey5(),
new ManiaModKey6(),
new ManiaModKey7(),
new ManiaModKey8(),
new ManiaModKey9(),
new ManiaModKey1(),
new ManiaModKey2(),
new ManiaModKey3(),
},
},
new ModButton
{
ToggleKey = Key.X,
Mods = new Mod[]
{
new ManiaModKeyCoop(),
},
},
new ModButton
{
ToggleKey = Key.C,
Mods = new Mod[]
{
new ManiaModRandom(),
},
},
new ModButton
{
ToggleKey = Key.V,
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
}
},
};
};
default:
return new Mod[] { };
}
}
protected override PlayMode PlayMode => PlayMode.Mania;

View File

@ -59,6 +59,11 @@ namespace osu.Game.Modes.Osu
public override Mods[] DisablesMods => new Mods[] { };
}
public class OsuModPerfect : ModPerfect
{
}
public class OsuModSpunOut : Mod
{
public override Mods Name => Mods.SpunOut;

View File

@ -53,134 +53,63 @@ namespace osu.Game.Modes.Osu
new OsuModTarget(),
};
public override IEnumerable<ModSection> CreateModSections() => new ModSection[]
public override IEnumerable<Mod> GetModsFor(ModType type)
{
new DifficultyReductionSection
switch (type)
{
Buttons = new[]
{
new ModButton
case ModType.DifficultyReduction:
return new Mod[]
{
ToggleKey = Key.Q,
Mods = new Mod[]
{
new OsuModEasy(),
},
},
new ModButton
new OsuModEasy(),
new OsuModNoFail(),
new OsuModHalfTime(),
};
case ModType.DifficultyIncrease:
return new Mod[]
{
ToggleKey = Key.W,
Mods = new Mod[]
new OsuModHardRock(),
new MultiMod
{
new OsuModNoFail(),
Mods = new Mod[]
{
new OsuModSuddenDeath(),
new OsuModPerfect(),
},
},
},
new ModButton
new MultiMod
{
Mods = new Mod[]
{
new OsuModDoubleTime(),
new OsuModNightcore(),
},
},
new OsuModHidden(),
new OsuModFlashlight(),
};
case ModType.Special:
return new Mod[]
{
ToggleKey = Key.E,
Mods = new Mod[]
new OsuModRelax(),
new OsuModAutopilot(),
new OsuModTarget(),
new OsuModSpunOut(),
new MultiMod
{
new OsuModHalfTime(),
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
},
},
},
new DifficultyIncreaseSection
{
Buttons = new ModButton[]
{
new ModButton
{
ToggleKey = Key.A,
Mods = new Mod[]
{
new OsuModHardRock(),
},
},
new ModButton
{
ToggleKey = Key.S,
Mods = new Mod[]
{
new OsuModSuddenDeath(),
new ModPerfect(),
},
},
new ModButton
{
ToggleKey = Key.D,
Mods = new Mod[]
{
new OsuModDoubleTime(),
new OsuModNightcore(),
},
},
new ModButton
{
ToggleKey = Key.F,
Mods = new Mod[]
{
new OsuModHidden(),
},
},
new ModButton
{
ToggleKey = Key.G,
Mods = new Mod[]
{
new OsuModFlashlight(),
},
},
},
},
new AssistedSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new OsuModRelax(),
},
},
new ModButton
{
ToggleKey = Key.X,
Mods = new Mod[]
{
new OsuModAutopilot(),
},
},
new ModButton
{
ToggleKey = Key.C,
Mods = new Mod[]
{
new OsuModTarget(),
},
},
new ModButton
{
ToggleKey = Key.V,
Mods = new Mod[]
{
new OsuModSpunOut(),
},
},
new ModButton
{
ToggleKey = Key.B,
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
}
},
};
};
default:
return new Mod[] { };
}
}
public override FontAwesome Icon => FontAwesome.fa_osu_osu_o;

View File

@ -56,4 +56,9 @@ namespace osu.Game.Modes.Taiko
public override double ScoreMultiplier => 1.12;
public override Mods[] DisablesMods => new Mods[] { };
}
public class TaikoModPerfect : ModPerfect
{
}
}

View File

@ -33,110 +33,60 @@ namespace osu.Game.Modes.Taiko
new TaikoModFlashlight(),
};
public override IEnumerable<ModSection> CreateModSections() => new ModSection[]
public override IEnumerable<Mod> GetModsFor(ModType type)
{
new DifficultyReductionSection
switch (type)
{
Buttons = new[]
{
new ModButton
case ModType.DifficultyReduction:
return new Mod[]
{
ToggleKey = Key.Q,
Mods = new Mod[]
{
new TaikoModEasy(),
},
},
new ModButton
new TaikoModEasy(),
new TaikoModNoFail(),
new TaikoModHalfTime(),
};
case ModType.DifficultyIncrease:
return new Mod[]
{
ToggleKey = Key.W,
Mods = new Mod[]
new TaikoModHardRock(),
new MultiMod
{
new TaikoModNoFail(),
Mods = new Mod[]
{
new TaikoModPerfect(),
new TaikoModSuddenDeath(),
},
},
},
new ModButton
new MultiMod
{
Mods = new Mod[]
{
new TaikoModDoubleTime(),
new TaikoModNightcore(),
},
},
new TaikoModHidden(),
new TaikoModFlashlight(),
};
case ModType.Special:
return new Mod[]
{
ToggleKey = Key.E,
Mods = new Mod[]
new TaikoModRelax(),
new MultiMod
{
new TaikoModHalfTime(),
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
},
},
},
new DifficultyIncreaseSection
{
Buttons = new ModButton[]
{
new ModButton
{
ToggleKey = Key.A,
Mods = new Mod[]
{
new TaikoModHardRock(),
},
},
new ModButton
{
ToggleKey = Key.S,
Mods = new Mod[]
{
new TaikoModSuddenDeath(),
new ModPerfect(),
},
},
new ModButton
{
ToggleKey = Key.D,
Mods = new Mod[]
{
new TaikoModDoubleTime(),
new TaikoModNightcore(),
},
},
new ModButton
{
ToggleKey = Key.F,
Mods = new Mod[]
{
new TaikoModHidden(),
},
},
new ModButton
{
ToggleKey = Key.G,
Mods = new Mod[]
{
new TaikoModFlashlight(),
},
},
},
},
new AssistedSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new TaikoModRelax(),
},
},
new ModButton
{
ToggleKey = Key.B,
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
}
},
};
};
default:
return new Mod[] { };
}
}
protected override PlayMode PlayMode => PlayMode.Taiko;

View File

@ -43,6 +43,18 @@ namespace osu.Game.Modes
public abstract Mods[] DisablesMods { get; }
}
public class MultiMod : Mod
{
public override Mods Name => Modes.Mods.None;
public override FontAwesome Icon => FontAwesome.fa_close;
public override string Description => @"";
public override double ScoreMultiplier => 0.0;
public override bool Ranked => false;
public override Mods[] DisablesMods => new Mods[] { };
public Mod[] Mods;
}
public abstract class ModNoFail : Mod
{
public override Mods Name => Mods.NoFail;
@ -140,7 +152,7 @@ namespace osu.Game.Modes
public override Mods[] DisablesMods => new Mods[] { Mods.Relax, Mods.Autopilot, Mods.SpunOut, Mods.SuddenDeath, Mods.Perfect };
}
public class ModPerfect : ModSuddenDeath
public abstract class ModPerfect : ModSuddenDeath
{
public override Mods Name => Mods.Perfect;
public override FontAwesome Icon => FontAwesome.fa_osu_mod_perfect;
@ -250,4 +262,11 @@ namespace osu.Game.Modes
FreeModAllowed = NoFail | Easy | Hidden | HardRock | SuddenDeath | Flashlight | FadeIn | Relax | Autopilot | SpunOut | KeyMod,
ScoreIncreaseMods = Hidden | HardRock | DoubleTime | Flashlight | FadeIn
}
public enum ModType
{
DifficultyReduction,
DifficultyIncrease,
Special,
}
}

View File

@ -29,7 +29,7 @@ namespace osu.Game.Modes
public abstract IEnumerable<Mod> AvailableMods { get; }
public abstract IEnumerable<ModSection> CreateModSections();
public abstract IEnumerable<Mod> GetModsFor(ModType type);
public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount);

View File

@ -1,14 +1,11 @@
// 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 OpenTK.Input;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Modes;
using osu.Game.Overlays.Mods;
namespace osu.Game
namespace osu.Game.Overlays.Mods
{
public class AssistedSection : ModSection
{

View File

@ -1,13 +1,10 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Modes;
using osu.Game.Overlays.Mods;
namespace osu.Game
namespace osu.Game.Overlays.Mods
{
public class DifficultyIncreaseSection : ModSection
{

View File

@ -100,25 +100,38 @@ namespace osu.Game.Overlays.Mods
}
}
private Mod[] mods;
public Mod[] Mods
private Mod mod;
public Mod Mod
{
get
{
return mods;
return mod;
}
set
{
if (mods == value) return;
mods = value;
createIcons();
if (value.Length > 0)
if (mod == value) return;
mod = value;
if (mod is MultiMod)
{
displayMod(value[0]);
mods = ((MultiMod)mod).Mods;
}
else
{
mods = new Mod[] { mod };
}
createIcons();
if (mods.Length > 0)
{
displayMod(mods[0]);
}
}
}
private Mod[] mods;
public Mod[] Mods => mods; // the mods from Mod, only multiple if Mod is a MultiMod
public Mod SelectedMod => Mods.ElementAtOrDefault(selectedMod);
[BackgroundDependencyLoader]
@ -233,7 +246,7 @@ namespace osu.Game.Overlays.Mods
return base.OnKeyDown(state, args);
}
public ModButton()
public ModButton(Mod m)
{
Direction = FlowDirections.Vertical;
Spacing = new Vector2(0f, -5f);
@ -263,6 +276,8 @@ namespace osu.Game.Overlays.Mods
TextSize = 18,
},
};
Mod = m;
}
}
}

View File

@ -37,9 +37,7 @@ namespace osu.Game.Overlays.Mods
{
Mod selectedMod = button.SelectedMod;
if (selectedMod != null)
{
selectedMods.Add(selectedMod);
}
}
return selectedMods.ToArray();
@ -75,6 +73,7 @@ namespace osu.Game.Overlays.Mods
foreach (ModButton button in value)
{
button.Colour = Colour;
button.SelectedColour = selectedColour;
button.Action = buttonPressed;
}

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.Linq;
using System.Collections.Generic;
using OpenTK;
using OpenTK.Graphics;
@ -10,11 +11,11 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
using osu.Game.Modes;
using osu.Framework.Allocation;
namespace osu.Game.Overlays.Mods
{
@ -43,17 +44,35 @@ namespace osu.Game.Overlays.Mods
set
{
modMode = value;
var ruleset = Ruleset.GetRuleset(value);
modSectionsContainer.RemoveAll(delegate (ModSection m) { return true; });
foreach (ModSection s in Ruleset.GetRuleset(value).CreateModSections())
modSectionsContainer.Children = new ModSection[]
{
s.RelativeSizeAxes = Axes.X;
s.Origin = Anchor.TopCentre;
s.Anchor = Anchor.TopCentre;
s.Action = modButtonPressed;
modSectionsContainer.Add(s);
}
new DifficultyReductionSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
Buttons = ruleset.GetModsFor(ModType.DifficultyReduction).Select(m => new ModButton(m)).ToArray(),
},
new DifficultyIncreaseSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
Buttons = ruleset.GetModsFor(ModType.DifficultyIncrease).Select(m => new ModButton(m)).ToArray(),
},
new AssistedSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
Buttons = ruleset.GetModsFor(ModType.Special).Select(m => new ModButton(m)).ToArray(),
},
};
}
}
@ -109,51 +128,6 @@ namespace osu.Game.Overlays.Mods
}
}
private void modButtonPressed(Mod selectedMod)
{
if (selectedMod != null)
{
foreach (Modes.Mods disableMod in selectedMod.DisablesMods)
{
DeselectMod(disableMod);
}
refreshSelectedMods();
}
double multiplier = 1;
bool ranked = true;
foreach (Mod mod in SelectedMods.Value)
{
multiplier *= mod.ScoreMultiplier;
if (ranked)
{
ranked = mod.Ranked;
}
}
// 1.00x
// 1.05x
// 1.20x
multiplierLabel.Text = string.Format("{0:N2}x", multiplier);
string rankedString = ranked ? "Ranked" : "Unranked";
rankedLabel.Text = $@"{rankedString}, Score Multiplier: ";
if (multiplier > 1.0)
{
multiplierLabel.FadeColour(highMultiplierColour, 200);
}
else if (multiplier < 1.0)
{
multiplierLabel.FadeColour(lowMultiplierColour, 200);
}
else
{
multiplierLabel.FadeColour(Color4.White, 200);
}
}
public void DeselectMod(Modes.Mods modName)
{
foreach (ModSection section in modSectionsContainer.Children)
@ -172,6 +146,51 @@ namespace osu.Game.Overlays.Mods
}
}
private void modButtonPressed(Mod selectedMod)
{
if (selectedMod != null)
{
foreach (Modes.Mods disableMod in selectedMod.DisablesMods)
{
DeselectMod(disableMod);
}
}
refreshSelectedMods();
double multiplier = 1.0;
bool ranked = true;
foreach (Mod mod in SelectedMods.Value)
{
multiplier *= mod.ScoreMultiplier;
if (ranked)
ranked = mod.Ranked;
}
// 1.00x
// 1.05x
// 1.20x
multiplierLabel.Text = string.Format("{0:N2}x", multiplier);
string rankedString = ranked ? "Ranked" : "Unranked";
rankedLabel.Text = $@"{rankedString}, Score Multiplier: ";
if (multiplier > 1.0)
{
multiplierLabel.FadeColour(highMultiplierColour, 200);
}
else if (multiplier < 1.0)
{
multiplierLabel.FadeColour(lowMultiplierColour, 200);
}
else
{
multiplierLabel.FadeColour(Color4.White, 200);
}
}
private void refreshSelectedMods()
{
List<Mod> selectedMods = new List<Mod>();