Multi-window input handling. (#3911)

This commit is contained in:
Pieter-Jan Briers
2021-05-02 20:48:00 +02:00
committed by GitHub
parent 31c5b18fe2
commit d796dcfcca
12 changed files with 18 additions and 18 deletions

View File

@@ -104,14 +104,14 @@ namespace Content.Client
label.Measure(Vector2.Infinity);
var minimumSize = label.DesiredSize;
label.InitialPos = (coordinates.Position / _userInterfaceManager.UIScale) - minimumSize / 2;
label.InitialPos = (coordinates.Position / label.UIScale) - minimumSize / 2;
LayoutContainer.SetPosition(label, label.InitialPos);
_aliveLabels.Add(label);
}
public void PopupMessage(string message)
{
PopupMessage(new ScreenCoordinates(_userInterfaceManager.MousePositionScaled), message);
PopupMessage(_userInterfaceManager.MousePositionScaled, message);
}
public void FrameUpdate(FrameEventArgs eventArgs)

View File

@@ -210,7 +210,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
}
var screenCoordinates = _eyeManager.CoordinatesToScreen(AttachedEntity.Transform.Coordinates);
_playerPosition = new ScreenCoordinates(screenCoordinates.X / UIScale, screenCoordinates.Y / UIScale);
_playerPosition = new ScreenCoordinates(screenCoordinates.Position / UIScale, screenCoordinates.Window);
LayoutContainer.SetPosition(this, new Vector2(_playerPosition.X - Width / 2, _playerPosition.Y - Height - 30.0f));
}
}

View File

@@ -96,7 +96,7 @@ namespace Content.Client.GameObjects.EntitySystems
panel.Measure(Vector2.Infinity);
var size = Vector2.ComponentMax((minWidth, 0), panel.DesiredSize);
_examineTooltipOpen.Open(UIBox2.FromDimensions(popupPos, size));
_examineTooltipOpen.Open(UIBox2.FromDimensions(popupPos.Position, size));
FormattedMessage message;
if (entity.Uid.IsClientSide())

View File

@@ -147,7 +147,7 @@ namespace Content.Client.GameObjects.EntitySystems.HealthOverlay
Visible = true;
var screenCoordinates = _eyeManager.CoordinatesToScreen(Entity.Transform.Coordinates);
var playerPosition = new ScreenCoordinates(screenCoordinates.X / UIScale, screenCoordinates.Y / UIScale);
var playerPosition = UserInterfaceManager.ScreenToUIPosition(screenCoordinates);
LayoutContainer.SetPosition(this, new Vector2(playerPosition.X - Width / 2, playerPosition.Y - Height - 30.0f));
}

View File

@@ -119,7 +119,7 @@ namespace Content.Client.GameObjects.EntitySystems
public void OnContextButtonPressed(IEntity entity)
{
OpenContextMenu(entity, new ScreenCoordinates(_userInterfaceManager.MousePositionScaled));
OpenContextMenu(entity, _userInterfaceManager.MousePositionScaled);
}
private void FillEntityPopup(VerbSystemMessages.VerbsResponseMessage msg)

View File

@@ -72,7 +72,7 @@ namespace Content.Client.State
var renderScale = 1;
if (UserInterfaceManager.CurrentlyHovered is IViewportControl vp)
{
var mousePosWorld = vp.ScreenToMap(InputManager.MouseScreenPosition);
var mousePosWorld = vp.ScreenToMap(InputManager.MouseScreenPosition.Position);
entityToClick = GetEntityUnderPosition(mousePosWorld);
if (vp is ScalingViewport svp)

View File

@@ -198,14 +198,14 @@ namespace Content.Client.UserInterface
{
_dragShadow.Texture = _dragDropHelper.Dragged!.Action.Icon.Frame0();
// don't make visible until frameupdate, otherwise it'll flicker
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled - (32, 32));
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled.Position - (32, 32));
return true;
}
private bool OnContinueActionDrag(float frameTime)
{
// keep dragged entity centered under mouse
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled - (32, 32));
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled.Position - (32, 32));
// we don't set this visible until frameupdate, otherwise it flickers
_dragShadow.Visible = true;
return true;

View File

@@ -533,7 +533,7 @@ namespace Content.Client.UserInterface
if (Locked || DragDropHelper.Dragged?.Action == null) return false;
_dragShadow.Texture = DragDropHelper.Dragged.Action.Icon.Frame0();
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled - (32, 32));
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled.Position - (32, 32));
DragDropHelper.Dragged.CancelPress();
return true;
}
@@ -544,7 +544,7 @@ namespace Content.Client.UserInterface
if (Locked || DragDropHelper.Dragged?.Action == null) return false;
// keep dragged entity centered under mouse
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled - (32, 32));
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled.Position - (32, 32));
// we don't set this visible until frameupdate, otherwise it flickers
_dragShadow.Visible = true;
return true;

View File

@@ -79,7 +79,7 @@ namespace Content.Client.UserInterface.ContextMenu
_userInterfaceManager.ModalRoot.AddChild(rootContextMenu);
var size = rootContextMenu.List.CombinedMinimumSize;
var box = UIBox2.FromDimensions(_userInterfaceManager.MousePositionScaled, size);
var box = UIBox2.FromDimensions(_userInterfaceManager.MousePositionScaled.Position, size);
rootContextMenu.Open(box);
}
public void AddChildMenu(IEnumerable<IEntity> entities, Vector2 position, StackContextElement? stack)

View File

@@ -59,7 +59,7 @@ namespace Content.Client.UserInterface
else if (args.Function == ContentKeyFunctions.OpenContextMenu)
{
_entitySystemManager.GetEntitySystem<VerbSystem>()
.OpenContextMenu(item, new ScreenCoordinates(_uiMgr.ScreenToUIPosition(args.PointerLocation)));
.OpenContextMenu(item, _uiMgr.ScreenToUIPosition(args.PointerLocation));
}
else if (args.Function == ContentKeyFunctions.ActivateItemInWorld)
{

View File

@@ -1,6 +1,6 @@
using Robust.Client.Input;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Map;
namespace Content.Client.Utility
{
@@ -33,7 +33,7 @@ namespace Content.Client.Utility
/// <summary>
/// Convenience method, current mouse screen position as provided by inputmanager.
/// </summary>
public Vector2 MouseScreenPosition => _inputManager.MouseScreenPosition;
public ScreenCoordinates MouseScreenPosition => _inputManager.MouseScreenPosition;
/// <summary>
/// True if initiated a drag and currently dragging something.
@@ -48,7 +48,7 @@ namespace Content.Client.Utility
public T? Dragged { get; private set; }
// screen pos where the mouse down began for the drag
private Vector2 _mouseDownScreenPos;
private ScreenCoordinates _mouseDownScreenPos;
private DragState _state = DragState.NotDragging;
private enum DragState : byte
@@ -128,7 +128,7 @@ namespace Content.Client.Utility
case DragState.MouseDown:
{
var screenPos = _inputManager.MouseScreenPosition;
if ((_mouseDownScreenPos - screenPos).Length > _deadzone)
if ((_mouseDownScreenPos.Position - screenPos.Position).Length > _deadzone)
{
StartDragging();
}