mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
asset archiving wip
This commit is contained in:
@@ -629,7 +629,7 @@ public class App implements ApplicationListener {
|
||||
// make loading list
|
||||
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
|
||||
@@ -1992,8 +1992,8 @@ public class App implements ApplicationListener {
|
||||
}
|
||||
|
||||
public static ShaderProgram loadShaderFromFile(String vert, String frag) {
|
||||
String v = Gdx.files.internal(vert).readString("utf-8");
|
||||
String f = Gdx.files.internal(frag).readString("utf-8");
|
||||
String v = AssetCache.INSTANCE.getFileHandle(vert).readString("utf-8");
|
||||
String f = AssetCache.INSTANCE.getFileHandle(frag).readString("utf-8");
|
||||
return loadShaderInline(v, f);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.io.File
|
||||
* Build-time tool that creates assets.tevd from assets_release/ directory.
|
||||
*
|
||||
* 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>) {
|
||||
val srcDir = File(if (args.isNotEmpty()) args[0] else "assets_release")
|
||||
@@ -24,21 +26,35 @@ fun main(args: Array<String>) {
|
||||
println("Scanning $srcDir...")
|
||||
var totalSize = 0L
|
||||
var fileCount = 0
|
||||
srcDir.walkTopDown().filter { it.isFile }.forEach {
|
||||
totalSize += it.length()
|
||||
fileCount++
|
||||
var dirCount = 0
|
||||
srcDir.walkTopDown().forEach {
|
||||
if (it.isFile) {
|
||||
totalSize += it.length()
|
||||
fileCount++
|
||||
} else if (it.isDirectory && it != srcDir) {
|
||||
dirCount++
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate capacity in sectors (4096 bytes per sector/cluster)
|
||||
// Add overhead for FAT entries and directory structures
|
||||
// Calculate capacity in sectors (4096 bytes per cluster)
|
||||
// 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 totalEntries = fileCount + dirCount
|
||||
// Sectors for actual file data (each file rounds up to whole clusters)
|
||||
val sectorsForData = (totalSize + clusterSize - 1) / clusterSize
|
||||
// Add ~25% overhead for FAT, directory entries, and slack space
|
||||
val capacityInSectors = ((sectorsForData * 1.25) + fileCount + 256).toLong()
|
||||
// Each entry (file or dir) needs at least 1 sector, plus FAT overhead
|
||||
// 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())
|
||||
.toInt()
|
||||
|
||||
println(" Files: $fileCount")
|
||||
println(" Files: $fileCount, Directories: $dirCount")
|
||||
println(" Total size: ${totalSize / 1024} KB")
|
||||
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 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}...")
|
||||
val root = Clustfile(dom, "/")
|
||||
root.importFrom(srcDir)
|
||||
val children = srcDir.listFiles() ?: run {
|
||||
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...")
|
||||
dom.trimArchive()
|
||||
dom.dispose()
|
||||
|
||||
println("Done. Output:")
|
||||
println("Done. Imported $importedCount top-level entries. Output:")
|
||||
println(" ${outFile.path} (${outFile.length() / 1024} KB, $fileCount files)")
|
||||
}
|
||||
|
||||
@@ -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.Clustfile
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
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 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 {
|
||||
|
||||
@@ -39,7 +44,10 @@ object AssetCache {
|
||||
*/
|
||||
fun getClustfile(relativePath: String): Clustfile {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,8 @@ import java.io.InputStream
|
||||
/**
|
||||
* A GDX FileHandle backed by a Clustfile from TerranVirtualDisk.
|
||||
* 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() {
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ object ColorLimiterTest : ApplicationAdapter() {
|
||||
override fun create() {
|
||||
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.setUniformf("rcount", 4f)
|
||||
shader4096.setUniformf("gcount", 4f)
|
||||
@@ -50,7 +50,7 @@ object ColorLimiterTest : ApplicationAdapter() {
|
||||
batch = SpriteBatch()
|
||||
shapeRenderer = App.makeShapeRenderer()
|
||||
|
||||
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap")
|
||||
font = TerrarumSansBitmap()
|
||||
|
||||
|
||||
if (!shader4096.isCompiled) {
|
||||
|
||||
@@ -22,16 +22,16 @@ object CommonResourcePool {
|
||||
|
||||
init {
|
||||
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") {
|
||||
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") {
|
||||
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") {
|
||||
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") {
|
||||
TextureRegion(Texture("assets/test_texture.tga")).also { it.flip(false, false) }
|
||||
|
||||
@@ -47,10 +47,10 @@ object GlslTilingTest : ApplicationAdapter() {
|
||||
override fun create() {
|
||||
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) {
|
||||
@@ -93,9 +93,9 @@ object GlslTilingTest : ApplicationAdapter() {
|
||||
|
||||
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)
|
||||
|
||||
@@ -168,7 +168,7 @@ object ModMgr {
|
||||
AssetCache.getFileHandle("mods/$moduleName/$metaFilename").exists()
|
||||
else
|
||||
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
|
||||
|
||||
fun getGdxFileLocal(path: String) = if (isInternal) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class MusicComposerApp extends ApplicationAdapter {
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
fontGame = new TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap", false, true, false);
|
||||
fontGame = new TerrarumSansBitmap(false, true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,10 +55,10 @@ object SanicLoadScreen : LoadScreenBase() {
|
||||
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()
|
||||
|
||||
textOverlayTex = Texture(Gdx.files.internal("assets/graphics/test_loading_text_tint.tga"))
|
||||
textOverlayTex = Texture(AssetCache.getFileHandle("graphics/test_loading_text_tint.tga"))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,10 +39,10 @@ object ShitOnGlsl : ApplicationAdapter() {
|
||||
override fun create() {
|
||||
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) {
|
||||
@@ -75,8 +75,8 @@ object ShitOnGlsl : ApplicationAdapter() {
|
||||
|
||||
batch = SpriteBatch()
|
||||
|
||||
fucktex = Texture(Gdx.files.internal("assets/graphics/ortho_line_tex_2px.tga"))
|
||||
testTex = Texture(Gdx.files.internal("assets/test_texture.tga"))
|
||||
fucktex = Texture(AssetCache.getFileHandle("graphics/ortho_line_tex_2px.tga"))
|
||||
testTex = Texture(AssetCache.getFileHandle("test_texture.tga"))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ object TerrarumPostProcessor : Disposable {
|
||||
private lateinit var outFBO: FrameBuffer
|
||||
|
||||
fun reloadLUT(filename: String) {
|
||||
lutTex = Texture(Gdx.files.internal("assets/clut/$filename"))
|
||||
lutTex = Texture(AssetCache.getFileHandle("clut/$filename"))
|
||||
}
|
||||
|
||||
private val defaultResCol = Color(0x66ffff66)
|
||||
@@ -48,9 +48,9 @@ object TerrarumPostProcessor : Disposable {
|
||||
|
||||
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 shaderPostNoDither = ShaderMgr["postNoDither"]
|
||||
|
||||
@@ -50,7 +50,7 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
|
||||
|
||||
img = Texture("assets/test_texture.tga")
|
||||
|
||||
gameFont = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap")
|
||||
gameFont = TerrarumSansBitmap()
|
||||
//gameFont = BitmapFont()
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ object TestTestMain : ApplicationAdapter() {
|
||||
|
||||
override fun create() {
|
||||
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()
|
||||
|
||||
@@ -60,7 +60,7 @@ object TexRegionTilingTest : ApplicationAdapter() {
|
||||
val gzTmpFName = listOf("tmp_terrain.tga", "tmp_wire.tga")
|
||||
// unzip GZIP temporarily
|
||||
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 wholeFile = gzi.readBytes()
|
||||
gzi.close()
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import java.io.File
|
||||
|
||||
@@ -108,8 +109,8 @@ object IME {
|
||||
}
|
||||
|
||||
|
||||
val iconSheet = TextureRegionPack("assets/graphics/gui/ime_icons_by_language.tga", 20, 20)
|
||||
val iconPixmap = Pixmap(Gdx.files.internal("assets/graphics/gui/ime_icons_by_language.tga"))
|
||||
val iconSheet = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/ime_icons_by_language.tga"), 20, 20)
|
||||
val iconPixmap = Pixmap(AssetCache.getFileHandle("graphics/gui/ime_icons_by_language.tga"))
|
||||
for (k in 0 until iconPixmap.height step 20) {
|
||||
val langCode = StringBuilder()
|
||||
for (c in 0 until 20) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.gamecontroller
|
||||
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.util.SortedArrayList
|
||||
import org.graalvm.polyglot.HostAccess
|
||||
import java.io.File
|
||||
@@ -29,7 +30,7 @@ class IMEDictionary(private val filename: String) {
|
||||
private var dictLoaded = false
|
||||
|
||||
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 {
|
||||
if (it.contains(',')) {
|
||||
val (key, value) = it.split(',')
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.Batch
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.roundToFloat
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
@@ -15,7 +16,7 @@ object BigAlphNum : BitmapFont() {
|
||||
internal const val W = 12
|
||||
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
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.g2d.Batch
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.roundToFloat
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import kotlin.math.roundToInt
|
||||
@@ -18,8 +19,8 @@ object TinyAlphNum : BitmapFont() {
|
||||
internal const val W = 7
|
||||
internal const val H = 13
|
||||
|
||||
internal val fontSheet = TextureRegionPack("./assets/graphics/fonts/7x13_Tamzen7x14b.tga", W+1, H+1)
|
||||
internal val fontPixmap = Pixmap(Gdx.files.internal("./assets/graphics/fonts/7x13_Tamzen7x14b.tga"))
|
||||
internal val fontSheet = TextureRegionPack(AssetCache.getFileHandle("graphics/fonts/7x13_Tamzen7x14b.tga"), W+1, H+1)
|
||||
internal val fontPixmap = Pixmap(AssetCache.getFileHandle("graphics/fonts/7x13_Tamzen7x14b.tga"))
|
||||
|
||||
init {
|
||||
setOwnsTexture(true)
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.langpack
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.tail
|
||||
import net.torvald.terrarum.utils.JsonFetcher
|
||||
import net.torvald.unicode.getKeycapPC
|
||||
@@ -49,13 +50,13 @@ object Lang {
|
||||
|
||||
init {
|
||||
// load base langs
|
||||
load(File("./assets/locales/"))
|
||||
load(AssetCache.getFileHandle("locales/"))
|
||||
}
|
||||
|
||||
|
||||
@JvmStatic operator fun invoke() { /* dummy method for manual initialisation */ }
|
||||
|
||||
fun load(localesDir: File) {
|
||||
/*fun load(localesDir: File) {
|
||||
printdbg(this, "Loading languages from $localesDir")
|
||||
|
||||
// get all of the languages installed
|
||||
@@ -81,7 +82,7 @@ object Lang {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
fun load(localesHandle: FileHandle) {
|
||||
printdbg(this, "Loading languages from ${localesHandle.path()}")
|
||||
|
||||
@@ -149,8 +149,8 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private lateinit var worldFBO: Float16FrameBuffer
|
||||
|
||||
private val warning32bitJavaIcon = TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/32_bit_warning.tga")))
|
||||
private val warningAppleRosettaIcon = TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/apple_rosetta_warning.tga")))
|
||||
private val warning32bitJavaIcon = TextureRegion(Texture(AssetCache.getFileHandle("graphics/gui/32_bit_warning.tga")))
|
||||
private val warningAppleRosettaIcon = TextureRegion(Texture(AssetCache.getFileHandle("graphics/gui/apple_rosetta_warning.tga")))
|
||||
|
||||
init {
|
||||
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
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.console
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.audio.Music
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
|
||||
@@ -35,7 +36,7 @@ internal object MusicTest : ConsoleCommand {
|
||||
File("./assets/sounds/test/${args[1]}").absoluteFile.toURI().toURL()
|
||||
).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()
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
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 ->
|
||||
FixtureTapestry(
|
||||
// TODO use extra["fileRef"] (string) and extra["framingMaterial"] (string)
|
||||
Gdx.files.internal("assets/monkey_island").readBytes(),
|
||||
AssetCache.getFileHandle("monkey_island").readBytes(),
|
||||
Block.PLANK_NORMAL
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.imagefont
|
||||
import com.badlogic.gdx.graphics.g2d.Batch
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
@@ -22,7 +23,7 @@ class NewRunes : BitmapFont() {
|
||||
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 linegap = 8
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.TerrarumScreenSize
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
@@ -22,10 +23,10 @@ object ControlPanelCommon {
|
||||
|
||||
init {
|
||||
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") {
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.toInt
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
@@ -28,7 +29,7 @@ object ItemSlotImageFactory {
|
||||
/** Blend mode: screen */
|
||||
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 {
|
||||
return ItemSlotImage(slotImage.get(number ?: 10, 0 or isBlack.toInt().shl(1)), sprite)
|
||||
|
||||
@@ -67,7 +67,7 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
|
||||
// will be disposed by Terrarum (application main instance)
|
||||
val SEGMENT_BLACK = TextureRegionPack("assets/graphics/gui/message_black.tga", 8, 56)
|
||||
val SEGMENT_WHITE = TextureRegionPack("assets/graphics/gui/message_white.tga", 8, 56)
|
||||
val SEGMENT_BLACK = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/message_black.tga"), 8, 56)
|
||||
val SEGMENT_WHITE = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/message_white.tga"), 8, 56)
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -76,7 +76,7 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
readFromLang = true,
|
||||
textAreaWidth = 100,
|
||||
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),
|
||||
iconCol = defaultTextColour,
|
||||
highlightBackCol = Color(0xb8b8b8_ff.toInt()),
|
||||
@@ -108,7 +108,7 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
|
||||
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
|
||||
)
|
||||
private val scrollLeftButton = UIItemImageButton(this,
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.GdxColorMap
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
@@ -86,7 +87,7 @@ abstract class UIItemInventoryCellBase(
|
||||
}
|
||||
|
||||
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())
|
||||
|
||||
fun getHealthMeterColour(value: Float, start: Float, end: Float): Color {
|
||||
|
||||
@@ -66,7 +66,7 @@ open class UIItemInventoryItemGrid(
|
||||
|
||||
init {
|
||||
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()
|
||||
}
|
||||
@@ -105,7 +105,7 @@ open class UIItemInventoryItemGrid(
|
||||
var inventorySortList = ArrayList<InventoryPair>()
|
||||
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 = ""
|
||||
|
||||
|
||||
|
||||
@@ -103,10 +103,10 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : Advanceable() {
|
||||
|
||||
init {
|
||||
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") {
|
||||
TextureRegionPack("assets/graphics/gui/savegame_status_icon.tga", 24, 24)
|
||||
TextureRegionPack(AssetCache.getFileHandle("graphics/gui/savegame_status_icon.tga"), 24, 24)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
|
||||
|
||||
init {
|
||||
CommonResourcePool.addToLoadingList("gradtile32") {
|
||||
TextureRegionPack("assets/graphics/gui/gradtile32.tga", 1, 32)
|
||||
TextureRegionPack(AssetCache.getFileHandle("graphics/gui/gradtile32.tga"), 1, 32)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
||||
handler.allowESCtoClose = false
|
||||
|
||||
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") {
|
||||
TextureRegionPack("assets/graphics/gui/savegame_status_icon.tga", 24, 24)
|
||||
TextureRegionPack(AssetCache.getFileHandle("graphics/gui/savegame_status_icon.tga"), 24, 24)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ class BTeXTest(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
Thread {
|
||||
try {
|
||||
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
|
||||
documentHandler = f.second
|
||||
}.also {
|
||||
@@ -130,7 +130,7 @@ class BTeXTest(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
else {
|
||||
measureTimeMillis {
|
||||
document = BTeXDocument.fromFile(Gdx.files.internal("./assets/mods/basegame/books/$filePath"))
|
||||
document = BTeXDocument.fromFile(AssetCache.getFileHandle("mods/basegame/books/$filePath"))
|
||||
}.also {
|
||||
println("Time spent on loading [ms]: $it")
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.ItemCodex
|
||||
import net.torvald.terrarum.ReferencingRanges
|
||||
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, ...)
|
||||
*/
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
||||
import net.torvald.btex.BTeXDocViewer
|
||||
import net.torvald.btex.BTeXParser
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.FlippingSpriteBatch
|
||||
import net.torvald.terrarum.btex.BTeXDocument
|
||||
import net.torvald.terrarum.gdxClearAndEnableBlend
|
||||
@@ -82,7 +83,7 @@ class BTeXTest : ApplicationAdapter() {
|
||||
Thread {
|
||||
try {
|
||||
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
|
||||
documentHandler = f.second
|
||||
}.also {
|
||||
@@ -103,7 +104,7 @@ class BTeXTest : ApplicationAdapter() {
|
||||
}
|
||||
else {
|
||||
measureTimeMillis {
|
||||
document = BTeXDocument.fromFile(Gdx.files.internal("./assets/mods/basegame/books/$filePath"))
|
||||
document = BTeXDocument.fromFile(AssetCache.getFileHandle("mods/basegame/books/$filePath"))
|
||||
}.also {
|
||||
println("Time spent on loading [ms]: $it")
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.Screen
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.GdxColorMap
|
||||
|
||||
/**
|
||||
@@ -26,7 +27,7 @@ class ColorMapTest : Game() {
|
||||
}
|
||||
|
||||
override fun render() {
|
||||
val colormap = GdxColorMap(Gdx.files.internal("assets/testimage_resized.png"))
|
||||
val colormap = GdxColorMap(AssetCache.getFileHandle("testimage_resized.png"))
|
||||
println(colormap)
|
||||
|
||||
System.exit(0)
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.audio.Sound
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import java.awt.BorderLayout
|
||||
import javax.swing.JFrame
|
||||
import javax.swing.JPanel
|
||||
@@ -41,7 +42,7 @@ class AudioPlayerSlave : Game() {
|
||||
|
||||
|
||||
override fun create() {
|
||||
audioSample = Gdx.files.internal("assets/loopey.wav")
|
||||
audioSample = AssetCache.getFileHandle("loopey.wav")
|
||||
gdxSound = Gdx.audio.newSound(audioSample)
|
||||
surroundPanner = SurroundPannerTest()
|
||||
soundID = gdxSound.loop()
|
||||
@@ -137,7 +138,7 @@ class AudioPlayerSlave : Game() {
|
||||
|
||||
|
||||
override fun create() {
|
||||
audioSample = Gdx.files.internal("assets/loopey.wav")
|
||||
audioSample = AssetCache.getFileHandle("loopey.wav")
|
||||
gdxSound = Gdx.audio.newSound(audioSample)
|
||||
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
||||
private var genFutures: Array<Future<*>?> = arrayOfNulls(genSlices)
|
||||
|
||||
override fun create() {
|
||||
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap")
|
||||
font = TerrarumSansBitmap()
|
||||
|
||||
batch = FlippingSpriteBatch(1000)
|
||||
camera = OrthographicCamera(NOISEBOX_WIDTH.toFloat(), NOISEBOX_HEIGHT.toFloat())
|
||||
|
||||
@@ -53,9 +53,9 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
private var ingame: IngameInstance? = null
|
||||
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 back = Texture(Gdx.files.internal("assets/graphics/gui/debug_window_background.tga"))
|
||||
private val back2 = Texture(Gdx.files.internal("assets/graphics/gui/debug_window_background2.tga"))
|
||||
private val icons = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/debug_window_symbols.tga"), 21, 26)
|
||||
private val back = Texture(AssetCache.getFileHandle("graphics/gui/debug_window_background.tga"))
|
||||
private val back2 = Texture(AssetCache.getFileHandle("graphics/gui/debug_window_background2.tga"))
|
||||
|
||||
private val ARROW_RIGHT = 0xC0.toChar()
|
||||
private val ARROW_LEFT = 0xC1.toChar()
|
||||
|
||||
@@ -46,11 +46,11 @@ object Toolkit : Disposable {
|
||||
}
|
||||
private lateinit var fboBlur: Float16FrameBuffer
|
||||
|
||||
// val baloonTile = TextureRegionPack("assets/graphics/gui/message_black_tileable.tga", 36, 36)
|
||||
val shadowTile = TextureRegionPack("assets/graphics/gui/blur_shadow.tga", 32, 32)
|
||||
// val baloonTile = TextureRegionPack(AssetCache.getFileHandle("graphics/gui/message_black_tileable.tga"), 36, 36)
|
||||
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 textureWhiteCircle = Texture(Gdx.files.internal("assets/graphics/circle_512.tga"))
|
||||
val textureWhiteSquare = Texture(AssetCache.getFileHandle("graphics/ortho_line_tex_2px.tga"))
|
||||
val textureWhiteCircle = Texture(AssetCache.getFileHandle("graphics/circle_512.tga"))
|
||||
|
||||
init {
|
||||
App.disposables.add(this)
|
||||
@@ -59,7 +59,7 @@ object Toolkit : Disposable {
|
||||
textureWhiteCircle.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.imagefont.TinyAlphNum
|
||||
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)")
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.imagefont.BigAlphNum
|
||||
import net.torvald.terrarum.utils.PasswordBase32
|
||||
@@ -34,7 +35,7 @@ class UIItemRedeemCodeArea(
|
||||
|
||||
init {
|
||||
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()
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.blendNormalStraightAlpha
|
||||
import net.torvald.terrarum.toInt
|
||||
@@ -28,7 +29,7 @@ class UIItemToggleButton(
|
||||
|
||||
init {
|
||||
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()
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.torvald.colourutil.toRGB
|
||||
import net.torvald.parametricsky.ArHosekSkyModel
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.AssetCache
|
||||
import net.torvald.terrarum.abs
|
||||
import net.torvald.terrarum.floorToInt
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -36,7 +37,7 @@ object SkyboxModelHosek : SkyboxModel {
|
||||
private lateinit var texStripRegions: TextureRegionPack
|
||||
|
||||
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.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat)
|
||||
texRegions = TextureRegionPack(tex, 2, gradSize - 2, 0, 2, 0, 1)
|
||||
|
||||
@@ -91,7 +91,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
var forceTurbidity: Double? = null
|
||||
|
||||
// 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.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat)
|
||||
}
|
||||
@@ -112,7 +112,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
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) {
|
||||
|
||||
@@ -97,7 +97,7 @@ class CreateTileAtlas {
|
||||
// 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.
|
||||
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
|
||||
|
||||
internal lateinit var itemTerrainPixmap: Pixmap
|
||||
@@ -111,7 +111,7 @@ class CreateTileAtlas {
|
||||
get() = atlasVernal
|
||||
|
||||
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 tilesPossibleInCurrentPixmap = (atlas.width * atlas.height) / (TILE_SIZE * TILE_SIZE)
|
||||
@@ -240,10 +240,10 @@ class CreateTileAtlas {
|
||||
printdbg(this, "processing $prefix $modname:${filehandle.name()}")
|
||||
|
||||
try {
|
||||
val glowFile = Gdx.files.internal(
|
||||
val glowFile = AssetCache.getFileHandle(
|
||||
filehandle.path().dropLast(4) + "_glow.tga"
|
||||
) // assuming strict ".tga" file for now...
|
||||
val emissiveFile = Gdx.files.internal(
|
||||
val emissiveFile = AssetCache.getFileHandle(
|
||||
filehandle.path().dropLast(4) + "_emsv.tga"
|
||||
) // assuming strict ".tga" file for now...
|
||||
fileToAtlantes(
|
||||
|
||||
Reference in New Issue
Block a user