From f26cf7bf68599f2ea84c8b020df832c6a5a8c694 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 17 Mar 2017 16:55:57 +0900 Subject: [PATCH 01/10] Add basic DrawableHit (no graphics yet, just input). --- .../Objects/Drawable/DrawableHit.cs | 82 +++++++++++++++++++ .../osu.Game.Modes.Taiko.csproj | 1 + 2 files changed, 83 insertions(+) create mode 100644 osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs new file mode 100644 index 0000000000..caf4fee335 --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs @@ -0,0 +1,82 @@ +using OpenTK.Input; +using osu.Framework.Input; +using osu.Game.Modes.Objects.Drawables; +using osu.Game.Modes.Taiko.Judgements; +using System; +using System.Collections.Generic; + +namespace osu.Game.Modes.Taiko.Objects.Drawable +{ + public abstract class DrawableHit : DrawableTaikoHitObject + { + /// + /// A list of keys which can result in hits for this HitObject. + /// + protected abstract List HitKeys { get; } + + /// + /// A list of keys which this hit object will accept. These are the standard Taiko keys for now. + /// These should be moved to bindings later. + /// + private List validKeys = new List(new[] { Key.D, Key.F, Key.J, Key.K }); + + /// + /// Whether the last key pressed is a valid hit key. + /// + private bool validKeyPressed; + + protected DrawableHit(TaikoHitObject hitObject) + : base(hitObject) + { + } + + protected override void CheckJudgement(bool userTriggered) + { + if (!userTriggered) + { + if (Judgement.TimeOffset > HitObject.HitWindowGood) + Judgement.Result = HitResult.Miss; + return; + } + + double hitOffset = Math.Abs(Judgement.TimeOffset); + + if (hitOffset > HitObject.HitWindowMiss) + return; + + if (!validKeyPressed) + Judgement.Result = HitResult.Miss; + else if (hitOffset < HitObject.HitWindowGood) + { + Judgement.Result = HitResult.Hit; + Judgement.Score = hitOffset < HitObject.HitWindowGreat ? TaikoScoreResult.Great : TaikoScoreResult.Good; + } + else + Judgement.Result = HitResult.Miss; + } + + protected virtual bool HandleKeyPress(Key key) + { + if (Judgement.Result.HasValue) + return false; + + validKeyPressed = HitKeys.Contains(key); + + return UpdateJudgement(true); + } + + protected sealed override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + // Make sure we don't handle held-down keys + if (args.Repeat) + return false; + + // Check if we've pressed a valid taiko key + if (!validKeys.Contains(args.Key)) + return false; + + // Handle it! + return HandleKeyPress(args.Key); + } + } +} diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index aab9a17276..dbd58d4666 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -50,6 +50,7 @@ + From 863d4959af1f4c7153b2c4f4763446cfc7aea845 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 17 Mar 2017 17:38:24 +0900 Subject: [PATCH 02/10] Make OnKeyDown non-sealed. --- osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs index caf4fee335..46cf9e5f87 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs @@ -65,7 +65,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable return UpdateJudgement(true); } - protected sealed override bool OnKeyDown(InputState state, KeyDownEventArgs args) + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { // Make sure we don't handle held-down keys if (args.Repeat) From 1892d869215b5a525e734adc220a8e69b0672bf6 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 17 Mar 2017 17:38:49 +0900 Subject: [PATCH 03/10] Add basic DrawableHitFinisher (no graphics yet, just input). --- .../Objects/Drawable/DrawableHitFinisher.cs | 80 +++++++++++++++++++ .../osu.Game.Modes.Taiko.csproj | 1 + 2 files changed, 81 insertions(+) create mode 100644 osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs new file mode 100644 index 0000000000..22fc83874b --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs @@ -0,0 +1,80 @@ +using OpenTK.Input; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Input; + +namespace osu.Game.Modes.Taiko.Objects.Drawable +{ + public abstract class DrawableHitFinisher : DrawableHit + { + /// + /// The lenience for the second key press. + /// This does not adjust by map difficulty in ScoreV2 yet. + /// + private const double second_hit_window = 30; + + private double firstHitTime; + private Key firstHitKey; + + protected DrawableHitFinisher(TaikoHitObject hitObject) + : base(hitObject) + { + } + + protected override void CheckJudgement(bool userTriggered) + { + if (!Judgement.Result.HasValue) + { + base.CheckJudgement(userTriggered); + return; + } + + if (!userTriggered) + return; + + // If we get here, we're assured that the key pressed is the correct secondary key + + if (Math.Abs(firstHitTime - Time.Current) < second_hit_window) + Judgement.SecondHit = true; + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + // Check if we've handled the initial key + if (!Judgement.Result.HasValue) + { + bool result = base.OnKeyDown(state, args); + + if (result) + { + firstHitTime = Time.Current; + firstHitKey = args.Key; + } + + return result; + } + + // If we've already hit the second key, don't handle this object any further + if (Judgement.SecondHit) + return false; + + // Don't handle represses of the same key + if (firstHitKey == args.Key) + return false; + + // Don't handle invalid hit key presses + if (!HitKeys.Contains(args.Key)) + return false; + + // If we're not holding the first key down still, assume the intention + // was not to hit the finisher with both keys simultaneously + if (!state.Keyboard.Keys.Contains(firstHitKey)) + return false; + + return UpdateJudgement(true); + } + } +} diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index 3a79d721c6..5b8a1fd2b8 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -52,6 +52,7 @@ + From 938da01540c5b836baadb8fd06efae3c070d7859 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 17 Mar 2017 18:56:58 +0900 Subject: [PATCH 04/10] Fix post-merge errors. --- osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs index 46cf9e5f87..dc5d846ebc 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; namespace osu.Game.Modes.Taiko.Objects.Drawable { - public abstract class DrawableHit : DrawableTaikoHitObject + public abstract class DrawableHit : DrawableTaikoHitObject { /// /// A list of keys which can result in hits for this HitObject. From ad396c65ee6e9c6774d15e5bc4abdb52394c1375 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 17 Mar 2017 19:24:39 +0900 Subject: [PATCH 05/10] Fix post-merge errors. --- osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs index dc5d846ebc..46cf9e5f87 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; namespace osu.Game.Modes.Taiko.Objects.Drawable { - public abstract class DrawableHit : DrawableTaikoHitObject + public abstract class DrawableHit : DrawableTaikoHitObject { /// /// A list of keys which can result in hits for this HitObject. From 75d09e7038c4b42cfe70bc25ff0fabbc27bfb153 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 20 Mar 2017 18:18:25 +0900 Subject: [PATCH 06/10] Fix unused usings. --- osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs index 22fc83874b..2e5281839a 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs @@ -1,9 +1,6 @@ using OpenTK.Input; using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using osu.Framework.Input; namespace osu.Game.Modes.Taiko.Objects.Drawable From ed9c7c800877187bb0cde71aea922b904b0c4a7b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 20 Mar 2017 18:25:12 +0900 Subject: [PATCH 07/10] Add license headers. --- osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs | 5 ++++- osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs index 46cf9e5f87..483f6a31d5 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs @@ -1,4 +1,7 @@ -using OpenTK.Input; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Input; using osu.Framework.Input; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Taiko.Judgements; diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs index 2e5281839a..c72b520cc4 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs @@ -1,4 +1,7 @@ -using OpenTK.Input; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Input; using System; using System.Linq; using osu.Framework.Input; From e4926d54ab735cbe24e5f640644aae6282a0d4be Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 22 Mar 2017 01:48:51 +0900 Subject: [PATCH 08/10] Fix post-merge errors. --- osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs index 483f6a31d5..4f3e06cd6d 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs @@ -52,7 +52,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable else if (hitOffset < HitObject.HitWindowGood) { Judgement.Result = HitResult.Hit; - Judgement.Score = hitOffset < HitObject.HitWindowGreat ? TaikoScoreResult.Great : TaikoScoreResult.Good; + Judgement.TaikoResult = hitOffset < HitObject.HitWindowGreat ? TaikoHitResult.Great : TaikoHitResult.Good; } else Judgement.Result = HitResult.Miss; From 45b013c85fff493edadb060b37c2e745af4ee129 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 24 Mar 2017 14:59:59 +0900 Subject: [PATCH 09/10] Fix post-merge errors. --- .../Objects/Drawable/DrawableHit.cs | 17 ++++++++++------- .../Objects/Drawable/DrawableHitFinisher.cs | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs index 4f3e06cd6d..cc017ab376 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHit.cs @@ -21,38 +21,41 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable /// A list of keys which this hit object will accept. These are the standard Taiko keys for now. /// These should be moved to bindings later. /// - private List validKeys = new List(new[] { Key.D, Key.F, Key.J, Key.K }); + private readonly List validKeys = new List(new[] { Key.D, Key.F, Key.J, Key.K }); + + private readonly Hit hit; /// /// Whether the last key pressed is a valid hit key. /// private bool validKeyPressed; - protected DrawableHit(TaikoHitObject hitObject) - : base(hitObject) + protected DrawableHit(Hit hit) + : base(hit) { + this.hit = hit; } protected override void CheckJudgement(bool userTriggered) { if (!userTriggered) { - if (Judgement.TimeOffset > HitObject.HitWindowGood) + if (Judgement.TimeOffset > hit.HitWindowGood) Judgement.Result = HitResult.Miss; return; } double hitOffset = Math.Abs(Judgement.TimeOffset); - if (hitOffset > HitObject.HitWindowMiss) + if (hitOffset > hit.HitWindowMiss) return; if (!validKeyPressed) Judgement.Result = HitResult.Miss; - else if (hitOffset < HitObject.HitWindowGood) + else if (hitOffset < hit.HitWindowGood) { Judgement.Result = HitResult.Hit; - Judgement.TaikoResult = hitOffset < HitObject.HitWindowGreat ? TaikoHitResult.Great : TaikoHitResult.Good; + Judgement.TaikoResult = hitOffset < hit.HitWindowGreat ? TaikoHitResult.Great : TaikoHitResult.Good; } else Judgement.Result = HitResult.Miss; diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs index c72b520cc4..3f7361b62c 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs @@ -19,8 +19,8 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable private double firstHitTime; private Key firstHitKey; - protected DrawableHitFinisher(TaikoHitObject hitObject) - : base(hitObject) + protected DrawableHitFinisher(Hit hit) + : base(hit) { } From be4ab13f4d567190d0d614021b64fb92665a24b9 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sat, 25 Mar 2017 20:30:26 +0900 Subject: [PATCH 10/10] Rename finisher -> accented. --- .../{DrawableHitFinisher.cs => DrawableAccentedHit.cs} | 6 +++--- osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename osu.Game.Modes.Taiko/Objects/Drawable/{DrawableHitFinisher.cs => DrawableAccentedHit.cs} (89%) diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableAccentedHit.cs similarity index 89% rename from osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs rename to osu.Game.Modes.Taiko/Objects/Drawable/DrawableAccentedHit.cs index 3f7361b62c..e251daae7d 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableHitFinisher.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableAccentedHit.cs @@ -8,7 +8,7 @@ using osu.Framework.Input; namespace osu.Game.Modes.Taiko.Objects.Drawable { - public abstract class DrawableHitFinisher : DrawableHit + public abstract class DrawableAccentedHit : DrawableHit { /// /// The lenience for the second key press. @@ -19,7 +19,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable private double firstHitTime; private Key firstHitKey; - protected DrawableHitFinisher(Hit hit) + protected DrawableAccentedHit(Hit hit) : base(hit) { } @@ -70,7 +70,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable return false; // If we're not holding the first key down still, assume the intention - // was not to hit the finisher with both keys simultaneously + // was not to hit the accented hit with both keys simultaneously if (!state.Keyboard.Keys.Contains(firstHitKey)) return false; diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index fcabccc9ca..d6b2fb6364 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -53,7 +53,7 @@ - +