mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
fix: double scroll on crafting ui opened by right-clicking on the workbench
This commit is contained in:
@@ -10,7 +10,6 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|||||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||||
import com.badlogic.gdx.utils.Disposable
|
import com.badlogic.gdx.utils.Disposable
|
||||||
import com.badlogic.gdx.utils.GdxRuntimeException
|
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
import net.torvald.gdx.graphics.Cvec
|
import net.torvald.gdx.graphics.Cvec
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
@@ -39,7 +38,6 @@ import net.torvald.util.CircularArray
|
|||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.PrintStream
|
import java.io.PrintStream
|
||||||
import java.util.*
|
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
|
|
||||||
|
|
||||||
@@ -686,10 +684,17 @@ inline fun printStackTrace(obj: Any) = printStackTrace(obj, System.out) // becau
|
|||||||
|
|
||||||
fun printStackTrace(obj: Any, out: PrintStream = System.out) {
|
fun printStackTrace(obj: Any, out: PrintStream = System.out) {
|
||||||
if (App.IS_DEVELOPMENT_BUILD) {
|
if (App.IS_DEVELOPMENT_BUILD) {
|
||||||
val indentation = " ".repeat(obj.javaClass.simpleName.length + 4)
|
val timeNow = System.currentTimeMillis()
|
||||||
|
val ss = timeNow / 1000 % 60
|
||||||
|
val mm = timeNow / 60000 % 60
|
||||||
|
val hh = timeNow / 3600000 % 24
|
||||||
|
val ms = timeNow % 1000
|
||||||
|
val objName = if (obj is String) obj else obj.javaClass.simpleName
|
||||||
|
val prompt = csiG + String.format("%02d:%02d:%02d.%03d%s [%s] ", hh, mm, ss, ms, csi0, objName)
|
||||||
|
val indentation = " ".repeat(objName.length + 16)
|
||||||
Thread.currentThread().stackTrace.forEachIndexed { index, it ->
|
Thread.currentThread().stackTrace.forEachIndexed { index, it ->
|
||||||
if (index == 1)
|
if (index == 1)
|
||||||
out.println("[${obj.javaClass.simpleName}]> $it")
|
out.println("$prompt$it")
|
||||||
else if (index > 1)
|
else if (index > 1)
|
||||||
out.println("$indentation$it")
|
out.println("$indentation$it")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,8 +248,19 @@ open class UIItemInventoryItemGrid(
|
|||||||
itemList.forEach { it.customHighlightRule2 = predicate }
|
itemList.forEach { it.customHighlightRule2 = predicate }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var lastScrolled = System.nanoTime()
|
||||||
|
|
||||||
open fun scrollItemPage(relativeAmount: Int) {
|
open fun scrollItemPage(relativeAmount: Int) {
|
||||||
itemPage = if (itemPageCount == 0) 0 else (itemPage + relativeAmount).fmod(itemPageCount)
|
val timeNow = System.nanoTime()
|
||||||
|
|
||||||
|
// hack to fix double scroll when UI opened by right clicking on the workbench
|
||||||
|
// the double-stacktrace is identical, so I have no clue why the double-scrolling is happening :/
|
||||||
|
if ((timeNow - lastScrolled) ushr 20 != 0L) { // 1.048 ms
|
||||||
|
// printStackTrace("$this@${this.hashCode()}")
|
||||||
|
itemPage = if (itemPageCount == 0) 0 else (itemPage + relativeAmount).fmod(itemPageCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
lastScrolled = timeNow // some nanoseconds have passed since the timeNow but it doesn't matter
|
||||||
}
|
}
|
||||||
|
|
||||||
val navRemoCon = UIItemListNavBarVertical(parentUI, iconPosX, posY + 8, height, true, if (isCompactMode) 1 else 0)
|
val navRemoCon = UIItemListNavBarVertical(parentUI, iconPosX, posY + 8, height, true, if (isCompactMode) 1 else 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user