2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
|
using osu.Game.Input.Bindings;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Volume
|
|
|
|
|
{
|
2019-08-27 17:42:49 +08:00
|
|
|
|
public class VolumeControlReceptor : Container, IScrollBindingHandler<GlobalAction>, IHandleGlobalKeyboardInput
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
public Func<GlobalAction, bool> ActionRequested;
|
2018-07-05 15:50:04 +08:00
|
|
|
|
public Func<GlobalAction, float, bool, bool> ScrollActionRequested;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-03-02 17:59:38 +08:00
|
|
|
|
public bool OnPressed(GlobalAction action)
|
|
|
|
|
{
|
|
|
|
|
// if nothing else handles selection actions in the game, it's safe to let volume be adjusted.
|
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case GlobalAction.SelectPrevious:
|
|
|
|
|
action = GlobalAction.IncreaseVolume;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GlobalAction.SelectNext:
|
|
|
|
|
action = GlobalAction.DecreaseVolume;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ActionRequested?.Invoke(action) ?? false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool OnScroll(GlobalAction action, float amount, bool isPrecise) =>
|
|
|
|
|
ScrollActionRequested?.Invoke(action, amount, isPrecise) ?? false;
|
2020-01-22 12:22:34 +08:00
|
|
|
|
|
|
|
|
|
public void OnReleased(GlobalAction action)
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|