mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
asynch update and render (aka frameskip)
This commit is contained in:
@@ -1,25 +1,21 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
||||
import net.torvald.terrarum.TerrarumGDX.mouseTileX
|
||||
import net.torvald.terrarum.TerrarumGDX.mouseTileY
|
||||
import net.torvald.terrarum.TerrarumGDX.mouseScreenX
|
||||
import net.torvald.terrarum.TerrarumGDX.mouseScreenY
|
||||
import net.torvald.terrarum.Terrarum.mouseTileX
|
||||
import net.torvald.terrarum.Terrarum.mouseTileY
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-14.
|
||||
*/
|
||||
class BasicDebugInfoWindow : UICanvas {
|
||||
|
||||
override var width: Int = TerrarumGDX.WIDTH
|
||||
override var height: Int = TerrarumGDX.HEIGHT
|
||||
override var width: Int = Terrarum.WIDTH
|
||||
override var height: Int = Terrarum.HEIGHT
|
||||
|
||||
override var openCloseTime: Float = 0f
|
||||
|
||||
@@ -34,7 +30,7 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
|
||||
|
||||
override fun update(delta: Float) {
|
||||
val player = TerrarumGDX.ingame!!.player!!
|
||||
val player = Terrarum.ingame!!.player!!
|
||||
val hitbox = player.hitbox
|
||||
|
||||
xdelta = hitbox.canonicalX - prevPlayerX
|
||||
@@ -49,7 +45,7 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
fun Int.rawG() = this % LightmapRenderer.MUL_2 / LightmapRenderer.MUL
|
||||
fun Int.rawB() = this % LightmapRenderer.MUL
|
||||
|
||||
val player = TerrarumGDX.ingame!!.player
|
||||
val player = Terrarum.ingame!!.player
|
||||
|
||||
batch.color = Color(0xFFEE88FF.toInt())
|
||||
|
||||
@@ -123,7 +119,7 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
rawB.toString() + ")"
|
||||
printLine(batch, 8, "light@cursor $ccG$lightVal")
|
||||
|
||||
val tileNum = TerrarumGDX.ingame!!.world.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
|
||||
val tileNum = Terrarum.ingame!!.world.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
|
||||
|
||||
printLine(batch, 9, "tile@cursor $ccG$tileNum ($mtX, $mtY)")
|
||||
|
||||
@@ -134,25 +130,25 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
//printLineColumn(batch, 2, 1, "VSync $ccG" + Terrarum.appgc.isVSyncRequested)
|
||||
//printLineColumn(batch, 2, 2, "Env colour temp $ccG" + FeaturesDrawer.colTemp)
|
||||
|
||||
printLineColumn(batch, 2, 5, "Time $ccG${TerrarumGDX.ingame!!.world.time.todaySeconds.toString().padStart(5, '0')}" +
|
||||
" (${TerrarumGDX.ingame!!.world.time.getFormattedTime()})")
|
||||
printLineColumn(batch, 2, 5, "Time $ccG${Terrarum.ingame!!.world.time.todaySeconds.toString().padStart(5, '0')}" +
|
||||
" (${Terrarum.ingame!!.world.time.getFormattedTime()})")
|
||||
printLineColumn(batch, 2, 6, "Mass $ccG${player?.mass}")
|
||||
|
||||
printLineColumn(batch, 2, 7, "noClip $ccG${player?.noClip}")
|
||||
|
||||
|
||||
drawHistogram(batch, LightmapRenderer.histogram,
|
||||
TerrarumGDX.WIDTH - histogramW - 30,
|
||||
TerrarumGDX.HEIGHT - histogramH - 30
|
||||
Terrarum.WIDTH - histogramW - 30,
|
||||
Terrarum.HEIGHT - histogramH - 30
|
||||
)
|
||||
|
||||
batch.color = Color.WHITE
|
||||
|
||||
if (TerrarumGDX.controller != null) {
|
||||
if (Terrarum.controller != null) {
|
||||
drawGamepadAxis(batch,
|
||||
TerrarumGDX.controller!!.getAxisValue(3),
|
||||
TerrarumGDX.controller!!.getAxisValue(2),
|
||||
TerrarumGDX.WIDTH - 135,
|
||||
Terrarum.controller!!.getAxisValue(3),
|
||||
Terrarum.controller!!.getAxisValue(2),
|
||||
Terrarum.WIDTH - 135,
|
||||
40
|
||||
)
|
||||
}
|
||||
@@ -162,42 +158,42 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
*/
|
||||
|
||||
//g.color = GameFontBase.codeToCol["y"]
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccY}MEM ", (TerrarumGDX.WIDTH - 21 * 8 - 2).toFloat(), 2f)
|
||||
//g.draw(batch, "${ccY}FPS $ccG${Terrarum.appgc.fps}", (TerrarumGDX.WIDTH - 6 * 8 - 2).toFloat(), 10f)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccY}CPUs ${if (TerrarumGDX.MULTITHREAD) ccG else ccR}${TerrarumGDX.THREADS}",
|
||||
(TerrarumGDX.WIDTH - 2 - 6*8).toFloat(), 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccY}MEM ", (Terrarum.WIDTH - 21 * 8 - 2).toFloat(), 2f)
|
||||
//g.draw(batch, "${ccY}FPS $ccG${Terrarum.appgc.fps}", (Terrarum.WIDTH - 6 * 8 - 2).toFloat(), 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccY}CPUs ${if (Terrarum.MULTITHREAD) ccG else ccR}${Terrarum.THREADS}",
|
||||
(Terrarum.WIDTH - 2 - 6 * 8).toFloat(), 10f)
|
||||
|
||||
//g.color = GameFontBase.codeToCol["g"]
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${TerrarumGDX.memInUse}M",
|
||||
(TerrarumGDX.WIDTH - 17 * 8 - 2).toFloat(), 2f)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "/${TerrarumGDX.memTotal}M/",
|
||||
(TerrarumGDX.WIDTH - 12 * 8 - 2).toFloat(), 2f)
|
||||
//TerrarumGDX.fontSmallNumbers.color = GameFontBase.codeToCol["m"]
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${TerrarumGDX.memXmx}M",
|
||||
(TerrarumGDX.WIDTH - 5 * 8 - 2).toFloat(), 2f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${Terrarum.memInUse}M",
|
||||
(Terrarum.WIDTH - 17 * 8 - 2).toFloat(), 2f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "/${Terrarum.memTotal}M/",
|
||||
(Terrarum.WIDTH - 12 * 8 - 2).toFloat(), 2f)
|
||||
//Terrarum.fontSmallNumbers.color = GameFontBase.codeToCol["m"]
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${Terrarum.memXmx}M",
|
||||
(Terrarum.WIDTH - 5 * 8 - 2).toFloat(), 2f)
|
||||
|
||||
/**
|
||||
* Bottom left
|
||||
*/
|
||||
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccY}Actors total $ccG${TerrarumGDX.ingame!!.actorContainer.size + TerrarumGDX.ingame!!.actorContainerInactive.size}",
|
||||
2f, TerrarumGDX.HEIGHT - 10f)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccY}Active $ccG${TerrarumGDX.ingame!!.actorContainer.size}",
|
||||
(2 + 17*8).toFloat(), TerrarumGDX.HEIGHT - 10f)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccY}Dormant $ccG${TerrarumGDX.ingame!!.actorContainerInactive.size}",
|
||||
(2 + 28*8).toFloat(), TerrarumGDX.HEIGHT - 10f)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${TerrarumGDX.ingame!!.particlesActive}",
|
||||
(2 + 41*8).toFloat(), TerrarumGDX.HEIGHT - 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Actors total $ccG${Terrarum.ingame!!.actorContainer.size + Terrarum.ingame!!.actorContainerInactive.size}",
|
||||
2f, Terrarum.HEIGHT - 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Active $ccG${Terrarum.ingame!!.actorContainer.size}",
|
||||
(2 + 17*8).toFloat(), Terrarum.HEIGHT - 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Dormant $ccG${Terrarum.ingame!!.actorContainerInactive.size}",
|
||||
(2 + 28*8).toFloat(), Terrarum.HEIGHT - 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${Terrarum.ingame!!.particlesActive}",
|
||||
(2 + 41*8).toFloat(), Terrarum.HEIGHT - 10f)
|
||||
}
|
||||
|
||||
private fun printLine(batch: SpriteBatch, l: Int, s: String) {
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
s, 10f, line(l)
|
||||
)
|
||||
}
|
||||
|
||||
private fun printLineColumn(batch: SpriteBatch, col: Int, row: Int, s: String) {
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
s, (10 + column(col)), line(row)
|
||||
)
|
||||
}
|
||||
@@ -219,9 +215,9 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
batch.color = uiColour
|
||||
batch.fillRect(x.toFloat(), y.toFloat(), w.plus(1), h)
|
||||
batch.color = Color.GRAY
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "0", x.toFloat(), y.toFloat() + h + 2)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "255", x.toFloat() + w + 1 - 8*3, y.toFloat() + h + 2)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "Histogramme", x + w / 2 - 5.5f * 8, y.toFloat() + h + 2)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "0", x.toFloat(), y.toFloat() + h + 2)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "255", x.toFloat() + w + 1 - 8 * 3, y.toFloat() + h + 2)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "Histogramme", x + w / 2 - 5.5f * 8, y.toFloat() + h + 2)
|
||||
|
||||
blendScreen()
|
||||
for (c in 0..2) {
|
||||
@@ -255,13 +251,13 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
val pointDX = axisX * halfW
|
||||
val pointDY = axisY * halfH
|
||||
|
||||
val padName = if (TerrarumGDX.controller!!.name.isEmpty()) "Gamepad"
|
||||
else TerrarumGDX.controller!!.name
|
||||
val padName = if (Terrarum.controller!!.name.isEmpty()) "Gamepad"
|
||||
else Terrarum.controller!!.name
|
||||
|
||||
blendNormal()
|
||||
|
||||
batch.end()
|
||||
TerrarumGDX.inShapeRenderer {
|
||||
Terrarum.inShapeRenderer {
|
||||
it.color = uiColour
|
||||
it.rect(uiX.toFloat(), uiY.toFloat(), w, h)
|
||||
it.color = Color.WHITE
|
||||
@@ -270,7 +266,7 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
}
|
||||
batch.begin()
|
||||
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, padName, uiX + w / 2 - (padName.length) * 4, uiY.toFloat() + h + 2)
|
||||
Terrarum.fontSmallNumbers.draw(batch, padName, uiX + w / 2 - (padName.length) * 4, uiY.toFloat() + h + 2)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.dataclass.HistoryArray
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.Authenticator
|
||||
import net.torvald.terrarum.console.CommandInterpreter
|
||||
import net.torvald.terrarum.fillRect
|
||||
@@ -32,7 +31,7 @@ class ConsoleWindow : UICanvas, KeyControlled {
|
||||
private val LINE_HEIGHT = 20
|
||||
private val MESSAGES_DISPLAY_COUNT = 11
|
||||
|
||||
override var width: Int = TerrarumGDX.WIDTH
|
||||
override var width: Int = Terrarum.WIDTH
|
||||
override var height: Int = LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT + 1)
|
||||
|
||||
override var openCloseTime = 0f
|
||||
@@ -59,12 +58,12 @@ class ConsoleWindow : UICanvas, KeyControlled {
|
||||
batch.fillRect(drawOffX, drawOffY, width.toFloat(), LINE_HEIGHT.toFloat())
|
||||
|
||||
val input = commandInputPool!!.toString()
|
||||
val inputDrawWidth = TerrarumGDX.fontGame.getWidth(input)
|
||||
val inputDrawHeight = TerrarumGDX.fontGame.lineHeight
|
||||
val inputDrawWidth = Terrarum.fontGame.getWidth(input)
|
||||
val inputDrawHeight = Terrarum.fontGame.lineHeight
|
||||
|
||||
// text and cursor
|
||||
batch.color = Color.WHITE
|
||||
TerrarumGDX.fontGame.draw(batch, input, 1f + drawOffX, drawOffY)
|
||||
Terrarum.fontGame.draw(batch, input, 1f + drawOffX, drawOffY)
|
||||
|
||||
batch.color = Color(0x7f7f7f_ff)
|
||||
batch.fillRect(inputDrawWidth.toFloat() + drawOffX + 1, drawOffY, 2f, inputDrawHeight)
|
||||
@@ -75,7 +74,7 @@ class ConsoleWindow : UICanvas, KeyControlled {
|
||||
// messages
|
||||
for (i in 0..MESSAGES_DISPLAY_COUNT - 1) {
|
||||
val message = messages[messageDisplayPos + i]
|
||||
TerrarumGDX.fontGame.draw(batch, message, 1f + drawOffX, (LINE_HEIGHT * (i + 1)).toFloat() + drawOffY)
|
||||
Terrarum.fontGame.draw(batch, message, 1f + drawOffX, (LINE_HEIGHT * (i + 1)).toFloat() + drawOffY)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +181,7 @@ class ConsoleWindow : UICanvas, KeyControlled {
|
||||
commandInputPool = StringBuilder()
|
||||
|
||||
if (Authenticator.b()) {
|
||||
sendMessage("${TerrarumGDX.NAME} ${TerrarumGDX.VERSION_STRING}")
|
||||
sendMessage("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
|
||||
sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.TerrarumGDX
|
||||
object DrawUtil {
|
||||
fun drawCentered(batch: SpriteBatch, image: Texture, screenPosY: Int, ui: UICanvas? = null) {
|
||||
val imageW = image.width
|
||||
val targetW = if (ui == null) TerrarumGDX.WIDTH else ui.width
|
||||
val targetW = if (ui == null) Terrarum.WIDTH else ui.width
|
||||
|
||||
batch.draw(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -19,7 +19,7 @@ class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas
|
||||
override var height: Int = 0
|
||||
|
||||
private var fontCol: Color = if (!isBlackVariant) Color.BLACK else Color.WHITE
|
||||
private val GLYPH_HEIGHT = TerrarumGDX.fontGame.lineHeight
|
||||
private val GLYPH_HEIGHT = Terrarum.fontGame.lineHeight
|
||||
|
||||
override var openCloseTime: Second = OPEN_CLOSE_TIME
|
||||
|
||||
@@ -38,7 +38,7 @@ class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas
|
||||
override fun render(batch: SpriteBatch) {
|
||||
blendNormal()
|
||||
|
||||
val textWidth = messagesList.map { TerrarumGDX.fontGame.getWidth(it) }.sorted()[1]
|
||||
val textWidth = messagesList.map { Terrarum.fontGame.getWidth(it) }.sorted()[1]
|
||||
|
||||
batch.color = Color.WHITE
|
||||
|
||||
@@ -47,7 +47,7 @@ class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas
|
||||
batch.draw(segment.get(2, 0), 2 * LRmargin + textWidth, 0f)
|
||||
|
||||
messagesList.forEachIndexed { index, s ->
|
||||
TerrarumGDX.fontGame.draw(batch, s, segment.tileW + LRmargin, (segment.tileH - TerrarumGDX.fontGame.lineHeight) / 2f)
|
||||
Terrarum.fontGame.draw(batch, s, segment.tileW + LRmargin, (segment.tileH - Terrarum.fontGame.lineHeight) / 2f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ class Notification : UICanvas {
|
||||
|
||||
override var height: Int = msgUI.height
|
||||
private val visibleTime = Math.min(
|
||||
TerrarumGDX.getConfigInt("notificationshowuptime"),
|
||||
Terrarum.getConfigInt("notificationshowuptime"),
|
||||
SHOWUP_MAX
|
||||
)
|
||||
private var displayTimer = 0f
|
||||
|
||||
@@ -34,7 +34,7 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas {
|
||||
ELuptimer += delta
|
||||
}
|
||||
|
||||
if (mouseUp || Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyinteract"))) {
|
||||
if (mouseUp || Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyinteract"))) {
|
||||
ELuptimer = 0f
|
||||
ELon = true
|
||||
}
|
||||
@@ -94,11 +94,11 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas {
|
||||
if (player != null) {
|
||||
val playerPos = player.tilewiseHitbox
|
||||
lightLevel = (LightmapRenderer.getLight(playerPos.centeredX.toInt(), playerPos.centeredY.toInt()) ?:
|
||||
TerrarumGDX.ingame!!.world.globalLight
|
||||
Terrarum.ingame!!.world.globalLight
|
||||
).normaliseToColour()
|
||||
}
|
||||
else {
|
||||
lightLevel = TerrarumGDX.ingame!!.world.globalLight.normaliseToColour()
|
||||
lightLevel = Terrarum.ingame!!.world.globalLight.normaliseToColour()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
|
||||
@@ -29,16 +29,16 @@ interface UICanvas {
|
||||
|
||||
|
||||
val relativeMouseX: Int
|
||||
get() = (TerrarumGDX.mouseScreenX - (handler?.posX ?: 0))
|
||||
get() = (Terrarum.mouseScreenX - (handler?.posX ?: 0))
|
||||
val relativeMouseY: Int
|
||||
get() = (TerrarumGDX.mouseScreenY - (handler?.posY ?: 0))
|
||||
get() = (Terrarum.mouseScreenY - (handler?.posY ?: 0))
|
||||
|
||||
/** If mouse is hovering over it */
|
||||
val mouseUp: Boolean
|
||||
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
|
||||
/** If mouse is hovering over it and mouse is down */
|
||||
val mousePushed: Boolean
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(TerrarumGDX.getConfigInt("mouseprimary"))
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary"))
|
||||
|
||||
|
||||
fun update(delta: Float)
|
||||
@@ -98,13 +98,13 @@ interface UICanvas {
|
||||
).roundInt()
|
||||
Position.RIGHT -> handler!!.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
TerrarumGDX.WIDTH.toFloat(),
|
||||
TerrarumGDX.WIDTH - handler.UI.width.toFloat()
|
||||
Terrarum.WIDTH.toFloat(),
|
||||
Terrarum.WIDTH - handler.UI.width.toFloat()
|
||||
).roundInt()
|
||||
Position.BOTTOM -> handler!!.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
TerrarumGDX.HEIGHT.toFloat(),
|
||||
TerrarumGDX.HEIGHT - handler.UI.height.toFloat()
|
||||
Terrarum.HEIGHT.toFloat(),
|
||||
Terrarum.HEIGHT - handler.UI.height.toFloat()
|
||||
).roundInt()
|
||||
}
|
||||
}
|
||||
@@ -122,13 +122,13 @@ interface UICanvas {
|
||||
).roundInt()
|
||||
Position.RIGHT -> handler!!.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
TerrarumGDX.WIDTH - handler.UI.width.toFloat(),
|
||||
TerrarumGDX.WIDTH.toFloat()
|
||||
Terrarum.WIDTH - handler.UI.width.toFloat(),
|
||||
Terrarum.WIDTH.toFloat()
|
||||
).roundInt()
|
||||
Position.BOTTOM -> handler!!.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
TerrarumGDX.HEIGHT - handler.UI.height.toFloat(),
|
||||
TerrarumGDX.HEIGHT.toFloat()
|
||||
Terrarum.HEIGHT - handler.UI.height.toFloat(),
|
||||
Terrarum.HEIGHT.toFloat()
|
||||
).roundInt()
|
||||
}
|
||||
}
|
||||
@@ -136,16 +136,16 @@ interface UICanvas {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = 0
|
||||
Position.TOP -> handler!!.posY = 0
|
||||
Position.RIGHT -> handler!!.posX = TerrarumGDX.WIDTH - handler.UI.width
|
||||
Position.BOTTOM -> handler!!.posY = TerrarumGDX.HEIGHT - handler.UI.height
|
||||
Position.RIGHT -> handler!!.posX = Terrarum.WIDTH - handler.UI.width
|
||||
Position.BOTTOM -> handler!!.posY = Terrarum.HEIGHT - handler.UI.height
|
||||
}
|
||||
}
|
||||
fun endClosingPopOut(handler: UIHandler?, position: Position) {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = -handler.UI.width
|
||||
Position.TOP -> handler!!.posY = -handler.UI.height
|
||||
Position.RIGHT -> handler!!.posX = TerrarumGDX.WIDTH
|
||||
Position.BOTTOM -> handler!!.posY = TerrarumGDX.HEIGHT
|
||||
Position.RIGHT -> handler!!.posX = Terrarum.WIDTH
|
||||
Position.BOTTOM -> handler!!.posY = Terrarum.HEIGHT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.math.Matrix4
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
|
||||
/**
|
||||
@@ -134,12 +133,12 @@ class UIHandler(val UI: UICanvas,
|
||||
//batch.projectionMatrix = Matrix4()
|
||||
//
|
||||
//if (!customPositioning)
|
||||
// TerrarumGDX.ingame?.camera?.position?.set(posX.toFloat(), posY.toFloat(), 0f) // does it work?
|
||||
// Terrarum.ingame?.camera?.position?.set(posX.toFloat(), posY.toFloat(), 0f) // does it work?
|
||||
|
||||
|
||||
|
||||
if (!customPositioning)
|
||||
TerrarumGDX.ingame?.setCameraPosition(posX.toFloat(), posY.toFloat())
|
||||
Terrarum.ingame?.setCameraPosition(posX.toFloat(), posY.toFloat())
|
||||
batch.color = Color.WHITE
|
||||
|
||||
UI.render(batch)
|
||||
|
||||
@@ -2,10 +2,9 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumGDX.joypadLabelNinA
|
||||
import net.torvald.terrarum.TerrarumGDX.joypadLabelNinY
|
||||
import net.torvald.terrarum.Terrarum.joypadLabelNinA
|
||||
import net.torvald.terrarum.Terrarum.joypadLabelNinY
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.ActorInventory.Companion.CAPACITY_MODE_NO_ENCUMBER
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
@@ -57,7 +56,7 @@ class UIInventory(
|
||||
val itemStripGutterH = 8
|
||||
val itemInterColGutter = 8
|
||||
|
||||
val controlHelpHeight = TerrarumGDX.fontGame.lineHeight.toInt()
|
||||
val controlHelpHeight = Terrarum.fontGame.lineHeight.toInt()
|
||||
|
||||
val catButtons = UIItemTextButtonList(
|
||||
this,
|
||||
@@ -116,7 +115,7 @@ class UIInventory(
|
||||
|
||||
private val SP = "${0x3000.toChar()}${0x3000.toChar()}${0x3000.toChar()}"
|
||||
val listControlHelp: String
|
||||
get() = if (TerrarumGDX.environment == RunningEnvironment.PC)
|
||||
get() = if (Terrarum.environment == RunningEnvironment.PC)
|
||||
"${0xe006.toChar()} ${Lang["GAME_INVENTORY_USE"]}$SP" +
|
||||
"${0xe011.toChar()}..${0xe010.toChar()} ${Lang["GAME_INVENTORY_REGISTER"]}$SP" +
|
||||
"${0xe034.toChar()} ${Lang["GAME_INVENTORY_DROP"]}"
|
||||
@@ -125,7 +124,7 @@ class UIInventory(
|
||||
"${0xe011.toChar()}${0xe010.toChar()} ${Lang["GAME_INVENTORY_REGISTER"]}$SP" +
|
||||
"$joypadLabelNinA ${Lang["GAME_INVENTORY_DROP"]}"
|
||||
val listControlClose: String
|
||||
get() = if (TerrarumGDX.environment == RunningEnvironment.PC)
|
||||
get() = if (Terrarum.environment == RunningEnvironment.PC)
|
||||
"${0xe037.toChar()} ${Lang["GAME_ACTION_CLOSE"]}"
|
||||
else
|
||||
"${0xe069.toChar()} ${Lang["GAME_ACTION_CLOSE"]}"
|
||||
@@ -181,16 +180,16 @@ class UIInventory(
|
||||
blendNormal()
|
||||
batch.color = defaultTextColour
|
||||
// W - close
|
||||
TerrarumGDX.fontGame.draw(batch, listControlClose, 4f, height - controlHelpHeight.toFloat())
|
||||
Terrarum.fontGame.draw(batch, listControlClose, 4f, height - controlHelpHeight.toFloat())
|
||||
// MouseL - Use ; 1.9 - Register ; T - Drop
|
||||
TerrarumGDX.fontGame.draw(batch, listControlHelp, catButtons.width + 4f, height - controlHelpHeight.toFloat())
|
||||
Terrarum.fontGame.draw(batch, listControlHelp, catButtons.width + 4f, height - controlHelpHeight.toFloat())
|
||||
// encumbrance
|
||||
if (inventory != null) {
|
||||
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
|
||||
|
||||
TerrarumGDX.fontGame.draw(batch,
|
||||
Terrarum.fontGame.draw(batch,
|
||||
encumbranceText,
|
||||
width - 9 - TerrarumGDX.fontGame.getWidth(encumbranceText) - weightBarWidth,
|
||||
width - 9 - Terrarum.fontGame.getWidth(encumbranceText) - weightBarWidth,
|
||||
height - controlHelpHeight.toFloat()
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,16 +17,16 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI
|
||||
abstract val height: Int
|
||||
|
||||
protected val relativeMouseX: Int
|
||||
get() = (TerrarumGDX.mouseScreenX - (parentUI.handler?.posX ?: 0) - this.posX)
|
||||
get() = (Terrarum.mouseScreenX - (parentUI.handler?.posX ?: 0) - this.posX)
|
||||
protected val relativeMouseY: Int
|
||||
get() = (TerrarumGDX.mouseScreenY - (parentUI.handler?.posY ?: 0) - this.posY)
|
||||
get() = (Terrarum.mouseScreenY - (parentUI.handler?.posY ?: 0) - this.posY)
|
||||
|
||||
/** If mouse is hovering over it */
|
||||
open val mouseUp: Boolean
|
||||
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
|
||||
/** If mouse is hovering over it and mouse is down */
|
||||
open val mousePushed: Boolean
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(TerrarumGDX.getConfigInt("mouseprimary")!!)
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary")!!)
|
||||
|
||||
abstract fun update(delta: Float)
|
||||
abstract fun render(batch: SpriteBatch)
|
||||
|
||||
@@ -30,7 +30,7 @@ class UIItemTextButton(
|
||||
) : UIItem(parentUI) {
|
||||
|
||||
companion object {
|
||||
val font = TerrarumGDX.fontGame
|
||||
val font = Terrarum.fontGame
|
||||
val height = font.lineHeight.toInt() * 2
|
||||
val defaultInactiveCol: Color = Color(0xc8c8c8_ff.toInt())
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.ui
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
@@ -35,9 +35,9 @@ class UIPieMenu : UICanvas {
|
||||
var selection: Int = -1
|
||||
|
||||
override fun update(delta: Float) {
|
||||
if (TerrarumGDX.ingame!!.player != null) {
|
||||
if (Terrarum.ingame!!.player != null) {
|
||||
if (selection >= 0)
|
||||
TerrarumGDX.ingame!!.player!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
|
||||
Terrarum.ingame!!.player!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
|
||||
selection % slotCount
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,8 @@ class UIPieMenu : UICanvas {
|
||||
|
||||
val slotSize = image.width
|
||||
|
||||
val slotX = slotCentrePoint.x.toFloat() - (slotSize / 2) + TerrarumGDX.HALFW
|
||||
val slotY = slotCentrePoint.y.toFloat() - (slotSize / 2) + TerrarumGDX.HALFH
|
||||
val slotX = slotCentrePoint.x.toFloat() - (slotSize / 2) + Terrarum.HALFW
|
||||
val slotY = slotCentrePoint.y.toFloat() - (slotSize / 2) + Terrarum.HALFH
|
||||
|
||||
batch.color = Color(1f, 1f, 1f, handler!!.opacity * UIQuickBar.finalOpacity)
|
||||
batch.draw(
|
||||
@@ -69,7 +69,7 @@ class UIPieMenu : UICanvas {
|
||||
|
||||
|
||||
// draw item
|
||||
val itemPair = TerrarumGDX.ingame!!.player!!.inventory.getQuickBar(i)
|
||||
val itemPair = Terrarum.ingame!!.player!!.inventory.getQuickBar(i)
|
||||
|
||||
if (itemPair != null) {
|
||||
val itemImage = ItemCodex.getItemImage(itemPair.item)
|
||||
@@ -88,8 +88,8 @@ class UIPieMenu : UICanvas {
|
||||
|
||||
override fun processInput(delta: Float) {
|
||||
if (handler!!.isOpened || handler!!.isOpening) {
|
||||
val cursorPos = Vector2(TerrarumGDX.mouseX, TerrarumGDX.mouseY)
|
||||
val centre = Vector2(TerrarumGDX.HALFW.toDouble(), TerrarumGDX.HALFH.toDouble())
|
||||
val cursorPos = Vector2(Terrarum.mouseX, Terrarum.mouseY)
|
||||
val centre = Vector2(Terrarum.HALFW.toDouble(), Terrarum.HALFH.toDouble())
|
||||
val deg = -(centre - cursorPos).direction.toFloat()
|
||||
|
||||
selection = Math.round(deg * slotCount / FastMath.TWO_PI)
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
@@ -14,7 +14,7 @@ import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
class UIQuickBar : UICanvas, MouseControlled {
|
||||
private val gutter = 8
|
||||
override var width: Int = (ItemSlotImageBuilder.slotImage.width + gutter) * SLOT_COUNT
|
||||
override var height: Int = ItemSlotImageBuilder.slotImage.height + 4 + TerrarumGDX.fontGame.lineHeight.toInt()
|
||||
override var height: Int = ItemSlotImageBuilder.slotImage.height + 4 + Terrarum.fontGame.lineHeight.toInt()
|
||||
/**
|
||||
* In milliseconds
|
||||
*/
|
||||
@@ -26,8 +26,8 @@ class UIQuickBar : UICanvas, MouseControlled {
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
private var selection: Int
|
||||
get() = TerrarumGDX.ingame!!.player?.actorValue?.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||
set(value) { TerrarumGDX.ingame!!.player?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, value.fmod(SLOT_COUNT)) }
|
||||
get() = Terrarum.ingame!!.player?.actorValue?.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||
set(value) { Terrarum.ingame!!.player?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, value.fmod(SLOT_COUNT)) }
|
||||
|
||||
|
||||
override fun update(delta: Float) {
|
||||
@@ -53,7 +53,7 @@ class UIQuickBar : UICanvas, MouseControlled {
|
||||
)
|
||||
|
||||
// draw item
|
||||
val itemPair = TerrarumGDX.ingame!!.player!!.inventory.getQuickBar(i)
|
||||
val itemPair = Terrarum.ingame!!.player!!.inventory.getQuickBar(i)
|
||||
|
||||
if (itemPair != null) {
|
||||
val itemImage = ItemCodex.getItemImage(itemPair.item)
|
||||
|
||||
@@ -39,7 +39,7 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas {
|
||||
private val lcdLitCol = Color(0x141414_ff)
|
||||
|
||||
private val worldTime: WorldTime
|
||||
get() = TerrarumGDX.ingame!!.world.time
|
||||
get() = Terrarum.ingame!!.world.time
|
||||
|
||||
|
||||
override fun update(delta: Float) {
|
||||
@@ -47,7 +47,7 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas {
|
||||
ELuptimer += delta
|
||||
}
|
||||
|
||||
if (mouseUp || Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyinteract"))) {
|
||||
if (mouseUp || Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyinteract"))) {
|
||||
ELuptimer = 0f
|
||||
ELon = true
|
||||
}
|
||||
@@ -69,11 +69,11 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas {
|
||||
if (player != null) {
|
||||
val playerPos = player.tilewiseHitbox
|
||||
lightLevel = (LightmapRenderer.getLight(playerPos.centeredX.toInt(), playerPos.centeredY.toInt()) ?:
|
||||
TerrarumGDX.ingame!!.world.globalLight
|
||||
Terrarum.ingame!!.world.globalLight
|
||||
).normaliseToColour()
|
||||
}
|
||||
else {
|
||||
lightLevel = TerrarumGDX.ingame!!.world.globalLight.normaliseToColour()
|
||||
lightLevel = Terrarum.ingame!!.world.globalLight.normaliseToColour()
|
||||
}
|
||||
|
||||
// backplate
|
||||
|
||||
@@ -4,10 +4,9 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.colourutil.CIELabUtil.darkerLab
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-03-03.
|
||||
@@ -56,8 +55,8 @@ class UIVitalMetre(
|
||||
|
||||
override fun update(delta: Float) {
|
||||
handler!!.setPosition(
|
||||
TerrarumGDX.HALFW,
|
||||
TerrarumGDX.HALFH
|
||||
Terrarum.HALFW,
|
||||
Terrarum.HALFH
|
||||
)
|
||||
}
|
||||
|
||||
@@ -69,8 +68,8 @@ class UIVitalMetre(
|
||||
|
||||
/*if (vitalGetterVal() != null && vitalGetterMax() != null && player != null) {
|
||||
g.translate(
|
||||
TerrarumGDX.ingame!!.screenZoom * (player!!.centrePosPoint.x.toFloat() - (WorldCamera.x)),
|
||||
TerrarumGDX.ingame!!.screenZoom * (player!!.centrePosPoint.y.toFloat() - (WorldCamera.y))
|
||||
Terrarum.ingame!!.screenZoom * (player!!.centrePosPoint.x.toFloat() - (WorldCamera.x)),
|
||||
Terrarum.ingame!!.screenZoom * (player!!.centrePosPoint.y.toFloat() - (WorldCamera.y))
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user