From 10f92a11a96414f878ab6e6d74a5cd38e56130f9 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 12 Jul 2023 02:23:49 +0900 Subject: [PATCH] loadlist: version number of the savegame --- assets/graphics/gui/inventory/category.tga | 2 +- .../modulebasegame/ui/UILoadAutosave.kt | 40 ++++--------------- .../modulebasegame/ui/UILoadDemoSavefiles.kt | 38 +++++++++++------- 3 files changed, 32 insertions(+), 48 deletions(-) diff --git a/assets/graphics/gui/inventory/category.tga b/assets/graphics/gui/inventory/category.tga index 47dadb826..e2a761fc4 100755 --- a/assets/graphics/gui/inventory/category.tga +++ b/assets/graphics/gui/inventory/category.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:332c3d7395d8274f6bcd7e88f2998df28dc3c0f0caa692b356067c3e6c1b6d91 +oid sha256:22da5c9145c1ea1e20b02fe6db00965b6bbbe684d5b92dfb7826616d1e16113c size 240018 diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UILoadAutosave.kt b/src/net/torvald/terrarum/modulebasegame/ui/UILoadAutosave.kt index 4e911b009..ee0706974 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UILoadAutosave.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UILoadAutosave.kt @@ -71,13 +71,15 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() { val pixmapManual = full.playerButtonSelected!!.pixmapManual val pixmapAuto = full.playerButtonSelected!!.pixmapAuto + // might throw "texture already disposed" error textureManual?.texture?.tryDispose() textureAuto?.texture?.tryDispose() - val manualThumb = if (pixmapManual != null) TextureRegion(Texture(pixmapManual)) else texPlaceholder - val autoThumb = if (pixmapAuto != null) TextureRegion(Texture(pixmapAuto)) else texPlaceholder + textureManual = if (pixmapManual != null) TextureRegion(Texture(pixmapManual)) else null + textureAuto = if (pixmapAuto != null) TextureRegion(Texture(pixmapAuto)) else null - loadManualThumbButton = UIItemImageButton(this, manualThumb, + + loadManualThumbButton = UIItemImageButton(this, textureManual ?: texPlaceholder, initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQdrawW - imageButtonW/2, initialY = altSelDrawY + 120, width = imageButtonW, @@ -93,7 +95,7 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() { mode = MODE_LOAD } } - loadAutoThumbButton = UIItemImageButton(this, autoThumb, + loadAutoThumbButton = UIItemImageButton(this, textureAuto ?: texPlaceholder, initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQQQdrawW - imageButtonW/2, initialY = altSelDrawY + 120, width = imageButtonW, @@ -142,39 +144,11 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() { } override fun dispose() { - if (::loadAutoThumbButton.isInitialized) loadAutoThumbButton.dispose() - if (::loadManualThumbButton.isInitialized) loadManualThumbButton.dispose() - - // might throw Texture already disposed + // might throw "texture already disposed" error textureManual?.texture?.tryDispose() textureAuto?.texture?.tryDispose() } - - private fun DiskPair.getThumbnail(): TextureRegion { - return this.player.requestFile(VDFileID.PLAYER_SCREENSHOT).let { file -> - if (file != null) { - val zippedTga = (file.contents as EntryFile).bytes - val gzin = GZIPInputStream(ByteArray64InputStream(zippedTga)) - val tgaFileContents = gzin.readAllBytes(); gzin.close() - val pixmap = Pixmap(tgaFileContents, 0, tgaFileContents.size) - TextureRegion(Texture(pixmap)).also { - App.disposables.add(it.texture) - // do cropping and resizing - it.setRegion( - (pixmap.width - imageButtonW*2) / 2, - (pixmap.height - imageButtonH*2) / 2, - imageButtonW * 2, - imageButtonH * 2 - ) - } - } - else { - CommonResourcePool.getAsTextureRegion("terrarum-defaultsavegamethumb") - } - } - } - override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { super.touchDown(screenX, screenY, pointer, button) if (::loadAutoThumbButton.isInitialized) loadAutoThumbButton.touchDown(screenX, screenY, pointer, button) diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt b/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt index 5b647da8c..f243b37e1 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt @@ -507,6 +507,7 @@ class UIItemPlayerCells( private var worldName: String = "$EMDASH" private var lastPlayTime: String = "????-??-?? --:--:--" private var totalPlayTime: String = "--h--m--s" + private var versionString: String = "0.0.0" // lateinit var playerUUID: UUID; private set lateinit var worldUUID: UUID; private set @@ -523,6 +524,7 @@ class UIItemPlayerCells( if (name == "worldCurrentlyPlaying") worldUUID = UUID.fromString(value.asString()) if (name == "totalPlayTime") totalPlayTime = parseDuration(value.asLong()) if (name == "lastPlayTime") lastPlayTime0 = value.asLong() + if (name == "genver") versionString = value.asLong().let { "${it.ushr(48)}.${it.ushr(24).and(0xFFFFFF)}.${it.and(0xFFFFFF)}" } } App.savegamePlayersName[playerUUID]?.let { if (it.isNotBlank()) playerName = it else "(name)" } @@ -649,40 +651,48 @@ class UIItemPlayerCells( val x = posX + offX val y = posY + offY + val line1 = y + 3f + val line2 = line1 + 30 + val line3 = line2 + 30 + val line4 = line3 + 30 + // draw box backgrounds batch.color = cellCol Toolkit.fillArea(batch, x, y, 106, height) - Toolkit.fillArea(batch, x + 116, y + 34, width - 116, 86) + Toolkit.fillArea(batch, x + 116, y, width - 116, height) // draw borders batch.color = highlightCol // avatar border Toolkit.drawBoxBorder(batch, x - 1, y - 1, 106 + 2, height + 2) // infocell border - Toolkit.drawBoxBorder(batch, x + 115, y + 33, width - 114, 88) + Toolkit.drawBoxBorder(batch, x + 115, y - 1, width - 114, height + 2) // texts batch.color = highlightTextCol val playTimeTextLen = App.fontGame.getWidth(totalPlayTime) - App.fontGame.draw(batch, playerName, x + 146f, y + height - 84f) - App.fontGame.draw(batch, worldName, x + 146f, y + height - 55f) - App.fontGame.draw(batch, lastPlayTime, x + 146f, y + height - 26f) - App.fontGame.draw(batch, totalPlayTime, x + width - 5f - playTimeTextLen, y + height - 26f) + App.fontGame.draw(batch, playerName, x + 146f, line1) + App.fontGame.draw(batch, worldName, x + 146f, line2) + App.fontGame.draw(batch, lastPlayTime, x + 146f, line3) + App.fontGame.draw(batch, versionString, x + 146f, line4) + App.fontGame.draw(batch, totalPlayTime, x + width - 5f - playTimeTextLen, line4) // icons - batch.draw(icons.get(24,0), x + 120f, y + height - 82f) // player name - batch.draw(icons.get(12,0), x + 119f, y + height - 53f) // world map - batch.draw(icons.get(13,0), x + 120f, y + height - 24f) // journal - batch.draw(icons.get(23,0), x + width - 4f - playTimeTextLen - 24f, y + height - 24f) // stopwatch + batch.draw(icons.get(24,0), x + 120f, line1 + 2f) // player name + batch.draw(icons.get(12,0), x + 119f, line2 + 2f) // world map + batch.draw(icons.get(13,0), x + 120f, line3 + 2f) // journal + batch.draw(icons.get(22,1), x + 119f, line4 + 2f) // version(?) + batch.draw(icons.get(23,0), x + width - 4f - playTimeTextLen - 24f, line4 + 2f) // stopwatch // autosave marker if (savegameStatus == 2) - batch.draw(icons.get(24,1), x + 459f, y + 5f) + batch.draw(icons.get(24,1), x + 457f, line1 + 2f) else if (savegameStatus == 0) - batch.draw(icons.get(23,1), x + 459f, y + 5f) + batch.draw(icons.get(23,1), x + 457f, line1 + 2f) // infocell divider batch.color = if (mouseUp) hruleColLit else hruleCol - Toolkit.fillArea(batch, x + 118, y + 62, width - 120, 1) - Toolkit.fillArea(batch, x + 118, y + 91, width - 120, 1) + Toolkit.fillArea(batch, x + 118, y + 29, width - 120, 1) + Toolkit.fillArea(batch, x + 118, y + 59, width - 120, 1) + Toolkit.fillArea(batch, x + 118, y + 89, width - 120, 1) // player avatar batch.color = Color.WHITE