From 6e2809404a73ae421ec8db0cc657b8b985f9bace Mon Sep 17 00:00:00 2001 From: Minjae Song Date: Tue, 11 Dec 2018 02:22:31 +0900 Subject: [PATCH] fix: textbuttonlist selector appearance bug, nsmenu not closing its child --- .../terrarum/ui/UIItemTextButtonList.kt | 4 ++-- src/net/torvald/terrarum/ui/UINSMenu.kt | 22 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt index 6bb128002..f02120ffd 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt @@ -169,8 +169,8 @@ class UIItemTextButtonList( val oldIndex = selectedIndex if (kinematic) { - highlighterYStart = buttons[selectedIndex!!].posY.toDouble() selectedIndex = index + highlighterYStart = buttons[selectedIndex!!].posY.toDouble() highlighterMoving = true highlighterYEnd = buttons[selectedIndex!!].posY.toDouble() } @@ -195,7 +195,7 @@ class UIItemTextButtonList( batch.color = highlightBackCol BlendMode.resolve(highlightBackBlendMode, batch) if (highlightY != null) { - batch.fillRect(posX.toFloat(), highlightY!!.toFloat(), width.toFloat(), UIItemTextButton.height.toFloat()) + batch.fillRect(posX.toFloat(), highlightY!!.toFloat(), width.toFloat(), itemHitboxSize.toFloat()) } buttons.forEach { it.render(batch, camera) } diff --git a/src/net/torvald/terrarum/ui/UINSMenu.kt b/src/net/torvald/terrarum/ui/UINSMenu.kt index 00e8a496b..359e2f036 100644 --- a/src/net/torvald/terrarum/ui/UINSMenu.kt +++ b/src/net/torvald/terrarum/ui/UINSMenu.kt @@ -78,16 +78,20 @@ class UINSMenu( // List selection change listener list.selectionChangeListener = { old, new -> // if the selection has a child... + + //println("new sel: ${tree.children[new]}") + + + // 1. pop as far as possible + // 2. push the new menu + + // 1. pop as far as possible + while (listStack.peek().list != list) { + popSubMenu() + } + + // 2. push the new menu if (tree.children[new].children.isNotEmpty()) { - // 1. pop as far as possible - // 2. push the new menu - - // 1. pop as far as possible - while (listStack.peek().list != list) { - popSubMenu() - } - - // 2. push the new menu addSubMenu(tree.children[new]) } }