mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
custom keyboard handling wip
This commit is contained in:
@@ -86,7 +86,7 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
|
||||
}
|
||||
|
||||
// respond to click
|
||||
if (Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))) {
|
||||
if (Terrarum.mouseDown) {
|
||||
// scroll bar
|
||||
if (relativeMouseX in width - SCROLLBAR_SIZE until width && relativeMouseY in 0 until height) {
|
||||
mouseOnScroll = true
|
||||
|
||||
@@ -133,7 +133,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
||||
}
|
||||
|
||||
// primary click
|
||||
if (Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))) {
|
||||
if (Terrarum.mouseDown) {
|
||||
// close by clicking close button or out-of-boud
|
||||
if (mouseVec.distanceSquared(RADIUS, RADIUS) !in CLOSE_BUTTON_RADIUS.sqr()..RADIUSF.sqr()) {
|
||||
closeGracefully()
|
||||
@@ -175,7 +175,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
||||
batch.draw(ItemCodex.getItemImage(slotConfig[i]), x - 16, y - 16, 32f, 32f)
|
||||
|
||||
// update as well while looping
|
||||
if (i == mouseOnBlocksSlot && Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))) {
|
||||
if (i == mouseOnBlocksSlot && Terrarum.mouseDown) {
|
||||
parent.setPencilColour(slotConfig[i])
|
||||
closeGracefully()
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
||||
|
||||
// update map panning
|
||||
// if left click is down and cursor is in the map area
|
||||
if (Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary")) &&
|
||||
if (Terrarum.mouseDown &&
|
||||
Terrarum.mouseScreenY in cellOffY..cellOffY + INVENTORY_CELLS_UI_HEIGHT) {
|
||||
minimapPanX += Terrarum.mouseDeltaX * 2f / minimapZoom
|
||||
minimapPanY += Terrarum.mouseDeltaY * 2f / minimapZoom
|
||||
|
||||
@@ -4,11 +4,8 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbgerr
|
||||
import net.torvald.terrarum.QNDTreeNode
|
||||
import net.torvald.terrarum.TitleScreen
|
||||
import net.torvald.terrarum.Yaml
|
||||
import net.torvald.terrarum.serialise.WriteConfig
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
@@ -77,7 +74,7 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
private var openUI: UICanvas? = null
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
if (mouseActionAvailable && Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))) {
|
||||
if (mouseActionAvailable && Terrarum.mouseDown) {
|
||||
mouseActionAvailable = false
|
||||
|
||||
remoConTray.update(delta)
|
||||
@@ -149,7 +146,7 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
openUI?.update(delta)
|
||||
|
||||
|
||||
if (!Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))) {
|
||||
if (!Terrarum.mouseDown) {
|
||||
mouseActionAvailable = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user