LR click behav change/mouse clicks were sticky and causes unwanted behaviour on some fixture UIs

This commit is contained in:
minjaesong
2024-03-05 05:21:17 +09:00
parent 0090cc7d40
commit 5b5534bcb9
27 changed files with 206 additions and 181 deletions

View File

@@ -446,8 +446,6 @@ class UICraftingWorkbench(val inventoryUI: UIInventoryFull?, val parentContainer
itemListCraftable.numberMultiplier = 1L
}
private var openingClickLatched = false
override fun show() {
nearbyCraftingStations = getCraftingStationsWithinReach()
// printdbg(this, "Nearby crafting stations: $nearbyCraftingStations")
@@ -455,7 +453,7 @@ class UICraftingWorkbench(val inventoryUI: UIInventoryFull?, val parentContainer
playerThings.setGetInventoryFun { INGAME.actorNowPlaying!!.inventory }
itemListUpdate()
openingClickLatched = Terrarum.mouseDown
super.show()
tooltipShowing.clear()
INGAME.setTooltipMessage(null)
@@ -472,18 +470,9 @@ class UICraftingWorkbench(val inventoryUI: UIInventoryFull?, val parentContainer
encumbrancePerc = getPlayerInventory().encumberment.toFloat()
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (!openingClickLatched) {
return super.touchDown(screenX, screenY, pointer, button)
}
return false
}
override fun updateImpl(delta: Float) {
// NO super.update due to an infinite recursion
this.uiItems.forEach { it.update(delta) }
if (openingClickLatched && !Terrarum.mouseDown) openingClickLatched = false
}
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {

View File

@@ -180,6 +180,7 @@ internal class UIInventoryCells(
}
override fun show() {
super.show()
tooltipShowing.clear()
INGAME.setTooltipMessage(null)
}

View File

@@ -304,6 +304,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
)
override fun show() {
super.show()
tooltipShowing.clear()
INGAME.setTooltipMessage(null)
toInitScreen()

View File

@@ -323,15 +323,11 @@ class UIInventoryFull(
}
override fun show() {
transitionPanel.show()
super.show()
tooltipShowing.clear()
INGAME.setTooltipMessage(null)
}
override fun hide() {
transitionPanel.hide()
}
internal var offsetX = ((width - internalWidth) / 2).toFloat()
private set
internal var offsetY = ((App.scr.height - internalHeight) / 2).toFloat()

View File

@@ -65,7 +65,7 @@ abstract class UIItemInventoryCellBase(
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (mouseUp) {
if (mouseUp && !parentUI.openingClickLatched) {
touchDownFun(item, amount, button, extraInfo, this)
super.touchDown(screenX, screenY, pointer, button)
}

View File

@@ -74,23 +74,20 @@ class UIJukebox : UICanvas(
addUIitem(transitionPanel)
}
private var openingClickLatched = false
override fun show() {
openingClickLatched = Terrarum.mouseDown
super.show()
transitionPanel.show()
tooltipShowing.clear()
INGAME.setTooltipMessage(null)
}
override fun hide() {
super.hide()
transitionPanel.hide()
}
override fun updateImpl(delta: Float) {
uiItems.forEach { it.update(delta) }
if (openingClickLatched && !Terrarum.mouseDown) openingClickLatched = false
}
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
@@ -108,10 +105,7 @@ class UIJukebox : UICanvas(
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (!openingClickLatched) {
return super.touchDown(screenX, screenY, pointer, button)
}
return false
return super.touchDown(screenX, screenY, pointer, button)
}
override fun doOpening(delta: Float) {

View File

@@ -141,6 +141,8 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
}
catch (e: UninitializedPropertyAccessException) {
}
super.show()
}
}
@@ -299,6 +301,7 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
}
override fun hide() {
super.hide()
showCalled = false
cellLoadThread.interrupt()
}

View File

@@ -132,6 +132,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
override fun show() {
// takeAutosaveSelectorDown()
super.show()
transitionPanel.show()
nodesForListing.parent = remoCon.treeRoot
@@ -140,6 +141,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
}
override fun hide() {
super.hide()
transitionPanel.hide()
}

View File

@@ -32,6 +32,8 @@ class UIShare : UICanvas() {
private var shareCode = ""
override fun show() {
super.show()
shareCode = Common.encodeUUID(INGAME.world.worldIndex)
App.printdbg(this, shareCode)

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.langpack.Lang
@@ -183,15 +184,13 @@ internal class UIStorageChest : UICanvas(
addUIitem(itemListPlayer)
}
private var openingClickLatched = false
override fun show() {
super.show()
itemListPlayer.itemList.getInventory = { INGAME.actorNowPlaying!!.inventory }
itemListUpdate()
openingClickLatched = Terrarum.mouseDown
tooltipShowing.clear()
INGAME.setTooltipMessage(null)
}
@@ -221,18 +220,13 @@ internal class UIStorageChest : UICanvas(
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (!openingClickLatched) {
return super.touchDown(screenX, screenY, pointer, button)
}
return false
return super.touchDown(screenX, screenY, pointer, button)
}
override fun updateImpl(delta: Float) {
catBar.update(delta)
itemListChest.update(delta)
itemListPlayer.update(delta)
if (openingClickLatched && !Terrarum.mouseDown) openingClickLatched = false
}
private val thisOffsetX = Toolkit.hdrawWidth - getWidthOfCells(6) - halfSlotOffset

View File

@@ -70,6 +70,7 @@ class UITemplateHalfInventory(
}
fun rebuild(category: Array<String>) {
itemList.rebuild(category)
}

View File

@@ -119,10 +119,12 @@ class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
override fun show() {
initialMouseBlock = true
super.show()
}
override fun hide() {
initialMouseBlock = true
super.hide()
}

View File

@@ -156,9 +156,8 @@ class UIWorldPortal : UICanvas(
}
override fun show() {
super.show()
transitionPanel.forcePosition(0)
transitionPanel.show()
super.show()
INGAME.setTooltipMessage(null)
// add current world to the player's worldportaldict
@@ -166,10 +165,6 @@ class UIWorldPortal : UICanvas(
cleanUpWorldDict()
}
override fun hide() {
transitionPanel.hide()
}
override fun dispose() {
transitionPanel.dispose()
}

View File

@@ -139,15 +139,13 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
addUIitem(itemListPlayer)
}
private var openingClickLatched = false
override fun show() {
super.show()
itemListPlayer.getInventory = { INGAME.actorNowPlaying!!.inventory }
itemListUpdate()
openingClickLatched = Terrarum.mouseDown
tooltipShowing.clear()
INGAME.setTooltipMessage(null)
}
@@ -177,9 +175,7 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (!openingClickLatched) {
return super.touchDown(screenX, screenY, pointer, button)
}
return super.touchDown(screenX, screenY, pointer, button)
return false
}
@@ -187,8 +183,6 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
catBar.update(delta)
itemListChest.update(delta)
itemListPlayer.update(delta)
if (openingClickLatched && !Terrarum.mouseDown) openingClickLatched = false
}
private val thisOffsetX = Toolkit.hdrawWidth - UIInventoryFull.getWidthOfCells(6) - halfSlotOffset

View File

@@ -304,6 +304,8 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
private var threadFired = false
override fun show() {
super.show()
listPage = 0
showSpinner = true
@@ -464,7 +466,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
}
override fun hide() {
uiItems.forEach { it.hide() }
super.hide()
if (::worldCells.isInitialized) worldCells.forEach { it.hide() }
if (::worldCells.isInitialized) worldCells.forEach { it.tryDispose() }
@@ -554,18 +556,6 @@ class UIItemWorldCellsSimple(
var highlighted = false
override fun show() {
super.show()
}
override fun hide() {
super.hide()
}
override fun update(delta: Float) {
super.update(delta)
}
fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera, offX: Int, offY: Int) {
super.render(frameDelta, batch, camera)

View File

@@ -50,6 +50,8 @@ class UIWorldPortalShare(private val full: UIWorldPortal) : UICanvas() {
private var shareCode = ""
override fun show() {
super.show()
shareCode = Common.encodeUUID(INGAME.world.worldIndex)