mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Adapt signature change of event handlers
This commit is contained in:
parent
99fc04c8af
commit
50091252e2
@ -6,10 +6,10 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.States;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Skinning;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
@ -102,23 +102,23 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
};
|
||||
}
|
||||
|
||||
private InputState lastState;
|
||||
private Vector2? lastScreenSpaceMousePosition;
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
lastState = state;
|
||||
lastScreenSpaceMousePosition = e.ScreenSpaceMousePosition;
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
lastState = state;
|
||||
lastScreenSpaceMousePosition = e.ScreenSpaceMousePosition;
|
||||
return base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
lastState = e;
|
||||
lastScreenSpaceMousePosition = e.ScreenSpaceMousePosition;
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
@ -155,8 +155,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
// Make sure to use the base version of ReceivePositionalInputAt so that we correctly check the position.
|
||||
Tracking = canCurrentlyTrack
|
||||
&& lastState != null
|
||||
&& ReceivePositionalInputAt(lastState.Mouse.NativeState.Position)
|
||||
&& lastScreenSpaceMousePosition.HasValue
|
||||
&& ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value)
|
||||
&& (drawableSlider?.OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
mousePosition = Parent.ToLocalSpace(e.Mouse.NativeState.Position);
|
||||
mousePosition = Parent.ToLocalSpace(e.ScreenSpaceMousePosition);
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.States;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu
|
||||
@ -36,13 +35,11 @@ namespace osu.Game.Rulesets.Osu
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e) => AllowUserPresses && base.OnKeyDown(e);
|
||||
protected override bool OnKeyUp(KeyUpEvent e) => AllowUserPresses && base.OnKeyUp(e);
|
||||
protected override bool OnJoystickPress(InputState state, JoystickEventArgs args) => AllowUserPresses && base.OnJoystickPress(args);
|
||||
protected override bool OnJoystickRelease(InputState state, JoystickEventArgs args) => AllowUserPresses && base.OnJoystickRelease(args);
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => AllowUserPresses && base.OnMouseDown(e);
|
||||
protected override bool OnMouseUp(MouseUpEvent e) => AllowUserPresses && base.OnMouseUp(e);
|
||||
protected override bool OnScroll(ScrollEvent e) => AllowUserPresses && base.OnScroll(e);
|
||||
protected override bool Handle(UIEvent e)
|
||||
{
|
||||
if (!AllowUserPresses) return false;
|
||||
return base.Handle(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
Vector2 pos = e.Mouse.NativeState.Position;
|
||||
Vector2 pos = e.ScreenSpaceMousePosition;
|
||||
|
||||
if (lastPosition == null)
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ namespace osu.Game.Tests.Visual
|
||||
/// </summary>
|
||||
/// <param name="cursorContainer">The cursor to check.</param>
|
||||
private bool checkAtMouse(CursorContainer cursorContainer)
|
||||
=> Precision.AlmostEquals(InputManager.CurrentState.Mouse.NativeState.Position, cursorContainer.ToScreenSpace(cursorContainer.ActiveCursor.DrawPosition));
|
||||
=> Precision.AlmostEquals(InputManager.CurrentState.Mouse.Position, cursorContainer.ToScreenSpace(cursorContainer.ActiveCursor.DrawPosition));
|
||||
|
||||
private class CustomCursorBox : Container, IProvideCursor
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (!base.ReceivePositionalInputAt(state.Mouse.NativeState.Position))
|
||||
if (!base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
|
||||
{
|
||||
State = Visibility.Hidden;
|
||||
return true;
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.States;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
@ -21,7 +20,7 @@ namespace osu.Game.Graphics.Containers
|
||||
/// </summary>
|
||||
public double DistanceDecayOnRightMouseScrollbar = 0.02;
|
||||
|
||||
private bool shouldPerformRightMouseScroll(InputState state) => RightMouseScrollbar && state.Mouse.IsPressed(MouseButton.Right);
|
||||
private bool shouldPerformRightMouseScroll(MouseButtonEvent e) => RightMouseScrollbar && e.Button == MouseButton.Right;
|
||||
|
||||
private void scrollToRelative(float value) => ScrollTo(Clamp((value - Scrollbar.DrawSize[ScrollDim] / 2) / Scrollbar.Size[ScrollDim]), true, DistanceDecayOnRightMouseScrollbar);
|
||||
|
||||
@ -31,9 +30,9 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
if (shouldPerformRightMouseScroll(state))
|
||||
if (shouldPerformRightMouseScroll(e))
|
||||
{
|
||||
scrollToRelative(state.Mouse.Position[ScrollDim]);
|
||||
scrollToRelative(e.MousePosition[ScrollDim]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -44,7 +43,7 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
if (mouseScrollBarDragging)
|
||||
{
|
||||
scrollToRelative(e.Mouse.Position[ScrollDim]);
|
||||
scrollToRelative(e.MousePosition[ScrollDim]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
if (parallaxEnabled)
|
||||
{
|
||||
Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2) * ParallaxAmount;
|
||||
Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.Position) - DrawSize / 2) * ParallaxAmount;
|
||||
|
||||
double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000);
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
if (dragRotationState != DragRotationState.NotDragging)
|
||||
{
|
||||
var position = e.Mouse.Position;
|
||||
var position = e.MousePosition;
|
||||
var distance = Vector2Extensions.Distance(position, positionMouseDown);
|
||||
// don't start rotating until we're moved a minimum distance away from the mouse down location,
|
||||
// else it can have an annoying effect.
|
||||
@ -52,7 +52,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
// don't rotate when distance is zero to avoid NaN
|
||||
if (dragRotationState == DragRotationState.Rotating && distance > 0)
|
||||
{
|
||||
Vector2 offset = e.Mouse.Position - positionMouseDown;
|
||||
Vector2 offset = e.MousePosition - positionMouseDown;
|
||||
float degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f;
|
||||
|
||||
// Always rotate in the direction of least distance
|
||||
@ -83,14 +83,14 @@ namespace osu.Game.Graphics.Cursor
|
||||
if (e.Button == MouseButton.Left && cursorRotate)
|
||||
{
|
||||
dragRotationState = DragRotationState.DragStarted;
|
||||
positionMouseDown = state.Mouse.Position;
|
||||
positionMouseDown = e.MousePosition;
|
||||
}
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
if (!state.Mouse.HasMainButtonPressed)
|
||||
if (!e.CurrentState.Mouse.HasMainButtonPressed)
|
||||
{
|
||||
activeCursor.AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint);
|
||||
activeCursor.ScaleTo(1, 500, Easing.OutElastic);
|
||||
|
@ -34,7 +34,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (!state.Keyboard.ControlPressed && !state.Keyboard.ShiftPressed)
|
||||
var keyboard = e.CurrentState.Keyboard;
|
||||
if (!keyboard.ControlPressed && !keyboard.ShiftPressed)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
@ -56,7 +57,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (state.Keyboard.ShiftPressed)
|
||||
if (keyboard.ShiftPressed)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
|
@ -206,10 +206,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
if (isDragging)
|
||||
{
|
||||
Trace.Assert(e.Mouse.PositionMouseDown != null);
|
||||
|
||||
// ReSharper disable once PossibleInvalidOperationException
|
||||
double targetChatHeight = startDragChatHeight - (e.Mouse.Position.Y - e.Mouse.PositionMouseDown.Value.Y) / Parent.DrawSize.Y;
|
||||
double targetChatHeight = startDragChatHeight - (e.MousePosition.Y - e.MouseDownPosition.Y) / Parent.DrawSize.Y;
|
||||
|
||||
// If the channel selection screen is shown, mind its minimum height
|
||||
if (channelSelection.State == Visibility.Visible && targetChatHeight > 1f - channel_selection_min_height)
|
||||
|
@ -11,14 +11,12 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.States;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Input;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Input;
|
||||
using JoystickEventArgs = osu.Framework.Input.EventArgs.JoystickEventArgs;
|
||||
|
||||
namespace osu.Game.Overlays.KeyBinding
|
||||
{
|
||||
@ -166,14 +164,14 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
}
|
||||
}
|
||||
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState));
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
// don't do anything until the last button is released.
|
||||
if (!HasFocus || state.Mouse.Buttons.Any())
|
||||
if (!HasFocus || e.CurrentState.Mouse.HasAnyButtonPressed)
|
||||
return base.OnMouseUp(e);
|
||||
|
||||
if (bindTarget.IsHovered)
|
||||
@ -189,7 +187,7 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
{
|
||||
if (bindTarget.IsHovered)
|
||||
{
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e, e.Mouse.ScrollDelta));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState, e.ScrollDelta));
|
||||
finalise();
|
||||
return true;
|
||||
}
|
||||
@ -207,7 +205,7 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
{
|
||||
case Key.Delete:
|
||||
{
|
||||
if (state.Keyboard.ShiftPressed)
|
||||
if (e.CurrentState.Keyboard.ShiftPressed)
|
||||
{
|
||||
bindTarget.UpdateKeyCombination(InputKey.None);
|
||||
finalise();
|
||||
@ -218,7 +216,7 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
}
|
||||
}
|
||||
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState));
|
||||
if (!isModifier(e.Key)) finalise();
|
||||
|
||||
return true;
|
||||
@ -232,21 +230,21 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnJoystickPress(InputState state, JoystickEventArgs args)
|
||||
protected override bool OnJoystickPress(JoystickPressEvent e)
|
||||
{
|
||||
if (!HasFocus)
|
||||
return false;
|
||||
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state));
|
||||
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState));
|
||||
finalise();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnJoystickRelease(InputState state, JoystickEventArgs args)
|
||||
protected override bool OnJoystickRelease(JoystickReleaseEvent e)
|
||||
{
|
||||
if (!HasFocus)
|
||||
return base.OnJoystickRelease(args);
|
||||
return base.OnJoystickRelease(e);
|
||||
|
||||
finalise();
|
||||
return true;
|
||||
|
@ -183,7 +183,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected override void OnFocusLost(FocusLostEvent e)
|
||||
{
|
||||
if (e.Keyboard.Keys.Contains(Key.Escape)) dismiss();
|
||||
if (e.CurrentState.Keyboard.IsPressed(Key.Escape)) dismiss();
|
||||
}
|
||||
|
||||
private const double initial_duration = 400;
|
||||
|
@ -159,7 +159,7 @@ namespace osu.Game.Overlays.Mods
|
||||
scaleContainer.ScaleTo(1, 500, Easing.OutElastic);
|
||||
|
||||
// only trigger the event if we are inside the area of the button
|
||||
if (Contains(ToScreenSpace(state.Mouse.Position - Position)))
|
||||
if (Contains(e.ScreenSpaceMousePosition))
|
||||
{
|
||||
switch (e.Button)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
var index = Array.IndexOf(ToggleKeys, e.Key);
|
||||
if (index > -1 && index < buttons.Length)
|
||||
buttons[index].SelectNext(state.Keyboard.ShiftPressed ? -1 : 1);
|
||||
buttons[index].SelectNext(e.CurrentState.Keyboard.ShiftPressed ? -1 : 1);
|
||||
}
|
||||
|
||||
return base.OnKeyDown(e);
|
||||
|
@ -117,14 +117,14 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
protected override bool OnDragStart(DragStartEvent e)
|
||||
{
|
||||
nativeDragPosition = e.Mouse.NativeState.Position;
|
||||
nativeDragPosition = e.ScreenSpaceMousePosition;
|
||||
draggedItem = items.FirstOrDefault(d => d.IsDraggable);
|
||||
return draggedItem != null || base.OnDragStart(e);
|
||||
}
|
||||
|
||||
protected override bool OnDrag(DragEvent e)
|
||||
{
|
||||
nativeDragPosition = e.Mouse.NativeState.Position;
|
||||
nativeDragPosition = e.ScreenSpaceMousePosition;
|
||||
if (draggedItem == null)
|
||||
return base.OnDrag(e);
|
||||
return true;
|
||||
@ -132,7 +132,7 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
protected override bool OnDragEnd(DragEndEvent e)
|
||||
{
|
||||
nativeDragPosition = e.Mouse.NativeState.Position;
|
||||
nativeDragPosition = e.ScreenSpaceMousePosition;
|
||||
var handled = draggedItem != null || base.OnDragEnd(e);
|
||||
draggedItem = null;
|
||||
|
||||
|
@ -457,20 +457,14 @@ namespace osu.Game.Overlays
|
||||
|
||||
private class DragContainer : Container
|
||||
{
|
||||
private Vector2 dragStart;
|
||||
|
||||
protected override bool OnDragStart(DragStartEvent e)
|
||||
{
|
||||
base.OnDragStart(e);
|
||||
dragStart = e.Mouse.Position;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDrag(DragEvent e)
|
||||
{
|
||||
if (base.OnDrag(e)) return true;
|
||||
|
||||
Vector2 change = e.Mouse.Position - dragStart;
|
||||
Vector2 change = e.MousePosition - e.MouseDownPosition;
|
||||
|
||||
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
|
||||
change *= change.Length <= 0 ? 0 : (float)Math.Pow(change.Length, 0.7f) / change.Length;
|
||||
|
@ -141,7 +141,7 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
if (ranks?.Length > 1)
|
||||
{
|
||||
graph.UpdateBallPosition(e.Mouse.Position.X);
|
||||
graph.UpdateBallPosition(e.MousePosition.X);
|
||||
graph.ShowBall();
|
||||
}
|
||||
return base.OnHover(e);
|
||||
@ -150,7 +150,7 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
if (ranks?.Length > 1)
|
||||
graph.UpdateBallPosition(e.Mouse.Position.X);
|
||||
graph.UpdateBallPosition(e.MousePosition.X);
|
||||
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
|
||||
if (state.Keyboard.ControlPressed && !e.Repeat && e.Key >= Key.Number1 && e.Key <= Key.Number9)
|
||||
if (e.CurrentState.Keyboard.ControlPressed && !e.Repeat && e.Key >= Key.Number1 && e.Key <= Key.Number9)
|
||||
{
|
||||
int requested = e.Key - Key.Number1;
|
||||
|
||||
|
@ -241,7 +241,7 @@ namespace osu.Game.Overlays.Volume
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
adjust(e.Mouse.ScrollDelta.Y, e.Mouse.HasPreciseScroll);
|
||||
adjust(e.ScrollDelta.Y, e.IsPrecise);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <summary>
|
||||
/// Invoked when this <see cref="HitObjectMask"/> has requested drag.
|
||||
/// </summary>
|
||||
public event Action<HitObjectMask, InputState> DragRequested;
|
||||
public event Action<HitObjectMask, Vector2, InputState> DragRequested;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DrawableHitObject"/> which this <see cref="HitObjectMask"/> applies to.
|
||||
@ -102,7 +102,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
if (State == SelectionState.NotSelected)
|
||||
{
|
||||
SelectionRequested?.Invoke(this, state);
|
||||
SelectionRequested?.Invoke(this, e.CurrentState);
|
||||
selectionRequested = true;
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
if (State == SelectionState.Selected && !selectionRequested)
|
||||
{
|
||||
selectionRequested = true;
|
||||
SelectionRequested?.Invoke(this, e);
|
||||
SelectionRequested?.Invoke(this, e.CurrentState);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
protected override bool OnDrag(DragEvent e)
|
||||
{
|
||||
DragRequested?.Invoke(this, e);
|
||||
DragRequested?.Invoke(this, e.Delta, e.CurrentState);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,9 @@ using osu.Game.Input.Handlers;
|
||||
using osu.Game.Screens.Play;
|
||||
using OpenTK.Input;
|
||||
using static osu.Game.Input.Handlers.ReplayInputHandler;
|
||||
using JoystickState = osu.Framework.Input.States.JoystickState;
|
||||
using KeyboardState = osu.Framework.Input.States.KeyboardState;
|
||||
using MouseState = osu.Framework.Input.States.MouseState;
|
||||
|
||||
namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
@ -35,13 +38,7 @@ namespace osu.Game.Rulesets.UI
|
||||
protected override InputState CreateInitialState()
|
||||
{
|
||||
var state = base.CreateInitialState();
|
||||
return new RulesetInputManagerInputState<T>
|
||||
{
|
||||
Mouse = state.Mouse,
|
||||
Keyboard = state.Keyboard,
|
||||
Joystick = state.Joystick,
|
||||
LastReplayState = null
|
||||
};
|
||||
return new RulesetInputManagerInputState<T>(state.Mouse, state.Keyboard, state.Joystick);
|
||||
}
|
||||
|
||||
protected readonly KeyBindingContainer<T> KeyBindingContainer;
|
||||
@ -275,5 +272,10 @@ namespace osu.Game.Rulesets.UI
|
||||
where T : struct
|
||||
{
|
||||
public ReplayState<T> LastReplayState;
|
||||
|
||||
public RulesetInputManagerInputState(MouseState mouse = null, KeyboardState keyboard = null, JoystickState joystick = null)
|
||||
: base(mouse, keyboard, joystick)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,13 +33,13 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
protected override bool OnDragEnd(DragEndEvent e) => true;
|
||||
protected override bool OnDrag(DragEvent e)
|
||||
{
|
||||
seekToPosition(e.Mouse.NativeState.Position);
|
||||
seekToPosition(e.ScreenSpaceMousePosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
seekToPosition(state.Mouse.NativeState.Position);
|
||||
seekToPosition(e.ScreenSpaceMousePosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
if (e.Mouse.ScrollDelta.X + e.Mouse.ScrollDelta.Y > 0)
|
||||
if (e.ScrollDelta.X + e.ScrollDelta.Y > 0)
|
||||
clock.SeekBackward(!clock.IsRunning);
|
||||
else
|
||||
clock.SeekForward(!clock.IsRunning);
|
||||
|
@ -13,7 +13,6 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.States;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK;
|
||||
@ -264,20 +263,20 @@ namespace osu.Game.Screens.Edit.Screens.Compose
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
handleMouseInput(e);
|
||||
handleMouseInput(e.ScreenSpaceMousePosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDrag(DragEvent e)
|
||||
{
|
||||
handleMouseInput(e);
|
||||
handleMouseInput(e.ScreenSpaceMousePosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void handleMouseInput(InputState state)
|
||||
private void handleMouseInput(Vector2 screenSpaceMousePosition)
|
||||
{
|
||||
// copied from SliderBar so we can do custom spacing logic.
|
||||
var xPosition = (ToLocalSpace(state?.Mouse.NativeState.Position ?? Vector2.Zero).X - RangePadding) / UsableWidth;
|
||||
var xPosition = (ToLocalSpace(screenSpaceMousePosition).X - RangePadding) / UsableWidth;
|
||||
|
||||
CurrentNumber.Value = availableDivisors.OrderBy(d => Math.Abs(getMappedPosition(d) - xPosition)).First();
|
||||
OnUserChange();
|
||||
|
@ -64,8 +64,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
|
||||
protected override bool OnDrag(DragEvent e)
|
||||
{
|
||||
var dragPosition = e.Mouse.NativeState.Position;
|
||||
var dragStartPosition = e.Mouse.NativeState.PositionMouseDown ?? dragPosition;
|
||||
var dragPosition = e.ScreenSpaceMousePosition;
|
||||
var dragStartPosition = e.ScreenSpaceMouseDownPosition;
|
||||
|
||||
var dragQuad = new Quad(dragStartPosition.X, dragStartPosition.Y, dragPosition.X - dragStartPosition.X, dragPosition.Y - dragStartPosition.Y);
|
||||
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.States;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using OpenTK;
|
||||
using RectangleF = osu.Framework.Graphics.Primitives.RectangleF;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
@ -32,7 +33,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
/// <summary>
|
||||
/// Invoked when any <see cref="HitObjectMask"/> requests drag.
|
||||
/// </summary>
|
||||
public event Action<HitObjectMask, InputState> MaskDragRequested;
|
||||
public event Action<HitObjectMask, Vector2, InputState> MaskDragRequested;
|
||||
|
||||
private IEnumerable<HitObjectMask> aliveMasks => AliveInternalChildren.Cast<HitObjectMask>();
|
||||
|
||||
@ -103,7 +104,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
}
|
||||
|
||||
private void onSelectionRequested(HitObjectMask mask, InputState state) => MaskSelectionRequested?.Invoke(mask, state);
|
||||
private void onDragRequested(HitObjectMask mask, InputState state) => MaskDragRequested?.Invoke(mask, state);
|
||||
private void onDragRequested(HitObjectMask mask, Vector2 delta, InputState state) => MaskDragRequested?.Invoke(mask, delta, state);
|
||||
|
||||
protected override int Compare(Drawable x, Drawable y)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
|
||||
#region User Input Handling
|
||||
|
||||
public void HandleDrag(HitObjectMask m, InputState state)
|
||||
public void HandleDrag(HitObjectMask m, Vector2 delta, InputState state)
|
||||
{
|
||||
// Todo: Various forms of snapping
|
||||
|
||||
@ -63,7 +63,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
switch (mask.HitObject.HitObject)
|
||||
{
|
||||
case IHasEditablePosition editablePosition:
|
||||
editablePosition.OffsetPosition(state.Mouse.Delta);
|
||||
editablePosition.OffsetPosition(delta);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -99,11 +99,11 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
if (e.Mouse.HasPreciseScroll)
|
||||
if (e.IsPrecise)
|
||||
// for now, we don't support zoom when using a precision scroll device. this needs gesture support.
|
||||
return base.OnScroll(e);
|
||||
|
||||
setZoomTarget(zoomTarget + e.Mouse.ScrollDelta.Y, zoomedContent.ToLocalSpace(e.Mouse.NativeState.Position).X);
|
||||
setZoomTarget(zoomTarget + e.ScrollDelta.Y, zoomedContent.ToLocalSpace(e.ScreenSpaceMousePosition).X);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.Repeat || state.Keyboard.ControlPressed || state.Keyboard.ShiftPressed || state.Keyboard.AltPressed)
|
||||
var keyboard = e.CurrentState.Keyboard;
|
||||
if (e.Repeat || keyboard.ControlPressed || keyboard.ShiftPressed || keyboard.AltPressed)
|
||||
return false;
|
||||
|
||||
if (triggerKey == e.Key && triggerKey != Key.Unknown)
|
||||
|
@ -201,7 +201,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (!e.Repeat && state.Keyboard.ControlPressed && state.Keyboard.ShiftPressed && e.Key == Key.D)
|
||||
var keyboard = e.CurrentState.Keyboard;
|
||||
if (!e.Repeat && keyboard.ControlPressed && keyboard.ShiftPressed && e.Key == Key.D)
|
||||
{
|
||||
Push(new Drawings());
|
||||
return true;
|
||||
|
@ -295,7 +295,7 @@ namespace osu.Game.Screens.Play
|
||||
if (e.Repeat || e.Key != Key.Enter || !Selected)
|
||||
return false;
|
||||
|
||||
OnClick(state);
|
||||
Click();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
if (e.Repeat) return false;
|
||||
|
||||
if (state.Keyboard.ControlPressed)
|
||||
if (e.CurrentState.Keyboard.ControlPressed)
|
||||
{
|
||||
if (e.Key == Key.H && ReplayLoaded)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -62,7 +63,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
positionalAdjust = Vector2.Distance(e.Mouse.NativeState.Position, button.ScreenSpaceDrawQuad.Centre) / 200;
|
||||
positionalAdjust = Vector2.Distance(e.ScreenSpaceMousePosition, button.ScreenSpaceDrawQuad.Centre) / 200;
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
@ -182,14 +183,14 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
if (!pendingAnimation && state.Mouse.Buttons.Count() == 1)
|
||||
if (!pendingAnimation && e.CurrentState.Mouse.Buttons.Count() == 1)
|
||||
BeginConfirm();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
if (!state.Mouse.Buttons.Any())
|
||||
if (!e.CurrentState.Mouse.Buttons.Any())
|
||||
AbortConfirm();
|
||||
return true;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (e.Repeat) return false;
|
||||
|
||||
if (state.Keyboard.ShiftPressed)
|
||||
if (e.CurrentState.Keyboard.ShiftPressed)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
|
@ -130,7 +130,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
if (!e.Mouse.HasAnyButtonPressed)
|
||||
if (!e.CurrentState.Mouse.HasAnyButtonPressed)
|
||||
fadeContainer.State = Visibility.Visible;
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
if (!e.Repeat && e.Key == Hotkey)
|
||||
{
|
||||
OnClick(state);
|
||||
Click();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ namespace osu.Game.Screens.Select.Options
|
||||
{
|
||||
if (!e.Repeat && e.Key == HotKey)
|
||||
{
|
||||
OnClick(state);
|
||||
Click();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -560,7 +560,7 @@ namespace osu.Game.Screens.Select
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Delete:
|
||||
if (state.Keyboard.ShiftPressed)
|
||||
if (e.CurrentState.Keyboard.ShiftPressed)
|
||||
{
|
||||
if (!Beatmap.IsDefault)
|
||||
delete(Beatmap.Value.BeatmapSetInfo);
|
||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
if (e.Mouse.ScrollDelta.Y > 0)
|
||||
if (e.ScrollDelta.Y > 0)
|
||||
Clock.SeekBackward(true);
|
||||
else
|
||||
Clock.SeekForward(true);
|
||||
|
Loading…
Reference in New Issue
Block a user