feat: Double-click equipped item to unequip
This commit is contained in:
@@ -134,19 +134,23 @@ public class Inventory implements GlobalUIClickHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (inventoryState.isGonnaDoubleclick) {
|
||||
inventoryState.isGonnaDoubleclick = false;
|
||||
if (inventoryState.isGonnaDoubleClick) {
|
||||
inventoryState.isGonnaDoubleClick = false;
|
||||
inventoryState.selectedItem = -1;
|
||||
gameState.getPlayer().setSelectedItem(inventory[itemClickedOnIndex]);
|
||||
gameState.getPlayer().setSelectedItem(
|
||||
gameState.getPlayer().getSelectedItem() == inventory[itemClickedOnIndex]
|
||||
? null
|
||||
: inventory[itemClickedOnIndex]
|
||||
);
|
||||
eventManager.emitEvent(new InventoryRerender());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inventoryState.isGonnaDoubleclick = true;
|
||||
inventoryState.isGonnaDoubleClick = true;
|
||||
log.debug("Gonna doubleclick: {}", true);
|
||||
scheduler.schedule(() -> {
|
||||
inventoryState.isGonnaDoubleclick = false;
|
||||
inventoryState.isGonnaDoubleClick = false;
|
||||
log.debug("Gonna doubleclick: {}", false);
|
||||
}, 200, TimeUnit.MILLISECONDS);
|
||||
|
||||
@@ -288,9 +292,9 @@ public class Inventory implements GlobalUIClickHandler {
|
||||
int bottomG = bottomPixel.getColor().getGreen();
|
||||
int bottomB = bottomPixel.getColor().getBlue();
|
||||
|
||||
int finalR = (int)(topR * topOpacity + bottomR * (1 - topOpacity));
|
||||
int finalG = (int)(topG * topOpacity + bottomG * (1 - topOpacity));
|
||||
int finalB = (int)(topB * topOpacity + bottomB * (1 - topOpacity));
|
||||
int finalR = (int) (topR * topOpacity + bottomR * (1 - topOpacity));
|
||||
int finalG = (int) (topG * topOpacity + bottomG * (1 - topOpacity));
|
||||
int finalB = (int) (topB * topOpacity + bottomB * (1 - topOpacity));
|
||||
|
||||
internalBuffer[y + offsetY][x + offsetX] = new ColoredPixel(new TextColor.RGB(finalR, finalG, finalB));
|
||||
}
|
||||
@@ -309,6 +313,6 @@ public class Inventory implements GlobalUIClickHandler {
|
||||
protected TerminalPosition draggingItemPosition;
|
||||
protected int onNextDragTakeItemOnIndex = -1;
|
||||
protected int draggingItemOriginalIndex = -1;
|
||||
protected boolean isGonnaDoubleclick = false;
|
||||
protected boolean isGonnaDoubleClick = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user