mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
pause using the pause key
This commit is contained in:
@@ -17,6 +17,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
|
||||
import net.torvald.terrarum.modulebasegame.ui.Noticelet
|
||||
import net.torvald.terrarum.modulebasegame.ui.Notification
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIPauseTheGame
|
||||
import net.torvald.terrarum.modulebasegame.ui.UITooltip
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import net.torvald.terrarum.savegame.VirtualDisk
|
||||
@@ -74,6 +75,7 @@ open class IngameInstance(val batch: FlippingSpriteBatch, val isMultiplayer: Boo
|
||||
val ZOOM_MINIMUM = 1.0f
|
||||
|
||||
open var consoleHandler: ConsoleWindow = ConsoleWindow()
|
||||
open var uiPaused: UIPauseTheGame = UIPauseTheGame()
|
||||
|
||||
var paused: Boolean = false; protected set
|
||||
var playerControlDisabled = false; protected set
|
||||
|
||||
@@ -215,6 +215,10 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
||||
terrarumIngame.consoleHandler.toggleOpening()
|
||||
}
|
||||
|
||||
if (keycode == Input.Keys.PAUSE) {
|
||||
terrarumIngame.uiPaused.toggleOpening()
|
||||
}
|
||||
|
||||
|
||||
// screenshot key
|
||||
if (keycode == Input.Keys.F12 && !f12Down) {
|
||||
|
||||
@@ -241,7 +241,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
private lateinit var uiBasicInfo: UICanvas
|
||||
private lateinit var uiWatchTierOne: UICanvas
|
||||
lateinit var uiAutosaveNotifier: UIAutosaveNotifier
|
||||
lateinit var uiCheatMotherfuckerNootNoot: UICheatDetected
|
||||
lateinit var uiCheatDetected: UICheatDetected
|
||||
|
||||
|
||||
var particlesActive = 0
|
||||
@@ -628,7 +628,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
uiBasicInfo.setPosition((uiQuickBar.posX - uiBasicInfo.width - App.scr.tvSafeActionWidth) / 2 + App.scr.tvSafeActionWidth, uiWatchTierOne.posY)
|
||||
|
||||
|
||||
uiCheatMotherfuckerNootNoot = UICheatDetected()
|
||||
uiCheatDetected = UICheatDetected()
|
||||
|
||||
|
||||
// batch-process uiAliases
|
||||
@@ -654,7 +654,8 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
getUIFixture,
|
||||
uiTooltip,
|
||||
consoleHandler,
|
||||
uiCheatMotherfuckerNootNoot
|
||||
uiPaused,
|
||||
uiCheatDetected,
|
||||
// drawn last
|
||||
)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
object CheatWarnTest : ConsoleCommand {
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
(Terrarum.ingame as? TerrarumIngame)?.uiCheatMotherfuckerNootNoot?.setAsOpen()
|
||||
(Terrarum.ingame as? TerrarumIngame)?.uiCheatDetected?.setAsOpen()
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
|
||||
@@ -714,18 +714,18 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
|
||||
private fun swimUp() {
|
||||
val timedJumpCharge = jumpFunc(MAX_JUMP_LENGTH, 0)
|
||||
swimAcc = -getJumpAcc(jumpPower1, timedJumpCharge) * SWIM_ACC_MULT
|
||||
swimAcc = -getJumpAcc(jumpPower1, timedJumpCharge) * SWIM_ACC_MULT * speedMultByTile
|
||||
}
|
||||
|
||||
private fun swimDown() {
|
||||
val timedJumpCharge = jumpFunc(MAX_JUMP_LENGTH, 0)
|
||||
swimAcc = getJumpAcc(jumpPower1, timedJumpCharge) * SWIM_ACC_MULT
|
||||
swimAcc = getJumpAcc(jumpPower1, timedJumpCharge) * SWIM_ACC_MULT * speedMultByTile
|
||||
}
|
||||
|
||||
private fun swimVertJoypad(up: Boolean, absAxisVal: Float) {
|
||||
val timedJumpCharge = jumpFunc(MAX_JUMP_LENGTH, 0)
|
||||
val sign = if (up) -1.0 else 1.0
|
||||
swimAcc = sign * getJumpAcc(jumpPower1, timedJumpCharge) * absAxisVal * SWIM_ACC_MULT
|
||||
swimAcc = sign * getJumpAcc(jumpPower1, timedJumpCharge) * absAxisVal * SWIM_ACC_MULT * speedMultByTile
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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() {}
|
||||
}
|
||||
@@ -209,11 +209,11 @@ object Toolkit : Disposable {
|
||||
fun blurEntireScreen(batch: SpriteBatch, camera: OrthographicCamera, blurRadius0: Float, x: Int, y: Int, w: Int, h: Int) {
|
||||
batch.end()
|
||||
|
||||
val blurRadius = FastMath.pow(blurRadius0, 0.5f)
|
||||
// val blurRadius = FastMath.pow(blurRadius0, 0.5f)
|
||||
val renderTarget = FrameBufferManager.peek()
|
||||
|
||||
/*if (blurRadius > 3f) {
|
||||
val radius3 = (blurRadius - 3f) / 8f
|
||||
//if (blurRadius > 3f) {
|
||||
val radius3 = FastMath.pow(blurRadius0 / 2, 0.5f)//(blurRadius - 3f) / 8f
|
||||
fboBlurHalf.inAction(camera, batch) {
|
||||
blurtex0 = renderTarget.colorBufferTexture
|
||||
blurtex0.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
||||
@@ -257,9 +257,9 @@ object Toolkit : Disposable {
|
||||
shaderKawaseUp.setUniformf("halfpixel", radius3 / fboBlurHalf.width, radius3 / fboBlurHalf.height)
|
||||
blurWriteQuad.render(shaderKawaseUp, GL20.GL_TRIANGLE_FAN)
|
||||
}
|
||||
}*/
|
||||
//}
|
||||
|
||||
fboBlurHalf.inAction(camera, batch) {
|
||||
/*fboBlurHalf.inAction(camera, batch) {
|
||||
blurtex2 = renderTarget.colorBufferTexture
|
||||
blurtex2.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
||||
blurtex2.bind(0)
|
||||
@@ -279,7 +279,7 @@ object Toolkit : Disposable {
|
||||
shaderKawaseUp.setUniformi("u_texture", 0)
|
||||
shaderKawaseUp.setUniformf("halfpixel", blurRadius / fboBlurHalf.width, blurRadius / fboBlurHalf.height)
|
||||
blurWriteQuad.render(shaderKawaseUp, GL20.GL_TRIANGLE_FAN)
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user