From f353e00257a70bb9cdee0e783558c68f5cb0d3d6 Mon Sep 17 00:00:00 2001 From: fredboy Date: Thu, 9 May 2024 15:19:01 +0700 Subject: [PATCH] Better touch inventory controls --- .../OpenInventoryKeyboardInputHandler.kt | 2 +- .../ToggleControlsModeKeyboardInputHandler.kt | 2 +- .../mouse/CloseGameWindowMouseInputHandler.kt | 7 +- ...tCraftingInventoryItemMouseInputHandler.kt | 83 ++++++++++--------- ...tSurvivalInventoryItemMouseInputHandler.kt | 83 ++++++++++--------- .../handler/touch/JoystickInputHandler.kt | 5 +- .../game/ui/windows/GameWindowsManager.kt | 6 +- .../inventory/AbstractInventoryWindow.kt | 41 +++++++++ .../inventory/CraftingInventoryWindow.kt | 6 +- .../inventory/CreativeInventoryWindow.kt | 7 +- .../inventory/SurvivalInventoryWindow.kt | 6 +- 11 files changed, 147 insertions(+), 101 deletions(-) diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/OpenInventoryKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/OpenInventoryKeyboardInputHandler.kt index 50aa5b0..ce70054 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/OpenInventoryKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/OpenInventoryKeyboardInputHandler.kt @@ -17,7 +17,7 @@ class OpenInventoryKeyboardInputHandler @Inject constructor( override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.OpenInventory && - action.isKeyDown && gameWindowsManager.getCurrentWindow() == GameUiWindow.NONE + !action.isKeyDown && gameWindowsManager.getCurrentWindow() == GameUiWindow.NONE } override fun handle(action: KeyboardInputAction) { diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleControlsModeKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleControlsModeKeyboardInputHandler.kt index 0f656d8..fc95e29 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleControlsModeKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleControlsModeKeyboardInputHandler.kt @@ -16,7 +16,7 @@ class ToggleControlsModeKeyboardInputHandler @Inject constructor( ) : IGameInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { - return action.actionKey is KeyboardInputActionKey.SwitchControlsMode && action.isKeyDown + return action.actionKey is KeyboardInputActionKey.SwitchControlsMode && !action.isKeyDown && mainConfig.isTouch } diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt index 8a7fdb4..ffda344 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt @@ -27,7 +27,7 @@ class CloseGameWindowMouseInputHandler @Inject constructor( override fun checkConditions(action: MouseInputAction): Boolean { return gameWindowsManager.getCurrentWindow() != GameUiWindow.NONE && (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Screen) && - !action.actionKey.touchUp && + action.actionKey.touchUp && !isInsideWindow(action, getCurrentWindowTexture()) } @@ -43,13 +43,12 @@ class CloseGameWindowMouseInputHandler @Inject constructor( override fun handle(action: MouseInputAction) { val selectedItem = gameWindowsManager.currentWindow?.selectedItem if (selectedItem != null) { - for (i in 1 .. selectedItem.amount) { dropController.addDrop( /* x = */ mobsController.player.x + (32f * mobsController.player.direction.basis), /* y = */ mobsController.player.y, - /* item = */ selectedItem.item + /* item = */ selectedItem.item, + /* count = */ selectedItem.amount, ) - } gameWindowsManager.currentWindow?.selectedItem = null } gameWindowsManager.closeWindow() diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectCraftingInventoryItemMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectCraftingInventoryItemMouseInputHandler.kt index 4898150..b3fb223 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectCraftingInventoryItemMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectCraftingInventoryItemMouseInputHandler.kt @@ -10,6 +10,7 @@ import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey import ru.deadsoftware.cavedroid.game.input.isInsideWindow import ru.deadsoftware.cavedroid.game.mobs.MobsController import ru.deadsoftware.cavedroid.game.model.item.InventoryItem +import ru.deadsoftware.cavedroid.game.objects.DropController import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsConfigs import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager import ru.deadsoftware.cavedroid.game.ui.windows.inventory.CraftingInventoryWindow @@ -21,6 +22,7 @@ class SelectCraftingInventoryItemMouseInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, private val gameItemsHolder: GameItemsHolder, + private val dropController: DropController, ) : IGameInputHandler { private val survivalWindowTexture get() = requireNotNull(Assets.textureRegions["survival"]) @@ -29,38 +31,7 @@ class SelectCraftingInventoryItemMouseInputHandler @Inject constructor( return gameWindowsManager.getCurrentWindow() == GameUiWindow.CRAFTING_TABLE && isInsideWindow(action, survivalWindowTexture) && (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Right || action.actionKey is MouseInputActionKey.Screen) - && action.actionKey.touchUp - } - - private fun onLeftCLick(items: MutableList, window: CraftingInventoryWindow, index: Int) { - val selectedItem = window.selectedItem - val clickedItem = items[index] - - if (clickedItem != null && selectedItem != null && items[index]!!.item == selectedItem.item && - items[index]!!.amount + selectedItem.amount <= selectedItem.item.params.maxStack) { - items[index]!!.amount += selectedItem.amount - window.selectedItem = null - return - } - - val item = items[index] - items[index] = selectedItem ?: gameItemsHolder.fallbackItem.toInventoryItem() - window.selectedItem = item - } - - private fun onRightClick(items: MutableList, window: CraftingInventoryWindow, index: Int) { - val clickedItem = items[index] - val selectedItem = window.selectedItem - ?.takeIf { clickedItem == null || clickedItem.item.isNone() || it.item == items[index]!!.item && items[index]!!.amount + 1 < it.item.params.maxStack } - ?: return - - val newItem = selectedItem.item.toInventoryItem((clickedItem?.takeIf { !it.item.isNone() }?.amount ?: 0) + 1) - items[index] = newItem - selectedItem.amount -- - - if (selectedItem.amount <= 0) { - window.selectedItem = null - } + && (action.actionKey.touchUp || action.actionKey is MouseInputActionKey.Screen) } private fun handleInsideInventoryGrid(action: MouseInputAction, xOnGrid: Int, yOnGrid: Int) { @@ -69,14 +40,24 @@ class SelectCraftingInventoryItemMouseInputHandler @Inject constructor( var itemIndex = ((xOnGrid.toInt() + yOnGrid.toInt() * GameWindowsConfigs.Crafting.itemsInRow)) itemIndex += GameWindowsConfigs.Crafting.hotbarCells - if (itemIndex >= 36) { - itemIndex -= 36 + if (itemIndex >= mobsController.player.inventory.size) { + itemIndex -= mobsController.player.inventory.size } - if (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Screen) { - onLeftCLick(mobsController.player.inventory.items as MutableList, window, itemIndex) + if (action.actionKey is MouseInputActionKey.Screen) { + if (!action.actionKey.touchUp) { + window.onLeftCLick(mobsController.player.inventory.items as MutableList, gameItemsHolder, itemIndex, action.actionKey.pointer) + } else { + if (action.actionKey.pointer == window.selectItemPointer) { + window.onLeftCLick(mobsController.player.inventory.items as MutableList, gameItemsHolder, itemIndex, action.actionKey.pointer) + } else { + window.onRightClick(mobsController.player.inventory.items as MutableList, itemIndex) + } + } + } else if (action.actionKey is MouseInputActionKey.Left) { + window.onLeftCLick(mobsController.player.inventory.items as MutableList, gameItemsHolder, itemIndex) } else { - onRightClick(mobsController.player.inventory.items as MutableList, window, itemIndex) + window.onRightClick(mobsController.player.inventory.items as MutableList, itemIndex) } Gdx.app.debug( @@ -89,10 +70,20 @@ class SelectCraftingInventoryItemMouseInputHandler @Inject constructor( val window = gameWindowsManager.currentWindow as CraftingInventoryWindow val index = xOnCraft + yOnCraft * GameWindowsConfigs.Crafting.craftGridSize - if (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Screen) { - onLeftCLick(window.craftingItems, window, index) + if (action.actionKey is MouseInputActionKey.Screen) { + if (!action.actionKey.touchUp) { + window.onLeftCLick(window.craftingItems, gameItemsHolder, index, action.actionKey.pointer) + } else { + if (action.actionKey.pointer == window.selectItemPointer) { + window.onLeftCLick(window.craftingItems, gameItemsHolder, index, action.actionKey.pointer) + } else { + window.onRightClick(window.craftingItems, index) + } + } + } else if (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Screen) { + window.onLeftCLick(window.craftingItems, gameItemsHolder, index) } else { - onRightClick(window.craftingItems, window, index) + window.onRightClick(window.craftingItems, index) } window.craftResult = @@ -131,7 +122,7 @@ class SelectCraftingInventoryItemMouseInputHandler @Inject constructor( handleInsideInventoryGrid(action, xOnGrid.toInt(), yOnGrid.toInt()) } else if (isInsideCraftGrid) { handleInsideCraft(action, xOnCraft.toInt(), yOnCraft.toInt()) - } else if (isInsideCraftResult) { + } else if (isInsideCraftResult && action.actionKey.touchUp) { val selectedItem = window.selectedItem if (selectedItem == null || selectedItem.item.isNone() || (selectedItem.item == window.craftResult?.item && selectedItem.amount + (window.craftResult?.amount ?: 0) <= selectedItem.item.params.maxStack)) { @@ -150,6 +141,16 @@ class SelectCraftingInventoryItemMouseInputHandler @Inject constructor( window.craftResult = gameItemsHolder.craftItem(window.craftingItems .map { it?.item ?: gameItemsHolder.fallbackItem }) } + } else if (action.actionKey.touchUp) { + window.selectedItem?.let { selectedItem -> + dropController.addDrop( + /* x = */ mobsController.player.x + (32f * mobsController.player.direction.basis), + /* y = */ mobsController.player.y, + /* item = */ selectedItem.item, + /* count = */ selectedItem.amount, + ) + window.selectedItem = null + } } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectSurvivalInventoryItemMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectSurvivalInventoryItemMouseInputHandler.kt index 0d0a647..d5858ac 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectSurvivalInventoryItemMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectSurvivalInventoryItemMouseInputHandler.kt @@ -10,6 +10,7 @@ import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey import ru.deadsoftware.cavedroid.game.input.isInsideWindow import ru.deadsoftware.cavedroid.game.mobs.MobsController import ru.deadsoftware.cavedroid.game.model.item.InventoryItem +import ru.deadsoftware.cavedroid.game.objects.DropController import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsConfigs import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager import ru.deadsoftware.cavedroid.game.ui.windows.inventory.SurvivalInventoryWindow @@ -21,6 +22,7 @@ class SelectSurvivalInventoryItemMouseInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, private val gameItemsHolder: GameItemsHolder, + private val dropController: DropController, ) : IGameInputHandler { private val survivalWindowTexture get() = requireNotNull(Assets.textureRegions["survival"]) @@ -29,38 +31,7 @@ class SelectSurvivalInventoryItemMouseInputHandler @Inject constructor( return gameWindowsManager.getCurrentWindow() == GameUiWindow.SURVIVAL_INVENTORY && isInsideWindow(action, survivalWindowTexture) && (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Right || action.actionKey is MouseInputActionKey.Screen) - && action.actionKey.touchUp - } - - private fun onLeftCLick(items: MutableList, window: SurvivalInventoryWindow, index: Int) { - val selectedItem = window.selectedItem - val clickedItem = items[index] - - if (clickedItem != null && selectedItem != null && items[index]!!.item == selectedItem.item && - items[index]!!.amount + selectedItem.amount <= selectedItem.item.params.maxStack) { - items[index]!!.amount += selectedItem.amount - window.selectedItem = null - return - } - - val item = items[index] - items[index] = selectedItem ?: gameItemsHolder.fallbackItem.toInventoryItem() - window.selectedItem = item - } - - private fun onRightClick(items: MutableList, window: SurvivalInventoryWindow, index: Int) { - val clickedItem = items[index] - val selectedItem = window.selectedItem - ?.takeIf { clickedItem == null || clickedItem.item.isNone() || it.item == items[index]!!.item && items[index]!!.amount + 1 < it.item.params.maxStack } - ?: return - - val newItem = selectedItem.item.toInventoryItem((clickedItem?.takeIf { !it.item.isNone() }?.amount ?: 0) + 1) - items[index] = newItem - selectedItem.amount -- - - if (selectedItem.amount <= 0) { - window.selectedItem = null - } + && (action.actionKey.touchUp || action.actionKey is MouseInputActionKey.Screen) } private fun handleInsideInventoryGrid(action: MouseInputAction, xOnGrid: Int, yOnGrid: Int) { @@ -69,14 +40,24 @@ class SelectSurvivalInventoryItemMouseInputHandler @Inject constructor( var itemIndex = ((xOnGrid.toInt() + yOnGrid.toInt() * GameWindowsConfigs.Survival.itemsInRow)) itemIndex += GameWindowsConfigs.Survival.hotbarCells - if (itemIndex >= 36) { - itemIndex -= 36 + if (itemIndex >= mobsController.player.inventory.size) { + itemIndex -= mobsController.player.inventory.size } - if (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Screen) { - onLeftCLick(mobsController.player.inventory.items as MutableList, window, itemIndex) + if (action.actionKey is MouseInputActionKey.Screen) { + if (!action.actionKey.touchUp) { + window.onLeftCLick(mobsController.player.inventory.items as MutableList, gameItemsHolder, itemIndex, action.actionKey.pointer) + } else { + if (action.actionKey.pointer == window.selectItemPointer) { + window.onLeftCLick(mobsController.player.inventory.items as MutableList, gameItemsHolder, itemIndex, action.actionKey.pointer) + } else { + window.onRightClick(mobsController.player.inventory.items as MutableList, itemIndex) + } + } + } else if (action.actionKey is MouseInputActionKey.Left) { + window.onLeftCLick(mobsController.player.inventory.items as MutableList, gameItemsHolder, itemIndex) } else { - onRightClick(mobsController.player.inventory.items as MutableList, window, itemIndex) + window.onRightClick(mobsController.player.inventory.items as MutableList, itemIndex) } Gdx.app.debug( @@ -89,10 +70,20 @@ class SelectSurvivalInventoryItemMouseInputHandler @Inject constructor( val window = gameWindowsManager.currentWindow as SurvivalInventoryWindow val index = xOnCraft + yOnCraft * GameWindowsConfigs.Crafting.craftGridSize // this is crafting on purpose!! - if (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Screen) { - onLeftCLick(window.craftingItems, window, index) + if (action.actionKey is MouseInputActionKey.Screen) { + if (!action.actionKey.touchUp) { + window.onLeftCLick(window.craftingItems, gameItemsHolder, index, action.actionKey.pointer) + } else { + if (action.actionKey.pointer == window.selectItemPointer) { + window.onLeftCLick(window.craftingItems, gameItemsHolder, index, action.actionKey.pointer) + } else { + window.onRightClick(window.craftingItems, index) + } + } + } else if (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Screen) { + window.onLeftCLick(window.craftingItems, gameItemsHolder, index) } else { - onRightClick(window.craftingItems, window, index) + window.onRightClick(window.craftingItems, index) } window.craftResult = @@ -131,7 +122,7 @@ class SelectSurvivalInventoryItemMouseInputHandler @Inject constructor( handleInsideInventoryGrid(action, xOnGrid.toInt(), yOnGrid.toInt()) } else if (isInsideCraftGrid) { handleInsideCraft(action, xOnCraft.toInt(), yOnCraft.toInt()) - } else if (isInsideCraftResult) { + } else if (isInsideCraftResult && action.actionKey.touchUp) { val selectedItem = window.selectedItem if (selectedItem == null || selectedItem.item.isNone() || (selectedItem.item == window.craftResult?.item && selectedItem.amount + (window.craftResult?.amount ?: 0) <= selectedItem.item.params.maxStack)) { @@ -150,6 +141,16 @@ class SelectSurvivalInventoryItemMouseInputHandler @Inject constructor( window.craftResult = gameItemsHolder.craftItem(window.craftingItems .map { it?.item ?: gameItemsHolder.fallbackItem }) } + } else if (action.actionKey.touchUp) { + window.selectedItem?.let { selectedItem -> + dropController.addDrop( + /* x = */ mobsController.player.x + (32f * mobsController.player.direction.basis), + /* y = */ mobsController.player.y, + /* item = */ selectedItem.item, + /* count = */ selectedItem.amount, + ) + window.selectedItem = null + } } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/touch/JoystickInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/touch/JoystickInputHandler.kt index c175f31..d4fb451 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/touch/JoystickInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/touch/JoystickInputHandler.kt @@ -1,6 +1,5 @@ package ru.deadsoftware.cavedroid.game.input.handler.touch -import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.utils.TimeUtils import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope @@ -95,6 +94,10 @@ class JoystickInputHandler @Inject constructor( } private fun handleDragged() { + if (!active) { + return + } + if (mobsController.player.controlMode == Player.ControlMode.CURSOR) { handleCursor() return diff --git a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/GameWindowsManager.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/GameWindowsManager.kt index 56d92d6..05c8a9b 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/GameWindowsManager.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/GameWindowsManager.kt @@ -30,14 +30,14 @@ class GameWindowsManager @Inject constructor( fun openInventory() { if (mobsController.player.gameMode == 1) { - currentWindow = CreativeInventoryWindow(GameUiWindow.CREATIVE_INVENTORY) + currentWindow = CreativeInventoryWindow() } else { - currentWindow = SurvivalInventoryWindow(GameUiWindow.SURVIVAL_INVENTORY) + currentWindow = SurvivalInventoryWindow() } } fun openCrafting() { - currentWindow = CraftingInventoryWindow(GameUiWindow.CRAFTING_TABLE) + currentWindow = CraftingInventoryWindow() } fun closeWindow() { diff --git a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/AbstractInventoryWindow.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/AbstractInventoryWindow.kt index 9d8e0f9..f49ba49 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/AbstractInventoryWindow.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/AbstractInventoryWindow.kt @@ -1,5 +1,6 @@ package ru.deadsoftware.cavedroid.game.ui.windows.inventory +import ru.deadsoftware.cavedroid.game.GameItemsHolder import ru.deadsoftware.cavedroid.game.GameUiWindow import ru.deadsoftware.cavedroid.game.model.item.InventoryItem @@ -9,4 +10,44 @@ abstract class AbstractInventoryWindow { abstract var selectedItem: InventoryItem? + var selectItemPointer: Int = -1 + + fun onLeftCLick(items: MutableList, gameItemsHolder: GameItemsHolder, index: Int, pointer: Int = -1) { + if (selectedItem != null && selectedItem?.item?.isNone() != true && pointer >= 0 && selectItemPointer >= 0 && pointer != selectItemPointer) { + return + } + + val clickedItem = items[index] + + selectedItem?.let { selectedItem -> + if (clickedItem != null && items[index]!!.item == selectedItem.item && + items[index]!!.amount + selectedItem.amount <= selectedItem.item.params.maxStack) { + items[index]!!.amount += selectedItem.amount + this@AbstractInventoryWindow.selectedItem = null + selectItemPointer = -1 + return + } + } + + val item = items[index] + items[index] = selectedItem ?: gameItemsHolder.fallbackItem.toInventoryItem() + selectedItem = item + selectItemPointer = pointer + } + + fun onRightClick(items: MutableList, index: Int) { + val clickedItem = items[index] + val selectedItem = selectedItem + ?.takeIf { clickedItem == null || clickedItem.item.isNone() || it.item == items[index]!!.item && items[index]!!.amount + 1 < it.item.params.maxStack } + ?: return + + val newItem = selectedItem.item.toInventoryItem((clickedItem?.takeIf { !it.item.isNone() }?.amount ?: 0) + 1) + items[index] = newItem + selectedItem.amount -- + + if (selectedItem.amount <= 0) { + this@AbstractInventoryWindow.selectedItem = null + } + } + } \ No newline at end of file diff --git a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CraftingInventoryWindow.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CraftingInventoryWindow.kt index 13dbd83..d83f1d5 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CraftingInventoryWindow.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CraftingInventoryWindow.kt @@ -3,9 +3,9 @@ package ru.deadsoftware.cavedroid.game.ui.windows.inventory import ru.deadsoftware.cavedroid.game.GameUiWindow import ru.deadsoftware.cavedroid.game.model.item.InventoryItem -class CraftingInventoryWindow( - override val type: GameUiWindow, -) : AbstractInventoryWindow() { +class CraftingInventoryWindow : AbstractInventoryWindow() { + + override val type = GameUiWindow.CRAFTING_TABLE override var selectedItem: InventoryItem? = null diff --git a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CreativeInventoryWindow.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CreativeInventoryWindow.kt index 22a3d56..a38fd29 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CreativeInventoryWindow.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CreativeInventoryWindow.kt @@ -3,8 +3,9 @@ package ru.deadsoftware.cavedroid.game.ui.windows.inventory import ru.deadsoftware.cavedroid.game.GameUiWindow import ru.deadsoftware.cavedroid.game.model.item.InventoryItem -class CreativeInventoryWindow( - override val type: GameUiWindow, -) : AbstractInventoryWindow() { +class CreativeInventoryWindow() : AbstractInventoryWindow() { + + override val type = GameUiWindow.CREATIVE_INVENTORY + override var selectedItem: InventoryItem? = null } \ No newline at end of file diff --git a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/SurvivalInventoryWindow.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/SurvivalInventoryWindow.kt index 685642c..12026d8 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/SurvivalInventoryWindow.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/SurvivalInventoryWindow.kt @@ -3,9 +3,9 @@ package ru.deadsoftware.cavedroid.game.ui.windows.inventory import ru.deadsoftware.cavedroid.game.GameUiWindow import ru.deadsoftware.cavedroid.game.model.item.InventoryItem -class SurvivalInventoryWindow( - override val type: GameUiWindow, -) : AbstractInventoryWindow() { +class SurvivalInventoryWindow() : AbstractInventoryWindow() { + + override val type = GameUiWindow.SURVIVAL_INVENTORY override var selectedItem: InventoryItem? = null -- 2.29.2