Added toggling mods with keys

This commit is contained in:
DrabWeb 2017-02-16 19:00:18 -04:00
parent 9fc3726925
commit e0dab3490f
4 changed files with 34 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Modes;
@ -98,6 +99,7 @@ namespace osu.Game
{
relaxButton = new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new ModRelax(),
@ -105,6 +107,7 @@ namespace osu.Game
},
autopilotButton = new ModButton
{
ToggleKey = Key.X,
Mods = new Mod[]
{
new ModAutopilot(),
@ -112,6 +115,7 @@ namespace osu.Game
},
targetPracticeButton = new ModButton
{
ToggleKey = Key.C,
Mods = new Mod[]
{
new ModTarget(),
@ -119,6 +123,7 @@ namespace osu.Game
},
spunOutButton = new ModButton
{
ToggleKey = Key.V,
Mods = new Mod[]
{
new ModSpunOut(),
@ -126,6 +131,7 @@ namespace osu.Game
},
autoplayCinemaButton = new ModButton
{
ToggleKey = Key.B,
Mods = new Mod[]
{
new ModAutoplay(),
@ -141,6 +147,7 @@ namespace osu.Game
{
relaxButton = new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new ModRelax(),
@ -148,6 +155,7 @@ namespace osu.Game
},
autoplayCinemaButton = new ModButton
{
ToggleKey = Key.X,
Mods = new Mod[]
{
new ModAutoplay(),
@ -162,6 +170,7 @@ namespace osu.Game
{
keyButton = new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new ModKey4(),
@ -177,6 +186,7 @@ namespace osu.Game
},
coopButton = new ModButton
{
ToggleKey = Key.X,
Mods = new Mod[]
{
new ModKeyCoop(),
@ -184,6 +194,7 @@ namespace osu.Game
},
randomButton = new ModButton
{
ToggleKey = Key.C,
Mods = new Mod[]
{
new ModRandom(),
@ -191,6 +202,7 @@ namespace osu.Game
},
autoplayCinemaButton = new ModButton
{
ToggleKey = Key.V,
Mods = new Mod[]
{
new ModAutoplay(),

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Modes;
@ -29,6 +30,7 @@ namespace osu.Game
{
new ModButton
{
ToggleKey = Key.A,
Mods = new Mod[]
{
new ModHardRock(),
@ -36,6 +38,7 @@ namespace osu.Game
},
new ModButton
{
ToggleKey = Key.S,
Mods = new Mod[]
{
new ModSuddenDeath(),
@ -44,6 +47,7 @@ namespace osu.Game
},
new ModButton
{
ToggleKey = Key.D,
Mods = new Mod[]
{
new ModDoubleTime(),
@ -52,6 +56,7 @@ namespace osu.Game
},
new ModButton
{
ToggleKey = Key.F,
Mods = new Mod[]
{
new ModHidden(),
@ -59,6 +64,7 @@ namespace osu.Game
},
new ModButton
{
ToggleKey = Key.G,
Mods = new Mod[]
{
new ModFlashlight(),

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Modes;
@ -27,6 +28,7 @@ namespace osu.Game
{
new ModButton
{
ToggleKey = Key.Q,
Mods = new Mod[]
{
new ModEasy(),
@ -34,6 +36,7 @@ namespace osu.Game
},
new ModButton
{
ToggleKey = Key.W,
Mods = new Mod[]
{
new ModNoFail(),
@ -41,6 +44,7 @@ namespace osu.Game
},
new ModButton
{
ToggleKey = Key.E,
Mods = new Mod[]
{
new ModHalfTime(),

View File

@ -27,6 +27,7 @@ namespace osu.Game.Overlays.Mods
private AudioSample sampleOn, sampleOff;
public Action<Mod> Action; // Passed the selected mod or null if none
public Key ToggleKey;
private int _selectedMod = -1;
private int selectedMod
@ -216,6 +217,17 @@ namespace osu.Game.Overlays.Mods
}
}
protected override bool OnKeyDown(Framework.Input.InputState state, KeyDownEventArgs args)
{
if (args.Key == ToggleKey)
{
SelectNext();
return true;
}
return base.OnKeyDown(state, args);
}
public ModButton()
{
Direction = FlowDirections.Vertical;