mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-11 22:31:52 +09:00
worldgen preview loadscreen (NOT WORKING)
This commit is contained in:
@@ -12,7 +12,7 @@ open class LoadScreenBase : ScreenAdapter() {
|
|||||||
|
|
||||||
internal val messages = CircularArray<String>(20, true)
|
internal val messages = CircularArray<String>(20, true)
|
||||||
|
|
||||||
fun addMessage(msg: String) {
|
open fun addMessage(msg: String) {
|
||||||
messages.appendHead(msg)
|
messages.appendHead(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +61,13 @@ open class LoadScreenBase : ScreenAdapter() {
|
|||||||
Gdx.gl20.glViewport(0, 0, width, height)
|
Gdx.gl20.glViewport(0, 0, width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun render(delta: Float) {
|
||||||
|
if (doContextChange) {
|
||||||
|
Thread.sleep(80)
|
||||||
|
AppLoader.setScreen(LoadScreen.screenToLoad!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun resize(width: Int, height: Int) {
|
override fun resize(width: Int, height: Int) {
|
||||||
initViewPort(AppLoader.screenW, AppLoader.screenH)
|
initViewPort(AppLoader.screenW, AppLoader.screenH)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,11 +219,9 @@ object LoadScreen : LoadScreenBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppLoader.batch.flush()
|
AppLoader.batch.flush()
|
||||||
|
|
||||||
Thread.sleep(80)
|
|
||||||
|
|
||||||
AppLoader.setScreen(screenToLoad!!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.render(delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPulseEffCol(): Color {
|
private fun getPulseEffCol(): Color {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.graphics.Pixmap
|
import com.badlogic.gdx.graphics.Pixmap
|
||||||
import com.badlogic.gdx.graphics.Texture
|
import com.badlogic.gdx.graphics.Texture
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.util.CircularArray
|
import net.torvald.util.CircularArray
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
@@ -14,14 +15,19 @@ import kotlin.math.roundToInt
|
|||||||
*
|
*
|
||||||
* Created by minjaesong on 2019-11-09.
|
* Created by minjaesong on 2019-11-09.
|
||||||
*/
|
*/
|
||||||
class WorldgenLoadScreen(private val world: GameWorld, screenToBeLoaded: IngameInstance) : LoadScreenBase() {
|
class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, worldwidth: Int, worldheight: Int) : LoadScreenBase() {
|
||||||
|
|
||||||
// a Class impl is chosen to make resize-handling easier, there's not much benefit making this a singleton anyway
|
// a Class impl is chosen to make resize-handling easier, there's not much benefit making this a singleton anyway
|
||||||
|
|
||||||
|
init {
|
||||||
|
screenToBeLoaded.world
|
||||||
|
}
|
||||||
|
|
||||||
|
private val world = screenToBeLoaded.world
|
||||||
override var screenToLoad: IngameInstance? = screenToBeLoaded
|
override var screenToLoad: IngameInstance? = screenToBeLoaded
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val WIDTH_RATIO = 0.6
|
private const val WIDTH_RATIO = 0.7
|
||||||
private const val PREVIEW_UPDATE_RATE = 1/8f
|
private const val PREVIEW_UPDATE_RATE = 1/8f
|
||||||
|
|
||||||
private val COL_WALL = Color.WHITE
|
private val COL_WALL = Color.WHITE
|
||||||
@@ -30,14 +36,21 @@ class WorldgenLoadScreen(private val world: GameWorld, screenToBeLoaded: IngameI
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val previewWidth = (AppLoader.screenW * WIDTH_RATIO).roundToInt()
|
private val previewWidth = (AppLoader.screenW * WIDTH_RATIO).roundToInt()
|
||||||
private val previewHeight = (AppLoader.screenW * WIDTH_RATIO * world.height / world.width).roundToInt()
|
private val previewHeight = (AppLoader.screenW * WIDTH_RATIO * worldheight / worldwidth).roundToInt()
|
||||||
|
|
||||||
private lateinit var previewPixmap: Pixmap
|
private lateinit var previewPixmap: Pixmap
|
||||||
private lateinit var previewTexture: Texture
|
private lateinit var previewTexture: Texture
|
||||||
|
|
||||||
|
private var previewRenderCounter = 0f
|
||||||
|
|
||||||
override fun show() {
|
override fun show() {
|
||||||
|
super.show()
|
||||||
|
|
||||||
previewPixmap = Pixmap(previewWidth, previewHeight, Pixmap.Format.RGBA8888)
|
previewPixmap = Pixmap(previewWidth, previewHeight, Pixmap.Format.RGBA8888)
|
||||||
previewTexture = Texture(1, 1, Pixmap.Format.RGBA8888)
|
previewTexture = Texture(1, 1, Pixmap.Format.RGBA8888)
|
||||||
|
|
||||||
|
previewPixmap.setColor(Color.BLACK)
|
||||||
|
previewPixmap.fill()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(delta: Float) {
|
override fun render(delta: Float) {
|
||||||
@@ -45,12 +58,21 @@ class WorldgenLoadScreen(private val world: GameWorld, screenToBeLoaded: IngameI
|
|||||||
previewTexture = Texture(previewPixmap)
|
previewTexture = Texture(previewPixmap)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
previewRenderCounter += delta
|
||||||
|
if (previewRenderCounter >= PREVIEW_UPDATE_RATE) {
|
||||||
|
previewRenderCounter -= PREVIEW_UPDATE_RATE
|
||||||
|
renderToPreview()
|
||||||
|
}
|
||||||
|
|
||||||
AppLoader.batch.inUse {
|
AppLoader.batch.inUse {
|
||||||
it.draw(previewTexture,
|
it.draw(previewTexture,
|
||||||
(AppLoader.screenW - previewWidth).div(2f).round(),
|
(AppLoader.screenW - previewWidth).div(2f).round(),
|
||||||
(AppLoader.screenH - previewHeight.times(1.25f)).div(2f).round()
|
(AppLoader.screenH - previewHeight.times(1.5f)).div(2f).round()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.render(delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderToPreview() {
|
private fun renderToPreview() {
|
||||||
@@ -68,6 +90,11 @@ class WorldgenLoadScreen(private val world: GameWorld, screenToBeLoaded: IngameI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun addMessage(msg: String) {
|
||||||
|
super.addMessage(msg)
|
||||||
|
println("[WorldgenLoadScreen] $msg")
|
||||||
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
previewPixmap.dispose()
|
previewPixmap.dispose()
|
||||||
previewTexture.dispose()
|
previewTexture.dispose()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.torvald.terrarum.LoadScreen
|
|||||||
import net.torvald.terrarum.Second
|
import net.torvald.terrarum.Second
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||||
|
import net.torvald.terrarum.modulebasegame.WorldgenLoadScreen
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,13 +39,16 @@ class UIProxyNewRandomGame : UICanvas() {
|
|||||||
|
|
||||||
|
|
||||||
val ingame = TerrarumIngame(AppLoader.batch)
|
val ingame = TerrarumIngame(AppLoader.batch)
|
||||||
ingame.gameLoadInfoPayload = TerrarumIngame.NewWorldParameters(2400, 800, HQRNG().nextLong())
|
val worldParam = TerrarumIngame.NewWorldParameters(2400, 800, HQRNG().nextLong())
|
||||||
//ingame.gameLoadInfoPayload = Ingame.NewWorldParameters(8192, 2048, 0x51621DL)
|
//val worldParam = Ingame.NewWorldParameters(8192, 2048, 0x51621DL)
|
||||||
|
ingame.gameLoadInfoPayload = worldParam
|
||||||
ingame.gameLoadMode = TerrarumIngame.GameLoadMode.CREATE_NEW
|
ingame.gameLoadMode = TerrarumIngame.GameLoadMode.CREATE_NEW
|
||||||
|
|
||||||
Terrarum.setCurrentIngameInstance(ingame)
|
Terrarum.setCurrentIngameInstance(ingame)
|
||||||
LoadScreen.screenToLoad = ingame
|
//LoadScreen.screenToLoad = ingame
|
||||||
AppLoader.setScreen(LoadScreen)
|
//AppLoader.setScreen(LoadScreen)
|
||||||
|
val loadScreen = WorldgenLoadScreen(ingame, worldParam.width, worldParam.height)
|
||||||
|
AppLoader.setScreen(loadScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endClosing(delta: Float) {
|
override fun endClosing(delta: Float) {
|
||||||
|
|||||||
Reference in New Issue
Block a user