mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-11 06:11:50 +09:00
fix: inventory panels and their indices are mutually inversed
This commit is contained in:
@@ -174,6 +174,7 @@ class UIItemInventoryCatBar(
|
|||||||
selectedPanel = 1
|
selectedPanel = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// move selection highlighter
|
||||||
if (btn.mousePushed && index != selectedIndex) {
|
if (btn.mousePushed && index != selectedIndex) {
|
||||||
// normal stuffs
|
// normal stuffs
|
||||||
val oldIndex = selectedIndex
|
val oldIndex = selectedIndex
|
||||||
@@ -203,7 +204,6 @@ class UIItemInventoryCatBar(
|
|||||||
if (selectedPanel != 0) transitionFired = true
|
if (selectedPanel != 0) transitionFired = true
|
||||||
mainButtons.forEach { it.highlighted = false }
|
mainButtons.forEach { it.highlighted = false }
|
||||||
selectedPanel = 0
|
selectedPanel = 0
|
||||||
parentInventory.requestTransition(0)
|
|
||||||
|
|
||||||
sideButtons[0].highlighted = true
|
sideButtons[0].highlighted = true
|
||||||
sideButtons[3].highlighted = false
|
sideButtons[3].highlighted = false
|
||||||
@@ -212,7 +212,6 @@ class UIItemInventoryCatBar(
|
|||||||
if (selectedPanel != 2) transitionFired = true
|
if (selectedPanel != 2) transitionFired = true
|
||||||
mainButtons.forEach { it.highlighted = false }
|
mainButtons.forEach { it.highlighted = false }
|
||||||
selectedPanel = 2
|
selectedPanel = 2
|
||||||
parentInventory.requestTransition(2)
|
|
||||||
transitionFired = true
|
transitionFired = true
|
||||||
|
|
||||||
sideButtons[0].highlighted = false
|
sideButtons[0].highlighted = false
|
||||||
@@ -222,7 +221,7 @@ class UIItemInventoryCatBar(
|
|||||||
|
|
||||||
if (transitionFired) {
|
if (transitionFired) {
|
||||||
transitionFired = false
|
transitionFired = false
|
||||||
parentInventory.requestTransition(2 - selectedPanel)
|
parentInventory.requestTransition(selectedPanel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.torvald.terrarum.ui
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import com.jme3.math.FastMath
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,7 +19,12 @@ class UIItemHorizontalFadeSlide(
|
|||||||
) : UIItemTransitionContainer(parent, initialX, initialY, width, height, 0.15f, currentPosition, uis) {
|
) : UIItemTransitionContainer(parent, initialX, initialY, width, height, 0.15f, currentPosition, uis) {
|
||||||
|
|
||||||
fun getOffX(index: Int) = ((currentPosition - index) * width / 2f).roundToInt()
|
fun getOffX(index: Int) = ((currentPosition - index) * width / 2f).roundToInt()
|
||||||
fun getOpacity(index: Int) = 1f - (currentPosition - index).coerceIn(0f, 1f) // fixme make it work for both direction
|
fun getOpacity(index: Int) = 1f
|
||||||
|
/*if (currentPosition >= index)
|
||||||
|
1f - (currentPosition - index).coerceIn(0f, 1f)
|
||||||
|
else
|
||||||
|
(currentPosition - index).coerceIn(0f, 1f) - 1f*/
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// re-position the uis according to the initial choice of currentPosition
|
// re-position the uis according to the initial choice of currentPosition
|
||||||
@@ -33,7 +39,7 @@ class UIItemHorizontalFadeSlide(
|
|||||||
|
|
||||||
override fun onTransition(currentPosition: Float, uis: Array<out UICanvas>) {
|
override fun onTransition(currentPosition: Float, uis: Array<out UICanvas>) {
|
||||||
uis.forEachIndexed { index, it ->
|
uis.forEachIndexed { index, it ->
|
||||||
it.posX = it.initialX + getOffX(index)
|
it.posX = it.initialX - getOffX(index)
|
||||||
it.posY = it.initialY
|
it.posY = it.initialY
|
||||||
it.opacity = getOpacity(index)
|
it.opacity = getOpacity(index)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user