1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:42:54 +08:00

Initial commit for the snap colour mod. Implements basic functionality.

This commit is contained in:
John 2023-05-12 19:07:25 -07:00
parent 3e8711ed96
commit e5884016ab
3 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,42 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Screens.Edit;
namespace osu.Game.Rulesets.Osu.Mods
{
/// <summary>
/// Mod that colours <see cref="HitObject"/>s based on the musical division they are on
/// </summary>
public class OsuModSnapColour : ModSnapColour, IApplicableToBeatmap, IApplicableToDrawableHitObject
{
[Resolved]
private OsuColour colours { get; set; } = new OsuColour();
[Resolved(canBeNull: true)]
private IBeatmap currentBeatmap { get; set; }
public void ApplyToBeatmap(IBeatmap beatmap)
{
//Store a reference to the current beatmap to look up the beat divisor when notes are drawn
if (this.currentBeatmap != beatmap)
this.currentBeatmap = beatmap;
}
public void ApplyToDrawableHitObject(DrawableHitObject drawable)
{
if (currentBeatmap.IsNull() || drawable.IsNull()) return;
drawable.OnUpdate += _ =>
drawable.AccentColour.Value = BindableBeatDivisor.GetColourFor(currentBeatmap.ControlPointInfo.GetClosestBeatDivisor(drawable.HitObject.StartTime), colours);
}
}
}

View File

@ -176,6 +176,7 @@ namespace osu.Game.Rulesets.Osu
new OsuModClassic(),
new OsuModRandom(),
new OsuModMirror(),
new OsuModSnapColour(),
new MultiMod(new OsuModAlternate(), new OsuModSingleTap())
};

View File

@ -0,0 +1,19 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation;
namespace osu.Game.Rulesets.Mods
{
/// <summary>
/// Mod that colours hitobjects based on the musical division they are on
/// </summary>
public class ModSnapColour : Mod
{
public override string Name => "Snap Colour";
public override string Acronym => "SC";
public override LocalisableString Description => new LocalisableString("Colours hit objects based on the rhythm.");
public override double ScoreMultiplier => 1;
public override ModType Type => ModType.Conversion;
}
}