mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 04:24:05 +09:00
game loading is back but newgame is broken
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user