1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-22 00:33:22 +08:00

Add snap color option for osu!mania

This commit is contained in:
Justus Franklin Tumacder 2021-04-24 16:23:52 +08:00
parent 3b77d02752
commit 7e3a611f95
37 changed files with 314 additions and 99 deletions

View File

@ -4,10 +4,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
@ -28,6 +30,9 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
[Cached(typeof(IScrollingInfo))] [Cached(typeof(IScrollingInfo))]
private IScrollingInfo scrollingInfo; private IScrollingInfo scrollingInfo;
[Cached]
protected readonly Bindable<ManiaColourCode> configColourCode = new Bindable<ManiaColourCode>();
protected ManiaPlacementBlueprintTestScene() protected ManiaPlacementBlueprintTestScene()
{ {
scrollingInfo = ((ScrollingTestContainer)HitObjectContainer).ScrollingInfo; scrollingInfo = ((ScrollingTestContainer)HitObjectContainer).ScrollingInfo;
@ -41,6 +46,13 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
}); });
} }
[BackgroundDependencyLoader]
private void load(RulesetConfigCache configCache)
{
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode);
}
protected override SnapResult SnapForBlueprint(PlacementBlueprint blueprint) protected override SnapResult SnapForBlueprint(PlacementBlueprint blueprint)
{ {
var time = column.TimeAtScreenSpacePosition(InputManager.CurrentState.Mouse.Position); var time = column.TimeAtScreenSpacePosition(InputManager.CurrentState.Mouse.Position);

View File

@ -2,8 +2,10 @@
// 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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK.Graphics; using osuTK.Graphics;
@ -15,6 +17,9 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
[Cached(Type = typeof(IAdjustableClock))] [Cached(Type = typeof(IAdjustableClock))]
private readonly IAdjustableClock clock = new StopwatchClock(); private readonly IAdjustableClock clock = new StopwatchClock();
[Cached]
protected readonly Bindable<ManiaColourCode> configColourCode = new Bindable<ManiaColourCode>();
protected ManiaSelectionBlueprintTestScene() protected ManiaSelectionBlueprintTestScene()
{ {
Add(new Column(0) Add(new Column(0)
@ -26,6 +31,13 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
}); });
} }
[BackgroundDependencyLoader]
private void load(RulesetConfigCache configCache)
{
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode);
}
public ManiaPlayfield Playfield => null; public ManiaPlayfield Playfield => null;
} }
} }

View File

@ -13,6 +13,6 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
public class TestSceneHoldNotePlacementBlueprint : ManiaPlacementBlueprintTestScene public class TestSceneHoldNotePlacementBlueprint : ManiaPlacementBlueprintTestScene
{ {
protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableHoldNote((HoldNote)hitObject); protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableHoldNote((HoldNote)hitObject);
protected override PlacementBlueprint CreateBlueprint() => new HoldNotePlacementBlueprint(); protected override PlacementBlueprint CreateBlueprint() => new HoldNotePlacementBlueprint(null);
} }
} }

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
public TestSceneHoldNoteSelectionBlueprint() public TestSceneHoldNoteSelectionBlueprint()
{ {
var holdNote = new HoldNote { Column = 0, Duration = 1000 }; var holdNote = new HoldNote(null) { Column = 0, Duration = 1000 };
holdNote.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); holdNote.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
base.Content.Child = content = new ScrollingTestContainer(ScrollingDirection.Down) base.Content.Child = content = new ScrollingTestContainer(ScrollingDirection.Down)

View File

@ -159,7 +159,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
AddStep("setup beatmap", () => AddStep("setup beatmap", () =>
{ {
composer.EditorBeatmap.Clear(); composer.EditorBeatmap.Clear();
composer.EditorBeatmap.Add(new HoldNote composer.EditorBeatmap.Add(new HoldNote(Beatmap.Value.Beatmap)
{ {
Column = 1, Column = 1,
EndTime = 200 EndTime = 200
@ -201,9 +201,10 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
public TestComposer() public TestComposer()
{ {
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 4 });
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
EditorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 })) EditorBeatmap = new EditorBeatmap(beatmap)
{ {
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo } BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo }
}, },
@ -211,7 +212,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
}; };
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
EditorBeatmap.Add(new Note { StartTime = 125 * i }); EditorBeatmap.Add(new Note(beatmap) { StartTime = 125 * i });
} }
} }
} }

View File

@ -55,6 +55,6 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
private Note getNote() => this.ChildrenOfType<DrawableNote>().FirstOrDefault()?.HitObject; private Note getNote() => this.ChildrenOfType<DrawableNote>().FirstOrDefault()?.HitObject;
protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableNote((Note)hitObject); protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableNote((Note)hitObject);
protected override PlacementBlueprint CreateBlueprint() => new NotePlacementBlueprint(); protected override PlacementBlueprint CreateBlueprint() => new NotePlacementBlueprint(null);
} }
} }

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
public TestSceneNoteSelectionBlueprint() public TestSceneNoteSelectionBlueprint()
{ {
var note = new Note { Column = 0 }; var note = new Note(null) { Column = 0 };
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
DrawableNote drawableObject; DrawableNote drawableObject;

View File

@ -1,15 +1,21 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Mania.Tests namespace osu.Game.Rulesets.Mania.Tests
{ {
public abstract class ManiaInputTestScene : OsuTestScene public abstract class ManiaInputTestScene : OsuTestScene
{ {
[Cached]
protected readonly Bindable<ManiaColourCode> configColourCode = new Bindable<ManiaColourCode>();
private readonly Container<Drawable> content; private readonly Container<Drawable> content;
protected override Container<Drawable> Content => content ?? base.Content; protected override Container<Drawable> Content => content ?? base.Content;
@ -18,6 +24,13 @@ namespace osu.Game.Rulesets.Mania.Tests
base.Content.Add(content = new LocalInputManager(keys)); base.Content.Add(content = new LocalInputManager(keys));
} }
[BackgroundDependencyLoader]
private void load(RulesetConfigCache configCache)
{
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode);
}
private class LocalInputManager : ManiaInputManager private class LocalInputManager : ManiaInputManager
{ {
public LocalInputManager(int variant) public LocalInputManager(int variant)

View File

@ -19,10 +19,10 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
[TestCase(false)] [TestCase(false)]
[TestCase(true)] [TestCase(true)]
public void TestNote(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new Note { StartTime = 1000 }), shouldMiss); public void TestNote(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new Note(Beatmap.Value.Beatmap) { StartTime = 1000 }), shouldMiss);
[TestCase(false)] [TestCase(false)]
[TestCase(true)] [TestCase(true)]
public void TestHoldNote(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new HoldNote { StartTime = 1000, EndTime = 3000 }), shouldMiss); public void TestHoldNote(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new HoldNote(Beatmap.Value.Beatmap) { StartTime = 1000, EndTime = 3000 }), shouldMiss);
} }
} }

View File

@ -7,6 +7,8 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Rulesets.UI.Scrolling.Algorithms; using osu.Game.Rulesets.UI.Scrolling.Algorithms;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
@ -24,6 +26,9 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
[Cached(Type = typeof(IScrollingInfo))] [Cached(Type = typeof(IScrollingInfo))]
private readonly TestScrollingInfo scrollingInfo = new TestScrollingInfo(); private readonly TestScrollingInfo scrollingInfo = new TestScrollingInfo();
[Cached]
protected readonly Bindable<ManiaColourCode> configColourCode = new Bindable<ManiaColourCode>();
protected override Ruleset CreateRulesetForSkinProvider() => new ManiaRuleset(); protected override Ruleset CreateRulesetForSkinProvider() => new ManiaRuleset();
protected ManiaSkinnableTestScene() protected ManiaSkinnableTestScene()
@ -38,6 +43,13 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
}); });
} }
[BackgroundDependencyLoader]
private void load(RulesetConfigCache configCache)
{
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode);
}
[Test] [Test]
public void TestScrollingDown() public void TestScrollingDown()
{ {

View File

@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
protected override DrawableManiaHitObject CreateHitObject() protected override DrawableManiaHitObject CreateHitObject()
{ {
var note = new HoldNote { Duration = 1000 }; var note = new HoldNote(Beatmap.Value.Beatmap) { Duration = 1000 };
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
return new DrawableHoldNote(note); return new DrawableHoldNote(note);

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
{ {
protected override DrawableManiaHitObject CreateHitObject() protected override DrawableManiaHitObject CreateHitObject()
{ {
var note = new Note(); var note = new Note(Beatmap.Value.Beatmap);
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
return new DrawableNote(note); return new DrawableNote(note);

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Mania.Tests
// | | // | |
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 }); var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 });
beatmap.HitObjects.Add(new Note { StartTime = 1000 }); beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 1000 });
var generated = new ManiaAutoGenerator(beatmap).Generate(); var generated = new ManiaAutoGenerator(beatmap).Generate();
@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Mania.Tests
// | | // | |
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 }); var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 });
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 }); beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 1000, Duration = 2000 });
var generated = new ManiaAutoGenerator(beatmap).Generate(); var generated = new ManiaAutoGenerator(beatmap).Generate();
@ -69,8 +69,8 @@ namespace osu.Game.Rulesets.Mania.Tests
// | | | // | | |
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 }); var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
beatmap.HitObjects.Add(new Note { StartTime = 1000 }); beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 1000 });
beatmap.HitObjects.Add(new Note { StartTime = 1000, Column = 1 }); beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 1000, Column = 1 });
var generated = new ManiaAutoGenerator(beatmap).Generate(); var generated = new ManiaAutoGenerator(beatmap).Generate();
@ -91,8 +91,8 @@ namespace osu.Game.Rulesets.Mania.Tests
// | | | // | | |
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 }); var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 }); beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 1000, Duration = 2000 });
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000, Column = 1 }); beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 1000, Duration = 2000, Column = 1 });
var generated = new ManiaAutoGenerator(beatmap).Generate(); var generated = new ManiaAutoGenerator(beatmap).Generate();
@ -114,8 +114,8 @@ namespace osu.Game.Rulesets.Mania.Tests
// | | | // | | |
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 }); var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
beatmap.HitObjects.Add(new Note { StartTime = 1000 }); beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 1000 });
beatmap.HitObjects.Add(new Note { StartTime = 2000, Column = 1 }); beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 2000, Column = 1 });
var generated = new ManiaAutoGenerator(beatmap).Generate(); var generated = new ManiaAutoGenerator(beatmap).Generate();
@ -141,8 +141,8 @@ namespace osu.Game.Rulesets.Mania.Tests
// | | | // | | |
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 }); var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 }); beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 1000, Duration = 2000 });
beatmap.HitObjects.Add(new HoldNote { StartTime = 2000, Duration = 2000, Column = 1 }); beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 2000, Duration = 2000, Column = 1 });
var generated = new ManiaAutoGenerator(beatmap).Generate(); var generated = new ManiaAutoGenerator(beatmap).Generate();
@ -168,8 +168,8 @@ namespace osu.Game.Rulesets.Mania.Tests
// | | | // | | |
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 }); var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 }); beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 1000, Duration = 2000 });
beatmap.HitObjects.Add(new Note { StartTime = 3000, Column = 1 }); beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 3000, Column = 1 });
var generated = new ManiaAutoGenerator(beatmap).Generate(); var generated = new ManiaAutoGenerator(beatmap).Generate();

View File

@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Mania.Tests
{ {
for (int i = 0; i < columns.Count; i++) for (int i = 0; i < columns.Count; i++)
{ {
var obj = new Note { Column = i, StartTime = Time.Current + 2000 }; var obj = new Note(null) { Column = i, StartTime = Time.Current + 2000 };
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
columns[i].Add(new DrawableNote(obj)); columns[i].Add(new DrawableNote(obj));
@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Tests
{ {
for (int i = 0; i < columns.Count; i++) for (int i = 0; i < columns.Count; i++)
{ {
var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 }; var obj = new HoldNote(null) { Column = i, StartTime = Time.Current + 2000, Duration = 500 };
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
columns[i].Add(new DrawableHoldNote(obj)); columns[i].Add(new DrawableHoldNote(obj));

View File

@ -249,21 +249,6 @@ namespace osu.Game.Rulesets.Mania.Tests
var beatmap = new Beatmap<ManiaHitObject> var beatmap = new Beatmap<ManiaHitObject>
{ {
HitObjects =
{
new HoldNote
{
StartTime = 1000,
Duration = 500,
Column = 0,
},
new HoldNote
{
StartTime = 1000 + 500 + windows.WindowFor(HitResult.Miss) + 10,
Duration = 500,
Column = 0,
},
},
BeatmapInfo = BeatmapInfo =
{ {
BaseDifficulty = new BeatmapDifficulty BaseDifficulty = new BeatmapDifficulty
@ -274,6 +259,20 @@ namespace osu.Game.Rulesets.Mania.Tests
Ruleset = new ManiaRuleset().RulesetInfo Ruleset = new ManiaRuleset().RulesetInfo
}, },
}; };
beatmap.HitObjects = new List<ManiaHitObject> {
new HoldNote(beatmap)
{
StartTime = 1000,
Duration = 500,
Column = 0,
},
new HoldNote(beatmap)
{
StartTime = 1000 + 500 + windows.WindowFor(HitResult.Miss) + 10,
Duration = 500,
Column = 0,
},
};
performTest(new List<ReplayFrame> performTest(new List<ReplayFrame>
{ {
@ -297,21 +296,21 @@ namespace osu.Game.Rulesets.Mania.Tests
var beatmap = new Beatmap<ManiaHitObject> var beatmap = new Beatmap<ManiaHitObject>
{ {
HitObjects =
{
new HoldNote
{
StartTime = time_head,
Duration = time_tail - time_head,
Column = 0,
}
},
BeatmapInfo = BeatmapInfo =
{ {
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = tick_rate }, BaseDifficulty = new BeatmapDifficulty { SliderTickRate = tick_rate },
Ruleset = new ManiaRuleset().RulesetInfo Ruleset = new ManiaRuleset().RulesetInfo
}, },
}; };
beatmap.HitObjects = new List<ManiaHitObject>
{
new HoldNote(beatmap)
{
StartTime = time_head,
Duration = time_tail - time_head,
Column = 0,
}
};
performTest(new List<ReplayFrame> performTest(new List<ReplayFrame>
{ {
@ -329,17 +328,17 @@ namespace osu.Game.Rulesets.Mania.Tests
{ {
var beatmap = new Beatmap<ManiaHitObject> var beatmap = new Beatmap<ManiaHitObject>
{ {
HitObjects = BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
};
beatmap.HitObjects = new List<ManiaHitObject>
{ {
new HoldNote new HoldNote(beatmap)
{ {
StartTime = 1000, StartTime = 1000,
Duration = 0, Duration = 0,
Column = 0, Column = 0,
}, },
}, };
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
};
performTest(new List<ReplayFrame> performTest(new List<ReplayFrame>
{ {
@ -374,21 +373,21 @@ namespace osu.Game.Rulesets.Mania.Tests
{ {
beatmap = new Beatmap<ManiaHitObject> beatmap = new Beatmap<ManiaHitObject>
{ {
HitObjects =
{
new HoldNote
{
StartTime = time_head,
Duration = time_tail - time_head,
Column = 0,
}
},
BeatmapInfo = BeatmapInfo =
{ {
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 4 }, BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Ruleset = new ManiaRuleset().RulesetInfo Ruleset = new ManiaRuleset().RulesetInfo
}, },
}; };
beatmap.HitObjects = new List<ManiaHitObject>
{
new HoldNote(beatmap)
{
StartTime = time_head,
Duration = time_tail - time_head,
Column = 0,
}
};
beatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 0.1f }); beatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 0.1f });
} }

View File

@ -15,8 +15,10 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
@ -29,6 +31,10 @@ namespace osu.Game.Rulesets.Mania.Tests
[TestFixture] [TestFixture]
public class TestSceneNotes : OsuTestScene public class TestSceneNotes : OsuTestScene
{ {
[Cached]
protected readonly Bindable<ManiaColourCode> configColourCode = new Bindable<ManiaColourCode>();
[Test] [Test]
public void TestVariousNotes() public void TestVariousNotes()
{ {
@ -63,9 +69,16 @@ namespace osu.Game.Rulesets.Mania.Tests
AddAssert("hold note 2 facing upwards", () => verifyAnchors(holdNote2, Anchor.y0)); AddAssert("hold note 2 facing upwards", () => verifyAnchors(holdNote2, Anchor.y0));
} }
[BackgroundDependencyLoader]
private void load(RulesetConfigCache configCache)
{
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode);
}
private Drawable createNoteDisplay(ScrollingDirection direction, int identifier, out DrawableNote hitObject) private Drawable createNoteDisplay(ScrollingDirection direction, int identifier, out DrawableNote hitObject)
{ {
var note = new Note { StartTime = 0 }; var note = new Note(null) { StartTime = 0 };
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
return new ScrollingTestContainer(direction) return new ScrollingTestContainer(direction)
@ -80,7 +93,7 @@ namespace osu.Game.Rulesets.Mania.Tests
private Drawable createHoldNoteDisplay(ScrollingDirection direction, int identifier, out DrawableHoldNote hitObject) private Drawable createHoldNoteDisplay(ScrollingDirection direction, int identifier, out DrawableHoldNote hitObject)
{ {
var note = new HoldNote { StartTime = 0, Duration = 5000 }; var note = new HoldNote(null) { StartTime = 0, Duration = 5000 };
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
return new ScrollingTestContainer(direction) return new ScrollingTestContainer(direction)

View File

@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Mania.Tests
{ {
double time = 1000 + i * 100; double time = 1000 + i * 100;
objects.Add(new Note { StartTime = time }); objects.Add(new Note(Beatmap.Value.Beatmap) { StartTime = time });
// don't hit the first note // don't hit the first note
if (i > 0) if (i > 0)
@ -60,12 +60,12 @@ namespace osu.Game.Rulesets.Mania.Tests
{ {
var objects = new List<ManiaHitObject> var objects = new List<ManiaHitObject>
{ {
new HoldNote new HoldNote(Beatmap.Value.Beatmap)
{ {
StartTime = 1000, StartTime = 1000,
EndTime = 1010, EndTime = 1010,
}, },
new HoldNote new HoldNote(Beatmap.Value.Beatmap)
{ {
StartTime = 1020, StartTime = 1020,
EndTime = 1030 EndTime = 1030
@ -83,12 +83,12 @@ namespace osu.Game.Rulesets.Mania.Tests
{ {
var objects = new List<ManiaHitObject> var objects = new List<ManiaHitObject>
{ {
new HoldNote new HoldNote(Beatmap.Value.Beatmap)
{ {
StartTime = 1000, StartTime = 1000,
EndTime = 1010, EndTime = 1010,
}, },
new HoldNote new HoldNote(Beatmap.Value.Beatmap)
{ {
StartTime = 1020, StartTime = 1020,
EndTime = 1030 EndTime = 1030

View File

@ -91,7 +91,7 @@ namespace osu.Game.Rulesets.Mania.Tests
{ {
for (int i = 0; i < stage.Columns.Count; i++) for (int i = 0; i < stage.Columns.Count; i++)
{ {
var obj = new Note { Column = i, StartTime = Time.Current + 2000 }; var obj = new Note(null) { Column = i, StartTime = Time.Current + 2000 };
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
stage.Add(new DrawableNote(obj)); stage.Add(new DrawableNote(obj));
@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Mania.Tests
{ {
for (int i = 0; i < stage.Columns.Count; i++) for (int i = 0; i < stage.Columns.Count; i++)
{ {
var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 }; var obj = new HoldNote(null) { Column = i, StartTime = Time.Current + 2000, Duration = 500 };
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
stage.Add(new DrawableHoldNote(obj)); stage.Add(new DrawableHoldNote(obj));

View File

@ -247,7 +247,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
if (HitObject is IHasDuration endTimeData) if (HitObject is IHasDuration endTimeData)
{ {
pattern.Add(new HoldNote pattern.Add(new HoldNote(Beatmap)
{ {
StartTime = HitObject.StartTime, StartTime = HitObject.StartTime,
Duration = endTimeData.Duration, Duration = endTimeData.Duration,
@ -258,7 +258,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
} }
else if (HitObject is IHasXPosition) else if (HitObject is IHasXPosition)
{ {
pattern.Add(new Note pattern.Add(new Note(Beatmap)
{ {
StartTime = HitObject.StartTime, StartTime = HitObject.StartTime,
Samples = HitObject.Samples, Samples = HitObject.Samples,

View File

@ -512,7 +512,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
if (startTime == endTime) if (startTime == endTime)
{ {
newObject = new Note newObject = new Note(Beatmap)
{ {
StartTime = startTime, StartTime = startTime,
Samples = sampleInfoListAt(startTime), Samples = sampleInfoListAt(startTime),
@ -521,7 +521,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
} }
else else
{ {
newObject = new HoldNote newObject = new HoldNote(Beatmap)
{ {
StartTime = startTime, StartTime = startTime,
Duration = endTime - startTime, Duration = endTime - startTime,

View File

@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
if (holdNote) if (holdNote)
{ {
newObject = new HoldNote newObject = new HoldNote(Beatmap)
{ {
StartTime = HitObject.StartTime, StartTime = HitObject.StartTime,
Duration = endTime - HitObject.StartTime, Duration = endTime - HitObject.StartTime,
@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
} }
else else
{ {
newObject = new Note newObject = new Note(Beatmap)
{ {
StartTime = HitObject.StartTime, StartTime = HitObject.StartTime,
Samples = HitObject.Samples, Samples = HitObject.Samples,

View File

@ -441,7 +441,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
/// <param name="column">The column to add the note to.</param> /// <param name="column">The column to add the note to.</param>
private void addToPattern(Pattern pattern, int column) private void addToPattern(Pattern pattern, int column)
{ {
pattern.Add(new Note pattern.Add(new Note(Beatmap)
{ {
StartTime = HitObject.StartTime, StartTime = HitObject.StartTime,
Samples = HitObject.Samples, Samples = HitObject.Samples,

View File

@ -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.ColourCode, ManiaColourCode.Off);
} }
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,
ColourCode
} }
} }

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components; using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
@ -23,8 +24,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
[Resolved] [Resolved]
private IScrollingInfo scrollingInfo { get; set; } private IScrollingInfo scrollingInfo { get; set; }
public HoldNotePlacementBlueprint() public HoldNotePlacementBlueprint(IBeatmap beatmap)
: base(new HoldNote()) : base(new HoldNote(beatmap))
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;

View File

@ -3,6 +3,7 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components; using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
@ -14,8 +15,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{ {
private readonly EditNotePiece piece; private readonly EditNotePiece piece;
public NotePlacementBlueprint() public NotePlacementBlueprint(IBeatmap beatmap)
: base(new Note()) : base(new Note(beatmap))
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;

View File

@ -5,19 +5,22 @@ using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Edit.Blueprints; using osu.Game.Rulesets.Mania.Edit.Blueprints;
namespace osu.Game.Rulesets.Mania.Edit namespace osu.Game.Rulesets.Mania.Edit
{ {
public class HoldNoteCompositionTool : HitObjectCompositionTool public class HoldNoteCompositionTool : HitObjectCompositionTool
{ {
public HoldNoteCompositionTool() private ManiaBeatmap Beatmap;
public HoldNoteCompositionTool(ManiaBeatmap beatmap)
: base("Hold") : base("Hold")
{ {
Beatmap = beatmap;
} }
public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders); public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders);
public override PlacementBlueprint CreatePlacementBlueprint() => new HoldNotePlacementBlueprint(); public override PlacementBlueprint CreatePlacementBlueprint() => new HoldNotePlacementBlueprint(Beatmap);
} }
} }

View File

@ -93,8 +93,8 @@ namespace osu.Game.Rulesets.Mania.Edit
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[] protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
{ {
new NoteCompositionTool(), new NoteCompositionTool(drawableRuleset.Beatmap),
new HoldNoteCompositionTool() new HoldNoteCompositionTool(drawableRuleset.Beatmap)
}; };
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()

View File

@ -5,6 +5,7 @@ using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Edit.Blueprints; using osu.Game.Rulesets.Mania.Edit.Blueprints;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
@ -12,13 +13,16 @@ namespace osu.Game.Rulesets.Mania.Edit
{ {
public class NoteCompositionTool : HitObjectCompositionTool public class NoteCompositionTool : HitObjectCompositionTool
{ {
public NoteCompositionTool() private ManiaBeatmap Beatmap;
public NoteCompositionTool(ManiaBeatmap beatmap)
: base(nameof(Note)) : base(nameof(Note))
{ {
Beatmap = beatmap;
} }
public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles); public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles);
public override PlacementBlueprint CreatePlacementBlueprint() => new NotePlacementBlueprint(); public override PlacementBlueprint CreatePlacementBlueprint() => new NotePlacementBlueprint(Beatmap);
} }
} }

View File

@ -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 SettingsEnumDropdown<ManiaColourCode>
{
LabelText = "Colour-coded notes",
Current = config.GetBindable<ManiaColourCode>(ManiaRulesetSetting.ColourCode),
}
}; };
} }

View File

@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Mania.Mods
// Decrease the duration by at most a 1/4 beat to ensure there's no instantaneous notes. // Decrease the duration by at most a 1/4 beat to ensure there's no instantaneous notes.
duration = Math.Max(duration / 2, duration - beatLength / 4); duration = Math.Max(duration / 2, duration - beatLength / 4);
newColumnObjects.Add(new HoldNote newColumnObjects.Add(new HoldNote(maniaBeatmap)
{ {
Column = column.Key, Column = column.Key,
StartTime = locations[i].startTime, StartTime = locations[i].startTime,

View File

@ -2,12 +2,16 @@
// 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.Graphics;
using osu.Game.Rulesets.Mania.Skinning.Default; using osu.Game.Rulesets.Mania.Skinning.Default;
using osu.Game.Rulesets.Mania.UI;
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;
namespace osu.Game.Rulesets.Mania.Objects.Drawables namespace osu.Game.Rulesets.Mania.Objects.Drawables
@ -17,6 +21,12 @@ 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]
private Bindable<ManiaColourCode> configColourCode { get; set; }
protected virtual ManiaSkinComponents Component => ManiaSkinComponents.Note; protected virtual ManiaSkinComponents Component => ManiaSkinComponents.Note;
private readonly Drawable headPiece; private readonly Drawable headPiece;
@ -34,6 +44,26 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
}); });
} }
protected override void LoadComplete()
{
base.LoadComplete();
HitObject.SnapBindable.BindValueChanged(snap => UpdateSnapColour(configColourCode.Value, snap.NewValue), true);
configColourCode.BindValueChanged(colourCode => UpdateSnapColour(colourCode.NewValue, HitObject.Snap));
}
private void UpdateSnapColour(ManiaColourCode colourCode, int snap)
{
if (colourCode == ManiaColourCode.On)
{
Colour = BindableBeatDivisor.GetColourFor(HitObject.Snap, colours);
}
else
{
Colour = Colour4.White;
}
}
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> e) protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> e)
{ {
base.OnDirectionChanged(e); base.OnDirectionChanged(e);

View File

@ -17,6 +17,8 @@ namespace osu.Game.Rulesets.Mania.Objects
/// </summary> /// </summary>
public class HoldNote : ManiaHitObject, IHasDuration public class HoldNote : ManiaHitObject, IHasDuration
{ {
public IBeatmap Beatmap;
public double EndTime public double EndTime
{ {
get => StartTime + Duration; get => StartTime + Duration;
@ -84,6 +86,11 @@ namespace osu.Game.Rulesets.Mania.Objects
/// </summary> /// </summary>
private double tickSpacing = 50; private double tickSpacing = 50;
public HoldNote(IBeatmap beatmap) : base()
{
Beatmap = beatmap;
}
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaultsToSelf(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
@ -98,14 +105,14 @@ namespace osu.Game.Rulesets.Mania.Objects
createTicks(cancellationToken); createTicks(cancellationToken);
AddNested(Head = new Note AddNested(Head = new Note(Beatmap)
{ {
StartTime = StartTime, StartTime = StartTime,
Column = Column, Column = Column,
Samples = GetNodeSamples(0), Samples = GetNodeSamples(0),
}); });
AddNested(Tail = new TailNote AddNested(Tail = new TailNote(Beatmap)
{ {
StartTime = EndTime, StartTime = EndTime,
Column = Column, Column = Column,

View File

@ -1,6 +1,11 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Bindables;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Judgements;
@ -12,5 +17,79 @@ namespace osu.Game.Rulesets.Mania.Objects
public class Note : ManiaHitObject public class Note : ManiaHitObject
{ {
public override Judgement CreateJudgement() => new ManiaJudgement(); public override Judgement CreateJudgement() => new ManiaJudgement();
private IBeatmap Beatmap;
public readonly Bindable<int> SnapBindable = new Bindable<int>();
public int Snap
{
get => SnapBindable.Value;
set => SnapBindable.Value = value;
}
public Note(IBeatmap beatmap) : base()
{
Beatmap = beatmap;
this.StartTimeBindable.BindValueChanged(_ => SnapToBeatmap(), true);
}
private void SnapToBeatmap()
{
if (Beatmap != null)
{
TimingControlPoint currentTimingPoint = Beatmap.ControlPointInfo.TimingPointAt(StartTime);
int timeSignature = (int)currentTimingPoint.TimeSignature;
double startTime = currentTimingPoint.Time;
double secondsPerFourCounts = currentTimingPoint.BeatLength * 4;
double offset = startTime % secondsPerFourCounts;
double snapResult = StartTime % secondsPerFourCounts - offset;
if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 4.0))
{
Snap = 1;
}
else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 8.0))
{
Snap = 2;
}
else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 12.0))
{
Snap = 3;
}
else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 16.0))
{
Snap = 4;
}
else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 24.0))
{
Snap = 6;
}
else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 32.0))
{
Snap = 8;
}
else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 48.0))
{
Snap = 12;
}
else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 64.0))
{
Snap = 16;
}
else
{
Snap = 0;
}
}
}
private const double LENIENCY_MS = 1.0;
private static bool AlmostDivisibleBy(double dividend, double divisor)
{
double remainder = Math.Abs(dividend) % divisor;
return Precision.AlmostEquals(remainder, 0, LENIENCY_MS) || Precision.AlmostEquals(remainder - divisor, 0, LENIENCY_MS);
}
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Judgements;
@ -8,6 +9,10 @@ namespace osu.Game.Rulesets.Mania.Objects
{ {
public class TailNote : Note public class TailNote : Note
{ {
public TailNote(IBeatmap beatmap) : base(beatmap)
{
}
public override Judgement CreateJudgement() => new ManiaJudgement(); public override Judgement CreateJudgement() => new ManiaJudgement();
} }
} }

View File

@ -51,6 +51,9 @@ namespace osu.Game.Rulesets.Mania.UI
protected new ManiaRulesetConfigManager Config => (ManiaRulesetConfigManager)base.Config; protected new ManiaRulesetConfigManager Config => (ManiaRulesetConfigManager)base.Config;
[Cached]
protected readonly Bindable<ManiaColourCode> configColourCode = new Bindable<ManiaColourCode>();
public ScrollVisualisationMethod ScrollMethod public ScrollVisualisationMethod ScrollMethod
{ {
get => scrollMethod; get => scrollMethod;
@ -104,6 +107,8 @@ namespace osu.Game.Rulesets.Mania.UI
configDirection.BindValueChanged(direction => Direction.Value = (ScrollingDirection)direction.NewValue, true); configDirection.BindValueChanged(direction => Direction.Value = (ScrollingDirection)direction.NewValue, true);
Config.BindWith(ManiaRulesetSetting.ScrollTime, configTimeRange); Config.BindWith(ManiaRulesetSetting.ScrollTime, configTimeRange);
Config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode);
} }
protected override void AdjustScrollSpeed(int amount) protected override void AdjustScrollSpeed(int amount)

View File

@ -0,0 +1,11 @@
// 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.
namespace osu.Game.Rulesets.Mania.UI
{
public enum ManiaColourCode
{
Off,
On
}
}

View File

@ -140,12 +140,12 @@ namespace osu.Game.Tests.Visual.Collections
AddStep("add dropdown", () => AddStep("add dropdown", () =>
{ {
Add(new CollectionFilterDropdown Add(new CollectionFilterDropdown
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Width = 0.4f, Width = 0.4f,
} }
); );
}); });
AddStep("add two collections with same name", () => manager.Collections.AddRange(new[] AddStep("add two collections with same name", () => manager.Collections.AddRange(new[]