mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
turns out uiitemtextbuttonlist colouring bug was because of the gamefont
This commit is contained in:
Binary file not shown.
@@ -76,20 +76,31 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
|
|
||||||
gameMenuButtons.selectionChangeListener = { _, new ->
|
gameMenuButtons.selectionChangeListener = { _, new ->
|
||||||
when (new) {
|
when (new) {
|
||||||
4 -> screen = 2
|
4 -> {
|
||||||
5 -> screen = 1
|
screen = 2; gameMenuButtons.deselect()
|
||||||
|
}
|
||||||
|
5 -> {
|
||||||
|
screen = 1; gameMenuButtons.deselect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
areYouSureMainMenuButtons.selectionChangeListener = { _, new ->
|
areYouSureMainMenuButtons.selectionChangeListener = { _, new ->
|
||||||
when (new) {
|
when (new) {
|
||||||
1 -> App.setScreen(TitleScreen(App.batch))
|
1 -> {
|
||||||
2 -> screen = 0
|
areYouSureMainMenuButtons.deselect()
|
||||||
|
App.setScreen(TitleScreen(App.batch))
|
||||||
|
}
|
||||||
|
2 -> {
|
||||||
|
screen = 0; areYouSureMainMenuButtons.deselect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
areYouSureQuitButtons.selectionChangeListener = { _, new ->
|
areYouSureQuitButtons.selectionChangeListener = { _, new ->
|
||||||
when (new) {
|
when (new) {
|
||||||
1 -> Gdx.app.exit()
|
1 -> Gdx.app.exit()
|
||||||
2 -> screen = 0
|
2 -> {
|
||||||
|
screen = 0; areYouSureQuitButtons.deselect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
import net.torvald.terrarum.BlendMode
|
import net.torvald.terrarum.BlendMode
|
||||||
import net.torvald.terrarum.blendNormal
|
import net.torvald.terrarum.blendNormal
|
||||||
import net.torvald.terrarum.fillRect
|
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,12 +68,18 @@ open class UIItemTextButton(
|
|||||||
|
|
||||||
var highlighted: Boolean = false
|
var highlighted: Boolean = false
|
||||||
|
|
||||||
|
override fun update(delta: Float) {
|
||||||
|
super.update(delta)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
val textW = font.getWidth(label)
|
val textW = font.getWidth(label)
|
||||||
|
|
||||||
|
|
||||||
// draw background
|
// draw background
|
||||||
if (highlighted) {
|
/*if (highlighted) {
|
||||||
BlendMode.resolve(highlightBackBlendMode, batch)
|
BlendMode.resolve(highlightBackBlendMode, batch)
|
||||||
batch.color = highlightBackCol
|
batch.color = highlightBackCol
|
||||||
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||||
@@ -88,7 +93,7 @@ open class UIItemTextButton(
|
|||||||
batch.color = backgroundCol
|
batch.color = backgroundCol
|
||||||
BlendMode.resolve(backgroundBlendMode, batch)
|
BlendMode.resolve(backgroundBlendMode, batch)
|
||||||
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
@@ -99,7 +104,8 @@ open class UIItemTextButton(
|
|||||||
else inactiveCol
|
else inactiveCol
|
||||||
|
|
||||||
font.draw(batch,
|
font.draw(batch,
|
||||||
label, //"$label/H:${highlighted.toInt()}, M:${mouseUp.toInt()}",
|
label,
|
||||||
|
// "$label/H:${highlighted.toInt()}, M:${mouseUp.toInt()}",
|
||||||
when (alignment) {
|
when (alignment) {
|
||||||
Alignment.CENTRE -> posX.toFloat() + width.minus(textW).div(2) + (preGapX - postGapX).div(2)
|
Alignment.CENTRE -> posX.toFloat() + width.minus(textW).div(2) + (preGapX - postGapX).div(2)
|
||||||
Alignment.LEFT -> posX.toFloat() + preGapX
|
Alignment.LEFT -> posX.toFloat() + preGapX
|
||||||
|
|||||||
@@ -242,10 +242,16 @@ class UIItemTextButtonList(
|
|||||||
|
|
||||||
fun select(index: Int) {
|
fun select(index: Int) {
|
||||||
selectedIndex = index
|
selectedIndex = index
|
||||||
|
buttons.forEachIndexed { index, btn ->
|
||||||
|
btn.highlighted = (index == selectedIndex) // forcibly highlight if this.highlighted != null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deselect() {
|
fun deselect() {
|
||||||
selectedIndex = null
|
selectedIndex = null
|
||||||
|
buttons.forEachIndexed { index, btn ->
|
||||||
|
btn.highlighted = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
|||||||
Reference in New Issue
Block a user