game loading is back but newgame is broken

This commit is contained in:
minjaesong
2023-07-08 21:53:19 +09:00
parent 325e67f999
commit 03c6061a12
17 changed files with 111 additions and 126 deletions

View File

@@ -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.selectionChangeListener = {
itemListIngredients.numberMultiplier = it.toLong()

View File

@@ -106,13 +106,12 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
private val resetButtonWidth = 140
private val buttonReset = UIItemTextButton(this,
"MENU_LABEL_RESET",
kbx + (width - resetButtonWidth) / 2,
kby + 162 + 12,
resetButtonWidth,
readFromLang = true,
hasBorder = true,
alignment = UIItemTextButton.Companion.Alignment.CENTRE
{ Lang["MENU_LABEL_RESET"] },
kbx + (width - resetButtonWidth) / 2,
kby + 162 + 12,
resetButtonWidth,
hasBorder = true,
alignment = UIItemTextButton.Companion.Alignment.CENTRE
)
private val controlPalette = UIItemControlPaletteBaloon(this, (Toolkit.drawWidth - 500) / 2, kby + 219)

View File

@@ -46,7 +46,7 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
override fun show() {
super.show()
val loadables = SavegameCollectionPair(App.savegamePlayers[UILoadGovernor.playerUUID], App.savegameWorlds[UILoadGovernor.worldUUID])
val loadables = full.loadables
val autoThumb = loadables.getAutoSave()!!.getThumbnail()
val manualThumb = loadables.getManualSave()!!.getThumbnail()

View File

@@ -69,33 +69,8 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
fun advanceMode() {
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
full.loadables = SavegameCollectionPair(App.savegamePlayers[UILoadGovernor.playerUUID], App.savegameWorlds[UILoadGovernor.worldUUID])
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.queueUpManageScr()
full.takeAutosaveSelectorDown()
full.changePanelTo(1)
}

View File

@@ -1,15 +1,15 @@
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.gdxClearAndEnableBlend
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.round
import net.torvald.terrarum.ui.Movement
import net.torvald.terrarum.modulebasegame.serialise.LoadSavegame
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemTextButton
import kotlin.math.roundToInt
/**
* 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 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
}
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 = { _,_ ->
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 = { _,_ ->
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 = { _,_ ->
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 = { _,_ ->
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 = { _,_ ->
val pu = full.playerButtonSelected!!.playerUUID
val wu = full.playerButtonSelected!!.worldUUID
@@ -89,6 +111,7 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
private val MODE_INIT = 0
private val MODE_DELETE = 16 // are you sure?
private val MODE_RENAME = 32 // show rename dialogue
private val MODE_LOAD = 256 // is needed to make the static loading screen
init {
@@ -113,18 +136,39 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
}
}
private var loadFiredFrameCounter = 0
override fun renderUI(batch: SpriteBatch, camera: Camera) {
val buttonYdelta = (full.titleTopGradEnd + full.cellInterval) - full.playerButtonSelected!!.posY
full.playerButtonSelected!!.render(batch, camera, 0, buttonYdelta)
if (mode == 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)
when (mode) {
MODE_INIT -> {
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) }
}
else if (mode == MODE_INIT) {
mainButtons.forEach { it.render(batch, camera) }
delButtons.forEach { it.render(batch, camera) }
}
MODE_LOAD -> {
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)
}
}
}
}

View File

@@ -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() {
}
}

View File

@@ -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 loadManageSelectedGame: DiskPair
/*private val altSelDrawW = 640
private val altSelHdrawW = altSelDrawW / 2
private val altSelDrawH = 480
@@ -89,7 +91,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
private val altSelQdrawW = altSelDrawW / 4
private val altSelQQQdrawW = altSelDrawW * 3 / 4*/
internal var hasNewerAutosave = false
// internal var hasNewerAutosave = false
private val transitionalListing = UILoadList(this)
private val transitionalAutosave = UILoadAutosave(this)
@@ -132,7 +134,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
override fun show() {
takeAutosaveSelectorDown()
transitionPanel.show()
hasNewerAutosave = false
// hasNewerAutosave = false
/*try {
remoCon.handler.lockToggle()
showSpinner = true

View File

@@ -40,8 +40,10 @@ class UINewCharacter(val remoCon: UIRemoCon) : UICanvas() {
{ RandomWordsName(4) }, InputLenCap(VirtualDisk.NAME_LENGTH, InputLenCap.CharLenUnit.UTF8_BYTES))
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)
private val backButton = UIItemTextButton(this,
{ 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

View File

@@ -85,8 +85,10 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
{ 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)
private val backButton = UIItemTextButton(this,
{ 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 {

View File

@@ -10,6 +10,7 @@ import net.torvald.terrarum.QNDTreeNode
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.Yaml
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.TitleScreen
import net.torvald.terrarum.serialise.WriteConfig
import net.torvald.terrarum.ui.Toolkit
@@ -100,11 +101,11 @@ open class UIRemoCon(val parent: TitleScreen, val treeRoot: QNDTreeNode<String>)
oldSelectedItem?.highlighted = false
// selection change
if (it.labelText == "MENU_LABEL_QUIT") {
if (it.textfun() == Lang["MENU_LABEL_QUIT"]) {
//System.exit(0)
Gdx.app.exit()
}
else if (it.labelText.startsWith("MENU_LABEL_RETURN")) {
else if (it.textfun() == Lang["MENU_LABEL_RETURN"]) {
val tag = it.tags
if (tag.contains("WRITETOCONFIG")) WriteConfig()

View File

@@ -80,12 +80,12 @@ class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
// highlight initial
textArea1.buttons.forEachIndexed { index, it ->
if (it.labelText == Lang["MENU_LANGUAGE_THIS"]) {
if (it.textfun() == Lang["MENU_LANGUAGE_THIS"]) {
textArea1.select(index)
}
}
textArea2.buttons.forEachIndexed { index, it ->
if (it.labelText == Lang["MENU_LANGUAGE_THIS"]) {
if (it.textfun() == Lang["MENU_LANGUAGE_THIS"]) {
textArea2.select(index)
}
}

View File

@@ -65,7 +65,7 @@ class UIWorldPortal : UICanvas(
App.scr.height,
0f,
listOf(transitionalListing),
listOf(),
listOf(transitionalSearch),
listOf()
)

View File

@@ -68,11 +68,10 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
private val buttonsY = y + listHeight + gridGap
private val buttonSearch = UIItemTextButton(this,
"CONTEXT_WORLD_NEW",
{ Lang["CONTEXT_WORLD_NEW"] },
hx - gridGap/2 - 2*deleteButtonWidth - gridGap,
buttonsY,
deleteButtonWidth,
readFromLang = true,
hasBorder = true,
alignment = UIItemTextButton.Companion.Alignment.CENTRE
).also {
@@ -81,11 +80,10 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
}
}
private val buttonTeleport = UIItemTextButton(this,
"GAME_ACTION_TELEPORT",
{ Lang["GAME_ACTION_TELEPORT"] },
hx - gridGap/2 - deleteButtonWidth,
buttonsY,
deleteButtonWidth,
readFromLang = true,
hasBorder = true,
alignment = UIItemTextButton.Companion.Alignment.CENTRE
).also {
@@ -100,20 +98,18 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
}
}
private val buttonRename = UIItemTextButton(this,
"MENU_LABEL_RENAME",
{ Lang["MENU_LABEL_RENAME"] },
hx + gridGap/2,
buttonsY,
deleteButtonWidth,
readFromLang = true,
hasBorder = true,
alignment = UIItemTextButton.Companion.Alignment.CENTRE
)
private val buttonDelete = UIItemTextButton(this,
"MENU_LABEL_DELETE",
{ Lang["MENU_LABEL_DELETE"] },
hx + gridGap/2 + deleteButtonWidth + gridGap,
buttonsY,
deleteButtonWidth,
readFromLang = true,
hasBorder = true,
alignment = UIItemTextButton.Companion.Alignment.CENTRE
)

View File

@@ -78,8 +78,10 @@ class UIWorldPortalSearch(val full: UIWorldPortal) : UICanvas() {
)
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)
private val backButton = UIItemTextButton(this,
{ 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 {
goButton.clickOnceListener = { _, _ ->