mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
making gamepad work again
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,7 +12,6 @@ Thumbs.db
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# Resources that should not be tracked
|
# Resources that should not be tracked
|
||||||
*.jar
|
|
||||||
assets/mods/basegame/demoworld
|
assets/mods/basegame/demoworld
|
||||||
#assets/mods/basegame/demoworld.gz
|
#assets/mods/basegame/demoworld.gz
|
||||||
external_resource_packs.zip
|
external_resource_packs.zip
|
||||||
|
|||||||
BIN
TerrarumBuild.jar
Normal file
BIN
TerrarumBuild.jar
Normal file
Binary file not shown.
BIN
lib/GetCpuName.jar
Normal file
BIN
lib/GetCpuName.jar
Normal file
Binary file not shown.
BIN
lib/gdx-controllers-desktop-natives.jar
Normal file
BIN
lib/gdx-controllers-desktop-natives.jar
Normal file
Binary file not shown.
BIN
lib/gdx-controllers-desktop.jar
Normal file
BIN
lib/gdx-controllers-desktop.jar
Normal file
Binary file not shown.
BIN
lib/gdx-controllers-lwjgl3.jar
Normal file
BIN
lib/gdx-controllers-lwjgl3.jar
Normal file
Binary file not shown.
BIN
lib/gdx-controllers.jar
Normal file
BIN
lib/gdx-controllers.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
lib/source/GetCpuName-src.jar
Normal file
BIN
lib/source/GetCpuName-src.jar
Normal file
Binary file not shown.
@@ -1,6 +1,9 @@
|
|||||||
package net.torvald.terrarum;
|
package net.torvald.terrarum;
|
||||||
|
|
||||||
import com.badlogic.gdx.*;
|
import com.badlogic.gdx.ApplicationListener;
|
||||||
|
import com.badlogic.gdx.Files;
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Screen;
|
||||||
import com.badlogic.gdx.assets.AssetManager;
|
import com.badlogic.gdx.assets.AssetManager;
|
||||||
import com.badlogic.gdx.audio.AudioDevice;
|
import com.badlogic.gdx.audio.AudioDevice;
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||||
@@ -26,8 +29,6 @@ import net.torvald.terrarum.worlddrawer.BlocksDrawer;
|
|||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer;
|
import net.torvald.terrarum.worlddrawer.LightmapRenderer;
|
||||||
import net.torvald.terrarumsansbitmap.gdx.GameFontBase;
|
import net.torvald.terrarumsansbitmap.gdx.GameFontBase;
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack;
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack;
|
||||||
import org.lwjgl.input.Controller;
|
|
||||||
import org.lwjgl.input.Controllers;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -174,7 +175,6 @@ public class AppLoader implements ApplicationListener {
|
|||||||
public static TinyAlphNum fontSmallNumbers;
|
public static TinyAlphNum fontSmallNumbers;
|
||||||
|
|
||||||
/** A gamepad. Multiple gamepads may controll this single virtualised gamepad. */
|
/** A gamepad. Multiple gamepads may controll this single virtualised gamepad. */
|
||||||
public static org.lwjgl.input.Controller gamepad = null;
|
|
||||||
public static float gamepadDeadzone = 0.1f;
|
public static float gamepadDeadzone = 0.1f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -305,21 +305,6 @@ public class AppLoader implements ApplicationListener {
|
|||||||
);
|
);
|
||||||
updateFullscreenQuad(appConfig.width, appConfig.height);
|
updateFullscreenQuad(appConfig.width, appConfig.height);
|
||||||
|
|
||||||
// enlist suitable gamepads
|
|
||||||
try {
|
|
||||||
Controllers.create();
|
|
||||||
|
|
||||||
printdbg(this, "Available gamepads: " + Controllers.getControllerCount());
|
|
||||||
for (int x = 0; x < Controllers.getControllerCount(); x++) {
|
|
||||||
Controller gamepad = Controllers.getController(x);
|
|
||||||
printdbg(this, String.format("Gamepad #%d: %s", x + 1, gamepad.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable e) {
|
|
||||||
printdbg(this, "Exception occured while creating controllers -- there will be no gamepads available.");
|
|
||||||
printdbg(this, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// set up renderer info variables
|
// set up renderer info variables
|
||||||
renderer = Gdx.graphics.getGLVersion().getRendererString();
|
renderer = Gdx.graphics.getGLVersion().getRendererString();
|
||||||
@@ -477,7 +462,6 @@ public class AppLoader implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IngameRenderer.INSTANCE.dispose();
|
IngameRenderer.INSTANCE.dispose();
|
||||||
if (Controllers.isCreated()) Controllers.destroy();
|
|
||||||
|
|
||||||
Terrarum.INSTANCE.dispose();
|
Terrarum.INSTANCE.dispose();
|
||||||
|
|
||||||
|
|||||||
@@ -28,20 +28,22 @@ object DefaultConfig {
|
|||||||
|
|
||||||
|
|
||||||
// control-gamepad
|
// control-gamepad
|
||||||
jsonObject.addProperty("gamepadkeyn", 4)
|
jsonObject.addProperty("gamepadkeyn", 3)
|
||||||
jsonObject.addProperty("gamepadkeyw", 1)
|
jsonObject.addProperty("gamepadkeyw", 2)
|
||||||
jsonObject.addProperty("gamepadkeys", 2)
|
jsonObject.addProperty("gamepadkeys", 0)
|
||||||
jsonObject.addProperty("gamepadkeye", 3) // logitech indices
|
jsonObject.addProperty("gamepadkeye", 1) // xbox indices
|
||||||
|
|
||||||
jsonObject.addProperty("gamepadlup", 4)
|
jsonObject.addProperty("gamepadlup", 4)
|
||||||
jsonObject.addProperty("gamepadrup", 5)
|
jsonObject.addProperty("gamepadrup", 5)
|
||||||
jsonObject.addProperty("gamepadldown", 6)
|
jsonObject.addProperty("gamepadselect", 6)
|
||||||
jsonObject.addProperty("gamepadrdown", 7) // logitech indices
|
jsonObject.addProperty("gamepadstart", 7)
|
||||||
|
|
||||||
|
jsonObject.addProperty("gamepadlstickx", 1)
|
||||||
|
jsonObject.addProperty("gamepadlsticky", 0)
|
||||||
|
jsonObject.addProperty("gamepadrstickx", 3)
|
||||||
|
jsonObject.addProperty("gamepadrsticky", 2) // 0-1-2-3 but sometimes 3-2-1-0 ?! what the actual fuck?
|
||||||
|
jsonObject.addProperty("gamepadtriggeraxis", 4) // positive: LT, negative: RT (xbox pad)
|
||||||
|
|
||||||
jsonObject.addProperty("gamepadlstickx", 0)
|
|
||||||
jsonObject.addProperty("gamepadlsticky", 1)
|
|
||||||
jsonObject.addProperty("gamepadrstickx", 2)
|
|
||||||
jsonObject.addProperty("gamepadrsticky", 3) // 0-1-2-3 but sometimes 3-2-1-0 ?! what the actual fuck?
|
|
||||||
|
|
||||||
jsonObject.addProperty("gamepadlabelstyle", "msxb360") // "nwii", "logitech", "sonyps", "msxb360", "generic"
|
jsonObject.addProperty("gamepadlabelstyle", "msxb360") // "nwii", "logitech", "sonyps", "msxb360", "generic"
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,13 @@ package net.torvald.terrarum.gamecontroller
|
|||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
import com.badlogic.gdx.InputAdapter
|
import com.badlogic.gdx.InputAdapter
|
||||||
|
import com.badlogic.gdx.controllers.Controller
|
||||||
|
import com.badlogic.gdx.controllers.ControllerListener
|
||||||
|
import com.badlogic.gdx.controllers.Controllers
|
||||||
|
import com.badlogic.gdx.controllers.PovDirection
|
||||||
|
import com.badlogic.gdx.math.Vector3
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.floorInt
|
import net.torvald.terrarum.floorInt
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
@@ -16,9 +22,11 @@ import net.torvald.terrarum.worlddrawer.WorldCamera
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2015-12-31.
|
* Created by minjaesong on 2015-12-31.
|
||||||
*/
|
*/
|
||||||
class IngameController(val ingame: Ingame) : InputAdapter() {
|
class IngameController(val ingame: Ingame) : InputAdapter(), ControllerListener {
|
||||||
|
|
||||||
|
|
||||||
|
var hasController = true
|
||||||
|
|
||||||
// these four values can also be accessed with GameContainer.<varname>
|
// these four values can also be accessed with GameContainer.<varname>
|
||||||
// e.g. gc.mouseTileX
|
// e.g. gc.mouseTileX
|
||||||
|
|
||||||
@@ -35,6 +43,13 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
|||||||
val mouseTileY: Int
|
val mouseTileY: Int
|
||||||
get() = (mouseY / FeaturesDrawer.TILE_SIZE).floorInt()
|
get() = (mouseY / FeaturesDrawer.TILE_SIZE).floorInt()
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (Controllers.getControllers().size == 0) {
|
||||||
|
hasController = false
|
||||||
|
printdbg(this, "Controller not found")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun update(delta: Float) {
|
fun update(delta: Float) {
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
@@ -196,4 +211,39 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun connected(p0: Controller?) {
|
||||||
|
hasController = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun buttonUp(p0: Controller?, p1: Int): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ySliderMoved(p0: Controller?, p1: Int, p2: Boolean): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun accelerometerMoved(p0: Controller?, p1: Int, p2: Vector3?): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun axisMoved(p0: Controller?, p1: Int, p2: Float): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun disconnected(p0: Controller?) {
|
||||||
|
hasController = false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun xSliderMoved(p0: Controller?, p1: Int, p2: Boolean): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun povMoved(p0: Controller?, p1: Int, p2: PovDirection?): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun buttonDown(p0: Controller?, p1: Int): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame
|
package net.torvald.terrarum.modulebasegame
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.controllers.Controllers
|
||||||
import com.badlogic.gdx.graphics.Camera
|
import com.badlogic.gdx.graphics.Camera
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.dataclass.CircularArray
|
import net.torvald.dataclass.CircularArray
|
||||||
@@ -253,7 +254,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val ingameController = IngameController(this)
|
val ingameController = IngameController(this)
|
||||||
|
|
||||||
/** Load rest of the game with GL context */
|
/** Load rest of the game with GL context */
|
||||||
fun postInit() {
|
fun postInit() {
|
||||||
@@ -266,7 +267,9 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// make controls work
|
||||||
Gdx.input.inputProcessor = ingameController
|
Gdx.input.inputProcessor = ingameController
|
||||||
|
Controllers.addListener(ingameController)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.controllers.Controllers
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
import net.torvald.spriteanimation.HasAssembledSprite
|
import net.torvald.spriteanimation.HasAssembledSprite
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
|
import net.torvald.terrarum.AppLoader.gamepadDeadzone
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
import net.torvald.terrarum.gameactors.faction.Faction
|
import net.torvald.terrarum.gameactors.faction.Faction
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
@@ -143,7 +145,6 @@ open class ActorHumanoid(
|
|||||||
@Transient private var prevVMoveKey = KEY_NULL
|
@Transient private var prevVMoveKey = KEY_NULL
|
||||||
|
|
||||||
@Transient private val AXIS_KEYBOARD = -13372f // leetz
|
@Transient private val AXIS_KEYBOARD = -13372f // leetz
|
||||||
@Transient private val GAMEPAD_JUMP = 7
|
|
||||||
|
|
||||||
var isUpDown = false; protected set
|
var isUpDown = false; protected set
|
||||||
var isDownDown = false; protected set
|
var isDownDown = false; protected set
|
||||||
@@ -225,11 +226,13 @@ open class ActorHumanoid(
|
|||||||
isRightDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyright"))
|
isRightDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyright"))
|
||||||
isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyjump"))
|
isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyjump"))
|
||||||
|
|
||||||
if (AppLoader.gamepad != null) {
|
if ((Terrarum.ingame as Ingame).ingameController.hasController) {
|
||||||
axisX = AppLoader.gamepad!!.getAxisValue(AppLoader.getConfigInt("gamepadlstickx"))
|
val gamepad = Controllers.getControllers()[0]
|
||||||
axisY = AppLoader.gamepad!!.getAxisValue(AppLoader.getConfigInt("gamepadlsticky"))
|
|
||||||
axisRX = AppLoader.gamepad!!.getAxisValue(AppLoader.getConfigInt("gamepadrstickx"))
|
axisX = gamepad.getAxis(AppLoader.getConfigInt("gamepadlstickx"))
|
||||||
axisRY = AppLoader.gamepad!!.getAxisValue(AppLoader.getConfigInt("gamepadrsticky"))
|
axisY = gamepad.getAxis(AppLoader.getConfigInt("gamepadlsticky"))
|
||||||
|
axisRX = gamepad.getAxis(AppLoader.getConfigInt("gamepadrstickx"))
|
||||||
|
axisRY = gamepad.getAxis(AppLoader.getConfigInt("gamepadrsticky"))
|
||||||
|
|
||||||
// deadzonning
|
// deadzonning
|
||||||
if (Math.abs(axisX) < AppLoader.gamepadDeadzone) axisX = 0f
|
if (Math.abs(axisX) < AppLoader.gamepadDeadzone) axisX = 0f
|
||||||
@@ -238,7 +241,7 @@ open class ActorHumanoid(
|
|||||||
if (Math.abs(axisRY) < AppLoader.gamepadDeadzone) axisRY = 0f
|
if (Math.abs(axisRY) < AppLoader.gamepadDeadzone) axisRY = 0f
|
||||||
|
|
||||||
isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyjump")) ||
|
isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyjump")) ||
|
||||||
AppLoader.gamepad!!.isButtonPressed(GAMEPAD_JUMP)
|
gamepad.getAxis(AppLoader.getConfigInt("gamepadtriggeraxis")) < -AppLoader.gamepadDeadzone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -250,7 +253,7 @@ open class ActorHumanoid(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private inline val hasController: Boolean
|
private inline val hasController: Boolean
|
||||||
get() = if (isGamer) AppLoader.gamepad != null
|
get() = if (isGamer) (Terrarum.ingame as Ingame).ingameController.hasController
|
||||||
else true
|
else true
|
||||||
|
|
||||||
private fun processInput(delta: Float) {
|
private fun processInput(delta: Float) {
|
||||||
@@ -264,7 +267,7 @@ open class ActorHumanoid(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ↑F, ↑S
|
// ↑F, ↑S
|
||||||
if (isWalkingH && !isLeftDown && !isRightDown) {
|
if (isWalkingH && !isLeftDown && !isRightDown && axisX.abs() < gamepadDeadzone) {
|
||||||
walkHStop()
|
walkHStop()
|
||||||
prevHMoveKey = KEY_NULL
|
prevHMoveKey = KEY_NULL
|
||||||
}
|
}
|
||||||
@@ -278,7 +281,7 @@ open class ActorHumanoid(
|
|||||||
}
|
}
|
||||||
// ↑E
|
// ↑E
|
||||||
// ↑D
|
// ↑D
|
||||||
if (isNoClip && !isUpDown && !isDownDown) {
|
if (isNoClip && !isUpDown && !isDownDown && axisY.abs() < gamepadDeadzone) {
|
||||||
walkVStop()
|
walkVStop()
|
||||||
prevVMoveKey = KEY_NULL
|
prevVMoveKey = KEY_NULL
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.ui
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.controllers.Controllers
|
||||||
import com.badlogic.gdx.graphics.Camera
|
import com.badlogic.gdx.graphics.Camera
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
@@ -10,6 +11,7 @@ import net.torvald.terrarum.Terrarum.mouseTileY
|
|||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
|
||||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
@@ -190,10 +192,12 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
|
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
|
||||||
if (AppLoader.gamepad != null) {
|
if ((Terrarum.ingame as? Ingame)?.ingameController?.hasController == true) {
|
||||||
|
val gamepad = Controllers.getControllers()[0]
|
||||||
|
|
||||||
drawGamepadAxis(batch,
|
drawGamepadAxis(batch,
|
||||||
AppLoader.gamepad!!.getAxisValue(3),
|
gamepad.getAxis(AppLoader.getConfigInt("gamepadlstickx")),
|
||||||
AppLoader.gamepad!!.getAxisValue(2),
|
gamepad.getAxis(AppLoader.getConfigInt("gamepadlsticky")),
|
||||||
Terrarum.WIDTH - 135,
|
Terrarum.WIDTH - 135,
|
||||||
40
|
40
|
||||||
)
|
)
|
||||||
@@ -308,7 +312,7 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun drawGamepadAxis(batch: SpriteBatch, axisX: Float, axisY: Float, uiX: Int, uiY: Int) {
|
private fun drawGamepadAxis(batch: SpriteBatch, axisX: Float, axisY: Float, uiX: Int, uiY: Int) {
|
||||||
val uiColour = Color(0xAA000000.toInt())
|
val uiColour = ItemSlotImageFactory.CELLCOLOUR_BLACK
|
||||||
val w = 128f
|
val w = 128f
|
||||||
val h = 128f
|
val h = 128f
|
||||||
val halfW = w / 2f
|
val halfW = w / 2f
|
||||||
@@ -317,22 +321,24 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
val pointDX = axisX * halfW
|
val pointDX = axisX * halfW
|
||||||
val pointDY = axisY * halfH
|
val pointDY = axisY * halfH
|
||||||
|
|
||||||
val padName = if (AppLoader.gamepad!!.name.isEmpty()) "Gamepad"
|
val gamepad = Controllers.getControllers()[0]
|
||||||
else AppLoader.gamepad!!.name
|
val padName = if (gamepad.name.isEmpty()) "Gamepad"
|
||||||
|
else gamepad.name
|
||||||
|
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
|
|
||||||
batch.end()
|
batch.end()
|
||||||
|
gdxSetBlendNormal()
|
||||||
Terrarum.inShapeRenderer {
|
Terrarum.inShapeRenderer {
|
||||||
it.color = uiColour
|
it.color = uiColour
|
||||||
it.rect(uiX.toFloat(), uiY.toFloat(), w, h)
|
it.rect(uiX.toFloat(), Terrarum.HEIGHT - uiY.toFloat(), w, -h)
|
||||||
it.color = Color.WHITE
|
it.color = Color.WHITE
|
||||||
it.line(uiX + halfW, uiY + halfH, uiX + halfW + pointDX, uiY + halfH + pointDY)
|
it.line(uiX + halfW, Terrarum.HEIGHT - (uiY + halfH), uiX + halfW + pointDX, Terrarum.HEIGHT - (uiY + halfH + pointDY))
|
||||||
it.color = Color.GRAY
|
it.color = Color.GRAY
|
||||||
}
|
}
|
||||||
batch.begin()
|
batch.begin()
|
||||||
|
|
||||||
Terrarum.fontSmallNumbers.draw(batch, padName, uiX + w / 2 - (padName.length) * 4, uiY.toFloat() + h + 2)
|
Terrarum.fontSmallNumbers.draw(batch, padName, Terrarum.WIDTH - (padName.length) * 8f, uiY.toFloat() + h + 2)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user