new param 'frameDelta' on every render() function

This commit is contained in:
minjaesong
2024-01-04 16:38:58 +09:00
parent f2ecb109e6
commit f54a2133f9
116 changed files with 374 additions and 348 deletions

View File

@@ -128,7 +128,7 @@ class BasicDebugInfoWindow : UICanvas() {
private val tileCursX = 0; private val tileCursY = 4
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
override fun renderUI(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
TerrarumIngame.setCameraPosition(batch, App.shapeRender, camera, 0f, 0f)
// toggle show-something

View File

@@ -104,7 +104,7 @@ class ConsoleWindow : UICanvas() {
textinput.isEnabled = (isOpened && !isClosing)
}
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
override fun renderUI(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
// background
batch.color = UIColour
Toolkit.fillArea(batch, drawOffX, drawOffY, width.toFloat(), height.toFloat())
@@ -132,7 +132,7 @@ class ConsoleWindow : UICanvas() {
App.fontGame.draw(batch, message, 1f + drawOffX, (LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT - i)).toFloat() + drawOffY + inputToMsgboxGap)
}
uiItems.forEach { it.render(batch, camera) }
uiItems.forEach { it.render(frameDelta, batch, camera) }
}
override fun inputStrobed(e: TerrarumKeyboardEvent) {

View File

@@ -56,7 +56,7 @@ class UIAutosaveNotifier : UICanvas() {
}
}
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
override fun renderUI(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
val spin = spinner.get(spinnerFrame % 8, spinnerFrame / 8)
val offX = App.scr.width - WIDTH - (App.scr.tvSafeGraphicsWidth * 1.25f).roundToInt().toFloat()
val offY = App.scr.height - HEIGHT - App.scr.tvSafeGraphicsHeight - 9f // +9 to align to quickslot and watch UI

View File

@@ -120,8 +120,8 @@ abstract class UICanvas(
handler.update(this, delta)
}
/** Called by the screen */
fun render(batch: SpriteBatch, camera: OrthographicCamera, parentOpacity: Float = 1f) {
handler.render(this, batch, camera, parentOpacity)
fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera, parentOpacity: Float = 1f) {
handler.render(this, frameDelta, batch, camera, parentOpacity)
}
@@ -156,7 +156,7 @@ abstract class UICanvas(
* The transparency of the handler is independent of the draw, you must set the drawing color yourself
* (use handler.opacity or handler.opacityColour)
*/
abstract fun renderUI(batch: SpriteBatch, camera: OrthographicCamera)
abstract fun renderUI(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera)
/**
* Do not modify ui.handler.openCloseCounter here.

View File

@@ -281,7 +281,7 @@ void main() {
subUIs.forEach { it.update(delta) }
}
fun render(ui: UICanvas, batch: SpriteBatch, camera: OrthographicCamera, parentOpacity: Float) {
fun render(ui: UICanvas, frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera, parentOpacity: Float) {
if (isVisible) {
// camera SHOULD BE CENTERED to HALFX and HALFY (see StateInGame) //
@@ -301,7 +301,7 @@ void main() {
batch.shader = shader
shader.setUniformf("opacity", opacity * parentOpacity)
ui.renderUI(batch, camera)
ui.renderUI(frameDelta, batch, camera)
//ingameGraphics.flush()
batch.shader = null
@@ -313,7 +313,7 @@ void main() {
subUIs.forEach {
it.render(batch, camera)
it.render(frameDelta, batch, camera)
batch.color = Color.WHITE
}

View File

@@ -177,13 +177,13 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
/**
* In this time, you do write like: ```draw(posX + 4, posY + 32)```, unlike UICanvas, because posX/posY comes from the parent UI.
*/
open fun render(batch: SpriteBatch, camera: OrthographicCamera) {
open fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
if (parentUI.isVisible) {
// if (isActive) {
mouseOverCall?.render(batch, camera)
mouseOverCall?.render(frameDelta, batch, camera)
if (mouseUp) {
mouseOverCall?.renderUI(batch, camera)
mouseOverCall?.renderUI(frameDelta, batch, camera)
}
// }
}

View File

@@ -40,7 +40,7 @@ class UIItemConfigKeycap(
super.update(delta)
}
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
// draw keycap
batch.draw(capTex.get(0, 0), posX.toFloat(), posY.toFloat())
batch.draw(capTex.get(1, 0), (posX + capTex.tileW).toFloat(), posY.toFloat(),
@@ -54,7 +54,7 @@ class UIItemConfigKeycap(
// draw icon
super.render(batch, camera)
super.render(frameDelta, batch, camera)
}
override fun dispose() {

View File

@@ -95,11 +95,11 @@ class UIItemHorzSlider(
private val renderOrderMouseUp = arrayOf(0,2,3,1).map { renderJobs[it] }
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
renderOrderMouseUp.forEach { it(batch) }
super.render(batch, camera)
super.render(frameDelta, batch, camera)
}
override fun dispose() {

View File

@@ -54,7 +54,7 @@ open class UIItemImageButton(
var highlighted = false
var extraDrawOp: (UIItem, SpriteBatch) -> Unit = { _,_ -> }
fun render(batch: SpriteBatch, camera: OrthographicCamera, offX: Int, offY: Int) {
fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera, offX: Int, offY: Int) {
val posX = this.posX + offX
val posY = this.posY + offY
@@ -93,8 +93,8 @@ open class UIItemImageButton(
extraDrawOp(this, batch)
}
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
render(batch, camera, 0, 0)
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
render(frameDelta, batch, camera, 0, 0)
}
override fun dispose() {

View File

@@ -24,7 +24,7 @@ class UIItemImageGallery(
override fun update(delta: Float) {
}
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
fun column(i: Int) = i % column
fun row(i: Int) = i / column

View File

@@ -52,7 +52,7 @@ class UIItemInlineRadioButtons(
super.update(delta)
}
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
// backgrounds
batch.color = UIItemTextLineInput.TEXTINPUT_COL_BACKGROUND
for (i in labelfuns.indices) {
@@ -96,7 +96,7 @@ class UIItemInlineRadioButtons(
App.fontGame.draw(batch, text, xpos + (cellWidth - tw) / 2, posY)
super.render(batch, camera)
super.render(frameDelta, batch, camera)
}
override fun dispose() {

View File

@@ -121,7 +121,7 @@ class UIItemList<Item: UIItem>(
oldPosX = posX
}
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = backgroundCol
BlendMode.resolve(backgroundBlendMode, batch)
Toolkit.fillArea(batch, posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
@@ -132,7 +132,7 @@ class UIItemList<Item: UIItem>(
Toolkit.fillArea(batch, posX.toFloat(), highlightY!!.toFloat(), width.toFloat(), UIItemTextButton.height.toFloat())
}
itemList.forEach { it.render(batch, camera) }
itemList.forEach { it.render(frameDelta, batch, camera) }
batch.color = backgroundCol
}

View File

@@ -72,7 +72,7 @@ class UIItemModuleInfoCell(
private val ccNum2 = App.fontGame.toColorCode(12,11,4)
private val ccDesc = App.fontGame.toColorCode(13,13,13)
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
batch.color = Toolkit.Theme.COL_CELL_FILL

View File

@@ -118,7 +118,7 @@ class UIItemSpinner(
fboUpdateLatch = true
}
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
batch.end()
@@ -186,7 +186,7 @@ class UIItemSpinner(
// batch.draw(fbo.colorBufferTexture, posX + buttonW + 3f, posY + 2f, fbo.width.toFloat(), fbo.height.toFloat())
App.fontGame.draw(batch, textCache, posX + buttonW + 3f + (fboWidth - textCacheLen).div(2), posY.toFloat())
super.render(batch, camera)
super.render(frameDelta, batch, camera)
// batch.color = Color.WHITE
// App.fontSmallNumbers.draw(batch, "${valueType.simpleName}", posX.toFloat(), posY.toFloat()) // draws "Integer" or "Double"

View File

@@ -34,7 +34,7 @@ class UIItemTextArea(
if (scrollPos < 0) scrollPos = 0
}
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
for (i in scrollPos until min(lineCount + scrollPos, entireText.size)) {
val yPtr = i - scrollPos

View File

@@ -75,7 +75,7 @@ open class UIItemTextButton(
super.update(delta)
}
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
val textW = font.getWidth(label)
val fontX = when (alignment) {
Alignment.CENTRE -> posX + width.minus(textW).div(2) + (paddingLeft - paddingRight).div(2)

View File

@@ -224,7 +224,7 @@ class UIItemTextButtonList(
oldPosX = posX
}
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
/*if (kinematic) {
batch.color = backgroundCol
@@ -243,7 +243,7 @@ class UIItemTextButtonList(
Toolkit.fillArea(batch, posX, posY, width, height)
buttons.forEach { it.render(batch, camera) }
buttons.forEach { it.render(frameDelta, batch, camera) }
if (iconSpriteSheet != null) {

View File

@@ -525,7 +525,7 @@ class UIItemTextLineInput(
private var textDrawOffset = 0
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
val posXDelta = posX - oldPosX
@@ -683,7 +683,7 @@ class UIItemTextLineInput(
}
batch.color = Color.WHITE
super.render(batch, camera)
super.render(frameDelta, batch, camera)
oldPosX = posX

View File

@@ -134,7 +134,7 @@ class UIItemTextSelector(
private val leftIcon = if (useSpinnerButtons) labels.get(9,2) else labels.get(16,0)
private val rightIcon = if (useSpinnerButtons) labels.get(10,2) else labels.get(17,0)
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
labelCache = labelfuns.map { it() }
batch.end()
@@ -238,7 +238,7 @@ class UIItemTextSelector(
}
}
super.render(batch, camera)
super.render(frameDelta, batch, camera)
}

View File

@@ -135,7 +135,7 @@ class UIItemToggleButton(
Color(0x00E800FF)
)
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
@@ -145,7 +145,7 @@ class UIItemToggleButton(
renderOrderNormal.forEach { it(batch) }
super.render(batch, camera)
super.render(frameDelta, batch, camera)
}
override fun dispose() {

View File

@@ -59,8 +59,8 @@ open class UIItemTransitionContainer(
open val currentUI: UICanvas
get() = uis[currentPosition.roundToInt()]
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
super.render(batch, camera)
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
super.render(frameDelta, batch, camera)
if (transitionRequested && !transitionOngoing) {
transitionRequested = false
@@ -69,7 +69,7 @@ open class UIItemTransitionContainer(
}
if (transitionOngoing) {
transitionTimer += Gdx.graphics.deltaTime
transitionTimer += frameDelta
currentPosition = Movement.moveLinear(transitionReqSource, transitionReqTarget, transitionTimer, transitionLength)
@@ -84,7 +84,7 @@ open class UIItemTransitionContainer(
uis.forEachIndexed { index, ui ->
if (currentPosition > index - 1 + epsilon && currentPosition < index + 1 - epsilon) {
if (!ui.isOpened && !ui.isOpening) ui.setAsOpen()
ui.render(batch, camera, parent.opacity)
ui.render(frameDelta, batch, camera, parent.opacity)
if (debugvals) {
App.fontSmallNumbers.draw(batch, "$index", 300f + (20 * index), 10f)

View File

@@ -93,11 +93,11 @@ class UIItemVertSlider(
private val renderOrderMouseUp = arrayOf(0,2,3,1).map { renderJobs[it] }
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
renderOrderMouseUp.forEach { it(batch) }
super.render(batch, camera)
super.render(frameDelta, batch, camera)
}
override fun dispose() {

View File

@@ -186,7 +186,7 @@ class UINSMenu(
private val borderCol = Color(1f, 1f, 1f, 0.35f)
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
override fun renderUI(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
listStack.forEach {
// draw title bar
batch.color = titleBackCol
@@ -199,7 +199,7 @@ class UINSMenu(
// draw the list
batch.color = Color.WHITE
it.ui.render(batch, camera)
it.ui.render(frameDelta, batch, camera)
// draw border
batch.color = borderCol