From 147c57557dcd2e8895b0027143385114e3edfc76 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 30 Mar 2022 14:21:16 +0900 Subject: [PATCH] debug window: toggle visibility of timers using U key --- .../torvald/terrarum/ui/BasicDebugInfoWindow.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt index 0dbdfb1eb..f2138cd54 100644 --- a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt +++ b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt @@ -1,6 +1,7 @@ package net.torvald.terrarum.ui import com.badlogic.gdx.Gdx +import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Texture @@ -60,6 +61,9 @@ class BasicDebugInfoWindow : UICanvas() { private val MASS = 0xD5.toChar() private val HEIGHT = 0xC7.toChar() + private val KEY_TIMERS = Input.Keys.U + + private var showTimers = false override fun updateUI(delta: Float) { val player = ingame?.actorNowPlaying @@ -121,7 +125,7 @@ class BasicDebugInfoWindow : UICanvas() { batch.color = Color(1f, 1f, 1f, 0.65f) batch.draw(back, gap - 5f, gap - 5f) - + showTimers = showTimers xor Gdx.input.isKeyJustPressed(KEY_TIMERS) batch.color = Color(0xFFEE88FF.toInt()) @@ -226,10 +230,12 @@ class BasicDebugInfoWindow : UICanvas() { } // print time - var dbgCnt = 10 - App.debugTimers.forEach { t, u -> -// printLine(batch, dbgCnt, "$ccO$t $ccG${formatNanoTime(u as? Long)}$ccY ns") - dbgCnt++ + if (showTimers) { + var dbgCnt = 10 + App.debugTimers.forEach { t, u -> + printLine(batch, dbgCnt, "$ccO$t $ccG${formatNanoTime(u as? Long)}$ccY ns") + dbgCnt++ + } }