DEADSOFTWARE

Add touch controls renderer to module
authorfredboy <fredboy@protonmail.com>
Sun, 21 Apr 2024 14:13:17 +0000 (21:13 +0700)
committerfredboy <fredboy@protonmail.com>
Sun, 21 Apr 2024 14:14:34 +0000 (21:14 +0700)
core/src/ru/deadsoftware/cavedroid/game/render/RenderModule.kt
core/src/ru/deadsoftware/cavedroid/game/render/TouchControlsRenderer.kt

index a23ae32ea7e241cbf4139717b3d7c30998637148..9ae3b462bfceb9ba88509d3059faef3fe0e5e6e4 100644 (file)
@@ -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
index e8b19d013f0d5a1431f27582f0d39b59c4b137b2..c9f2bccb4d57b83dc24bd08dfe27cdfdbf89b799 100644 (file)
@@ -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) ->