mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 14:22:55 +08:00
Merge branch 'better_taiko_keys' into taiko_bash_drawable
Conflicts: osu.Game.Modes.Taiko/Objects/Drawable/DrawableTaikoHitObject.cs
This commit is contained in:
commit
6e5db7b75d
@ -17,6 +17,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|||||||
private const double second_hit_window = 30;
|
private const double second_hit_window = 30;
|
||||||
|
|
||||||
private double firstHitTime;
|
private double firstHitTime;
|
||||||
|
private bool firstKeyHeld;
|
||||||
private Key firstHitKey;
|
private Key firstHitKey;
|
||||||
|
|
||||||
protected DrawableAccentedHit(Hit hit)
|
protected DrawableAccentedHit(Hit hit)
|
||||||
@ -41,40 +42,44 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|||||||
Judgement.SecondHit = true;
|
Judgement.SecondHit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
protected override bool HandleKeyPress(Key key)
|
||||||
{
|
{
|
||||||
// Check if we've handled the initial key
|
// Check if we've handled the first key
|
||||||
if (!Judgement.Result.HasValue)
|
if (!Judgement.Result.HasValue)
|
||||||
{
|
{
|
||||||
bool result = base.OnKeyDown(state, args);
|
// First key hasn't been handled yet, attempt to handle it
|
||||||
|
bool handled = base.HandleKeyPress(key);
|
||||||
|
|
||||||
if (result)
|
if (handled)
|
||||||
{
|
{
|
||||||
firstHitTime = Time.Current;
|
firstHitTime = Time.Current;
|
||||||
firstHitKey = args.Key;
|
firstHitKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've already hit the second key, don't handle this object any further
|
// If we've already hit the second key, don't handle this object any further
|
||||||
if (Judgement.SecondHit)
|
if (Judgement.SecondHit)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Don't handle represses of the same key
|
// Don't handle represses of the first key
|
||||||
if (firstHitKey == args.Key)
|
if (firstHitKey == key)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Don't handle invalid hit key presses
|
// Don't handle invalid hit key presses
|
||||||
if (!HitKeys.Contains(args.Key))
|
if (!HitKeys.Contains(key))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If we're not holding the first key down still, assume the intention
|
// Assume the intention was to hit the accented hit with both keys only if the first key is still being held down
|
||||||
// was not to hit the accented hit with both keys simultaneously
|
return firstKeyHeld && UpdateJudgement(true);
|
||||||
if (!state.Keyboard.Keys.Contains(firstHitKey))
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
return UpdateJudgement(true);
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
|
{
|
||||||
|
firstKeyHeld = state.Keyboard.Keys.Contains(firstHitKey);
|
||||||
|
|
||||||
|
return base.OnKeyDown(state, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using osu.Framework.Input;
|
|
||||||
using osu.Game.Modes.Objects.Drawables;
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
using osu.Game.Modes.Taiko.Judgements;
|
using osu.Game.Modes.Taiko.Judgements;
|
||||||
using System;
|
using System;
|
||||||
@ -17,12 +16,6 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract List<Key> HitKeys { get; }
|
protected abstract List<Key> HitKeys { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 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.
|
|
||||||
/// </summary>
|
|
||||||
private readonly List<Key> validKeys = new List<Key>(new[] { Key.D, Key.F, Key.J, Key.K });
|
|
||||||
|
|
||||||
private readonly Hit hit;
|
private readonly Hit hit;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -61,7 +54,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|||||||
Judgement.Result = HitResult.Miss;
|
Judgement.Result = HitResult.Miss;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool HandleKeyPress(Key key)
|
protected override bool HandleKeyPress(Key key)
|
||||||
{
|
{
|
||||||
if (Judgement.Result.HasValue)
|
if (Judgement.Result.HasValue)
|
||||||
return false;
|
return false;
|
||||||
@ -70,19 +63,5 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|||||||
|
|
||||||
return UpdateJudgement(true);
|
return UpdateJudgement(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using OpenTK.Input;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Modes.Objects.Drawables;
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
using osu.Game.Modes.Taiko.Judgements;
|
using osu.Game.Modes.Taiko.Judgements;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Taiko.Objects.Drawable
|
namespace osu.Game.Modes.Taiko.Objects.Drawable
|
||||||
{
|
{
|
||||||
public abstract class DrawableTaikoHitObject : DrawableHitObject<TaikoHitObject, TaikoJudgement>
|
public abstract class DrawableTaikoHitObject : DrawableHitObject<TaikoHitObject, TaikoJudgement>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
private readonly List<Key> validKeys = new List<Key>(new[] { Key.D, Key.F, Key.J, Key.K });
|
||||||
|
|
||||||
protected DrawableTaikoHitObject(TaikoHitObject hitObject)
|
protected DrawableTaikoHitObject(TaikoHitObject hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
@ -42,5 +51,21 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|||||||
{
|
{
|
||||||
UpdateScrollPosition(Time.Current);
|
UpdateScrollPosition(Time.Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual bool HandleKeyPress(Key key) { return false; }
|
||||||
|
|
||||||
|
protected 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user