1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00

Initial attempt at making mods apply better.

This commit is contained in:
smoogipooo 2017-03-12 22:13:43 +09:00
parent 64aab090d5
commit c0e29652a6
29 changed files with 167 additions and 84 deletions

View File

@ -1,12 +1,15 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // 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.Framework.Input.Handlers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Modes; 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 osu.Game.Screens.Play;
using System;
using System.IO;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
@ -22,9 +25,9 @@ namespace osu.Desktop.VisualTests.Tests
protected override Player CreatePlayer(WorkingBeatmap beatmap) protected override Player CreatePlayer(WorkingBeatmap beatmap)
{ {
var player = base.CreatePlayer(beatmap); beatmap.Mods.Value = new Mod[] { new OsuModAutoplay() };
player.ReplayInputHandler = Ruleset.GetRuleset(beatmap.PlayMode).CreateAutoplayScore(beatmap.Beatmap)?.Replay?.GetInputHandler();
return player; return base.CreatePlayer(beatmap);
} }
} }
} }

View File

@ -5,7 +5,9 @@ using OpenTK.Input;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes.Catch.Beatmaps; using osu.Game.Modes.Catch.Beatmaps;
using osu.Game.Modes.Catch.Mods;
using osu.Game.Modes.Catch.UI; using osu.Game.Modes.Catch.UI;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.UI; using osu.Game.Modes.UI;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;

View File

@ -1,7 +1,9 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // 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 public class CatchModNoFail : ModNoFail
{ {

View File

@ -58,7 +58,7 @@
<Compile Include="UI\CatchHitRenderer.cs" /> <Compile Include="UI\CatchHitRenderer.cs" />
<Compile Include="UI\CatchPlayfield.cs" /> <Compile Include="UI\CatchPlayfield.cs" />
<Compile Include="CatchRuleset.cs" /> <Compile Include="CatchRuleset.cs" />
<Compile Include="CatchMod.cs" /> <Compile Include="Mods\CatchMod.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\osu.licenseheader"> <None Include="..\osu.licenseheader">
@ -76,6 +76,10 @@
<Project>{C92A607B-1FDD-4954-9F92-03FF547D9080}</Project> <Project>{C92A607B-1FDD-4954-9F92-03FF547D9080}</Project>
<Name>osu.Game.Modes.Osu</Name> <Name>osu.Game.Modes.Osu</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\osu.Game.Modes.Taiko\osu.Game.Modes.Taiko.csproj">
<Project>{F167E17A-7DE6-4AF5-B920-A5112296C695}</Project>
<Name>osu.Game.Modes.Taiko</Name>
</ProjectReference>
<ProjectReference Include="..\osu.Game\osu.Game.csproj"> <ProjectReference Include="..\osu.Game\osu.Game.csproj">
<Project>{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}</Project> <Project>{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}</Project>
<Name>osu.Game</Name> <Name>osu.Game</Name>

View File

@ -4,7 +4,9 @@
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes.Mania.Beatmaps; using osu.Game.Modes.Mania.Beatmaps;
using osu.Game.Modes.Mania.Mods;
using osu.Game.Modes.Mania.UI; using osu.Game.Modes.Mania.UI;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.UI; using osu.Game.Modes.UI;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;

View File

@ -1,10 +1,11 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Game.Graphics; 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 public class ManiaModNoFail : ModNoFail
{ {

View File

@ -58,7 +58,7 @@
<Compile Include="UI\ManiaHitRenderer.cs" /> <Compile Include="UI\ManiaHitRenderer.cs" />
<Compile Include="UI\ManiaPlayfield.cs" /> <Compile Include="UI\ManiaPlayfield.cs" />
<Compile Include="ManiaRuleset.cs" /> <Compile Include="ManiaRuleset.cs" />
<Compile Include="ManiaMod.cs" /> <Compile Include="Mods\ManiaMod.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj"> <ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">

View File

@ -0,0 +1,13 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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<HitRenderer<OsuHitObject>>
{
}
}

View File

@ -1,11 +1,14 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // 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;
using System.Linq; using System.Linq;
using osu.Game.Graphics;
namespace osu.Game.Modes.Osu namespace osu.Game.Modes.Osu.Mods
{ {
public class OsuModNoFail : ModNoFail 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 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 override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
public void Apply(HitRenderer<OsuHitObject> hitRenderer)
{
Attach(hitRenderer, new Score
{
Replay = new OsuAutoReplay(hitRenderer.Beatmap)
});
}
public void Revert(HitRenderer<OsuHitObject> hitRenderer)
{
Detach(hitRenderer);
}
} }
public class OsuModTarget : Mod public class OsuModTarget : Mod

View File

@ -1,14 +1,14 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // 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.Beatmaps;
using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects;
using OpenTK;
using System;
using osu.Framework.Graphics.Transforms;
using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables;
using osu.Framework.MathUtils; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
namespace osu.Game.Modes.Osu namespace osu.Game.Modes.Osu
@ -19,9 +19,9 @@ namespace osu.Game.Modes.Osu
private const float spin_radius = 50; private const float spin_radius = 50;
private Beatmap beatmap; private Beatmap<OsuHitObject> beatmap;
public OsuAutoReplay(Beatmap beatmap) public OsuAutoReplay(Beatmap<OsuHitObject> beatmap)
{ {
this.beatmap = beatmap; this.beatmap = beatmap;
@ -86,7 +86,7 @@ namespace osu.Game.Modes.Osu
for (int i = 0; i < beatmap.HitObjects.Count; i++) 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) //if (h.EndTime < InputManager.ReplayStartTime)
//{ //{
@ -98,7 +98,7 @@ namespace osu.Game.Modes.Osu
if (DelayedMovements && i > 0) 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). //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) if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > last.EndTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50)

View File

@ -4,8 +4,10 @@
using OpenTK.Input; using OpenTK.Input;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Beatmaps; using osu.Game.Modes.Osu.Beatmaps;
using osu.Game.Modes.Osu.Mods;
using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.UI; using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.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 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; protected override PlayMode PlayMode => PlayMode.Osu;
public override string Description => "osu!"; public override string Description => "osu!";

View File

@ -44,6 +44,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Beatmaps\OsuBeatmapConverter.cs" /> <Compile Include="Beatmaps\OsuBeatmapConverter.cs" />
<Compile Include="Mods\IApplyableOsuMod.cs" />
<Compile Include="Objects\BezierApproximator.cs" /> <Compile Include="Objects\BezierApproximator.cs" />
<Compile Include="Objects\CircularArcApproximator.cs" /> <Compile Include="Objects\CircularArcApproximator.cs" />
<Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" /> <Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" />
@ -84,7 +85,7 @@
<Compile Include="Objects\Slider.cs" /> <Compile Include="Objects\Slider.cs" />
<Compile Include="Objects\Spinner.cs" /> <Compile Include="Objects\Spinner.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="OsuMod.cs" /> <Compile Include="Mods\OsuMod.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj"> <ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">

View File

@ -1,7 +1,9 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // 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 public class TaikoModNoFail : ModNoFail
{ {

View File

@ -4,8 +4,10 @@
using OpenTK.Input; using OpenTK.Input;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.Taiko.Beatmaps; using osu.Game.Modes.Taiko.Beatmaps;
using osu.Game.Modes.Taiko.Mods;
using osu.Game.Modes.Taiko.UI; using osu.Game.Modes.Taiko.UI;
using osu.Game.Modes.UI; using osu.Game.Modes.UI;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;

View File

@ -56,7 +56,7 @@
<Compile Include="UI\TaikoHitRenderer.cs" /> <Compile Include="UI\TaikoHitRenderer.cs" />
<Compile Include="UI\TaikoPlayfield.cs" /> <Compile Include="UI\TaikoPlayfield.cs" />
<Compile Include="TaikoRuleset.cs" /> <Compile Include="TaikoRuleset.cs" />
<Compile Include="TaikoMod.cs" /> <Compile Include="Mods\TaikoMod.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\osu.licenseheader"> <None Include="..\osu.licenseheader">

View File

@ -1,9 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // 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.Audio.Track;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
@ -11,6 +8,10 @@ using osu.Game.Beatmaps.Formats;
using osu.Game.Beatmaps.IO; using osu.Game.Beatmaps.IO;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Modes; using osu.Game.Modes;
using osu.Game.Modes.Mods;
using System;
using System.Collections.Generic;
using System.IO;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {

View File

@ -0,0 +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 osu.Game.Modes.UI;
namespace osu.Game.Modes.Mods
{
public interface IApplyableMod<TRenderer>
where TRenderer : HitRenderer
{
void Apply(TRenderer hitRenderer);
void Revert(TRenderer hitRenderer);
}
}

View File

@ -1,11 +1,11 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Game.Graphics; 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
{ {
/// <summary> /// <summary>
/// The base class for gameplay modifiers. /// The base class for gameplay modifiers.
@ -41,12 +41,6 @@ namespace osu.Game.Modes
/// The mods this mod cannot be enabled with. /// The mods this mod cannot be enabled with.
/// </summary> /// </summary>
public virtual Type[] IncompatibleMods => new Type[] { }; public virtual Type[] IncompatibleMods => new Type[] { };
/// <summary>
/// Direct access to the Player before load has run.
/// </summary>
/// <param name="player"></param>
public virtual void PlayerLoading(Player player) { }
} }
public class MultiMod : Mod public class MultiMod : Mod
@ -152,10 +146,23 @@ namespace osu.Game.Modes
public override double ScoreMultiplier => 0; public override double ScoreMultiplier => 0;
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) }; public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) };
public override void PlayerLoading(Player player) /// <summary>
/// Attaches a replay score to a HitRenderer.
/// </summary>
/// <param name="hitRenderer">The HitRenderer to attach the score to.</param>
/// <param name="score">The score to attach.</param>
protected void Attach(HitRenderer hitRenderer, Score score)
{ {
base.PlayerLoading(player); hitRenderer.InputManager.ReplayInputHandler = score?.Replay?.GetInputHandler();
player.ReplayInputHandler = Ruleset.GetRuleset(player.Beatmap.PlayMode).CreateAutoplayScore(player.Beatmap.Beatmap)?.Replay?.GetInputHandler(); }
/// <summary>
/// Detaches the active replay score from a HitRenderer.
/// </summary>
/// <param name="hitRenderer">The HitRenderer to detach the score from.</param>
protected void Detach(HitRenderer hitRenderer)
{
hitRenderer.InputManager.ReplayInputHandler = null;
} }
} }
@ -170,11 +177,4 @@ namespace osu.Game.Modes
public override string Name => "Cinema"; public override string Name => "Cinema";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_cinema; public override FontAwesome Icon => FontAwesome.fa_osu_mod_cinema;
} }
public enum ModType
{
DifficultyReduction,
DifficultyIncrease,
Special,
}
} }

View File

@ -0,0 +1,13 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Modes.Mods
{
public enum ModType
{
DifficultyReduction,
DifficultyIncrease,
Special,
}
}

View File

@ -3,6 +3,7 @@
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.UI; using osu.Game.Modes.UI;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
@ -49,8 +50,6 @@ namespace osu.Game.Modes
public abstract IEnumerable<KeyCounter> CreateGameplayKeys(); public abstract IEnumerable<KeyCounter> CreateGameplayKeys();
public virtual Score CreateAutoplayScore(Beatmap beatmap) => null;
public static Ruleset GetRuleset(PlayMode mode) public static Ruleset GetRuleset(PlayMode mode)
{ {
Type type; Type type;

View File

@ -1,11 +1,11 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
@ -22,11 +22,6 @@ namespace osu.Game.Modes.UI
internal readonly PlayerInputManager InputManager = new PlayerInputManager(); internal readonly PlayerInputManager InputManager = new PlayerInputManager();
/// <summary>
/// A function to convert coordinates from gamefield to screen space.
/// </summary>
public abstract Func<Vector2, Vector2> MapPlayfieldToScreenSpace { get; }
/// <summary> /// <summary>
/// Whether all the HitObjects have been judged. /// Whether all the HitObjects have been judged.
/// </summary> /// </summary>
@ -44,14 +39,14 @@ namespace osu.Game.Modes.UI
public abstract class HitRenderer<TObject> : HitRenderer public abstract class HitRenderer<TObject> : HitRenderer
where TObject : HitObject where TObject : HitObject
{ {
public override Func<Vector2, Vector2> MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace; public Beatmap<TObject> Beatmap;
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children; public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue); protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
protected Playfield<TObject> Playfield; protected Playfield<TObject> Playfield;
protected Beatmap<TObject> Beatmap;
private Container content; private Container content;
@ -59,6 +54,8 @@ namespace osu.Game.Modes.UI
{ {
Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap); Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap);
applyMods(beatmap.Mods.Value);
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
InputManager.Add(content = new Container InputManager.Add(content = new Container
@ -78,6 +75,9 @@ namespace osu.Game.Modes.UI
private void load() private void load()
{ {
loadObjects(); loadObjects();
if (InputManager?.ReplayInputHandler != null)
InputManager.ReplayInputHandler.ToScreenSpace = Playfield.ScaledContent.ToScreenSpace;
} }
private void loadObjects() private void loadObjects()
@ -97,6 +97,20 @@ namespace osu.Game.Modes.UI
Playfield.PostProcess(); Playfield.PostProcess();
} }
private void applyMods(IEnumerable<Mod> mods)
{
if (mods == null)
return;
foreach (var mod in mods)
{
var applyable = mod as IApplyableMod<HitRenderer<TObject>>;
if (applyable != null)
applyable.Apply(this);
}
}
private void onJudgement(DrawableHitObject<TObject> o, JudgementInfo j) => TriggerOnJudgement(j); private void onJudgement(DrawableHitObject<TObject> o, JudgementInfo j) => TriggerOnJudgement(j);
protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h); protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);

View File

@ -4,7 +4,7 @@
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes; using osu.Game.Modes.Mods;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {

View File

@ -4,7 +4,7 @@
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes; using osu.Game.Modes.Mods;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {

View File

@ -4,7 +4,7 @@
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes; using osu.Game.Modes.Mods;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {

View File

@ -1,8 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
@ -15,8 +13,10 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.Transforms;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Modes; using osu.Game.Modes.Mods;
using osu.Game.Modes.UI; using osu.Game.Modes.UI;
using System;
using System.Linq;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
@ -10,7 +9,8 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Modes; using osu.Game.Modes.Mods;
using System;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {

View File

@ -1,11 +1,9 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // 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;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -13,11 +11,14 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.Transforms;
using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Modes; using osu.Game.Modes;
using osu.Game.Modes.Mods;
using System;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {

View File

@ -7,7 +7,6 @@ using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.Transforms;
@ -69,8 +68,6 @@ namespace osu.Game.Screens.Play
return; return;
} }
Beatmap.Mods.Value.ForEach(m => m.PlayerLoading(this));
dimLevel = config.GetBindable<int>(OsuConfig.DimLevel); dimLevel = config.GetBindable<int>(OsuConfig.DimLevel);
mouseWheelDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableWheel); mouseWheelDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableWheel);
@ -131,10 +128,7 @@ namespace osu.Game.Screens.Play
hitRenderer = ruleset.CreateHitRendererWith(Beatmap); hitRenderer = ruleset.CreateHitRendererWith(Beatmap);
if (ReplayInputHandler != null) if (ReplayInputHandler != null)
{
ReplayInputHandler.ToScreenSpace = hitRenderer.MapPlayfieldToScreenSpace;
hitRenderer.InputManager.ReplayInputHandler = ReplayInputHandler; hitRenderer.InputManager.ReplayInputHandler = ReplayInputHandler;
}
hudOverlay.BindHitRenderer(hitRenderer); hudOverlay.BindHitRenderer(hitRenderer);
@ -305,7 +299,8 @@ namespace osu.Game.Screens.Play
{ {
if (pauseOverlay == null) return false; 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; if (pauseOverlay.State != Visibility.Visible && !canPause) return true;

View File

@ -91,6 +91,8 @@
<Compile Include="IO\Legacy\SerializationWriter.cs" /> <Compile Include="IO\Legacy\SerializationWriter.cs" />
<Compile Include="IPC\ScoreIPCChannel.cs" /> <Compile Include="IPC\ScoreIPCChannel.cs" />
<Compile Include="Modes\LegacyReplay.cs" /> <Compile Include="Modes\LegacyReplay.cs" />
<Compile Include="Modes\Mods\IApplyableMod.cs" />
<Compile Include="Modes\Mods\ModType.cs" />
<Compile Include="Modes\Objects\Drawables\IDrawableHitObjectWithProxiedApproach.cs" /> <Compile Include="Modes\Objects\Drawables\IDrawableHitObjectWithProxiedApproach.cs" />
<Compile Include="Modes\Objects\HitObjectParser.cs" /> <Compile Include="Modes\Objects\HitObjectParser.cs" />
<Compile Include="Modes\Objects\NullHitObjectParser.cs" /> <Compile Include="Modes\Objects\NullHitObjectParser.cs" />
@ -306,7 +308,7 @@
<Compile Include="Screens\Play\Pause\RetryButton.cs" /> <Compile Include="Screens\Play\Pause\RetryButton.cs" />
<Compile Include="Screens\Play\Pause\QuitButton.cs" /> <Compile Include="Screens\Play\Pause\QuitButton.cs" />
<Compile Include="Overlays\Mods\ModSelectOverlay.cs" /> <Compile Include="Overlays\Mods\ModSelectOverlay.cs" />
<Compile Include="Modes\Mod.cs" /> <Compile Include="Modes\Mods\Mod.cs" />
<Compile Include="Overlays\Mods\ModButton.cs" /> <Compile Include="Overlays\Mods\ModButton.cs" />
<Compile Include="Modes\UI\ModIcon.cs" /> <Compile Include="Modes\UI\ModIcon.cs" />
<Compile Include="Overlays\Mods\ModSection.cs" /> <Compile Include="Overlays\Mods\ModSection.cs" />