From 6da6f8b40b6945e0b4e8376f506c43e548918df4 Mon Sep 17 00:00:00 2001 From: fredboy Date: Sun, 21 Apr 2024 21:13:17 +0700 Subject: [PATCH] Add touch controls renderer to module --- .../ru/deadsoftware/cavedroid/game/render/RenderModule.kt | 5 +++++ .../cavedroid/game/render/TouchControlsRenderer.kt | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/core/src/ru/deadsoftware/cavedroid/game/render/RenderModule.kt b/core/src/ru/deadsoftware/cavedroid/game/render/RenderModule.kt index a23ae32..9ae3b46 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/render/RenderModule.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/render/RenderModule.kt @@ -38,6 +38,11 @@ object RenderModule { @GameScope fun bindWindowsRenderer(renderer: WindowsRenderer): IGameRenderer = renderer + @Binds + @IntoSet + @GameScope + fun bindTouchControlsRenderer(renderer: TouchControlsRenderer): IGameRenderer = renderer + @Binds @IntoSet @GameScope diff --git a/core/src/ru/deadsoftware/cavedroid/game/render/TouchControlsRenderer.kt b/core/src/ru/deadsoftware/cavedroid/game/render/TouchControlsRenderer.kt index e8b19d0..c9f2bcc 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/render/TouchControlsRenderer.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/render/TouchControlsRenderer.kt @@ -3,6 +3,7 @@ package ru.deadsoftware.cavedroid.game.render import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.glutils.ShapeRenderer import com.badlogic.gdx.math.Rectangle +import ru.deadsoftware.cavedroid.MainConfig import ru.deadsoftware.cavedroid.game.GameInput import ru.deadsoftware.cavedroid.game.GameScope import ru.deadsoftware.cavedroid.misc.Assets @@ -13,6 +14,7 @@ import javax.inject.Inject @GameScope class TouchControlsRenderer @Inject constructor( + private val mainConfig: MainConfig, private val gameInput: GameInput ) : IGameRenderer { @@ -21,6 +23,10 @@ class TouchControlsRenderer @Inject constructor( private val shadeTexture get() = Assets.textureRegions[SHADE_KEY] override fun draw(spriteBatch: SpriteBatch, shapeRenderer: ShapeRenderer, viewport: Rectangle, delta: Float) { + if (!mainConfig.isTouch) { + return + } + val touchControlsMap = Assets.guiMap touchControlsMap.forEach { (key, value) -> -- 2.29.2