mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
debug info: timer toggle is now Ctrl+T
This commit is contained in:
@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
|
import com.badlogic.gdx.Input.Keys
|
||||||
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.Texture
|
import com.badlogic.gdx.graphics.Texture
|
||||||
@@ -62,9 +63,11 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
private val HEIGHT = 0xC7.toChar()
|
private val HEIGHT = 0xC7.toChar()
|
||||||
private val WIDTH = 0xCD.toChar()
|
private val WIDTH = 0xCD.toChar()
|
||||||
|
|
||||||
private val KEY_TIMERS = Input.Keys.U
|
private val KEY_TIMERS = Input.Keys.T // + CONTROL_LEFT
|
||||||
|
private val KEY_WEATHERS = Input.Keys.W // + CONTROL_LEFT
|
||||||
|
|
||||||
private var showTimers = false
|
private var showTimers = false
|
||||||
|
private var showWeatherInfo = false
|
||||||
|
|
||||||
override fun show() {
|
override fun show() {
|
||||||
ingame = Terrarum.ingame
|
ingame = Terrarum.ingame
|
||||||
@@ -120,6 +123,16 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
private val tileCursX = 0; private val tileCursY = 4
|
private val tileCursX = 0; private val tileCursY = 4
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
|
// toggle show-something
|
||||||
|
showTimers = showTimers xor (Gdx.input.isKeyJustPressed(KEY_TIMERS) && Gdx.input.isKeyPressed(Keys.CONTROL_LEFT))
|
||||||
|
showWeatherInfo = showWeatherInfo xor (Gdx.input.isKeyJustPressed(KEY_WEATHERS) && Gdx.input.isKeyPressed(Keys.CONTROL_LEFT))
|
||||||
|
|
||||||
|
|
||||||
|
drawMain(batch)
|
||||||
|
if (showTimers) drawTimers(batch)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawMain(batch: SpriteBatch) {
|
||||||
val windowWidth = Toolkit.drawWidth
|
val windowWidth = Toolkit.drawWidth
|
||||||
val player = ingame?.actorNowPlaying
|
val player = ingame?.actorNowPlaying
|
||||||
val hitbox = player?.hitbox
|
val hitbox = player?.hitbox
|
||||||
@@ -133,7 +146,6 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
batch.draw(back, gap - 4f, gap - 4f - 1f)
|
batch.draw(back, gap - 4f, gap - 4f - 1f)
|
||||||
batch.draw(back2, windowWidth - back2.width - (gap - 4f), gap - 4f - 1f)
|
batch.draw(back2, windowWidth - back2.width - (gap - 4f), gap - 4f - 1f)
|
||||||
|
|
||||||
showTimers = showTimers xor Gdx.input.isKeyJustPressed(KEY_TIMERS)
|
|
||||||
|
|
||||||
batch.color = Color(0xFFEE88FF.toInt())
|
batch.color = Color(0xFFEE88FF.toInt())
|
||||||
|
|
||||||
@@ -250,16 +262,6 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// print time
|
|
||||||
if (showTimers) {
|
|
||||||
var dbgCnt = 10
|
|
||||||
App.debugTimers.forEach { t, u ->
|
|
||||||
printLine(batch, dbgCnt, "$ccM$t $ccG${formatNanoTime(u as? Long)}$ccY ns")
|
|
||||||
dbgCnt++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top right
|
* Top right
|
||||||
*/
|
*/
|
||||||
@@ -319,6 +321,15 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
// processor and renderer
|
// processor and renderer
|
||||||
App.fontSmallNumbers.draw(batch, "$ccY$totalHardwareName",
|
App.fontSmallNumbers.draw(batch, "$ccY$totalHardwareName",
|
||||||
(windowWidth - (totalHardwareName.length+2) * TinyAlphNum.W).toFloat(), App.scr.height - TinyAlphNum.H * 2f)
|
(windowWidth - (totalHardwareName.length+2) * TinyAlphNum.W).toFloat(), App.scr.height - TinyAlphNum.H * 2f)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawTimers(batch: SpriteBatch) {
|
||||||
|
var dbgCnt = 10
|
||||||
|
App.debugTimers.forEach { t, u ->
|
||||||
|
printLine(batch, dbgCnt, "$ccM$t $ccG${formatNanoTime(u as? Long)}$ccY ns")
|
||||||
|
dbgCnt++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val processorName = App.processor.replace(Regex(""" Processor|( CPU)? @ [0-9.]+GHz"""), "") + if (App.is32BitJVM) " (32-bit)" else ""
|
private val processorName = App.processor.replace(Regex(""" Processor|( CPU)? @ [0-9.]+GHz"""), "") + if (App.is32BitJVM) " (32-bit)" else ""
|
||||||
@@ -338,6 +349,7 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
val histogramW = 256
|
val histogramW = 256
|
||||||
val histogramH = 256
|
val histogramH = 256
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user