mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
load screen render, fixed some init code of the app
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -35,6 +35,7 @@ import net.torvald.random.HQRNG
|
|||||||
import net.torvald.terrarum.ui.*
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarum.worldgenerator.RoguelikeRandomiser
|
import net.torvald.terrarum.worldgenerator.RoguelikeRandomiser
|
||||||
import net.torvald.terrarum.worldgenerator.WorldGenerator
|
import net.torvald.terrarum.worldgenerator.WorldGenerator
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,6 +198,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
override fun show() {
|
override fun show() {
|
||||||
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
|
|
||||||
|
|
||||||
// gameLoadMode and gameLoadInfoPayload must be set beforehand!!
|
// gameLoadMode and gameLoadInfoPayload must be set beforehand!!
|
||||||
|
|
||||||
when (gameLoadMode) {
|
when (gameLoadMode) {
|
||||||
@@ -223,7 +225,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
*/
|
*/
|
||||||
private fun enter(gameSaveData: GameSaveData) {
|
private fun enter(gameSaveData: GameSaveData) {
|
||||||
if (gameFullyLoaded) {
|
if (gameFullyLoaded) {
|
||||||
Error("You are doing things horribly wrong, fucknugget.")
|
Error("You are doing horribly wrong, fucknugget.")
|
||||||
}
|
}
|
||||||
|
|
||||||
world = gameSaveData.world
|
world = gameSaveData.world
|
||||||
@@ -1474,6 +1476,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun hide() {
|
override fun hide() {
|
||||||
|
dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1524,6 +1527,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
worldDrawFrameBuffer.dispose()
|
worldDrawFrameBuffer.dispose()
|
||||||
worldGlowFrameBuffer.dispose()
|
worldGlowFrameBuffer.dispose()
|
||||||
|
worldBlendFrameBuffer.dispose()
|
||||||
lightmapFboA.dispose()
|
lightmapFboA.dispose()
|
||||||
lightmapFboB.dispose()
|
lightmapFboB.dispose()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
package net.torvald.terrarum
|
package net.torvald.terrarum
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.Screen
|
import com.badlogic.gdx.Screen
|
||||||
import com.badlogic.gdx.ScreenAdapter
|
import com.badlogic.gdx.ScreenAdapter
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.GL20
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
import net.torvald.dataclass.HistoryArray
|
import net.torvald.dataclass.HistoryArray
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-07-13.
|
* Created by minjaesong on 2017-07-13.
|
||||||
@@ -12,21 +18,99 @@ object LoadScreen : ScreenAdapter() {
|
|||||||
private lateinit var actualSceneToBeLoaded: Screen
|
private lateinit var actualSceneToBeLoaded: Screen
|
||||||
private lateinit var sceneLoadingThread: Thread
|
private lateinit var sceneLoadingThread: Thread
|
||||||
|
|
||||||
|
|
||||||
private val messages = HistoryArray<String>(20)
|
private val messages = HistoryArray<String>(20)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun setMessage(msg: String) {
|
fun setMessage(msg: String) {
|
||||||
messages.add(msg)
|
messages.add(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun show() {
|
|
||||||
|
|
||||||
|
|
||||||
|
private var arrowObjPos = 0f // 0 means at starting position, regardless of screen position
|
||||||
|
private var arrowObjGlideOffsetX = 0f
|
||||||
|
private var arrowObjGlideSize = 0f
|
||||||
|
private var arrowGlideSpeed = Terrarum.WIDTH * 1.2f // pixels per sec
|
||||||
|
private lateinit var arrowObjTex: TextureRegionPack
|
||||||
|
private var glideTimer = 0f
|
||||||
|
private var glideDispY = 0f
|
||||||
|
private var arrowColours = arrayOf(
|
||||||
|
Color(0xff847fff.toInt()),
|
||||||
|
Color(0xffc87fff.toInt()),
|
||||||
|
Color(0xbffff2ff.toInt()),
|
||||||
|
Color(0x7fcaffff)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
var camera = OrthographicCamera(Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
||||||
|
|
||||||
|
fun initViewPort(width: Int, height: Int) {
|
||||||
|
//val width = if (width % 1 == 1) width + 1 else width
|
||||||
|
//val height = if (height % 1 == 1) height + 1 else width
|
||||||
|
|
||||||
|
// Set Y to point downwards
|
||||||
|
camera.setToOrtho(true, width.toFloat(), height.toFloat())
|
||||||
|
|
||||||
|
// Update camera matrix
|
||||||
|
camera.update()
|
||||||
|
|
||||||
|
// Set viewport to restrict drawing
|
||||||
|
Gdx.gl20.glViewport(0, 0, width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
override fun show() {
|
||||||
|
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
|
|
||||||
|
arrowObjTex = TextureRegionPack(Gdx.files.internal("assets/graphics/test_loading_arrow_atlas.tga"), 22, 17)
|
||||||
|
arrowObjGlideOffsetX = -arrowObjTex.texture.width.toFloat()
|
||||||
|
arrowObjGlideSize = arrowObjTex.texture.width + 1.5f * Terrarum.WIDTH
|
||||||
|
glideDispY = Terrarum.HEIGHT - 140f
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private val textColour = Color(0xeeeeeeff.toInt())
|
||||||
|
|
||||||
override fun render(delta: Float) {
|
override fun render(delta: Float) {
|
||||||
|
Gdx.gl.glClearColor(.157f, .157f, .157f, 0f)
|
||||||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||||
|
|
||||||
|
|
||||||
|
glideTimer += delta
|
||||||
|
if (glideTimer >= arrowObjGlideSize / arrowGlideSpeed) {
|
||||||
|
glideTimer -= arrowObjGlideSize / arrowGlideSpeed
|
||||||
|
}
|
||||||
|
arrowObjPos = glideTimer * arrowGlideSpeed
|
||||||
|
|
||||||
|
|
||||||
|
Terrarum.batch.inUse {
|
||||||
|
it.projectionMatrix = camera.combined
|
||||||
|
|
||||||
|
|
||||||
|
it.color = textColour
|
||||||
|
val textWidth = Terrarum.fontGame.getWidth(Lang["MENU_IO_LOADING"])
|
||||||
|
Terrarum.fontGame.draw(it, Lang["MENU_IO_LOADING"], (Terrarum.WIDTH - 2.5f * textWidth).round(), glideDispY - 2f)
|
||||||
|
|
||||||
|
|
||||||
|
arrowColours.forEachIndexed { index, color ->
|
||||||
|
it.color = color
|
||||||
|
it.draw(arrowObjTex.get(index, 0), arrowObjPos + arrowObjGlideOffsetX + 22 * index, glideDispY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
arrowObjTex.dispose()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hide() {
|
||||||
|
dispose()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resize(width: Int, height: Int) {
|
||||||
|
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -82,12 +82,6 @@ object Terrarum : Game() {
|
|||||||
// GLOBAL IMMUTABLE CONFIGS //
|
// GLOBAL IMMUTABLE CONFIGS //
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
val RENDER_FPS = getConfigInt("displayfps")
|
|
||||||
val USE_VSYNC = getConfigBoolean("usevsync")
|
|
||||||
var VSYNC = USE_VSYNC
|
|
||||||
val VSYNC_TRIGGER_THRESHOLD = 56
|
|
||||||
|
|
||||||
|
|
||||||
val WIDTH: Int
|
val WIDTH: Int
|
||||||
get() = if (screenW!! % 2 == 0) screenW!! else screenW!! + 1
|
get() = if (screenW!! % 2 == 0) screenW!! else screenW!! + 1
|
||||||
val HEIGHT: Int
|
val HEIGHT: Int
|
||||||
@@ -252,6 +246,16 @@ object Terrarum : Game() {
|
|||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
getDefaultDirectory()
|
||||||
|
createDirs()
|
||||||
|
|
||||||
|
|
||||||
|
// read config i guess...?
|
||||||
|
val readFromDisk = readConfigJson()
|
||||||
|
if (!readFromDisk) readConfigJson() // what's this for?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
println("[Terrarum] os.arch = $systemArch") // debug info
|
println("[Terrarum] os.arch = $systemArch") // debug info
|
||||||
|
|
||||||
if (is32BitJVM) {
|
if (is32BitJVM) {
|
||||||
@@ -273,12 +277,6 @@ object Terrarum : Game() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
getDefaultDirectory()
|
|
||||||
createDirs()
|
|
||||||
|
|
||||||
val readFromDisk = readConfigJson()
|
|
||||||
if (!readFromDisk) readConfigJson()
|
|
||||||
|
|
||||||
environment = try {
|
environment = try {
|
||||||
Controllers.getController(0) // test if controller exists
|
Controllers.getController(0) // test if controller exists
|
||||||
if (getConfigString("pcgamepadenv") == "console")
|
if (getConfigString("pcgamepadenv") == "console")
|
||||||
@@ -289,8 +287,16 @@ object Terrarum : Game() {
|
|||||||
catch (e: IndexOutOfBoundsException) {
|
catch (e: IndexOutOfBoundsException) {
|
||||||
RunningEnvironment.PC
|
RunningEnvironment.PC
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val RENDER_FPS = getConfigInt("displayfps")
|
||||||
|
val USE_VSYNC = getConfigBoolean("usevsync")
|
||||||
|
var VSYNC = USE_VSYNC
|
||||||
|
val VSYNC_TRIGGER_THRESHOLD = 56
|
||||||
|
|
||||||
|
|
||||||
override fun create() {
|
override fun create() {
|
||||||
TextureRegionPack.globalFlipY = true // !! TO MAKE LEGACY CODE RENDER ON ITS POSITION !!
|
TextureRegionPack.globalFlipY = true // !! TO MAKE LEGACY CODE RENDER ON ITS POSITION !!
|
||||||
Gdx.graphics.isContinuousRendering = true
|
Gdx.graphics.isContinuousRendering = true
|
||||||
@@ -330,6 +336,11 @@ object Terrarum : Game() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
gameLocale = getConfigString("language")
|
||||||
|
println("[Terrarum] locale = $gameLocale")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ModMgr // invoke Module Manager, will also invoke BlockCodex
|
ModMgr // invoke Module Manager, will also invoke BlockCodex
|
||||||
ItemCodex // invoke Item Codex
|
ItemCodex // invoke Item Codex
|
||||||
|
|
||||||
@@ -340,7 +351,8 @@ object Terrarum : Game() {
|
|||||||
ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(8192, 2048, HQRNG().nextLong())
|
ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(8192, 2048, HQRNG().nextLong())
|
||||||
ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW
|
ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW
|
||||||
|
|
||||||
super.setScreen(ingame)
|
//super.setScreen(ingame)
|
||||||
|
super.setScreen(LoadScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render() {
|
override fun render() {
|
||||||
@@ -498,20 +510,37 @@ object Terrarum : Game() {
|
|||||||
return cfg as IntArray
|
return cfg as IntArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get config from config file. If the entry does not exist, get from defaults; if the entry is not in the default, NullPointerException will be thrown
|
||||||
|
*/
|
||||||
|
private val defaultConfig = DefaultConfig.fetch()
|
||||||
|
|
||||||
private fun getConfigMaster(key: String): Any {
|
private fun getConfigMaster(key: String): Any {
|
||||||
var cfg: Any? = null
|
val config = try {
|
||||||
try {
|
gameConfig[key]
|
||||||
cfg = gameConfig[key.toLowerCase()]!!
|
|
||||||
}
|
}
|
||||||
catch (e: NullPointerException) {
|
catch (e: NullPointerException) {
|
||||||
try {
|
null
|
||||||
cfg = DefaultConfig.fetch()[key.toLowerCase()]
|
}
|
||||||
|
|
||||||
|
val defaults = try {
|
||||||
|
defaultConfig.get(key)
|
||||||
|
}
|
||||||
|
catch (e: NullPointerException) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config == null) {
|
||||||
|
if (defaults == null) {
|
||||||
|
throw NullPointerException("key not found: '$key'")
|
||||||
}
|
}
|
||||||
catch (e1: NullPointerException) {
|
else {
|
||||||
e.printStackTrace()
|
return defaults
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cfg!!
|
else {
|
||||||
|
return config
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setConfig(key: String, value: Any) {
|
fun setConfig(key: String, value: Any) {
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ object ItemCodex {
|
|||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
|
println("[ItemCodex] recording item ID ")
|
||||||
|
|
||||||
// blocks.csvs are loaded by ModMgr beforehand
|
// blocks.csvs are loaded by ModMgr beforehand
|
||||||
// block items (blocks and walls are the same thing basically)
|
// block items (blocks and walls are the same thing basically)
|
||||||
for (i in ITEM_TILES + ITEM_WALLS) {
|
for (i in ITEM_TILES + ITEM_WALLS) {
|
||||||
@@ -53,7 +56,7 @@ object ItemCodex {
|
|||||||
override val material = Material(0,0,0,0,0,0,0,0,0,0.0)
|
override val material = Material(0,0,0,0,0,0,0,0,0,0.0)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
println("[ItemCodex] recording item ID $originalID")
|
print("$originalID ")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun primaryUse(delta: Float): Boolean {
|
override fun primaryUse(delta: Float): Boolean {
|
||||||
@@ -165,6 +168,10 @@ object ItemCodex {
|
|||||||
|
|
||||||
|
|
||||||
// read from save (if applicable) and fill dynamicItemDescription
|
// read from save (if applicable) and fill dynamicItemDescription
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
println()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user