mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 10:04:05 +09:00
storage chest ui to display its name and player encumbrance meter
This commit is contained in:
@@ -6,6 +6,10 @@ import net.torvald.terrarum.utils.JsonFetcher
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
class LangObject(val key: String, val fromLang: Boolean) {
|
||||||
|
fun get() = if (fromLang) Lang[key] else key
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-22.
|
* Created by minjaesong on 2016-01-22.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.console
|
|||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
|||||||
*/
|
*/
|
||||||
internal object SpawnTikiTorch : ConsoleCommand {
|
internal object SpawnTikiTorch : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
val torch = FixtureTikiTorch()
|
val torch = FixtureTikiTorch { "Tiki Torch" }
|
||||||
torch.setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
torch.setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
||||||
|
|
||||||
Terrarum.ingame!!.addNewActor(torch)
|
Terrarum.ingame!!.addNewActor(torch)
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.Pixmap
|
import com.badlogic.gdx.graphics.Pixmap
|
||||||
|
import net.torvald.EMDASH
|
||||||
|
import net.torvald.terrarum.ccC
|
||||||
|
import net.torvald.terrarum.ccW
|
||||||
import net.torvald.terrarum.gameworld.toUint
|
import net.torvald.terrarum.gameworld.toUint
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
@@ -171,6 +174,6 @@ object DecodeTapestry {
|
|||||||
readCounter++
|
readCounter++
|
||||||
}
|
}
|
||||||
|
|
||||||
return TapestryObject(outImageData, artName, authorName)
|
return TapestryObject(outImageData, artName, authorName) { "$ccW$authorName, $ccC$artName" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ open class FixtureBase(
|
|||||||
blockBox0: BlockBox,
|
blockBox0: BlockBox,
|
||||||
val blockBoxProps: BlockBoxProps = BlockBoxProps(0),
|
val blockBoxProps: BlockBoxProps = BlockBoxProps(0),
|
||||||
renderOrder: RenderOrder = RenderOrder.MIDDLE,
|
renderOrder: RenderOrder = RenderOrder.MIDDLE,
|
||||||
|
val nameFun: () -> String,
|
||||||
val mainUI: UICanvas? = null,
|
val mainUI: UICanvas? = null,
|
||||||
val inventory: FixtureInventory? = null
|
val inventory: FixtureInventory? = null
|
||||||
// disabling physics (not allowing the fixture to move) WILL make things easier in many ways
|
// disabling physics (not allowing the fixture to move) WILL make things easier in many ways
|
||||||
|
|||||||
@@ -8,22 +8,22 @@ import net.torvald.terrarum.*
|
|||||||
import net.torvald.terrarum.AppLoader.printdbg
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.gameitem.GameItem
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory.Companion.CAPACITY_MODE_COUNT
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory.Companion.CAPACITY_MODE_COUNT
|
||||||
import net.torvald.terrarum.modulebasegame.ui.HasInventory
|
import net.torvald.terrarum.modulebasegame.ui.*
|
||||||
import net.torvald.terrarum.modulebasegame.ui.InventoryNegotiator
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryCells.Companion.weightBarWidth
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_HOR
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_HOR
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_VRT
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_VRT
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_X
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_X
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.catBarWidth
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.catBarWidth
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.controlHelpHeight
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.gradEndCol
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.gradEndCol
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.gradHeight
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.gradHeight
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.gradStartCol
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.gradStartCol
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalHeight
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalHeight
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryEquippedView
|
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid
|
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
@@ -31,14 +31,16 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2019-07-08.
|
* Created by minjaesong on 2019-07-08.
|
||||||
*/
|
*/
|
||||||
internal class FixtureStorageChest : FixtureBase(
|
internal class FixtureStorageChest(nameFun: () -> String) : FixtureBase(
|
||||||
BlockBox(BlockBox.ALLOW_MOVE_DOWN, 1, 1),
|
BlockBox(BlockBox.ALLOW_MOVE_DOWN, 1, 1),
|
||||||
inventory = FixtureInventory(40, CAPACITY_MODE_COUNT),
|
inventory = FixtureInventory(40, CAPACITY_MODE_COUNT),
|
||||||
mainUI = UIStorageChest()
|
mainUI = UIStorageChest(),
|
||||||
|
nameFun = nameFun
|
||||||
) {
|
) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(mainUI as UIStorageChest).chest = this.inventory!!
|
(mainUI as UIStorageChest).chestInventory = this.inventory!!
|
||||||
|
(mainUI as UIStorageChest).chestNameFun = this.nameFun
|
||||||
|
|
||||||
setHitboxDimension(16, 16, 0, 0)
|
setHitboxDimension(16, 16, 0, 0)
|
||||||
|
|
||||||
@@ -56,7 +58,8 @@ internal class FixtureStorageChest : FixtureBase(
|
|||||||
|
|
||||||
internal class UIStorageChest : UICanvas(), HasInventory {
|
internal class UIStorageChest : UICanvas(), HasInventory {
|
||||||
|
|
||||||
lateinit var chest: FixtureInventory
|
lateinit var chestInventory: FixtureInventory
|
||||||
|
lateinit var chestNameFun: () -> String
|
||||||
|
|
||||||
override var width = AppLoader.screenW
|
override var width = AppLoader.screenW
|
||||||
override var height = AppLoader.screenH
|
override var height = AppLoader.screenH
|
||||||
@@ -77,13 +80,16 @@ internal class UIStorageChest : UICanvas(), HasInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getNegotiator() = negotiator
|
override fun getNegotiator() = negotiator
|
||||||
override fun getFixtureInventory(): FixtureInventory = chest
|
override fun getFixtureInventory(): FixtureInventory = chestInventory
|
||||||
override fun getPlayerInventory(): FixtureInventory = Terrarum.ingame!!.actorNowPlaying!!.inventory
|
override fun getPlayerInventory(): FixtureInventory = Terrarum.ingame!!.actorNowPlaying!!.inventory
|
||||||
|
|
||||||
private lateinit var catBar: UIItemInventoryCatBar
|
private lateinit var catBar: UIItemInventoryCatBar
|
||||||
private lateinit var itemListChest: UIItemInventoryItemGrid
|
private lateinit var itemListChest: UIItemInventoryItemGrid
|
||||||
private lateinit var itemListPlayer: UIItemInventoryItemGrid
|
private lateinit var itemListPlayer: UIItemInventoryItemGrid
|
||||||
|
|
||||||
|
private var encumbrancePerc = 0f
|
||||||
|
private var isEncumbered = false
|
||||||
|
|
||||||
private var halfSlotOffset = (UIItemInventoryElemSimple.height + listGap) / 2
|
private var halfSlotOffset = (UIItemInventoryElemSimple.height + listGap) / 2
|
||||||
|
|
||||||
private var initialised = false
|
private var initialised = false
|
||||||
@@ -91,6 +97,9 @@ internal class UIStorageChest : UICanvas(), HasInventory {
|
|||||||
private fun itemListUpdate() {
|
private fun itemListUpdate() {
|
||||||
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||||
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||||
|
|
||||||
|
encumbrancePerc = getPlayerInventory().capacity.toFloat() / getPlayerInventory().maxCapacity
|
||||||
|
isEncumbered = getPlayerInventory().isEncumbered
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setCompact(yes: Boolean) {
|
private fun setCompact(yes: Boolean) {
|
||||||
@@ -105,6 +114,8 @@ internal class UIStorageChest : UICanvas(), HasInventory {
|
|||||||
itemListPlayer.gridModeButtons[1].highlighted = yes
|
itemListPlayer.gridModeButtons[1].highlighted = yes
|
||||||
itemListPlayer.itemPage = 0
|
itemListPlayer.itemPage = 0
|
||||||
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||||
|
|
||||||
|
itemListUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateUI(delta: Float) {
|
override fun updateUI(delta: Float) {
|
||||||
@@ -123,7 +134,7 @@ internal class UIStorageChest : UICanvas(), HasInventory {
|
|||||||
itemListChest = UIItemInventoryItemGrid(
|
itemListChest = UIItemInventoryItemGrid(
|
||||||
this,
|
this,
|
||||||
catBar,
|
catBar,
|
||||||
chest,
|
getFixtureInventory(),
|
||||||
INVENTORY_CELLS_OFFSET_X - halfSlotOffset,
|
INVENTORY_CELLS_OFFSET_X - halfSlotOffset,
|
||||||
INVENTORY_CELLS_OFFSET_Y,
|
INVENTORY_CELLS_OFFSET_Y,
|
||||||
6, CELLS_VRT,
|
6, CELLS_VRT,
|
||||||
@@ -132,7 +143,7 @@ internal class UIStorageChest : UICanvas(), HasInventory {
|
|||||||
keyDownFun = { _, _, _ -> Unit },
|
keyDownFun = { _, _, _ -> Unit },
|
||||||
touchDownFun = { gameItem, amount, _ ->
|
touchDownFun = { gameItem, amount, _ ->
|
||||||
if (gameItem != null) {
|
if (gameItem != null) {
|
||||||
negotiator.reject(chest, getPlayerInventory(), gameItem, amount)
|
negotiator.reject(getFixtureInventory(), getPlayerInventory(), gameItem, amount)
|
||||||
}
|
}
|
||||||
itemListUpdate()
|
itemListUpdate()
|
||||||
}
|
}
|
||||||
@@ -149,7 +160,7 @@ internal class UIStorageChest : UICanvas(), HasInventory {
|
|||||||
keyDownFun = { _, _, _ -> Unit },
|
keyDownFun = { _, _, _ -> Unit },
|
||||||
touchDownFun = { gameItem, amount, _ ->
|
touchDownFun = { gameItem, amount, _ ->
|
||||||
if (gameItem != null) {
|
if (gameItem != null) {
|
||||||
negotiator.accept(getPlayerInventory(), chest, gameItem, amount)
|
negotiator.accept(getPlayerInventory(), getFixtureInventory(), gameItem, amount)
|
||||||
}
|
}
|
||||||
itemListUpdate()
|
itemListUpdate()
|
||||||
}
|
}
|
||||||
@@ -195,6 +206,7 @@ internal class UIStorageChest : UICanvas(), HasInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
batch.begin()
|
batch.begin()
|
||||||
|
|
||||||
// UI items
|
// UI items
|
||||||
@@ -203,6 +215,40 @@ internal class UIStorageChest : UICanvas(), HasInventory {
|
|||||||
catBar.render(batch, camera)
|
catBar.render(batch, camera)
|
||||||
itemListChest.render(batch, camera)
|
itemListChest.render(batch, camera)
|
||||||
itemListPlayer.render(batch, camera)
|
itemListPlayer.render(batch, camera)
|
||||||
|
|
||||||
|
|
||||||
|
blendNormal(batch)
|
||||||
|
|
||||||
|
// encumbrance meter
|
||||||
|
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
|
||||||
|
// encumbrance bar will go one row down if control help message is too long
|
||||||
|
val encumbBarXPos = itemListPlayer.posX + itemListPlayer.width - weightBarWidth
|
||||||
|
val encumbBarTextXPos = encumbBarXPos - 6 - AppLoader.fontGame.getWidth(encumbranceText)
|
||||||
|
val encumbBarYPos = UIInventoryCells.encumbBarYPos
|
||||||
|
// encumbrance bar background
|
||||||
|
val encumbCol = UIItemInventoryCellCommonRes.getHealthMeterColour(1f - encumbrancePerc, 0f, 1f)
|
||||||
|
val encumbBack = encumbCol mul UIItemInventoryCellCommonRes.meterBackDarkening
|
||||||
|
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
// encumb text
|
||||||
|
AppLoader.fontGame.draw(batch, encumbranceText, encumbBarTextXPos, encumbBarYPos - 3f)
|
||||||
|
// chest name text
|
||||||
|
AppLoader.fontGame.draw(batch, chestNameFun(), itemListChest.posX + 6f, encumbBarYPos - 3f)
|
||||||
|
batch.color = encumbBack
|
||||||
|
batch.fillRect(
|
||||||
|
encumbBarXPos, encumbBarYPos,
|
||||||
|
weightBarWidth, controlHelpHeight - 6f
|
||||||
|
)
|
||||||
|
// encumbrance bar
|
||||||
|
batch.color = encumbCol
|
||||||
|
batch.fillRect(
|
||||||
|
encumbBarXPos, encumbBarYPos,
|
||||||
|
if (getPlayerInventory().capacityMode == FixtureInventory.CAPACITY_MODE_NO_ENCUMBER)
|
||||||
|
1f
|
||||||
|
else // make sure 1px is always be seen
|
||||||
|
minOf(weightBarWidth, maxOf(1f, weightBarWidth * encumbrancePerc)),
|
||||||
|
controlHelpHeight - 6f
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.*
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-06-17.
|
* Created by minjaesong on 2016-06-17.
|
||||||
*/
|
*/
|
||||||
internal class FixtureTikiTorch : FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1, 2)), Luminous {
|
internal class FixtureTikiTorch(nameFun: () -> String) : FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1, 2), nameFun = nameFun), Luminous {
|
||||||
|
|
||||||
private val rndHash1: Int
|
private val rndHash1: Int
|
||||||
private val rndHash2: Int
|
private val rndHash2: Int
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-01-07.
|
* Created by minjaesong on 2017-01-07.
|
||||||
*/
|
*/
|
||||||
class TapestryObject(pixmap: Pixmap, val artName: String, val artAuthor: String) :
|
class TapestryObject(pixmap: Pixmap, val artName: String, val artAuthor: String, nameFun: () -> String) :
|
||||||
FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1, 1), renderOrder = RenderOrder.BEHIND) // placeholder blockbox
|
FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1, 1), renderOrder = RenderOrder.BEHIND, nameFun = nameFun) // placeholder blockbox
|
||||||
{
|
{
|
||||||
|
|
||||||
// physics = false only speeds up for ~2 frames with 50 tapestries
|
// physics = false only speeds up for ~2 frames with 50 tapestries
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import net.torvald.terrarum.Terrarum
|
|||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.gameitem.GameItem
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.gameitem.ItemID
|
||||||
import net.torvald.terrarum.itemproperties.Material
|
import net.torvald.terrarum.itemproperties.Material
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureStorageChest
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureStorageChest
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ class ItemStorageChest(originalID: ItemID) : GameItem(originalID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun startPrimaryUse(delta: Float): Boolean {
|
override fun startPrimaryUse(delta: Float): Boolean {
|
||||||
val item = FixtureStorageChest()
|
val item = FixtureStorageChest { Lang[originalName] }
|
||||||
|
|
||||||
return item.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - item.blockBox.height + 1)
|
return item.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - item.blockBox.height + 1)
|
||||||
// return true when placed, false when cannot be placed
|
// return true when placed, false when cannot be placed
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import net.torvald.terrarum.Terrarum
|
|||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.gameitem.GameItem
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.gameitem.ItemID
|
||||||
import net.torvald.terrarum.itemproperties.Material
|
import net.torvald.terrarum.itemproperties.Material
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,14 +15,14 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
|||||||
class TikiTorchTester(originalID: ItemID) : GameItem(originalID) {
|
class TikiTorchTester(originalID: ItemID) : GameItem(originalID) {
|
||||||
|
|
||||||
override var dynamicID: ItemID = originalID
|
override var dynamicID: ItemID = originalID
|
||||||
override val originalName = "Tiki Torch"
|
override val originalName = "ITEM_TIKI_TORCH"
|
||||||
override var baseMass = FixtureTikiTorch.MASS
|
override var baseMass = FixtureTikiTorch.MASS
|
||||||
override var stackable = true
|
override var stackable = true
|
||||||
override var inventoryCategory = Category.FIXTURE
|
override var inventoryCategory = Category.FIXTURE
|
||||||
override val isUnique = false
|
override val isUnique = false
|
||||||
override val isDynamic = false
|
override val isDynamic = false
|
||||||
override val material = Material()
|
override val material = Material()
|
||||||
override val itemImage: TextureRegion?
|
override val itemImage: TextureRegion
|
||||||
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_48")
|
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_48")
|
||||||
override var baseToolSize: Double? = baseMass
|
override var baseToolSize: Double? = baseMass
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ class TikiTorchTester(originalID: ItemID) : GameItem(originalID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun startPrimaryUse(delta: Float): Boolean {
|
override fun startPrimaryUse(delta: Float): Boolean {
|
||||||
val item = FixtureTikiTorch()
|
val item = FixtureTikiTorch { Lang[originalName] }
|
||||||
|
|
||||||
return item.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - item.blockBox.height + 1)
|
return item.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - item.blockBox.height + 1)
|
||||||
// return true when placed, false when cannot be placed
|
// return true when placed, false when cannot be placed
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTOR
|
|||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVEN_DEBUG_MODE
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVEN_DEBUG_MODE
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.controlHelpHeight
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericKeyDownFun
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericKeyDownFun
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericTouchDownFun
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericTouchDownFun
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
@@ -26,8 +27,10 @@ internal class UIInventoryCells(
|
|||||||
override var height: Int = AppLoader.screenH
|
override var height: Int = AppLoader.screenH
|
||||||
override var openCloseTime: Second = 0.0f
|
override var openCloseTime: Second = 0.0f
|
||||||
|
|
||||||
|
companion object {
|
||||||
private val weightBarWidth = UIItemInventoryElemSimple.height * 2f + UIItemInventoryItemGrid.listGap
|
val weightBarWidth = UIItemInventoryElemSimple.height * 2f + UIItemInventoryItemGrid.listGap
|
||||||
|
var encumbBarYPos = 0f
|
||||||
|
}
|
||||||
|
|
||||||
internal var encumbrancePerc = 0f
|
internal var encumbrancePerc = 0f
|
||||||
private set
|
private set
|
||||||
@@ -106,6 +109,7 @@ internal class UIInventoryCells(
|
|||||||
if (AppLoader.fontGame.getWidth(full.listControlHelp) + 2 + controlHintXPos >= encumbBarTextXPos)
|
if (AppLoader.fontGame.getWidth(full.listControlHelp) + 2 + controlHintXPos >= encumbBarTextXPos)
|
||||||
AppLoader.fontGame.lineHeight
|
AppLoader.fontGame.lineHeight
|
||||||
else 0f
|
else 0f
|
||||||
|
Companion.encumbBarYPos = encumbBarYPos // q&d hack to share some numbers
|
||||||
|
|
||||||
AppLoader.fontGame.draw(batch,
|
AppLoader.fontGame.draw(batch,
|
||||||
encumbranceText,
|
encumbranceText,
|
||||||
@@ -120,7 +124,7 @@ internal class UIInventoryCells(
|
|||||||
batch.color = encumbBack
|
batch.color = encumbBack
|
||||||
batch.fillRect(
|
batch.fillRect(
|
||||||
encumbBarXPos, encumbBarYPos,
|
encumbBarXPos, encumbBarYPos,
|
||||||
weightBarWidth, full.controlHelpHeight - 6f
|
weightBarWidth, controlHelpHeight - 6f
|
||||||
)
|
)
|
||||||
// encumbrance bar
|
// encumbrance bar
|
||||||
batch.color = encumbCol
|
batch.color = encumbCol
|
||||||
@@ -130,7 +134,7 @@ internal class UIInventoryCells(
|
|||||||
1f
|
1f
|
||||||
else // make sure 1px is always be seen
|
else // make sure 1px is always be seen
|
||||||
minOf(weightBarWidth, maxOf(1f, weightBarWidth * encumbrancePerc)),
|
minOf(weightBarWidth, maxOf(1f, weightBarWidth * encumbrancePerc)),
|
||||||
full.controlHelpHeight - 6f
|
controlHelpHeight - 6f
|
||||||
)
|
)
|
||||||
// debug text
|
// debug text
|
||||||
batch.color = Color.LIGHT_GRAY
|
batch.color = Color.LIGHT_GRAY
|
||||||
@@ -138,7 +142,7 @@ internal class UIInventoryCells(
|
|||||||
AppLoader.fontSmallNumbers.draw(batch,
|
AppLoader.fontSmallNumbers.draw(batch,
|
||||||
"${full.actor.inventory.capacity}/${full.actor.inventory.maxCapacity}",
|
"${full.actor.inventory.capacity}/${full.actor.inventory.maxCapacity}",
|
||||||
encumbBarTextXPos,
|
encumbBarTextXPos,
|
||||||
encumbBarYPos + full.controlHelpHeight - 4f
|
encumbBarYPos + controlHelpHeight - 4f
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ class UIInventoryFull(
|
|||||||
val gradStartCol = Color(0x404040_60)
|
val gradStartCol = Color(0x404040_60)
|
||||||
val gradEndCol = Color(0x000000_70)
|
val gradEndCol = Color(0x000000_70)
|
||||||
val gradHeight = 48f
|
val gradHeight = 48f
|
||||||
|
|
||||||
|
val controlHelpHeight = AppLoader.fontGame.lineHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
//val REQUIRED_MARGIN: Int = 138 // hard-coded value. Don't know the details. Range: [91-146]. I chose MAX-8 because cell gap is 8
|
//val REQUIRED_MARGIN: Int = 138 // hard-coded value. Don't know the details. Range: [91-146]. I chose MAX-8 because cell gap is 8
|
||||||
@@ -108,9 +110,7 @@ class UIInventoryFull(
|
|||||||
else
|
else
|
||||||
"$gamepadLabelStart ${Lang["GAME_ACTION_CLOSE"]}$SP" +
|
"$gamepadLabelStart ${Lang["GAME_ACTION_CLOSE"]}$SP" +
|
||||||
"$gamepadLabelLT ${Lang["GAME_INVENTORY"]}"
|
"$gamepadLabelLT ${Lang["GAME_INVENTORY"]}"
|
||||||
val controlHelpHeight = AppLoader.fontGame.lineHeight
|
|
||||||
|
|
||||||
//val catBarWidth = 330
|
|
||||||
val catBar = UIItemInventoryCatBar(
|
val catBar = UIItemInventoryCatBar(
|
||||||
this,
|
this,
|
||||||
(AppLoader.screenW - catBarWidth) / 2,
|
(AppLoader.screenW - catBarWidth) / 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user