DEADSOFTWARE

Add tooltips
authorfredboy <fredboy@protonmail.com>
Tue, 7 May 2024 20:43:29 +0000 (03:43 +0700)
committerfredboy <fredboy@protonmail.com>
Tue, 7 May 2024 21:01:01 +0000 (04:01 +0700)
41 files changed:
android/assets/textures/items/charcoal.png [new file with mode: 0644]
android/assets/textures/items/coal.png [new file with mode: 0644]
core/src/ru/deadsoftware/cavedroid/game/GameModule.java
core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java
core/src/ru/deadsoftware/cavedroid/game/actions/useblock/UseCraftingTableAction.kt
core/src/ru/deadsoftware/cavedroid/game/debug/DebugInfoStringsProvider.kt
core/src/ru/deadsoftware/cavedroid/game/input/KeyboardInputHandlersModule.kt
core/src/ru/deadsoftware/cavedroid/game/input/action/keys/KeyboardInputActionKey.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/CloseGameWindowKeyboardInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/DropItemKeyboardInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/OpenInventoryKeyboardInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SelectHotbarSlotKeyboardInputHandler.kt [new file with mode: 0644]
core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/AttackMouseInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CreativeInventoryScrollMouseInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CursorMouseInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/HotbarMouseInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectCraftingInventoryItemMouseInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectCreativeInventoryItemMouseInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectSurvivalInventoryItemMouseInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/UseItemMouseInputHandler.kt
core/src/ru/deadsoftware/cavedroid/game/input/mapper/KeyboardInputActionMapper.kt
core/src/ru/deadsoftware/cavedroid/game/mobs/MobsController.kt
core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt
core/src/ru/deadsoftware/cavedroid/game/mobs/player/Player.java
core/src/ru/deadsoftware/cavedroid/game/objects/DropController.java
core/src/ru/deadsoftware/cavedroid/game/render/HudRenderer.kt
core/src/ru/deadsoftware/cavedroid/game/render/TouchControlsRenderer.kt
core/src/ru/deadsoftware/cavedroid/game/render/WindowsRenderer.kt
core/src/ru/deadsoftware/cavedroid/game/render/windows/CraftingWindowRenderer.kt
core/src/ru/deadsoftware/cavedroid/game/render/windows/CreativeWindowRenderer.kt
core/src/ru/deadsoftware/cavedroid/game/render/windows/SurvivalWindowRenderer.kt
core/src/ru/deadsoftware/cavedroid/game/ui/TooltipManager.kt [new file with mode: 0644]
core/src/ru/deadsoftware/cavedroid/game/ui/windows/GameWindowsConfigs.kt [moved from core/src/ru/deadsoftware/cavedroid/game/windows/GameWindowsConfigs.kt with 97% similarity]
core/src/ru/deadsoftware/cavedroid/game/ui/windows/GameWindowsManager.kt [new file with mode: 0644]
core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/AbstractInventoryWindow.kt [moved from core/src/ru/deadsoftware/cavedroid/game/windows/inventory/AbstractInventoryWindow.kt with 79% similarity]
core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CraftingInventoryWindow.kt [moved from core/src/ru/deadsoftware/cavedroid/game/windows/inventory/CraftingInventoryWindow.kt with 86% similarity]
core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CreativeInventoryWindow.kt [moved from core/src/ru/deadsoftware/cavedroid/game/windows/inventory/CreativeInventoryWindow.kt with 81% similarity]
core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/SurvivalInventoryWindow.kt [moved from core/src/ru/deadsoftware/cavedroid/game/windows/inventory/SurvivalInventoryWindow.kt with 86% similarity]
core/src/ru/deadsoftware/cavedroid/game/windows/GameWindowsManager.kt [deleted file]
core/src/ru/deadsoftware/cavedroid/misc/Assets.java

diff --git a/android/assets/textures/items/charcoal.png b/android/assets/textures/items/charcoal.png
new file mode 100644 (file)
index 0000000..9fe49a7
Binary files /dev/null and b/android/assets/textures/items/charcoal.png differ
diff --git a/android/assets/textures/items/coal.png b/android/assets/textures/items/coal.png
new file mode 100644 (file)
index 0000000..c94ebad
Binary files /dev/null and b/android/assets/textures/items/coal.png differ
index 29175da1968fba60e36f64a8ebb8ec746c73b630..fbbd294b0e032dda43c29c6ce772303a83673c1f 100644 (file)
@@ -6,6 +6,7 @@ import ru.deadsoftware.cavedroid.MainConfig;
 import ru.deadsoftware.cavedroid.game.mobs.MobsController;
 import ru.deadsoftware.cavedroid.game.model.block.Block;
 import ru.deadsoftware.cavedroid.game.objects.DropController;
+import ru.deadsoftware.cavedroid.game.ui.TooltipManager;
 import ru.deadsoftware.cavedroid.game.world.GameWorld;
 
 import javax.annotation.CheckForNull;
@@ -44,11 +45,15 @@ public class GameModule {
 
     @Provides
     @GameScope
-    public static MobsController provideMobsController(MainConfig mainConfig, GameItemsHolder gameItemsHolder) {
+    public static MobsController provideMobsController(MainConfig mainConfig,
+                                                       GameItemsHolder gameItemsHolder,
+                                                       TooltipManager tooltipManager) {
         load(mainConfig, gameItemsHolder);
-        MobsController controller = data != null ? data.retrieveMobsController() : new MobsController(gameItemsHolder);
+        MobsController controller = data != null
+                ? data.retrieveMobsController()
+                : new MobsController(gameItemsHolder, tooltipManager);
         makeDataNullIfEmpty();
-        controller.getPlayer().initInventory(gameItemsHolder);
+        controller.getPlayer().initInventory(gameItemsHolder, tooltipManager);
         return controller;
     }
 
index 35f318aada2057cfa9d537fa069e54925829dd90..4b418a7b566ac26b03c72a926c8b382ecc3c69db 100644 (file)
@@ -1,8 +1,12 @@
 package ru.deadsoftware.cavedroid.game;
 
 import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.GL20;
 import com.badlogic.gdx.math.Rectangle;
+import com.badlogic.gdx.scenes.scene2d.ui.Label;
+import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
+import com.badlogic.gdx.utils.Align;
 import com.badlogic.gdx.utils.ObjectMap;
 import ru.deadsoftware.cavedroid.MainConfig;
 import ru.deadsoftware.cavedroid.game.input.IGameInputHandler;
@@ -16,7 +20,8 @@ import ru.deadsoftware.cavedroid.game.mobs.MobsController;
 import ru.deadsoftware.cavedroid.game.mobs.player.Player;
 import ru.deadsoftware.cavedroid.game.objects.TouchButton;
 import ru.deadsoftware.cavedroid.game.render.IGameRenderer;
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager;
+import ru.deadsoftware.cavedroid.game.ui.TooltipManager;
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager;
 import ru.deadsoftware.cavedroid.misc.Assets;
 import ru.deadsoftware.cavedroid.misc.Renderer;
 
@@ -41,6 +46,7 @@ public class GameRenderer extends Renderer {
     private final Set<IGameInputHandler<MouseInputAction>> mMouseInputHandlers;
     private final Set<IGameInputHandler<KeyboardInputAction>> mKeyboardInputHandlers;
     private final GameWindowsManager mGameWindowsManager;
+    private final TooltipManager mTooltipManager;
 
     @Inject
     GameRenderer(MainConfig mainConfig,
@@ -51,7 +57,8 @@ public class GameRenderer extends Renderer {
                  KeyboardInputActionMapper keyboardInputActionMapper,
                  Set<IGameInputHandler<MouseInputAction>> mouseInputHandlers,
                  Set<IGameInputHandler<KeyboardInputAction>> keyboardInputHandlers,
-                 GameWindowsManager gameWindowsManager) {
+                 GameWindowsManager gameWindowsManager,
+                 TooltipManager tooltipManager) {
         super(mainConfig.getWidth(), mainConfig.getHeight());
 
         mMainConfig = mainConfig;
@@ -64,6 +71,7 @@ public class GameRenderer extends Renderer {
         mMouseInputHandlers = mouseInputHandlers;
         mKeyboardInputHandlers = keyboardInputHandlers;
         mGameWindowsManager = gameWindowsManager;
+        mTooltipManager = tooltipManager;
 
         Gdx.gl.glClearColor(0f, .6f, .6f, 1f);
     }
@@ -86,13 +94,28 @@ public class GameRenderer extends Renderer {
 
     private void handleMousePosition() {
         final Rectangle viewport = getCameraViewport();
+
+        final float screenX = transformScreenX(Gdx.input.getX());
+        final float screenY = transformScreenY(Gdx.input.getY());
+
         final MouseInputAction action = new MouseInputAction(
-                Gdx.input.getX() * (viewport.width / Gdx.graphics.getWidth()),
-                Gdx.input.getY() * (viewport.height / Gdx.graphics.getHeight()),
+                screenX,
+                screenY,
                 MouseInputActionKey.None.INSTANCE,
                 viewport);
 
         mCursorMouseInputHandler.handle(action);
+
+        if (!mTooltipManager.getCurrentMouseTooltip().isEmpty()) {
+            final Label.LabelStyle style = new Label.LabelStyle(Assets.minecraftFont, Color.WHITE);
+            style.background = new TextureRegionDrawable(Assets.textureRegions.get("background"));
+            final Label label = new Label(mTooltipManager.getCurrentMouseTooltip(), style);
+            label.setX(screenX);
+            label.setY(screenY);
+//            label.setHeight(10f);
+//            label.setAlignment(Align.left, Align.top);
+            label.draw(spriter, 1f);
+        }
     }
 
     private boolean handleMouseAction(@CheckForNull  MouseInputAction action) {
@@ -226,14 +249,14 @@ public class GameRenderer extends Renderer {
     @Override
     public void render(float delta) {
         updateCameraPosition();
-        handleMousePosition();
-//        mGameInput.moveCursor(this);
 
         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
 
         spriter.begin();
         mRenderers.forEach(iGameRenderer -> iGameRenderer.draw(spriter, shaper, getCameraViewport(), delta));
+        handleMousePosition();
         spriter.end();
+
     }
 
 }
index 7c4136487d0fd1d4148d59c36de9ea8cce126809..3ce42b94f01ef0403e551ec2a80f5954cf14f1d7 100644 (file)
@@ -2,7 +2,7 @@ package ru.deadsoftware.cavedroid.game.actions.useblock
 
 import ru.deadsoftware.cavedroid.game.GameScope
 import ru.deadsoftware.cavedroid.game.model.block.Block
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import javax.inject.Inject
 
 @GameScope
index f34903b143f8d505f3738f67dc68047327662586..0886a0756f7a54a829edb8ad6769cb1b59f6bc3b 100644 (file)
@@ -20,7 +20,7 @@ class DebugInfoStringsProvider @Inject constructor(
         return listOf(
             "FPS: ${Gdx.graphics.framesPerSecond}",
             "X: ${player.mapX}",
-            "Y: ${gameWorld.height - player.upperMapY}",
+            "Y: ${player.upperMapY} (${gameWorld.height - player.upperMapY})",
             "CurX: ${player.cursorX}",
             "CurY: ${player.cursorY}",
             "Velocity: ${player.velocity}",
index 0a33d9337db9b7802dea88b9f76304f409408187..a58e52294dfe6a196c94f4f199a4023c7fcf9060 100644 (file)
@@ -129,4 +129,11 @@ object KeyboardInputHandlersModule {
         return handler
     }
 
+    @Binds
+    @IntoSet
+    @GameScope
+    fun bindSelectHotbarSlotKeyboardInputHandler(handler: SelectHotbarSlotKeyboardInputHandler): IGameInputHandler<KeyboardInputAction> {
+        return handler
+    }
+
 }
\ No newline at end of file
index 89ff50658340fd38c7366b6bec6cadbfc36d98b0..fd14fc4947412527773b85e76edf0864d62d8db8 100644 (file)
@@ -21,4 +21,8 @@ sealed interface KeyboardInputActionKey {
     data object SpawnPig : KeyboardInputActionKey
     data object SwitchGameMode : KeyboardInputActionKey
     data object ShowMap : KeyboardInputActionKey
+
+    data class SelectHotbarSlot(
+        val slot: Int
+    ) : KeyboardInputActionKey
 }
\ No newline at end of file
index 705f9aa0e71a5ae60a64c8ac1e411c8cbf511a45..b2d1244aa91dbc0a903142733a8e58921d645111 100644 (file)
@@ -7,7 +7,7 @@ import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
 import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
 import ru.deadsoftware.cavedroid.game.mobs.MobsController
 import ru.deadsoftware.cavedroid.game.objects.DropController
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import javax.inject.Inject
 
 @GameScope
index 7e6454c32dbb9eddd0890eee6f197a2237d317a8..4003271fd61301ac713fc65dc6fbb66897998d69 100644 (file)
@@ -9,7 +9,7 @@ import ru.deadsoftware.cavedroid.game.mobs.MobsController
 import ru.deadsoftware.cavedroid.game.model.item.Item
 import ru.deadsoftware.cavedroid.game.objects.Drop
 import ru.deadsoftware.cavedroid.game.objects.DropController
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import javax.inject.Inject
 
 @GameScope
index 0e2c11bd17a0adce97b6853cbe37965891b11fb0..50aa5b01b5d6677865d350b61574449ecae1ebf0 100644 (file)
@@ -7,7 +7,7 @@ import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
 import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
 import ru.deadsoftware.cavedroid.game.mobs.MobsController
 import ru.deadsoftware.cavedroid.game.objects.DropController
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import javax.inject.Inject
 
 @GameScope
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SelectHotbarSlotKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SelectHotbarSlotKeyboardInputHandler.kt
new file mode 100644 (file)
index 0000000..45e04da
--- /dev/null
@@ -0,0 +1,24 @@
+package ru.deadsoftware.cavedroid.game.input.handler.keyboard
+
+import ru.deadsoftware.cavedroid.game.GameScope
+import ru.deadsoftware.cavedroid.game.input.IGameInputHandler
+import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
+import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
+import ru.deadsoftware.cavedroid.game.mobs.MobsController
+import javax.inject.Inject
+
+@GameScope
+class SelectHotbarSlotKeyboardInputHandler @Inject constructor(
+    private val mobsController: MobsController,
+) : IGameInputHandler<KeyboardInputAction> {
+
+    override fun checkConditions(action: KeyboardInputAction): Boolean {
+        return action.actionKey is KeyboardInputActionKey.SelectHotbarSlot &&
+                action.isKeyDown
+    }
+
+    override fun handle(action: KeyboardInputAction) {
+        mobsController.player.inventory.activeSlot = (action.actionKey as KeyboardInputActionKey.SelectHotbarSlot).slot
+    }
+
+}
\ No newline at end of file
index a0bfa4cd8da9ea8d176a73c2c7da1175c31e229a..2afc3d5b1bbb50d6310f0fa4a247926c29bd9d3b 100644 (file)
@@ -7,7 +7,7 @@ import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction
 import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey
 import ru.deadsoftware.cavedroid.game.input.isInsideHotbar
 import ru.deadsoftware.cavedroid.game.mobs.MobsController
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import ru.deadsoftware.cavedroid.game.world.GameWorld
 import javax.inject.Inject
 
index e80ff476b00fdfbb02c1c7623ddb2b8969b3ee6a..bee22dc621d77b89b2029dbfec40eb6b05935cdc 100644 (file)
@@ -3,7 +3,7 @@ package ru.deadsoftware.cavedroid.game.input.handler.mouse
 import com.badlogic.gdx.graphics.g2d.TextureRegion
 import ru.deadsoftware.cavedroid.game.GameScope
 import ru.deadsoftware.cavedroid.game.GameUiWindow
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import ru.deadsoftware.cavedroid.game.input.IGameInputHandler
 import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction
 import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey
index 01cc4e23a5c1f78a38c7dd2ee6a4a8b47ef2e9b9..352d04bcb5fba0e98d439af2da68edcc5e4f0a0c 100644 (file)
@@ -5,7 +5,7 @@ import ru.deadsoftware.cavedroid.MainConfig
 import ru.deadsoftware.cavedroid.game.GameItemsHolder
 import ru.deadsoftware.cavedroid.game.GameScope
 import ru.deadsoftware.cavedroid.game.GameUiWindow
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import ru.deadsoftware.cavedroid.game.input.IGameInputHandler
 import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction
 import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey
index 062859cf9cd53e95e6ed829098167607364014d5..6a4b5a4eb968101d134eeeefa7aa9b9e290b51bd 100644 (file)
@@ -2,7 +2,9 @@ package ru.deadsoftware.cavedroid.game.input.handler.mouse
 
 import com.badlogic.gdx.math.MathUtils
 import ru.deadsoftware.cavedroid.MainConfig
+import ru.deadsoftware.cavedroid.game.GameItemsHolder
 import ru.deadsoftware.cavedroid.game.GameScope
+import ru.deadsoftware.cavedroid.game.GameUiWindow
 import ru.deadsoftware.cavedroid.game.input.IGameInputHandler
 import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction
 import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey
@@ -10,7 +12,11 @@ import ru.deadsoftware.cavedroid.game.mobs.Mob
 import ru.deadsoftware.cavedroid.game.mobs.MobsController
 import ru.deadsoftware.cavedroid.game.mobs.player.Player
 import ru.deadsoftware.cavedroid.game.model.block.Block
+import ru.deadsoftware.cavedroid.game.ui.TooltipManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsConfigs
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import ru.deadsoftware.cavedroid.game.world.GameWorld
+import ru.deadsoftware.cavedroid.misc.Assets
 import ru.deadsoftware.cavedroid.misc.utils.bl
 import ru.deadsoftware.cavedroid.misc.utils.px
 import javax.inject.Inject
@@ -20,10 +26,15 @@ class CursorMouseInputHandler @Inject constructor(
     private val mainConfig: MainConfig,
     private val mobsController: MobsController,
     private val gameWorld: GameWorld,
+    private val gameWindowsManager: GameWindowsManager,
+    private val gameItemsHolder: GameItemsHolder,
+    private val tooltipManager: TooltipManager,
 ) : IGameInputHandler<MouseInputAction> {
 
     private val player get() = mobsController.player
 
+    private val creativeInventoryTexture get() = requireNotNull(Assets.textureRegions["creative"])
+
     private val Block.isAutoselectable
         get() = !isNone() && params.hasCollision
 
@@ -92,6 +103,27 @@ class CursorMouseInputHandler @Inject constructor(
         player.headRotation = getPlayerHeadRotation(worldX, worldY)
     }
 
+    private fun getCreativeTooltip(action: MouseInputAction): String? {
+        val creativeTexture = creativeInventoryTexture
+        val xOnGrid = (action.screenX - (action.cameraViewport.width / 2 - creativeTexture.regionWidth / 2 +
+                GameWindowsConfigs.Creative.itemsGridMarginLeft)) /
+                GameWindowsConfigs.Creative.itemsGridColWidth
+        val yOnGrid = (action.screenY - (action.cameraViewport.height / 2 - creativeTexture.regionHeight / 2 +
+                GameWindowsConfigs.Creative.itemsGridMarginTop)) /
+                GameWindowsConfigs.Creative.itemsGridRowHeight
+
+        if (xOnGrid < 0 || xOnGrid >= GameWindowsConfigs.Creative.itemsInRow ||
+            yOnGrid < 0 || yOnGrid >= GameWindowsConfigs.Creative.itemsInCol) {
+            return null
+        }
+
+        val itemIndex = (gameWindowsManager.creativeScrollAmount * GameWindowsConfigs.Creative.itemsInRow +
+                (xOnGrid.toInt() + yOnGrid.toInt() * GameWindowsConfigs.Creative.itemsInRow))
+        val item = gameItemsHolder.getItemFromCreativeInventory(itemIndex)
+
+        return item.params.name
+    }
+
     override fun checkConditions(action: MouseInputAction): Boolean {
         return action.actionKey is MouseInputActionKey.None
     }
@@ -111,6 +143,10 @@ class CursorMouseInputHandler @Inject constructor(
         if (player.cursorX != pastCursorX || player.cursorY != pastCursorY) {
             player.blockDamage = 0f
         }
+
+        if (gameWindowsManager.getCurrentWindow() == GameUiWindow.CREATIVE_INVENTORY) {
+            tooltipManager.showMouseTooltip(getCreativeTooltip(action).orEmpty())
+        }
     }
 
     companion object {
index c7f54acf609f9b6740353b23b38c23b32ada02c6..0725abee6fc190dbbc230a82d1e7f1407790abc4 100644 (file)
@@ -3,7 +3,7 @@ package ru.deadsoftware.cavedroid.game.input.handler.mouse
 import com.badlogic.gdx.utils.Timer
 import ru.deadsoftware.cavedroid.game.GameScope
 import ru.deadsoftware.cavedroid.game.GameUiWindow
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import ru.deadsoftware.cavedroid.game.input.IGameInputHandler
 import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction
 import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey
index 4395337b1101bc2ec3ea5f22ba5ffbe1523ce8ec..89c0ce1061910b1378a8cf1a0573b647a7816682 100644 (file)
@@ -10,9 +10,9 @@ 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.windows.GameWindowsConfigs
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
-import ru.deadsoftware.cavedroid.game.windows.inventory.CraftingInventoryWindow
+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
 import ru.deadsoftware.cavedroid.misc.Assets
 import javax.inject.Inject
 
index 032bade3b74875e6dfddbf40537a2ed3ce4d0331..9ccbf6eac8fde6cddf301ee9e09aefec3918ea07 100644 (file)
@@ -3,13 +3,13 @@ package ru.deadsoftware.cavedroid.game.input.handler.mouse
 import ru.deadsoftware.cavedroid.game.GameItemsHolder
 import ru.deadsoftware.cavedroid.game.GameScope
 import ru.deadsoftware.cavedroid.game.GameUiWindow
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import ru.deadsoftware.cavedroid.game.input.IGameInputHandler
 import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction
 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.windows.GameWindowsConfigs
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsConfigs
 import ru.deadsoftware.cavedroid.misc.Assets
 import javax.inject.Inject
 
index 828f02fa8fcbb5c4ddde5bd39a4f48707b3a1eac..ab65fb8c05d888d644bb63fcc618b46b453588d6 100644 (file)
@@ -10,9 +10,9 @@ 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.windows.GameWindowsConfigs
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
-import ru.deadsoftware.cavedroid.game.windows.inventory.SurvivalInventoryWindow
+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
 import ru.deadsoftware.cavedroid.misc.Assets
 import javax.inject.Inject
 
index da59bc65cc612e301edf8a355920c5ca285dff3c..04bc6198295fcf3fede52cfa413b685f3c6b6d9b 100644 (file)
@@ -15,7 +15,7 @@ import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey
 import ru.deadsoftware.cavedroid.game.input.isInsideHotbar
 import ru.deadsoftware.cavedroid.game.mobs.MobsController
 import ru.deadsoftware.cavedroid.game.model.item.Item
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import ru.deadsoftware.cavedroid.game.world.GameWorld
 import javax.inject.Inject
 
index 61e97932708cdcb07f122e8283a250fcfe0a89f1..8d18d070703931aeafdb4a41867d66e7c4b2cc35 100644 (file)
@@ -27,6 +27,16 @@ class KeyboardInputActionMapper @Inject constructor() {
 
             Input.Keys.Q -> KeyboardInputActionKey.DropItem
 
+            Input.Keys.NUM_1 -> KeyboardInputActionKey.SelectHotbarSlot(0)
+            Input.Keys.NUM_2 -> KeyboardInputActionKey.SelectHotbarSlot(1)
+            Input.Keys.NUM_3 -> KeyboardInputActionKey.SelectHotbarSlot(2)
+            Input.Keys.NUM_4 -> KeyboardInputActionKey.SelectHotbarSlot(3)
+            Input.Keys.NUM_5 -> KeyboardInputActionKey.SelectHotbarSlot(4)
+            Input.Keys.NUM_6 -> KeyboardInputActionKey.SelectHotbarSlot(5)
+            Input.Keys.NUM_7 -> KeyboardInputActionKey.SelectHotbarSlot(6)
+            Input.Keys.NUM_8 -> KeyboardInputActionKey.SelectHotbarSlot(7)
+            Input.Keys.NUM_9 -> KeyboardInputActionKey.SelectHotbarSlot(8)
+
             else -> null
         }
 
index df2a6dec5eef62240a5708edf676af8008e003ee..158d22a9e55445ae1056e680c4fb3621f03a03e0 100644 (file)
@@ -3,19 +3,21 @@ package ru.deadsoftware.cavedroid.game.mobs
 import ru.deadsoftware.cavedroid.game.GameItemsHolder
 import ru.deadsoftware.cavedroid.game.GameScope
 import ru.deadsoftware.cavedroid.game.mobs.player.Player
+import ru.deadsoftware.cavedroid.game.ui.TooltipManager
 import java.io.Serializable
 import java.util.*
 import javax.inject.Inject
 
 @GameScope
 class MobsController @Inject constructor(
-    gameItemsHolder: GameItemsHolder
+    gameItemsHolder: GameItemsHolder,
+    tooltipManager: TooltipManager,
 ) : Serializable {
 
     private val _mobs = LinkedList<Mob>()
 
     val player: Player =
-        Player(gameItemsHolder)
+        Player(gameItemsHolder, tooltipManager)
 
     val mobs: List<Mob>
         get() = _mobs
index b82aa44bcb775991b4ff12e175a511925620c28b..44ee6dd17e6bb94393475dc22c2778f4a2569338 100644 (file)
@@ -4,19 +4,26 @@ import ru.deadsoftware.cavedroid.game.GameItemsHolder
 import ru.deadsoftware.cavedroid.game.model.item.InventoryItem
 import ru.deadsoftware.cavedroid.game.model.item.Item
 import ru.deadsoftware.cavedroid.game.objects.Drop
+import ru.deadsoftware.cavedroid.game.ui.TooltipManager
 import java.io.Serializable
 
 class Inventory(
     val size: Int,
     val hotbarSize: Int,
-    gameItemsHolder: GameItemsHolder
+    gameItemsHolder: GameItemsHolder,
+    tooltipManager: TooltipManager,
 ) : Serializable {
 
+    @Transient
+    private lateinit var tooltipManager: TooltipManager
+
     @Transient
     private lateinit var fallbackItem: InventoryItem
 
     init {
         fallbackItem = gameItemsHolder.fallbackItem.toInventoryItem()
+        this.tooltipManager = tooltipManager
+
         if (size < 0 || hotbarSize < 0 || hotbarSize > size) {
             throw IllegalArgumentException("Invalid inventory sizes: hotbarSize=$hotbarSize; size=$size")
         }
@@ -32,12 +39,18 @@ class Inventory(
         set(value) {
             if (value in 0 ..< hotbarSize) {
                 field = value
+                showCurrentItemTooltip()
             }
         }
 
+    fun showCurrentItemTooltip() {
+        tooltipManager.showHotbarTooltip(activeItem.item.params.name)
+    }
+
     val activeItem get() = items[activeSlot]
 
-    fun initItems(gameItemsHolder: GameItemsHolder) {
+    fun initItems(gameItemsHolder: GameItemsHolder, tooltipManager: TooltipManager) {
+        this.tooltipManager = tooltipManager
         fallbackItem = gameItemsHolder.fallbackItem.toInventoryItem()
         items.forEach { item ->
             item.init(gameItemsHolder)
@@ -70,11 +83,14 @@ class Inventory(
 
         if (inventoryItem.item == drop.item) {
             inventoryItem.add()
-            drop.pickedUp = true
         } else {
             _items[slot] = drop.item.toInventoryItem()
-            drop.pickedUp = true
+            if (slot == activeSlot) {
+                showCurrentItemTooltip()
+            }
         }
+
+        drop.pickedUp = true
     }
 
     fun addItem(item: Item) {
@@ -86,6 +102,7 @@ class Inventory(
         )
 
         _items[0] = item.toInventoryItem(item.params.maxStack)
+        showCurrentItemTooltip()
     }
 
     @JvmOverloads
index dcc77ef81202b4bb6e96018b3651b348b3aeb1f1..241714a3579cc8bfb94e5d0fd39017cc0169ee4c 100644 (file)
@@ -10,6 +10,7 @@ import ru.deadsoftware.cavedroid.game.model.block.Block;
 import ru.deadsoftware.cavedroid.game.model.item.InventoryItem;
 import ru.deadsoftware.cavedroid.game.model.item.Item;
 import ru.deadsoftware.cavedroid.game.objects.Drop;
+import ru.deadsoftware.cavedroid.game.ui.TooltipManager;
 import ru.deadsoftware.cavedroid.game.world.GameWorld;
 import ru.deadsoftware.cavedroid.misc.Assets;
 import ru.deadsoftware.cavedroid.misc.utils.SpriteOrigin;
@@ -50,14 +51,14 @@ public class Player extends Mob {
         CURSOR
     }
 
-    public Player(GameItemsHolder gameItemsHolder) {
+    public Player(GameItemsHolder gameItemsHolder, TooltipManager tooltipManager) {
         super(0, 0, 4, 30, randomDir(), Type.MOB, MAX_HEALTH);
-        inventory = new Inventory(INVENTORY_SIZE, HOTBAR_SIZE, gameItemsHolder);
+        inventory = new Inventory(INVENTORY_SIZE, HOTBAR_SIZE, gameItemsHolder, tooltipManager);
         swim = false;
     }
 
-    public void initInventory(GameItemsHolder gameItemsHolder) {
-        inventory.initItems(gameItemsHolder);
+    public void initInventory(GameItemsHolder gameItemsHolder, TooltipManager tooltipManager) {
+        inventory.initItems(gameItemsHolder, tooltipManager);
     }
 
     public void respawn(GameWorld gameWorld, GameItemsHolder itemsHolder) {
index 798a84ce5b77415bbf88f87187c39d51e636ff04..639a2aa834365f9a27897f6bddfc9526213eab7f 100644 (file)
@@ -33,6 +33,12 @@ public class DropController implements Serializable {
         mDrops.add(new Drop(x, y, item));
     }
 
+    public void addDrop(float x, float y, Item item, int count) {
+        for (int i = 0 ; i < count; i++) {
+            addDrop(x, y, item);
+        }
+    }
+
     public int getSize() {
         return mDrops.size();
     }
index 1053a9f3d2b887840f9a35ef018d37a93d5611aa..a2570e25f3120f8208233038f3b85e4738409dc4 100644 (file)
@@ -7,8 +7,10 @@ import ru.deadsoftware.cavedroid.game.GameScope
 import ru.deadsoftware.cavedroid.game.mobs.MobsController
 import ru.deadsoftware.cavedroid.game.mobs.player.Player
 import ru.deadsoftware.cavedroid.game.mobs.player.Player.ControlMode
+import ru.deadsoftware.cavedroid.game.ui.TooltipManager
 import ru.deadsoftware.cavedroid.game.world.GameWorld
 import ru.deadsoftware.cavedroid.misc.Assets
+import ru.deadsoftware.cavedroid.misc.utils.drawString
 import ru.deadsoftware.cavedroid.misc.utils.px
 import javax.inject.Inject
 
@@ -16,6 +18,7 @@ import javax.inject.Inject
 class HudRenderer @Inject constructor(
     private val gameWorld: GameWorld,
     private val mobsController: MobsController,
+    private val tooltipManager: TooltipManager,
 ) : IGameRenderer {
 
     override val renderLayer = RENDER_LAYER
@@ -102,6 +105,15 @@ class HudRenderer @Inject constructor(
         drawHealth(spriteBatch, hotbarX, hotbarTexture.regionHeight.toFloat())
         drawHotbarSelector(spriteBatch, hotbarX)
         drawHotbarItems(spriteBatch, shapeRenderer, hotbarX)
+
+        val tooltip = tooltipManager.currentHotbarTooltip
+        if (tooltip.isNotBlank()) {
+            spriteBatch.drawString(
+                str = tooltip,
+                x = viewport.width / 2 - Assets.getStringWidth(tooltip) / 2,
+                y = hotbarTexture.regionHeight.toFloat()
+            )
+        }
     }
 
     override fun draw(spriteBatch: SpriteBatch, shapeRenderer: ShapeRenderer, viewport: Rectangle, delta: Float) {
index c768d5f07d1fc512d7b49fd964c0848dbb7d3618..ad68bce795a4721413fb373000a09ec1215243ce 100644 (file)
@@ -8,7 +8,7 @@ import ru.deadsoftware.cavedroid.game.GameScope
 import ru.deadsoftware.cavedroid.game.GameUiWindow
 import ru.deadsoftware.cavedroid.game.mobs.MobsController
 import ru.deadsoftware.cavedroid.game.mobs.player.Player.ControlMode
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import ru.deadsoftware.cavedroid.misc.Assets
 import ru.deadsoftware.cavedroid.misc.utils.ArrayMapExtensions.component1
 import ru.deadsoftware.cavedroid.misc.utils.ArrayMapExtensions.component2
index 2fa093f61719d8564637e5ce4e456b2e7153b201..03df48f4178e307a159b2c83944abfd3e07b678c 100644 (file)
@@ -9,7 +9,7 @@ import ru.deadsoftware.cavedroid.game.GameUiWindow
 import ru.deadsoftware.cavedroid.game.render.windows.CraftingWindowRenderer
 import ru.deadsoftware.cavedroid.game.render.windows.CreativeWindowRenderer
 import ru.deadsoftware.cavedroid.game.render.windows.SurvivalWindowRenderer
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import javax.inject.Inject
 
 @GameScope
index cc8c1baf4522a6cd31fb625b6f6f1977c2475a7a..6772282b15b18968ef3d0d82a27d1f1f8fb3651e 100644 (file)
@@ -10,9 +10,9 @@ import ru.deadsoftware.cavedroid.game.GameScope
 import ru.deadsoftware.cavedroid.game.mobs.MobsController
 import ru.deadsoftware.cavedroid.game.render.IGameRenderer
 import ru.deadsoftware.cavedroid.game.render.WindowsRenderer
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsConfigs
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
-import ru.deadsoftware.cavedroid.game.windows.inventory.CraftingInventoryWindow
+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
 import ru.deadsoftware.cavedroid.misc.Assets
 import javax.inject.Inject
 
index dede82f94252a226c9fda7bcccbef89f94b88392..6bfac428fc32d3c76ab8b33cf9845306e3057138 100644 (file)
@@ -6,11 +6,11 @@ import com.badlogic.gdx.math.Rectangle
 import ru.deadsoftware.cavedroid.MainConfig
 import ru.deadsoftware.cavedroid.game.GameItemsHolder
 import ru.deadsoftware.cavedroid.game.GameScope
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
 import ru.deadsoftware.cavedroid.game.mobs.MobsController
 import ru.deadsoftware.cavedroid.game.render.IGameRenderer
 import ru.deadsoftware.cavedroid.game.render.WindowsRenderer
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsConfigs
+import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsConfigs
 import ru.deadsoftware.cavedroid.misc.Assets
 import javax.inject.Inject
 import kotlin.math.min
index ef23be556e35397fb4a87714edcfb9bd1cf356d4..7ee3b27087eb76bd0b75f2549786b54b5eac241c 100644 (file)
@@ -12,9 +12,9 @@ import ru.deadsoftware.cavedroid.game.mobs.Mob
 import ru.deadsoftware.cavedroid.game.mobs.MobsController
 import ru.deadsoftware.cavedroid.game.render.IGameRenderer
 import ru.deadsoftware.cavedroid.game.render.WindowsRenderer
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsConfigs
-import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
-import ru.deadsoftware.cavedroid.game.windows.inventory.SurvivalInventoryWindow
+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
 import ru.deadsoftware.cavedroid.misc.Assets
 import javax.inject.Inject
 import kotlin.math.atan
diff --git a/core/src/ru/deadsoftware/cavedroid/game/ui/TooltipManager.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/TooltipManager.kt
new file mode 100644 (file)
index 0000000..a8f5a9b
--- /dev/null
@@ -0,0 +1,41 @@
+package ru.deadsoftware.cavedroid.game.ui
+
+import com.badlogic.gdx.utils.Timer
+import ru.deadsoftware.cavedroid.MainConfig
+import ru.deadsoftware.cavedroid.game.GameScope
+import javax.inject.Inject
+
+@GameScope
+class TooltipManager @Inject constructor(
+    private val mainConfig: MainConfig
+) {
+
+    private val resetTask = object : Timer.Task() {
+        override fun run() {
+            currentHotbarTooltip = ""
+        }
+    }
+
+    var currentHotbarTooltip: String = ""
+        private set
+
+    var currentMouseTooltip: String = ""
+        private set
+
+    fun showHotbarTooltip(tooltip: String) {
+        currentHotbarTooltip = tooltip
+        if (resetTask.isScheduled) {
+            resetTask.cancel()
+        }
+        Timer.schedule(resetTask, TOOLTIP_TIME_S)
+    }
+
+    fun showMouseTooltip(tooltip: String) {
+        currentMouseTooltip = tooltip
+    }
+
+    companion object {
+        private const val TOOLTIP_TIME_S = 2f
+    }
+
+}
\ No newline at end of file
similarity index 97%
rename from core/src/ru/deadsoftware/cavedroid/game/windows/GameWindowsConfigs.kt
rename to core/src/ru/deadsoftware/cavedroid/game/ui/windows/GameWindowsConfigs.kt
index a6cff63b08c049c3dc646c11ffdee28593ff05fc..8fa3fb2a7a1f216ba8a255b74395d176feef0365 100644 (file)
@@ -1,4 +1,4 @@
-package ru.deadsoftware.cavedroid.game.windows
+package ru.deadsoftware.cavedroid.game.ui.windows
 
 object GameWindowsConfigs {
     data object Creative {
diff --git a/core/src/ru/deadsoftware/cavedroid/game/ui/windows/GameWindowsManager.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/GameWindowsManager.kt
new file mode 100644 (file)
index 0000000..56d92d6
--- /dev/null
@@ -0,0 +1,64 @@
+package ru.deadsoftware.cavedroid.game.ui.windows
+
+import ru.deadsoftware.cavedroid.game.GameScope
+import ru.deadsoftware.cavedroid.game.GameUiWindow
+import ru.deadsoftware.cavedroid.game.mobs.MobsController
+import ru.deadsoftware.cavedroid.game.objects.DropController
+import ru.deadsoftware.cavedroid.game.ui.TooltipManager
+import ru.deadsoftware.cavedroid.game.ui.windows.inventory.AbstractInventoryWindow
+import ru.deadsoftware.cavedroid.game.ui.windows.inventory.CraftingInventoryWindow
+import ru.deadsoftware.cavedroid.game.ui.windows.inventory.CreativeInventoryWindow
+import ru.deadsoftware.cavedroid.game.ui.windows.inventory.SurvivalInventoryWindow
+import javax.inject.Inject
+
+@GameScope
+class GameWindowsManager @Inject constructor(
+    private val tooltipManager: TooltipManager,
+    private val mobsController: MobsController,
+    private val dropController: DropController,
+) {
+
+    var creativeScrollAmount = 0
+    var isDragging = false
+
+    var currentWindow: AbstractInventoryWindow? = null
+
+    @JvmName("getCurrentWindowType")
+    fun getCurrentWindow(): GameUiWindow {
+        return currentWindow?.type ?: GameUiWindow.NONE
+    }
+
+    fun openInventory() {
+        if (mobsController.player.gameMode == 1) {
+            currentWindow = CreativeInventoryWindow(GameUiWindow.CREATIVE_INVENTORY)
+        } else {
+            currentWindow = SurvivalInventoryWindow(GameUiWindow.SURVIVAL_INVENTORY)
+        }
+    }
+
+    fun openCrafting() {
+        currentWindow = CraftingInventoryWindow(GameUiWindow.CRAFTING_TABLE)
+    }
+
+    fun closeWindow() {
+        (currentWindow as? SurvivalInventoryWindow)?.let { window ->
+            window.craftingItems.forEach { item ->
+                item?.item?.let {
+                    dropController.addDrop(mobsController.player.x, mobsController.player.y, it, item.amount)
+                }
+            }
+        }
+
+        (currentWindow as? CraftingInventoryWindow)?.let { window ->
+            window.craftingItems.forEach { item ->
+                item?.item?.let {
+                    dropController.addDrop(mobsController.player.x, mobsController.player.y, it, item.amount)
+                }
+            }
+        }
+
+        currentWindow = null
+        tooltipManager.showMouseTooltip("")
+    }
+
+}
\ No newline at end of file
similarity index 79%
rename from core/src/ru/deadsoftware/cavedroid/game/windows/inventory/AbstractInventoryWindow.kt
rename to core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/AbstractInventoryWindow.kt
index 06606049c9670d15b440b236a447b42a52fc14c8..9d8e0f93387fd99da2198fa9d5ead2dc7028a13e 100644 (file)
@@ -1,4 +1,4 @@
-package ru.deadsoftware.cavedroid.game.windows.inventory
+package ru.deadsoftware.cavedroid.game.ui.windows.inventory
 
 import ru.deadsoftware.cavedroid.game.GameUiWindow
 import ru.deadsoftware.cavedroid.game.model.item.InventoryItem
similarity index 86%
rename from core/src/ru/deadsoftware/cavedroid/game/windows/inventory/CraftingInventoryWindow.kt
rename to core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CraftingInventoryWindow.kt
index 03808f1751abed4c132d58a70cf08b9381ea4676..13dbd83ce930e526f6b0ff405d572c5dc53af487 100644 (file)
@@ -1,4 +1,4 @@
-package ru.deadsoftware.cavedroid.game.windows.inventory
+package ru.deadsoftware.cavedroid.game.ui.windows.inventory
 
 import ru.deadsoftware.cavedroid.game.GameUiWindow
 import ru.deadsoftware.cavedroid.game.model.item.InventoryItem
similarity index 81%
rename from core/src/ru/deadsoftware/cavedroid/game/windows/inventory/CreativeInventoryWindow.kt
rename to core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CreativeInventoryWindow.kt
index 5f72243a5ca8206aa9157c25403f065a23f93452..22a3d5663c7b35cf065329aa49a38d838ac0406d 100644 (file)
@@ -1,4 +1,4 @@
-package ru.deadsoftware.cavedroid.game.windows.inventory
+package ru.deadsoftware.cavedroid.game.ui.windows.inventory
 
 import ru.deadsoftware.cavedroid.game.GameUiWindow
 import ru.deadsoftware.cavedroid.game.model.item.InventoryItem
similarity index 86%
rename from core/src/ru/deadsoftware/cavedroid/game/windows/inventory/SurvivalInventoryWindow.kt
rename to core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/SurvivalInventoryWindow.kt
index 4eeba3ce9a079d2aacc11738dc8839e025a811c6..685642c396642cebbd1054bc098eac41a8bcb882 100644 (file)
@@ -1,4 +1,4 @@
-package ru.deadsoftware.cavedroid.game.windows.inventory
+package ru.deadsoftware.cavedroid.game.ui.windows.inventory
 
 import ru.deadsoftware.cavedroid.game.GameUiWindow
 import ru.deadsoftware.cavedroid.game.model.item.InventoryItem
diff --git a/core/src/ru/deadsoftware/cavedroid/game/windows/GameWindowsManager.kt b/core/src/ru/deadsoftware/cavedroid/game/windows/GameWindowsManager.kt
deleted file mode 100644 (file)
index b07f1fd..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-package ru.deadsoftware.cavedroid.game.windows
-
-import ru.deadsoftware.cavedroid.MainConfig
-import ru.deadsoftware.cavedroid.game.GameScope
-import ru.deadsoftware.cavedroid.game.GameUiWindow
-import ru.deadsoftware.cavedroid.game.mobs.MobsController
-import ru.deadsoftware.cavedroid.game.model.item.InventoryItem
-import ru.deadsoftware.cavedroid.game.windows.inventory.AbstractInventoryWindow
-import ru.deadsoftware.cavedroid.game.windows.inventory.CraftingInventoryWindow
-import ru.deadsoftware.cavedroid.game.windows.inventory.CreativeInventoryWindow
-import ru.deadsoftware.cavedroid.game.windows.inventory.SurvivalInventoryWindow
-import javax.inject.Inject
-
-@GameScope
-class GameWindowsManager @Inject constructor(
-    private val mainConfig: MainConfig,
-    private val mobsController: MobsController,
-) {
-
-    var creativeScrollAmount = 0
-    var isDragging = false
-
-    var currentWindow: AbstractInventoryWindow? = null
-
-    @JvmName("getCurrentWindowType")
-    fun getCurrentWindow(): GameUiWindow {
-        return currentWindow?.type ?: GameUiWindow.NONE
-    }
-
-    fun openInventory() {
-        if (mobsController.player.gameMode == 1) {
-            currentWindow = CreativeInventoryWindow(GameUiWindow.CREATIVE_INVENTORY)
-        } else {
-            currentWindow = SurvivalInventoryWindow(GameUiWindow.SURVIVAL_INVENTORY)
-        }
-    }
-
-    fun openCrafting() {
-        currentWindow = CraftingInventoryWindow(GameUiWindow.CRAFTING_TABLE)
-    }
-
-    fun closeWindow() {
-        currentWindow = null
-    }
-
-}
\ No newline at end of file
index b7fd03e132063167fe37cc0ee2d97ac5f2b6090e..029c59f362407e74cdd0c138a9ac03ca2880fc10 100644 (file)
@@ -199,6 +199,7 @@ public class Assets {
         setPlayerHeadOrigin();
         minecraftFont = new BitmapFont(assetLoader.getAssetHandle("font.fnt"), true);
         minecraftFont.getData().setScale(.375f);
+        minecraftFont.setUseIntegerPositions(false);
     }
 
     /**