Various Loadscreens WIP

This commit is contained in:
minjaesong
2019-11-18 01:20:17 +09:00
parent e71c56cf0d
commit d8317e4226
5 changed files with 87 additions and 68 deletions

View File

@@ -3,8 +3,7 @@ package net.torvald.terrarum.modulebasegame
import com.badlogic.gdx.ScreenAdapter
import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.IngameInstance
import net.torvald.terrarum.*
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.util.CircularArray
import kotlin.math.roundToInt
@@ -14,10 +13,12 @@ import kotlin.math.roundToInt
*
* Created by minjaesong on 2019-11-09.
*/
class WorldgenLoadScreen(private var world: GameWorld, private var screenToLoad: IngameInstance) : ScreenAdapter() {
class WorldgenLoadScreen(private val world: GameWorld, screenToBeLoaded: IngameInstance) : LoadScreenBase() {
// a Class impl is chosen to make resize-handling easier, there's not much benefit making this a singleton anyway
override var screenToLoad: IngameInstance? = screenToBeLoaded
companion object {
private const val WIDTH_RATIO = 0.6
}
@@ -25,13 +26,9 @@ class WorldgenLoadScreen(private var world: GameWorld, private var screenToLoad:
private val previewWidth = (AppLoader.screenW * WIDTH_RATIO).roundToInt()
private val previewHeight = (AppLoader.screenW * WIDTH_RATIO * world.height / world.width).roundToInt()
private lateinit var screenLoadingThread: Thread
private lateinit var previewPixmap: Pixmap
private lateinit var previewTexture: Texture
private val messages = CircularArray<String>(20, true) // this many texts will be shown at once
override fun show() {
previewPixmap = Pixmap(previewWidth, previewHeight, Pixmap.Format.RGBA8888)
previewTexture = Texture(1, 1, Pixmap.Format.RGBA8888)
@@ -42,6 +39,12 @@ class WorldgenLoadScreen(private var world: GameWorld, private var screenToLoad:
previewTexture = Texture(previewPixmap)
//
AppLoader.batch.inUse {
it.draw(previewTexture,
(AppLoader.screenW - previewWidth).div(2f).round(),
(AppLoader.screenH - previewHeight.times(1.25f)).div(2f).round()
)
}
}
override fun dispose() {