HasAssembledSprite saves path instead of FileHandle (easier gson-ing)

This commit is contained in:
minjaesong
2019-02-22 15:19:39 +09:00
parent d0e2b20fc3
commit 955f36dad5
5 changed files with 9 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
package net.torvald.spriteanimation package net.torvald.spriteanimation
import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import net.torvald.spriteassembler.ADProperties import net.torvald.spriteassembler.ADProperties
import net.torvald.spriteassembler.AssembleSheetPixmap import net.torvald.spriteassembler.AssembleSheetPixmap
@@ -11,16 +11,16 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
*/ */
interface HasAssembledSprite { interface HasAssembledSprite {
var animDesc: FileHandle var animDescPath: String
// FIXME sometimes the animmation is invisible (row and nFrames mismatch -- row is changed to 1 but it's drawing 3rd frame?) // FIXME sometimes the animmation is invisible (row and nFrames mismatch -- row is changed to 1 but it's drawing 3rd frame?)
fun reassembleSprite(sprite: SpriteAnimation) { fun reassembleSprite(sprite: SpriteAnimation) {
_rebuild(ADProperties(animDesc.read()), sprite) _rebuild(ADProperties(Gdx.files.internal(animDescPath).read()), sprite)
} }
/*fun rebuild(animDesc: String, spriteAnimation: SpriteAnimation) { /*fun rebuild(animDescPath: String, spriteAnimation: SpriteAnimation) {
_rebuild(ADProperties(StringReader(animDesc)), spriteAnimation) _rebuild(ADProperties(StringReader(animDescPath)), spriteAnimation)
} }
fun rebuild(animDesc: FileHandle, spriteAnimation: SpriteAnimation) { fun rebuild(animDesc: FileHandle, spriteAnimation: SpriteAnimation) {

View File

@@ -1,6 +1,5 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.files.FileHandle
import net.torvald.spriteanimation.HasAssembledSprite import net.torvald.spriteanimation.HasAssembledSprite
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.modulebasegame.gameworld.time_t import net.torvald.terrarum.modulebasegame.gameworld.time_t
@@ -12,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
* Created by minjaesong on 2015-12-31. * Created by minjaesong on 2015-12-31.
*/ */
class IngamePlayer(override var animDesc: FileHandle, born: time_t) : ActorHumanoid(born), HasAssembledSprite { class IngamePlayer(override var animDescPath: String, born: time_t) : ActorHumanoid(born), HasAssembledSprite {
/** /**
* Creates new Player instance with empty elements (sprites, actorvalue, etc.). * Creates new Player instance with empty elements (sprites, actorvalue, etc.).

View File

@@ -1,6 +1,5 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.Gdx
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.Actor import net.torvald.terrarum.gameactors.Actor
@@ -14,7 +13,7 @@ object PlayerBuilder {
operator fun invoke(): Actor { operator fun invoke(): Actor {
val world = (Terrarum.ingame!! as Ingame).gameworld val world = (Terrarum.ingame!! as Ingame).gameworld
val p: Actor = IngamePlayer(Gdx.files.internal("lol"), world.time.TIME_T) val p: Actor = IngamePlayer("lol", world.time.TIME_T)
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json") InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
// attach sprite // attach sprite

View File

@@ -1,6 +1,5 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.Gdx
import net.torvald.terrarum.ModMgr import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.AVKey
@@ -15,7 +14,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
object PlayerBuilderSigrid { object PlayerBuilderSigrid {
operator fun invoke(): IngamePlayer { operator fun invoke(): IngamePlayer {
val p = IngamePlayer(Gdx.files.internal("lol"), - 9223372036854775807L) // XD val p = IngamePlayer("lol", - 9223372036854775807L) // XD
p.referenceID = 0x51621D // the only constant of this procedural universe p.referenceID = 0x51621D // the only constant of this procedural universe

View File

@@ -10,7 +10,7 @@ import net.torvald.terrarum.worlddrawer.FeaturesDrawer
*/ */
object PlayerBuilderTestSubject1 { object PlayerBuilderTestSubject1 {
operator fun invoke(): IngamePlayer { operator fun invoke(): IngamePlayer {
val p: IngamePlayer = IngamePlayer(ModMgr.getGdxFile("basegame", "sprites/test_sprite.properties"), -589141658L) // random value thrown val p: IngamePlayer = IngamePlayer(ModMgr.getPath("basegame", "sprites/test_sprite.properties"), -589141658L) // random value thrown
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json") InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")