Add interface to adjust Beatmaps

This commit is contained in:
Kyle Chang 2018-10-28 01:40:19 -04:00
parent 5b048d9a99
commit df6fc4013a
2 changed files with 36 additions and 2 deletions

View File

@ -0,0 +1,19 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Beatmaps;
namespace osu.Game.Rulesets.Mods
{
/// <summary>
/// Interface for a <see cref="Mod"/> that applies changes to a <see cref="Beatmap"/>.
/// </summary>
public interface IApplicableToBeatmap : IApplicableMod
{
/// <summary>
/// Applies this <see cref="Mod"/> to a <see cref="Beatmap"/>.
/// </summary>
/// <param name="beatmap">The <see cref="Beatmap"/> to apply to.</param>
void ApplyToBeatmap(IBeatmap beatmap);
}
}

View File

@ -238,6 +238,8 @@ protected RulesetContainer(Ruleset ruleset, WorkingBeatmap workingBeatmap)
KeyBindingInputManager = CreateInputManager(); KeyBindingInputManager = CreateInputManager();
KeyBindingInputManager.RelativeSizeAxes = Axes.Both; KeyBindingInputManager.RelativeSizeAxes = Axes.Both;
applyBeatmapMods(Mods);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -255,16 +257,29 @@ private void load(OsuConfigManager config)
KeyBindingInputManager.Add(Cursor); KeyBindingInputManager.Add(Cursor);
// Apply mods // Apply mods
applyMods(Mods, config); applyRulesetMods(Mods, config);
loadObjects(); loadObjects();
} }
/// <summary>
/// Applies the active mods to the Beatmap.
/// </summary>
/// <param name="mods"></param>
private void applyBeatmapMods(IEnumerable<Mod> mods)
{
if (mods == null)
return;
foreach (var mod in mods.OfType<IApplicableToBeatmap>())
mod.ApplyToBeatmap(Beatmap);
}
/// <summary> /// <summary>
/// Applies the active mods to this RulesetContainer. /// Applies the active mods to this RulesetContainer.
/// </summary> /// </summary>
/// <param name="mods"></param> /// <param name="mods"></param>
private void applyMods(IEnumerable<Mod> mods, OsuConfigManager config) private void applyRulesetMods(IEnumerable<Mod> mods, OsuConfigManager config)
{ {
if (mods == null) if (mods == null)
return; return;