feat(ui): port retail radar and compass
This commit is contained in:
parent
c4af181b92
commit
3cbe4b00a1
43 changed files with 2882 additions and 262 deletions
|
|
@ -187,6 +187,59 @@ public class UiRootInputTests
|
|||
Assert.Equal(80f, panel.Top);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WindowDrag_ConstrainedPanel_StaysFullyInsideParent()
|
||||
{
|
||||
var root = new UiRoot { Width = 200, Height = 150 };
|
||||
var panel = new UiPanel
|
||||
{
|
||||
Left = 10,
|
||||
Top = 10,
|
||||
Width = 120,
|
||||
Height = 100,
|
||||
Draggable = true,
|
||||
ConstrainDragToParent = true,
|
||||
};
|
||||
root.AddChild(panel);
|
||||
root.RegisterWindow("radar", panel);
|
||||
(string name, UiElement window)? moved = null;
|
||||
root.WindowMoved += (name, window) => moved = (name, window);
|
||||
|
||||
root.OnMouseDown(UiMouseButton.Left, 20, 20);
|
||||
root.OnMouseMove(500, 500);
|
||||
Assert.Equal(80f, panel.Left);
|
||||
Assert.Equal(50f, panel.Top);
|
||||
|
||||
root.OnMouseMove(-500, -500);
|
||||
Assert.Equal(0f, panel.Left);
|
||||
Assert.Equal(0f, panel.Top);
|
||||
root.OnMouseUp(UiMouseButton.Left, -500, -500);
|
||||
Assert.Equal("radar", moved?.name);
|
||||
Assert.Same(panel, moved?.window);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UiLocked_BlocksWindowMoveWithoutDisablingWindow()
|
||||
{
|
||||
var root = new UiRoot { Width = 200, Height = 150, UiLocked = true };
|
||||
var panel = new UiPanel
|
||||
{
|
||||
Left = 10,
|
||||
Top = 10,
|
||||
Width = 100,
|
||||
Height = 60,
|
||||
Draggable = true,
|
||||
};
|
||||
root.AddChild(panel);
|
||||
|
||||
root.OnMouseDown(UiMouseButton.Left, 20, 20);
|
||||
root.OnMouseMove(100, 100);
|
||||
|
||||
Assert.Equal(10f, panel.Left);
|
||||
Assert.Equal(10f, panel.Top);
|
||||
Assert.True(panel.Enabled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NonDraggablePanel_DoesNotMoveOnDrag()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue