mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 04:24:05 +09:00
some sort of error screen impl
This commit is contained in:
@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.dataclass.HistoryArray
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppLoader
|
||||
import net.torvald.terrarum.console.Authenticator
|
||||
import net.torvald.terrarum.console.CommandInterpreter
|
||||
import net.torvald.terrarum.fillRect
|
||||
@@ -180,7 +181,7 @@ class ConsoleWindow : UICanvas() {
|
||||
commandInputPool = StringBuilder()
|
||||
|
||||
if (Authenticator.b()) {
|
||||
sendMessage("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
|
||||
sendMessage("${Terrarum.NAME} ${TerrarumAppLoader.getVERSION_STRING()}")
|
||||
sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class UIItemList<Item: UIItem>(
|
||||
init {
|
||||
itemList.forEachIndexed { index, item ->
|
||||
item.posX = this.posX
|
||||
item.posY = if (index == 0) this.posY else itemList[index - 1].posY + itemList[index - 1].height + this.posY
|
||||
item.posY = if (index == 0) this.posY else itemList[index - 1].posY + itemList[index - 1].height
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.gameactors.floor
|
||||
|
||||
class UIItemModuleInfoCell(
|
||||
@@ -19,47 +20,49 @@ class UIItemModuleInfoCell(
|
||||
private val numberAreaWidth = Terrarum.fontSmallNumbers.W * 3 + 4
|
||||
|
||||
override fun render(batch: SpriteBatch) {
|
||||
blendNormal()
|
||||
|
||||
if (ModMgr.moduleInfo.containsKey(moduleName)) {
|
||||
val modInfo = ModMgr.moduleInfo[moduleName]!!
|
||||
|
||||
// print load order index
|
||||
batch.color = Color(0x7f7f7fff)
|
||||
batch.color = Color(0xccccccff.toInt())
|
||||
var strlen = Terrarum.fontSmallNumbers.getWidth(modInfo.order.toString())
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
modInfo.order.toString(),
|
||||
(numberAreaWidth - strlen).div(2f).floor(),
|
||||
(height - Terrarum.fontSmallNumbers.H).div(2f).floor()
|
||||
posX + (numberAreaWidth - strlen).div(2f).floor(),
|
||||
posY + (height - Terrarum.fontSmallNumbers.H).div(2f).floor()
|
||||
)
|
||||
|
||||
// print module name
|
||||
batch.color = Color.WHITE
|
||||
Terrarum.fontGame.draw(batch,
|
||||
"${modInfo.properName} (${modInfo.version})",
|
||||
numberAreaWidth.toFloat(),
|
||||
0f
|
||||
posX + numberAreaWidth.toFloat(),
|
||||
posY.toFloat()
|
||||
)
|
||||
|
||||
// print author name
|
||||
strlen = Terrarum.fontGame.getWidth(modInfo.author)
|
||||
Terrarum.fontGame.draw(batch,
|
||||
modInfo.author,
|
||||
width - strlen.toFloat(),
|
||||
0f
|
||||
posX + width - strlen.toFloat(),
|
||||
posY.toFloat()
|
||||
)
|
||||
|
||||
// print description
|
||||
Terrarum.fontGame.draw(batch,
|
||||
modInfo.description,
|
||||
numberAreaWidth.toFloat(),
|
||||
Terrarum.fontGame.lineHeight
|
||||
posX + numberAreaWidth.toFloat(),
|
||||
posY + Terrarum.fontGame.lineHeight
|
||||
)
|
||||
|
||||
// print releasedate
|
||||
strlen = Terrarum.fontGame.getWidth(modInfo.releaseDate)
|
||||
Terrarum.fontGame.draw(batch,
|
||||
modInfo.releaseDate,
|
||||
width - strlen.toFloat(),
|
||||
Terrarum.fontGame.lineHeight
|
||||
posX + width - strlen.toFloat(),
|
||||
posY + Terrarum.fontGame.lineHeight
|
||||
)
|
||||
|
||||
}
|
||||
@@ -69,8 +72,8 @@ class UIItemModuleInfoCell(
|
||||
val strlen = Terrarum.fontSmallNumbers.getWidth(str)
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
str,
|
||||
(width - numberAreaWidth - strlen).div(2f).floor() + numberAreaWidth,
|
||||
(height - Terrarum.fontSmallNumbers.H).div(2f).floor()
|
||||
posX + (width - numberAreaWidth - strlen).div(2f).floor() + numberAreaWidth,
|
||||
posY + (height - Terrarum.fontSmallNumbers.H).div(2f).floor()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,16 @@ 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.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-08-01.
|
||||
*/
|
||||
/*class UITitleRemoConModules(val superMenu: UICanvas) : UICanvas() {
|
||||
class UITitleRemoConModules(val superMenu: UICanvas) : UICanvas() {
|
||||
|
||||
val menuLabels = arrayOf(
|
||||
"MENU_LABEL_RETURN"
|
||||
@@ -22,9 +24,7 @@ import net.torvald.terrarum.langpack.Lang
|
||||
override var openCloseTime: Second = 0f
|
||||
|
||||
|
||||
private val moduleListWidth = Terrarum.WIDTH / 2
|
||||
|
||||
private val moduleList = UIItemList<UIItemModuleInfoCell>(
|
||||
private val menubar = UIItemTextButtonList(
|
||||
this,
|
||||
menuLabels,
|
||||
0, UITitleRemoConRoot.menubarOffY,
|
||||
@@ -39,44 +39,44 @@ import net.torvald.terrarum.langpack.Lang
|
||||
)
|
||||
|
||||
|
||||
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,
|
||||
align = UIItemTextArea.Align.CENTRE
|
||||
)*/
|
||||
private val localeList = Lang.languageList.toList().sorted()
|
||||
private val textArea = UIItemTextButtonList(this,
|
||||
localeList.map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }.toTypedArray(),
|
||||
Terrarum.WIDTH - textAreaWidth, textAreaHMargin,
|
||||
textAreaWidth, textAreaHeight,
|
||||
textAreaWidth = textAreaWidth,
|
||||
readFromLang = false,
|
||||
activeBackCol = Color(0),
|
||||
highlightBackCol = Color(0),
|
||||
backgroundCol = Color(0),
|
||||
inactiveCol = Color.WHITE,
|
||||
defaultSelection = null
|
||||
private val moduleAreaHMargin = 48
|
||||
private val moduleAreaWidth = (Terrarum.WIDTH * 0.75).toInt() - moduleAreaHMargin
|
||||
private val moduleAreaHeight = Terrarum.HEIGHT - moduleAreaHMargin * 2
|
||||
|
||||
private val moduleInfoCells = ArrayList<UIItemModuleInfoCell>()
|
||||
// build module list
|
||||
init {
|
||||
ModMgr.moduleInfo.toList().sortedBy { it.second.order }.forEachIndexed { index, it ->
|
||||
moduleInfoCells.add(UIItemModuleInfoCell(
|
||||
this,
|
||||
it.first,
|
||||
moduleAreaWidth,
|
||||
0, 0 // placeholder
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
private val mouduleArea = UIItemList<UIItemModuleInfoCell>(
|
||||
this,
|
||||
moduleInfoCells,
|
||||
(Terrarum.WIDTH * 0.25f).toInt(), moduleAreaHMargin,
|
||||
moduleAreaWidth,
|
||||
moduleAreaHeight,
|
||||
inactiveCol = Color.WHITE
|
||||
)
|
||||
|
||||
|
||||
init {
|
||||
uiItems.add(menubar)
|
||||
uiItems.add(mouduleArea)
|
||||
|
||||
|
||||
//textArea.entireText = Lang.languageList.toList().sorted().map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }
|
||||
|
||||
////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
// attach listeners
|
||||
textArea.selectionChangeListener = { _, newSelectionIndex ->
|
||||
Terrarum.gameLocale = localeList[newSelectionIndex]
|
||||
}
|
||||
|
||||
menubar.buttons[menuLabels.indexOf("MENU_LABEL_RETURN")].clickOnceListener = { _, _, _ ->
|
||||
this.setAsClose()
|
||||
@@ -88,14 +88,15 @@ import net.torvald.terrarum.langpack.Lang
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
menubar.update(delta)
|
||||
textArea.update(delta)
|
||||
mouduleArea.update(delta)
|
||||
}
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
menubar.render(batch)
|
||||
|
||||
batch.color = Color.WHITE
|
||||
textArea.render(batch)
|
||||
blendNormal()
|
||||
mouduleArea.render(batch)
|
||||
}
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
@@ -113,4 +114,4 @@ import net.torvald.terrarum.langpack.Lang
|
||||
override fun dispose() {
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
@@ -3,6 +3,9 @@ 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.random.HQRNG
|
||||
import net.torvald.terrarum.Ingame
|
||||
import net.torvald.terrarum.LoadScreen
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
class UITitleRemoConRoot : UICanvas() {
|
||||
@@ -45,20 +48,20 @@ class UITitleRemoConRoot : UICanvas() {
|
||||
)
|
||||
|
||||
|
||||
//private val paneCredits = UIHandler()
|
||||
private val remoConCredits = UITitleRemoConCredits(this)
|
||||
|
||||
private val remoConLanguage = UITitleRemoConLanguage(this)
|
||||
|
||||
private val remoConModules = UITitleRemoConModules(this)
|
||||
|
||||
init {
|
||||
remoConLanguage.setPosition(0, 0)
|
||||
remoConCredits.setPosition(0, 0)
|
||||
remoConModules.setPosition(0, 0)
|
||||
|
||||
|
||||
|
||||
addSubUI(remoConLanguage)
|
||||
addSubUI(remoConCredits)
|
||||
addSubUI(remoConModules)
|
||||
|
||||
|
||||
////////////////////////////
|
||||
@@ -68,6 +71,26 @@ class UITitleRemoConRoot : UICanvas() {
|
||||
|
||||
|
||||
// attach listeners
|
||||
|
||||
// TEST TEST TEST
|
||||
menubar.buttons[menuLabels.indexOf("MENU_MODE_SINGLEPLAYER")].clickOnceListener = { _, _, _ ->
|
||||
this.setAsClose()
|
||||
Thread.sleep(50)
|
||||
|
||||
Terrarum.ingame = Ingame(Terrarum.batch)
|
||||
Terrarum.ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong())
|
||||
Terrarum.ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW
|
||||
LoadScreen.screenToLoad = Terrarum.ingame!!
|
||||
Terrarum.setScreen(LoadScreen)
|
||||
}
|
||||
|
||||
|
||||
|
||||
menubar.buttons[menuLabels.indexOf("MENU_MODULES")].clickOnceListener = { _, _, _ ->
|
||||
this.setAsClose()
|
||||
Thread.sleep(50)
|
||||
remoConModules.setAsOpen()
|
||||
}
|
||||
menubar.buttons[menuLabels.indexOf("MENU_LABEL_LANGUAGE")].clickOnceListener = { _, _, _ ->
|
||||
this.setAsClose()
|
||||
Thread.sleep(50)
|
||||
|
||||
Reference in New Issue
Block a user