summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 34dbc04)
raw | patch | inline | side by side (parent: 34dbc04)
author | fredboy <fredboy@protonmail.com> | |
Tue, 7 May 2024 20:43:29 +0000 (03:43 +0700) | ||
committer | fredboy <fredboy@protonmail.com> | |
Tue, 7 May 2024 21:01:01 +0000 (04:01 +0700) |
41 files changed:
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
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 0000000..c94ebad
Binary files /dev/null and b/android/assets/textures/items/coal.png differ
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameModule.java b/core/src/ru/deadsoftware/cavedroid/game/GameModule.java
index 29175da1968fba60e36f64a8ebb8ec746c73b630..fbbd294b0e032dda43c29c6ce772303a83673c1f 100644 (file)
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;
@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;
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java b/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java
index 35f318aada2057cfa9d537fa069e54925829dd90..4b418a7b566ac26b03c72a926c8b382ecc3c69db 100644 (file)
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;
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;
private final Set<IGameInputHandler<MouseInputAction>> mMouseInputHandlers;
private final Set<IGameInputHandler<KeyboardInputAction>> mKeyboardInputHandlers;
private final GameWindowsManager mGameWindowsManager;
+ private final TooltipManager mTooltipManager;
@Inject
GameRenderer(MainConfig mainConfig,
KeyboardInputActionMapper keyboardInputActionMapper,
Set<IGameInputHandler<MouseInputAction>> mouseInputHandlers,
Set<IGameInputHandler<KeyboardInputAction>> keyboardInputHandlers,
- GameWindowsManager gameWindowsManager) {
+ GameWindowsManager gameWindowsManager,
+ TooltipManager tooltipManager) {
super(mainConfig.getWidth(), mainConfig.getHeight());
mMainConfig = mainConfig;
mMouseInputHandlers = mouseInputHandlers;
mKeyboardInputHandlers = keyboardInputHandlers;
mGameWindowsManager = gameWindowsManager;
+ mTooltipManager = tooltipManager;
Gdx.gl.glClearColor(0f, .6f, .6f, 1f);
}
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) {
@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();
+
}
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/actions/useblock/UseCraftingTableAction.kt b/core/src/ru/deadsoftware/cavedroid/game/actions/useblock/UseCraftingTableAction.kt
index 7c4136487d0fd1d4148d59c36de9ea8cce126809..3ce42b94f01ef0403e551ec2a80f5954cf14f1d7 100644 (file)
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/debug/DebugInfoStringsProvider.kt b/core/src/ru/deadsoftware/cavedroid/game/debug/DebugInfoStringsProvider.kt
index f34903b143f8d505f3738f67dc68047327662586..0886a0756f7a54a829edb8ad6769cb1b59f6bc3b 100644 (file)
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}",
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/KeyboardInputHandlersModule.kt b/core/src/ru/deadsoftware/cavedroid/game/input/KeyboardInputHandlersModule.kt
index 0a33d9337db9b7802dea88b9f76304f409408187..a58e52294dfe6a196c94f4f199a4023c7fcf9060 100644 (file)
return handler
}
+ @Binds
+ @IntoSet
+ @GameScope
+ fun bindSelectHotbarSlotKeyboardInputHandler(handler: SelectHotbarSlotKeyboardInputHandler): IGameInputHandler<KeyboardInputAction> {
+ return handler
+ }
+
}
\ No newline at end of file
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/action/keys/KeyboardInputActionKey.kt b/core/src/ru/deadsoftware/cavedroid/game/input/action/keys/KeyboardInputActionKey.kt
index 89ff50658340fd38c7366b6bec6cadbfc36d98b0..fd14fc4947412527773b85e76edf0864d62d8db8 100644 (file)
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/CloseGameWindowKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/CloseGameWindowKeyboardInputHandler.kt
index 705f9aa0e71a5ae60a64c8ac1e411c8cbf511a45..b2d1244aa91dbc0a903142733a8e58921d645111 100644 (file)
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/DropItemKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/DropItemKeyboardInputHandler.kt
index 7e6454c32dbb9eddd0890eee6f197a2237d317a8..4003271fd61301ac713fc65dc6fbb66897998d69 100644 (file)
--- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/DropItemKeyboardInputHandler.kt
+++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/DropItemKeyboardInputHandler.kt
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
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 0e2c11bd17a0adce97b6853cbe37965891b11fb0..50aa5b01b5d6677865d350b61574449ecae1ebf0 100644 (file)
--- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/OpenInventoryKeyboardInputHandler.kt
+++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/OpenInventoryKeyboardInputHandler.kt
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
--- /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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/AttackMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/AttackMouseInputHandler.kt
index a0bfa4cd8da9ea8d176a73c2c7da1175c31e229a..2afc3d5b1bbb50d6310f0fa4a247926c29bd9d3b 100644 (file)
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
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 e80ff476b00fdfbb02c1c7623ddb2b8969b3ee6a..bee22dc621d77b89b2029dbfec40eb6b05935cdc 100644 (file)
--- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt
+++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CreativeInventoryScrollMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CreativeInventoryScrollMouseInputHandler.kt
index 01cc4e23a5c1f78a38c7dd2ee6a4a8b47ef2e9b9..352d04bcb5fba0e98d439af2da68edcc5e4f0a0c 100644 (file)
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CursorMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CursorMouseInputHandler.kt
index 062859cf9cd53e95e6ed829098167607364014d5..6a4b5a4eb968101d134eeeefa7aa9b9e290b51bd 100644 (file)
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
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
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
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
}
if (player.cursorX != pastCursorX || player.cursorY != pastCursorY) {
player.blockDamage = 0f
}
+
+ if (gameWindowsManager.getCurrentWindow() == GameUiWindow.CREATIVE_INVENTORY) {
+ tooltipManager.showMouseTooltip(getCreativeTooltip(action).orEmpty())
+ }
}
companion object {
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/HotbarMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/HotbarMouseInputHandler.kt
index c7f54acf609f9b6740353b23b38c23b32ada02c6..0725abee6fc190dbbc230a82d1e7f1407790abc4 100644 (file)
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
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 4395337b1101bc2ec3ea5f22ba5ffbe1523ce8ec..89c0ce1061910b1378a8cf1a0573b647a7816682 100644 (file)
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
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 032bade3b74875e6dfddbf40537a2ed3ce4d0331..9ccbf6eac8fde6cddf301ee9e09aefec3918ea07 100644 (file)
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
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 828f02fa8fcbb5c4ddde5bd39a4f48707b3a1eac..ab65fb8c05d888d644bb63fcc618b46b453588d6 100644 (file)
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/UseItemMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/UseItemMouseInputHandler.kt
index da59bc65cc612e301edf8a355920c5ca285dff3c..04bc6198295fcf3fede52cfa413b685f3c6b6d9b 100644 (file)
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/mapper/KeyboardInputActionMapper.kt b/core/src/ru/deadsoftware/cavedroid/game/input/mapper/KeyboardInputActionMapper.kt
index 61e97932708cdcb07f122e8283a250fcfe0a89f1..8d18d070703931aeafdb4a41867d66e7c4b2cc35 100644 (file)
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
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/MobsController.kt b/core/src/ru/deadsoftware/cavedroid/game/mobs/MobsController.kt
index df2a6dec5eef62240a5708edf676af8008e003ee..158d22a9e55445ae1056e680c4fb3621f03a03e0 100644 (file)
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt b/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt
index b82aa44bcb775991b4ff12e175a511925620c28b..44ee6dd17e6bb94393475dc22c2778f4a2569338 100644 (file)
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")
}
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)
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) {
)
_items[0] = item.toInventoryItem(item.params.maxStack)
+ showCurrentItemTooltip()
}
@JvmOverloads
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Player.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Player.java
index dcc77ef81202b4bb6e96018b3651b348b3aeb1f1..241714a3579cc8bfb94e5d0fd39017cc0169ee4c 100644 (file)
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;
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) {
diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/DropController.java b/core/src/ru/deadsoftware/cavedroid/game/objects/DropController.java
index 798a84ce5b77415bbf88f87187c39d51e636ff04..639a2aa834365f9a27897f6bddfc9526213eab7f 100644 (file)
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();
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/render/HudRenderer.kt b/core/src/ru/deadsoftware/cavedroid/game/render/HudRenderer.kt
index 1053a9f3d2b887840f9a35ef018d37a93d5611aa..a2570e25f3120f8208233038f3b85e4738409dc4 100644 (file)
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
class HudRenderer @Inject constructor(
private val gameWorld: GameWorld,
private val mobsController: MobsController,
+ private val tooltipManager: TooltipManager,
) : IGameRenderer {
override val renderLayer = RENDER_LAYER
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) {
diff --git a/core/src/ru/deadsoftware/cavedroid/game/render/TouchControlsRenderer.kt b/core/src/ru/deadsoftware/cavedroid/game/render/TouchControlsRenderer.kt
index c768d5f07d1fc512d7b49fd964c0848dbb7d3618..ad68bce795a4721413fb373000a09ec1215243ce 100644 (file)
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/render/WindowsRenderer.kt b/core/src/ru/deadsoftware/cavedroid/game/render/WindowsRenderer.kt
index 2fa093f61719d8564637e5ce4e456b2e7153b201..03df48f4178e307a159b2c83944abfd3e07b678c 100644 (file)
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/render/windows/CraftingWindowRenderer.kt b/core/src/ru/deadsoftware/cavedroid/game/render/windows/CraftingWindowRenderer.kt
index cc8c1baf4522a6cd31fb625b6f6f1977c2475a7a..6772282b15b18968ef3d0d82a27d1f1f8fb3651e 100644 (file)
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/render/windows/CreativeWindowRenderer.kt b/core/src/ru/deadsoftware/cavedroid/game/render/windows/CreativeWindowRenderer.kt
index dede82f94252a226c9fda7bcccbef89f94b88392..6bfac428fc32d3c76ab8b33cf9845306e3057138 100644 (file)
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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/render/windows/SurvivalWindowRenderer.kt b/core/src/ru/deadsoftware/cavedroid/game/render/windows/SurvivalWindowRenderer.kt
index ef23be556e35397fb4a87714edcfb9bd1cf356d4..7ee3b27087eb76bd0b75f2549786b54b5eac241c 100644 (file)
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
--- /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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/windows/GameWindowsConfigs.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/GameWindowsConfigs.kt
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)
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)
-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
--- /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
diff --git a/core/src/ru/deadsoftware/cavedroid/game/windows/inventory/AbstractInventoryWindow.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/AbstractInventoryWindow.kt
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)
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)
-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/inventory/CraftingInventoryWindow.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CraftingInventoryWindow.kt
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)
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)
-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/inventory/CreativeInventoryWindow.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/CreativeInventoryWindow.kt
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)
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)
-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/inventory/SurvivalInventoryWindow.kt b/core/src/ru/deadsoftware/cavedroid/game/ui/windows/inventory/SurvivalInventoryWindow.kt
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)
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)
-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
+++ /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
diff --git a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java
index b7fd03e132063167fe37cc0ee2d97ac5f2b6090e..029c59f362407e74cdd0c138a9ac03ca2880fc10 100644 (file)
setPlayerHeadOrigin();
minecraftFont = new BitmapFont(assetLoader.getAssetHandle("font.fnt"), true);
minecraftFont.getData().setScale(.375f);
+ minecraftFont.setUseIntegerPositions(false);
}
/**