From c0e29652a6d8e5f5d40c0b6cb3ddae905ddbd64d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sun, 12 Mar 2017 22:13:43 +0900 Subject: [PATCH] Initial attempt at making mods apply better. --- .../Tests/TestCaseReplay.cs | 13 ++++--- osu.Game.Modes.Catch/CatchRuleset.cs | 2 + osu.Game.Modes.Catch/{ => Mods}/CatchMod.cs | 4 +- .../osu.Game.Modes.Catch.csproj | 6 ++- osu.Game.Modes.Mania/ManiaRuleset.cs | 2 + osu.Game.Modes.Mania/{ => Mods}/ManiaMod.cs | 5 ++- .../osu.Game.Modes.Mania.csproj | 2 +- osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs | 13 +++++++ osu.Game.Modes.Osu/{ => Mods}/OsuMod.cs | 22 +++++++++-- osu.Game.Modes.Osu/OsuAutoReplay.cs | 18 ++++----- osu.Game.Modes.Osu/OsuRuleset.cs | 9 +---- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 3 +- osu.Game.Modes.Taiko/{ => Mods}/TaikoMod.cs | 4 +- osu.Game.Modes.Taiko/TaikoRuleset.cs | 2 + .../osu.Game.Modes.Taiko.csproj | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 7 ++-- osu.Game/Modes/Mods/IApplyableMod.cs | 15 ++++++++ osu.Game/Modes/{ => Mods}/Mod.cs | 38 +++++++++---------- osu.Game/Modes/Mods/ModType.cs | 13 +++++++ osu.Game/Modes/Ruleset.cs | 3 +- osu.Game/Modes/UI/HitRenderer.cs | 30 +++++++++++---- osu.Game/Overlays/Mods/AssistedSection.cs | 2 +- .../Mods/DifficultyIncreaseSection.cs | 2 +- .../Mods/DifficultyReductionSection.cs | 2 +- osu.Game/Overlays/Mods/ModButton.cs | 6 +-- osu.Game/Overlays/Mods/ModSection.cs | 4 +- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 9 +++-- osu.Game/Screens/Play/Player.cs | 9 +---- osu.Game/osu.Game.csproj | 4 +- 29 files changed, 167 insertions(+), 84 deletions(-) rename osu.Game.Modes.Catch/{ => Mods}/CatchMod.cs (91%) rename osu.Game.Modes.Mania/{ => Mods}/ManiaMod.cs (94%) create mode 100644 osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs rename osu.Game.Modes.Osu/{ => Mods}/OsuMod.cs (83%) rename osu.Game.Modes.Taiko/{ => Mods}/TaikoMod.cs (91%) create mode 100644 osu.Game/Modes/Mods/IApplyableMod.cs rename osu.Game/Modes/{ => Mods}/Mod.cs (87%) create mode 100644 osu.Game/Modes/Mods/ModType.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs index f39da70a16..b5a45f237a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs @@ -1,12 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.IO; using osu.Framework.Input.Handlers; using osu.Game.Beatmaps; using osu.Game.Modes; +using osu.Game.Modes.Mods; +using osu.Game.Modes.Osu; +using osu.Game.Modes.Osu.Mods; using osu.Game.Screens.Play; +using System; +using System.IO; namespace osu.Desktop.VisualTests.Tests { @@ -22,9 +25,9 @@ namespace osu.Desktop.VisualTests.Tests protected override Player CreatePlayer(WorkingBeatmap beatmap) { - var player = base.CreatePlayer(beatmap); - player.ReplayInputHandler = Ruleset.GetRuleset(beatmap.PlayMode).CreateAutoplayScore(beatmap.Beatmap)?.Replay?.GetInputHandler(); - return player; + beatmap.Mods.Value = new Mod[] { new OsuModAutoplay() }; + + return base.CreatePlayer(beatmap); } } } diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 31599bbc44..d989db8ddf 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -5,7 +5,9 @@ using OpenTK.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Modes.Catch.Beatmaps; +using osu.Game.Modes.Catch.Mods; using osu.Game.Modes.Catch.UI; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.UI; using osu.Game.Screens.Play; diff --git a/osu.Game.Modes.Catch/CatchMod.cs b/osu.Game.Modes.Catch/Mods/CatchMod.cs similarity index 91% rename from osu.Game.Modes.Catch/CatchMod.cs rename to osu.Game.Modes.Catch/Mods/CatchMod.cs index 07d6d3469e..97e4e58a5d 100644 --- a/osu.Game.Modes.Catch/CatchMod.cs +++ b/osu.Game.Modes.Catch/Mods/CatchMod.cs @@ -1,7 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Modes.Catch +using osu.Game.Modes.Mods; + +namespace osu.Game.Modes.Catch.Mods { public class CatchModNoFail : ModNoFail { diff --git a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj index 10abb312fc..5b815d667c 100644 --- a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj +++ b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj @@ -58,7 +58,7 @@ - + @@ -76,6 +76,10 @@ {C92A607B-1FDD-4954-9F92-03FF547D9080} osu.Game.Modes.Osu + + {F167E17A-7DE6-4AF5-B920-A5112296C695} + osu.Game.Modes.Taiko + {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D} osu.Game diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 015df0c961..0d548eacff 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -4,7 +4,9 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Modes.Mania.Beatmaps; +using osu.Game.Modes.Mania.Mods; using osu.Game.Modes.Mania.UI; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.UI; using osu.Game.Screens.Play; diff --git a/osu.Game.Modes.Mania/ManiaMod.cs b/osu.Game.Modes.Mania/Mods/ManiaMod.cs similarity index 94% rename from osu.Game.Modes.Mania/ManiaMod.cs rename to osu.Game.Modes.Mania/Mods/ManiaMod.cs index d52db2977c..b330680550 100644 --- a/osu.Game.Modes.Mania/ManiaMod.cs +++ b/osu.Game.Modes.Mania/Mods/ManiaMod.cs @@ -1,10 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Game.Graphics; +using osu.Game.Modes.Mods; +using System; -namespace osu.Game.Modes.Mania +namespace osu.Game.Modes.Mania.Mods { public class ManiaModNoFail : ModNoFail { diff --git a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj index 66e46f9e48..c6db2d257f 100644 --- a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj +++ b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj @@ -58,7 +58,7 @@ - + diff --git a/osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs b/osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs new file mode 100644 index 0000000000..e30c2eb0a5 --- /dev/null +++ b/osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Modes.Mods; +using osu.Game.Modes.Osu.Objects; +using osu.Game.Modes.UI; + +namespace osu.Game.Modes.Osu.Mods +{ + internal interface IApplyableOsuMod : IApplyableMod> + { + } +} diff --git a/osu.Game.Modes.Osu/OsuMod.cs b/osu.Game.Modes.Osu/Mods/OsuMod.cs similarity index 83% rename from osu.Game.Modes.Osu/OsuMod.cs rename to osu.Game.Modes.Osu/Mods/OsuMod.cs index 3290eed61a..f7d318a9d4 100644 --- a/osu.Game.Modes.Osu/OsuMod.cs +++ b/osu.Game.Modes.Osu/Mods/OsuMod.cs @@ -1,11 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Graphics; +using osu.Game.Modes.Mods; +using osu.Game.Modes.Osu.Objects; +using osu.Game.Modes.UI; using System; using System.Linq; -using osu.Game.Graphics; -namespace osu.Game.Modes.Osu +namespace osu.Game.Modes.Osu.Mods { public class OsuModNoFail : ModNoFail { @@ -85,9 +88,22 @@ namespace osu.Game.Modes.Osu public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail), typeof(ModAutoplay) }; } - public class OsuModAutoplay : ModAutoplay + public class OsuModAutoplay : ModAutoplay, IApplyableOsuMod { public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray(); + + public void Apply(HitRenderer hitRenderer) + { + Attach(hitRenderer, new Score + { + Replay = new OsuAutoReplay(hitRenderer.Beatmap) + }); + } + + public void Revert(HitRenderer hitRenderer) + { + Detach(hitRenderer); + } } public class OsuModTarget : Mod diff --git a/osu.Game.Modes.Osu/OsuAutoReplay.cs b/osu.Game.Modes.Osu/OsuAutoReplay.cs index 953f131797..3de6106030 100644 --- a/osu.Game.Modes.Osu/OsuAutoReplay.cs +++ b/osu.Game.Modes.Osu/OsuAutoReplay.cs @@ -1,14 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; +using OpenTK; +using osu.Framework.Graphics.Transforms; +using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Modes.Osu.Objects; -using OpenTK; -using System; -using osu.Framework.Graphics.Transforms; using osu.Game.Modes.Osu.Objects.Drawables; -using osu.Framework.MathUtils; +using System; +using System.Collections.Generic; using System.Diagnostics; namespace osu.Game.Modes.Osu @@ -19,9 +19,9 @@ namespace osu.Game.Modes.Osu private const float spin_radius = 50; - private Beatmap beatmap; + private Beatmap beatmap; - public OsuAutoReplay(Beatmap beatmap) + public OsuAutoReplay(Beatmap beatmap) { this.beatmap = beatmap; @@ -86,7 +86,7 @@ namespace osu.Game.Modes.Osu for (int i = 0; i < beatmap.HitObjects.Count; i++) { - OsuHitObject h = (OsuHitObject)beatmap.HitObjects[i]; + OsuHitObject h = beatmap.HitObjects[i]; //if (h.EndTime < InputManager.ReplayStartTime) //{ @@ -98,7 +98,7 @@ namespace osu.Game.Modes.Osu if (DelayedMovements && i > 0) { - OsuHitObject last = (OsuHitObject)beatmap.HitObjects[i - 1]; + OsuHitObject last = beatmap.HitObjects[i - 1]; //Make the cursor stay at a hitObject as long as possible (mainly for autopilot). if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > last.EndTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50) diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index 1b06d704f1..c9d1fa136c 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -4,8 +4,10 @@ using OpenTK.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.Beatmaps; +using osu.Game.Modes.Osu.Mods; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; @@ -101,13 +103,6 @@ namespace osu.Game.Modes.Osu public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap); - public override Score CreateAutoplayScore(Beatmap beatmap) - { - var score = CreateScoreProcessor().GetScore(); - score.Replay = new OsuAutoReplay(beatmap); - return score; - } - protected override PlayMode PlayMode => PlayMode.Osu; public override string Description => "osu!"; diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index c214c881d8..341accbdff 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -44,6 +44,7 @@ + @@ -84,7 +85,7 @@ - + diff --git a/osu.Game.Modes.Taiko/TaikoMod.cs b/osu.Game.Modes.Taiko/Mods/TaikoMod.cs similarity index 91% rename from osu.Game.Modes.Taiko/TaikoMod.cs rename to osu.Game.Modes.Taiko/Mods/TaikoMod.cs index 62db875991..c929ebffdd 100644 --- a/osu.Game.Modes.Taiko/TaikoMod.cs +++ b/osu.Game.Modes.Taiko/Mods/TaikoMod.cs @@ -1,7 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Modes.Taiko +using osu.Game.Modes.Mods; + +namespace osu.Game.Modes.Taiko.Mods { public class TaikoModNoFail : ModNoFail { diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index e8a8dcdd64..8f67ce9e9e 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -4,8 +4,10 @@ using OpenTK.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.Taiko.Beatmaps; +using osu.Game.Modes.Taiko.Mods; using osu.Game.Modes.Taiko.UI; using osu.Game.Modes.UI; using osu.Game.Screens.Play; diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index 0089e84532..5e99d2ba65 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -56,7 +56,7 @@ - + diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 1d4047ea45..16db4fc2a6 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -1,9 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; -using System.IO; using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Graphics.Textures; @@ -11,6 +8,10 @@ using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.IO; using osu.Game.Database; using osu.Game.Modes; +using osu.Game.Modes.Mods; +using System; +using System.Collections.Generic; +using System.IO; namespace osu.Game.Beatmaps { diff --git a/osu.Game/Modes/Mods/IApplyableMod.cs b/osu.Game/Modes/Mods/IApplyableMod.cs new file mode 100644 index 0000000000..6e21aa1095 --- /dev/null +++ b/osu.Game/Modes/Mods/IApplyableMod.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + + +using osu.Game.Modes.UI; + +namespace osu.Game.Modes.Mods +{ + public interface IApplyableMod + where TRenderer : HitRenderer + { + void Apply(TRenderer hitRenderer); + void Revert(TRenderer hitRenderer); + } +} diff --git a/osu.Game/Modes/Mod.cs b/osu.Game/Modes/Mods/Mod.cs similarity index 87% rename from osu.Game/Modes/Mod.cs rename to osu.Game/Modes/Mods/Mod.cs index 167421c23d..870b9d3fc1 100644 --- a/osu.Game/Modes/Mod.cs +++ b/osu.Game/Modes/Mods/Mod.cs @@ -1,11 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Game.Graphics; -using osu.Game.Screens.Play; +using osu.Game.Modes.UI; +using System; -namespace osu.Game.Modes +namespace osu.Game.Modes.Mods { /// /// The base class for gameplay modifiers. @@ -41,12 +41,6 @@ namespace osu.Game.Modes /// The mods this mod cannot be enabled with. /// public virtual Type[] IncompatibleMods => new Type[] { }; - - /// - /// Direct access to the Player before load has run. - /// - /// - public virtual void PlayerLoading(Player player) { } } public class MultiMod : Mod @@ -152,10 +146,23 @@ namespace osu.Game.Modes public override double ScoreMultiplier => 0; public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) }; - public override void PlayerLoading(Player player) + /// + /// Attaches a replay score to a HitRenderer. + /// + /// The HitRenderer to attach the score to. + /// The score to attach. + protected void Attach(HitRenderer hitRenderer, Score score) { - base.PlayerLoading(player); - player.ReplayInputHandler = Ruleset.GetRuleset(player.Beatmap.PlayMode).CreateAutoplayScore(player.Beatmap.Beatmap)?.Replay?.GetInputHandler(); + hitRenderer.InputManager.ReplayInputHandler = score?.Replay?.GetInputHandler(); + } + + /// + /// Detaches the active replay score from a HitRenderer. + /// + /// The HitRenderer to detach the score from. + protected void Detach(HitRenderer hitRenderer) + { + hitRenderer.InputManager.ReplayInputHandler = null; } } @@ -170,11 +177,4 @@ namespace osu.Game.Modes public override string Name => "Cinema"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_cinema; } - - public enum ModType - { - DifficultyReduction, - DifficultyIncrease, - Special, - } } diff --git a/osu.Game/Modes/Mods/ModType.cs b/osu.Game/Modes/Mods/ModType.cs new file mode 100644 index 0000000000..f7d3aea5e2 --- /dev/null +++ b/osu.Game/Modes/Mods/ModType.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + + +namespace osu.Game.Modes.Mods +{ + public enum ModType + { + DifficultyReduction, + DifficultyIncrease, + Special, + } +} diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index 1dcd452541..ab8dda8a2a 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -3,6 +3,7 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.UI; using osu.Game.Screens.Play; @@ -49,8 +50,6 @@ namespace osu.Game.Modes public abstract IEnumerable CreateGameplayKeys(); - public virtual Score CreateAutoplayScore(Beatmap beatmap) => null; - public static Ruleset GetRuleset(PlayMode mode) { Type type; diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index 27d2cf693f..6bdcd15872 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -1,11 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Screens.Play; @@ -22,11 +22,6 @@ namespace osu.Game.Modes.UI internal readonly PlayerInputManager InputManager = new PlayerInputManager(); - /// - /// A function to convert coordinates from gamefield to screen space. - /// - public abstract Func MapPlayfieldToScreenSpace { get; } - /// /// Whether all the HitObjects have been judged. /// @@ -44,14 +39,14 @@ namespace osu.Game.Modes.UI public abstract class HitRenderer : HitRenderer where TObject : HitObject { - public override Func MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace; + public Beatmap Beatmap; + public IEnumerable DrawableObjects => Playfield.HitObjects.Children; protected override Container Content => content; protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue); protected Playfield Playfield; - protected Beatmap Beatmap; private Container content; @@ -59,6 +54,8 @@ namespace osu.Game.Modes.UI { Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap); + applyMods(beatmap.Mods.Value); + RelativeSizeAxes = Axes.Both; InputManager.Add(content = new Container @@ -78,6 +75,9 @@ namespace osu.Game.Modes.UI private void load() { loadObjects(); + + if (InputManager?.ReplayInputHandler != null) + InputManager.ReplayInputHandler.ToScreenSpace = Playfield.ScaledContent.ToScreenSpace; } private void loadObjects() @@ -97,6 +97,20 @@ namespace osu.Game.Modes.UI Playfield.PostProcess(); } + private void applyMods(IEnumerable mods) + { + if (mods == null) + return; + + foreach (var mod in mods) + { + var applyable = mod as IApplyableMod>; + + if (applyable != null) + applyable.Apply(this); + } + } + private void onJudgement(DrawableHitObject o, JudgementInfo j) => TriggerOnJudgement(j); protected abstract DrawableHitObject GetVisualRepresentation(TObject h); diff --git a/osu.Game/Overlays/Mods/AssistedSection.cs b/osu.Game/Overlays/Mods/AssistedSection.cs index 0bb1bc9dff..a1ec7a3fdc 100644 --- a/osu.Game/Overlays/Mods/AssistedSection.cs +++ b/osu.Game/Overlays/Mods/AssistedSection.cs @@ -4,7 +4,7 @@ using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Modes; +using osu.Game.Modes.Mods; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs b/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs index 4dfb0ba6c2..13df5aabfb 100644 --- a/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs +++ b/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs @@ -4,7 +4,7 @@ using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Modes; +using osu.Game.Modes.Mods; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Overlays/Mods/DifficultyReductionSection.cs b/osu.Game/Overlays/Mods/DifficultyReductionSection.cs index d92fb541c3..f8ac4551ef 100644 --- a/osu.Game/Overlays/Mods/DifficultyReductionSection.cs +++ b/osu.Game/Overlays/Mods/DifficultyReductionSection.cs @@ -4,7 +4,7 @@ using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Modes; +using osu.Game.Modes.Mods; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 6e3bafbada..acd5f37092 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Linq; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; @@ -15,8 +13,10 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using osu.Game.Graphics.Sprites; -using osu.Game.Modes; +using osu.Game.Modes.Mods; using osu.Game.Modes.UI; +using System; +using System.Linq; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index c07114919e..489af21ef4 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; @@ -10,7 +9,8 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Input; using osu.Game.Graphics.Sprites; -using osu.Game.Modes; +using osu.Game.Modes.Mods; +using System; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 1be1b9a351..3a685be7fa 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -1,11 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; -using System.Linq; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -13,11 +11,14 @@ 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.Game.Modes.Mods; +using System; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 71ac67601a..1a3a5b7036 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -7,7 +7,6 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Configuration; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transforms; @@ -69,8 +68,6 @@ namespace osu.Game.Screens.Play return; } - Beatmap.Mods.Value.ForEach(m => m.PlayerLoading(this)); - dimLevel = config.GetBindable(OsuConfig.DimLevel); mouseWheelDisabled = config.GetBindable(OsuConfig.MouseDisableWheel); @@ -131,10 +128,7 @@ namespace osu.Game.Screens.Play hitRenderer = ruleset.CreateHitRendererWith(Beatmap); if (ReplayInputHandler != null) - { - ReplayInputHandler.ToScreenSpace = hitRenderer.MapPlayfieldToScreenSpace; hitRenderer.InputManager.ReplayInputHandler = ReplayInputHandler; - } hudOverlay.BindHitRenderer(hitRenderer); @@ -305,7 +299,8 @@ namespace osu.Game.Screens.Play { if (pauseOverlay == null) return false; - if (ReplayInputHandler != null) return false; + if (hitRenderer.InputManager.ReplayInputHandler != null) + return false; if (pauseOverlay.State != Visibility.Visible && !canPause) return true; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3d4a763cb8..46cb593d20 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -91,6 +91,8 @@ + + @@ -306,7 +308,7 @@ - +