diff --git a/src/net/torvald/terrarum/UIItemInventoryCatBar.kt b/src/net/torvald/terrarum/UIItemInventoryCatBar.kt index 4859119ee..e4f1277f0 100644 --- a/src/net/torvald/terrarum/UIItemInventoryCatBar.kt +++ b/src/net/torvald/terrarum/UIItemInventoryCatBar.kt @@ -174,6 +174,7 @@ class UIItemInventoryCatBar( selectedPanel = 1 } + // move selection highlighter if (btn.mousePushed && index != selectedIndex) { // normal stuffs val oldIndex = selectedIndex @@ -203,7 +204,6 @@ class UIItemInventoryCatBar( if (selectedPanel != 0) transitionFired = true mainButtons.forEach { it.highlighted = false } selectedPanel = 0 - parentInventory.requestTransition(0) sideButtons[0].highlighted = true sideButtons[3].highlighted = false @@ -212,7 +212,6 @@ class UIItemInventoryCatBar( if (selectedPanel != 2) transitionFired = true mainButtons.forEach { it.highlighted = false } selectedPanel = 2 - parentInventory.requestTransition(2) transitionFired = true sideButtons[0].highlighted = false @@ -222,7 +221,7 @@ class UIItemInventoryCatBar( if (transitionFired) { transitionFired = false - parentInventory.requestTransition(2 - selectedPanel) + parentInventory.requestTransition(selectedPanel) } } diff --git a/src/net/torvald/terrarum/ui/UIItemHorizontalFadeSlide.kt b/src/net/torvald/terrarum/ui/UIItemHorizontalFadeSlide.kt index e363a1936..ef3faa198 100644 --- a/src/net/torvald/terrarum/ui/UIItemHorizontalFadeSlide.kt +++ b/src/net/torvald/terrarum/ui/UIItemHorizontalFadeSlide.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.ui +import com.jme3.math.FastMath import kotlin.math.roundToInt /** @@ -18,7 +19,12 @@ class UIItemHorizontalFadeSlide( ) : UIItemTransitionContainer(parent, initialX, initialY, width, height, 0.15f, currentPosition, uis) { 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 { // re-position the uis according to the initial choice of currentPosition @@ -33,7 +39,7 @@ class UIItemHorizontalFadeSlide( override fun onTransition(currentPosition: Float, uis: Array) { uis.forEachIndexed { index, it -> - it.posX = it.initialX + getOffX(index) + it.posX = it.initialX - getOffX(index) it.posY = it.initialY it.opacity = getOpacity(index) }