feat: Double-click equipped item to unequip

This commit is contained in:
2026-01-03 00:38:19 +01:00
parent 070d4fa0f8
commit 00be3b066e
2 changed files with 20 additions and 9 deletions

7
.idea/misc.xml generated
View File

@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<writeAnnotations>
<writeAnnotation name="cz.jzitnik.annotations.injectors.InjectConfig" />
<writeAnnotation name="cz.jzitnik.annotations.injectors.InjectDependency" />
<writeAnnotation name="cz.jzitnik.annotations.injectors.InjectState" />
</writeAnnotations>
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">

View File

@@ -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;
}
}