mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
less fancy inventory transition WIP
This commit is contained in:
@@ -15,10 +15,10 @@ import net.torvald.terrarum.ui.UIUtils
|
|||||||
*/
|
*/
|
||||||
class UIItemInventoryCatBar(
|
class UIItemInventoryCatBar(
|
||||||
parentUI: UIInventoryFull,
|
parentUI: UIInventoryFull,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
override val width: Int
|
override val width: Int
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
@@ -59,8 +59,8 @@ class UIItemInventoryCatBar(
|
|||||||
backgroundCol = Color(0),
|
backgroundCol = Color(0),
|
||||||
highlightBackCol = Color(0),
|
highlightBackCol = Color(0),
|
||||||
activeBackBlendMode = BlendMode.NORMAL,
|
activeBackBlendMode = BlendMode.NORMAL,
|
||||||
posX = posX + iconPosX,
|
initialX = posX + iconPosX,
|
||||||
posY = posY + iconPosY,
|
initialY = posY + iconPosY,
|
||||||
highlightable = true
|
highlightable = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -91,8 +91,8 @@ class UIItemInventoryCatBar(
|
|||||||
backgroundCol = Color(0),
|
backgroundCol = Color(0),
|
||||||
highlightBackCol = Color(0),
|
highlightBackCol = Color(0),
|
||||||
activeBackBlendMode = BlendMode.NORMAL,
|
activeBackBlendMode = BlendMode.NORMAL,
|
||||||
posX = iconPosX,
|
initialX = iconPosX,
|
||||||
posY = posY + iconPosY,
|
initialY = posY + iconPosY,
|
||||||
inactiveCol = if (index == 0 || index == 3) Color.WHITE else Color(0xffffff7f.toInt()),
|
inactiveCol = if (index == 0 || index == 3) Color.WHITE else Color(0xffffff7f.toInt()),
|
||||||
activeCol = if (index == 0 || index == 3) Color(0xfff066_ff.toInt()) else Color(0xffffff7f.toInt()),
|
activeCol = if (index == 0 || index == 3) Color(0xfff066_ff.toInt()) else Color(0xffffff7f.toInt()),
|
||||||
highlightable = (index == 0 || index == 3)
|
highlightable = (index == 0 || index == 3)
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import net.torvald.terrarum.ui.UIItemTextButton
|
|||||||
*/
|
*/
|
||||||
class UIItemInventoryElem(
|
class UIItemInventoryElem(
|
||||||
parentUI: UIInventoryFull,
|
parentUI: UIInventoryFull,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
override var item: GameItem?,
|
override var item: GameItem?,
|
||||||
override var amount: Int,
|
override var amount: Int,
|
||||||
@@ -39,7 +39,7 @@ class UIItemInventoryElem(
|
|||||||
override var quickslot: Int? = null,
|
override var quickslot: Int? = null,
|
||||||
override var equippedSlot: Int? = null,
|
override var equippedSlot: Int? = null,
|
||||||
val drawBackOnNull: Boolean = true
|
val drawBackOnNull: Boolean = true
|
||||||
) : UIItemInventoryCellBase(parentUI, posX, posY, item, amount, itemImage, quickslot, equippedSlot) {
|
) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import net.torvald.terrarum.ui.UIItemTextButton
|
|||||||
*/
|
*/
|
||||||
class UIItemInventoryElemSimple(
|
class UIItemInventoryElemSimple(
|
||||||
parentUI: UIInventoryFull,
|
parentUI: UIInventoryFull,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
override var item: GameItem?,
|
override var item: GameItem?,
|
||||||
override var amount: Int,
|
override var amount: Int,
|
||||||
override var itemImage: TextureRegion?,
|
override var itemImage: TextureRegion?,
|
||||||
@@ -37,7 +37,7 @@ class UIItemInventoryElemSimple(
|
|||||||
override var quickslot: Int? = null,
|
override var quickslot: Int? = null,
|
||||||
override var equippedSlot: Int? = null,
|
override var equippedSlot: Int? = null,
|
||||||
val drawBackOnNull: Boolean = true
|
val drawBackOnNull: Boolean = true
|
||||||
) : UIItemInventoryCellBase(parentUI, posX, posY, item, amount, itemImage, quickslot, equippedSlot) {
|
) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
|
|||||||
// initialise with terrain blocks
|
// initialise with terrain blocks
|
||||||
UIItemImageButton(
|
UIItemImageButton(
|
||||||
this, ItemCodex.getItemImage(it),
|
this, ItemCodex.getItemImage(it),
|
||||||
posX = MENUBAR_SIZE + (it % 16) * TILESREGION_SIZE,
|
initialX = MENUBAR_SIZE + (it % 16) * TILESREGION_SIZE,
|
||||||
posY = (it / 16) * TILESREGION_SIZE,
|
initialY = (it / 16) * TILESREGION_SIZE,
|
||||||
highlightable = false,
|
highlightable = false,
|
||||||
width = TILESREGION_SIZE,
|
width = TILESREGION_SIZE,
|
||||||
height = TILESREGION_SIZE,
|
height = TILESREGION_SIZE,
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
|||||||
backgroundCol = Color(0),
|
backgroundCol = Color(0),
|
||||||
highlightBackCol = Color(0),
|
highlightBackCol = Color(0),
|
||||||
activeBackCol = Color(0),
|
activeBackCol = Color(0),
|
||||||
posX = newvec.x.roundInt(),
|
initialX = newvec.x.roundInt(),
|
||||||
posY = newvec.y.roundInt(),
|
initialY = newvec.y.roundInt(),
|
||||||
width = ICON_SIZE, height = ICON_SIZE,
|
width = ICON_SIZE, height = ICON_SIZE,
|
||||||
highlightable = false
|
highlightable = false
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,13 +11,12 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
class UIBuildingMakerToolbox : UICanvas() {
|
class UIBuildingMakerToolbox : UICanvas() {
|
||||||
|
|
||||||
val toolsTexture = TextureRegionPack(ModMgr.getGdxFile("basegame", "gui/building_maker_toolbox.tga"), 16, 16)
|
val toolsTexture = TextureRegionPack(ModMgr.getGdxFile("basegame", "gui/building_maker_toolbox.tga"), 16, 16)
|
||||||
val tools = Array(toolsTexture.verticalCount, { UIItemImageButton(
|
val tools = Array(toolsTexture.verticalCount) { UIItemImageButton(
|
||||||
this, toolsTexture.get(0, it),
|
this, toolsTexture.get(0, it),
|
||||||
posX = 0,
|
initialX = 0,
|
||||||
posY = 20 * it,
|
initialY = 20 * it,
|
||||||
highlightable = true
|
highlightable = true
|
||||||
|
) }
|
||||||
) })
|
|
||||||
|
|
||||||
override var width = 16
|
override var width = 16
|
||||||
override var height = 20 * tools.size - 4
|
override var height = 20 * tools.size - 4
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import net.torvald.terrarum.ui.UIItemTextButtonList
|
|||||||
import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_LINE_HEIGHT
|
import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_LINE_HEIGHT
|
||||||
import net.torvald.terrarum.ui.UIUtils
|
import net.torvald.terrarum.ui.UIUtils
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-10-21.
|
* Created by minjaesong on 2017-10-21.
|
||||||
@@ -36,7 +37,7 @@ class UIInventoryFull(
|
|||||||
doNotWarnConstant: Boolean = false
|
doNotWarnConstant: Boolean = false
|
||||||
) : UICanvas(toggleKeyLiteral, toggleButtonLiteral, customPositioning, doNotWarnConstant) {
|
) : UICanvas(toggleKeyLiteral, toggleButtonLiteral, customPositioning, doNotWarnConstant) {
|
||||||
|
|
||||||
private val debugvals = false
|
private val debugvals = true
|
||||||
|
|
||||||
override var width: Int = AppLoader.screenW
|
override var width: Int = AppLoader.screenW
|
||||||
override var height: Int = AppLoader.screenH
|
override var height: Int = AppLoader.screenH
|
||||||
@@ -145,7 +146,7 @@ class UIInventoryFull(
|
|||||||
private val gameMenuListWidth = 400
|
private val gameMenuListWidth = 400
|
||||||
private val gameMenuButtons = UIItemTextButtonList(
|
private val gameMenuButtons = UIItemTextButtonList(
|
||||||
this, gameMenu,
|
this, gameMenu,
|
||||||
AppLoader.screenW + (AppLoader.screenW - gameMenuListWidth) / 2,
|
(AppLoader.screenW - gameMenuListWidth) / 2,
|
||||||
(itemList.height - gameMenuListHeight) / 2 + itemList.posY,
|
(itemList.height - gameMenuListHeight) / 2 + itemList.posY,
|
||||||
gameMenuListWidth, gameMenuListHeight,
|
gameMenuListWidth, gameMenuListHeight,
|
||||||
readFromLang = true,
|
readFromLang = true,
|
||||||
@@ -157,11 +158,12 @@ class UIInventoryFull(
|
|||||||
defaultSelection = null
|
defaultSelection = null
|
||||||
)
|
)
|
||||||
|
|
||||||
private val SCREEN_MINIMAP = 2f
|
private val SCREEN_MINIMAP = 0f
|
||||||
private val SCREEN_INVENTORY = 1f
|
private val SCREEN_INVENTORY = 1f
|
||||||
private val SCREEN_MENU = 0f
|
private val SCREEN_MENU = 2f
|
||||||
|
|
||||||
private var currentScreen = SCREEN_INVENTORY
|
/** 0..2 where 0 is minimap, 1 is inventory, 2 is menu. Non-integer value means transition is on-going */
|
||||||
|
private var currentScreenTransition = SCREEN_INVENTORY
|
||||||
private var transitionRequested = false
|
private var transitionRequested = false
|
||||||
private var transitionOngoing = false
|
private var transitionOngoing = false
|
||||||
private var transitionReqSource = SCREEN_INVENTORY
|
private var transitionReqSource = SCREEN_INVENTORY
|
||||||
@@ -174,17 +176,6 @@ class UIInventoryFull(
|
|||||||
private val transitionalUpdateUIoriginalPosX = ArrayList<Int>()
|
private val transitionalUpdateUIoriginalPosX = ArrayList<Int>()
|
||||||
|
|
||||||
|
|
||||||
private fun addToTransitionalGroup(item: UIItem) {
|
|
||||||
transitionalUpdateUIs.add(item)
|
|
||||||
transitionalUpdateUIoriginalPosX.add(item.posX)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateTransitionalItems() {
|
|
||||||
for (k in 0..transitionalUpdateUIs.lastIndex) {
|
|
||||||
val intOff = inventoryScrOffX.roundInt()
|
|
||||||
transitionalUpdateUIs[k].posX = transitionalUpdateUIoriginalPosX[k] + intOff
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
addItem(categoryBar)
|
addItem(categoryBar)
|
||||||
@@ -201,11 +192,6 @@ class UIInventoryFull(
|
|||||||
|
|
||||||
rebuildList()
|
rebuildList()
|
||||||
|
|
||||||
|
|
||||||
addToTransitionalGroup(itemList)
|
|
||||||
addToTransitionalGroup(equipped)
|
|
||||||
addToTransitionalGroup(gameMenuButtons)
|
|
||||||
|
|
||||||
// make gameMenuButtons work
|
// make gameMenuButtons work
|
||||||
gameMenuButtons.selectionChangeListener = { old, new ->
|
gameMenuButtons.selectionChangeListener = { old, new ->
|
||||||
if (new == 0) {
|
if (new == 0) {
|
||||||
@@ -233,11 +219,23 @@ class UIInventoryFull(
|
|||||||
|
|
||||||
transitionalUpdateUIs.forEach { it.update(delta) }
|
transitionalUpdateUIs.forEach { it.update(delta) }
|
||||||
|
|
||||||
if (currentScreen > 1f + epsilon) {
|
// update map while visible
|
||||||
|
if (currentScreenTransition > 1f + epsilon) {
|
||||||
MinimapComposer.setWorld(Terrarum.ingame!!.world)
|
MinimapComposer.setWorld(Terrarum.ingame!!.world)
|
||||||
MinimapComposer.update()
|
MinimapComposer.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update inventory while visible
|
||||||
|
if (currentScreenTransition in epsilon..2f - epsilon) {
|
||||||
|
itemList.update(delta)
|
||||||
|
equipped.update(delta)
|
||||||
|
}
|
||||||
|
|
||||||
|
// update menu while visible
|
||||||
|
if (currentScreenTransition < 1f - epsilon) {
|
||||||
|
gameMenuButtons.update(delta)
|
||||||
|
}
|
||||||
|
|
||||||
minimapRerenderTimer += Gdx.graphics.rawDeltaTime
|
minimapRerenderTimer += Gdx.graphics.rawDeltaTime
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +255,7 @@ class UIInventoryFull(
|
|||||||
fun requestTransition(target: Int) {
|
fun requestTransition(target: Int) {
|
||||||
if (!transitionOngoing) {
|
if (!transitionOngoing) {
|
||||||
transitionRequested = true
|
transitionRequested = true
|
||||||
transitionReqSource = currentScreen.round()
|
transitionReqSource = currentScreenTransition.round()
|
||||||
transitionReqTarget = target.toFloat()
|
transitionReqTarget = target.toFloat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,21 +271,20 @@ class UIInventoryFull(
|
|||||||
if (transitionOngoing) {
|
if (transitionOngoing) {
|
||||||
transitionTimer += Gdx.graphics.rawDeltaTime
|
transitionTimer += Gdx.graphics.rawDeltaTime
|
||||||
|
|
||||||
currentScreen = UIUtils.moveQuick(transitionReqSource, transitionReqTarget, transitionTimer, transitionLength)
|
currentScreenTransition = UIUtils.moveLinear(transitionReqSource, transitionReqTarget, transitionTimer, transitionLength)
|
||||||
|
|
||||||
if (transitionTimer > transitionLength) {
|
if (transitionTimer > transitionLength) {
|
||||||
transitionOngoing = false
|
transitionOngoing = false
|
||||||
currentScreen = transitionReqTarget
|
currentScreenTransition = transitionReqTarget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// update at render time
|
// update at render time
|
||||||
updateTransitionalItems()
|
|
||||||
if (debugvals) {
|
if (debugvals) {
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
AppLoader.fontSmallNumbers.draw(batch, "screen:$currentScreen", 500f, 20f)
|
AppLoader.fontSmallNumbers.draw(batch, "screen:$currentScreenTransition", 500f, 30f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -316,8 +313,8 @@ class UIInventoryFull(
|
|||||||
// UI items
|
// UI items
|
||||||
categoryBar.render(batch, camera)
|
categoryBar.render(batch, camera)
|
||||||
|
|
||||||
|
// render map while visible
|
||||||
if (currentScreen > 1f + epsilon) {
|
if (currentScreenTransition > 1f + epsilon) {
|
||||||
renderScreenMinimap(batch, camera)
|
renderScreenMinimap(batch, camera)
|
||||||
|
|
||||||
if (debugvals) {
|
if (debugvals) {
|
||||||
@@ -326,7 +323,8 @@ class UIInventoryFull(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentScreen in epsilon..2f - epsilon) {
|
// render inventory while visible
|
||||||
|
if (currentScreenTransition in epsilon..2f - epsilon) {
|
||||||
renderScreenInventory(batch, camera)
|
renderScreenInventory(batch, camera)
|
||||||
|
|
||||||
if (debugvals) {
|
if (debugvals) {
|
||||||
@@ -335,7 +333,8 @@ class UIInventoryFull(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentScreen < 1f - epsilon) {
|
// render menu while visible
|
||||||
|
if (currentScreenTransition < 1f - epsilon) {
|
||||||
renderScreenGamemenu(batch, camera)
|
renderScreenGamemenu(batch, camera)
|
||||||
|
|
||||||
if (debugvals) {
|
if (debugvals) {
|
||||||
@@ -346,7 +345,9 @@ class UIInventoryFull(
|
|||||||
|
|
||||||
if (debugvals) {
|
if (debugvals) {
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
AppLoader.fontSmallNumbers.draw(batch, "inventoryScrOffX:$inventoryScrOffX", 500f, 10f)
|
AppLoader.fontSmallNumbers.draw(batch, "minimap:$minimapScrOffX", 500f, 0f)
|
||||||
|
AppLoader.fontSmallNumbers.draw(batch, "inven:$inventoryScrOffX", 500f, 10f)
|
||||||
|
AppLoader.fontSmallNumbers.draw(batch, "menu:$menuScrOffX", 500f, 20f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -354,17 +355,24 @@ class UIInventoryFull(
|
|||||||
|
|
||||||
private val epsilon = 0.001f
|
private val epsilon = 0.001f
|
||||||
|
|
||||||
private val minimapScrOffX: Float
|
|
||||||
get() = (currentScreen - 2f) * AppLoader.screenW
|
|
||||||
/**
|
/**
|
||||||
* - 0 on inventory screen
|
* - 0 on inventory screen
|
||||||
* - +WIDTH on minimap screen
|
* - +WIDTH on minimap screen
|
||||||
* - -WIDTH on gamemenu screen
|
* - -WIDTH on gamemenu screen
|
||||||
*/
|
*/
|
||||||
|
private val minimapScrOffX: Float
|
||||||
|
get() = (currentScreenTransition - 2f) * AppLoader.screenW / 2f
|
||||||
private val inventoryScrOffX: Float
|
private val inventoryScrOffX: Float
|
||||||
get() = (currentScreen - 1f) * AppLoader.screenW
|
get() = (currentScreenTransition - 1f) * AppLoader.screenW / 2f
|
||||||
private val menuScrOffX: Float
|
private val menuScrOffX: Float
|
||||||
get() = (currentScreen) * AppLoader.screenW
|
get() = (currentScreenTransition - 0f) * AppLoader.screenW / 2f
|
||||||
|
|
||||||
|
private val minimapScrOpacity: Float
|
||||||
|
get() = (currentScreenTransition - 2f).coerceIn(0f, 1f)
|
||||||
|
private val inventoryScrOpacity: Float
|
||||||
|
get() = (currentScreenTransition - 1f).coerceIn(0f, 1f)
|
||||||
|
private val menuScrOpacity: Float
|
||||||
|
get() = (currentScreenTransition - 0f).coerceIn(0f, 1f)
|
||||||
|
|
||||||
private val MINIMAP_WIDTH = 800f
|
private val MINIMAP_WIDTH = 800f
|
||||||
private val MINIMAP_HEIGHT = itemList.height.toFloat()
|
private val MINIMAP_HEIGHT = itemList.height.toFloat()
|
||||||
@@ -377,11 +385,15 @@ class UIInventoryFull(
|
|||||||
private val minimapFBO = FrameBuffer(Pixmap.Format.RGBA8888, MINIMAP_WIDTH.toInt(), MINIMAP_HEIGHT.toInt(), false)
|
private val minimapFBO = FrameBuffer(Pixmap.Format.RGBA8888, MINIMAP_WIDTH.toInt(), MINIMAP_HEIGHT.toInt(), false)
|
||||||
private val minimapCamera = OrthographicCamera(MINIMAP_WIDTH, MINIMAP_HEIGHT)
|
private val minimapCamera = OrthographicCamera(MINIMAP_WIDTH, MINIMAP_HEIGHT)
|
||||||
|
|
||||||
|
|
||||||
|
// TODO put 3 bare sub-UIs into proper UIcanvas to handle the motherfucking opacity
|
||||||
|
|
||||||
|
|
||||||
private fun renderScreenMinimap(batch: SpriteBatch, camera: Camera) {
|
private fun renderScreenMinimap(batch: SpriteBatch, camera: Camera) {
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
|
|
||||||
// update map panning
|
// update map panning
|
||||||
if (currentScreen >= 2f - epsilon) {
|
if (currentScreenTransition >= 2f - epsilon) {
|
||||||
// if left click is down and cursor is in the map area
|
// if left click is down and cursor is in the map area
|
||||||
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary")) &&
|
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary")) &&
|
||||||
Terrarum.mouseScreenY in itemList.posY..itemList.posY + itemList.height) {
|
Terrarum.mouseScreenY in itemList.posY..itemList.posY + itemList.height) {
|
||||||
@@ -455,9 +467,9 @@ class UIInventoryFull(
|
|||||||
}
|
}
|
||||||
batch.begin()
|
batch.begin()
|
||||||
|
|
||||||
|
if (debugvals) {
|
||||||
AppLoader.fontSmallNumbers.draw(batch, "$minimapPanX, $minimapPanY; x$minimapZoom", minimapScrOffX + (AppLoader.screenW - MINIMAP_WIDTH) / 2, -10f + itemList.posY)
|
AppLoader.fontSmallNumbers.draw(batch, "$minimapPanX, $minimapPanY; x$minimapZoom", minimapScrOffX + (AppLoader.screenW - MINIMAP_WIDTH) / 2, -10f + itemList.posY)
|
||||||
|
}
|
||||||
|
|
||||||
batch.projectionMatrix = camera.combined
|
batch.projectionMatrix = camera.combined
|
||||||
// 1px stroke
|
// 1px stroke
|
||||||
@@ -479,11 +491,14 @@ class UIInventoryFull(
|
|||||||
AppLoader.fontGame.draw(batch, gameMenuControlHelp, offsetX + menuScrOffX, yEnd - 20)
|
AppLoader.fontGame.draw(batch, gameMenuControlHelp, offsetX + menuScrOffX, yEnd - 20)
|
||||||
|
|
||||||
// text buttons
|
// text buttons
|
||||||
|
gameMenuButtons.posX = gameMenuButtons.initialX + menuScrOffX.roundToInt()
|
||||||
gameMenuButtons.render(batch, camera)
|
gameMenuButtons.render(batch, camera)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderScreenInventory(batch: SpriteBatch, camera: Camera) {
|
private fun renderScreenInventory(batch: SpriteBatch, camera: Camera) {
|
||||||
|
itemList.posX = itemList.initialX + inventoryScrOffX.roundToInt()
|
||||||
itemList.render(batch, camera)
|
itemList.render(batch, camera)
|
||||||
|
equipped.posX = equipped.initialX + inventoryScrOffX.roundToInt()
|
||||||
equipped.render(batch, camera)
|
equipped.render(batch, camera)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ import kotlin.math.roundToInt
|
|||||||
*/
|
*/
|
||||||
abstract class UIItemInventoryCellBase(
|
abstract class UIItemInventoryCellBase(
|
||||||
parentUI: UIInventoryFull,
|
parentUI: UIInventoryFull,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
open var item: GameItem?,
|
open var item: GameItem?,
|
||||||
open var amount: Int,
|
open var amount: Int,
|
||||||
open var itemImage: TextureRegion?,
|
open var itemImage: TextureRegion?,
|
||||||
open var quickslot: Int? = null,
|
open var quickslot: Int? = null,
|
||||||
open var equippedSlot: Int? = null
|
open var equippedSlot: Int? = null
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
abstract override fun update(delta: Float)
|
abstract override fun update(delta: Float)
|
||||||
abstract override fun render(batch: SpriteBatch, camera: Camera)
|
abstract override fun render(batch: SpriteBatch, camera: Camera)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,13 +31,13 @@ import java.util.*
|
|||||||
class UIItemInventoryDynamicList(
|
class UIItemInventoryDynamicList(
|
||||||
parentUI: UIInventoryFull,
|
parentUI: UIInventoryFull,
|
||||||
val inventory: ActorInventory, // when you're going to display List of Craftables, you could implement a Delegator...? Or just build a virtual inventory
|
val inventory: ActorInventory, // when you're going to display List of Craftables, you could implement a Delegator...? Or just build a virtual inventory
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
val horizontalCells: Int,
|
val horizontalCells: Int,
|
||||||
val verticalCells: Int,
|
val verticalCells: Int,
|
||||||
val drawScrollOnRightside: Boolean = false,
|
val drawScrollOnRightside: Boolean = false,
|
||||||
val drawWallet: Boolean = true
|
val drawWallet: Boolean = true
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
@@ -115,8 +115,8 @@ class UIItemInventoryDynamicList(
|
|||||||
private val itemGrid = Array<UIItemInventoryCellBase>(horizontalCells * verticalCells) {
|
private val itemGrid = Array<UIItemInventoryCellBase>(horizontalCells * verticalCells) {
|
||||||
UIItemInventoryElemSimple(
|
UIItemInventoryElemSimple(
|
||||||
parentUI = inventoryUI,
|
parentUI = inventoryUI,
|
||||||
posX = this.posX + (UIItemInventoryElemSimple.height + listGap) * (it % horizontalCells),
|
initialX = this.posX + (UIItemInventoryElemSimple.height + listGap) * (it % horizontalCells),
|
||||||
posY = this.posY + (UIItemInventoryElemSimple.height + listGap) * (it / horizontalCells),
|
initialY = this.posY + (UIItemInventoryElemSimple.height + listGap) * (it / horizontalCells),
|
||||||
item = null,
|
item = null,
|
||||||
amount = UIItemInventoryElem.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
amount = UIItemInventoryElem.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
||||||
itemImage = null,
|
itemImage = null,
|
||||||
@@ -132,8 +132,8 @@ class UIItemInventoryDynamicList(
|
|||||||
private val itemList = Array<UIItemInventoryCellBase>(verticalCells * 2) {
|
private val itemList = Array<UIItemInventoryCellBase>(verticalCells * 2) {
|
||||||
UIItemInventoryElem(
|
UIItemInventoryElem(
|
||||||
parentUI = inventoryUI,
|
parentUI = inventoryUI,
|
||||||
posX = this.posX + (largeListWidth + listGap) * (it % 2),
|
initialX = this.posX + (largeListWidth + listGap) * (it % 2),
|
||||||
posY = this.posY + (UIItemInventoryElem.height + listGap) * (it / 2),
|
initialY = this.posY + (UIItemInventoryElem.height + listGap) * (it / 2),
|
||||||
width = largeListWidth,
|
width = largeListWidth,
|
||||||
item = null,
|
item = null,
|
||||||
amount = UIItemInventoryElem.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
amount = UIItemInventoryElem.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
||||||
@@ -174,8 +174,8 @@ class UIItemInventoryDynamicList(
|
|||||||
highlightBackCol = Color(0),
|
highlightBackCol = Color(0),
|
||||||
activeBackBlendMode = BlendMode.NORMAL,
|
activeBackBlendMode = BlendMode.NORMAL,
|
||||||
activeCol = defaultActiveCol,
|
activeCol = defaultActiveCol,
|
||||||
posX = iconPosX,
|
initialX = iconPosX,
|
||||||
posY = getIconPosY(index),
|
initialY = getIconPosY(index),
|
||||||
highlightable = true
|
highlightable = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -187,8 +187,8 @@ class UIItemInventoryDynamicList(
|
|||||||
activeBackCol = Color(0),
|
activeBackCol = Color(0),
|
||||||
activeBackBlendMode = BlendMode.NORMAL,
|
activeBackBlendMode = BlendMode.NORMAL,
|
||||||
activeCol = defaultActiveCol,
|
activeCol = defaultActiveCol,
|
||||||
posX = iconPosX,
|
initialX = iconPosX,
|
||||||
posY = getIconPosY(2),
|
initialY = getIconPosY(2),
|
||||||
highlightable = false
|
highlightable = false
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -199,8 +199,8 @@ class UIItemInventoryDynamicList(
|
|||||||
activeBackCol = Color(0),
|
activeBackCol = Color(0),
|
||||||
activeBackBlendMode = BlendMode.NORMAL,
|
activeBackBlendMode = BlendMode.NORMAL,
|
||||||
activeCol = defaultActiveCol,
|
activeCol = defaultActiveCol,
|
||||||
posX = iconPosX,
|
initialX = iconPosX,
|
||||||
posY = getIconPosY(3),
|
initialY = getIconPosY(3),
|
||||||
highlightable = false
|
highlightable = false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ class UIItemInventoryEquippedView(
|
|||||||
parentUI: UIInventoryFull,
|
parentUI: UIInventoryFull,
|
||||||
val inventory: ActorInventory,
|
val inventory: ActorInventory,
|
||||||
val theActor: ActorWithBody,
|
val theActor: ActorWithBody,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int
|
initialY: Int
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
|
|
||||||
override val width = WIDTH
|
override val width = WIDTH
|
||||||
@@ -53,8 +53,8 @@ class UIItemInventoryEquippedView(
|
|||||||
private val itemGrid = Array<UIItemInventoryCellBase>(2 * 6) {
|
private val itemGrid = Array<UIItemInventoryCellBase>(2 * 6) {
|
||||||
UIItemInventoryElemSimple(
|
UIItemInventoryElemSimple(
|
||||||
parentUI = parentUI,
|
parentUI = parentUI,
|
||||||
posX = this.posX + (UIItemInventoryElemSimple.height + listGap) * ((it + 4) % 2),
|
initialX = this.posX + (UIItemInventoryElemSimple.height + listGap) * ((it + 4) % 2),
|
||||||
posY = this.posY + (UIItemInventoryElemSimple.height + listGap) * ((it + 4) / 2),
|
initialY = this.posY + (UIItemInventoryElemSimple.height + listGap) * ((it + 4) / 2),
|
||||||
item = null,
|
item = null,
|
||||||
amount = UIItemInventoryElem.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
amount = UIItemInventoryElem.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
||||||
itemImage = null,
|
itemImage = null,
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ class UIItemPlayerInfoCell(
|
|||||||
parent: UICanvas,
|
parent: UICanvas,
|
||||||
val saveInfo: ReadWorldInfo.SaveMetaData,
|
val saveInfo: ReadWorldInfo.SaveMetaData,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
var highlightable: Boolean,
|
var highlightable: Boolean,
|
||||||
var ingamePlayer: IngamePlayer? = null
|
var ingamePlayer: IngamePlayer? = null
|
||||||
) : UIItem(parent) {
|
) : UIItem(parent, initialX, initialY) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ class UIItemSavegameInfoCell(
|
|||||||
parent: UICanvas,
|
parent: UICanvas,
|
||||||
savefile: File,
|
savefile: File,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int
|
initialY: Int
|
||||||
) : UIItem(parent) {
|
) : UIItem(parent, initialX, initialY) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
|
|||||||
@@ -45,13 +45,16 @@ import net.torvald.terrarum.Terrarum
|
|||||||
* As mentioned in [UICanvas], UIItems must be added to the Canvas to make listeners work without implementing
|
* As mentioned in [UICanvas], UIItems must be added to the Canvas to make listeners work without implementing
|
||||||
* everything by yourself.
|
* everything by yourself.
|
||||||
*
|
*
|
||||||
|
* @param initialX initial position of the item. Useful for making transition that requires the item to be moved
|
||||||
|
* @param initialY initial position of the item. Useful for making transition that requires the item to be moved
|
||||||
|
*
|
||||||
* Created by minjaesong on 2015-12-31.
|
* Created by minjaesong on 2015-12-31.
|
||||||
*/
|
*/
|
||||||
abstract class UIItem(var parentUI: UICanvas): Disposable { // do not replace parentUI to UIHandler!
|
abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: Int): Disposable { // do not replace parentUI to UIHandler!
|
||||||
|
|
||||||
// X/Y Position relative to the containing canvas
|
// X/Y Position relative to the containing canvas
|
||||||
abstract var posX: Int
|
var posX: Int = initialX
|
||||||
abstract var posY: Int
|
var posY: Int = initialY
|
||||||
abstract val width: Int
|
abstract val width: Int
|
||||||
abstract val height: Int
|
abstract val height: Int
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
*/
|
*/
|
||||||
class UIItemConfigKeycap(
|
class UIItemConfigKeycap(
|
||||||
parent: UICanvas,
|
parent: UICanvas,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
|
|
||||||
private val keySize: Int,
|
private val keySize: Int,
|
||||||
|
|
||||||
private val keycode: Int, // also used to draw key label
|
private val keycode: Int, // also used to draw key label
|
||||||
private var keyItem: Int? = null // internal index for the key's behaviour, also used to choose appropriate icon
|
private var keyItem: Int? = null // internal index for the key's behaviour, also used to choose appropriate icon
|
||||||
) : UIItem(parent) {
|
) : UIItem(parent, initialX, initialY) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (keySize < 3) throw IllegalArgumentException("Key size must be greater than 2 (got $keySize)")
|
if (keySize < 3) throw IllegalArgumentException("Key size must be greater than 2 (got $keySize)")
|
||||||
|
|||||||
@@ -32,14 +32,14 @@ open class UIItemImageButton(
|
|||||||
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
|
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
|
||||||
val backgroundBlendMode: String = BlendMode.NORMAL,
|
val backgroundBlendMode: String = BlendMode.NORMAL,
|
||||||
|
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
override val width: Int = image.regionWidth,
|
override val width: Int = image.regionWidth,
|
||||||
override val height: Int = image.regionHeight,
|
override val height: Int = image.regionHeight,
|
||||||
|
|
||||||
/** When clicked, toggle its "lit" status */
|
/** When clicked, toggle its "lit" status */
|
||||||
var highlightable: Boolean
|
var highlightable: Boolean
|
||||||
) : UIItem(parent) {
|
) : UIItem(parent, initialX, initialY) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import java.util.*
|
|||||||
*/
|
*/
|
||||||
class UIItemImageGallery(
|
class UIItemImageGallery(
|
||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
override val height: Int,
|
override val height: Int,
|
||||||
val imageList: ArrayList<Texture>,
|
val imageList: ArrayList<Texture>,
|
||||||
val column: Int = 1
|
val column: Int = 1
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
|
|||||||
@@ -13,8 +13,12 @@ import java.awt.Color
|
|||||||
class UIItemIntSlider(
|
class UIItemIntSlider(
|
||||||
parent: UICanvas,
|
parent: UICanvas,
|
||||||
initValue: Int,
|
initValue: Int,
|
||||||
|
initialX: Int,
|
||||||
|
initialY: Int,
|
||||||
|
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
override val height: Int,
|
override val height: Int,
|
||||||
|
|
||||||
val minValue: Int,
|
val minValue: Int,
|
||||||
val maxValue: Int,
|
val maxValue: Int,
|
||||||
val step: Int,
|
val step: Int,
|
||||||
@@ -38,11 +42,13 @@ class UIItemIntSlider(
|
|||||||
|
|
||||||
val sliderUseColourMap: GdxColorMap? = null,
|
val sliderUseColourMap: GdxColorMap? = null,
|
||||||
val sliderUseTexture: Texture? = null
|
val sliderUseTexture: Texture? = null
|
||||||
) : UIItem(parent) {
|
) : UIItem(parent, initialX, initialY) {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
parent: UICanvas,
|
parent: UICanvas,
|
||||||
initValue: Int,
|
initValue: Int,
|
||||||
|
initialX: Int,
|
||||||
|
initialY: Int,
|
||||||
values: IntRange,
|
values: IntRange,
|
||||||
width: Int,
|
width: Int,
|
||||||
height: Int,
|
height: Int,
|
||||||
@@ -60,6 +66,8 @@ class UIItemIntSlider(
|
|||||||
) : this(
|
) : this(
|
||||||
parent,
|
parent,
|
||||||
initValue,
|
initValue,
|
||||||
|
initialX,
|
||||||
|
initialY,
|
||||||
values.first,
|
values.first,
|
||||||
values.last,
|
values.last,
|
||||||
values.step,
|
values.step,
|
||||||
@@ -84,12 +92,6 @@ class UIItemIntSlider(
|
|||||||
// TODO unimplemented
|
// TODO unimplemented
|
||||||
|
|
||||||
|
|
||||||
override var posX: Int
|
|
||||||
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
|
||||||
set(value) {}
|
|
||||||
override var posY: Int
|
|
||||||
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
|
||||||
set(value) {}
|
|
||||||
override val mouseUp: Boolean
|
override val mouseUp: Boolean
|
||||||
get() = super.mouseUp
|
get() = super.mouseUp
|
||||||
override val mousePushed: Boolean
|
override val mousePushed: Boolean
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import net.torvald.terrarum.fillRect
|
|||||||
class UIItemList<Item: UIItem>(
|
class UIItemList<Item: UIItem>(
|
||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
val itemList: ArrayList<Item>,
|
val itemList: ArrayList<Item>,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
override val height: Int,
|
override val height: Int,
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ class UIItemList<Item: UIItem>(
|
|||||||
val backgroundBlendMode: String = BlendMode.NORMAL,
|
val backgroundBlendMode: String = BlendMode.NORMAL,
|
||||||
val kinematic: Boolean = false,
|
val kinematic: Boolean = false,
|
||||||
val border: Int = 0
|
val border: Int = 0
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ class UIItemModuleInfoCell(
|
|||||||
parent: UICanvas,
|
parent: UICanvas,
|
||||||
var moduleName: String,
|
var moduleName: String,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int
|
initialY: Int
|
||||||
) : UIItem(parent) {
|
) : UIItem(parent, initialX, initialY) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ import net.torvald.terrarum.ui.UIItemTextButton.Companion.Alignment
|
|||||||
|
|
||||||
class UIItemTextArea(
|
class UIItemTextArea(
|
||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
override val height: Int,
|
override val height: Int,
|
||||||
val lineGap: Int = 0,
|
val lineGap: Int = 0,
|
||||||
val lineCount: Int = ((height + lineGap) / AppLoader.fontGame.lineHeight).toInt(),
|
val lineCount: Int = ((height + lineGap) / AppLoader.fontGame.lineHeight).toInt(),
|
||||||
val align: Alignment = Alignment.LEFT
|
val align: Alignment = Alignment.LEFT
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ open class UIItemTextButton(
|
|||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
/** Stored text (independent to the Langpack) */
|
/** Stored text (independent to the Langpack) */
|
||||||
val labelText: String,
|
val labelText: String,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
val readFromLang: Boolean = false,
|
val readFromLang: Boolean = false,
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ open class UIItemTextButton(
|
|||||||
|
|
||||||
val alignment: Alignment = Alignment.CENTRE,
|
val alignment: Alignment = Alignment.CENTRE,
|
||||||
val hitboxSize: Int = UIItemTextButton.height
|
val hitboxSize: Int = UIItemTextButton.height
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
class UIItemTextButtonList(
|
class UIItemTextButtonList(
|
||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
labelsList: Array<String>,
|
labelsList: Array<String>,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
override var width: Int,
|
override var width: Int,
|
||||||
override var height: Int = DEFAULT_LINE_HEIGHT * labelsList.size,
|
override var height: Int = DEFAULT_LINE_HEIGHT * labelsList.size,
|
||||||
val readFromLang: Boolean = false,
|
val readFromLang: Boolean = false,
|
||||||
@@ -48,7 +48,7 @@ class UIItemTextButtonList(
|
|||||||
|
|
||||||
val alignment: UIItemTextButton.Companion.Alignment = UIItemTextButton.Companion.Alignment.CENTRE,
|
val alignment: UIItemTextButton.Companion.Alignment = UIItemTextButton.Companion.Alignment.CENTRE,
|
||||||
val itemHitboxSize: Int = DEFAULT_LINE_HEIGHT
|
val itemHitboxSize: Int = DEFAULT_LINE_HEIGHT
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val DEFAULT_BACKGROUNDCOL = Color(0x242424_80)
|
val DEFAULT_BACKGROUNDCOL = Color(0x242424_80)
|
||||||
@@ -83,8 +83,8 @@ class UIItemTextButtonList(
|
|||||||
if (!kinematic) {
|
if (!kinematic) {
|
||||||
UIItemTextButton(
|
UIItemTextButton(
|
||||||
parentUI, s,
|
parentUI, s,
|
||||||
posX = posX,
|
initialX = posX,
|
||||||
posY = posY + vertOff,
|
initialY = posY + vertOff,
|
||||||
width = width,
|
width = width,
|
||||||
readFromLang = readFromLang,
|
readFromLang = readFromLang,
|
||||||
activeCol = activeCol,
|
activeCol = activeCol,
|
||||||
@@ -105,8 +105,8 @@ class UIItemTextButtonList(
|
|||||||
else {
|
else {
|
||||||
UIItemTextButton(
|
UIItemTextButton(
|
||||||
parentUI, s,
|
parentUI, s,
|
||||||
posX = posX,
|
initialX = posX,
|
||||||
posY = posY + vertOff,
|
initialY = posY + vertOff,
|
||||||
width = width,
|
width = width,
|
||||||
readFromLang = readFromLang,
|
readFromLang = readFromLang,
|
||||||
activeCol = activeCol,
|
activeCol = activeCol,
|
||||||
@@ -126,7 +126,7 @@ class UIItemTextButtonList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*override var posX = 0
|
/*initialX = 0
|
||||||
set(value) {
|
set(value) {
|
||||||
buttons.forEach {
|
buttons.forEach {
|
||||||
val oldPosX = field
|
val oldPosX = field
|
||||||
@@ -135,7 +135,7 @@ class UIItemTextButtonList(
|
|||||||
}
|
}
|
||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
override var posY = 0
|
initialY = 0
|
||||||
set(value) {
|
set(value) {
|
||||||
buttons.forEach {
|
buttons.forEach {
|
||||||
val oldPosY = field
|
val oldPosY = field
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ import kotlin.math.roundToInt
|
|||||||
*/
|
*/
|
||||||
class UIItemToggleButton(
|
class UIItemToggleButton(
|
||||||
parent: UICanvas,
|
parent: UICanvas,
|
||||||
override var posX: Int,
|
initialX: Int,
|
||||||
override var posY: Int,
|
initialY: Int,
|
||||||
private var status: Boolean = false
|
private var status: Boolean = false
|
||||||
) : UIItem(parent) {
|
) : UIItem(parent, initialX, initialY) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
CommonResourcePool.addToLoadingList("ui_item_toggler_base") {
|
CommonResourcePool.addToLoadingList("ui_item_toggler_base") {
|
||||||
|
|||||||
@@ -8,4 +8,6 @@ import net.torvald.terrarum.sqr
|
|||||||
object UIUtils {
|
object UIUtils {
|
||||||
fun moveQuick(start: Float, end: Float, timer: Float, duration: Float) =
|
fun moveQuick(start: Float, end: Float, timer: Float, duration: Float) =
|
||||||
(start - end) * ((timer / duration) - 1).sqr() + end
|
(start - end) * ((timer / duration) - 1).sqr() + end
|
||||||
|
fun moveLinear(start: Float, end: Float, timer: Float, duration: Float) =
|
||||||
|
(start - end) * (1 - (timer / duration)) + end
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user