mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
pause using the pause key
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
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.gamecontroller.TerrarumKeyboardEvent
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
@@ -27,9 +29,6 @@ class UICheatDetected : UICanvas() {
|
||||
set(value) { throw UnsupportedOperationException() }
|
||||
|
||||
override var openCloseTime: Second = 0f
|
||||
|
||||
|
||||
|
||||
private val backgroundCol = Color(0x00000080)
|
||||
|
||||
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
||||
@@ -42,29 +41,63 @@ class UICheatDetected : UICanvas() {
|
||||
|
||||
batch.color = Color.WHITE
|
||||
val txt = Lang["ERROR_GENERIC_CHEATING"]
|
||||
val txtW = App.fontGame.getWidth(txt)
|
||||
val txtH = App.fontGame.lineHeight.toInt()
|
||||
val txtW = App.fontUITitle.getWidth(txt)
|
||||
val txtH = App.fontUITitle.lineHeight.toInt()
|
||||
|
||||
App.fontGame.draw(batch, txt, width.minus(txtW).ushr(1).toFloat(), height.minus(txtH).ushr(1).toFloat())
|
||||
App.fontUITitle.draw(batch, txt, width.minus(txtW).ushr(1).toFloat(), height.minus(txtH).ushr(1).toFloat())
|
||||
}
|
||||
|
||||
override fun updateImpl(delta: Float) {
|
||||
INGAME.pause()
|
||||
override fun updateImpl(delta: Float) { INGAME.pause() }
|
||||
override fun doOpening(delta: Float) { INGAME.pause() }
|
||||
override fun doClosing(delta: Float) {}
|
||||
override fun endOpening(delta: Float) {}
|
||||
override fun endClosing(delta: Float) {}
|
||||
override fun dispose() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* The obscure PAUSE screen that's only accessible by hitting the equally obscure Pause/Break key
|
||||
*
|
||||
* Created by minjaesong on 2024-09-13.
|
||||
*/
|
||||
class UIPauseTheGame : UICanvas() {
|
||||
|
||||
init {
|
||||
handler.allowESCtoClose = false
|
||||
}
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
INGAME.pause()
|
||||
override var width: Int
|
||||
get() = App.scr.width
|
||||
set(value) { throw UnsupportedOperationException() }
|
||||
|
||||
override var height: Int
|
||||
get() = App.scr.height
|
||||
set(value) { throw UnsupportedOperationException() }
|
||||
|
||||
private val backgroundCol = Color(0x00000080)
|
||||
|
||||
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
||||
Terrarum.ingame?.consoleHandler?.setAsClose()
|
||||
Terrarum.ingame?.consoleHandler?.isVisible = false
|
||||
|
||||
Toolkit.blurEntireScreen(batch, camera as OrthographicCamera, 2f, 0, 0, width, height)
|
||||
batch.color = backgroundCol
|
||||
Toolkit.fillArea(batch, 0f, 0f, width.toFloat(), height.toFloat())
|
||||
|
||||
batch.color = Color.WHITE
|
||||
val txt = Lang["MENU_LABEL_PAUSED"]
|
||||
val txtW = App.fontUITitle.getWidth(txt)
|
||||
val txtH = App.fontUITitle.lineHeight.toInt()
|
||||
|
||||
App.fontUITitle.draw(batch, txt, width.minus(txtW).ushr(1).toFloat(), height.minus(txtH).ushr(1).toFloat())
|
||||
}
|
||||
|
||||
override fun doClosing(delta: Float) {
|
||||
}
|
||||
private var pauseLatched = false
|
||||
|
||||
override fun endOpening(delta: Float) {
|
||||
}
|
||||
|
||||
override fun endClosing(delta: Float) {
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
}
|
||||
override fun updateImpl(delta: Float) { INGAME.pause() }
|
||||
override fun doOpening(delta: Float) { pauseLatched = true; INGAME.pause() }
|
||||
override fun doClosing(delta: Float) { pauseLatched = true; INGAME.resume() }
|
||||
override fun endOpening(delta: Float) { pauseLatched = false }
|
||||
override fun endClosing(delta: Float) { pauseLatched = false; INGAME.resume() }
|
||||
override fun dispose() {}
|
||||
}
|
||||
Reference in New Issue
Block a user