players loads their sprites now

This commit is contained in:
minjaesong
2021-10-13 16:18:27 +09:00
parent f28fabb8b5
commit 03a854ca58
11 changed files with 46 additions and 21 deletions

View File

@@ -12,5 +12,5 @@
"GAME_32BIT_WARNING2": "아래 링크에서 최신 64비트 Java를 내려받아 설치해주세요.",
"GAME_32BIT_WARNING3": "https://www.java.com/ko/download/",
"MENU_OPTION_STREAMERS_LAYOUT": "스트리머 채팅창 모드",
"MENU_LABEL_RESTART_REQUIRED": "다시 시작 필요"
}
"MENU_LABEL_RESTART_REQUIRED": "시작 필요"
}

View File

@@ -6,5 +6,5 @@
"MENU_LABEL_PRESS_START_SYMBOL": "> basınız",
"MENU_MODULES" : "Modüller",
"MENU_LABEL_RESET" : "Sıfırla",
"MENU_LABEL_RESTART_REQUIRED": "Yeniden başlatma gerekiyor "
}
"MENU_LABEL_RESTART_REQUIRED": "Yeniden başlatma gerekiyor"
}

View File

@@ -3,7 +3,6 @@ package net.torvald.spriteanimation
import com.badlogic.gdx.graphics.Texture
import net.torvald.spriteassembler.ADProperties
import net.torvald.spriteassembler.AssembleSheetPixmap
import net.torvald.terrarum.tvda.SimpleFileSystem
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/**
@@ -35,12 +34,12 @@ interface HasAssembledSprite {
_rebuild(animGlow, spriteGlow)
}
fun reassembleSprite(disk: SimpleFileSystem, sprite: SpriteAnimation?, anim: ADProperties?, spriteGlow: SpriteAnimation? = null, animGlow: ADProperties? = null) {
/*fun reassembleSprite(disk: SimpleFileSystem, sprite: SpriteAnimation?, anim: ADProperties?, spriteGlow: SpriteAnimation? = null, animGlow: ADProperties? = null) {
if (anim != null && sprite != null)
_rebuild(disk, anim, sprite)
if (animGlow != null && spriteGlow != null)
_rebuild(disk, animGlow, spriteGlow)
}
}*/
private fun _rebuild(ad: ADProperties, sprite: SpriteAnimation) {
// TODO injecting held item/armour pictures? Would it be AssembleSheetPixmap's job?
@@ -66,7 +65,7 @@ interface HasAssembledSprite {
sprite.nRows = newAnimDelays.size
}
private fun _rebuild(disk: SimpleFileSystem, ad: ADProperties, sprite: SpriteAnimation) {
/*private fun _rebuild(disk: SimpleFileSystem, ad: ADProperties, sprite: SpriteAnimation) {
// TODO injecting held item/armour pictures? Would it be AssembleSheetPixmap's job?
val pixmap = if (disk.getEntry(-1025) != null) AssembleSheetPixmap.fromVirtualDisk(disk, ad) else AssembleSheetPixmap.fromAssetsDir(ad)
@@ -88,6 +87,6 @@ interface HasAssembledSprite {
sprite.delays = newAnimDelays
sprite.nFrames = newAnimFrames
sprite.nRows = newAnimDelays.size
}
}*/
}

View File

@@ -1227,10 +1227,17 @@ public class App implements ApplicationListener {
public static void printdbg(Object obj, Object message) {
if (IS_DEVELOPMENT_BUILD) {
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
if (message == null)
if (message == null) {
System.out.println("[" + out + "] null");
else
System.out.println("[" + out + "] " + message);
return;
}
else {
String indentation = " ".repeat(out.length() + 3);
String[] msgLines = message.toString().split("\\n");
for (int i = 0; i < msgLines.length; i++) {
System.out.println((i == 0 ? "[" + out + "] " : indentation) + msgLines[i]);
}
}
}
}

View File

@@ -19,7 +19,6 @@ import net.torvald.terrarum.App.*
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.gameactors.ActorID
import net.torvald.terrarum.gameactors.faction.FactionCodex
@@ -597,9 +596,12 @@ inline fun printStackTrace(obj: Any) = printStackTrace(obj, System.out) // becau
fun printStackTrace(obj: Any, out: PrintStream = System.out) {
if (App.IS_DEVELOPMENT_BUILD) {
val indentation = " ".repeat(obj.javaClass.simpleName.length + 4)
Thread.currentThread().stackTrace.forEachIndexed { index, it ->
if (index >= 3)
out.println("[${obj.javaClass.simpleName}] ... $it")
if (index == 3)
out.println("[${obj.javaClass.simpleName}]> $it")
else if (index > 3)
out.println("$indentation$it")
}
}
}

View File

@@ -1,7 +1,10 @@
package net.torvald.terrarum.gameactors
import net.torvald.random.HQRNG
import net.torvald.terrarum.ReferencingRanges
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.tvda.toBigEndian
import net.torvald.terrarum.utils.PasswordBase32
typealias ActorID = Int
@@ -80,6 +83,8 @@ abstract class Actor : Comparable<Actor>, Runnable {
abstract fun dispose()
@Transient val localHash = HQRNG().nextInt()
@Transient val localHashStr = PasswordBase32.encode(localHash.toBigEndian()).substringBefore('=')
}
annotation class Event

View File

@@ -1714,9 +1714,11 @@ open class ActorWithBody : Actor {
// warnings
if (sprite == null && isVisible)
printdbg(this, "Caution: actor ${this.javaClass.simpleName} is visible but the sprite was not set.")
printdbg(this, "Caution: actor ${this.javaClass.simpleName} is visible but the sprite was not set.\n" +
"Actor localhash: ${this.localHashStr}")
else if (sprite != null && !isVisible)
printdbg(this, "Caution: actor ${this.javaClass.simpleName} is invisible but the sprite was given.")
printdbg(this, "Caution: actor ${this.javaClass.simpleName} is invisible but the sprite was given.\n" +
"Actor localhash: ${this.localHashStr}")
assertPrinted = true
}

View File

@@ -38,7 +38,6 @@ import net.torvald.terrarum.serialise.ReadActor
import net.torvald.terrarum.serialise.WriteSavegame
import net.torvald.terrarum.tvda.DiskSkimmer
import net.torvald.terrarum.tvda.VDUtil
import net.torvald.terrarum.tvda.VirtualDisk
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UIAutosaveNotifier
import net.torvald.terrarum.ui.UICanvas
@@ -301,6 +300,8 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
}
}
printdbg(this, "Player localhash: ${codices.player.localHashStr}, hasSprite: ${codices.player.sprite != null}")
// assign new random referenceID for player
codices.player.referenceID = Terrarum.generateUniqueReferenceID(Actor.RenderOrder.MIDDLE)
addNewActor(codices.player)

View File

@@ -64,7 +64,7 @@ internal class UIInventoryCells(
}
fun rebuildList() {
App.printdbg(this, "rebuilding list")
// App.printdbg(this, "rebuilding list")
itemList.rebuild(full.catBar.catIconsMeaning[full.catBar.selectedIcon])
equipped.rebuild()

View File

@@ -135,13 +135,13 @@ object ReadActor {
if (actor is Pocketed)
actor.inventory.actor = actor
if (actor is ActorWithBody && actor is HasAssembledSprite) {
if (actor is ActorWithBody && actor is IngamePlayer) {
val animFile = disk.getFile(-2L)
val animFileGlow = disk.getFile(-3L)
val bodypartsFile = disk.getFile(-1025)
actor.sprite = SpriteAnimation(actor)
if (animFileGlow != null) actor.spriteGlow = SpriteAnimation(actor)
val bodypartsFile = disk.getFile(-1025)
if (bodypartsFile != null)
actor.reassembleSprite(
@@ -159,6 +159,13 @@ object ReadActor {
if (animFileGlow == null) null else ADProperties(ByteArray64Reader(animFileGlow.bytes, Common.CHARSET))
)
}
else if (actor is ActorWithBody && actor is HasAssembledSprite) {
if (actor.animDesc != null) actor.sprite = SpriteAnimation(actor)
if (actor.animDescGlow != null) actor.spriteGlow = SpriteAnimation(actor)
actor.reassembleSprite(actor.sprite, actor.animDesc, actor.spriteGlow, actor.animDescGlow)
}
return actor
}

View File

@@ -140,6 +140,8 @@ object LoadSavegame {
val newIngame = TerrarumIngame(App.batch)
val player = ReadActor.invoke(playerDisk, ByteArray64Reader(playerDisk.getFile(-1L)!!.bytes, Common.CHARSET)) as IngamePlayer
printdbg(this, "Player localhash: ${player.localHashStr}, hasSprite: ${player.sprite != null}")
val currentWorldId = player.worldCurrentlyPlaying
val worldDisk = worldDisk0 ?: App.savegameWorlds[currentWorldId]!!
val world = ReadWorld(ByteArray64Reader(worldDisk.getFile(-1L)!!.bytes, Common.CHARSET))