mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 01:16:46 -04:00
hud: fix some hotbar offset issues
This commit is contained in:
parent
e1bdd71e5e
commit
e09871b5da
@ -51,6 +51,7 @@ class ItemElement(
|
||||
countText.text = when {
|
||||
count < 0 -> TextComponent((count < -99).decide({ "-∞" }, { count }), color = ChatColors.RED) // No clue why I do this...
|
||||
count == 0 -> TextComponent("0", color = ChatColors.YELLOW)
|
||||
count == 1 -> TextComponent("")
|
||||
count > ProtocolDefinition.ITEM_STACK_MAX_SIZE -> TextComponent((count > 99).decide({ "∞" }, { count }), color = ChatColors.RED)
|
||||
else -> TextComponent(count)
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class HotbarBaseElement(hudRenderer: HUDRenderer) : Element(hudRenderer), Pollab
|
||||
|
||||
private val HOTBAR_BASE_SIZE = Vec2i(182, 22)
|
||||
private const val FRAME_SIZE = 24
|
||||
private const val HORIZONTAL_MARGIN = 1
|
||||
const val HORIZONTAL_MARGIN = 1
|
||||
private const val FRAME_OFFSET = -2 // FRAME_SIZE - HOTBAR_BASE_SIZE.y
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.layout.RowLayout
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.Vec2Util.max
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.Vec4Util.copy
|
||||
import glm_.vec2.Vec2i
|
||||
import java.lang.Integer.max
|
||||
|
||||
@ -51,10 +52,12 @@ class HotbarElement(hudRenderer: HUDRenderer) : Element(hudRenderer) {
|
||||
topLeft.apply {
|
||||
parent = this@HotbarElement
|
||||
spacing = VERTICAL_SPACING
|
||||
margin = margin.copy(left = HotbarBaseElement.HORIZONTAL_MARGIN)
|
||||
}
|
||||
topRight.apply {
|
||||
parent = this@HotbarElement
|
||||
spacing = VERTICAL_SPACING
|
||||
margin = margin.copy(right = HotbarBaseElement.HORIZONTAL_MARGIN)
|
||||
}
|
||||
|
||||
topLeft += protection
|
||||
|
@ -222,7 +222,7 @@ class HotbarHealthElement(hudRenderer: HUDRenderer) : Element(hudRenderer), Poll
|
||||
rows++
|
||||
}
|
||||
|
||||
_size = Vec2i(HEARTS_PER_ROW, rows) * HEART_SIZE
|
||||
_size = Vec2i(HEARTS_PER_ROW, rows) * HEART_SIZE + Vec2i(1, 0) // 1 pixel is overlapping, so we have one more for the heart
|
||||
cacheUpToDate = false
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class HotbarHungerElement(hudRenderer: HUDRenderer) : Element(hudRenderer), Poll
|
||||
|
||||
|
||||
init {
|
||||
size = Vec2i(HUNGER_CONTAINERS, 1) * HUNGER_SIZE
|
||||
_size = Vec2i(HUNGER_CONTAINERS, 1) * HUNGER_SIZE + Vec2i(1, 0) // 1 pixel is overlapping per hunger, so one more
|
||||
}
|
||||
|
||||
override fun forceRender(offset: Vec2i, z: Int, consumer: GUIVertexConsumer): Int {
|
||||
|
@ -62,4 +62,9 @@ object Vec4Util {
|
||||
|
||||
val Vec4i.offset: Vec2i
|
||||
get() = Vec2i(left, top)
|
||||
|
||||
|
||||
fun Vec4i.copy(top: Int = this.top, right: Int = this.right, bottom: Int = this.bottom, left: Int = this.left): Vec4i {
|
||||
return Vec4i(top, right, bottom, left)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user