From: fredboy Date: Sun, 21 Apr 2024 14:13:17 +0000 (+0700) Subject: Add touch controls renderer to module X-Git-Tag: alpha0.6.0~4 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=6da6f8b40b6945e0b4e8376f506c43e548918df4;p=cavedroid.git Add touch controls renderer to module --- 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) ->