mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-08 12:51:51 +09:00
inventory ui elements position adjustments
This commit is contained in:
@@ -105,7 +105,7 @@ internal class UIStorageChest : UICanvas(
|
||||
catBar = UIItemInventoryCatBar(
|
||||
this,
|
||||
(App.scr.width - catBarWidth) / 2,
|
||||
42 + (App.scr.height - internalHeight) / 2,
|
||||
42 - UIInventoryFull.YPOS_CORRECTION + (App.scr.height - internalHeight) / 2,
|
||||
internalWidth,
|
||||
catBarWidth,
|
||||
false
|
||||
@@ -228,7 +228,8 @@ internal class UIStorageChest : UICanvas(
|
||||
val chestNameXpos = itemListChest.posX + 6f
|
||||
val encumbBarXPos = itemListPlayer.posX + itemListPlayer.width - weightBarWidth
|
||||
val encumbBarTextXPos = encumbBarXPos - 6 - App.fontGame.getWidth(encumbranceText)
|
||||
val encumbBarYPos = (App.scr.height + internalHeight).div(2) - 20 + 3f
|
||||
val yEnd = -UIInventoryFull.YPOS_CORRECTION + (App.scr.height + internalHeight).div(2).toFloat() // directly copied from UIInventoryFull.yEnd
|
||||
val encumbBarYPos = yEnd - 20 + 3 // dunno why but extra 3 px is needed
|
||||
val encumbCol = UIItemInventoryCellCommonRes.getHealthMeterColour(1f - encumbrancePerc, 0f, 1f)
|
||||
val encumbBack = encumbCol mul UIItemInventoryCellCommonRes.meterBackDarkening
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.gameitems.mouseInInteractableRange
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureBase
|
||||
import net.torvald.terrarum.utils.RandomWordsName
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
@@ -17,20 +18,22 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : GameItem(originalID) {
|
||||
|
||||
private val hash = RandomWordsName(4)
|
||||
|
||||
|
||||
protected open val makeFixture: () -> FixtureBase = {
|
||||
Class.forName(fixtureClassName).getDeclaredConstructor().newInstance() as FixtureBase
|
||||
}
|
||||
|
||||
init {
|
||||
ItemCodex.fixtureToSpawnerItemID[fixtureClassName] = originalID
|
||||
|
||||
|
||||
println("FixtureItemBase init: $hash")
|
||||
}
|
||||
|
||||
protected var ghostItem: FixtureBase? = null
|
||||
get() {
|
||||
if (field == null)
|
||||
field = makeFixture()
|
||||
return field
|
||||
}
|
||||
// private var _ghostItem: FixtureBase? = null
|
||||
private var ghostItem: FixtureBase? = null
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "FIXTUREBASE"
|
||||
@@ -51,7 +54,15 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
private var ghostInit = false
|
||||
|
||||
override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) {
|
||||
println("ghost: ${ghostItem}; ghostInit = $ghostInit; instance: $hash")
|
||||
if (!ghostInit) {
|
||||
ghostInit = true
|
||||
ghostItem = makeFixture()
|
||||
}
|
||||
|
||||
(INGAME as TerrarumIngame).blockMarkingActor.let {
|
||||
it.setGhost(ghostItem!!)
|
||||
it.isVisible = true
|
||||
@@ -62,6 +73,8 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
||||
}
|
||||
|
||||
override fun effectOnUnequip(actor: ActorWithBody, delta: Float) {
|
||||
// ghostInit = false
|
||||
|
||||
(INGAME as TerrarumIngame).blockMarkingActor.let {
|
||||
it.unsetGhost()
|
||||
it.isVisible = false
|
||||
|
||||
@@ -37,6 +37,8 @@ class UIInventoryFull(
|
||||
|
||||
val CELL_COL = Toolkit.Theme.COL_CELL_FILL
|
||||
|
||||
const val YPOS_CORRECTION = 16 // another hard-coding. X_X
|
||||
|
||||
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
|
||||
@@ -51,7 +53,7 @@ class UIInventoryFull(
|
||||
|
||||
val INVENTORY_CELLS_UI_HEIGHT: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * UIItemInventoryItemGrid.listGap
|
||||
val INVENTORY_CELLS_OFFSET_X = { 0 + (Toolkit.drawWidth - internalWidth) / 2 }
|
||||
val INVENTORY_CELLS_OFFSET_Y = { 107 + (App.scr.height - internalHeight) / 2 }
|
||||
val INVENTORY_CELLS_OFFSET_Y = { -YPOS_CORRECTION + 107 + (App.scr.height - internalHeight) / 2 }
|
||||
|
||||
val catBarWidth = 330
|
||||
|
||||
@@ -71,7 +73,7 @@ class UIInventoryFull(
|
||||
}
|
||||
|
||||
|
||||
val gradTopStart = (App.scr.height - internalHeight).div(2).toFloat()
|
||||
val gradTopStart = -YPOS_CORRECTION + (App.scr.height - internalHeight).div(2).toFloat()
|
||||
val gradBottomEnd = App.scr.height - gradTopStart
|
||||
|
||||
shapeRenderer!!.inUse {
|
||||
@@ -79,7 +81,7 @@ class UIInventoryFull(
|
||||
it.rect(0f, gradTopStart, App.scr.wf, gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
|
||||
it.rect(0f, gradBottomEnd, App.scr.wf, -gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
|
||||
|
||||
it.rect(0f, gradTopStart + gradHeight, App.scr.wf, internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol)
|
||||
it.rect(0f, gradTopStart + gradHeight, App.scr.wf, 2*YPOS_CORRECTION + internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol)
|
||||
|
||||
it.rect(0f, 0f, App.scr.wf, gradTopStart, gradStartCol, gradStartCol, gradStartCol, gradStartCol)
|
||||
it.rect(0f, App.scr.hf, App.scr.wf, -(App.scr.hf - gradBottomEnd), gradStartCol, gradStartCol, gradStartCol, gradStartCol)
|
||||
@@ -151,7 +153,7 @@ class UIInventoryFull(
|
||||
val catBar = UIItemInventoryCatBar(
|
||||
this,
|
||||
(width - catBarWidth) / 2,
|
||||
42 + (App.scr.height - internalHeight) / 2,
|
||||
42 - YPOS_CORRECTION + (App.scr.height - internalHeight) / 2,
|
||||
internalWidth,
|
||||
catBarWidth,
|
||||
true,
|
||||
@@ -238,7 +240,7 @@ class UIInventoryFull(
|
||||
|
||||
internal var xEnd = (width + internalWidth).div(2).toFloat()
|
||||
private set
|
||||
internal var yEnd = (App.scr.height + internalHeight).div(2).toFloat()
|
||||
internal var yEnd = -YPOS_CORRECTION + (App.scr.height + internalHeight).div(2).toFloat()
|
||||
private set
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
@@ -302,7 +304,7 @@ class UIInventoryFull(
|
||||
offsetY = ((App.scr.height - internalHeight) / 2).toFloat()
|
||||
|
||||
xEnd = (width + internalWidth).div(2).toFloat()
|
||||
yEnd = (App.scr.height + internalHeight).div(2).toFloat()
|
||||
yEnd = -YPOS_CORRECTION + (scr.height + internalHeight).div(2).toFloat()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user