Skip to content

Commit

Permalink
fix(input): cancel eyedrop when changing toolbar index (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenira committed Mar 11, 2024
1 parent c7b3d39 commit 7f4f7c7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plugin/src/input/ui/ToolbarInteractableUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ private Interactable getInteractable(ToolbarSlotUI uiSlot)
private void onClick(ToolbarSlotUI uiSlot)
{
Logger.LogDebug($"Clicked toolbar slot {uiSlot.slotIndex} {uiSlot.primaryToolbar}");

Player.instance.builder.ExitEyeDropperMode();

if (isSelected(uiSlot) && !Player.instance.toolbar.IsToolbarHidden)
{
Player.instance.toolbar.TogglePutAway();
return;
}

selectSlot(uiSlot);
}

Expand Down Expand Up @@ -120,6 +129,11 @@ private int getToolbarIndex(ToolbarSlotUI slot)
return slot.primaryToolbar ? Player.instance.toolbar.selectedToolbar : Player.instance.toolbar.secondaryToolbar;
}

private bool isSelected(ToolbarSlotUI slot)
{
return Player.instance.toolbar._primaryToolbarSelected == slot.primaryToolbar && Player.instance.toolbar.selectedIndex == slot.slotIndex;
}

private ResourceInfo getSlotResource(ToolbarSlotUI slot)
{
return slot.setResource;
Expand Down

0 comments on commit 7f4f7c7

Please sign in to comment.