mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
generalised things so that they would work outside of ingame.world; title screen wip
This commit is contained in:
@@ -19,8 +19,6 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
|
||||
override var openCloseTime: Float = 0f
|
||||
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
private var prevPlayerX = 0.0
|
||||
private var prevPlayerY = 0.0
|
||||
|
||||
@@ -30,7 +28,7 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
|
||||
|
||||
override fun update(delta: Float) {
|
||||
val player = Terrarum.ingame!!.player!!
|
||||
val player = Terrarum.ingame!!.player
|
||||
val hitbox = player.hitbox
|
||||
|
||||
xdelta = hitbox.canonicalX - prevPlayerX
|
||||
@@ -49,7 +47,7 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
|
||||
batch.color = Color(0xFFEE88FF.toInt())
|
||||
|
||||
val hitbox = player?.hitbox
|
||||
val hitbox = player.hitbox
|
||||
|
||||
/**
|
||||
* First column
|
||||
@@ -80,11 +78,11 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
+ "${(hitbox?.endY?.div(FeaturesDrawer.TILE_SIZE))?.toInt()}"
|
||||
+ ")")
|
||||
|
||||
printLine(batch, 3, "veloX reported $ccG${player?.externalForce?.x}")
|
||||
printLine(batch, 4, "veloY reported $ccG${player?.externalForce?.y}")
|
||||
printLine(batch, 3, "veloX reported $ccG${player.externalForce?.x}")
|
||||
printLine(batch, 4, "veloY reported $ccG${player.externalForce?.y}")
|
||||
|
||||
printLine(batch, 5, "p_WalkX $ccG${player?.controllerMoveDelta?.x}")
|
||||
printLine(batch, 6, "p_WalkY $ccG${player?.controllerMoveDelta?.y}")
|
||||
printLine(batch, 5, "p_WalkX $ccG${player.controllerMoveDelta?.x}")
|
||||
printLine(batch, 6, "p_WalkY $ccG${player.controllerMoveDelta?.y}")
|
||||
|
||||
printLineColumn(batch, 2, 3, "veloX measured $ccG${xdelta}")
|
||||
printLineColumn(batch, 2, 4, "veloY measured $ccG${ydelta}")
|
||||
@@ -130,9 +128,9 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
|
||||
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, 6, "Mass $ccG${player.mass}")
|
||||
|
||||
printLineColumn(batch, 2, 7, "noClip $ccG${player?.noClip}")
|
||||
printLineColumn(batch, 2, 7, "noClip $ccG${player.noClip}")
|
||||
|
||||
|
||||
drawHistogram(batch, LightmapRenderer.histogram,
|
||||
|
||||
@@ -40,8 +40,6 @@ class ConsoleWindow : UICanvas() {
|
||||
private var drawOffY: Float = -height.toFloat()
|
||||
private var openingTimeCounter = 0f
|
||||
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
private var historyIndex = -1
|
||||
|
||||
init {
|
||||
|
||||
@@ -23,8 +23,6 @@ class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas
|
||||
|
||||
override var openCloseTime: Second = OPEN_CLOSE_TIME
|
||||
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
private val LRmargin = 0f // there's "base value" of 8 px for LR (width of segment tile)
|
||||
|
||||
|
||||
|
||||
@@ -26,14 +26,12 @@ class Notification : UICanvas() {
|
||||
|
||||
override var openCloseTime: Second = MessageWindow.OPEN_CLOSE_TIME
|
||||
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
override fun update(delta: Float) {
|
||||
if (handler!!.isOpened)
|
||||
if (handler.isOpened)
|
||||
displayTimer += delta
|
||||
|
||||
if (displayTimer >= visibleTime) {
|
||||
handler!!.setAsClose()
|
||||
handler.setAsClose()
|
||||
displayTimer = 0f
|
||||
}
|
||||
}
|
||||
@@ -61,9 +59,9 @@ class Notification : UICanvas() {
|
||||
fun sendNotification(message: Array<String>) {
|
||||
this.message = message
|
||||
msgUI.setMessage(this.message)
|
||||
handler!!.openCloseCounter = 0f
|
||||
handler!!.opacity = 0f
|
||||
handler!!.setAsOpen()
|
||||
handler.openCloseCounter = 0f
|
||||
handler.opacity = 0f
|
||||
handler.setAsOpen()
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
class NullUI : UICanvas() {
|
||||
override var width: Int = 0
|
||||
override var height: Int = 0
|
||||
override var handler: UIHandler? = null
|
||||
override var openCloseTime = 0f
|
||||
|
||||
override fun update(delta: Float) {
|
||||
|
||||
@@ -18,7 +18,6 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas() {
|
||||
override var width = 116
|
||||
override var height = 24
|
||||
override var handler: UIHandler? = null
|
||||
override var openCloseTime: Second = 0f
|
||||
|
||||
private var ELuptimer = 10f // to make the light turned off by default
|
||||
|
||||
@@ -20,7 +20,7 @@ abstract class UICanvas {
|
||||
/**
|
||||
* Usage: (in StateInGame:) uiHandlerField.ui.handler = uiHandlerField
|
||||
*/
|
||||
abstract var handler: UIHandler?
|
||||
open lateinit var handler: UIHandler
|
||||
|
||||
/**
|
||||
* In milliseconds
|
||||
@@ -34,9 +34,9 @@ abstract class UICanvas {
|
||||
|
||||
|
||||
val relativeMouseX: Int
|
||||
get() = (Terrarum.mouseScreenX - (handler?.posX ?: 0))
|
||||
get() = Terrarum.mouseScreenX - handler.posX
|
||||
val relativeMouseY: Int
|
||||
get() = (Terrarum.mouseScreenY - (handler?.posY ?: 0))
|
||||
get() = Terrarum.mouseScreenY - handler.posY
|
||||
|
||||
/** If mouse is hovering over it */
|
||||
val mouseUp: Boolean
|
||||
@@ -51,22 +51,22 @@ abstract class UICanvas {
|
||||
abstract fun render(batch: SpriteBatch)
|
||||
|
||||
/**
|
||||
* Do not modify handler!!.openCloseCounter here.
|
||||
* Do not modify handler.openCloseCounter here.
|
||||
*/
|
||||
abstract fun doOpening(delta: Float)
|
||||
|
||||
/**
|
||||
* Do not modify handler!!.openCloseCounter here.
|
||||
* Do not modify handler.openCloseCounter here.
|
||||
*/
|
||||
abstract fun doClosing(delta: Float)
|
||||
|
||||
/**
|
||||
* Do not modify handler!!.openCloseCounter here.
|
||||
* Do not modify handler.openCloseCounter here.
|
||||
*/
|
||||
abstract fun endOpening(delta: Float)
|
||||
|
||||
/**
|
||||
* Do not modify handler!!.openCloseCounter here.
|
||||
* Do not modify handler.openCloseCounter here.
|
||||
*/
|
||||
abstract fun endClosing(delta: Float)
|
||||
|
||||
@@ -118,82 +118,82 @@ abstract class UICanvas {
|
||||
companion object {
|
||||
const val OPENCLOSE_GENERIC = 0.2f
|
||||
|
||||
fun doOpeningFade(handler: UIHandler?, openCloseTime: Second) {
|
||||
handler!!.opacity = handler.openCloseCounter / openCloseTime
|
||||
fun doOpeningFade(handler: UIHandler, openCloseTime: Second) {
|
||||
handler.opacity = handler.openCloseCounter / openCloseTime
|
||||
}
|
||||
fun doClosingFade(handler: UIHandler?, openCloseTime: Second) {
|
||||
handler!!.opacity = (openCloseTime - handler.openCloseCounter) / openCloseTime
|
||||
fun doClosingFade(handler: UIHandler, openCloseTime: Second) {
|
||||
handler.opacity = (openCloseTime - handler.openCloseCounter) / openCloseTime
|
||||
}
|
||||
fun endOpeningFade(handler: UIHandler?) {
|
||||
handler!!.opacity = 1f
|
||||
fun endOpeningFade(handler: UIHandler) {
|
||||
handler.opacity = 1f
|
||||
}
|
||||
fun endClosingFade(handler: UIHandler?) {
|
||||
handler!!.opacity = 0f
|
||||
fun endClosingFade(handler: UIHandler) {
|
||||
handler.opacity = 0f
|
||||
}
|
||||
|
||||
|
||||
fun doOpeningPopOut(handler: UIHandler?, openCloseTime: Second, position: Position) {
|
||||
fun doOpeningPopOut(handler: UIHandler, openCloseTime: Second, position: Position) {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = Movement.fastPullOut(
|
||||
Position.LEFT -> handler.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
-handler.UI.width.toFloat(),
|
||||
0f
|
||||
).roundInt()
|
||||
Position.TOP -> handler!!.posY = Movement.fastPullOut(
|
||||
Position.TOP -> handler.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
-handler.UI.height.toFloat(),
|
||||
0f
|
||||
).roundInt()
|
||||
Position.RIGHT -> handler!!.posX = Movement.fastPullOut(
|
||||
Position.RIGHT -> handler.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
Terrarum.WIDTH.toFloat(),
|
||||
Terrarum.WIDTH - handler.UI.width.toFloat()
|
||||
).roundInt()
|
||||
Position.BOTTOM -> handler!!.posY = Movement.fastPullOut(
|
||||
Position.BOTTOM -> handler.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
Terrarum.HEIGHT.toFloat(),
|
||||
Terrarum.HEIGHT - handler.UI.height.toFloat()
|
||||
).roundInt()
|
||||
}
|
||||
}
|
||||
fun doClosingPopOut(handler: UIHandler?, openCloseTime: Second, position: Position) {
|
||||
fun doClosingPopOut(handler: UIHandler, openCloseTime: Second, position: Position) {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = Movement.fastPullOut(
|
||||
Position.LEFT -> handler.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
0f,
|
||||
-handler.UI.width.toFloat()
|
||||
).roundInt()
|
||||
Position.TOP -> handler!!.posY = Movement.fastPullOut(
|
||||
Position.TOP -> handler.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
0f,
|
||||
-handler.UI.height.toFloat()
|
||||
).roundInt()
|
||||
Position.RIGHT -> handler!!.posX = Movement.fastPullOut(
|
||||
Position.RIGHT -> handler.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
Terrarum.WIDTH - handler.UI.width.toFloat(),
|
||||
Terrarum.WIDTH.toFloat()
|
||||
).roundInt()
|
||||
Position.BOTTOM -> handler!!.posY = Movement.fastPullOut(
|
||||
Position.BOTTOM -> handler.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
Terrarum.HEIGHT - handler.UI.height.toFloat(),
|
||||
Terrarum.HEIGHT.toFloat()
|
||||
).roundInt()
|
||||
}
|
||||
}
|
||||
fun endOpeningPopOut(handler: UIHandler?, position: Position) {
|
||||
fun endOpeningPopOut(handler: UIHandler, position: Position) {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = 0
|
||||
Position.TOP -> handler!!.posY = 0
|
||||
Position.RIGHT -> handler!!.posX = Terrarum.WIDTH - handler.UI.width
|
||||
Position.BOTTOM -> handler!!.posY = Terrarum.HEIGHT - handler.UI.height
|
||||
Position.LEFT -> handler.posX = 0
|
||||
Position.TOP -> handler.posY = 0
|
||||
Position.RIGHT -> handler.posX = Terrarum.WIDTH - handler.UI.width
|
||||
Position.BOTTOM -> handler.posY = Terrarum.HEIGHT - handler.UI.height
|
||||
}
|
||||
}
|
||||
fun endClosingPopOut(handler: UIHandler?, position: Position) {
|
||||
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 = Terrarum.WIDTH
|
||||
Position.BOTTOM -> handler!!.posY = Terrarum.HEIGHT
|
||||
Position.LEFT -> handler.posX = -handler.UI.width
|
||||
Position.TOP -> handler.posY = -handler.UI.height
|
||||
Position.RIGHT -> handler.posX = Terrarum.WIDTH
|
||||
Position.BOTTOM -> handler.posY = Terrarum.HEIGHT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ class UIInventory(
|
||||
//val actorValue: ActorValue
|
||||
// get() = (actor as Actor).actorValue
|
||||
|
||||
override var handler: UIHandler? = null
|
||||
override var openCloseTime: Second = 0.12f
|
||||
|
||||
val catButtonsToCatIdent = HashMap<String, String>()
|
||||
@@ -204,7 +203,7 @@ class UIInventory(
|
||||
// monitor and check if category selection has been changed
|
||||
// OR UI is being opened from closed state
|
||||
if (oldCatSelect != catButtons.selectedIndex ||
|
||||
!rebuildList && handler!!.openFired) {
|
||||
!rebuildList && handler.openFired) {
|
||||
rebuildList = true
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,10 @@ class UIPieMenu : UICanvas() {
|
||||
private val slotCount = UIQuickBar.SLOT_COUNT
|
||||
|
||||
private val slotDistanceFromCentre: Double
|
||||
get() = cellSize * 2.7 * handler!!.scale
|
||||
get() = cellSize * 2.8 * handler.scale
|
||||
override var width: Int = cellSize * 7
|
||||
override var height: Int = width
|
||||
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
/**
|
||||
* In milliseconds
|
||||
@@ -35,16 +34,14 @@ class UIPieMenu : UICanvas() {
|
||||
var selection: Int = -1
|
||||
|
||||
override fun update(delta: Float) {
|
||||
if (Terrarum.ingame!!.player != null) {
|
||||
if (selection >= 0)
|
||||
Terrarum.ingame!!.player!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
|
||||
selection % slotCount
|
||||
}
|
||||
if (selection >= 0)
|
||||
Terrarum.ingame!!.player.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
|
||||
selection % slotCount
|
||||
|
||||
|
||||
// update controls
|
||||
if (handler!!.isOpened || handler!!.isOpening) {
|
||||
val cursorPos = Vector2(Terrarum.mouseX, Terrarum.mouseY)
|
||||
if (handler.isOpened || handler.isOpening) {
|
||||
val cursorPos = Vector2(Terrarum.mouseScreenX.toDouble(), Terrarum.mouseScreenY.toDouble())
|
||||
val centre = Vector2(Terrarum.HALFW.toDouble(), Terrarum.HALFH.toDouble())
|
||||
val deg = -(centre - cursorPos).direction.toFloat()
|
||||
|
||||
@@ -60,7 +57,7 @@ class UIPieMenu : UICanvas() {
|
||||
for (i in 0..slotCount - 1) {
|
||||
// set position
|
||||
val angle = Math.PI * 2.0 * (i.toDouble() / slotCount) + Math.PI // 180 deg monitor-wise
|
||||
val slotCentrePoint = Vector2(0.0, slotDistanceFromCentre).setDirection(-angle)// + centrePoint
|
||||
val slotCentrePoint = Vector2(0.0, slotDistanceFromCentre).setDirection(-angle) // NOTE: NOT a center of circle!
|
||||
|
||||
// draw cells
|
||||
val image = if (i == selection)
|
||||
@@ -70,10 +67,10 @@ class UIPieMenu : UICanvas() {
|
||||
|
||||
val slotSize = image.width
|
||||
|
||||
val slotX = slotCentrePoint.x.toFloat() - (slotSize / 2) + Terrarum.HALFW
|
||||
val slotY = slotCentrePoint.y.toFloat() - (slotSize / 2) + Terrarum.HALFH
|
||||
val slotX = slotCentrePoint.x.toFloat() - (slotSize / 2)
|
||||
val slotY = slotCentrePoint.y.toFloat() - (slotSize / 2)
|
||||
|
||||
batch.color = Color(1f, 1f, 1f, handler!!.opacity * UIQuickBar.finalOpacity)
|
||||
batch.color = Color(1f, 1f, 1f, handler.opacity * UIQuickBar.finalOpacity)
|
||||
batch.draw(
|
||||
image,
|
||||
slotX,
|
||||
@@ -82,14 +79,14 @@ class UIPieMenu : UICanvas() {
|
||||
|
||||
|
||||
// draw item
|
||||
val itemPair = Terrarum.ingame!!.player!!.inventory.getQuickBar(i)
|
||||
val itemPair = Terrarum.ingame!!.player.inventory.getQuickBar(i)
|
||||
|
||||
if (itemPair != null) {
|
||||
val itemImage = ItemCodex.getItemImage(itemPair.item)
|
||||
val itemW = itemImage.regionWidth
|
||||
val itemH = itemImage.regionHeight
|
||||
|
||||
batch.color = Color(1f, 1f, 1f, handler!!.opacity)
|
||||
batch.color = Color(1f, 1f, 1f, handler.opacity)
|
||||
batch.draw(
|
||||
itemImage, // using fixed CELL_SIZE for reasons
|
||||
slotX + (CELL_SIZE - itemW) / 2f,
|
||||
@@ -101,22 +98,22 @@ class UIPieMenu : UICanvas() {
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
UICanvas.doOpeningFade(handler, openCloseTime)
|
||||
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
|
||||
handler.scale = smallenSize + (1f.minus(smallenSize) * handler.opacity)
|
||||
}
|
||||
|
||||
override fun doClosing(delta: Float) {
|
||||
UICanvas.doClosingFade(handler, openCloseTime)
|
||||
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
|
||||
handler.scale = smallenSize + (1f.minus(smallenSize) * handler.opacity)
|
||||
}
|
||||
|
||||
override fun endOpening(delta: Float) {
|
||||
UICanvas.endOpeningFade(handler)
|
||||
handler!!.scale = 1f
|
||||
handler.scale = 1f
|
||||
}
|
||||
|
||||
override fun endClosing(delta: Float) {
|
||||
UICanvas.endClosingFade(handler)
|
||||
handler!!.scale = 1f
|
||||
handler.scale = 1f
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.Terrarum
|
||||
@@ -23,12 +24,9 @@ class UIQuickBar : UICanvas() {
|
||||
private val startPointX = ItemSlotImageBuilder.slotLarge.width / 2
|
||||
private val startPointY = ItemSlotImageBuilder.slotLarge.height / 2
|
||||
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
private var selection: Int
|
||||
get() = Terrarum.ingame!!.player?.actorValue?.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||
set(value) { Terrarum.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) {
|
||||
}
|
||||
@@ -45,7 +43,7 @@ class UIQuickBar : UICanvas() {
|
||||
val slotY = startPointY.toFloat()
|
||||
|
||||
// draw slots
|
||||
batch.color = Color(1f, 1f, 1f, handler!!.opacity * finalOpacity)
|
||||
batch.color = Color(1f, 1f, 1f, handler.opacity * finalOpacity)
|
||||
batch.draw(
|
||||
image,
|
||||
slotX,
|
||||
@@ -53,14 +51,14 @@ class UIQuickBar : UICanvas() {
|
||||
)
|
||||
|
||||
// draw item
|
||||
val itemPair = Terrarum.ingame!!.player!!.inventory.getQuickBar(i)
|
||||
val itemPair = Terrarum.ingame!!.player.inventory.getQuickBar(i)
|
||||
|
||||
if (itemPair != null) {
|
||||
val itemImage = ItemCodex.getItemImage(itemPair.item)
|
||||
val itemW = itemImage.regionWidth
|
||||
val itemH = itemImage.regionHeight
|
||||
|
||||
batch.color = Color(1f, 1f, 1f, handler!!.opacity)
|
||||
batch.color = Color(1f, 1f, 1f, handler.opacity)
|
||||
batch.draw(
|
||||
itemImage, // using fixed CELL_SIZE for reasons
|
||||
slotX + (CELL_SIZE - itemW) / 2f,
|
||||
@@ -72,29 +70,47 @@ class UIQuickBar : UICanvas() {
|
||||
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
handler!!.opacity = handler!!.openCloseCounter.toFloat() / openCloseTime
|
||||
handler.opacity = handler.openCloseCounter.toFloat() / openCloseTime
|
||||
}
|
||||
|
||||
override fun doClosing(delta: Float) {
|
||||
handler!!.opacity = (openCloseTime - handler!!.openCloseCounter.toFloat()) / openCloseTime
|
||||
handler.opacity = (openCloseTime - handler.openCloseCounter.toFloat()) / openCloseTime
|
||||
}
|
||||
|
||||
override fun endOpening(delta: Float) {
|
||||
handler!!.opacity = 1f
|
||||
handler.opacity = 1f
|
||||
}
|
||||
|
||||
override fun endClosing(delta: Float) {
|
||||
handler!!.opacity = 0f
|
||||
handler.opacity = 0f
|
||||
}
|
||||
|
||||
override fun scrolled(amount: Int): Boolean {
|
||||
super.scrolled(amount)
|
||||
// super.scrolled(amount) // no UIItems here
|
||||
|
||||
selection = selection.plus(if (amount > 1) 1 else if (amount < -1) -1 else 0).fmod(SLOT_COUNT)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun keyDown(keycode: Int): Boolean {
|
||||
selection = when (keycode) {
|
||||
Input.Keys.NUM_1 -> 0
|
||||
Input.Keys.NUM_2 -> 1
|
||||
Input.Keys.NUM_3 -> 2
|
||||
Input.Keys.NUM_4 -> 3
|
||||
Input.Keys.NUM_5 -> 4
|
||||
Input.Keys.NUM_6 -> 5
|
||||
Input.Keys.NUM_7 -> 6
|
||||
Input.Keys.NUM_8 -> 7
|
||||
Input.Keys.NUM_9 -> 8
|
||||
Input.Keys.NUM_0 -> 9
|
||||
else -> return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ class UIStartMenu : UICanvas() {
|
||||
"MENU_OPTIONS",
|
||||
"MENU_MODULES",
|
||||
"MENU_LABEL_LANGUAGE",
|
||||
"MENU_LABEL_EXIT"
|
||||
"MENU_LABEL_CREDITS",
|
||||
"MENU_LABEL_QUIT"
|
||||
)
|
||||
|
||||
val menubarOffY: Int; get() = Terrarum.HEIGHT / 2 - (Terrarum.fontGame.lineHeight * 1.5).toInt()
|
||||
@@ -23,7 +24,6 @@ class UIStartMenu : UICanvas() {
|
||||
|
||||
override var width: Int = 240
|
||||
override var height: Int = 40 * menuLabels.size.plus(1)
|
||||
override var handler: UIHandler? = null
|
||||
override var openCloseTime = 0f
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class UIStartMenu : UICanvas() {
|
||||
|
||||
|
||||
// attach listeners
|
||||
menubar.buttons[menuLabels.indexOf("MENU_LABEL_EXIT")].clickOnceListener = { _, _, _ -> System.exit(0) }
|
||||
menubar.buttons[menuLabels.indexOf("MENU_LABEL_QUIT")].clickOnceListener = { _, _, _ -> System.exit(0) }
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas() {
|
||||
override var width = 85
|
||||
override var height = 52
|
||||
override var handler: UIHandler? = null
|
||||
override var openCloseTime: Second = 0f
|
||||
|
||||
private var ELuptimer = 10f // to make the light turned off by default
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.torvald.terrarum.gameactors.Second
|
||||
* Created by SKYHi14 on 2017-03-03.
|
||||
*/
|
||||
class UIVitalMetre(
|
||||
var player: ActorHumanoid?,
|
||||
var player: ActorHumanoid,
|
||||
var vitalGetterVal: () -> Float?,
|
||||
var vitalGetterMax: () -> Float?,
|
||||
var color: Color?,
|
||||
@@ -28,20 +28,13 @@ class UIVitalMetre(
|
||||
private val gap = 4f
|
||||
|
||||
override var width: Int = 80 + 2 * margin; set(value) { throw Error("operation not permitted") }
|
||||
override var height: Int; get() = player?.baseHitboxH ?: 0 * 3 + margin; set(value) { throw Error("operation not permitted") }
|
||||
override var handler: UIHandler? = null
|
||||
set(value) {
|
||||
// override customPositioning to be true
|
||||
if (value != null) {
|
||||
value.customPositioning = true
|
||||
}
|
||||
field = value
|
||||
}
|
||||
override var height: Int; get() = player.baseHitboxH ?: 0 * 3 + margin; set(value) { throw Error("operation not permitted") }
|
||||
|
||||
override var openCloseTime: Second = 0.05f
|
||||
|
||||
//private val relativePX = width / 2f
|
||||
private val offsetY: Float; get() = (player?.baseHitboxH ?: 0) * 1.5f
|
||||
private val circleRadius: Float; get() = (player?.baseHitboxH ?: 0) * 3f
|
||||
private val offsetY: Float; get() = (player.baseHitboxH ?: 0) * 1.5f
|
||||
private val circleRadius: Float; get() = (player.baseHitboxH ?: 0) * 3f
|
||||
|
||||
private val theta = 33f
|
||||
private val halfTheta = theta / 2f
|
||||
@@ -54,7 +47,7 @@ class UIVitalMetre(
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
handler!!.setPosition(
|
||||
handler.setPosition(
|
||||
Terrarum.HALFW,
|
||||
Terrarum.HALFH
|
||||
)
|
||||
@@ -68,8 +61,8 @@ class UIVitalMetre(
|
||||
|
||||
/*if (vitalGetterVal() != null && vitalGetterMax() != null && player != null) {
|
||||
g.translate(
|
||||
Terrarum.ingame!!.screenZoom * (player!!.centrePosPoint.x.toFloat() - (WorldCamera.x)),
|
||||
Terrarum.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