mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
new world screen for loading imported players
This commit is contained in:
Binary file not shown.
@@ -347,6 +347,10 @@ class SavegameCollectionPair(private val player: SavegameCollection?, private va
|
||||
return if (status == 0) null
|
||||
else DiskPair(playerDisk!!, worldDisk!!)
|
||||
}
|
||||
|
||||
fun getImportedPlayer(): DiskSkimmer? {
|
||||
return if (isImported) player!!.loadable() else null
|
||||
}
|
||||
}
|
||||
|
||||
data class DiskPair(val player: DiskSkimmer, val world: DiskSkimmer) {
|
||||
|
||||
@@ -39,6 +39,7 @@ class PlayerSavingThread(
|
||||
|
||||
disk.saveMode = 2 * isAuto.toInt() // no quick
|
||||
disk.saveKind = VDSaveKind.PLAYER_DATA
|
||||
disk.saveOrigin = disk.saveOrigin and 15 // remove flag "imported" if applicable
|
||||
disk.capacity = 0L
|
||||
|
||||
WriteSavegame.saveProgress = 0f
|
||||
|
||||
@@ -149,6 +149,7 @@ class QuickSingleplayerWorldSavingThread(
|
||||
skimmer.injectDiskCRC(disk.hashCode())
|
||||
skimmer.setSaveMode(1 + 2 * isAuto.toInt())
|
||||
skimmer.setSaveKind(VDSaveKind.WORLD_DATA)
|
||||
skimmer.setSaveOrigin(skimmer.getSaveOrigin() and 15) // remove flag "imported" if applicable
|
||||
|
||||
printdbg(this, "Game saved with size of ${outFile.length()} bytes")
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ class WorldSavingThread(
|
||||
|
||||
disk.saveMode = 2 * isAuto.toInt() // no quick
|
||||
disk.saveKind = VDSaveKind.WORLD_DATA
|
||||
disk.saveOrigin = disk.saveOrigin and 15 // remove flag "imported" if applicable
|
||||
|
||||
// wait for screencap
|
||||
var emergencyStopCnt = 0
|
||||
|
||||
@@ -74,7 +74,6 @@ object WritePlayer {
|
||||
player.lastPlayTime = time_t
|
||||
player.totalPlayTime += time_t - (ingame?.loadedTime_t ?: time_t)
|
||||
|
||||
|
||||
// restore player prop backup created on load-time for multiplayer
|
||||
if (ingame?.isMultiplayer == true) {
|
||||
player.setPosition(player.unauthorisedPlayerProps.physics.position)
|
||||
|
||||
@@ -66,6 +66,13 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
||||
{ Lang["ERROR_SAVE_CORRUPTED"].replace(".","") }, buttonX1third, buttonRowY2, buttonWidth * 3 + buttonGap * 2, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
it.isEnabled = false
|
||||
}
|
||||
private val mainImportedPlayerCreateNewWorldButton = UIItemTextButton(this,
|
||||
{ Lang["CONTEXT_WORLD_NEW"].replace(".","") }, buttonX1third, buttonRowY2, buttonWidth * 3 + buttonGap * 2, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
it.clickOnceListener = { _,_ ->
|
||||
val playerDisk = full.loadables.getImportedPlayer()!!
|
||||
full.remoCon.openUI(UINewWorld(full.remoCon, playerDisk))
|
||||
}
|
||||
}
|
||||
private val mainRenameButton = UIItemTextButton(this,
|
||||
{ Lang["MENU_LABEL_RENAME"] }, buttonX1third, buttonRowY, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
it.clickOnceListener = { _,_ ->
|
||||
@@ -134,11 +141,12 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
||||
|
||||
private var mainButtons0 = listOf(mainGoButton, mainBackButton, mainRenameButton, mainDeleteButton)
|
||||
private var mainButtons1 = listOf(mainNoGoButton, mainBackButton, mainRenameButton, mainDeleteButton)
|
||||
private var mainButtons2 = listOf(mainImportedPlayerCreateNewWorldButton, mainBackButton, mainRenameButton, mainDeleteButton)
|
||||
private var delButtons = listOf(confirmCancelButton, confirmDeleteButton)
|
||||
private var renameButtons = listOf(renameRenameButton, renameCancelButton)
|
||||
|
||||
private val mainButtons: List<UIItemTextButton>
|
||||
get() = if (full.loadables.saveAvaliable()) mainButtons0 else mainButtons1
|
||||
get() = if (full.loadables.saveAvaliable()) mainButtons0 else if (full.loadables.isImported) mainButtons2 else mainButtons1
|
||||
|
||||
private val MODE_INIT = 0
|
||||
private val MODE_DELETE = 16 // are you sure?
|
||||
@@ -212,18 +220,20 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
||||
val tex = screencap ?: CommonResourcePool.getAsTextureRegion("terrarum-defaultsavegamethumb")
|
||||
|
||||
|
||||
val tx = (Toolkit.drawWidth - screencapW) / 2
|
||||
val tys = full.titleTopGradEnd + SAVE_CELL_HEIGHT + buttonGap
|
||||
val tye = buttonRowY2 - buttonGap
|
||||
val ty = tys + (tye - tys - SAVE_THUMBNAIL_MAIN_HEIGHT) / 2
|
||||
if (full.loadables.saveAvaliable()) {
|
||||
val tx = (Toolkit.drawWidth - screencapW) / 2
|
||||
val tys = full.titleTopGradEnd + SAVE_CELL_HEIGHT + buttonGap
|
||||
val tye = buttonRowY2 - buttonGap
|
||||
val ty = tys + (tye - tys - SAVE_THUMBNAIL_MAIN_HEIGHT) / 2
|
||||
|
||||
batch.color = Toolkit.Theme.COL_INACTIVE
|
||||
Toolkit.drawBoxBorder(batch, tx - 1, ty - 1, screencapW + 2, screencapH + 2)
|
||||
batch.color = UIInventoryFull.CELL_COL
|
||||
Toolkit.fillArea(batch, tx, ty, screencapW, screencapH)
|
||||
batch.color = Toolkit.Theme.COL_INACTIVE
|
||||
Toolkit.drawBoxBorder(batch, tx - 1, ty - 1, screencapW + 2, screencapH + 2)
|
||||
batch.color = UIInventoryFull.CELL_COL
|
||||
Toolkit.fillArea(batch, tx, ty, screencapW, screencapH)
|
||||
|
||||
batch.color = Color.WHITE
|
||||
batch.draw(tex, tx.toFloat(), ty.toFloat(), screencapW.toFloat(), screencapH.toFloat())
|
||||
batch.color = Color.WHITE
|
||||
batch.draw(tex, tx.toFloat(), ty.toFloat(), screencapW.toFloat(), screencapH.toFloat())
|
||||
}
|
||||
|
||||
}
|
||||
MODE_DELETE -> {
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.torvald.terrarum.savegame.VirtualDisk
|
||||
import net.torvald.terrarum.serialise.Common
|
||||
import net.torvald.terrarum.modulebasegame.serialise.LoadSavegame
|
||||
import net.torvald.terrarum.modulebasegame.serialise.WritePlayer
|
||||
import net.torvald.terrarum.savegame.VDSaveOrigin
|
||||
import net.torvald.terrarum.ui.*
|
||||
import net.torvald.terrarum.utils.RandomWordsName
|
||||
import java.io.File
|
||||
@@ -71,6 +72,7 @@ class UINewCharacter(val remoCon: UIRemoCon) : UICanvas() {
|
||||
|
||||
disk.saveMode = 2 // auto, no quick
|
||||
disk.capacity = 0L
|
||||
disk.saveOrigin = VDSaveOrigin.INGAME
|
||||
|
||||
WritePlayer(player, disk, null, time_t)
|
||||
VDUtil.dumpToRealMachine(disk, outFile)
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.torvald.terrarum.savegame.ByteArray64Reader
|
||||
import net.torvald.terrarum.savegame.VirtualDisk
|
||||
import net.torvald.terrarum.serialise.Common
|
||||
import net.torvald.terrarum.modulebasegame.serialise.ReadActor
|
||||
import net.torvald.terrarum.savegame.DiskSkimmer
|
||||
import net.torvald.terrarum.savegame.VDFileID.SAVEGAMEINFO
|
||||
import net.torvald.terrarum.ui.*
|
||||
import net.torvald.terrarum.utils.RandomWordsName
|
||||
@@ -28,11 +29,16 @@ import net.torvald.terrarum.utils.RandomWordsName
|
||||
class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
||||
|
||||
private var newPlayerCreationThread = Thread {}
|
||||
private var existingPlayer: DiskSkimmer? = null
|
||||
|
||||
constructor(remoCon: UIRemoCon, playerCreationThread: Thread) : this(remoCon) {
|
||||
newPlayerCreationThread = playerCreationThread
|
||||
}
|
||||
|
||||
constructor(remoCon: UIRemoCon, importedPlayer: DiskSkimmer) : this(remoCon) {
|
||||
existingPlayer = importedPlayer
|
||||
}
|
||||
|
||||
private val hugeTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/huge.png")))
|
||||
private val largeTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/large.png")))
|
||||
private val normalTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/normal.png")))
|
||||
@@ -98,14 +104,16 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
||||
goButton.clickOnceListener = { _, _ ->
|
||||
|
||||
// after the save is complete, proceed to new world generation
|
||||
newPlayerCreationThread.start()
|
||||
newPlayerCreationThread.join()
|
||||
if (existingPlayer == null) {
|
||||
newPlayerCreationThread.start()
|
||||
newPlayerCreationThread.join()
|
||||
}
|
||||
|
||||
|
||||
printdbg(this, "generate! Size=${sizeSelector.selection}, Name=${nameInput.getTextOrPlaceholder()}, Seed=${seedInput.getTextOrPlaceholder()}")
|
||||
|
||||
val ingame = TerrarumIngame(App.batch)
|
||||
val playerDisk = App.savegamePlayers[UILoadGovernor.playerUUID]!!.loadable()
|
||||
val playerDisk = existingPlayer ?: App.savegamePlayers[UILoadGovernor.playerUUID]!!.loadable()
|
||||
val player = ReadActor.invoke(playerDisk, ByteArray64Reader(playerDisk.getFile(SAVEGAMEINFO)!!.bytes, Common.CHARSET)) as IngamePlayer
|
||||
val seed = try {
|
||||
seedInput.getTextOrPlaceholder().toLong()
|
||||
|
||||
@@ -76,9 +76,9 @@ Version 254 is a customised version of TEVD tailored to be used as a savegame fo
|
||||
0: Undefined (or very old version of the game)
|
||||
1: Player Data
|
||||
2: World Data
|
||||
Int8 Savefile Origin Flags
|
||||
Int8 Savefile Origin Flags (lower nybble: persistent, upper nybble: can be removed if conditions are met)
|
||||
0: Created in-game
|
||||
16: Imported
|
||||
16: Imported (will be removed once the file is loaded by the player and saved in-game)
|
||||
Int8[12] Extra info bytes reserved for future usage
|
||||
-- END extraInfoBytes --
|
||||
UInt8[236] Rest of the long disk name (268 bytes total)
|
||||
|
||||
Reference in New Issue
Block a user