From ce1289efe34570cbf70b817f1f73d741e2e174e4 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 12 Oct 2021 11:55:52 +0900 Subject: [PATCH] players info cell reworked --- assets/graphics/gui/inventory/category.tga | 2 +- src/net/torvald/terrarum/Terrarum.kt | 8 ++--- .../modulebasegame/ui/UILoadDemoSavefiles.kt | 35 +++++++++++++------ work_files/UI/character_cell.kra | 4 +-- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/assets/graphics/gui/inventory/category.tga b/assets/graphics/gui/inventory/category.tga index 9e1b77f80..4029c6af5 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:a385921af014661e6ecf09d9f6f8ff224b41c4cfa465ce0ff2e0441885cd5630 +oid sha256:bfbf9c948800dd3064e4ad0b23f804aec1d4249646a6051124a60ef149acf832 size 240018 diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 5abdf2806..05d0c7f16 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -706,7 +706,7 @@ fun AppUpdateListOfSavegames() { // TODO write simple and dumb SAX parser for JSON val jsonFile = it.getFile(-1L)!! val json = JsonReader().parse(ByteArray64Reader(jsonFile.bytes, Common.CHARSET).readText()) - val worldUUID = UUID.fromString(json.get("worldIndex")!!.asString()) + val worldUUID = UUID.fromString(json.getString("worldIndex")) App.savegameWorlds[worldUUID] = it App.savegameWorldsName[worldUUID] = it.getDiskName(Common.CHARSET) } @@ -729,10 +729,10 @@ fun AppUpdateListOfSavegames() { // TODO write simple and dumb SAX parser for JSON val jsonFile = it.getFile(-1L)!! val json = JsonReader().parse(ByteArray64Reader(jsonFile.bytes, Common.CHARSET).readText()) - val playerUUID = UUID.fromString(json.get("uuid")!!.asString()) + val playerUUID = UUID.fromString(json.getString("uuid")) App.savegamePlayers[playerUUID] = it -// App.savegamePlayersName[playerUUID] = it.getDiskName(Common.CHARSET) - App.savegamePlayersName[playerUUID] = json.get("actorValue")?.getChild(AVKey.NAME)?.asString() ?: "" + App.savegamePlayersName[playerUUID] = it.getDiskName(Common.CHARSET) +// App.savegamePlayersName[playerUUID] = json.get("actorValue")?.get(AVKey.NAME)?.asString() ?: "NULL!" } } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt b/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt index 0a8114661..aa99c7116 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UILoadDemoSavefiles.kt @@ -43,6 +43,9 @@ val SAVE_CELL_HEIGHT = 120 class UILoadDemoSavefiles : UICanvas() { init { + CommonResourcePool.addToLoadingList("inventory_category") { + TextureRegionPack("./assets/graphics/gui/inventory/category.tga", 20, 20) + } CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") { TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/savegame_thumb_placeholder.png"))) } @@ -371,8 +374,8 @@ class UIItemPlayerCells( private var playerName: String = "$EMDASH" private var worldName: String = "$EMDASH" - private var lastPlayTime: String = "--h--m--s" - private var totalPlayTime: String = "--:--:--" + private var lastPlayTime: String = "????-??-?? --:--:--" + private var totalPlayTime: String = "--h--m--s" init { skimmer.getFile(-1L)?.bytes?.let { @@ -381,7 +384,7 @@ class UIItemPlayerCells( val playerUUID = UUID.fromString(json["uuid"]?.asString()) val worldUUID = UUID.fromString(json["worldCurrentlyPlaying"]?.asString()) - App.savegamePlayersName[playerUUID]?.let { if (it.isNotBlank()) playerName = it } + App.savegamePlayersName[playerUUID]?.let { if (it.isNotBlank()) playerName = it else "(name)" } App.savegameWorldsName[worldUUID]?.let { if (it.isNotBlank()) worldName = it } json["lastPlayTime"]?.asString()?.let { lastPlayTime = Instant.ofEpochSecond(it.toLong()) @@ -413,6 +416,8 @@ class UIItemPlayerCells( private val cellCol = CELL_COL + private val icons = CommonResourcePool.getAsTextureRegionPack("inventory_category") + override fun render(batch: SpriteBatch, camera: Camera) { // try to generate a texture if (skimmer.initialised && !hasTexture) { @@ -438,27 +443,35 @@ class UIItemPlayerCells( // draw box backgrounds batch.color = cellCol Toolkit.fillArea(batch, posX, posY, 106, height) - Toolkit.fillArea(batch, posX + 116, posY + 63, width - 116, 57) + Toolkit.fillArea(batch, posX + 116, posY + 34, width - 116, 86) // draw borders batch.color = highlightCol // avatar border Toolkit.drawBoxBorder(batch, posX - 1, posY - 1, 106 + 2, height + 2) // infocell border - Toolkit.drawBoxBorder(batch, posX + 115, posY + 62, width - 114, 59) + Toolkit.drawBoxBorder(batch, posX + 115, posY + 33, width - 114, 88) // infocell divider - Toolkit.fillArea(batch, posX + 118, posY + 90, width - 120, 1) + Toolkit.fillArea(batch, posX + 118, posY + 62, width - 120, 1) + Toolkit.fillArea(batch, posX + 118, posY + 91, width - 120, 1) + + // texts + val playTimeTextLen = App.fontGame.getWidth(totalPlayTime) + App.fontGame.draw(batch, playerName, x + 146f, y + height - 82f) + App.fontGame.draw(batch, worldName, x + 146f, y + height - 53f) + App.fontGame.draw(batch, lastPlayTime, x + 146f, y + height - 24f) + App.fontGame.draw(batch, totalPlayTime, x + width - 5f - playTimeTextLen, y + height - 24f) + // 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 - 5f - playTimeTextLen - 24f, y + height - 24f) // stopwatch // player avatar batch.color = Color.WHITE thumb?.let { batch.draw(it, x + FastMath.ceil((106f - it.regionWidth) / 2f), y + FastMath.ceil((height - it.regionHeight) / 2f)) } - // texts - App.fontGame.draw(batch, playerName, x + 120f, y + height - 54f) - App.fontGame.draw(batch, worldName, x + 120f, y + height - 24f) - App.fontGame.draw(batch, lastPlayTime, x + width - 4f - App.fontGame.getWidth(lastPlayTime), y + height - 54f) - App.fontGame.draw(batch, totalPlayTime, x + width - 4f - App.fontGame.getWidth(totalPlayTime), y + height - 24f) } override fun dispose() { diff --git a/work_files/UI/character_cell.kra b/work_files/UI/character_cell.kra index 17137ace7..d689c825a 100644 --- a/work_files/UI/character_cell.kra +++ b/work_files/UI/character_cell.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9a6afa64a130e927260b7a6b6b06b19a4345a1b354655492b51fd20396fefdfb -size 124756 +oid sha256:aba8dcbc44134474f97bc9e10ac58ae80472708e0cb9846f11f7e290505e7f96 +size 307147