inventory gamemenu visual only

This commit is contained in:
minjaesong
2019-01-29 23:37:38 +09:00
parent aef07149b4
commit 1475fa08dc
19 changed files with 307 additions and 52 deletions

View File

@@ -246,6 +246,7 @@ object Terrarum : Screen {
RunningEnvironment.PC
}
//}
}
@@ -689,6 +690,7 @@ fun Double.roundInt(): Int = Math.round(this).toInt()
fun Float.roundInt(): Int = Math.round(this)
fun Double.abs() = Math.abs(this)
fun Double.sqr() = this * this
fun Float.sqr() = this * this
fun Double.sqrt() = Math.sqrt(this)
fun Float.sqrt() = FastMath.sqrt(this)
fun Int.abs() = this.absoluteValue

View File

@@ -6,7 +6,9 @@ import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
import net.torvald.terrarum.ui.*
import net.torvald.terrarum.ui.UIItem
import net.torvald.terrarum.ui.UIItemImageButton
import net.torvald.terrarum.ui.UIUtils
/**
* Created by minjaesong on 2017-10-20.
@@ -18,6 +20,12 @@ class UIItemInventoryCatBar(
override val width: Int
) : UIItem(parentUI) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
private val parentInventory = parentUI
private val catIcons = parentUI.catIcons
private val catArrangement = parentUI.catArrangement
@@ -91,7 +99,7 @@ class UIItemInventoryCatBar(
private val underlineColour = Color(0xeaeaea_40.toInt())
private val underlineHighlightColour = mainButtons[0].highlightCol
private var highlighterXPos = mainButtons[selectedIndex].posX.toDouble()
private var highlighterXPos = mainButtons[selectedIndex].posX.toFloat()
private var highlighterXStart = highlighterXPos
private var highlighterXEnd = highlighterXPos
@@ -100,6 +108,14 @@ class UIItemInventoryCatBar(
private val highlighterMoveDuration: Second = 0.1f
private var highlighterMoveTimer: Second = 0f
private var transitionFired = false
/**
* 0: map, 1: inventory caticons, 2: menu
*/
var selectedPanel = 1
private set
// set up underlined indicator
init {
// procedurally generate texture
@@ -134,8 +150,8 @@ class UIItemInventoryCatBar(
highlighterXPos = UIUtils.moveQuick(
highlighterXStart,
highlighterXEnd,
highlighterMoveTimer.toDouble(),
highlighterMoveDuration.toDouble()
highlighterMoveTimer,
highlighterMoveDuration
)
if (highlighterMoveTimer > highlighterMoveDuration) {
@@ -150,23 +166,61 @@ class UIItemInventoryCatBar(
mainButtons.forEachIndexed { index, btn ->
btn.update(delta)
if (btn.mousePushed && selectedPanel != 1) {
transitionFired = true
selectedPanel = 1
}
if (btn.mousePushed && index != selectedIndex) {
// normal stuffs
val oldIndex = selectedIndex
highlighterXStart = mainButtons[selectedIndex].posX.toDouble() // using old selectedIndex
highlighterXStart = mainButtons[selectedIndex].posX.toFloat() // using old selectedIndex
selectedIndex = index
highlighterMoving = true
highlighterXEnd = mainButtons[selectedIndex].posX.toDouble() // using new selectedIndex
highlighterXEnd = mainButtons[selectedIndex].posX.toFloat() // using new selectedIndex
selectionChangeListener?.invoke(oldIndex, index)
}
if (selectedPanel == 1) {
btn.highlighted = (index == selectedIndex) // forcibly highlight if this.highlighted != null
sideButtons[0].highlighted = false
sideButtons[3].highlighted = false
}
}
sideButtons[0].update(delta)
sideButtons[3].update(delta)
// more transition stuffs
if (sideButtons[0].mousePushed) {
if (selectedPanel != 0) transitionFired = true
mainButtons.forEach { it.highlighted = false }
selectedPanel = 0
parentInventory.requestTransition(0)
sideButtons[0].highlighted = true
sideButtons[3].highlighted = false
}
else if (sideButtons[3].mousePushed) {
if (selectedPanel != 2) transitionFired = true
mainButtons.forEach { it.highlighted = false }
selectedPanel = 2
parentInventory.requestTransition(2)
transitionFired = true
sideButtons[0].highlighted = false
sideButtons[3].highlighted = true
}
if (transitionFired) {
transitionFired = false
parentInventory.requestTransition(2 - selectedPanel)
}
}
override fun render(batch: SpriteBatch, camera: Camera) {
@@ -186,11 +240,15 @@ class UIItemInventoryCatBar(
batch.drawStraightLine(posX.toFloat(), posY + height - 1f, posX + width.toFloat(), 1f, false)
// indicator
if (selectedPanel == 1) {
batch.color = underlineHighlightColour
batch.draw(underlineIndTex, (highlighterXPos - buttonGapSize / 2).toFloat().round(), posY + highlighterYPos)
}
}
override fun dispose() {

View File

@@ -36,6 +36,10 @@ class UIItemInventoryElem(
val drawBackOnNull: Boolean = true
) : UIItemInventoryCellBase(parentUI, posX, posY, item, amount, itemImage, quickslot, equippedSlot) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
companion object {
val height = 48
val UNIQUE_ITEM_HAS_NO_AMOUNT = -1

View File

@@ -33,6 +33,10 @@ class UIItemInventoryElemSimple(
val drawBackOnNull: Boolean = true
) : UIItemInventoryCellBase(parentUI, posX, posY, item, amount, itemImage, quickslot, equippedSlot) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
companion object {
val height = UIItemInventoryElem.height
}

View File

@@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.GL20
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
import com.jme3.math.FastMath
import net.torvald.terrarum.*
import net.torvald.terrarum.gameactors.ActorWBMovable
import net.torvald.terrarum.langpack.Lang
@@ -15,6 +14,8 @@ import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory.Companion.C
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItem
import net.torvald.terrarum.ui.UIItemTextButtonList
import net.torvald.terrarum.ui.UIUtils
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/**
@@ -29,6 +30,8 @@ class UIInventoryFull(
doNotWarnConstant: Boolean = false
) : UICanvas(toggleKeyLiteral, toggleButtonLiteral, customPositioning, doNotWarnConstant) {
private val debugvals = false
override var width: Int = Terrarum.WIDTH
override var height: Int = Terrarum.HEIGHT
@@ -60,12 +63,12 @@ class UIInventoryFull(
get() = if (AppLoader.environment == RunningEnvironment.PC)
"${0xe031.toChar()} ${Lang["GAME_ACTION_CLOSE"]}"
else
"${0xe031.toChar()} ${Lang["GAME_ACTION_CLOSE"]}$SP${0xe06b.toChar()} ${Lang["GAME_INVENTORY"]}"
"${0xe069.toChar()} ${Lang["GAME_ACTION_CLOSE"]}$SP${0xe06b.toChar()} ${Lang["GAME_INVENTORY"]}"
val gameMenuControlHelp: String
get() = if (AppLoader.environment == RunningEnvironment.PC)
"${0xe031.toChar()} ${Lang["GAME_ACTION_CLOSE"]}"
else
"${0xe031.toChar()} ${Lang["GAME_ACTION_CLOSE"]}$SP${0xe068.toChar()} ${Lang["GAME_INVENTORY"]}"
"${0xe069.toChar()} ${Lang["GAME_ACTION_CLOSE"]}$SP${0xe068.toChar()} ${Lang["GAME_INVENTORY"]}"
val controlHelpHeight = Terrarum.fontGame.lineHeight
private var encumbrancePerc = 0f
@@ -104,16 +107,35 @@ class UIInventoryFull(
internalWidth - UIItemInventoryEquippedView.WIDTH + (Terrarum.WIDTH - internalWidth) / 2,
109 + (Terrarum.HEIGHT - internalHeight) / 2
)
private val gameMenuListWidth = 400
private val gameMenuListHeight = 40 * 5
private val gameMenuCharInfoHeight = 64 + 40 // no top margin, 40 bottom margin
private val gameMenuListTotalHeight = gameMenuListHeight + gameMenuCharInfoHeight
private val gameMenuButtons = UIItemTextButtonList(
this, arrayOf("MENU_LABEL_MAINMENU", "MENU_LABEL_DESKTOP", "MENU_OPTIONS_CONTROLS", "MENU_OPTIONS_SOUND", "MENU_LABEL_GRAPHICS"),
Terrarum.WIDTH + (Terrarum.WIDTH - gameMenuListWidth) / 2,
(itemList.height - gameMenuListTotalHeight) / 2 + itemList.posY + gameMenuCharInfoHeight,
gameMenuListWidth, gameMenuListHeight,
readFromLang = true,
textAreaWidth = gameMenuListWidth,
activeBackCol = Color(0),
highlightBackCol = Color(0),
backgroundCol = Color(0),
inactiveCol = Color.WHITE,
defaultSelection = null
)
private val SCREEN_MINIMAP = 2f
private val SCREEN_INVENTORY = 1f
private val SCREEN_MENU = 0f
private var currentScreen = 1f //
private var currentScreen = SCREEN_INVENTORY
private var transitionRequested = false
private var transitionOngoing = false
private var transitionReqSource = SCREEN_INVENTORY
private var transitionReqTarget = SCREEN_INVENTORY
private var transitionTimer = 0f
private val transitionLength = 0.5f
private val SCREEN_MINIMAP = 0
private val SCREEN_INVENTORY = 1
private val SCREEN_MENU = 2
private val transitionLength = 0.333f
private val transitionalUpdateUIs = ArrayList<UIItem>()
@@ -151,6 +173,7 @@ class UIInventoryFull(
addToTransitionalGroup(itemList)
addToTransitionalGroup(equipped)
addToTransitionalGroup(gameMenuButtons)
}
private var offsetX = ((Terrarum.WIDTH - internalWidth) / 2).toFloat()
@@ -165,8 +188,9 @@ class UIInventoryFull(
categoryBar.update(delta)
itemList.update(delta)
equipped.update(delta)
transitionalUpdateUIs.forEach { it.update(delta) }
}
private val gradStartCol = Color(0x404040_60)
@@ -179,13 +203,41 @@ class UIInventoryFull(
private var xEnd = (Terrarum.WIDTH + internalWidth).div(2).toFloat()
private var yEnd = (Terrarum.HEIGHT + internalHeight).div(2).toFloat()
fun requestTransition(target: Int) {
if (!transitionOngoing) {
transitionRequested = true
transitionReqSource = currentScreen.round()
transitionReqTarget = target.toFloat()
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
currentScreen = 1f + 0.1f * FastMath.sin(transitionTimer)
if (transitionRequested && !transitionOngoing) {
transitionRequested = false
transitionOngoing = true
transitionTimer = 0f
}
if (transitionOngoing) {
transitionTimer += Gdx.graphics.deltaTime
currentScreen = UIUtils.moveQuick(transitionReqSource, transitionReqTarget, transitionTimer, transitionLength)
if (transitionTimer > transitionLength) {
transitionOngoing = false
currentScreen = transitionReqTarget
}
}
// update at render time
updateTransitionalItems()
if (debugvals) {
batch.color = Color.WHITE
AppLoader.fontSmallNumbers.draw(batch, "screen:$currentScreen", 500f, 20f)
}
@@ -213,16 +265,83 @@ class UIInventoryFull(
categoryBar.render(batch, camera)
renderScreenInventory(batch, camera)
if (currentScreen > 1f + epsilon) {
renderScreenMinimap(batch, camera)
if (debugvals) {
batch.color = Color.CORAL
AppLoader.fontSmallNumbers.draw(batch, "Map", 300f, 10f)
}
}
if (currentScreen in epsilon..2f - epsilon) {
renderScreenInventory(batch, camera)
if (debugvals) {
batch.color = Color.CHARTREUSE
AppLoader.fontSmallNumbers.draw(batch, "Inv", 350f, 10f)
}
}
if (currentScreen < 1f - epsilon) {
renderScreenGamemenu(batch, camera)
if (debugvals) {
batch.color = Color.SKY
AppLoader.fontSmallNumbers.draw(batch, "Men", 400f, 10f)
}
}
if (debugvals) {
batch.color = Color.WHITE
AppLoader.fontSmallNumbers.draw(batch, "inventoryScrOffX:$inventoryScrOffX", 500f, 10f)
}
}
private val epsilon = 0.001f
private val minimapScrOffX: Float
get() = (currentScreen + 1f) * Terrarum.WIDTH
get() = (currentScreen - 2f) * Terrarum.WIDTH
/**
* - 0 on inventory screen
* - +WIDTH on minimap screen
* - -WIDTH on gamemenu screen
*/
private val inventoryScrOffX: Float
get() = (currentScreen - 1f) * Terrarum.WIDTH
private val menuScrOffX: Float
get() = (currentScreen) * Terrarum.WIDTH
private fun renderScreenMinimap(batch: SpriteBatch, camera: Camera) {
// control hints
blendNormal(batch)
batch.color = Color.WHITE
Terrarum.fontGame.draw(batch, minimapControlHelp, offsetX + minimapScrOffX, yEnd - 20)
}
private fun renderScreenGamemenu(batch: SpriteBatch, camera: Camera) {
// control hints
blendNormal(batch)
batch.color = Color.WHITE
Terrarum.fontGame.draw(batch, gameMenuControlHelp, offsetX + menuScrOffX, yEnd - 20)
// text buttons
gameMenuButtons.render(batch, camera)
// character info window
// !! DUMMY !!
batch.color = itemList.backColour
batch.fillRect(
((Terrarum.WIDTH - 400) / 2) + menuScrOffX,
(itemList.height - gameMenuListTotalHeight) / 2 + itemList.posY.toFloat(),
gameMenuListWidth.toFloat(),
64f
)
}
private fun renderScreenInventory(batch: SpriteBatch, camera: Camera) {
itemList.render(batch, camera)
equipped.render(batch, camera)

View File

@@ -32,8 +32,14 @@ class UIItemInventoryDynamicList(
override var posY: Int
) : UIItem(parentUI) {
override val width = 496
override val height = 384
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
override val width = WIDTH
override val height = HEIGHT
val backColour = Color(0x404040_88)
private val catArrangement = parentUI.catArrangement
@@ -94,7 +100,7 @@ class UIItemInventoryDynamicList(
itemImage = null,
mouseoverBackCol = Color(0x282828_ff),
mouseoverBackBlendMode = BlendMode.SCREEN,
backCol = Color(0x404040_88),
backCol = backColour,
backBlendMode = BlendMode.NORMAL,
drawBackOnNull = true,
inactiveTextCol = defaultTextColour
@@ -111,7 +117,7 @@ class UIItemInventoryDynamicList(
itemImage = null,
mouseoverBackCol = Color(0x282828_ff),
mouseoverBackBlendMode = BlendMode.SCREEN,
backCol = Color(0x404040_88),
backCol = backColour,
backBlendMode = BlendMode.NORMAL,
drawBackOnNull = true,
inactiveTextCol = defaultTextColour
@@ -165,9 +171,6 @@ class UIItemInventoryDynamicList(
highlightable = false
)
// deal with the moving position
private var oldPosX = posX
fun scrollItemPage(relativeAmount: Int) {
itemPage = if (itemPageCount == 0) 0 else (itemPage + relativeAmount).fmod(itemPageCount)
}

View File

@@ -63,7 +63,8 @@ class UIItemInventoryEquippedView(
private val spriteDrawCol = Color(0xddddddff.toInt())
// deal with the moving position
private var oldPosX = posX
override var oldPosX = posX
override var oldPosY = posY
override fun render(batch: SpriteBatch, camera: Camera) {
val posXDelta = posX - oldPosX

View File

@@ -18,6 +18,10 @@ class UIItemModuleInfoCell(
override var posY: Int
) : UIItem(parent) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
override val height: Int = Terrarum.fontGame.lineHeight.toInt() * 2
private val numberAreaWidth = Terrarum.fontSmallNumbers.W * 3 + 4

View File

@@ -20,6 +20,10 @@ class UIItemSavegameInfoCell(
override var posY: Int
) : UIItem(parent) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
override val height: Int = Terrarum.fontGame.lineHeight.toInt() * 2
override fun render(batch: SpriteBatch, camera: Camera) {

View File

@@ -44,6 +44,25 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI
abstract val width: Int
abstract val height: Int
/** This variable is NOT updated on its own.
* ```
* val posXDelta = posX - oldPosX
* itemGrid.forEach { it.posX += posXDelta }
* ...
* oldPosX = posX
* ```
*/
protected abstract var oldPosX: Int
/** This variable is NOT updated on its own.
* ```
* val posYDelta = posY - oldPosY
* itemGrid.forEach { it.posY += posYDelta }
* ...
* oldPosY = posY
* ```
*/
protected abstract var oldPosY: Int
/** Position of mouse relative to this item */
protected val relativeMouseX: Int
get() = (Terrarum.mouseScreenX - (parentUI.posX) - this.posX)

View File

@@ -35,6 +35,10 @@ open class UIItemImageButton(
var highlightable: Boolean
) : UIItem(parent) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
var highlighted = false
override fun render(batch: SpriteBatch, camera: Camera) {

View File

@@ -20,6 +20,10 @@ class UIItemImageGallery(
val column: Int = 1
) : UIItem(parentUI) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
override fun update(delta: Float) {
}

View File

@@ -67,6 +67,10 @@ class UIItemIntSlider(
)
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
var value = initValue

View File

@@ -36,6 +36,10 @@ class UIItemList<Item: UIItem>(
val border: Int = 0
) : UIItem(parentUI) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
init {
itemList.forEachIndexed { index, item ->
item.posX = this.posX + border
@@ -47,7 +51,7 @@ class UIItemList<Item: UIItem>(
var selectedIndex: Int? = defaultSelection
val selectedButton: UIItem?
get() = if (selectedIndex != null) itemList[selectedIndex!!] else null
private var highlightY: Double? = if (selectedIndex != null) itemList[selectedIndex!!].posY.toDouble() else null
private var highlightY: Float? = if (selectedIndex != null) itemList[selectedIndex!!].posY.toFloat() else null
private val highlighterMoveDuration: Second = 0.1f
private var highlighterMoveTimer: Second = 0f
private var highlighterMoving = false
@@ -66,8 +70,8 @@ class UIItemList<Item: UIItem>(
highlightY = UIUtils.moveQuick(
highlighterYStart!!,
highlighterYEnd!!,
highlighterMoveTimer.toDouble(),
highlighterMoveDuration.toDouble()
highlighterMoveTimer,
highlighterMoveDuration
)
}
@@ -87,14 +91,14 @@ class UIItemList<Item: UIItem>(
val oldIndex = selectedIndex
if (kinematic) {
highlighterYStart = itemList[selectedIndex!!].posY.toDouble()
highlighterYStart = itemList[selectedIndex!!].posY.toFloat()
selectedIndex = index
highlighterMoving = true
highlighterYEnd = itemList[selectedIndex!!].posY.toDouble()
highlighterYEnd = itemList[selectedIndex!!].posY.toFloat()
}
else {
selectedIndex = index
highlightY = itemList[selectedIndex!!].posY.toDouble()
highlightY = itemList[selectedIndex!!].posY.toFloat()
}
selectionChangeListener?.invoke(oldIndex, index)

View File

@@ -17,6 +17,10 @@ class UIItemTextArea(
val align: Alignment = Alignment.LEFT
) : UIItem(parentUI) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
private var entireText: List<String> = listOf("") // placeholder
var scrollPos = 0

View File

@@ -1,11 +1,14 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import net.torvald.terrarum.*
import net.torvald.terrarum.langpack.Lang
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.GlyphLayout
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.BlendMode
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.fillRect
import net.torvald.terrarum.langpack.Lang
/**
* Text button. Height of hitbox is extended (double lineHeight, or 40 px) for better clicking
@@ -34,6 +37,10 @@ open class UIItemTextButton(
val hitboxSize: Int = UIItemTextButton.height
) : UIItem(parentUI) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
companion object {
val font = Terrarum.fontGame
val height = font.lineHeight.toInt()

View File

@@ -4,8 +4,8 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.BlendMode
import net.torvald.terrarum.fillRect
import net.torvald.terrarum.Second
import net.torvald.terrarum.fillRect
import net.torvald.terrarum.gameactors.ai.toInt
import net.torvald.terrarum.roundInt
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -45,6 +45,10 @@ class UIItemTextButtonList(
val itemHitboxSize: Int = UIItemTextButton.height
) : UIItem(parentUI) {
// deal with the moving position
override var oldPosX = posX
override var oldPosY = posY
val iconToTextGap = 20
val iconCellWidth = (iconSpriteSheet?.tileW ?: -iconToTextGap) / (iconSpriteSheet?.horizontalCount ?: 1)
val iconCellHeight = (iconSpriteSheet?.tileH ?: 0) / (iconSpriteSheet?.verticalCount ?: 1)
@@ -130,7 +134,7 @@ class UIItemTextButtonList(
var selectedIndex: Int? = defaultSelection
val selectedButton: UIItemTextButton?
get() = if (selectedIndex != null) buttons[selectedIndex!!] else null
private var highlightY: Double? = if (selectedIndex != null) buttons[selectedIndex!!].posY.toDouble() else null
private var highlightY: Float? = if (selectedIndex != null) buttons[selectedIndex!!].posY.toFloat() else null
private val highlighterMoveDuration: Second = 0.1f
private var highlighterMoveTimer: Second = 0f
private var highlighterMoving = false
@@ -141,6 +145,10 @@ class UIItemTextButtonList(
var selectionChangeListener: ((Int?, Int) -> Unit)? = null
override fun update(delta: Float) {
val posXDelta = posX - oldPosX
buttons.forEach { it.posX += posXDelta }
if (highlighterMoving) {
highlighterMoveTimer += delta
@@ -148,8 +156,8 @@ class UIItemTextButtonList(
highlightY = UIUtils.moveQuick(
highlighterYStart!!,
highlighterYEnd!!,
highlighterMoveTimer.toDouble(),
highlighterMoveDuration.toDouble()
highlighterMoveTimer.toFloat(),
highlighterMoveDuration.toFloat()
)
}
@@ -170,13 +178,13 @@ class UIItemTextButtonList(
if (kinematic) {
selectedIndex = index
highlighterYStart = buttons[selectedIndex!!].posY.toDouble()
highlighterYStart = buttons[selectedIndex!!].posY.toFloat()
highlighterMoving = true
highlighterYEnd = buttons[selectedIndex!!].posY.toDouble()
highlighterYEnd = buttons[selectedIndex!!].posY.toFloat()
}
else {
selectedIndex = index
highlightY = buttons[selectedIndex!!].posY.toDouble()
highlightY = buttons[selectedIndex!!].posY.toFloat()
}
selectionChangeListener?.invoke(oldIndex, index)
@@ -184,6 +192,8 @@ class UIItemTextButtonList(
btn.highlighted = (index == selectedIndex) // forcibly highlight if this.highlighted != null
}
oldPosX = posX
}
override fun render(batch: SpriteBatch, camera: Camera) {

View File

@@ -6,6 +6,6 @@ import net.torvald.terrarum.sqr
* Created by minjaesong on 2017-03-14.
*/
object UIUtils {
fun moveQuick(start: Double, end: Double, timer: Double, duration: Double) =
fun moveQuick(start: Float, end: Float, timer: Float, duration: Float) =
(start - end) * ((timer / duration) - 1).sqr() + end
}