world search ui integrated to world portal ui

This commit is contained in:
minjaesong
2023-06-18 21:29:18 +09:00
parent 93c427473d
commit a33f0e7ab4
10 changed files with 259 additions and 21 deletions

View File

@@ -128,9 +128,15 @@ abstract class UICanvas(
/** A function that is run ONCE when the UI is requested to be opened; will work identical to [endOpening] if [openCloseTime] is zero */
open fun show() {}
open fun show() {
uiItems.forEach { it.show() }
handler.subUIs.forEach { it.show() }
}
/** A function that is run ONCE when the UI is requested to be closed; will work identical to [endClosing] if [openCloseTime] is zero */
open fun hide() {}
open fun hide() {
uiItems.forEach { it.hide() }
handler.subUIs.forEach { it.hide() }
}
/** **DO NOT CALL THIS FUNCTION FOR THE ACTUAL UPDATING OF THE UI — USE update() INSTEAD**

View File

@@ -110,6 +110,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
open var keyTypedListener: ((Char) -> Unit)? = null
open var touchDraggedListener: ((Int, Int, Int) -> Unit)? = null
/** Parameters: screenX, screenY, pointer, button */
@Deprecated("Not really deprecated but you MOST DEFINITELY want to use clickOnceListener(mouseX, mouseY) instead.")
open var touchDownListener: ((Int, Int, Int, Int) -> Unit)? = null
open var touchUpListener: ((Int, Int, Int, Int) -> Unit)? = null
/** Parameters: amountX, amountY */
@@ -146,14 +147,14 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
mouseOverCall?.update(delta)
if (mouseUp) {
if (mouseOverCall?.isVisible ?: false) {
if (mouseOverCall?.isVisible == true) {
mouseOverCall?.setAsOpen()
}
mouseOverCall?.updateUI(delta)
}
else {
if (mouseOverCall?.isVisible ?: false) {
if (mouseOverCall?.isVisible == true) {
mouseOverCall?.setAsClose()
}
}

View File

@@ -18,7 +18,7 @@ class UIItemHorizontalFadeSlide(
//transitionLength: Float,
currentPosition: Float,
vararg uis: UICanvas
) : UIItemTransitionContainer(parent, initialX, initialY, width, height, 0.10f, currentPosition, uis) {
) : UIItemTransitionContainer(parent, initialX, initialY, width, height, 0.12f, currentPosition, uis) {
fun getOffX(index: Int) = ((currentPosition - index) * width / 2f).roundToInt()
fun getOpacity(index: Int) = 1f - (currentPosition - index).absoluteValue.coerceIn(0f, 1f)

View File

@@ -121,9 +121,9 @@ class UIItemTextLineInput(
private var currentPlaceholderText = ArrayList<Int>(placeholder().toCodePoints()) // the placeholder text may change every time you call it
private val btn1PosX = posX
private val btn2PosX = posX + width - WIDTH_ONEBUTTON
private val inputPosX = posX + WIDTH_ONEBUTTON + 3
private val btn1PosX; get() = posX
private val btn2PosX; get() = posX + width - WIDTH_ONEBUTTON
private val inputPosX; get() = posX + WIDTH_ONEBUTTON + 3
var mouseoverUpdateLatch = true // keep it true by default!
set(value) {
@@ -242,6 +242,13 @@ class UIItemTextLineInput(
}
}
/**
* Only makes sense when the placeholder returns randomised texts
*/
fun refreshPlaceholder() {
currentPlaceholderText = ArrayList<Int>(placeholder().toCodePoints())
}
override fun inputStrobed(e: TerrarumKeyboardEvent) {
val oldActive = isActive
@@ -496,6 +503,8 @@ class UIItemTextLineInput(
private var textDrawOffset = 0
override fun render(batch: SpriteBatch, camera: Camera) {
val posXDelta = posX - oldPosX
val ime = getIME(true)
@@ -646,6 +655,9 @@ class UIItemTextLineInput(
batch.color = Color.WHITE
super.render(batch, camera)
oldPosX = posX
}
fun getText() = textbufToString()