mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
fixed a bug where a dynamic item would not get saved/loaded at all
This commit is contained in:
@@ -19,7 +19,7 @@ object AmmoMeterProxy {
|
||||
else {
|
||||
meter.vitalGetterVal = {
|
||||
if (currentItem.stackable && currentItem.maxDurability == GameItem.DURABILITY_NA) {
|
||||
actor.inventory.invSearchByDynamicID(currentItem.dynamicID)!!.qty.toFloat()
|
||||
actor.inventory.searchByID(currentItem.dynamicID)!!.qty.toFloat()
|
||||
}
|
||||
else
|
||||
currentItem.durability
|
||||
|
||||
@@ -10,9 +10,7 @@ import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_HO
|
||||
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_Y
|
||||
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.UIInventoryFull.Companion.internalHeight
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericKeyDownFun
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericTouchDownFun
|
||||
@@ -136,7 +134,7 @@ internal class UIInventoryCells(
|
||||
)
|
||||
// debug text
|
||||
batch.color = Color.LIGHT_GRAY
|
||||
if (INVEN_DEBUG_MODE) {
|
||||
if (App.IS_DEVELOPMENT_BUILD) {
|
||||
App.fontSmallNumbers.draw(batch,
|
||||
"${full.actor.inventory.capacity}/${full.actor.inventory.maxCapacity}",
|
||||
encumbBarTextXPos,
|
||||
|
||||
@@ -38,8 +38,6 @@ class UIInventoryFull(
|
||||
|
||||
val CELL_COL = Toolkit.Theme.COL_CELL_FILL
|
||||
|
||||
const val INVEN_DEBUG_MODE = false
|
||||
|
||||
const 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
|
||||
const val CELLS_HOR = 10
|
||||
val CELLS_VRT: Int; get() = (App.scr.height - REQUIRED_MARGIN - 134 + UIItemInventoryItemGrid.listGap) / // 134 is another magic number
|
||||
|
||||
@@ -125,7 +125,7 @@ class UIItemInventoryEquippedView(
|
||||
itemGrid[k].equippedSlot = null
|
||||
}
|
||||
else {
|
||||
val itemRecord = it.invSearchByDynamicID(item)!!
|
||||
val itemRecord = it.searchByID(item)!!
|
||||
|
||||
itemGrid[k].item = ItemCodex[item]
|
||||
itemGrid[k].amount = itemRecord.qty
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVEN_DEBUG_MODE
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItem
|
||||
@@ -162,6 +161,9 @@ class UIItemInventoryItemGrid(
|
||||
listRebuildFun()
|
||||
}
|
||||
}
|
||||
|
||||
// COMMON variables because more than one instance of this can be up on the screen
|
||||
private val tooltipShowing = HashMap<UIItemInventoryItemGrid, Boolean>()
|
||||
}
|
||||
|
||||
private val itemGrid = Array<UIItemInventoryCellBase>(horizontalCells * verticalCells) {
|
||||
@@ -347,8 +349,8 @@ class UIItemInventoryItemGrid(
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
|
||||
var tooltipSet = false
|
||||
|
||||
tooltipShowing[this] = false
|
||||
|
||||
|
||||
items.forEach {
|
||||
@@ -356,20 +358,21 @@ class UIItemInventoryItemGrid(
|
||||
|
||||
|
||||
// set tooltip accordingly
|
||||
if (isCompactMode && it.item != null && it.mouseUp && !tooltipSet) {
|
||||
if ((App.IS_DEVELOPMENT_BUILD || isCompactMode) && it.item != null && it.mouseUp && tooltipShowing[this] != true) {
|
||||
INGAME.setTooltipMessage(
|
||||
if (INVEN_DEBUG_MODE) {
|
||||
it.item?.name + " (${it.item?.originalID}${if (it.item?.originalID == it.item?.dynamicID) "" else "/${it.item?.dynamicID}"})"
|
||||
if (App.IS_DEVELOPMENT_BUILD) {
|
||||
it.item?.name + "\n(${it.item?.originalID}${if (it.item?.originalID == it.item?.dynamicID) "" else "/${it.item?.dynamicID}"})"
|
||||
}
|
||||
else {
|
||||
it.item?.name
|
||||
}
|
||||
)
|
||||
tooltipSet = true
|
||||
|
||||
tooltipShowing[this] = true
|
||||
}
|
||||
}
|
||||
|
||||
if (!tooltipSet) {
|
||||
if (tooltipShowing.values.all { !it }) {
|
||||
INGAME.setTooltipMessage(null)
|
||||
}
|
||||
|
||||
@@ -461,7 +464,11 @@ class UIItemInventoryItemGrid(
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
tooltipShowing.remove(this)
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
tooltipShowing.remove(this)
|
||||
}
|
||||
|
||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user