able to load player sprite from the disk archive

This commit is contained in:
minjaesong
2021-10-14 17:57:37 +09:00
parent c3b4dbc4b9
commit e679a421e5
9 changed files with 52 additions and 96 deletions

View File

@@ -701,7 +701,7 @@ fun AppUpdateListOfSavegames() {
e.printStackTrace()
null
}
}.filter { it != null }.sortedByDescending { it!!.diskFile.lastModified() } as List<DiskSkimmer>).forEach {
}.filter { it != null }.sortedByDescending { it!!.getLastModifiedOfFirstFile() } as List<DiskSkimmer>).forEach {
println(it.diskFile.absolutePath)
it.rebuild() // disk skimmer was created without initialisation, so do it now
@@ -724,7 +724,7 @@ fun AppUpdateListOfSavegames() {
e.printStackTrace()
null
}
}.filter { it != null }.sortedByDescending { it!!.diskFile.lastModified() } as List<DiskSkimmer>).forEach {
}.filter { it != null }.sortedByDescending { it!!.getLastModifiedOfFirstFile() } as List<DiskSkimmer>).forEach {
println(it.diskFile.absolutePath)
it.rebuild() // disk skimmer was created without initialisation, so do it now

View File

@@ -87,9 +87,9 @@ class IngamePlayer : ActorHumanoid {
fun reassembleSprite(disk: SimpleFileSystem, sprite: SpriteAnimation?, spriteGlow: SpriteAnimation? = null) {
if (animDesc != null && sprite != null)
_rebuild(disk, animDesc!!, sprite)
_rebuild(disk, -1025L, animDesc!!, sprite)
if (animDescGlow != null && spriteGlow != null)
_rebuild(disk, animDescGlow!!, spriteGlow)
_rebuild(disk, -1026L, animDescGlow!!, spriteGlow)
}
private fun _rebuild(ad: ADProperties, sprite: SpriteAnimation) {
@@ -116,10 +116,10 @@ class IngamePlayer : ActorHumanoid {
sprite.nRows = newAnimDelays.size
}
private fun _rebuild(disk: SimpleFileSystem, ad: ADProperties, sprite: SpriteAnimation) {
private fun _rebuild(disk: SimpleFileSystem, entrynum: Long, 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)
val pixmap = if (disk.getEntry(entrynum) != null) AssembleSheetPixmap.fromVirtualDisk(disk, entrynum, ad) else AssembleSheetPixmap.fromAssetsDir(ad)
val texture = Texture(pixmap)
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest)
pixmap.dispose()

View File

@@ -222,8 +222,16 @@ class UILoadDemoSavefiles : UICanvas() {
if (mode == 2) {
loadFired += 1
// to hide the "flipped skybox" artefact
batch.end()
gdxClearAndSetBlend(.094f, .094f, .094f, 0f)
batch.begin()
batch.color = Color.WHITE
val txt = Lang["MENU_IO_LOADING"]
App.fontGame.draw(batch, txt, (App.scr.width - App.fontGame.getWidth(txt)) / 2f, (App.scr.height - App.fontGame.lineHeight) / 2f)
if (loadFired == 2) {
LoadSavegame(playerDisk!!, worldDisk)
}

View File

@@ -10,6 +10,7 @@ import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.WorldgenLoadScreen
import net.torvald.terrarum.modulebasegame.gameactors.PlayerBuilderTestSubject1
import net.torvald.terrarum.modulebasegame.gameactors.PlayerBuilderWerebeastTest
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.utils.RandomWordsName
@@ -39,7 +40,8 @@ class UIProxyNewRandomGame : UICanvas() {
val ingame = TerrarumIngame(App.batch)
val worldParam = TerrarumIngame.NewGameParams(
PlayerBuilderTestSubject1(),
// PlayerBuilderTestSubject1(),
PlayerBuilderWerebeastTest(),
TerrarumIngame.NewWorldParameters(2880, 1350, HQRNG().nextLong(), RandomWordsName(4))
)
// val worldParam = TerrarumIngame.NewWorldParameters(2880, 1350, 0x51621D)

View File

@@ -69,7 +69,7 @@ removefile:
*/
private var entryToOffsetTable = HashMap<EntryID, Long>()
lateinit var fa: RandomAccessFile//RandomAccessFile(diskFile, "rw")
val fa: RandomAccessFile = RandomAccessFile(diskFile, "rw")
private fun debugPrintln(s: Any) {
if (false) println(s.toString())
@@ -87,7 +87,7 @@ removefile:
fun rebuild() {
checkFileSanity() // state of the file may have been changed (e.g. file deleted) so we check again
fa = RandomAccessFile(diskFile, "rw")
// fa = RandomAccessFile(diskFile, "rw")
val fis = FileInputStream(diskFile)
var currentPosition = fis.skip(VirtualDisk.HEADER_SIZE) // skip disk header
@@ -353,6 +353,13 @@ removefile:
return bytes.toCanonicalString(charset)
}
fun getLastModifiedOfFirstFile(): Long {
val bytes = ByteArray(6)
fa.seek(326L)
fa.read(bytes)
return bytes.toInt48()
}
///////////////////////////////////////////////////////
// THESE ARE METHODS TO SUPPORT ON-LINE MODIFICATION //
///////////////////////////////////////////////////////