asset archiving wip

This commit is contained in:
minjaesong
2026-02-20 10:39:53 +09:00
parent 04b49b8a5c
commit 7c8baa151f
49 changed files with 193 additions and 101 deletions

View File

@@ -0,0 +1,15 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Terrarum (no prebuild)" type="JarApplication">
<option name="JAR_PATH" value="$PROJECT_DIR$/out/TerrarumBuild.jar" />
<option name="VM_PARAMETERS" value="-ea -Dswing.aatext=true -Dawt.useSystemAAFontSettings=lcd" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH" value="17" />
<module name="TerrarumBuild" />
<method v="2">
<option name="BuildArtifacts" enabled="true">
<artifact name="TerrarumBuild" />
</option>
<option name="RunConfigurationTask" enabled="false" run_configuration_name="QuickDirtyLint" run_configuration_type="Application" />
</method>
</configuration>
</component>

Binary file not shown.

Binary file not shown.

View File

@@ -629,7 +629,7 @@ public class App implements ApplicationListener {
// make loading list // make loading list
CommonResourcePool.INSTANCE.loadAll(); CommonResourcePool.INSTANCE.loadAll();
newTempFile("wenquanyi.tga"); // temp file required by the font // newTempFile("wenquanyi.tga"); // temp file required by the font
// set basis of draw // set basis of draw
@@ -1992,8 +1992,8 @@ public class App implements ApplicationListener {
} }
public static ShaderProgram loadShaderFromFile(String vert, String frag) { public static ShaderProgram loadShaderFromFile(String vert, String frag) {
String v = Gdx.files.internal(vert).readString("utf-8"); String v = AssetCache.INSTANCE.getFileHandle(vert).readString("utf-8");
String f = Gdx.files.internal(frag).readString("utf-8"); String f = AssetCache.INSTANCE.getFileHandle(frag).readString("utf-8");
return loadShaderInline(v, f); return loadShaderInline(v, f);
} }

View File

@@ -8,6 +8,8 @@ import java.io.File
* Build-time tool that creates assets.tevd from assets_release/ directory. * Build-time tool that creates assets.tevd from assets_release/ directory.
* *
* Usage: java -cp <classpath> net.torvald.terrarum.AssetArchiveBuilderKt [assets_release_dir] [output_file] * Usage: java -cp <classpath> net.torvald.terrarum.AssetArchiveBuilderKt [assets_release_dir] [output_file]
*
* Created by minjaesong on 2026-02-19.
*/ */
fun main(args: Array<String>) { fun main(args: Array<String>) {
val srcDir = File(if (args.isNotEmpty()) args[0] else "assets_release") val srcDir = File(if (args.isNotEmpty()) args[0] else "assets_release")
@@ -24,21 +26,35 @@ fun main(args: Array<String>) {
println("Scanning $srcDir...") println("Scanning $srcDir...")
var totalSize = 0L var totalSize = 0L
var fileCount = 0 var fileCount = 0
srcDir.walkTopDown().filter { it.isFile }.forEach { var dirCount = 0
totalSize += it.length() srcDir.walkTopDown().forEach {
fileCount++ if (it.isFile) {
totalSize += it.length()
fileCount++
} else if (it.isDirectory && it != srcDir) {
dirCount++
}
} }
// Calculate capacity in sectors (4096 bytes per sector/cluster) // Calculate capacity in sectors (4096 bytes per cluster)
// Add overhead for FAT entries and directory structures // Each file uses at least 1 cluster regardless of size
// Each directory also needs a FAT entry and cluster(s) for its directory listing
// FAT entries are 256 bytes each; each cluster holds 16 FAT entries
val clusterSize = ClusteredFormatDOM.CLUSTER_SIZE val clusterSize = ClusteredFormatDOM.CLUSTER_SIZE
val totalEntries = fileCount + dirCount
// Sectors for actual file data (each file rounds up to whole clusters)
val sectorsForData = (totalSize + clusterSize - 1) / clusterSize val sectorsForData = (totalSize + clusterSize - 1) / clusterSize
// Add ~25% overhead for FAT, directory entries, and slack space // Each entry (file or dir) needs at least 1 sector, plus FAT overhead
val capacityInSectors = ((sectorsForData * 1.25) + fileCount + 256).toLong() // FAT entries: 256 bytes each, so totalEntries * 256 / 4096 sectors for FAT
val sectorsForFAT = (totalEntries.toLong() * ClusteredFormatDOM.FAT_ENTRY_SIZE + clusterSize - 1) / clusterSize
// Directory listings: each dir needs cluster(s) to store its child entries
val sectorsForDirs = dirCount.toLong()
// Total with generous margin (50% on data + fixed overhead)
val capacityInSectors = ((sectorsForData * 1.5) + sectorsForFAT + sectorsForDirs + totalEntries + 512).toLong()
.coerceAtMost(ClusteredFormatDOM.MAX_CAPA_IN_SECTORS.toLong()) .coerceAtMost(ClusteredFormatDOM.MAX_CAPA_IN_SECTORS.toLong())
.toInt() .toInt()
println(" Files: $fileCount") println(" Files: $fileCount, Directories: $dirCount")
println(" Total size: ${totalSize / 1024} KB") println(" Total size: ${totalSize / 1024} KB")
println(" Allocating $capacityInSectors sectors...") println(" Allocating $capacityInSectors sectors...")
@@ -46,14 +62,46 @@ fun main(args: Array<String>) {
val diskArchive = ClusteredFormatDOM.createNewArchive(outFile, Charsets.UTF_8, "Terrarum Assets", capacityInSectors) val diskArchive = ClusteredFormatDOM.createNewArchive(outFile, Charsets.UTF_8, "Terrarum Assets", capacityInSectors)
val dom = ClusteredFormatDOM(diskArchive) val dom = ClusteredFormatDOM(diskArchive)
// Pre-grow the FAT area to avoid growFAT/renum being triggered mid-import.
// Initial FAT is 2 clusters (32 entries). Each growFAT roughly doubles it.
// Each file/dir needs 1 FAT entry PLUS extended entries for inline data, long filenames, etc.
// Inline files need ~ceil(fileSize/248) extended entries; inline dirs need extended entries for listings.
// Conservative estimate: each entry needs ~3 FAT slots on average (1 head + 2 extended).
val neededFatClusters = (totalEntries * 3 + 20) / 16 + 4
var estimatedFatClusters = 2
var growthCount = 0
while (estimatedFatClusters < neededFatClusters) {
estimatedFatClusters = 2 * estimatedFatClusters + 2
growthCount++
}
if (growthCount > 0) {
println(" Pre-growing FAT: $growthCount growth(s) -> ~$estimatedFatClusters FAT clusters (${estimatedFatClusters * 16} entries)...")
repeat(growthCount) { dom.growFAT() }
}
println("Importing files from ${srcDir.path}...") println("Importing files from ${srcDir.path}...")
val root = Clustfile(dom, "/") val children = srcDir.listFiles() ?: run {
root.importFrom(srcDir) System.err.println("Error: Could not list files in ${srcDir.path}")
System.exit(1)
return
}
var importedCount = 0
for (child in children.sortedBy { it.name }) {
println(" Importing: ${child.name} (${if (child.isDirectory) "dir" else "${child.length()} bytes"})...")
val dest = Clustfile(dom, "/${child.name}")
val success = dest.importFrom(child)
if (!success) {
System.err.println("Warning: Failed to import ${child.name}")
} else {
importedCount++
println(" Imported: ${child.name}")
}
}
println("Trimming archive...") println("Trimming archive...")
dom.trimArchive() dom.trimArchive()
dom.dispose() dom.dispose()
println("Done. Output:") println("Done. Imported $importedCount top-level entries. Output:")
println(" ${outFile.path} (${outFile.length() / 1024} KB, $fileCount files)") println(" ${outFile.path} (${outFile.length() / 1024} KB, $fileCount files)")
} }

View File

@@ -5,12 +5,17 @@ import com.badlogic.gdx.files.FileHandle
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.archivers.ClusteredFormatDOM import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.archivers.ClusteredFormatDOM
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.archivers.Clustfile import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.archivers.Clustfile
import java.io.File import java.io.File
import java.io.FileNotFoundException
import java.io.RandomAccessFile import java.io.RandomAccessFile
/** /**
* Central accessor for the TerranVirtualDisk asset archive. * Central accessor for the game assets.
* In distribution mode, assets are read directly from assets.tevd. * In distribution mode, assets are read directly from assets.tevd.
* In development mode, assets are read from the local ./assets/ directory. * In development mode, assets are read from the local ./assets/ directory.
*
* Never call `gdx.files.internal` directly!
*
* Created by minjaesong on 2026-02-19.
*/ */
object AssetCache { object AssetCache {
@@ -39,7 +44,10 @@ object AssetCache {
*/ */
fun getClustfile(relativePath: String): Clustfile { fun getClustfile(relativePath: String): Clustfile {
val path = if (relativePath.startsWith("/")) relativePath else "/$relativePath" val path = if (relativePath.startsWith("/")) relativePath else "/$relativePath"
return Clustfile(dom!!, path) return Clustfile(dom!!, path).let {
if (!it.exists()) throw FileNotFoundException("Clustfile not exists: /$relativePath")
else it
}
} }
/** /**

View File

@@ -9,6 +9,8 @@ import java.io.InputStream
/** /**
* A GDX FileHandle backed by a Clustfile from TerranVirtualDisk. * A GDX FileHandle backed by a Clustfile from TerranVirtualDisk.
* Allows transparent asset loading from .tevd archives using all standard GDX APIs. * Allows transparent asset loading from .tevd archives using all standard GDX APIs.
*
* Created by minjaesong on 2026-02-19.
*/ */
class ClustfileHandle(private val clustfile: Clustfile) : FileHandle() { class ClustfileHandle(private val clustfile: Clustfile) : FileHandle() {

View File

@@ -38,7 +38,7 @@ object ColorLimiterTest : ApplicationAdapter() {
override fun create() { override fun create() {
ShaderProgram.pedantic = false ShaderProgram.pedantic = false
shader4096 = ShaderProgram(Gdx.files.internal("assets/shaders/default.vert"), Gdx.files.internal("assets/shaders/postproc_dither.frag")) shader4096 = ShaderProgram(AssetCache.getFileHandle("shaders/default.vert"), AssetCache.getFileHandle("shaders/postproc_dither.frag"))
shader4096.bind() shader4096.bind()
shader4096.setUniformf("rcount", 4f) shader4096.setUniformf("rcount", 4f)
shader4096.setUniformf("gcount", 4f) shader4096.setUniformf("gcount", 4f)
@@ -50,7 +50,7 @@ object ColorLimiterTest : ApplicationAdapter() {
batch = SpriteBatch() batch = SpriteBatch()
shapeRenderer = App.makeShapeRenderer() shapeRenderer = App.makeShapeRenderer()
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap") font = TerrarumSansBitmap()
if (!shader4096.isCompiled) { if (!shader4096.isCompiled) {

View File

@@ -22,16 +22,16 @@ object CommonResourcePool {
init { init {
addToLoadingList("itemplaceholder_16") { addToLoadingList("itemplaceholder_16") {
TextureRegion(Texture("assets/item_kari_16.tga")).also { it.flip(false, false) } TextureRegion(Texture(AssetCache.getFileHandle("item_kari_16.tga"))).also { it.flip(false, false) }
} }
addToLoadingList("itemplaceholder_24") { addToLoadingList("itemplaceholder_24") {
TextureRegion(Texture("assets/item_kari_24.tga")).also { it.flip(false, false) } TextureRegion(Texture(AssetCache.getFileHandle("item_kari_24.tga"))).also { it.flip(false, false) }
} }
addToLoadingList("itemplaceholder_32") { addToLoadingList("itemplaceholder_32") {
TextureRegion(Texture("assets/item_kari_32.tga")).also { it.flip(false, false) } TextureRegion(Texture(AssetCache.getFileHandle("item_kari_32.tga"))).also { it.flip(false, false) }
} }
addToLoadingList("itemplaceholder_48") { addToLoadingList("itemplaceholder_48") {
TextureRegion(Texture("assets/item_kari_48.tga")).also { it.flip(false, false) } TextureRegion(Texture(AssetCache.getFileHandle("item_kari_48.tga"))).also { it.flip(false, false) }
} }
/*addToLoadingList("test_texture") { /*addToLoadingList("test_texture") {
TextureRegion(Texture("assets/test_texture.tga")).also { it.flip(false, false) } TextureRegion(Texture("assets/test_texture.tga")).also { it.flip(false, false) }

View File

@@ -47,10 +47,10 @@ object GlslTilingTest : ApplicationAdapter() {
override fun create() { override fun create() {
ShaderProgram.pedantic = false ShaderProgram.pedantic = false
shader = ShaderProgram(Gdx.files.internal("assets/shaders/default.vert"), Gdx.files.internal("assets/shaders/tiling.frag")) shader = ShaderProgram(AssetCache.getFileHandle("shaders/default.vert"), AssetCache.getFileHandle("shaders/tiling.frag"))
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap") font = TerrarumSansBitmap()
if (!shader.isCompiled) { if (!shader.isCompiled) {
@@ -93,9 +93,9 @@ object GlslTilingTest : ApplicationAdapter() {
batch = SpriteBatch() batch = SpriteBatch()
fucktex = Texture(Gdx.files.internal("assets/graphics/ortho_line_tex_2px.tga")) fucktex = Texture(AssetCache.getFileHandle("graphics/ortho_line_tex_2px.tga"))
tileAtlas = Texture(Gdx.files.internal("assets/terrain.tga"))//BlocksDrawer.tilesTerrain.texture tileAtlas = Texture(AssetCache.getFileHandle("terrain.tga"))//BlocksDrawer.tilesTerrain.texture
println(tilesBuffer.format) println(tilesBuffer.format)

View File

@@ -168,7 +168,7 @@ object ModMgr {
AssetCache.getFileHandle("mods/$moduleName/$metaFilename").exists() AssetCache.getFileHandle("mods/$moduleName/$metaFilename").exists()
else else
File("$modDirInternal/$moduleName/$metaFilename").exists() File("$modDirInternal/$moduleName/$metaFilename").exists()
val isInternal = if (_externalFile.exists()) false else if (internalExists) true else throw FileNotFoundException() val isInternal = if (_externalFile.exists()) false else if (internalExists) true else throw FileNotFoundException("mods/$moduleName/$metaFilename")
val modDir = if (isInternal) modDirInternal else modDirExternal val modDir = if (isInternal) modDirInternal else modDirExternal
fun getGdxFileLocal(path: String) = if (isInternal) { fun getGdxFileLocal(path: String) = if (isInternal) {

View File

@@ -34,7 +34,7 @@ public class MusicComposerApp extends ApplicationAdapter {
@Override @Override
public void create() { public void create() {
fontGame = new TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap", false, true, false); fontGame = new TerrarumSansBitmap(false, true, false);
} }
@Override @Override

View File

@@ -55,10 +55,10 @@ object SanicLoadScreen : LoadScreenBase() {
false false
) )
arrowObjTex = Texture(Gdx.files.internal("assets/graphics/test_loading_arrow_atlas.tga")) arrowObjTex = Texture(AssetCache.getFileHandle("graphics/test_loading_arrow_atlas.tga"))
arrowObjGlideOffsetX = -arrowObjTex.width.toFloat() arrowObjGlideOffsetX = -arrowObjTex.width.toFloat()
textOverlayTex = Texture(Gdx.files.internal("assets/graphics/test_loading_text_tint.tga")) textOverlayTex = Texture(AssetCache.getFileHandle("graphics/test_loading_text_tint.tga"))
} }

View File

@@ -39,10 +39,10 @@ object ShitOnGlsl : ApplicationAdapter() {
override fun create() { override fun create() {
ShaderProgram.pedantic = false ShaderProgram.pedantic = false
shader = ShaderProgram(Gdx.files.internal("assets/shaders/default.vert"), Gdx.files.internal("assets/shaders/crt.frag")) shader = ShaderProgram(AssetCache.getFileHandle("shaders/default.vert"), AssetCache.getFileHandle("shaders/crt.frag"))
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap") font = TerrarumSansBitmap()
if (!shader.isCompiled) { if (!shader.isCompiled) {
@@ -75,8 +75,8 @@ object ShitOnGlsl : ApplicationAdapter() {
batch = SpriteBatch() batch = SpriteBatch()
fucktex = Texture(Gdx.files.internal("assets/graphics/ortho_line_tex_2px.tga")) fucktex = Texture(AssetCache.getFileHandle("graphics/ortho_line_tex_2px.tga"))
testTex = Texture(Gdx.files.internal("assets/test_texture.tga")) testTex = Texture(AssetCache.getFileHandle("test_texture.tga"))
} }

View File

@@ -37,7 +37,7 @@ object TerrarumPostProcessor : Disposable {
private lateinit var outFBO: FrameBuffer private lateinit var outFBO: FrameBuffer
fun reloadLUT(filename: String) { fun reloadLUT(filename: String) {
lutTex = Texture(Gdx.files.internal("assets/clut/$filename")) lutTex = Texture(AssetCache.getFileHandle("clut/$filename"))
} }
private val defaultResCol = Color(0x66ffff66) private val defaultResCol = Color(0x66ffff66)
@@ -48,9 +48,9 @@ object TerrarumPostProcessor : Disposable {
internal val debugUI = BasicDebugInfoWindow() internal val debugUI = BasicDebugInfoWindow()
private val functionRowHelper = Texture(Gdx.files.internal("assets/graphics/function_row_help.png")) private val functionRowHelper = Texture(AssetCache.getFileHandle("graphics/function_row_help.png"))
private val batteryTex = TextureRegionPack(Gdx.files.internal("assets/graphics/gui/fullscreen_bat_ind.tga"), 23, 14) private val batteryTex = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/fullscreen_bat_ind.tga"), 23, 14)
private val shaderPostDither = ShaderMgr["postDither"] private val shaderPostDither = ShaderMgr["postDither"]
private val shaderPostNoDither = ShaderMgr["postNoDither"] private val shaderPostNoDither = ShaderMgr["postNoDither"]

View File

@@ -50,7 +50,7 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
img = Texture("assets/test_texture.tga") img = Texture("assets/test_texture.tga")
gameFont = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap") gameFont = TerrarumSansBitmap()
//gameFont = BitmapFont() //gameFont = BitmapFont()
@@ -196,7 +196,7 @@ object TestTestMain : ApplicationAdapter() {
override fun create() { override fun create() {
ShaderProgram.pedantic = false ShaderProgram.pedantic = false
blurShader = ShaderProgram(Gdx.files.internal("assets/shaders/blur.vert"), Gdx.files.internal("assets/shaders/blur.frag")) blurShader = ShaderProgram(AssetCache.getFileHandle("shaders/blur.vert"), AssetCache.getFileHandle("shaders/blur.frag"))
batch = SpriteBatch() batch = SpriteBatch()

View File

@@ -60,7 +60,7 @@ object TexRegionTilingTest : ApplicationAdapter() {
val gzTmpFName = listOf("tmp_terrain.tga", "tmp_wire.tga") val gzTmpFName = listOf("tmp_terrain.tga", "tmp_wire.tga")
// unzip GZIP temporarily // unzip GZIP temporarily
gzFileList.forEachIndexed { index, filename -> gzFileList.forEachIndexed { index, filename ->
val terrainTexFile = Gdx.files.internal("assets/modules/basegame/" + filename) val terrainTexFile = AssetCache.getFileHandle("modules/basegame/" + filename)
val gzi = GZIPInputStream(terrainTexFile.read(8192)) val gzi = GZIPInputStream(terrainTexFile.read(8192))
val wholeFile = gzi.readBytes() val wholeFile = gzi.readBytes()
gzi.close() gzi.close()

View File

@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.AssetCache
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import java.io.File import java.io.File
@@ -108,8 +109,8 @@ object IME {
} }
val iconSheet = TextureRegionPack("assets/graphics/gui/ime_icons_by_language.tga", 20, 20) val iconSheet = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/ime_icons_by_language.tga"), 20, 20)
val iconPixmap = Pixmap(Gdx.files.internal("assets/graphics/gui/ime_icons_by_language.tga")) val iconPixmap = Pixmap(AssetCache.getFileHandle("graphics/gui/ime_icons_by_language.tga"))
for (k in 0 until iconPixmap.height step 20) { for (k in 0 until iconPixmap.height step 20) {
val langCode = StringBuilder() val langCode = StringBuilder()
for (c in 0 until 20) { for (c in 0 until 20) {

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.gamecontroller package net.torvald.terrarum.gamecontroller
import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.AssetCache
import net.torvald.util.SortedArrayList import net.torvald.util.SortedArrayList
import org.graalvm.polyglot.HostAccess import org.graalvm.polyglot.HostAccess
import java.io.File import java.io.File
@@ -29,7 +30,7 @@ class IMEDictionary(private val filename: String) {
private var dictLoaded = false private var dictLoaded = false
private fun loadDict() { private fun loadDict() {
val reader = FileReader(File("assets/keylayout/", filename), Charsets.UTF_8) val reader = AssetCache.getFileHandle("keylayout/$filename").reader(Charsets.UTF_8.displayName())
reader.forEachLine { reader.forEachLine {
if (it.contains(',')) { if (it.contains(',')) {
val (key, value) = it.split(',') val (key, value) = it.split(',')

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.GlyphLayout import com.badlogic.gdx.graphics.g2d.GlyphLayout
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.roundToFloat import net.torvald.terrarum.roundToFloat
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -15,7 +16,7 @@ object BigAlphNum : BitmapFont() {
internal const val W = 12 internal const val W = 12
internal const val H = 16 internal const val H = 16
internal val fontSheet = TextureRegionPack("./assets/graphics/fonts/code.tga", W, H) internal val fontSheet = TextureRegionPack(AssetCache.getFileHandle("graphics/fonts/code.tga"), W, H)
private const val interchar = 1 private const val interchar = 1

View File

@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.GlyphLayout import com.badlogic.gdx.graphics.g2d.GlyphLayout
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.roundToFloat import net.torvald.terrarum.roundToFloat
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import kotlin.math.roundToInt import kotlin.math.roundToInt
@@ -18,8 +19,8 @@ object TinyAlphNum : BitmapFont() {
internal const val W = 7 internal const val W = 7
internal const val H = 13 internal const val H = 13
internal val fontSheet = TextureRegionPack("./assets/graphics/fonts/7x13_Tamzen7x14b.tga", W+1, H+1) internal val fontSheet = TextureRegionPack(AssetCache.getFileHandle("graphics/fonts/7x13_Tamzen7x14b.tga"), W+1, H+1)
internal val fontPixmap = Pixmap(Gdx.files.internal("./assets/graphics/fonts/7x13_Tamzen7x14b.tga")) internal val fontPixmap = Pixmap(AssetCache.getFileHandle("graphics/fonts/7x13_Tamzen7x14b.tga"))
init { init {
setOwnsTexture(true) setOwnsTexture(true)

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.langpack
import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.files.FileHandle
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.tail import net.torvald.terrarum.tail
import net.torvald.terrarum.utils.JsonFetcher import net.torvald.terrarum.utils.JsonFetcher
import net.torvald.unicode.getKeycapPC import net.torvald.unicode.getKeycapPC
@@ -49,13 +50,13 @@ object Lang {
init { init {
// load base langs // load base langs
load(File("./assets/locales/")) load(AssetCache.getFileHandle("locales/"))
} }
@JvmStatic operator fun invoke() { /* dummy method for manual initialisation */ } @JvmStatic operator fun invoke() { /* dummy method for manual initialisation */ }
fun load(localesDir: File) { /*fun load(localesDir: File) {
printdbg(this, "Loading languages from $localesDir") printdbg(this, "Loading languages from $localesDir")
// get all of the languages installed // get all of the languages installed
@@ -81,7 +82,7 @@ object Lang {
} }
} }
} }*/
fun load(localesHandle: FileHandle) { fun load(localesHandle: FileHandle) {
printdbg(this, "Loading languages from ${localesHandle.path()}") printdbg(this, "Loading languages from ${localesHandle.path()}")

View File

@@ -149,8 +149,8 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
private lateinit var worldFBO: Float16FrameBuffer private lateinit var worldFBO: Float16FrameBuffer
private val warning32bitJavaIcon = TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/32_bit_warning.tga"))) private val warning32bitJavaIcon = TextureRegion(Texture(AssetCache.getFileHandle("graphics/gui/32_bit_warning.tga")))
private val warningAppleRosettaIcon = TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/apple_rosetta_warning.tga"))) private val warningAppleRosettaIcon = TextureRegion(Texture(AssetCache.getFileHandle("graphics/gui/apple_rosetta_warning.tga")))
init { init {
gameUpdateGovernor = ConsistentUpdateRate.also { it.reset() } gameUpdateGovernor = ConsistentUpdateRate.also { it.reset() }
@@ -219,7 +219,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
// load a half-gradient texture that would be used throughout the titlescreen and its sub UIs // load a half-gradient texture that would be used throughout the titlescreen and its sub UIs
CommonResourcePool.addToLoadingList("title_halfgrad") { CommonResourcePool.addToLoadingList("title_halfgrad") {
Texture(Gdx.files.internal("./assets/graphics/halfgrad.tga")).also { Texture(AssetCache.getFileHandle("graphics/halfgrad.tga")).also {
it.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear) it.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
} }
} }

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.console
import com.badlogic.gdx.Gdx import com.badlogic.gdx.Gdx
import com.badlogic.gdx.audio.Music import com.badlogic.gdx.audio.Music
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.console.ConsoleCommand import net.torvald.terrarum.console.ConsoleCommand
import net.torvald.terrarum.console.Echo import net.torvald.terrarum.console.Echo
@@ -35,7 +36,7 @@ internal object MusicTest : ConsoleCommand {
File("./assets/sounds/test/${args[1]}").absoluteFile.toURI().toURL() File("./assets/sounds/test/${args[1]}").absoluteFile.toURI().toURL()
).playAsMusic(1f, 1f, false)*/ ).playAsMusic(1f, 1f, false)*/
music = Gdx.audio.newMusic(Gdx.files.internal("./assets/sounds/test/${args[1]}")) music = Gdx.audio.newMusic(AssetCache.getFileHandle("sounds/test/${args[1]}"))
music!!.play() music!!.play()
} }

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameitems
import com.badlogic.gdx.Gdx import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.gameitems.ItemID import net.torvald.terrarum.gameitems.ItemID
@@ -29,7 +30,7 @@ class ItemTapestry(originalID: ItemID) : FixtureItemBase(originalID, "net.torval
@Transient override val makeFixture: (String) -> FixtureBase = { moduleName: String -> @Transient override val makeFixture: (String) -> FixtureBase = { moduleName: String ->
FixtureTapestry( FixtureTapestry(
// TODO use extra["fileRef"] (string) and extra["framingMaterial"] (string) // TODO use extra["fileRef"] (string) and extra["framingMaterial"] (string)
Gdx.files.internal("assets/monkey_island").readBytes(), AssetCache.getFileHandle("monkey_island").readBytes(),
Block.PLANK_NORMAL Block.PLANK_NORMAL
) )
} }

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.imagefont
import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.GlyphLayout import com.badlogic.gdx.graphics.g2d.GlyphLayout
import net.torvald.terrarum.AssetCache
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/** /**
@@ -22,7 +23,7 @@ class NewRunes : BitmapFont() {
null null
private val runes = TextureRegionPack("./assets/graphics/fonts/newrunes.tga", runeSize, runeSize) private val runes = TextureRegionPack(AssetCache.getFileHandle("graphics/fonts/newrunes.tga"), runeSize, runeSize)
var scale = 1 var scale = 1
var linegap = 8 var linegap = 8

View File

@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.TerrarumScreenSize import net.torvald.terrarum.TerrarumScreenSize
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
@@ -22,10 +23,10 @@ object ControlPanelCommon {
init { init {
CommonResourcePool.addToLoadingList("gui_hrule") { CommonResourcePool.addToLoadingList("gui_hrule") {
TextureRegionPack(Gdx.files.internal("assets/graphics/gui/hrule.tga"), 216, 20) TextureRegionPack(AssetCache.getFileHandle("graphics/gui/hrule.tga"), 216, 20)
} }
CommonResourcePool.addToLoadingList("gui_slider_horz_backdrop_contrast") { CommonResourcePool.addToLoadingList("gui_slider_horz_backdrop_contrast") {
TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/slider_background_contrast.tga")).also { TextureRegion(Texture(AssetCache.getFileHandle("graphics/gui/slider_background_contrast.tga")).also {
it.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear) it.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
}) })
} }

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.toInt import net.torvald.terrarum.toInt
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -28,7 +29,7 @@ object ItemSlotImageFactory {
/** Blend mode: screen */ /** Blend mode: screen */
val CELLCOLOUR_BLACK_ACTIVE = Color(0x282828ff) val CELLCOLOUR_BLACK_ACTIVE = Color(0x282828ff)
val slotImage = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slots_atlas2.tga"), TILE_WIDTH, TILE_HEIGHT) // must have same w/h as slotLarge val slotImage = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/quickbar/item_slots_atlas2.tga"), TILE_WIDTH, TILE_HEIGHT) // must have same w/h as slotLarge
fun produce(isBlack: Boolean, number: Int?, sprite: TextureRegion?): ItemSlotImage { fun produce(isBlack: Boolean, number: Int?, sprite: TextureRegion?): ItemSlotImage {
return ItemSlotImage(slotImage.get(number ?: 10, 0 or isBlack.toInt().shl(1)), sprite) return ItemSlotImage(slotImage.get(number ?: 10, 0 or isBlack.toInt().shl(1)), sprite)

View File

@@ -67,7 +67,7 @@ package net.torvald.terrarum.modulebasegame.ui
// will be disposed by Terrarum (application main instance) // will be disposed by Terrarum (application main instance)
val SEGMENT_BLACK = TextureRegionPack("assets/graphics/gui/message_black.tga", 8, 56) val SEGMENT_BLACK = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/message_black.tga"), 8, 56)
val SEGMENT_WHITE = TextureRegionPack("assets/graphics/gui/message_white.tga", 8, 56) val SEGMENT_WHITE = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/message_white.tga"), 8, 56)
} }
}*/ }*/

View File

@@ -76,7 +76,7 @@ package net.torvald.terrarum.modulebasegame.ui
readFromLang = true, readFromLang = true,
textAreaWidth = 100, textAreaWidth = 100,
defaultSelection = 0, defaultSelection = 0,
iconSpriteSheet = TextureRegionPack("./assets/graphics/gui/inventory/category.tga", 20, 20), iconSpriteSheet = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/inventory/category.tga"), 20, 20),
iconSpriteSheetIndices = intArrayOf(9,6,7,1,0,2,3,4,5,8), iconSpriteSheetIndices = intArrayOf(9,6,7,1,0,2,3,4,5,8),
iconCol = defaultTextColour, iconCol = defaultTextColour,
highlightBackCol = Color(0xb8b8b8_ff.toInt()), highlightBackCol = Color(0xb8b8b8_ff.toInt()),
@@ -108,7 +108,7 @@ package net.torvald.terrarum.modulebasegame.ui
private val scrollImageButtonAtlas = TextureRegionPack( private val scrollImageButtonAtlas = TextureRegionPack(
Gdx.files.internal("assets/graphics/gui/inventory/page_arrow_button.tga"), AssetCache.getFileHandle("graphics/gui/inventory/page_arrow_button.tga"),
40, 54 40, 54
) )
private val scrollLeftButton = UIItemImageButton(this, private val scrollLeftButton = UIItemImageButton(this,

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.GdxColorMap import net.torvald.terrarum.GdxColorMap
import net.torvald.terrarum.gameitems.GameItem import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.ui.Toolkit import net.torvald.terrarum.ui.Toolkit
@@ -86,7 +87,7 @@ abstract class UIItemInventoryCellBase(
} }
object UIItemInventoryCellCommonRes { object UIItemInventoryCellCommonRes {
val meterColourMap = GdxColorMap(Gdx.files.internal("./assets/clut/health_bar_colouring_4096.tga")) val meterColourMap = GdxColorMap(AssetCache.getFileHandle("clut/health_bar_colouring_4096.tga"))
val meterBackDarkening = Color(0x666666ff.toInt()) val meterBackDarkening = Color(0x666666ff.toInt())
fun getHealthMeterColour(value: Float, start: Float, end: Float): Color { fun getHealthMeterColour(value: Float, start: Float, end: Float): Color {

View File

@@ -66,7 +66,7 @@ open class UIItemInventoryItemGrid(
init { init {
CommonResourcePool.addToLoadingList("inventory_walletnumberfont") { CommonResourcePool.addToLoadingList("inventory_walletnumberfont") {
TextureRegionPack("./assets/graphics/fonts/inventory_wallet_numbers.tga", 20, 9) TextureRegionPack(AssetCache.getFileHandle("graphics/fonts/inventory_wallet_numbers.tga"), 20, 9)
} }
CommonResourcePool.loadAll() CommonResourcePool.loadAll()
} }
@@ -105,7 +105,7 @@ open class UIItemInventoryItemGrid(
var inventorySortList = ArrayList<InventoryPair>() var inventorySortList = ArrayList<InventoryPair>()
protected var rebuildList = true protected var rebuildList = true
protected val walletFont = TextureRegionPack("./assets/graphics/fonts/inventory_wallet_numbers.tga", 20, 9) protected val walletFont = TextureRegionPack(AssetCache.getFileHandle("graphics/fonts/inventory_wallet_numbers.tga"), 20, 9)
protected var walletText = "" protected var walletText = ""

View File

@@ -103,10 +103,10 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : Advanceable() {
init { init {
CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") { CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") {
TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/savegame_thumb_placeholder.png"))) TextureRegion(Texture(AssetCache.getFileHandle("graphics/gui/savegame_thumb_placeholder.png")))
} }
CommonResourcePool.addToLoadingList("savegame_status_icon") { CommonResourcePool.addToLoadingList("savegame_status_icon") {
TextureRegionPack("assets/graphics/gui/savegame_status_icon.tga", 24, 24) TextureRegionPack(AssetCache.getFileHandle("graphics/gui/savegame_status_icon.tga"), 24, 24)
} }
CommonResourcePool.loadAll() CommonResourcePool.loadAll()
} }

View File

@@ -73,7 +73,7 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
init { init {
CommonResourcePool.addToLoadingList("gradtile32") { CommonResourcePool.addToLoadingList("gradtile32") {
TextureRegionPack("assets/graphics/gui/gradtile32.tga", 1, 32) TextureRegionPack(AssetCache.getFileHandle("graphics/gui/gradtile32.tga"), 1, 32)
} }
CommonResourcePool.loadAll() CommonResourcePool.loadAll()
} }

View File

@@ -28,10 +28,10 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
handler.allowESCtoClose = false handler.allowESCtoClose = false
CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") { CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") {
TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/savegame_thumb_placeholder.png"))) TextureRegion(Texture(AssetCache.getFileHandle("graphics/gui/savegame_thumb_placeholder.png")))
} }
CommonResourcePool.addToLoadingList("savegame_status_icon") { CommonResourcePool.addToLoadingList("savegame_status_icon") {
TextureRegionPack("assets/graphics/gui/savegame_status_icon.tga", 24, 24) TextureRegionPack(AssetCache.getFileHandle("graphics/gui/savegame_status_icon.tga"), 24, 24)
} }
CommonResourcePool.loadAll() CommonResourcePool.loadAll()
} }

View File

@@ -103,7 +103,7 @@ class BTeXTest(batch: FlippingSpriteBatch) : IngameInstance(batch) {
Thread { Thread {
try { try {
measureTimeMillis { measureTimeMillis {
val f = BTeXParser.invoke(Gdx.files.internal("./assets/mods/basegame/books/$filePath"), varMap, typesetProgress) val f = BTeXParser.invoke(AssetCache.getFileHandle("mods/basegame/books/$filePath"), varMap, typesetProgress)
document = f.first document = f.first
documentHandler = f.second documentHandler = f.second
}.also { }.also {
@@ -130,7 +130,7 @@ class BTeXTest(batch: FlippingSpriteBatch) : IngameInstance(batch) {
} }
else { else {
measureTimeMillis { measureTimeMillis {
document = BTeXDocument.fromFile(Gdx.files.internal("./assets/mods/basegame/books/$filePath")) document = BTeXDocument.fromFile(AssetCache.getFileHandle("mods/basegame/books/$filePath"))
}.also { }.also {
println("Time spent on loading [ms]: $it") println("Time spent on loading [ms]: $it")
} }

View File

@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.utils.GdxRuntimeException import com.badlogic.gdx.utils.GdxRuntimeException
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.ItemCodex import net.torvald.terrarum.ItemCodex
import net.torvald.terrarum.ReferencingRanges import net.torvald.terrarum.ReferencingRanges
import net.torvald.terrarum.gameitems.GameItem import net.torvald.terrarum.gameitems.GameItem
@@ -34,7 +35,7 @@ object AssembleSheetPixmap {
* The name of the Bodypart here may or may not be case-sensitive (depends on your actual filesystem -- NTFS, APFS, Ext4, ...) * The name of the Bodypart here may or may not be case-sensitive (depends on your actual filesystem -- NTFS, APFS, Ext4, ...)
*/ */
fun getAssetsDirFileGetter(properties: ADProperties): (String) -> InputStream? = { partName: String -> fun getAssetsDirFileGetter(properties: ADProperties): (String) -> InputStream? = { partName: String ->
val file = Gdx.files.internal("assets/${properties.toFilename(partName)}") val file = AssetCache.getFileHandle("${properties.toFilename(partName)}")
if (file.exists()) file.read() else null if (file.exists()) file.read() else null
} }

View File

@@ -14,6 +14,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.graphics.glutils.ShaderProgram import com.badlogic.gdx.graphics.glutils.ShaderProgram
import net.torvald.btex.BTeXDocViewer import net.torvald.btex.BTeXDocViewer
import net.torvald.btex.BTeXParser import net.torvald.btex.BTeXParser
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.FlippingSpriteBatch import net.torvald.terrarum.FlippingSpriteBatch
import net.torvald.terrarum.btex.BTeXDocument import net.torvald.terrarum.btex.BTeXDocument
import net.torvald.terrarum.gdxClearAndEnableBlend import net.torvald.terrarum.gdxClearAndEnableBlend
@@ -82,7 +83,7 @@ class BTeXTest : ApplicationAdapter() {
Thread { Thread {
try { try {
measureTimeMillis { measureTimeMillis {
val f = BTeXParser.invoke(Gdx.files.internal("./assets/mods/basegame/books/$filePath"), varMap, typesetProgress) val f = BTeXParser.invoke(AssetCache.getFileHandle("mods/basegame/books/$filePath"), varMap, typesetProgress)
document = f.first document = f.first
documentHandler = f.second documentHandler = f.second
}.also { }.also {
@@ -103,7 +104,7 @@ class BTeXTest : ApplicationAdapter() {
} }
else { else {
measureTimeMillis { measureTimeMillis {
document = BTeXDocument.fromFile(Gdx.files.internal("./assets/mods/basegame/books/$filePath")) document = BTeXDocument.fromFile(AssetCache.getFileHandle("mods/basegame/books/$filePath"))
}.also { }.also {
println("Time spent on loading [ms]: $it") println("Time spent on loading [ms]: $it")
} }

View File

@@ -6,6 +6,7 @@ import com.badlogic.gdx.Screen
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration
import com.badlogic.gdx.graphics.glutils.ShaderProgram import com.badlogic.gdx.graphics.glutils.ShaderProgram
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.GdxColorMap import net.torvald.terrarum.GdxColorMap
/** /**
@@ -26,7 +27,7 @@ class ColorMapTest : Game() {
} }
override fun render() { override fun render() {
val colormap = GdxColorMap(Gdx.files.internal("assets/testimage_resized.png")) val colormap = GdxColorMap(AssetCache.getFileHandle("testimage_resized.png"))
println(colormap) println(colormap)
System.exit(0) System.exit(0)

View File

@@ -6,6 +6,7 @@ import com.badlogic.gdx.audio.Sound
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration
import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.files.FileHandle
import net.torvald.terrarum.AssetCache
import java.awt.BorderLayout import java.awt.BorderLayout
import javax.swing.JFrame import javax.swing.JFrame
import javax.swing.JPanel import javax.swing.JPanel
@@ -41,7 +42,7 @@ class AudioPlayerSlave : Game() {
override fun create() { override fun create() {
audioSample = Gdx.files.internal("assets/loopey.wav") audioSample = AssetCache.getFileHandle("loopey.wav")
gdxSound = Gdx.audio.newSound(audioSample) gdxSound = Gdx.audio.newSound(audioSample)
surroundPanner = SurroundPannerTest() surroundPanner = SurroundPannerTest()
soundID = gdxSound.loop() soundID = gdxSound.loop()
@@ -137,7 +138,7 @@ class AudioPlayerSlave : Game() {
override fun create() { override fun create() {
audioSample = Gdx.files.internal("assets/loopey.wav") audioSample = AssetCache.getFileHandle("loopey.wav")
gdxSound = Gdx.audio.newSound(audioSample) gdxSound = Gdx.audio.newSound(audioSample)

View File

@@ -73,7 +73,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
private var genFutures: Array<Future<*>?> = arrayOfNulls(genSlices) private var genFutures: Array<Future<*>?> = arrayOfNulls(genSlices)
override fun create() { override fun create() {
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap") font = TerrarumSansBitmap()
batch = FlippingSpriteBatch(1000) batch = FlippingSpriteBatch(1000)
camera = OrthographicCamera(NOISEBOX_WIDTH.toFloat(), NOISEBOX_HEIGHT.toFloat()) camera = OrthographicCamera(NOISEBOX_WIDTH.toFloat(), NOISEBOX_HEIGHT.toFloat())

View File

@@ -53,9 +53,9 @@ class BasicDebugInfoWindow : UICanvas() {
private var ingame: IngameInstance? = null private var ingame: IngameInstance? = null
internal var world: GameWorld? = null // is set by IngameRenderer.setRenderedWorld(GameWorld) internal var world: GameWorld? = null // is set by IngameRenderer.setRenderedWorld(GameWorld)
private val icons = TextureRegionPack(Gdx.files.internal("assets/graphics/gui/debug_window_symbols.tga"), 21, 26) private val icons = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/debug_window_symbols.tga"), 21, 26)
private val back = Texture(Gdx.files.internal("assets/graphics/gui/debug_window_background.tga")) private val back = Texture(AssetCache.getFileHandle("graphics/gui/debug_window_background.tga"))
private val back2 = Texture(Gdx.files.internal("assets/graphics/gui/debug_window_background2.tga")) private val back2 = Texture(AssetCache.getFileHandle("graphics/gui/debug_window_background2.tga"))
private val ARROW_RIGHT = 0xC0.toChar() private val ARROW_RIGHT = 0xC0.toChar()
private val ARROW_LEFT = 0xC1.toChar() private val ARROW_LEFT = 0xC1.toChar()

View File

@@ -46,11 +46,11 @@ object Toolkit : Disposable {
} }
private lateinit var fboBlur: Float16FrameBuffer private lateinit var fboBlur: Float16FrameBuffer
// val baloonTile = TextureRegionPack("assets/graphics/gui/message_black_tileable.tga", 36, 36) // val baloonTile = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/message_black_tileable.tga"), 36, 36)
val shadowTile = TextureRegionPack("assets/graphics/gui/blur_shadow.tga", 32, 32) val shadowTile = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/blur_shadow.tga"), 32, 32)
val textureWhiteSquare = Texture(Gdx.files.internal("assets/graphics/ortho_line_tex_2px.tga")) val textureWhiteSquare = Texture(AssetCache.getFileHandle("graphics/ortho_line_tex_2px.tga"))
val textureWhiteCircle = Texture(Gdx.files.internal("assets/graphics/circle_512.tga")) val textureWhiteCircle = Texture(AssetCache.getFileHandle("graphics/circle_512.tga"))
init { init {
App.disposables.add(this) App.disposables.add(this)
@@ -59,7 +59,7 @@ object Toolkit : Disposable {
textureWhiteCircle.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear) textureWhiteCircle.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
CommonResourcePool.addToLoadingList("toolkit_box_border") { CommonResourcePool.addToLoadingList("toolkit_box_border") {
TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/box_border_flat_tileable.tga"), 1, 1) TextureRegionPack(AssetCache.getFileHandle("graphics/gui/box_border_flat_tileable.tga"), 1, 1)
} }
CommonResourcePool.loadAll() CommonResourcePool.loadAll()
} }

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.imagefont.TinyAlphNum import net.torvald.terrarum.imagefont.TinyAlphNum
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -26,7 +27,7 @@ class UIItemConfigKeycap(
if (keySize < 3) throw IllegalArgumentException("Key size must be greater than 2 (got $keySize)") if (keySize < 3) throw IllegalArgumentException("Key size must be greater than 2 (got $keySize)")
CommonResourcePool.addToLoadingList("ui_item_keymap_keycap") { CommonResourcePool.addToLoadingList("ui_item_keymap_keycap") {
TextureRegionPack("./assets/graphics/gui/ui_control_key_map_keycap.tga", 8, 32) TextureRegionPack(AssetCache.getFileHandle("graphics/gui/ui_control_key_map_keycap.tga"), 8, 32)
} }
CommonResourcePool.loadAll() CommonResourcePool.loadAll()
} }

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.imagefont.BigAlphNum import net.torvald.terrarum.imagefont.BigAlphNum
import net.torvald.terrarum.utils.PasswordBase32 import net.torvald.terrarum.utils.PasswordBase32
@@ -34,7 +35,7 @@ class UIItemRedeemCodeArea(
init { init {
CommonResourcePool.addToLoadingList("spritesheet:terrarum_redeem_code_form") { CommonResourcePool.addToLoadingList("spritesheet:terrarum_redeem_code_form") {
TextureRegionPack(Gdx.files.internal("assets/graphics/code_input_cells.tga"), CELL_W, CELL_H) TextureRegionPack(AssetCache.getFileHandle("graphics/code_input_cells.tga"), CELL_W, CELL_H)
} }
CommonResourcePool.loadAll() CommonResourcePool.loadAll()
} }

View File

@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.blendNormalStraightAlpha import net.torvald.terrarum.blendNormalStraightAlpha
import net.torvald.terrarum.toInt import net.torvald.terrarum.toInt
@@ -28,7 +29,7 @@ class UIItemToggleButton(
init { init {
CommonResourcePool.addToLoadingList("gui_toggler_icons") { CommonResourcePool.addToLoadingList("gui_toggler_icons") {
TextureRegionPack(Texture(Gdx.files.internal("assets/graphics/gui/toggler_icons.tga")), 14, 14) TextureRegionPack(Texture(AssetCache.getFileHandle("graphics/gui/toggler_icons.tga")), 14, 14)
} }
CommonResourcePool.loadAll() CommonResourcePool.loadAll()
} }

View File

@@ -12,6 +12,7 @@ import net.torvald.colourutil.toRGB
import net.torvald.parametricsky.ArHosekSkyModel import net.torvald.parametricsky.ArHosekSkyModel
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.AssetCache
import net.torvald.terrarum.abs import net.torvald.terrarum.abs
import net.torvald.terrarum.floorToInt import net.torvald.terrarum.floorToInt
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -36,7 +37,7 @@ object SkyboxModelHosek : SkyboxModel {
private lateinit var texStripRegions: TextureRegionPack private lateinit var texStripRegions: TextureRegionPack
fun loadlut() { fun loadlut() {
tex = Texture(Gdx.files.internal("assets/clut/skybox.png")) tex = Texture(AssetCache.getFileHandle("clut/skybox.png"))
tex.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear) tex.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
tex.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat) tex.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat)
texRegions = TextureRegionPack(tex, 2, gradSize - 2, 0, 2, 0, 1) texRegions = TextureRegionPack(tex, 2, gradSize - 2, 0, 2, 0, 1)

View File

@@ -91,7 +91,7 @@ internal object WeatherMixer : RNGConsumer {
var forceTurbidity: Double? = null var forceTurbidity: Double? = null
// doesn't work if the png is in greyscale/indexed mode // doesn't work if the png is in greyscale/indexed mode
val starmapTex: TextureRegion = TextureRegion(Texture(Gdx.files.internal("assets/graphics/astrum.png"))).also { val starmapTex: TextureRegion = TextureRegion(Texture(AssetCache.getFileHandle("graphics/astrum.png"))).also {
it.texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear) it.texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
it.texture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat) it.texture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat)
} }
@@ -112,7 +112,7 @@ internal object WeatherMixer : RNGConsumer {
get() = 256 shl (App.getConfigInt("maxparticles") / 256) get() = 256 shl (App.getConfigInt("maxparticles") / 256)
private val skyboxavr = GdxColorMap(Gdx.files.internal("assets/clut/skyboxavr.png")) private val skyboxavr = GdxColorMap(AssetCache.getFileHandle("clut/skyboxavr.png"))
override fun loadFromSave(ingame: IngameInstance, s0: Long, s1: Long) { override fun loadFromSave(ingame: IngameInstance, s0: Long, s1: Long) {

View File

@@ -97,7 +97,7 @@ class CreateTileAtlas {
// 16 tiles are reserved for internal use: solid black, solid white, breakage stages. // 16 tiles are reserved for internal use: solid black, solid white, breakage stages.
// 0th tile is complete transparent tile and is also a BlockID of zero: air. // 0th tile is complete transparent tile and is also a BlockID of zero: air.
private var atlasCursor = 66 // 66 predefined tiles. The normal blocks (e.g. Air) should start from this number private var atlasCursor = 66 // 66 predefined tiles. The normal blocks (e.g. Air) should start from this number
private val atlasInit = "./assets/graphics/blocks/init.tga" private val atlasInit = "graphics/blocks/init.tga"
private var itemSheetCursor = 16 private var itemSheetCursor = 16
internal lateinit var itemTerrainPixmap: Pixmap internal lateinit var itemTerrainPixmap: Pixmap
@@ -111,7 +111,7 @@ class CreateTileAtlas {
get() = atlasVernal get() = atlasVernal
private fun drawInitPixmap() { private fun drawInitPixmap() {
val initPixmap = Pixmap(Gdx.files.internal(atlasInit)) val initPixmap = Pixmap(AssetCache.getFileHandle(atlasInit))
val tilesInInitPixmap = (initPixmap.width * initPixmap.height) / (TILE_SIZE * TILE_SIZE) val tilesInInitPixmap = (initPixmap.width * initPixmap.height) / (TILE_SIZE * TILE_SIZE)
val tilesPossibleInCurrentPixmap = (atlas.width * atlas.height) / (TILE_SIZE * TILE_SIZE) val tilesPossibleInCurrentPixmap = (atlas.width * atlas.height) / (TILE_SIZE * TILE_SIZE)
@@ -240,10 +240,10 @@ class CreateTileAtlas {
printdbg(this, "processing $prefix $modname:${filehandle.name()}") printdbg(this, "processing $prefix $modname:${filehandle.name()}")
try { try {
val glowFile = Gdx.files.internal( val glowFile = AssetCache.getFileHandle(
filehandle.path().dropLast(4) + "_glow.tga" filehandle.path().dropLast(4) + "_glow.tga"
) // assuming strict ".tga" file for now... ) // assuming strict ".tga" file for now...
val emissiveFile = Gdx.files.internal( val emissiveFile = AssetCache.getFileHandle(
filehandle.path().dropLast(4) + "_emsv.tga" filehandle.path().dropLast(4) + "_emsv.tga"
) // assuming strict ".tga" file for now... ) // assuming strict ".tga" file for now...
fileToAtlantes( fileToAtlantes(