some more new world ui thingies/fixed a bug where drawing an inventory background would cause a segfault

This commit is contained in:
minjaesong
2021-10-26 14:12:16 +09:00
parent d8aed8a34c
commit 08518fff06
11 changed files with 105 additions and 90 deletions

View File

@@ -42,7 +42,6 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
textAreaWidth = gameMenuListWidth,
activeBackCol = Color(0),
highlightBackCol = Color(0),
backgroundCol = Color(0),
inactiveCol = Color.WHITE,
defaultSelection = null
)
@@ -55,7 +54,6 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
textAreaWidth = gameMenuListWidth,
activeBackCol = Color(0),
highlightBackCol = Color(0),
backgroundCol = Color(0),
inactiveCol = Color.WHITE,
defaultSelection = null
)
@@ -68,7 +66,6 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
textAreaWidth = gameMenuListWidth,
activeBackCol = Color(0),
highlightBackCol = Color(0),
backgroundCol = Color(0),
inactiveCol = Color.WHITE,
defaultSelection = null
)

View File

@@ -34,6 +34,9 @@ class UIInventoryFull(
override var openCloseTime: Second = 0.0f
companion object {
private var shapeRenderer: ShapeRenderer? = null
val CELL_COL = Toolkit.Theme.COL_CELL_FILL
const val INVEN_DEBUG_MODE = false
@@ -62,24 +65,28 @@ class UIInventoryFull(
val controlHelpHeight = App.fontGame.lineHeight
fun drawBackground(batch: SpriteBatch, shapeRenderer: ShapeRenderer) {
fun drawBackground(batch: SpriteBatch) {
batch.end()
gdxSetBlendNormal()
if (shapeRenderer == null) {
shapeRenderer = ShapeRenderer()
App.disposables.add(shapeRenderer)
}
val gradTopStart = (App.scr.height - internalHeight).div(2).toFloat()
val gradBottomEnd = App.scr.height - gradTopStart
shapeRenderer.inUse {
shapeRenderer!!.inUse {
// shaperender starts at bottom-left!
it.rect(0f, gradTopStart, App.scr.wf, gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
it.rect(0f, gradBottomEnd, App.scr.wf, -gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
shapeRenderer.rect(0f, gradTopStart, App.scr.wf, gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
shapeRenderer.rect(0f, gradBottomEnd, App.scr.wf, -gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
it.rect(0f, gradTopStart + gradHeight, App.scr.wf, internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol)
shapeRenderer.rect(0f, gradTopStart + gradHeight, App.scr.wf, internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol)
shapeRenderer.rect(0f, 0f, App.scr.wf, gradTopStart, gradStartCol, gradStartCol, gradStartCol, gradStartCol)
shapeRenderer.rect(0f, App.scr.hf, App.scr.wf, -(App.scr.hf - gradBottomEnd), gradStartCol, gradStartCol, gradStartCol, gradStartCol)
it.rect(0f, 0f, App.scr.wf, gradTopStart, gradStartCol, gradStartCol, gradStartCol, gradStartCol)
it.rect(0f, App.scr.hf, App.scr.wf, -(App.scr.hf - gradBottomEnd), gradStartCol, gradStartCol, gradStartCol, gradStartCol)
}
batch.begin()
@@ -235,7 +242,6 @@ class UIInventoryFull(
//private val gradStartCol = Color(0x404040_60)
//private val gradEndCol = Color(0x000000_70)
//private val gradHeight = 48f
private val shapeRenderer = ShapeRenderer()
internal var xEnd = (width + internalWidth).div(2).toFloat()
private set
@@ -244,7 +250,7 @@ class UIInventoryFull(
override fun renderUI(batch: SpriteBatch, camera: Camera) {
drawBackground(batch, shapeRenderer)
drawBackground(batch)
// UI items
catBar.render(batch, camera)
@@ -274,7 +280,6 @@ class UIInventoryFull(
override fun dispose() {
catBar.dispose()
transitionPanel.dispose()
}

View File

@@ -5,7 +5,9 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.random.HQRNG
import net.torvald.terrarum.App
import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.Second
import net.torvald.terrarum.langpack.Lang
@@ -50,23 +52,35 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
{ Lang["CONTEXT_DESCRIPTION_HUGE"] }
))
private val rng = HQRNG()
private val nameInput = UIItemTextLineInput(this,
drawX + width - inputWidth, drawY + sizeSelY + 80, inputWidth,
{ RandomWordsName(4) }, InputLenCap(VirtualDisk.NAME_LENGTH, InputLenCap.CharLenUnit.UTF8_BYTES))
private val seedInput = UIItemTextLineInput(this,
drawX + width - inputWidth, drawY + sizeSelY + 120, inputWidth,
{ RandomWordsName(4) }, InputLenCap(256, InputLenCap.CharLenUnit.CODEPOINTS))
{ rng.nextLong().toString() }, InputLenCap(256, InputLenCap.CharLenUnit.CODEPOINTS))
private val goButtonWidth = 180
private val backButton = UIItemTextButton(this, "MENU_LABEL_BACK", drawX + (width/2 - goButtonWidth) / 2, drawY + height - 24, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
private val goButton = UIItemTextButton(this, "MENU_LABEL_CONFIRM_BUTTON", drawX + width/2 + (width/2 - goButtonWidth) / 2, drawY + height - 24, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
init {
tex.forEach { it.flip(false, true) }
sizeSelector.selectionChangeListener = {}
goButton.touchDownListener = { _, _, _, _ ->
printdbg(this, "generate!")
}
backButton.touchDownListener = { _, _, _, _ ->
printdbg(this, "back!")
}
addUIitem(sizeSelector)
addUIitem(nameInput)
addUIitem(seedInput)
addUIitem(goButton)
addUIitem(backButton)
}

View File

@@ -245,7 +245,6 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
readFromLang = true,
activeBackCol = Color(0),//Color(1f,0f,.75f,1f),
highlightBackCol = Color(0),
backgroundCol = Color(0),
inactiveCol = Color.WHITE,
defaultSelection = null,
itemHitboxSize = lineHeight - 2,

View File

@@ -39,7 +39,6 @@ class UITitleLanguage(val remoCon: UIRemoCon) : UICanvas() {
readFromLang = false,
activeBackCol = Color(0),
highlightBackCol = Color(0),
backgroundCol = Color(0),
inactiveCol = Color.WHITE,
defaultSelection = null
)
@@ -52,7 +51,6 @@ class UITitleLanguage(val remoCon: UIRemoCon) : UICanvas() {
readFromLang = false,
activeBackCol = Color(0),
highlightBackCol = Color(0),
backgroundCol = Color(0),
inactiveCol = Color.WHITE,
defaultSelection = null
)