mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
loadlist: version number of the savegame
This commit is contained in:
Binary file not shown.
@@ -71,13 +71,15 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
|||||||
val pixmapManual = full.playerButtonSelected!!.pixmapManual
|
val pixmapManual = full.playerButtonSelected!!.pixmapManual
|
||||||
val pixmapAuto = full.playerButtonSelected!!.pixmapAuto
|
val pixmapAuto = full.playerButtonSelected!!.pixmapAuto
|
||||||
|
|
||||||
|
// might throw "texture already disposed" error
|
||||||
textureManual?.texture?.tryDispose()
|
textureManual?.texture?.tryDispose()
|
||||||
textureAuto?.texture?.tryDispose()
|
textureAuto?.texture?.tryDispose()
|
||||||
|
|
||||||
val manualThumb = if (pixmapManual != null) TextureRegion(Texture(pixmapManual)) else texPlaceholder
|
textureManual = if (pixmapManual != null) TextureRegion(Texture(pixmapManual)) else null
|
||||||
val autoThumb = if (pixmapAuto != null) TextureRegion(Texture(pixmapAuto)) else texPlaceholder
|
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,
|
initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQdrawW - imageButtonW/2,
|
||||||
initialY = altSelDrawY + 120,
|
initialY = altSelDrawY + 120,
|
||||||
width = imageButtonW,
|
width = imageButtonW,
|
||||||
@@ -93,7 +95,7 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
|||||||
mode = MODE_LOAD
|
mode = MODE_LOAD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadAutoThumbButton = UIItemImageButton(this, autoThumb,
|
loadAutoThumbButton = UIItemImageButton(this, textureAuto ?: texPlaceholder,
|
||||||
initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQQQdrawW - imageButtonW/2,
|
initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQQQdrawW - imageButtonW/2,
|
||||||
initialY = altSelDrawY + 120,
|
initialY = altSelDrawY + 120,
|
||||||
width = imageButtonW,
|
width = imageButtonW,
|
||||||
@@ -142,39 +144,11 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
if (::loadAutoThumbButton.isInitialized) loadAutoThumbButton.dispose()
|
// might throw "texture already disposed" error
|
||||||
if (::loadManualThumbButton.isInitialized) loadManualThumbButton.dispose()
|
|
||||||
|
|
||||||
// might throw Texture already disposed
|
|
||||||
textureManual?.texture?.tryDispose()
|
textureManual?.texture?.tryDispose()
|
||||||
textureAuto?.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 {
|
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
super.touchDown(screenX, screenY, pointer, button)
|
super.touchDown(screenX, screenY, pointer, button)
|
||||||
if (::loadAutoThumbButton.isInitialized) loadAutoThumbButton.touchDown(screenX, screenY, pointer, button)
|
if (::loadAutoThumbButton.isInitialized) loadAutoThumbButton.touchDown(screenX, screenY, pointer, button)
|
||||||
|
|||||||
@@ -507,6 +507,7 @@ class UIItemPlayerCells(
|
|||||||
private var worldName: String = "$EMDASH"
|
private var worldName: String = "$EMDASH"
|
||||||
private var lastPlayTime: String = "????-??-?? --:--:--"
|
private var lastPlayTime: String = "????-??-?? --:--:--"
|
||||||
private var totalPlayTime: String = "--h--m--s"
|
private var totalPlayTime: String = "--h--m--s"
|
||||||
|
private var versionString: String = "0.0.0"
|
||||||
|
|
||||||
// lateinit var playerUUID: UUID; private set
|
// lateinit var playerUUID: UUID; private set
|
||||||
lateinit var worldUUID: 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 == "worldCurrentlyPlaying") worldUUID = UUID.fromString(value.asString())
|
||||||
if (name == "totalPlayTime") totalPlayTime = parseDuration(value.asLong())
|
if (name == "totalPlayTime") totalPlayTime = parseDuration(value.asLong())
|
||||||
if (name == "lastPlayTime") lastPlayTime0 = 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)" }
|
App.savegamePlayersName[playerUUID]?.let { if (it.isNotBlank()) playerName = it else "(name)" }
|
||||||
@@ -649,40 +651,48 @@ class UIItemPlayerCells(
|
|||||||
val x = posX + offX
|
val x = posX + offX
|
||||||
val y = posY + offY
|
val y = posY + offY
|
||||||
|
|
||||||
|
val line1 = y + 3f
|
||||||
|
val line2 = line1 + 30
|
||||||
|
val line3 = line2 + 30
|
||||||
|
val line4 = line3 + 30
|
||||||
|
|
||||||
// draw box backgrounds
|
// draw box backgrounds
|
||||||
batch.color = cellCol
|
batch.color = cellCol
|
||||||
Toolkit.fillArea(batch, x, y, 106, height)
|
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
|
// draw borders
|
||||||
batch.color = highlightCol
|
batch.color = highlightCol
|
||||||
// avatar border
|
// avatar border
|
||||||
Toolkit.drawBoxBorder(batch, x - 1, y - 1, 106 + 2, height + 2)
|
Toolkit.drawBoxBorder(batch, x - 1, y - 1, 106 + 2, height + 2)
|
||||||
// infocell border
|
// infocell border
|
||||||
Toolkit.drawBoxBorder(batch, x + 115, y + 33, width - 114, 88)
|
Toolkit.drawBoxBorder(batch, x + 115, y - 1, width - 114, height + 2)
|
||||||
|
|
||||||
// texts
|
// texts
|
||||||
batch.color = highlightTextCol
|
batch.color = highlightTextCol
|
||||||
val playTimeTextLen = App.fontGame.getWidth(totalPlayTime)
|
val playTimeTextLen = App.fontGame.getWidth(totalPlayTime)
|
||||||
App.fontGame.draw(batch, playerName, x + 146f, y + height - 84f)
|
App.fontGame.draw(batch, playerName, x + 146f, line1)
|
||||||
App.fontGame.draw(batch, worldName, x + 146f, y + height - 55f)
|
App.fontGame.draw(batch, worldName, x + 146f, line2)
|
||||||
App.fontGame.draw(batch, lastPlayTime, x + 146f, y + height - 26f)
|
App.fontGame.draw(batch, lastPlayTime, x + 146f, line3)
|
||||||
App.fontGame.draw(batch, totalPlayTime, x + width - 5f - playTimeTextLen, y + height - 26f)
|
App.fontGame.draw(batch, versionString, x + 146f, line4)
|
||||||
|
App.fontGame.draw(batch, totalPlayTime, x + width - 5f - playTimeTextLen, line4)
|
||||||
// icons
|
// icons
|
||||||
batch.draw(icons.get(24,0), x + 120f, y + height - 82f) // player name
|
batch.draw(icons.get(24,0), x + 120f, line1 + 2f) // player name
|
||||||
batch.draw(icons.get(12,0), x + 119f, y + height - 53f) // world map
|
batch.draw(icons.get(12,0), x + 119f, line2 + 2f) // world map
|
||||||
batch.draw(icons.get(13,0), x + 120f, y + height - 24f) // journal
|
batch.draw(icons.get(13,0), x + 120f, line3 + 2f) // journal
|
||||||
batch.draw(icons.get(23,0), x + width - 4f - playTimeTextLen - 24f, y + height - 24f) // stopwatch
|
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
|
// autosave marker
|
||||||
if (savegameStatus == 2)
|
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)
|
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
|
// infocell divider
|
||||||
batch.color = if (mouseUp) hruleColLit else hruleCol
|
batch.color = if (mouseUp) hruleColLit else hruleCol
|
||||||
Toolkit.fillArea(batch, x + 118, y + 62, width - 120, 1)
|
Toolkit.fillArea(batch, x + 118, y + 29, width - 120, 1)
|
||||||
Toolkit.fillArea(batch, x + 118, y + 91, 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
|
// player avatar
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
|||||||
Reference in New Issue
Block a user