mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:02:53 +08:00
Merge pull request #1 from Fabiano1337/osu-lazer-speedkeys
Osu lazer speedkeys
This commit is contained in:
commit
e73763545e
@ -182,6 +182,8 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(new[] { InputKey.Shift, InputKey.F2 }, GlobalAction.SelectPreviousRandom),
|
||||
new KeyBinding(InputKey.F3, GlobalAction.ToggleBeatmapOptions),
|
||||
new KeyBinding(InputKey.BackSpace, GlobalAction.DeselectAllMods),
|
||||
new KeyBinding(InputKey.PageUp, GlobalAction.IncreaseSpeed),
|
||||
new KeyBinding(InputKey.PageDown, GlobalAction.DecreaseSpeed),
|
||||
};
|
||||
|
||||
private static IEnumerable<KeyBinding> audioControlKeyBindings => new[]
|
||||
@ -409,6 +411,12 @@ namespace osu.Game.Input.Bindings
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorToggleRotateControl))]
|
||||
EditorToggleRotateControl,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.IncreaseSpeed))]
|
||||
IncreaseSpeed,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.DecreaseSpeed))]
|
||||
DecreaseSpeed,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.IncreaseOffset))]
|
||||
IncreaseOffset,
|
||||
|
||||
|
@ -369,6 +369,16 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString EditorToggleRotateControl => new TranslatableString(getKey(@"editor_toggle_rotate_control"), @"Toggle rotate control");
|
||||
|
||||
/// <summary>
|
||||
/// "Increase Speed"
|
||||
/// </summary>
|
||||
public static LocalisableString IncreaseSpeed => new TranslatableString(getKey(@"increase_speed"), @"Increase Speed");
|
||||
|
||||
/// <summary>
|
||||
/// "Decrease Speed"
|
||||
/// </summary>
|
||||
public static LocalisableString DecreaseSpeed => new TranslatableString(getKey(@"decrease_speed"), @"Decrease Speed");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
@ -808,7 +808,82 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void increaseSpeed()
|
||||
{
|
||||
var rateAdjustStates = ModSelect.AllAvailableMods.Where(pair => pair.Mod is ModRateAdjust);
|
||||
var stateDoubleTime = ModSelect.AllAvailableMods.First(pair => pair.Mod is ModDoubleTime);
|
||||
bool rateModActive = ModSelect.AllAvailableMods.Where(pair => pair.Mod is ModRateAdjust && pair.Active.Value).Count() > 0;
|
||||
double stepSize = 0.05d;
|
||||
double newRate = 1d + stepSize;
|
||||
// If no mod rateAdjust mod is currently active activate DoubleTime with speed newRate
|
||||
if (!rateModActive)
|
||||
{
|
||||
stateDoubleTime.Active.Value = true;
|
||||
((ModDoubleTime)stateDoubleTime.Mod).SpeedChange.Value = newRate;
|
||||
return;
|
||||
}
|
||||
// Find current active rateAdjust mod and modify speed, enable DoubleTime if necessary
|
||||
foreach (var state in rateAdjustStates)
|
||||
{
|
||||
ModRateAdjust mod = (ModRateAdjust)state.Mod;
|
||||
if (!state.Active.Value) continue;
|
||||
newRate = mod.SpeedChange.Value + stepSize;
|
||||
if (mod.Acronym == "DT" || mod.Acronym == "NC")
|
||||
mod.SpeedChange.Value = newRate;
|
||||
else
|
||||
{
|
||||
if (newRate == 1.0d)
|
||||
state.Active.Value = false;
|
||||
if (newRate > 1d)
|
||||
{
|
||||
state.Active.Value = false;
|
||||
stateDoubleTime.Active.Value = true;
|
||||
((ModDoubleTime)stateDoubleTime.Mod).SpeedChange.Value = newRate;
|
||||
break;
|
||||
}
|
||||
if (newRate < 1d)
|
||||
mod.SpeedChange.Value = newRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void decreaseSpeed()
|
||||
{
|
||||
var rateAdjustStates = ModSelect.AllAvailableMods.Where(pair => pair.Mod is ModRateAdjust);
|
||||
var stateHalfTime = ModSelect.AllAvailableMods.First(pair => pair.Mod is ModHalfTime);
|
||||
bool rateModActive = ModSelect.AllAvailableMods.Where(pair => pair.Mod is ModRateAdjust && pair.Active.Value).Count() > 0;
|
||||
double stepSize = 0.05d;
|
||||
double newRate = 1d - stepSize;
|
||||
// If no mod rateAdjust mod is currently active activate HalfTime with speed newRate
|
||||
if (!rateModActive)
|
||||
{
|
||||
stateHalfTime.Active.Value = true;
|
||||
((ModHalfTime)stateHalfTime.Mod).SpeedChange.Value = newRate;
|
||||
return;
|
||||
}
|
||||
// Find current active rateAdjust mod and modify speed, enable HalfTime if necessary
|
||||
foreach (var state in rateAdjustStates)
|
||||
{
|
||||
ModRateAdjust mod = (ModRateAdjust)state.Mod;
|
||||
if (!state.Active.Value) continue;
|
||||
newRate = mod.SpeedChange.Value - stepSize;
|
||||
if (mod.Acronym == "HT" || mod.Acronym == "DC")
|
||||
mod.SpeedChange.Value = newRate;
|
||||
else
|
||||
{
|
||||
if (newRate == 1.0d)
|
||||
state.Active.Value = false;
|
||||
if (newRate < 1d)
|
||||
{
|
||||
state.Active.Value = false;
|
||||
stateHalfTime.Active.Value = true;
|
||||
((ModHalfTime)stateHalfTime.Mod).SpeedChange.Value = newRate;
|
||||
break;
|
||||
}
|
||||
if (newRate > 1d)
|
||||
mod.SpeedChange.Value = newRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
@ -1011,12 +1086,17 @@ namespace osu.Game.Screens.Select
|
||||
return false;
|
||||
|
||||
if (!this.IsCurrentScreen()) return false;
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.Select:
|
||||
FinaliseSelection();
|
||||
return true;
|
||||
case GlobalAction.IncreaseSpeed:
|
||||
increaseSpeed();
|
||||
return true;
|
||||
case GlobalAction.DecreaseSpeed:
|
||||
decreaseSpeed();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user