diff --git a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs
index 2a0ce88506..674d83f6f2 100644
--- a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs
+++ b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs
@@ -140,6 +140,26 @@ namespace osu.Game.Rulesets.Mania.Judgements
Miss = BeatmapDifficulty.DifficultyRange(difficulty, miss_max, miss_mid, miss_min);
}
+ ///
+ /// Retrieves the hit result for a time offset.
+ ///
+ /// The time offset.
+ /// The hit result, or null if the time offset results in a miss.
+ public ManiaHitResult? ResultFor(double hitOffset)
+ {
+ if (hitOffset <= Perfect / 2)
+ return ManiaHitResult.Perfect;
+ if (hitOffset <= Great / 2)
+ return ManiaHitResult.Great;
+ if (hitOffset <= Good / 2)
+ return ManiaHitResult.Good;
+ if (hitOffset <= Ok / 2)
+ return ManiaHitResult.Ok;
+ if (hitOffset <= Bad / 2)
+ return ManiaHitResult.Bad;
+ return null;
+ }
+
///
/// Constructs new hit windows which have been multiplied by a value.
///
diff --git a/osu.Game.Rulesets.Mania/Judgements/ManiaHitResult.cs b/osu.Game.Rulesets.Mania/Judgements/ManiaHitResult.cs
new file mode 100644
index 0000000000..207a1fb251
--- /dev/null
+++ b/osu.Game.Rulesets.Mania/Judgements/ManiaHitResult.cs
@@ -0,0 +1,21 @@
+// Copyright (c) 2007-2017 ppy Pty Ltd .
+// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
+
+using System.ComponentModel;
+
+namespace osu.Game.Rulesets.Mania.Judgements
+{
+ public enum ManiaHitResult
+ {
+ [Description("PERFECT")]
+ Perfect,
+ [Description("GREAT")]
+ Great,
+ [Description("GOOD")]
+ Good,
+ [Description("OK")]
+ Ok,
+ [Description("BAD")]
+ Bad
+ }
+}
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs
index 8dafbd01a5..6e69da3da7 100644
--- a/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs
+++ b/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs
@@ -10,5 +10,10 @@ namespace osu.Game.Rulesets.Mania.Judgements
public override string ResultString => string.Empty;
public override string MaxResultString => string.Empty;
+
+ ///
+ /// The hit result.
+ ///
+ public ManiaHitResult ManiaResult;
}
}
diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs
index d9e46f4720..f9d027e7ce 100644
--- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs
+++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs
@@ -5,6 +5,8 @@ using osu.Game.Rulesets.Objects.Drawables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using OpenTK.Graphics;
+using osu.Framework.Configuration;
+using OpenTK.Input;
namespace osu.Game.Rulesets.Mania.Objects.Drawables
{
@@ -14,8 +16,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
private readonly BodyPiece bodyPiece;
private readonly NotePiece tailPiece;
- public DrawableHoldNote(HoldNote hitObject)
- : base(hitObject)
+ public DrawableHoldNote(HoldNote hitObject, Bindable key = null)
+ : base(hitObject, key)
{
RelativeSizeAxes = Axes.Both;
Height = (float)HitObject.Duration;
diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs
index d33a8c48ee..4e276fddb7 100644
--- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs
+++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs
@@ -2,6 +2,8 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Graphics;
+using OpenTK.Input;
+using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
@@ -11,13 +13,21 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
public abstract class DrawableManiaHitObject : DrawableHitObject
where TObject : ManiaHitObject
{
+ ///
+ /// The key that will trigger input for this hit object.
+ ///
+ protected Bindable Key { get; private set; } = new Bindable();
+
public new TObject HitObject;
- protected DrawableManiaHitObject(TObject hitObject)
+ protected DrawableManiaHitObject(TObject hitObject, Bindable key = null)
: base(hitObject)
{
HitObject = hitObject;
+ if (key != null)
+ Key.BindTo(key);
+
RelativePositionAxes = Axes.Y;
Y = (float)HitObject.StartTime;
}
diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs
index b216c362f5..d0519c61a8 100644
--- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs
+++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs
@@ -2,6 +2,8 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Graphics;
+using OpenTK.Input;
+using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Objects.Drawables;
@@ -12,8 +14,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
{
private readonly NotePiece headPiece;
- public DrawableNote(Note hitObject)
- : base(hitObject)
+ public DrawableNote(Note hitObject, Bindable key = null)
+ : base(hitObject, key)
{
RelativeSizeAxes = Axes.Both;
Height = 100;
diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs
index 701947c381..41bbe08d56 100644
--- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs
+++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs
@@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Mania.Objects
///
/// The key-release hit windows for this hold note.
///
- protected HitWindows ReleaseHitWindows = new HitWindows();
+ public HitWindows ReleaseHitWindows { get; protected set; } = new HitWindows();
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
{
diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs
index 1d2e4169b5..e955f6658b 100644
--- a/osu.Game.Rulesets.Mania/Objects/Note.cs
+++ b/osu.Game.Rulesets.Mania/Objects/Note.cs
@@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Objects
///
/// The key-press hit window for this note.
///
- protected HitWindows HitWindows = new HitWindows();
+ public HitWindows HitWindows { get; protected set; } = new HitWindows();
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
{
diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs
index 96f04f79d4..7a9572a0c7 100644
--- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs
+++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs
@@ -22,5 +22,12 @@ namespace osu.Game.Rulesets.Mania.Scoring
protected override void OnNewJudgement(ManiaJudgement judgement)
{
}
+
+ protected override void Reset()
+ {
+ base.Reset();
+
+ Health.Value = 1;
+ }
}
}
diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs
index dea00433e6..72c60b28c9 100644
--- a/osu.Game.Rulesets.Mania/UI/Column.cs
+++ b/osu.Game.Rulesets.Mania/UI/Column.cs
@@ -18,6 +18,8 @@ using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Judgements;
using osu.Game.Beatmaps.Timing;
+using System;
+using osu.Framework.Configuration;
namespace osu.Game.Rulesets.Mania.UI
{
@@ -33,7 +35,10 @@ namespace osu.Game.Rulesets.Mania.UI
private const float column_width = 45;
private const float special_column_width = 70;
- public Key Key;
+ ///
+ /// The key that will trigger input actions for this column and hit objects contained inside it.
+ ///
+ public Bindable Key = new Bindable();
private readonly Box background;
private readonly Container hitTargetBar;
@@ -95,6 +100,12 @@ namespace osu.Game.Rulesets.Mania.UI
Name = "Hit objects",
RelativeSizeAxes = Axes.Both,
},
+ // For column lighting, we need to capture input events before the notes
+ new InputTarget
+ {
+ KeyDown = onKeyDown,
+ KeyUp = onKeyUp
+ }
}
},
new Container
@@ -178,12 +189,9 @@ namespace osu.Game.Rulesets.Mania.UI
}
}
- public void Add(DrawableHitObject hitObject)
- {
- ControlPointContainer.Add(hitObject);
- }
+ public void Add(DrawableHitObject hitObject) => ControlPointContainer.Add(hitObject);
- protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
+ private bool onKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat)
return false;
@@ -197,7 +205,7 @@ namespace osu.Game.Rulesets.Mania.UI
return false;
}
- protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
+ private bool onKeyUp(InputState state, KeyUpEventArgs args)
{
if (args.Key == Key)
{
@@ -207,5 +215,24 @@ namespace osu.Game.Rulesets.Mania.UI
return false;
}
+
+ ///
+ /// This is a simple container which delegates various input events that have to be captured before the notes.
+ ///
+ private class InputTarget : Container
+ {
+ public Func KeyDown;
+ public Func KeyUp;
+
+ public InputTarget()
+ {
+ RelativeSizeAxes = Axes.Both;
+ AlwaysPresent = true;
+ Alpha = 0;
+ }
+
+ protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => KeyDown?.Invoke(state, args) ?? false;
+ protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) => KeyUp?.Invoke(state, args) ?? false;
+ }
}
}
diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs
index c67866dc10..4d734d231f 100644
--- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs
+++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs
@@ -4,6 +4,8 @@
using System;
using System.Linq;
using OpenTK;
+using OpenTK.Input;
+using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Timing;
@@ -76,13 +78,19 @@ namespace osu.Game.Rulesets.Mania.UI
protected override DrawableHitObject GetVisualRepresentation(ManiaHitObject h)
{
+ var maniaPlayfield = Playfield as ManiaPlayfield;
+ if (maniaPlayfield == null)
+ return null;
+
+ Bindable key = maniaPlayfield.Columns.ElementAt(h.Column).Key;
+
var holdNote = h as HoldNote;
if (holdNote != null)
- return new DrawableHoldNote(holdNote);
+ return new DrawableHoldNote(holdNote, key);
var note = h as Note;
if (note != null)
- return new DrawableNote(note);
+ return new DrawableNote(note, key);
return null;
}
diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
index 56a86873e9..70bdd3b13c 100644
--- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
+++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
@@ -55,7 +55,8 @@ namespace osu.Game.Rulesets.Mania.UI
}
}
- public readonly FlowContainer Columns;
+ private readonly FlowContainer columns;
+ public IEnumerable Columns => columns.Children;
private readonly ControlPointContainer barlineContainer;
@@ -87,7 +88,7 @@ namespace osu.Game.Rulesets.Mania.UI
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black
},
- Columns = new FillFlowContainer
+ columns = new FillFlowContainer
{
Name = "Columns",
RelativeSizeAxes = Axes.Y,
@@ -114,7 +115,7 @@ namespace osu.Game.Rulesets.Mania.UI
};
for (int i = 0; i < columnCount; i++)
- Columns.Add(new Column(timingChanges));
+ columns.Add(new Column(timingChanges));
TimeSpan = time_span_default;
}
@@ -133,17 +134,17 @@ namespace osu.Game.Rulesets.Mania.UI
// Set the special column + colour + key
for (int i = 0; i < columnCount; i++)
{
- Column column = Columns.Children.ElementAt(i);
+ Column column = Columns.ElementAt(i);
column.IsSpecial = isSpecialColumn(i);
if (!column.IsSpecial)
continue;
- column.Key = Key.Space;
+ column.Key.Value = Key.Space;
column.AccentColour = specialColumnColour;
}
- var nonSpecialColumns = Columns.Children.Where(c => !c.IsSpecial).ToList();
+ var nonSpecialColumns = Columns.Where(c => !c.IsSpecial).ToList();
// We'll set the colours of the non-special columns in a separate loop, because the non-special
// column colours are mirrored across their centre and special styles mess with this
@@ -162,11 +163,11 @@ namespace osu.Game.Rulesets.Mania.UI
int keyOffset = default_keys.Length / 2 - nonSpecialColumns.Count / 2 + i;
if (keyOffset >= 0 && keyOffset < default_keys.Length)
- column.Key = default_keys[keyOffset];
+ column.Key.Value = default_keys[keyOffset];
else
// There is no default key defined for this column. Let's set this to Unknown for now
// however note that this will be gone after bindings are in place
- column.Key = Key.Unknown;
+ column.Key.Value = Key.Unknown;
}
}
@@ -189,7 +190,7 @@ namespace osu.Game.Rulesets.Mania.UI
}
}
- public override void Add(DrawableHitObject h) => Columns.Children.ElementAt(h.HitObject.Column).Add(h);
+ public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h);
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
@@ -225,7 +226,7 @@ namespace osu.Game.Rulesets.Mania.UI
timeSpan = MathHelper.Clamp(timeSpan, time_span_min, time_span_max);
barlineContainer.TimeSpan = value;
- Columns.Children.ForEach(c => c.ControlPointContainer.TimeSpan = value);
+ Columns.ForEach(c => c.ControlPointContainer.TimeSpan = value);
}
}
diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj
index adcdfd5fae..408f20033e 100644
--- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj
+++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj
@@ -56,6 +56,7 @@
+