[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / input / handler / mouse / SelectCreativeInventoryItemMouseInputHandler.kt
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectCreativeInventoryItemMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectCreativeInventoryItemMouseInputHandler.kt
index 5e6402731670b079ba6c294ee271c036ab28022a..7c587b67b7162415ecceeb9525ce568fcdb2831c 100644 (file)
override fun checkConditions(action: MouseInputAction): Boolean {
return gameWindowsManager.getCurrentWindow() == GameUiWindow.CREATIVE_INVENTORY &&
!gameWindowsManager.isDragging &&
- action.actionKey is MouseInputActionKey.Left &&
+ (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Touch) &&
action.actionKey.touchUp && isInsideWindow(action, creativeInventoryTexture)
}
val itemIndex = (gameWindowsManager.creativeScrollAmount * GameWindowsConfigs.Creative.itemsInRow +
(xOnGrid.toInt() + yOnGrid.toInt() * GameWindowsConfigs.Creative.itemsInRow))
-
- mobsController.player.inventory.copyInto(
- destination = mobsController.player.inventory,
- destinationOffset = 1,
- startIndex = 0,
- endIndex = mobsController.player.inventory.size - 2
- )
-
val item = gameItemsHolder.getItemFromCreativeInventory(itemIndex)
- mobsController.player.inventory[0] = item.toInventoryItem(amount = item.params.maxStack)
+ mobsController.player.inventory.reverse()
+ mobsController.player.inventory.add(item.toInventoryItem(amount = item.params.maxStack))
+ mobsController.player.inventory.reverse()
+
+ if (mobsController.player.inventory.size > 36) {
+ mobsController.player.inventory.dropLast(mobsController.player.inventory.size - 36)
+ }
}
}
\ No newline at end of file