mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-17 00:56:07 +09:00
zooming properly with z key (with some async artefacts)
This commit is contained in:
66
src/net/torvald/terrarum/modulebasegame/ui/UIScreenZoom.kt
Normal file
66
src/net/torvald/terrarum/modulebasegame/ui/UIScreenZoom.kt
Normal file
@@ -0,0 +1,66 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.EMDASH
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.keyToIcon
|
||||
import net.torvald.terrarum.ui.Movement
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2019-08-11.
|
||||
*/
|
||||
class UIScreenZoom : UICanvas(
|
||||
AppLoader.getConfigInt("keyzoom")
|
||||
) {
|
||||
|
||||
val zoomText = "${keyToIcon(handler.toggleKeyLiteral!!)} $EMDASH Zoom Out"
|
||||
|
||||
override var width = AppLoader.fontGame.getWidth(zoomText)
|
||||
override var height = AppLoader.fontGame.lineHeight.toInt()
|
||||
|
||||
override var openCloseTime = 0.3f
|
||||
|
||||
override val mouseUp = false
|
||||
|
||||
private val zoomMin = 1f
|
||||
private val zoomMax = 2f
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
}
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
batch.color = handler.opacityColour
|
||||
|
||||
AppLoader.fontGame.draw(
|
||||
batch, zoomText,
|
||||
(AppLoader.screenW * AppLoader.TV_SAFE_GRAPHICS + 1).toInt().toFloat(),
|
||||
(AppLoader.screenH - height - AppLoader.getTvSafeGraphicsHeight()).toFloat()
|
||||
)
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
}
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
Terrarum.ingame?.screenZoom = Movement.fastPullOut(handler.openCloseCounter / openCloseTime, zoomMin, zoomMax)
|
||||
handler.opacity = Terrarum.ingame?.screenZoom!! - zoomMin
|
||||
}
|
||||
|
||||
override fun doClosing(delta: Float) {
|
||||
Terrarum.ingame?.screenZoom = Movement.fastPullOut(handler.openCloseCounter / openCloseTime, zoomMax, zoomMin)
|
||||
handler.opacity = Terrarum.ingame?.screenZoom!! - zoomMin
|
||||
}
|
||||
|
||||
override fun endOpening(delta: Float) {
|
||||
Terrarum.ingame?.screenZoom = zoomMax
|
||||
handler.opacity = 1f
|
||||
}
|
||||
|
||||
override fun endClosing(delta: Float) {
|
||||
Terrarum.ingame?.screenZoom = zoomMin
|
||||
handler.opacity = 0f
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user