mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 21:14:04 +09:00
RemoCons fully working; also fixed my stupidity
This commit is contained in:
@@ -3,6 +3,8 @@ package net.torvald.terrarum.ui
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.CreditSingleton
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
|
||||
class UITitleRemoConCredits(val superMenu: UICanvas) : UICanvas() {
|
||||
@@ -20,9 +22,20 @@ class UITitleRemoConCredits(val superMenu: UICanvas) : UICanvas() {
|
||||
override var openCloseTime: Second = 0f
|
||||
|
||||
|
||||
private val textAreaHMargin = 48
|
||||
private val textAreaWidth = (Terrarum.WIDTH * 0.75).toInt()
|
||||
private val textAreaHeight = Terrarum.HEIGHT - textAreaHMargin * 2
|
||||
private val textArea = UIItemTextArea(this,
|
||||
Terrarum.WIDTH - textAreaWidth, textAreaHMargin,
|
||||
textAreaWidth, textAreaHeight
|
||||
)
|
||||
private var drawTextArea = true
|
||||
|
||||
|
||||
private val menubar = UIItemTextButtonList(
|
||||
this,
|
||||
menuLabels,
|
||||
0, UITitleRemoConRoot.menubarOffY,
|
||||
this.width, this.height,
|
||||
textAreaWidth = this.width,
|
||||
readFromLang = true,
|
||||
@@ -30,26 +43,55 @@ class UITitleRemoConCredits(val superMenu: UICanvas) : UICanvas() {
|
||||
highlightBackCol = Color(0),
|
||||
backgroundCol = Color(0),
|
||||
inactiveCol = Color.WHITE,
|
||||
defaultSelection = null
|
||||
defaultSelection = 0 // show CREDITS
|
||||
)
|
||||
|
||||
init {
|
||||
uiItems.add(menubar)
|
||||
uiItems.add(textArea)
|
||||
|
||||
|
||||
|
||||
////////////////////////////
|
||||
|
||||
|
||||
|
||||
// attach listeners
|
||||
menubar.buttons[menuLabels.indexOf("MENU_LABEL_RETURN")].clickOnceListener = { _, _, _ ->
|
||||
menubar.selectedIndex = menubar.defaultSelection
|
||||
this.setAsClose()
|
||||
superMenu.setAsOpen()
|
||||
}
|
||||
|
||||
menubar.selectionChangeListener = { _, newIndex ->
|
||||
textArea.scrollPos = 0
|
||||
|
||||
if (newIndex == menuLabels.indexOf("MENU_LABEL_CREDITS")) {
|
||||
textArea.setWallOfText(CreditSingleton.credit)
|
||||
drawTextArea = true
|
||||
}
|
||||
else if (newIndex == menuLabels.indexOf("MENU_CREDIT_GPL_DNT")) {
|
||||
textArea.setWallOfText(CreditSingleton.gpl3)
|
||||
drawTextArea = true
|
||||
}
|
||||
else {
|
||||
drawTextArea = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
menubar.update(delta)
|
||||
if (drawTextArea) {
|
||||
textArea.update(delta)
|
||||
}
|
||||
}
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
menubar.render(batch)
|
||||
if (drawTextArea) {
|
||||
textArea.render(batch)
|
||||
}
|
||||
}
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
|
||||
Reference in New Issue
Block a user