mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-16 05:24:06 +09:00
jukebox ui wip
This commit is contained in:
@@ -44,7 +44,7 @@ class UIItemCatBar(
|
||||
// val selectedIcon: Int
|
||||
// get() = catArrangement[selectedIndex]
|
||||
|
||||
private val sideButtons: Array<UIItemImageButton>
|
||||
private lateinit var sideButtons: Array<UIItemImageButton>
|
||||
|
||||
// set up all the buttons
|
||||
init {
|
||||
@@ -71,30 +71,32 @@ class UIItemCatBar(
|
||||
}
|
||||
|
||||
|
||||
// side buttons
|
||||
// NOTE: < > arrows must "highlightable = false"; "true" otherwise
|
||||
// determine gaps: hacky way exploiting that we already know the catbar is always at the c of the ui
|
||||
val relativeStartX = posX - (uiInternalWidth - width) / 2
|
||||
val sideButtonsGap = (((uiInternalWidth - width) / 2) - 2f * catIcons.tileW) / 3f
|
||||
val iconIndex = arrayOf(
|
||||
catIcons.get(9,1),
|
||||
catIcons.get(16,0),
|
||||
catIcons.get(17,0),
|
||||
catIcons.get(13,0)
|
||||
)
|
||||
if (showSideButtons) {
|
||||
|
||||
// side buttons
|
||||
// NOTE: < > arrows must "highlightable = false"; "true" otherwise
|
||||
// determine gaps: hacky way exploiting that we already know the catbar is always at the c of the ui
|
||||
val relativeStartX = posX - (uiInternalWidth - width) / 2
|
||||
val sideButtonsGap = (((uiInternalWidth - width) / 2) - 2f * catIcons.tileW) / 3f
|
||||
val iconIndex = arrayOf(
|
||||
catIcons.get(9, 1),
|
||||
catIcons.get(16, 0),
|
||||
catIcons.get(17, 0),
|
||||
catIcons.get(13, 0)
|
||||
)
|
||||
|
||||
|
||||
//println("[UIItemInventoryCatBar] relativeStartX: $relativeStartX")
|
||||
//println("[UIItemInventoryCatBar] posX: $posX")
|
||||
//println("[UIItemInventoryCatBar] relativeStartX: $relativeStartX")
|
||||
//println("[UIItemInventoryCatBar] posX: $posX")
|
||||
|
||||
sideButtons = Array(iconIndex.size) { index ->
|
||||
val iconPosX = if (index < 2)
|
||||
(relativeStartX + sideButtonsGap + (sideButtonsGap + catIcons.tileW) * index).roundToInt()
|
||||
else
|
||||
(relativeStartX + width + 2 * sideButtonsGap + (sideButtonsGap + catIcons.tileW) * index).roundToInt()
|
||||
val iconPosY = 0
|
||||
sideButtons = Array(iconIndex.size) { index ->
|
||||
val iconPosX = if (index < 2)
|
||||
(relativeStartX + sideButtonsGap + (sideButtonsGap + catIcons.tileW) * index).roundToInt()
|
||||
else
|
||||
(relativeStartX + width + 2 * sideButtonsGap + (sideButtonsGap + catIcons.tileW) * index).roundToInt()
|
||||
val iconPosY = 0
|
||||
|
||||
UIItemImageButton(
|
||||
UIItemImageButton(
|
||||
inventoryUI,
|
||||
iconIndex[index],
|
||||
activeBackCol = Color(0),
|
||||
@@ -106,7 +108,8 @@ class UIItemCatBar(
|
||||
inactiveCol = if (index == 0 || index == 3) Color.WHITE else Color(0xffffff7f.toInt()),
|
||||
activeCol = if (index == 0 || index == 3) Toolkit.Theme.COL_MOUSE_UP else Color(0xffffff7f.toInt()),
|
||||
highlightable = (index == 0 || index == 3)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,9 +139,9 @@ class UIItemCatBar(
|
||||
if (n !in 0..2) throw IllegalArgumentException("$n")
|
||||
selectedPanel = n
|
||||
|
||||
sideButtons[0].highlighted = (n == 0)
|
||||
if (showSideButtons) sideButtons[0].highlighted = (n == 0)
|
||||
mainButtons[selectedIndex].highlighted = (n == 1)
|
||||
sideButtons[3].highlighted = (n == 2)
|
||||
if (showSideButtons) sideButtons[3].highlighted = (n == 2)
|
||||
}
|
||||
|
||||
|
||||
@@ -214,8 +217,10 @@ class UIItemCatBar(
|
||||
if (selectedPanel == 1) {
|
||||
btn.highlighted = (index == selectedIndex) // forcibly highlight if this.highlighted != null
|
||||
|
||||
sideButtons[0].highlighted = false
|
||||
sideButtons[3].highlighted = false
|
||||
if (showSideButtons) {
|
||||
sideButtons[0].highlighted = false
|
||||
sideButtons[3].highlighted = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ class UIItemInventoryElemSimple(
|
||||
parentUI: UICanvas,
|
||||
initialX: Int,
|
||||
initialY: Int,
|
||||
override var item: GameItem?,
|
||||
override var amount: Long,
|
||||
override var itemImage: TextureRegion?,
|
||||
override var item: GameItem? = null,
|
||||
override var amount: Long = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
||||
override var itemImage: TextureRegion? = null,
|
||||
override var quickslot: Int? = null,
|
||||
override var equippedSlot: Int? = null, // remnants of wide cell displaying slot number and highlighting; in this style of cell this field only determines highlightedness at render
|
||||
val drawBackOnNull: Boolean = true,
|
||||
|
||||
@@ -24,9 +24,9 @@ class UIItemInventoryElemWide(
|
||||
initialX: Int,
|
||||
initialY: Int,
|
||||
override val width: Int,
|
||||
override var item: GameItem?,
|
||||
override var amount: Long,
|
||||
override var itemImage: TextureRegion?,
|
||||
override var item: GameItem? = null,
|
||||
override var amount: Long = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
||||
override var itemImage: TextureRegion? = null,
|
||||
override var quickslot: Int? = null,
|
||||
override var equippedSlot: Int? = null,
|
||||
val drawBackOnNull: Boolean = true,
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
class UITemplateCatBar(
|
||||
parent: UICanvas,
|
||||
showSidebuttons: Boolean,
|
||||
|
||||
catIcons: TextureRegionPack = CommonResourcePool.getAsTextureRegionPack("inventory_category"),
|
||||
catArrangement: IntArray, // icon order
|
||||
@@ -26,7 +27,7 @@ class UITemplateCatBar(
|
||||
42 - UIInventoryFull.YPOS_CORRECTION + (App.scr.height - UIInventoryFull.internalHeight) / 2,
|
||||
UIInventoryFull.internalWidth,
|
||||
UIInventoryFull.catBarWidth,
|
||||
true,
|
||||
showSidebuttons,
|
||||
catIcons, catArrangement, catIconsMeaning, catIconsLabels
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user