Skip to content

Commit

Permalink
Allow using Global scroll speed keybinds
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed Aug 17, 2023
1 parent 495f99f commit e82bd2f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using osu.Game.Configuration;
using osu.Framework.Configuration.Tracking;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Rulesets.Configuration;

namespace osu.Game.Rulesets.Sentakki.Configuration
Expand All @@ -25,6 +27,33 @@ protected override void InitialiseDefaults()
SetDefault(SentakkiRulesetSettings.DetailedJudgements, false);
SetDefault(SentakkiRulesetSettings.BreakSampleVolume, 1d, 0d, 1d, 0.01f);
}

public override TrackedSettings CreateTrackedSettings()
{

return new TrackedSettings{
new TrackedSetting<double>(SentakkiRulesetSettings.AnimationDuration, t=> new SettingDescription(
t,
"Note animation speed",
generateNoteSpeedDescription(t)
))
};
}

private string generateNoteSpeedDescription(double time)
{
string speedRating()
{
double speed = (2200 - time) / 200;

if (speed == 10.5)
return "Sonic";

return speed.ToString();
}

return $"{time:N0}ms ({speedRating()})";
}
}

public enum SentakkiRulesetSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public DrawableSentakkiHitObject(SentakkiHitObject? hitObject = null)
}

[Resolved]
protected DrawableSentakkiRuleset? DrawableSentakkiRuleset { get; set; }
protected DrawableSentakkiRuleset? DrawableSentakkiRuleset { get; private set; }

protected override void LoadAsyncComplete()
{
Expand Down
28 changes: 26 additions & 2 deletions osu.Game.Rulesets.Sentakki/UI/DrawableSentakkiRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;

namespace osu.Game.Rulesets.Sentakki.UI
{
[Cached]
public partial class DrawableSentakkiRuleset : DrawableRuleset<SentakkiHitObject>
public partial class DrawableSentakkiRuleset : DrawableRuleset<SentakkiHitObject>, IKeyBindingHandler<GlobalAction>
{
private SlideFanChevrons slideFanChevronsTextures = null!;

Expand Down Expand Up @@ -60,7 +63,11 @@ private void load()
smoothTouchAnimDuration = configTouchAnimDuration.Value;
}

private readonly Bindable<double> configAnimDuration = new Bindable<double>(1000);
private readonly Bindable<double> configAnimDuration = new BindableDouble(1000)
{
MinValue = 100,
MaxValue = 2000,
};
private double smoothAnimDuration = 1000;
public readonly Bindable<double> AdjustedAnimDuration = new Bindable<double>(1000);

Expand All @@ -80,6 +87,23 @@ private void updateAnimationDurations()
AdjustedTouchAnimDuration.Value = smoothTouchAnimDuration * speedAdjustmentTrack.AggregateTempo.Value * speedAdjustmentTrack.AggregateFrequency.Value;
}

public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.DecreaseScrollSpeed:
configAnimDuration.Value -= 100;
return true;
case GlobalAction.IncreaseScrollSpeed:
configAnimDuration.Value += 100;
return true;
}

return false;
}

public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e) { }


// Gameplay speed specifics
private readonly Track speedAdjustmentTrack = new TrackVirtual(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using osu.Framework.Bindables;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Sentakki.Configuration;
using osu.Game.Rulesets.Sentakki.Objects;

namespace osu.Game.Rulesets.Sentakki.UI
Expand Down

0 comments on commit e82bd2f

Please sign in to comment.