mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 04:54:05 +09:00
game loading is back but newgame is broken
This commit is contained in:
@@ -119,6 +119,8 @@ object LoadSavegame {
|
|||||||
fun getFileBytes(disk: SimpleFileSystem, id: Long): ByteArray64 = disk.getFile(id)!!.bytes
|
fun getFileBytes(disk: SimpleFileSystem, id: Long): ByteArray64 = disk.getFile(id)!!.bytes
|
||||||
fun getFileReader(disk: SimpleFileSystem, id: Long): Reader = ByteArray64Reader(getFileBytes(disk, id), Common.CHARSET)
|
fun getFileReader(disk: SimpleFileSystem, id: Long): Reader = ByteArray64Reader(getFileBytes(disk, id), Common.CHARSET)
|
||||||
|
|
||||||
|
operator fun invoke(diskPair: DiskPair) = invoke(diskPair.player, diskPair.world)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param playerDisk DiskSkimmer representing the Player.
|
* @param playerDisk DiskSkimmer representing the Player.
|
||||||
* @param worldDisk0 DiskSkimmer representing the World to be loaded.
|
* @param worldDisk0 DiskSkimmer representing the World to be loaded.
|
||||||
@@ -126,12 +128,14 @@ object LoadSavegame {
|
|||||||
*/
|
*/
|
||||||
operator fun invoke(playerDisk: DiskSkimmer, worldDisk0: DiskSkimmer? = null) {
|
operator fun invoke(playerDisk: DiskSkimmer, worldDisk0: DiskSkimmer? = null) {
|
||||||
val newIngame = TerrarumIngame(App.batch)
|
val newIngame = TerrarumIngame(App.batch)
|
||||||
|
playerDisk.rebuild()
|
||||||
val player = ReadActor.invoke(playerDisk, ByteArray64Reader(playerDisk.getFile(SAVEGAMEINFO)!!.bytes, Common.CHARSET)) as IngamePlayer
|
val player = ReadActor.invoke(playerDisk, ByteArray64Reader(playerDisk.getFile(SAVEGAMEINFO)!!.bytes, Common.CHARSET)) as IngamePlayer
|
||||||
|
|
||||||
printdbg(this, "Player localhash: ${player.localHashStr}, hasSprite: ${player.sprite != null}")
|
printdbg(this, "Player localhash: ${player.localHashStr}, hasSprite: ${player.sprite != null}")
|
||||||
|
|
||||||
val currentWorldId = player.worldCurrentlyPlaying
|
val currentWorldId = player.worldCurrentlyPlaying
|
||||||
val worldDisk = worldDisk0 ?: App.savegameWorlds[currentWorldId]!!.loadable()
|
val worldDisk = worldDisk0 ?: App.savegameWorlds[currentWorldId]!!.loadable()
|
||||||
|
worldDisk.rebuild()
|
||||||
val world = ReadWorld(ByteArray64Reader(worldDisk.getFile(SAVEGAMEINFO)!!.bytes, Common.CHARSET), worldDisk.diskFile)
|
val world = ReadWorld(ByteArray64Reader(worldDisk.getFile(SAVEGAMEINFO)!!.bytes, Common.CHARSET), worldDisk.diskFile)
|
||||||
|
|
||||||
world.layerTerrain = BlockLayer(world.width, world.height)
|
world.layerTerrain = BlockLayer(world.width, world.height)
|
||||||
|
|||||||
@@ -305,7 +305,8 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
buttonCraft = UIItemTextButton(this, "GAME_ACTION_CRAFT", thisOffsetX + 3 + buttonWidth + listGap, craftButtonsY, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
buttonCraft = UIItemTextButton(this,
|
||||||
|
{ Lang["GAME_ACTION_CRAFT"] }, thisOffsetX + 3 + buttonWidth + listGap, craftButtonsY, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||||
spinnerCraftCount = UIItemSpinner(this, thisOffsetX + 1, craftButtonsY, 1, 1, App.getConfigInt("basegame:gameplay_max_crafting"), 1, buttonWidth, numberToTextFunction = {"×\u200A${it.toInt()}"})
|
spinnerCraftCount = UIItemSpinner(this, thisOffsetX + 1, craftButtonsY, 1, 1, App.getConfigInt("basegame:gameplay_max_crafting"), 1, buttonWidth, numberToTextFunction = {"×\u200A${it.toInt()}"})
|
||||||
spinnerCraftCount.selectionChangeListener = {
|
spinnerCraftCount.selectionChangeListener = {
|
||||||
itemListIngredients.numberMultiplier = it.toLong()
|
itemListIngredients.numberMultiplier = it.toLong()
|
||||||
|
|||||||
@@ -106,13 +106,12 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
|
|
||||||
private val resetButtonWidth = 140
|
private val resetButtonWidth = 140
|
||||||
private val buttonReset = UIItemTextButton(this,
|
private val buttonReset = UIItemTextButton(this,
|
||||||
"MENU_LABEL_RESET",
|
{ Lang["MENU_LABEL_RESET"] },
|
||||||
kbx + (width - resetButtonWidth) / 2,
|
kbx + (width - resetButtonWidth) / 2,
|
||||||
kby + 162 + 12,
|
kby + 162 + 12,
|
||||||
resetButtonWidth,
|
resetButtonWidth,
|
||||||
readFromLang = true,
|
hasBorder = true,
|
||||||
hasBorder = true,
|
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
||||||
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private val controlPalette = UIItemControlPaletteBaloon(this, (Toolkit.drawWidth - 500) / 2, kby + 219)
|
private val controlPalette = UIItemControlPaletteBaloon(this, (Toolkit.drawWidth - 500) / 2, kby + 219)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
|||||||
override fun show() {
|
override fun show() {
|
||||||
super.show()
|
super.show()
|
||||||
|
|
||||||
val loadables = SavegameCollectionPair(App.savegamePlayers[UILoadGovernor.playerUUID], App.savegameWorlds[UILoadGovernor.worldUUID])
|
val loadables = full.loadables
|
||||||
val autoThumb = loadables.getAutoSave()!!.getThumbnail()
|
val autoThumb = loadables.getAutoSave()!!.getThumbnail()
|
||||||
val manualThumb = loadables.getManualSave()!!.getThumbnail()
|
val manualThumb = loadables.getManualSave()!!.getThumbnail()
|
||||||
|
|
||||||
|
|||||||
@@ -69,33 +69,8 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
|
|||||||
fun advanceMode() {
|
fun advanceMode() {
|
||||||
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
|
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
|
||||||
full.loadables = SavegameCollectionPair(App.savegamePlayers[UILoadGovernor.playerUUID], App.savegameWorlds[UILoadGovernor.worldUUID])
|
full.loadables = SavegameCollectionPair(App.savegamePlayers[UILoadGovernor.playerUUID], App.savegameWorlds[UILoadGovernor.worldUUID])
|
||||||
|
full.queueUpManageScr()
|
||||||
|
full.takeAutosaveSelectorDown()
|
||||||
if (full.loadables.moreRecentAutosaveAvailable()) {
|
|
||||||
// make choice for load manual or auto, if available
|
|
||||||
full.hasNewerAutosave = true
|
|
||||||
|
|
||||||
full.queueUpManageScr()
|
|
||||||
full.bringAutosaveSelectorUp()
|
|
||||||
}
|
|
||||||
else if (!full.loadables.saveAvaliable()) {
|
|
||||||
// show save is damaged and cannot be loaded
|
|
||||||
// full.queueUpDamagedSaveScr()
|
|
||||||
full.queueUpManageScr() // management screen will take care of damaged saves
|
|
||||||
full.takeAutosaveSelectorDown()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// val (p, w) = full.loadables.getLoadableSave()!!
|
|
||||||
// UILoadGovernor.playerDisk = p; UILoadGovernor.worldDisk = w
|
|
||||||
|
|
||||||
if (full.loadables.newerSaveIsDamaged) {
|
|
||||||
UILoadGovernor.previousSaveWasLoaded = true
|
|
||||||
}
|
|
||||||
|
|
||||||
full.queueUpManageScr()
|
|
||||||
full.takeAutosaveSelectorDown()
|
|
||||||
}
|
|
||||||
|
|
||||||
full.changePanelTo(1)
|
full.changePanelTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.ui
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Camera
|
import com.badlogic.gdx.graphics.Camera
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
|
import net.torvald.terrarum.gdxClearAndEnableBlend
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.round
|
import net.torvald.terrarum.modulebasegame.serialise.LoadSavegame
|
||||||
import net.torvald.terrarum.ui.Movement
|
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
import net.torvald.terrarum.ui.Toolkit
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarum.ui.UIItemTextButton
|
import net.torvald.terrarum.ui.UIItemTextButton
|
||||||
import kotlin.math.roundToInt
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2023-07-05.
|
* Created by minjaesong on 2023-07-05.
|
||||||
@@ -36,34 +36,56 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
|||||||
private val buttonRowY = drawY + 480 - buttonHeight
|
private val buttonRowY = drawY + 480 - buttonHeight
|
||||||
private val buttonRowY2 = buttonRowY - buttonHeight - buttonGap
|
private val buttonRowY2 = buttonRowY - buttonHeight - buttonGap
|
||||||
|
|
||||||
private val mainGoButton = UIItemTextButton(this, "MENU_IO_LOAD_GAME", buttonX1third, buttonRowY, buttonWidth * 3 + buttonGap * 2, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
private val mainGoButton = UIItemTextButton(this,
|
||||||
|
{ Lang["MENU_IO_LOAD_GAME"] }, buttonX1third, buttonRowY, buttonWidth * 3 + buttonGap * 2, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||||
|
it.clickOnceListener = { _,_ ->
|
||||||
|
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
|
||||||
|
|
||||||
|
if (full.loadables.moreRecentAutosaveAvailable()) {
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
else if (full.loadables.saveAvaliable()) {
|
||||||
|
if (full.loadables.newerSaveIsDamaged) {
|
||||||
|
UILoadGovernor.previousSaveWasLoaded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
full.loadManageSelectedGame = full.loadables.getLoadableSave()!!
|
||||||
|
|
||||||
|
mode = MODE_LOAD
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private val mainNoGoButton = UIItemTextButton(this, "ERROR_SAVE_CORRUPTED", buttonX1third, buttonRowY, buttonWidth * 3 + buttonGap * 2, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
private val mainNoGoButton = UIItemTextButton(this,
|
||||||
|
{ Lang["ERROR_SAVE_CORRUPTED"].replace(".","") }, buttonX1third, buttonRowY, buttonWidth * 3 + buttonGap * 2, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||||
it.isEnabled = false
|
it.isEnabled = false
|
||||||
}
|
}
|
||||||
private val mainReturnButton = UIItemTextButton(this, "MENU_LABEL_BACK", buttonX1third, buttonRowY2, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
private val mainReturnButton = UIItemTextButton(this,
|
||||||
|
{ Lang["MENU_LABEL_BACK"] }, buttonX1third, buttonRowY2, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||||
it.clickOnceListener = { _,_ ->
|
it.clickOnceListener = { _,_ ->
|
||||||
full.changePanelTo(0)
|
full.changePanelTo(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private val mainRenameButton = UIItemTextButton(this, "MENU_LABEL_RENAME", buttonXcentre, buttonRowY2, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
private val mainRenameButton = UIItemTextButton(this,
|
||||||
|
{ Lang["MENU_LABEL_RENAME"] }, buttonXcentre, buttonRowY2, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||||
it.clickOnceListener = { _,_ ->
|
it.clickOnceListener = { _,_ ->
|
||||||
mode = MODE_RENAME
|
mode = MODE_RENAME
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private val mainDeleteButton = UIItemTextButton(this, "CONTEXT_CHARACTER_DELETE", buttonX3third, buttonRowY2, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD).also {
|
private val mainDeleteButton = UIItemTextButton(this,
|
||||||
|
{ Lang["CONTEXT_CHARACTER_DELETE"] }, buttonX3third, buttonRowY2, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD).also {
|
||||||
it.clickOnceListener = { _,_ ->
|
it.clickOnceListener = { _,_ ->
|
||||||
mode = MODE_DELETE
|
mode = MODE_DELETE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val confirmCancelButton = UIItemTextButton(this, "MENU_LABEL_CANCEL", buttonXleft, buttonRowY, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
private val confirmCancelButton = UIItemTextButton(this,
|
||||||
|
{ Lang["MENU_LABEL_CANCEL"] }, buttonXleft, buttonRowY, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||||
it.clickOnceListener = { _,_ ->
|
it.clickOnceListener = { _,_ ->
|
||||||
mode = MODE_INIT
|
mode = MODE_INIT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private val confirmDeleteButton = UIItemTextButton(this, "MENU_LABEL_DELETE", buttonXright, buttonRowY, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD).also {
|
private val confirmDeleteButton = UIItemTextButton(this,
|
||||||
|
{ Lang["MENU_LABEL_DELETE"] }, buttonXright, buttonRowY, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD).also {
|
||||||
it.clickOnceListener = { _,_ ->
|
it.clickOnceListener = { _,_ ->
|
||||||
val pu = full.playerButtonSelected!!.playerUUID
|
val pu = full.playerButtonSelected!!.playerUUID
|
||||||
val wu = full.playerButtonSelected!!.worldUUID
|
val wu = full.playerButtonSelected!!.worldUUID
|
||||||
@@ -89,6 +111,7 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
|||||||
private val MODE_INIT = 0
|
private val MODE_INIT = 0
|
||||||
private val MODE_DELETE = 16 // are you sure?
|
private val MODE_DELETE = 16 // are you sure?
|
||||||
private val MODE_RENAME = 32 // show rename dialogue
|
private val MODE_RENAME = 32 // show rename dialogue
|
||||||
|
private val MODE_LOAD = 256 // is needed to make the static loading screen
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
@@ -113,18 +136,39 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var loadFiredFrameCounter = 0
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
val buttonYdelta = (full.titleTopGradEnd + full.cellInterval) - full.playerButtonSelected!!.posY
|
val buttonYdelta = (full.titleTopGradEnd + full.cellInterval) - full.playerButtonSelected!!.posY
|
||||||
full.playerButtonSelected!!.render(batch, camera, 0, buttonYdelta)
|
full.playerButtonSelected!!.render(batch, camera, 0, buttonYdelta)
|
||||||
|
|
||||||
if (mode == MODE_DELETE) {
|
when (mode) {
|
||||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_LABEL_SAVE_WILL_BE_DELETED"], Toolkit.drawWidth, 0, full.titleTopGradEnd + full.cellInterval - 46)
|
MODE_INIT -> {
|
||||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_LABEL_ARE_YOU_SURE"], Toolkit.drawWidth, 0, full.titleTopGradEnd + full.cellInterval + SAVE_CELL_HEIGHT + 36)
|
mainButtons.forEach { it.render(batch, camera) }
|
||||||
|
}
|
||||||
|
MODE_DELETE -> {
|
||||||
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_LABEL_SAVE_WILL_BE_DELETED"], Toolkit.drawWidth, 0, full.titleTopGradEnd + full.cellInterval - 46)
|
||||||
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_LABEL_ARE_YOU_SURE"], Toolkit.drawWidth, 0, full.titleTopGradEnd + full.cellInterval + SAVE_CELL_HEIGHT + 36)
|
||||||
|
|
||||||
delButtons.forEach { it.render(batch, camera) }
|
delButtons.forEach { it.render(batch, camera) }
|
||||||
}
|
}
|
||||||
else if (mode == MODE_INIT) {
|
MODE_LOAD -> {
|
||||||
mainButtons.forEach { it.render(batch, camera) }
|
loadFiredFrameCounter += 1
|
||||||
|
// to hide the "flipped skybox" artefact
|
||||||
|
batch.end()
|
||||||
|
|
||||||
|
gdxClearAndEnableBlend(.094f, .094f, .094f, 0f)
|
||||||
|
|
||||||
|
batch.begin()
|
||||||
|
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
val txt = Lang["MENU_IO_LOADING"]
|
||||||
|
App.fontGame.draw(batch, txt, (App.scr.width - App.fontGame.getWidth(txt)) / 2f, (App.scr.height - App.fontGame.lineHeight) / 2f)
|
||||||
|
|
||||||
|
if (loadFiredFrameCounter == 2) {
|
||||||
|
LoadSavegame(full.loadManageSelectedGame)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.ui
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Camera
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|
||||||
import net.torvald.terrarum.App
|
|
||||||
import net.torvald.terrarum.langpack.Lang
|
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
|
||||||
import net.torvald.terrarum.ui.UIItemTextButton
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by minjaesong on 2023-07-07.
|
|
||||||
*/
|
|
||||||
class UILoadSaveDamaged(val full: UILoadSavegame) : UICanvas() {
|
|
||||||
|
|
||||||
override var width: Int = Toolkit.drawWidth
|
|
||||||
override var height: Int = App.scr.height
|
|
||||||
|
|
||||||
private val goButtonWidth = 180
|
|
||||||
private val drawX = (Toolkit.drawWidth - 480) / 2
|
|
||||||
private val drawY = (App.scr.height - 480) / 2
|
|
||||||
private val buttonRowY = drawY + 480 - 24
|
|
||||||
private val corruptedBackButton = UIItemTextButton(this, "MENU_LABEL_BACK", (Toolkit.drawWidth - goButtonWidth) / 2, buttonRowY, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
|
||||||
it.clickOnceListener = { _,_ ->
|
|
||||||
full.changePanelTo(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
addUIitem(corruptedBackButton)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateUI(delta: Float) {
|
|
||||||
corruptedBackButton.update(delta)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
|
||||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["ERROR_SAVE_CORRUPTED"], Toolkit.drawWidth, 0, App.scr.height / 2 - 42)
|
|
||||||
|
|
||||||
corruptedBackButton.render(batch, camera)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dispose() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -80,6 +80,8 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
|
|
||||||
internal lateinit var loadables: SavegameCollectionPair // will be used and modified by subUIs
|
internal lateinit var loadables: SavegameCollectionPair // will be used and modified by subUIs
|
||||||
|
|
||||||
|
internal lateinit var loadManageSelectedGame: DiskPair
|
||||||
|
|
||||||
/*private val altSelDrawW = 640
|
/*private val altSelDrawW = 640
|
||||||
private val altSelHdrawW = altSelDrawW / 2
|
private val altSelHdrawW = altSelDrawW / 2
|
||||||
private val altSelDrawH = 480
|
private val altSelDrawH = 480
|
||||||
@@ -89,7 +91,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
private val altSelQdrawW = altSelDrawW / 4
|
private val altSelQdrawW = altSelDrawW / 4
|
||||||
private val altSelQQQdrawW = altSelDrawW * 3 / 4*/
|
private val altSelQQQdrawW = altSelDrawW * 3 / 4*/
|
||||||
|
|
||||||
internal var hasNewerAutosave = false
|
// internal var hasNewerAutosave = false
|
||||||
|
|
||||||
private val transitionalListing = UILoadList(this)
|
private val transitionalListing = UILoadList(this)
|
||||||
private val transitionalAutosave = UILoadAutosave(this)
|
private val transitionalAutosave = UILoadAutosave(this)
|
||||||
@@ -132,7 +134,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
override fun show() {
|
override fun show() {
|
||||||
takeAutosaveSelectorDown()
|
takeAutosaveSelectorDown()
|
||||||
transitionPanel.show()
|
transitionPanel.show()
|
||||||
hasNewerAutosave = false
|
// hasNewerAutosave = false
|
||||||
/*try {
|
/*try {
|
||||||
remoCon.handler.lockToggle()
|
remoCon.handler.lockToggle()
|
||||||
showSpinner = true
|
showSpinner = true
|
||||||
|
|||||||
@@ -40,8 +40,10 @@ class UINewCharacter(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
{ RandomWordsName(4) }, InputLenCap(VirtualDisk.NAME_LENGTH, InputLenCap.CharLenUnit.UTF8_BYTES))
|
{ RandomWordsName(4) }, InputLenCap(VirtualDisk.NAME_LENGTH, InputLenCap.CharLenUnit.UTF8_BYTES))
|
||||||
|
|
||||||
private val goButtonWidth = 180
|
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 backButton = UIItemTextButton(this,
|
||||||
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)
|
{ Lang["MENU_LABEL_BACK"] }, drawX + (width/2 - goButtonWidth) / 2, drawY + height - 24, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||||
|
private val goButton = UIItemTextButton(this,
|
||||||
|
{ Lang["MENU_LABEL_CONFIRM_BUTTON"] }, drawX + width/2 + (width/2 - goButtonWidth) / 2, drawY + height - 24, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||||
|
|
||||||
private var returnedFromChargen = false
|
private var returnedFromChargen = false
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,10 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
{ rng.nextLong().toString() }, InputLenCap(256, InputLenCap.CharLenUnit.CODEPOINTS))
|
{ rng.nextLong().toString() }, InputLenCap(256, InputLenCap.CharLenUnit.CODEPOINTS))
|
||||||
|
|
||||||
private val goButtonWidth = 180
|
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 backButton = UIItemTextButton(this,
|
||||||
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)
|
{ Lang["MENU_LABEL_BACK"] }, drawX + (width/2 - goButtonWidth) / 2, drawY + height - 24, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||||
|
private val goButton = UIItemTextButton(this,
|
||||||
|
{ Lang["MENU_LABEL_CONFIRM_BUTTON"] }, drawX + width/2 + (width/2 - goButtonWidth) / 2, drawY + height - 24, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.QNDTreeNode
|
|||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.Yaml
|
import net.torvald.terrarum.Yaml
|
||||||
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
|
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.TitleScreen
|
import net.torvald.terrarum.modulebasegame.TitleScreen
|
||||||
import net.torvald.terrarum.serialise.WriteConfig
|
import net.torvald.terrarum.serialise.WriteConfig
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
import net.torvald.terrarum.ui.Toolkit
|
||||||
@@ -100,11 +101,11 @@ open class UIRemoCon(val parent: TitleScreen, val treeRoot: QNDTreeNode<String>)
|
|||||||
oldSelectedItem?.highlighted = false
|
oldSelectedItem?.highlighted = false
|
||||||
|
|
||||||
// selection change
|
// selection change
|
||||||
if (it.labelText == "MENU_LABEL_QUIT") {
|
if (it.textfun() == Lang["MENU_LABEL_QUIT"]) {
|
||||||
//System.exit(0)
|
//System.exit(0)
|
||||||
Gdx.app.exit()
|
Gdx.app.exit()
|
||||||
}
|
}
|
||||||
else if (it.labelText.startsWith("MENU_LABEL_RETURN")) {
|
else if (it.textfun() == Lang["MENU_LABEL_RETURN"]) {
|
||||||
val tag = it.tags
|
val tag = it.tags
|
||||||
if (tag.contains("WRITETOCONFIG")) WriteConfig()
|
if (tag.contains("WRITETOCONFIG")) WriteConfig()
|
||||||
|
|
||||||
|
|||||||
@@ -80,12 +80,12 @@ class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
|
|
||||||
// highlight initial
|
// highlight initial
|
||||||
textArea1.buttons.forEachIndexed { index, it ->
|
textArea1.buttons.forEachIndexed { index, it ->
|
||||||
if (it.labelText == Lang["MENU_LANGUAGE_THIS"]) {
|
if (it.textfun() == Lang["MENU_LANGUAGE_THIS"]) {
|
||||||
textArea1.select(index)
|
textArea1.select(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
textArea2.buttons.forEachIndexed { index, it ->
|
textArea2.buttons.forEachIndexed { index, it ->
|
||||||
if (it.labelText == Lang["MENU_LANGUAGE_THIS"]) {
|
if (it.textfun() == Lang["MENU_LANGUAGE_THIS"]) {
|
||||||
textArea2.select(index)
|
textArea2.select(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class UIWorldPortal : UICanvas(
|
|||||||
App.scr.height,
|
App.scr.height,
|
||||||
0f,
|
0f,
|
||||||
listOf(transitionalListing),
|
listOf(transitionalListing),
|
||||||
listOf(),
|
listOf(transitionalSearch),
|
||||||
listOf()
|
listOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -68,11 +68,10 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
private val buttonsY = y + listHeight + gridGap
|
private val buttonsY = y + listHeight + gridGap
|
||||||
|
|
||||||
private val buttonSearch = UIItemTextButton(this,
|
private val buttonSearch = UIItemTextButton(this,
|
||||||
"CONTEXT_WORLD_NEW",
|
{ Lang["CONTEXT_WORLD_NEW"] },
|
||||||
hx - gridGap/2 - 2*deleteButtonWidth - gridGap,
|
hx - gridGap/2 - 2*deleteButtonWidth - gridGap,
|
||||||
buttonsY,
|
buttonsY,
|
||||||
deleteButtonWidth,
|
deleteButtonWidth,
|
||||||
readFromLang = true,
|
|
||||||
hasBorder = true,
|
hasBorder = true,
|
||||||
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
||||||
).also {
|
).also {
|
||||||
@@ -81,11 +80,10 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private val buttonTeleport = UIItemTextButton(this,
|
private val buttonTeleport = UIItemTextButton(this,
|
||||||
"GAME_ACTION_TELEPORT",
|
{ Lang["GAME_ACTION_TELEPORT"] },
|
||||||
hx - gridGap/2 - deleteButtonWidth,
|
hx - gridGap/2 - deleteButtonWidth,
|
||||||
buttonsY,
|
buttonsY,
|
||||||
deleteButtonWidth,
|
deleteButtonWidth,
|
||||||
readFromLang = true,
|
|
||||||
hasBorder = true,
|
hasBorder = true,
|
||||||
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
||||||
).also {
|
).also {
|
||||||
@@ -100,20 +98,18 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private val buttonRename = UIItemTextButton(this,
|
private val buttonRename = UIItemTextButton(this,
|
||||||
"MENU_LABEL_RENAME",
|
{ Lang["MENU_LABEL_RENAME"] },
|
||||||
hx + gridGap/2,
|
hx + gridGap/2,
|
||||||
buttonsY,
|
buttonsY,
|
||||||
deleteButtonWidth,
|
deleteButtonWidth,
|
||||||
readFromLang = true,
|
|
||||||
hasBorder = true,
|
hasBorder = true,
|
||||||
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
||||||
)
|
)
|
||||||
private val buttonDelete = UIItemTextButton(this,
|
private val buttonDelete = UIItemTextButton(this,
|
||||||
"MENU_LABEL_DELETE",
|
{ Lang["MENU_LABEL_DELETE"] },
|
||||||
hx + gridGap/2 + deleteButtonWidth + gridGap,
|
hx + gridGap/2 + deleteButtonWidth + gridGap,
|
||||||
buttonsY,
|
buttonsY,
|
||||||
deleteButtonWidth,
|
deleteButtonWidth,
|
||||||
readFromLang = true,
|
|
||||||
hasBorder = true,
|
hasBorder = true,
|
||||||
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
alignment = UIItemTextButton.Companion.Alignment.CENTRE
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -78,8 +78,10 @@ class UIWorldPortalSearch(val full: UIWorldPortal) : UICanvas() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
private val goButtonWidth = 180
|
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 backButton = UIItemTextButton(this,
|
||||||
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)
|
{ Lang["MENU_LABEL_BACK"] }, drawX + (width/2 - goButtonWidth) / 2, drawY + height - 24, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||||
|
private val goButton = UIItemTextButton(this,
|
||||||
|
{ Lang["MENU_LABEL_CONFIRM_BUTTON"] }, drawX + width/2 + (width/2 - goButtonWidth) / 2, drawY + height - 24, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
goButton.clickOnceListener = { _, _ ->
|
goButton.clickOnceListener = { _, _ ->
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ import net.torvald.terrarum.langpack.Lang
|
|||||||
open class UIItemTextButton(
|
open class UIItemTextButton(
|
||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
/** Stored text (independent to the Langpack) */
|
/** Stored text (independent to the Langpack) */
|
||||||
val labelText: String,
|
val textfun: () -> String,
|
||||||
initialX: Int,
|
initialX: Int,
|
||||||
initialY: Int,
|
initialY: Int,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
val readFromLang: Boolean = false,
|
|
||||||
|
|
||||||
/** Colour when mouse is over */
|
/** Colour when mouse is over */
|
||||||
var activeCol: Color = Toolkit.Theme.COL_MOUSE_UP,
|
var activeCol: Color = Toolkit.Theme.COL_MOUSE_UP,
|
||||||
@@ -38,6 +37,7 @@ open class UIItemTextButton(
|
|||||||
var inactiveCol: Color = Toolkit.Theme.COL_LIST_DEFAULT,
|
var inactiveCol: Color = Toolkit.Theme.COL_LIST_DEFAULT,
|
||||||
|
|
||||||
var disabledCol: Color = Toolkit.Theme.COL_INVENTORY_CELL_BORDER,
|
var disabledCol: Color = Toolkit.Theme.COL_INVENTORY_CELL_BORDER,
|
||||||
|
var disabledTextCol: Color = Color(0x888888FF.toInt()),
|
||||||
|
|
||||||
val hasBorder: Boolean = false,
|
val hasBorder: Boolean = false,
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ open class UIItemTextButton(
|
|||||||
|
|
||||||
/** Actually displayed text (changes with the app language) */
|
/** Actually displayed text (changes with the app language) */
|
||||||
val label: String
|
val label: String
|
||||||
get() = if (readFromLang) Lang[labelText] else labelText
|
get() = textfun()
|
||||||
|
|
||||||
|
|
||||||
override val height: Int = hitboxSize
|
override val height: Int = hitboxSize
|
||||||
@@ -128,6 +128,7 @@ open class UIItemTextButton(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
|
if (!isEnabled) batch.color = disabledTextCol
|
||||||
font.draw(batch, label, fontX, fontY)
|
font.draw(batch, label, fontX, fontY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|||||||
import net.torvald.terrarum.BlendMode
|
import net.torvald.terrarum.BlendMode
|
||||||
import net.torvald.terrarum.Second
|
import net.torvald.terrarum.Second
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.toInt
|
import net.torvald.terrarum.toInt
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
@@ -79,13 +80,15 @@ class UIItemTextButtonList(
|
|||||||
val lh = itemHitboxSize
|
val lh = itemHitboxSize
|
||||||
val vertOff = lineHeight * i
|
val vertOff = lineHeight * i
|
||||||
|
|
||||||
|
val ld0 = { s }
|
||||||
|
val ld1 = { Lang[s] }
|
||||||
|
|
||||||
// if (!kinematic) {
|
// if (!kinematic) {
|
||||||
UIItemTextButton(
|
UIItemTextButton(
|
||||||
parentUI, s,
|
parentUI, if (readFromLang) ld1 else ld0,
|
||||||
initialX = posX,
|
initialX = posX,
|
||||||
initialY = posY + vertOff,
|
initialY = posY + vertOff,
|
||||||
width = width,
|
width = width,
|
||||||
readFromLang = readFromLang,
|
|
||||||
activeCol = activeCol,
|
activeCol = activeCol,
|
||||||
activeBackCol = activeBackCol,
|
activeBackCol = activeBackCol,
|
||||||
activeBackBlendMode = activeBackBlendMode,
|
activeBackBlendMode = activeBackBlendMode,
|
||||||
|
|||||||
Reference in New Issue
Block a user