Skip to content

Commit

Permalink
Improved cursor hiding when clicking on scrollbars
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrdacor committed Sep 1, 2020
1 parent 6e96af4 commit fd9065f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Ambermoon.Core/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,11 @@ public void OnMouseDown(Position position, MouseButtons buttons)
else
{
var cursorType = CursorType.Sword;
layout.Click(relativePosition, buttons);
layout.Hover(relativePosition, ref cursorType); // Update cursor
layout.Click(relativePosition, buttons, ref cursorType);
cursor.Type = cursorType;
layout.Hover(relativePosition, ref cursorType); // Update cursor
if (cursor.Type != CursorType.None)
cursor.Type = cursorType;

// TODO: check for other clicks
}
Expand Down
4 changes: 3 additions & 1 deletion Ambermoon.Core/UI/ItemGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void LeftMouseUp(Position position)
}

public bool Click(Game game, Position position, Layout.DraggedItem draggedItem,
out Layout.DraggedItem pickedUpItem, bool leftMouseButton)
out Layout.DraggedItem pickedUpItem, bool leftMouseButton, ref CursorType cursorType)
{
pickedUpItem = draggedItem;

Expand All @@ -266,6 +266,8 @@ public bool Click(Game game, Position position, Layout.DraggedItem draggedItem,
draggedItem.Item.Visible = false;
}

cursorType = CursorType.None;

return true;
}

Expand Down
6 changes: 3 additions & 3 deletions Ambermoon.Core/UI/Layout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,14 +497,14 @@ public void LeftMouseUp(Position position)
itemGrid.LeftMouseUp(position);
}

public bool Click(Position position, MouseButtons buttons)
public bool Click(Position position, MouseButtons buttons, ref CursorType cursorType)
{
if (buttons == MouseButtons.Left)
{
foreach (var itemGrid in itemGrids)
{
// TODO: If stacked it should ask for amount with left mouse
if (itemGrid.Click(game, position, draggedItem, out DraggedItem pickedUpItem, true))
if (itemGrid.Click(game, position, draggedItem, out DraggedItem pickedUpItem, true, ref cursorType))
{
DraggedItem dropped = (draggedItem != null && (pickedUpItem == null || pickedUpItem != draggedItem ||
pickedUpItem.Item.Item.Amount != draggedItem.Item.Item.Amount)) ? draggedItem : null;
Expand Down Expand Up @@ -534,7 +534,7 @@ public bool Click(Position position, MouseButtons buttons)
{
foreach (var itemGrid in itemGrids)
{
if (itemGrid.Click(game, position, null, out DraggedItem pickedUpItem, false))
if (itemGrid.Click(game, position, null, out DraggedItem pickedUpItem, false, ref cursorType))
{
if (pickedUpItem != null)
{
Expand Down

0 comments on commit fd9065f

Please sign in to comment.