mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
inventory ui will get taller if screen is taller
This commit is contained in:
@@ -137,14 +137,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
lateinit var uiCheatMotherfuckerNootNoot: UICheatDetected
|
lateinit var uiCheatMotherfuckerNootNoot: UICheatDetected
|
||||||
|
|
||||||
// UI aliases
|
|
||||||
lateinit var uiAliases: ArrayList<UICanvas>
|
|
||||||
private set
|
|
||||||
lateinit var uiAliasesPausing: ArrayList<UICanvas>
|
|
||||||
private set
|
|
||||||
|
|
||||||
//var paused: Boolean = false
|
|
||||||
//get() = uiAliasesPausing.map { if (it.isOpened) return true else 0 }.isEmpty() // isEmpty is always false, which we want
|
|
||||||
|
|
||||||
var particlesActive = 0
|
var particlesActive = 0
|
||||||
private set
|
private set
|
||||||
@@ -361,7 +353,8 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
|
|
||||||
// batch-process uiAliases
|
// batch-process uiAliases
|
||||||
uiAliases = arrayListOf(
|
// NOTE: UIs that should pause the game (e.g. Inventory) must have relevant codes ON THEIR SIDE
|
||||||
|
arrayListOf(
|
||||||
// drawn first
|
// drawn first
|
||||||
//uiVitalPrimary,
|
//uiVitalPrimary,
|
||||||
//uiVitalSecondary,
|
//uiVitalSecondary,
|
||||||
@@ -372,19 +365,13 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
uiBasicInfo,
|
uiBasicInfo,
|
||||||
uiWatchTierOne,
|
uiWatchTierOne,
|
||||||
UIScreenZoom(),
|
UIScreenZoom(),
|
||||||
uiTooltip
|
|
||||||
// drawn last
|
|
||||||
)
|
|
||||||
uiAliasesPausing = arrayListOf(
|
|
||||||
uiInventoryPlayer,
|
uiInventoryPlayer,
|
||||||
//uiInventoryContainer,
|
//uiInventoryContainer,
|
||||||
|
uiTooltip,
|
||||||
consoleHandler,
|
consoleHandler,
|
||||||
uiCheatMotherfuckerNootNoot
|
uiCheatMotherfuckerNootNoot
|
||||||
)
|
// drawn last
|
||||||
// UIFixture is handled "dirtily" (calling directly from the render/update code) because it's dynamic
|
).forEach { addUI(it) }
|
||||||
// Therefore, console window will be drawn behind of the thing
|
|
||||||
uiAliases.forEach { addUI(it) } // put them all to the UIContainer
|
|
||||||
uiAliasesPausing.forEach { addUI(it) } // put them all to the UIContainer
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,13 +41,16 @@ class UIInventoryFull(
|
|||||||
override var width: Int = AppLoader.screenW
|
override var width: Int = AppLoader.screenW
|
||||||
override var height: Int = AppLoader.screenH
|
override var height: Int = AppLoader.screenH
|
||||||
|
|
||||||
|
private val REQUIRED_MARGIN = 166 // hard-coded value. Don't know the details
|
||||||
|
|
||||||
private val CELLS_HOR = 10
|
private val CELLS_HOR = 10
|
||||||
private val CELLS_VRT = 8
|
private val CELLS_VRT = (AppLoader.screenH - REQUIRED_MARGIN - 134 + UIItemInventoryDynamicList.listGap) / // 134 is another magic number
|
||||||
|
(UIItemInventoryElemSimple.height + UIItemInventoryDynamicList.listGap)
|
||||||
|
|
||||||
private val itemListToEquipViewGap = UIItemInventoryDynamicList.listGap // used to be 24; figured out that the extra gap does nothig
|
private val itemListToEquipViewGap = UIItemInventoryDynamicList.listGap // used to be 24; figured out that the extra gap does nothig
|
||||||
|
|
||||||
val internalWidth: Int = UIItemInventoryDynamicList.getEstimatedW(CELLS_HOR) + UIItemInventoryEquippedView.WIDTH + itemListToEquipViewGap
|
val internalWidth: Int = UIItemInventoryDynamicList.getEstimatedW(CELLS_HOR) + UIItemInventoryEquippedView.WIDTH + itemListToEquipViewGap
|
||||||
val internalHeight: Int = 166 + UIItemInventoryDynamicList.getEstimatedH(CELLS_VRT) // grad_begin..grad_end..contents..grad_begin..grad_end
|
val internalHeight: Int = REQUIRED_MARGIN + UIItemInventoryDynamicList.getEstimatedH(CELLS_VRT) // grad_begin..grad_end..contents..grad_begin..grad_end
|
||||||
|
|
||||||
init {
|
init {
|
||||||
handler.allowESCtoClose = true
|
handler.allowESCtoClose = true
|
||||||
@@ -243,7 +246,7 @@ class UIInventoryFull(
|
|||||||
private val shapeRenderer = ShapeRenderer()
|
private val shapeRenderer = ShapeRenderer()
|
||||||
private val gradHeight = 48f
|
private val gradHeight = 48f
|
||||||
|
|
||||||
private val weightBarWidth = 64f
|
private val weightBarWidth = UIItemInventoryElemSimple.height * 2f + UIItemInventoryDynamicList.listGap
|
||||||
|
|
||||||
private var xEnd = (AppLoader.screenW + internalWidth).div(2).toFloat()
|
private var xEnd = (AppLoader.screenW + internalWidth).div(2).toFloat()
|
||||||
private var yEnd = (AppLoader.screenH + internalHeight).div(2).toFloat()
|
private var yEnd = (AppLoader.screenH + internalHeight).div(2).toFloat()
|
||||||
@@ -485,18 +488,28 @@ class UIInventoryFull(
|
|||||||
|
|
||||||
|
|
||||||
// control hints
|
// control hints
|
||||||
|
val controlHintXPos = offsetX + inventoryScrOffX
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
AppLoader.fontGame.draw(batch, listControlHelp, offsetX + inventoryScrOffX, yEnd - 20)
|
AppLoader.fontGame.draw(batch, listControlHelp, controlHintXPos, yEnd - 20)
|
||||||
|
|
||||||
|
|
||||||
// encumbrance meter
|
// encumbrance meter
|
||||||
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
|
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
|
||||||
|
// encumbrance bar will go one row down if control help message is too long
|
||||||
|
val encumbBarXPos = xEnd - weightBarWidth + inventoryScrOffX
|
||||||
|
val encumbBarTextXPos = encumbBarXPos - 6 - AppLoader.fontGame.getWidth(encumbranceText)
|
||||||
|
val encumbBarYPos = yEnd-20 + 3f +
|
||||||
|
if (AppLoader.fontGame.getWidth(listControlHelp) + 2 + controlHintXPos >= encumbBarTextXPos)
|
||||||
|
AppLoader.fontGame.lineHeight
|
||||||
|
else 0f
|
||||||
|
|
||||||
|
printdbg(this, "${AppLoader.fontGame.getWidth(listControlHelp) + 2 + controlHintXPos}; ${encumbBarTextXPos}")
|
||||||
|
|
||||||
AppLoader.fontGame.draw(batch,
|
AppLoader.fontGame.draw(batch,
|
||||||
encumbranceText,
|
encumbranceText,
|
||||||
xEnd - 6 - AppLoader.fontGame.getWidth(encumbranceText) - weightBarWidth + inventoryScrOffX,
|
encumbBarTextXPos,
|
||||||
yEnd-20
|
encumbBarYPos - 3f
|
||||||
)
|
)
|
||||||
|
|
||||||
// encumbrance bar background
|
// encumbrance bar background
|
||||||
@@ -505,16 +518,13 @@ class UIInventoryFull(
|
|||||||
val encumbBack = encumbCol mul UIItemInventoryCellCommonRes.meterBackDarkening
|
val encumbBack = encumbCol mul UIItemInventoryCellCommonRes.meterBackDarkening
|
||||||
batch.color = encumbBack
|
batch.color = encumbBack
|
||||||
batch.fillRect(
|
batch.fillRect(
|
||||||
xEnd - weightBarWidth + inventoryScrOffX,
|
encumbBarXPos, encumbBarYPos,
|
||||||
yEnd-20 + 3f,
|
weightBarWidth, controlHelpHeight - 6f
|
||||||
weightBarWidth,
|
|
||||||
controlHelpHeight - 6f
|
|
||||||
)
|
)
|
||||||
// encumbrance bar
|
// encumbrance bar
|
||||||
batch.color = encumbCol
|
batch.color = encumbCol
|
||||||
batch.fillRect(
|
batch.fillRect(
|
||||||
xEnd - weightBarWidth + inventoryScrOffX,
|
encumbBarXPos, encumbBarYPos,
|
||||||
yEnd-20 + 3f,
|
|
||||||
if (actor.inventory.capacityMode == CAPACITY_MODE_NO_ENCUMBER)
|
if (actor.inventory.capacityMode == CAPACITY_MODE_NO_ENCUMBER)
|
||||||
1f
|
1f
|
||||||
else // make sure 1px is always be seen
|
else // make sure 1px is always be seen
|
||||||
@@ -526,8 +536,8 @@ class UIInventoryFull(
|
|||||||
if (IS_DEVELOPMENT_BUILD) {
|
if (IS_DEVELOPMENT_BUILD) {
|
||||||
AppLoader.fontSmallNumbers.draw(batch,
|
AppLoader.fontSmallNumbers.draw(batch,
|
||||||
"${actor.inventory.capacity}/${actor.inventory.maxCapacity}",
|
"${actor.inventory.capacity}/${actor.inventory.maxCapacity}",
|
||||||
xEnd - 6 - AppLoader.fontGame.getWidth(encumbranceText) - weightBarWidth + inventoryScrOffX,
|
encumbBarTextXPos,
|
||||||
yEnd-20 + 3f + controlHelpHeight - 4f
|
encumbBarYPos + controlHelpHeight - 4f
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class UIItemInventoryDynamicList(
|
|||||||
|
|
||||||
|
|
||||||
// set tooltip accordingly
|
// set tooltip accordingly
|
||||||
if (isCompactMode && it.mouseUp && !tooltipSet) {
|
if (isCompactMode && it.item != null && it.mouseUp && !tooltipSet) {
|
||||||
(Terrarum.ingame as? TerrarumIngame)?.setTooltipMessage(
|
(Terrarum.ingame as? TerrarumIngame)?.setTooltipMessage(
|
||||||
if (AppLoader.IS_DEVELOPMENT_BUILD) {
|
if (AppLoader.IS_DEVELOPMENT_BUILD) {
|
||||||
it.item?.name + "/Mat: ${it.item?.material?.identifier}"
|
it.item?.name + "/Mat: ${it.item?.material?.identifier}"
|
||||||
|
|||||||
Reference in New Issue
Block a user