mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 22:22:55 +08:00
Merge pull request #12558 from JustusFT/justusft/mania-color-snap
Add snap color option for osu!mania
This commit is contained in:
commit
05e18e3ee3
@ -0,0 +1,80 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Mania.Configuration;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneTimingBasedNoteColouring : OsuTestScene
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private RulesetConfigCache configCache { get; set; }
|
||||||
|
|
||||||
|
private readonly Bindable<bool> configTimingBasedNoteColouring = new Bindable<bool>();
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
const double beat_length = 500;
|
||||||
|
|
||||||
|
var ruleset = new ManiaRuleset();
|
||||||
|
|
||||||
|
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 })
|
||||||
|
{
|
||||||
|
HitObjects =
|
||||||
|
{
|
||||||
|
new Note { StartTime = 0 },
|
||||||
|
new Note { StartTime = beat_length / 16 },
|
||||||
|
new Note { StartTime = beat_length / 12 },
|
||||||
|
new Note { StartTime = beat_length / 8 },
|
||||||
|
new Note { StartTime = beat_length / 6 },
|
||||||
|
new Note { StartTime = beat_length / 4 },
|
||||||
|
new Note { StartTime = beat_length / 3 },
|
||||||
|
new Note { StartTime = beat_length / 2 },
|
||||||
|
new Note { StartTime = beat_length }
|
||||||
|
},
|
||||||
|
ControlPointInfo = new ControlPointInfo(),
|
||||||
|
BeatmapInfo = { Ruleset = ruleset.RulesetInfo },
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var note in beatmap.HitObjects)
|
||||||
|
{
|
||||||
|
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
|
}
|
||||||
|
|
||||||
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint
|
||||||
|
{
|
||||||
|
BeatLength = beat_length
|
||||||
|
});
|
||||||
|
|
||||||
|
Child = new Container
|
||||||
|
{
|
||||||
|
Clock = new FramedClock(new ManualClock()),
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
ruleset.CreateDrawableRulesetWith(beatmap)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
|
||||||
|
config.BindWith(ManiaRulesetSetting.TimingBasedNoteColouring, configTimingBasedNoteColouring);
|
||||||
|
|
||||||
|
AddStep("Enable", () => configTimingBasedNoteColouring.Value = true);
|
||||||
|
AddStep("Disable", () => configTimingBasedNoteColouring.Value = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ namespace osu.Game.Rulesets.Mania.Configuration
|
|||||||
|
|
||||||
SetDefault(ManiaRulesetSetting.ScrollTime, 1500.0, DrawableManiaRuleset.MIN_TIME_RANGE, DrawableManiaRuleset.MAX_TIME_RANGE, 5);
|
SetDefault(ManiaRulesetSetting.ScrollTime, 1500.0, DrawableManiaRuleset.MIN_TIME_RANGE, DrawableManiaRuleset.MAX_TIME_RANGE, 5);
|
||||||
SetDefault(ManiaRulesetSetting.ScrollDirection, ManiaScrollingDirection.Down);
|
SetDefault(ManiaRulesetSetting.ScrollDirection, ManiaScrollingDirection.Down);
|
||||||
|
SetDefault(ManiaRulesetSetting.TimingBasedNoteColouring, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override TrackedSettings CreateTrackedSettings() => new TrackedSettings
|
public override TrackedSettings CreateTrackedSettings() => new TrackedSettings
|
||||||
@ -34,6 +35,7 @@ namespace osu.Game.Rulesets.Mania.Configuration
|
|||||||
public enum ManiaRulesetSetting
|
public enum ManiaRulesetSetting
|
||||||
{
|
{
|
||||||
ScrollTime,
|
ScrollTime,
|
||||||
ScrollDirection
|
ScrollDirection,
|
||||||
|
TimingBasedNoteColouring
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,11 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
Current = config.GetBindable<double>(ManiaRulesetSetting.ScrollTime),
|
Current = config.GetBindable<double>(ManiaRulesetSetting.ScrollTime),
|
||||||
KeyboardStep = 5
|
KeyboardStep = 5
|
||||||
},
|
},
|
||||||
|
new SettingsCheckbox
|
||||||
|
{
|
||||||
|
LabelText = "Timing-based note colouring",
|
||||||
|
Current = config.GetBindable<bool>(ManiaRulesetSetting.TimingBasedNoteColouring),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,13 +2,19 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Mania.Configuration;
|
||||||
using osu.Game.Rulesets.Mania.Skinning.Default;
|
using osu.Game.Rulesets.Mania.Skinning.Default;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -17,6 +23,14 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class DrawableNote : DrawableManiaHitObject<Note>, IKeyBindingHandler<ManiaAction>
|
public class DrawableNote : DrawableManiaHitObject<Note>, IKeyBindingHandler<ManiaAction>
|
||||||
{
|
{
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private IBeatmap beatmap { get; set; }
|
||||||
|
|
||||||
|
private readonly Bindable<bool> configTimingBasedNoteColouring = new Bindable<bool>();
|
||||||
|
|
||||||
protected virtual ManiaSkinComponents Component => ManiaSkinComponents.Note;
|
protected virtual ManiaSkinComponents Component => ManiaSkinComponents.Note;
|
||||||
|
|
||||||
private readonly Drawable headPiece;
|
private readonly Drawable headPiece;
|
||||||
@ -34,6 +48,18 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(ManiaRulesetConfigManager rulesetConfig)
|
||||||
|
{
|
||||||
|
rulesetConfig?.BindWith(ManiaRulesetSetting.TimingBasedNoteColouring, configTimingBasedNoteColouring);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
HitObject.StartTimeBindable.BindValueChanged(_ => updateSnapColour());
|
||||||
|
configTimingBasedNoteColouring.BindValueChanged(_ => updateSnapColour(), true);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> e)
|
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> e)
|
||||||
{
|
{
|
||||||
base.OnDirectionChanged(e);
|
base.OnDirectionChanged(e);
|
||||||
@ -73,5 +99,14 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
public virtual void OnReleased(ManiaAction action)
|
public virtual void OnReleased(ManiaAction action)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSnapColour()
|
||||||
|
{
|
||||||
|
if (beatmap == null) return;
|
||||||
|
|
||||||
|
int snapDivisor = beatmap.ControlPointInfo.GetClosestBeatDivisor(HitObject.StartTime);
|
||||||
|
|
||||||
|
Colour = configTimingBasedNoteColouring.Value ? BindableBeatDivisor.GetColourFor(snapDivisor, colours) : Color4.White;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Lists;
|
using osu.Framework.Lists;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.ControlPoints
|
namespace osu.Game.Beatmaps.ControlPoints
|
||||||
@ -195,7 +196,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
{
|
{
|
||||||
double distanceFromSnap = Math.Abs(time - getClosestSnappedTime(timingPoint, time, divisor));
|
double distanceFromSnap = Math.Abs(time - getClosestSnappedTime(timingPoint, time, divisor));
|
||||||
|
|
||||||
if (distanceFromSnap < closestTime)
|
if (Precision.DefinitelyBigger(closestTime, distanceFromSnap))
|
||||||
{
|
{
|
||||||
closestDivisor = divisor;
|
closestDivisor = divisor;
|
||||||
closestTime = distanceFromSnap;
|
closestTime = distanceFromSnap;
|
||||||
|
@ -85,6 +85,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The beatmap.
|
/// The beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Cached(typeof(IBeatmap))]
|
||||||
public readonly Beatmap<TObject> Beatmap;
|
public readonly Beatmap<TObject> Beatmap;
|
||||||
|
|
||||||
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
|
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
|
||||||
|
Loading…
Reference in New Issue
Block a user