From: fredboy Date: Tue, 14 May 2024 16:35:57 +0000 (+0700) Subject: Input handler modules code generation X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=ef72467133765381894c3af625e8644f96439642;p=cavedroid.git Input handler modules code generation --- diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java b/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java index 2ae4756..0dcbefc 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java @@ -9,7 +9,8 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.ObjectMap; import com.badlogic.gdx.utils.TimeUtils; import ru.deadsoftware.cavedroid.MainConfig; -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler; +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler; +import ru.deadsoftware.cavedroid.game.input.IMouseInputHandler; import ru.deadsoftware.cavedroid.game.input.Joystick; import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction; import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction; @@ -51,8 +52,8 @@ public class GameRenderer extends Renderer { private final CursorMouseInputHandler mCursorMouseInputHandler; private final MouseInputActionMapper mMouseInputActionMapper; private final KeyboardInputActionMapper mKeyboardInputActionMapper; - private final Set> mMouseInputHandlers; - private final Set> mKeyboardInputHandlers; + private final Set mMouseInputHandlers; + private final Set mKeyboardInputHandlers; private final GameWindowsManager mGameWindowsManager; private final TooltipManager mTooltipManager; @@ -71,8 +72,8 @@ public class GameRenderer extends Renderer { CursorMouseInputHandler cursorMouseInputHandler, MouseInputActionMapper mouseInputActionMapper, KeyboardInputActionMapper keyboardInputActionMapper, - Set> mouseInputHandlers, - Set> keyboardInputHandlers, + Set mouseInputHandlers, + Set keyboardInputHandlers, GameWindowsManager gameWindowsManager, TooltipManager tooltipManager) { super(mainConfig.getWidth(), mainConfig.getHeight()); @@ -224,7 +225,7 @@ public class GameRenderer extends Renderer { boolean anyProcessed = false; - for (IGameInputHandler handler : mMouseInputHandlers) { + for (IMouseInputHandler handler : mMouseInputHandlers) { final boolean conditions = handler.checkConditions(action); if (conditions) { anyProcessed = true; @@ -338,7 +339,7 @@ public class GameRenderer extends Renderer { boolean anyProcessed = false; - for (IGameInputHandler handler : mKeyboardInputHandlers) { + for (IKeyboardInputHandler handler : mKeyboardInputHandlers) { final boolean conditions = handler.checkConditions(action); if (conditions) { anyProcessed = true; diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/GameInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/GameInputHandler.kt new file mode 100644 index 0000000..55dc618 --- /dev/null +++ b/core/src/ru/deadsoftware/cavedroid/game/input/GameInputHandler.kt @@ -0,0 +1,40 @@ +package ru.deadsoftware.cavedroid.game.input + +import ru.deadsoftware.cavedroid.game.input.action.IGameInputAction +import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction +import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction +import ru.fredboy.cavedroid.ksp.annotations.GenerateSetMultibindingsModule + +@GenerateSetMultibindingsModule( + interfaceClass = IKeyboardInputHandler::class, + modulePackage = "ru.deadsoftware.cavedroid.game.input", + moduleName = "KeyboardInputHandlersModule" +) +annotation class KeyboardInputHandler + +@GenerateSetMultibindingsModule( + interfaceClass = IMouseInputHandler::class, + modulePackage = "ru.deadsoftware.cavedroid.game.input", + moduleName = "MouseInputHandlersModule" +) +annotation class MouseInputHandler + +interface IKeyboardInputHandler : IGameInputHandler + +interface IMouseInputHandler : IGameInputHandler + +interface IGameInputHandler { + + /** + * Implementation should check if conditions for handling an input are satisfied + * For example - inventory input handler should return false if inventory is closed + */ + fun checkConditions(action: A): Boolean + + /** + * Handle given input action. + * This will not be called if [checkConditions] returned false + */ + fun handle(action: A) + +} \ No newline at end of file diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/IGameInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/IGameInputHandler.kt deleted file mode 100644 index a8eaad1..0000000 --- a/core/src/ru/deadsoftware/cavedroid/game/input/IGameInputHandler.kt +++ /dev/null @@ -1,19 +0,0 @@ -package ru.deadsoftware.cavedroid.game.input - -import ru.deadsoftware.cavedroid.game.input.action.IGameInputAction - -interface IGameInputHandler { - - /** - * Implementation should check if conditions for handling an input are satisfied - * For example - inventory input handler should return false if inventory is closed - */ - fun checkConditions(action: A): Boolean - - /** - * Handle given input action. - * This will not be called if [checkConditions] returned false - */ - fun handle(action: A) - -} \ No newline at end of file diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/KeyboardInputHandlersModule.kt b/core/src/ru/deadsoftware/cavedroid/game/input/KeyboardInputHandlersModule.kt deleted file mode 100644 index a58e522..0000000 --- a/core/src/ru/deadsoftware/cavedroid/game/input/KeyboardInputHandlersModule.kt +++ /dev/null @@ -1,139 +0,0 @@ -package ru.deadsoftware.cavedroid.game.input - -import dagger.Binds -import dagger.Module -import dagger.multibindings.IntoSet -import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction -import ru.deadsoftware.cavedroid.game.input.handler.keyboard.* - -@Module -object KeyboardInputHandlersModule { - - @Binds - @IntoSet - @GameScope - fun bindGoLeftKeyboardInputHandler(handler: GoLeftKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindGoRightKeyboardInputHandler(handler: GoRightKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindJumpKeyboardActionHandler(handler: JumpKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindFlyUpKeyboardActionHandler(handler: FlyUpKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindTurnOnFlyModeKeyboardActionHandler(handler: TurnOnFlyModeKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindFlyDownKeyboardActionHandler(handler: FlyDownKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindOpenInventoryKeyboardInputHandler(handler: OpenInventoryKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindCloseGameWindowKeyboardInputHandler(handler: CloseGameWindowKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindToggleDebugInfoKeyboardInputHandler(handler: ToggleDebugInfoKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindToggleMinimapKeyboardInputHandler(handler: ToggleMinimapKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindToggleGameModeKeyboardInputHandler(handler: ToggleGameModeKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindPauseGameKeyboardInputHandler(handler: PauseGameKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindToggleControlsModeKeyboardInputHandler(handler: ToggleControlsModeKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindMoveCursorControlsModeKeyboardInputHandler(handler: MoveCursorControlsModeKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindOpenCraftingKeyboardInputHandler(handler: DropItemKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindSwimUpKeyboardInputHandler(handler: SwimUpKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindStopSwimKeyboardInputHandler(handler: StopSwimKeyboardInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindSelectHotbarSlotKeyboardInputHandler(handler: SelectHotbarSlotKeyboardInputHandler): IGameInputHandler { - return handler - } - -} \ No newline at end of file diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/MouseInputHandlersModule.kt b/core/src/ru/deadsoftware/cavedroid/game/input/MouseInputHandlersModule.kt deleted file mode 100644 index f0c3b3b..0000000 --- a/core/src/ru/deadsoftware/cavedroid/game/input/MouseInputHandlersModule.kt +++ /dev/null @@ -1,97 +0,0 @@ -package ru.deadsoftware.cavedroid.game.input - -import dagger.Binds -import dagger.Module -import dagger.multibindings.IntoSet -import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction -import ru.deadsoftware.cavedroid.game.input.handler.touch.JoystickInputHandler -import ru.deadsoftware.cavedroid.game.input.handler.mouse.* - -@Module -object MouseInputHandlersModule { - - @Binds - @IntoSet - @GameScope - fun bindCursorMouseInputHandler(handler: CursorMouseInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindHoldHotbarMouseInputHandler(handler: HotbarMouseInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindCloseGameWindowMouseActionHandler(handler: CloseGameWindowMouseInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindCreativeInventoryScrollMouseInputHandler(handler: CreativeInventoryScrollMouseInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindSelectCreativeInventoryItemMouseActionHandler(handler: SelectCreativeInventoryItemMouseInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindAttackMouseInputHandler(handler: AttackMouseInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindUseItemMouseInputActionHandler(handler: UseItemMouseInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindSelectSurvivalInventoryItemMouseInputHandler(handler: SelectSurvivalInventoryItemMouseInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindSelectCraftingInventoryItemMouseInputHandler(handler: SelectCraftingInventoryItemMouseInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindSelectFurnaceInventoryItemMouseInputHandler(handler: SelectFurnaceInventoryItemMouseInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindJoystickInputHandler(handler: JoystickInputHandler): IGameInputHandler { - return handler - } - - @Binds - @IntoSet - @GameScope - fun bindSelectChestInventoryItemMouseInputHandler(handler: SelectChestInventoryItemMouseInputHandler): IGameInputHandler { - return handler - } -} \ 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 89a7b69..cbc254e 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/CloseGameWindowKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/CloseGameWindowKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard 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.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -11,11 +12,12 @@ import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager import javax.inject.Inject @GameScope +@KeyboardInputHandler class CloseGameWindowKeyboardInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, private val dropController: DropController, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.OpenInventory && 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 04f5520..01a0c1f 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/DropItemKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/DropItemKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard 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.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -13,11 +14,12 @@ import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager import javax.inject.Inject @GameScope +@KeyboardInputHandler class DropItemKeyboardInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, private val dropController: DropController, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.DropItem && diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/FlyDownKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/FlyDownKeyboardInputHandler.kt index 0bb0a77..8e41dfe 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/FlyDownKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/FlyDownKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -10,10 +11,11 @@ import ru.deadsoftware.cavedroid.game.mobs.player.Player import javax.inject.Inject @GameScope +@KeyboardInputHandler class FlyDownKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.Down && diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/FlyUpKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/FlyUpKeyboardInputHandler.kt index bf12c1a..976b069 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/FlyUpKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/FlyUpKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -10,10 +11,11 @@ import ru.deadsoftware.cavedroid.game.mobs.player.Player import javax.inject.Inject @GameScope +@KeyboardInputHandler class FlyUpKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.Up && diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/GoLeftKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/GoLeftKeyboardInputHandler.kt index 421e47e..8234476 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/GoLeftKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/GoLeftKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.Mob @@ -11,10 +12,11 @@ import ru.deadsoftware.cavedroid.game.mobs.player.Player import javax.inject.Inject @GameScope +@KeyboardInputHandler class GoLeftKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.Left && diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/GoRightKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/GoRightKeyboardInputHandler.kt index e3f5bf9..3139a17 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/GoRightKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/GoRightKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.Mob @@ -11,10 +12,11 @@ import ru.deadsoftware.cavedroid.game.mobs.player.Player import javax.inject.Inject @GameScope +@KeyboardInputHandler class GoRightKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.Right && diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/JumpKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/JumpKeyboardInputHandler.kt index 1e68cea..30f12dd 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/JumpKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/JumpKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -10,10 +11,11 @@ import ru.deadsoftware.cavedroid.game.mobs.player.Player import javax.inject.Inject @GameScope +@KeyboardInputHandler class JumpKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.Up && diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/MoveCursorControlsModeKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/MoveCursorControlsModeKeyboardInputHandler.kt index 0cb74d7..98d3e0a 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/MoveCursorControlsModeKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/MoveCursorControlsModeKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -11,11 +12,12 @@ import ru.deadsoftware.cavedroid.game.world.GameWorld import javax.inject.Inject @GameScope +@KeyboardInputHandler class MoveCursorControlsModeKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, private val gameWorld: GameWorld, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return mainConfig.isTouch && 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 ec8190a..a1ca3da 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 @@ -2,16 +2,18 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard 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.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager import javax.inject.Inject @GameScope +@KeyboardInputHandler class OpenInventoryKeyboardInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.OpenInventory && diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/PauseGameKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/PauseGameKeyboardInputHandler.kt index b39ee74..e4d6707 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/PauseGameKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/PauseGameKeyboardInputHandler.kt @@ -4,7 +4,8 @@ import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameSaver 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.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -15,6 +16,7 @@ import ru.deadsoftware.cavedroid.game.world.GameWorld import javax.inject.Inject @GameScope +@KeyboardInputHandler class PauseGameKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val dropController: DropController, @@ -22,7 +24,7 @@ class PauseGameKeyboardInputHandler @Inject constructor( private val gameWorld: GameWorld, private val containerController: ContainerController, private val gameWindowsManager: GameWindowsManager, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.Pause && action.isKeyDown 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 index 45e04da..0c7ea74 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SelectHotbarSlotKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SelectHotbarSlotKeyboardInputHandler.kt @@ -1,16 +1,18 @@ 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.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler 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 +@KeyboardInputHandler class SelectHotbarSlotKeyboardInputHandler @Inject constructor( private val mobsController: MobsController, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.SelectHotbarSlot && diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/StopSwimKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/StopSwimKeyboardInputHandler.kt index e25a99f..7256c54 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/StopSwimKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/StopSwimKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -11,11 +12,12 @@ import ru.deadsoftware.cavedroid.game.world.GameWorld import javax.inject.Inject @GameScope +@KeyboardInputHandler class StopSwimKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, private val gameWorld: GameWorld, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.Up && !action.isKeyDown && diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SwimUpKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SwimUpKeyboardInputHandler.kt index 3159e7f..9dc4777 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SwimUpKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SwimUpKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -11,11 +12,12 @@ import ru.deadsoftware.cavedroid.game.world.GameWorld import javax.inject.Inject @GameScope +@KeyboardInputHandler class SwimUpKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, private val gameWorld: GameWorld, -) : IGameInputHandler { +) : IKeyboardInputHandler { private fun checkSwim(): Boolean { return gameWorld.getForeMap(mobsController.player.mapX, mobsController.player.lowerMapY).isFluid() 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 fc95e29..a933c80 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 @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -10,10 +11,11 @@ import ru.deadsoftware.cavedroid.game.mobs.player.Player import javax.inject.Inject @GameScope +@KeyboardInputHandler class ToggleControlsModeKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.SwitchControlsMode && !action.isKeyDown diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleDebugInfoKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleDebugInfoKeyboardInputHandler.kt index 96bc21d..065b28c 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleDebugInfoKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleDebugInfoKeyboardInputHandler.kt @@ -2,15 +2,17 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import javax.inject.Inject @GameScope +@KeyboardInputHandler class ToggleDebugInfoKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.ShowDebug && action.isKeyDown diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleGameModeKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleGameModeKeyboardInputHandler.kt index ef4e696..a17e6d2 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleGameModeKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleGameModeKeyboardInputHandler.kt @@ -1,16 +1,18 @@ 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.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler 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 +@KeyboardInputHandler class ToggleGameModeKeyboardInputHandler @Inject constructor( private val mobsController: MobsController -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleMinimapKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleMinimapKeyboardInputHandler.kt index d39dfdb..6f22e4c 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleMinimapKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/ToggleMinimapKeyboardInputHandler.kt @@ -2,15 +2,17 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import javax.inject.Inject @GameScope +@KeyboardInputHandler class ToggleMinimapKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return action.actionKey is KeyboardInputActionKey.ShowMap && action.isKeyDown diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/TurnOnFlyModeKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/TurnOnFlyModeKeyboardInputHandler.kt index f3b65eb..3b43d31 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/TurnOnFlyModeKeyboardInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/TurnOnFlyModeKeyboardInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.keyboard import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameScope -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler +import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey import ru.deadsoftware.cavedroid.game.mobs.MobsController @@ -10,10 +11,11 @@ import ru.deadsoftware.cavedroid.game.mobs.player.Player import javax.inject.Inject @GameScope +@KeyboardInputHandler class TurnOnFlyModeKeyboardInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, -) : IGameInputHandler { +) : IKeyboardInputHandler { override fun checkConditions(action: KeyboardInputAction): Boolean { return mobsController.player.gameMode == 1 && action.actionKey is KeyboardInputActionKey.Up && diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/AbstractInventoryItemsMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/AbstractInventoryItemsMouseInputHandler.kt index dec8b7d..3b925b0 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/AbstractInventoryItemsMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/AbstractInventoryItemsMouseInputHandler.kt @@ -3,7 +3,7 @@ package ru.deadsoftware.cavedroid.game.input.handler.mouse import com.badlogic.gdx.graphics.g2d.TextureRegion import ru.deadsoftware.cavedroid.game.GameItemsHolder import ru.deadsoftware.cavedroid.game.GameUiWindow -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IMouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey import ru.deadsoftware.cavedroid.game.input.isInsideWindow @@ -17,7 +17,7 @@ abstract class AbstractInventoryItemsMouseInputHandler( private val gameItemsHolder: GameItemsHolder, private val gameWindowsManager: GameWindowsManager, private val windowType: GameUiWindow, -) : IGameInputHandler { +) : IMouseInputHandler { protected abstract val windowTexture: TextureRegion 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 2afc3d5..c2a22ed 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/AttackMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/AttackMouseInputHandler.kt @@ -2,7 +2,8 @@ package ru.deadsoftware.cavedroid.game.input.handler.mouse 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.IMouseInputHandler +import ru.deadsoftware.cavedroid.game.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey import ru.deadsoftware.cavedroid.game.input.isInsideHotbar @@ -12,11 +13,12 @@ import ru.deadsoftware.cavedroid.game.world.GameWorld import javax.inject.Inject @GameScope +@MouseInputHandler class AttackMouseInputHandler @Inject constructor( private val mobsController: MobsController, private val gameWorld: GameWorld, private val gameWindowsManager: GameWindowsManager -) : IGameInputHandler { +) : IMouseInputHandler { override fun checkConditions(action: MouseInputAction): Boolean { return gameWindowsManager.getCurrentWindow() == GameUiWindow.NONE && 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 f6f6cfc..b5ff2c5 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 @@ -4,7 +4,8 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion import ru.deadsoftware.cavedroid.game.GameScope import ru.deadsoftware.cavedroid.game.GameUiWindow import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IMouseInputHandler +import ru.deadsoftware.cavedroid.game.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey import ru.deadsoftware.cavedroid.game.input.isInsideWindow @@ -14,11 +15,12 @@ import ru.deadsoftware.cavedroid.misc.Assets import javax.inject.Inject @GameScope +@MouseInputHandler class CloseGameWindowMouseInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, private val dropController: DropController, -) : IGameInputHandler { +) : IMouseInputHandler { private val creativeInventoryTexture get() = requireNotNull(Assets.textureRegions["creative"]) private val survivalInventoryTexture get() = requireNotNull(Assets.textureRegions["survival"]) 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 11f76e9..bf6ba37 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CreativeInventoryScrollMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CreativeInventoryScrollMouseInputHandler.kt @@ -6,7 +6,8 @@ import ru.deadsoftware.cavedroid.game.GameItemsHolder import ru.deadsoftware.cavedroid.game.GameScope import ru.deadsoftware.cavedroid.game.GameUiWindow import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IMouseInputHandler +import ru.deadsoftware.cavedroid.game.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey import ru.deadsoftware.cavedroid.game.input.isInsideWindow @@ -15,11 +16,12 @@ import javax.inject.Inject import kotlin.math.abs @GameScope +@MouseInputHandler class CreativeInventoryScrollMouseInputHandler @Inject constructor( private val mainConfig: MainConfig, private val gameWindowsManager: GameWindowsManager, private val gameItemsHolder: GameItemsHolder, -) : IGameInputHandler { +) : IMouseInputHandler { private val creativeInventoryTexture get() = requireNotNull(Assets.textureRegions["creative"]) 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 454337e..5d5c79f 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CursorMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CursorMouseInputHandler.kt @@ -5,7 +5,8 @@ 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.IMouseInputHandler +import ru.deadsoftware.cavedroid.game.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey import ru.deadsoftware.cavedroid.game.mobs.Mob @@ -22,6 +23,7 @@ import ru.deadsoftware.cavedroid.misc.utils.px import javax.inject.Inject @GameScope +@MouseInputHandler class CursorMouseInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, @@ -29,7 +31,7 @@ class CursorMouseInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val gameItemsHolder: GameItemsHolder, private val tooltipManager: TooltipManager, -) : IGameInputHandler { +) : IMouseInputHandler { private val player get() = mobsController.player 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 18cd41d..45ae49b 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/HotbarMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/HotbarMouseInputHandler.kt @@ -4,7 +4,8 @@ import com.badlogic.gdx.utils.Timer import ru.deadsoftware.cavedroid.game.GameScope import ru.deadsoftware.cavedroid.game.GameUiWindow import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IMouseInputHandler +import ru.deadsoftware.cavedroid.game.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey import ru.deadsoftware.cavedroid.game.input.handler.keyboard.DropItemKeyboardInputHandler.Companion.DROP_DISTANCE @@ -18,11 +19,12 @@ import ru.deadsoftware.cavedroid.misc.Assets import javax.inject.Inject @GameScope +@MouseInputHandler class HotbarMouseInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, private val dropController: DropController, -) : IGameInputHandler { +) : IMouseInputHandler { private val hotbarTexture get() = requireNotNull(Assets.textureRegions["hotbar"]) diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectChestInventoryItemMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectChestInventoryItemMouseInputHandler.kt index d47202e..3118e9f 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectChestInventoryItemMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectChestInventoryItemMouseInputHandler.kt @@ -3,6 +3,7 @@ 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.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.mobs.MobsController import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsConfigs @@ -12,6 +13,7 @@ import ru.deadsoftware.cavedroid.misc.Assets import javax.inject.Inject @GameScope +@MouseInputHandler class SelectChestInventoryItemMouseInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, 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 88e3620..cc993c9 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 @@ -3,6 +3,7 @@ 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.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.mobs.MobsController import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsConfigs @@ -12,6 +13,7 @@ import ru.deadsoftware.cavedroid.misc.Assets import javax.inject.Inject @GameScope +@MouseInputHandler class SelectCraftingInventoryItemMouseInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, 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 272a178..5c6975f 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectCreativeInventoryItemMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectCreativeInventoryItemMouseInputHandler.kt @@ -4,7 +4,8 @@ import ru.deadsoftware.cavedroid.game.GameItemsHolder import ru.deadsoftware.cavedroid.game.GameScope import ru.deadsoftware.cavedroid.game.GameUiWindow import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IMouseInputHandler +import ru.deadsoftware.cavedroid.game.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey import ru.deadsoftware.cavedroid.game.input.isInsideWindow @@ -14,11 +15,12 @@ import ru.deadsoftware.cavedroid.misc.Assets import javax.inject.Inject @GameScope +@MouseInputHandler class SelectCreativeInventoryItemMouseInputHandler @Inject constructor( private val gameItemsHolder: GameItemsHolder, private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, -) : IGameInputHandler { +) : IMouseInputHandler { private val creativeInventoryTexture get() = requireNotNull(Assets.textureRegions["creative"]) diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectFurnaceInventoryItemMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectFurnaceInventoryItemMouseInputHandler.kt index f4a00eb..164b0c1 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectFurnaceInventoryItemMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/SelectFurnaceInventoryItemMouseInputHandler.kt @@ -3,6 +3,7 @@ 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.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.mobs.MobsController import ru.deadsoftware.cavedroid.game.model.item.InventoryItem.Companion.isNoneOrNull @@ -14,6 +15,7 @@ import ru.deadsoftware.cavedroid.misc.Assets import javax.inject.Inject @GameScope +@MouseInputHandler class SelectFurnaceInventoryItemMouseInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, 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 0a455ab..9f25b9a 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 @@ -3,6 +3,7 @@ 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.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.mobs.MobsController import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsConfigs @@ -12,6 +13,7 @@ import ru.deadsoftware.cavedroid.misc.Assets import javax.inject.Inject @GameScope +@MouseInputHandler class SelectSurvivalInventoryItemMouseInputHandler @Inject constructor( private val gameWindowsManager: GameWindowsManager, private val mobsController: MobsController, 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 04bc619..c0ff332 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/UseItemMouseInputHandler.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/UseItemMouseInputHandler.kt @@ -9,7 +9,8 @@ import ru.deadsoftware.cavedroid.game.actions.placeToForegroundAction import ru.deadsoftware.cavedroid.game.actions.placeblock.IPlaceBlockAction import ru.deadsoftware.cavedroid.game.actions.useblock.IUseBlockAction import ru.deadsoftware.cavedroid.game.actions.useitem.IUseItemAction -import ru.deadsoftware.cavedroid.game.input.IGameInputHandler +import ru.deadsoftware.cavedroid.game.input.IMouseInputHandler +import ru.deadsoftware.cavedroid.game.input.MouseInputHandler import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction import ru.deadsoftware.cavedroid.game.input.action.keys.MouseInputActionKey import ru.deadsoftware.cavedroid.game.input.isInsideHotbar @@ -20,6 +21,7 @@ import ru.deadsoftware.cavedroid.game.world.GameWorld import javax.inject.Inject @GameScope +@MouseInputHandler class UseItemMouseInputHandler @Inject constructor( private val mobsController: MobsController, private val useItemActionMap: Map, @@ -27,7 +29,7 @@ class UseItemMouseInputHandler @Inject constructor( private val useBlockActionMap: Map, private val gameWindowsManager: GameWindowsManager, private val gameWorld: GameWorld, -) : IGameInputHandler { +) : IMouseInputHandler { private var buttonHoldTask: Timer.Task? = 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 1c020a5..b6f31a3 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 @@ -4,11 +4,9 @@ import com.badlogic.gdx.utils.TimeUtils import ru.deadsoftware.cavedroid.MainConfig 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.Joystick +import ru.deadsoftware.cavedroid.game.input.* 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.Mob import ru.deadsoftware.cavedroid.game.mobs.MobsController import ru.deadsoftware.cavedroid.game.mobs.player.Player @@ -17,12 +15,13 @@ import ru.deadsoftware.cavedroid.game.world.GameWorld import javax.inject.Inject @GameScope +@MouseInputHandler class JoystickInputHandler @Inject constructor( private val mainConfig: MainConfig, private val mobsController: MobsController, private val gameWindowsManager: GameWindowsManager, private val gameWorld: GameWorld, -) : IGameInputHandler { +) : IMouseInputHandler { private var activateTimeMs = 0L private var cursorTimeoutMs = 100L diff --git a/desktop/build.gradle b/desktop/build.gradle index 58553a3..9127345 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -13,7 +13,7 @@ sourceSets.main.resources.srcDirs = ["../android/assets"] project.ext.mainClassName = "ru.deadsoftware.cavedroid.desktop.DesktopLauncher" project.ext.assetsDir = new File("../android/assets") -task run(dependsOn: classes, type: JavaExec) { +task run(dependsOn: build, type: JavaExec) { main = project.mainClassName classpath = sourceSets.main.runtimeClasspath standardInput = System.in @@ -22,7 +22,7 @@ task run(dependsOn: classes, type: JavaExec) { args "--debug" } -task runTouch(dependsOn: classes, type: JavaExec) { +task runTouch(dependsOn: build, type: JavaExec) { main = project.mainClassName classpath = sourceSets.main.runtimeClasspath standardInput = System.in @@ -31,16 +31,7 @@ task runTouch(dependsOn: classes, type: JavaExec) { args "--touch", "--debug" } -task debug(dependsOn: classes, type: JavaExec) { - main = project.mainClassName - classpath = sourceSets.main.runtimeClasspath - standardInput = System.in - workingDir = project.assetsDir - ignoreExitValue = true as JavaExecSpec - debug = true -} - -task dist(type: Jar) { +task dist(dependsOn: build, type: Jar) { duplicatesStrategy = DuplicatesStrategy.EXCLUDE manifest { attributes 'Main-Class': project.mainClassName @@ -51,8 +42,6 @@ task dist(type: Jar) { with jar } -dist.dependsOn build - dependencies { implementation project(":core") implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializationVersion"