titlescreen moved to modules; using GLES 3.0 as default

This commit is contained in:
minjaesong
2021-12-11 21:08:56 +09:00
parent 56f5dc1686
commit 10819e2607
13 changed files with 135 additions and 80 deletions

View File

@@ -3,4 +3,4 @@
# You can disable basegame, but we don't recommend.
basegame
dwarventech
#dwarventech
1 # Load Order
3 # You can disable basegame, but we don't recommend.
4 basegame
5 dwarventech #dwarventech
6

View File

@@ -342,6 +342,7 @@ public class App implements ApplicationListener {
Lwjgl3ApplicationConfiguration appConfig = new Lwjgl3ApplicationConfiguration();
//appConfig.useGL30 = false; // https://stackoverflow.com/questions/46753218/libgdx-should-i-use-gl30
appConfig.useOpenGL3(true, 3, 0);
appConfig.useVsync(getConfigBoolean("usevsync"));
appConfig.setResizable(false);
appConfig.setWindowedMode(width, height);
@@ -555,11 +556,16 @@ public class App implements ApplicationListener {
// hand over the scene control to this single class; Terrarum must call
// 'AppLoader.getINSTANCE().screen.render(delta)', this is not redundant at all!
printdbg(this, "!! Force set current screen and ingame instance to TitleScreen !!");
IngameInstance title = ModMgr.INSTANCE.getTitleScreen(batch);
IngameInstance title = new TitleScreen(batch);
Terrarum.INSTANCE.setCurrentIngameInstance(title);
setScreen(title);
if (title != null) {
Terrarum.INSTANCE.setCurrentIngameInstance(title);
setScreen(title);
}
else {
IngameInstance notitle = new NoModuleDefaultTitlescreen(batch);
setScreen(notitle);
}
}
}
// draw the screen
@@ -570,7 +576,7 @@ public class App implements ApplicationListener {
KeyToggler.INSTANCE.update(currentScreen instanceof TerrarumIngame);
// nested FBOs are just not a thing in GL!
net.torvald.terrarum.FrameBufferManager.end();
FrameBufferManager.end();
PostProcessor.INSTANCE.draw(camera.combined, renderFBO);
@@ -855,6 +861,34 @@ public class App implements ApplicationListener {
*/
private void postInit() {
ModMgr.INSTANCE.invoke(); // invoke Module Manager
TextureRegionPack.Companion.setGlobalFlipY(true);
fontSmallNumbers = TinyAlphNum.INSTANCE;
IME.invoke();
inputStrober = InputStrober.INSTANCE;
try {
audioDevice = Gdx.audio.newAudioDevice(48000, false);
}
catch (NullPointerException deviceInUse) {
deviceInUse.printStackTrace();
System.err.println("[AppLoader] failed to create audio device: Audio device occupied by Exclusive Mode Device? (e.g. ASIO4all)");
}
CommonResourcePool.INSTANCE.loadAll();
if (ModMgr.INSTANCE.getModuleInfo().isEmpty()) {
return;
}
printdbg(this, "all modules loaded successfully");
@@ -869,8 +903,6 @@ public class App implements ApplicationListener {
tileMaker = new CreateTileAtlas();
tileMaker.invoke(false);
IME.invoke();
inputStrober = InputStrober.INSTANCE;
// check if selected IME is accessible; if not, set selected IME to none
String selectedIME = getConfigString("inputmethod");
@@ -880,18 +912,6 @@ public class App implements ApplicationListener {
Terrarum.initialise();
TextureRegionPack.Companion.setGlobalFlipY(true);
fontSmallNumbers = TinyAlphNum.INSTANCE;
try {
audioDevice = Gdx.audio.newAudioDevice(48000, false);
}
catch (NullPointerException deviceInUse) {
deviceInUse.printStackTrace();
System.err.println("[AppLoader] failed to create audio device: Audio device occupied by Exclusive Mode Device? (e.g. ASIO4all)");
}
CommonResourcePool.INSTANCE.loadAll();
// if there is a predefined screen, open that screen after my init process
if (injectScreen != null) {

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.files.FileHandle
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App.*
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.WireCodex
@@ -31,6 +32,7 @@ import java.util.*
/**
* Modules (or Mods) Resource Manager
*
* The very first mod on the load set must have a title screen
*
* NOTE!!: Usage of Groovy is only temporary; if Kotlin's "JSR 223" is no longer experimental and
* is readily available, ditch that Groovy.
@@ -93,6 +95,11 @@ object ModMgr {
errorLogs.add(ModuleErrorInfo(type, moduleName, cause))
}
/**
* Try to create an instance of a "titlescreen" from the current load order set.
*/
fun getTitleScreen(batch: SpriteBatch): IngameInstance? = entryPointClasses.getOrNull(0)?.getTitleScreen(batch)
init {
// load modules
val loadOrderCSVparser = CSVParser.parse(

View File

@@ -1,9 +1,12 @@
package net.torvald.terrarum
import com.badlogic.gdx.graphics.g2d.SpriteBatch
/**
* Created by minjaesong on 2018-06-21.
*/
abstract class ModuleEntryPoint {
abstract fun invoke()
abstract fun dispose()
open fun getTitleScreen(batch: SpriteBatch): IngameInstance? = null
}

View File

@@ -0,0 +1,54 @@
package net.torvald.terrarum
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.FrameBuffer
import net.torvald.terrarum.ui.Toolkit
/**
* Created by minjaesong on 2021-12-11.
*/
class NoModuleDefaultTitlescreen(batch: SpriteBatch) : IngameInstance(batch) {
private val wot = listOf(
"No Module is currently loaded.",
"Please review your Load Order on",
"assets/mods/LoadOrder.csv"
)
private val maxtw = wot.maxOf { App.fontGame.getWidth(it) }
private val fbo = FrameBuffer(Pixmap.Format.RGBA8888, App.scr.width, App.scr.height, true)
private var init = false
override fun render(updateRate: Float) {
gdxClearAndSetBlend(0f, 0f, 0f, 0f)
if (!init) {
val lh = 36f
val th = lh * wot.size
fbo.inAction(null, null) {
gdxClearAndSetBlend(.094f, .094f, .094f, 1f)
batch.inUse {
batch.color = Color.WHITE
wot.forEachIndexed { index, s ->
App.fontGame.draw(batch, s, (Toolkit.drawWidth - maxtw) / 2f, (App.scr.height - th) / 2f + lh * index)
}
}
}
}
batch.inUse {
batch.draw(fbo.colorBufferTexture, 0f, 0f)
}
}
override fun dispose() {
super.dispose()
fbo.dispose()
}
}

View File

@@ -31,7 +31,6 @@ import net.torvald.terrarum.serialise.Common
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import net.torvald.util.CircularArray
import java.io.File
import java.io.PrintStream
@@ -193,41 +192,6 @@ object Terrarum : Disposable {
printStackTrace(this)
}
private fun showxxx() {
testTexture = Texture(Gdx.files.internal("./assets/test_texture.tga"))
// resize fullscreen quad?
TextureRegionPack.globalFlipY = true // !! TO MAKE LEGACY CODE RENDER ON ITS POSITION !!
Gdx.graphics.isContinuousRendering = true
//batch = SpriteBatch()
//shapeRender = ShapeRenderer()
App.GAME_LOCALE = getConfigString("language")
printdbg(this, "locale = ${App.GAME_LOCALE}")
// jump straight into the ingame
/*val ingame = Ingame(batch)
ingame.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong())
ingame.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW
LoadScreen.screenToLoad = ingame
this.ingame = ingame
setScreen(LoadScreen)*/
// title screen
App.setScreen(TitleScreen(batch))
}
/** Don't call this! Call AppLoader.dispose() */
override fun dispose() {
//dispose any other resources used in this level

View File

@@ -158,15 +158,17 @@ open class GameWorld() : Disposable {
lastPlayTime = lastPlayTIME_T
App.tileMaker.tags.forEach {
printdbg(this, "tileNumber ${it.value.tileNumber} <-> tileName ${it.key}")
if (App.tileMaker != null) {
App.tileMaker.tags.forEach {
printdbg(this, "tileNumber ${it.value.tileNumber} <-> tileName ${it.key}")
tileNumberToNameMap[it.value.tileNumber.toLong()] = it.key
tileNameToNumberMap[it.key] = it.value.tileNumber
tileNumberToNameMap[it.value.tileNumber.toLong()] = it.key
tileNameToNumberMap[it.key] = it.value.tileNumber
}
// AN EXCEPTIONAL TERM: tilenum 0 is always redirected to Air tile, even if the tilenum for actual Air tile is not zero
tileNumberToNameMap[0] = Block.AIR
}
// AN EXCEPTIONAL TERM: tilenum 0 is always redirected to Air tile, even if the tilenum for actual Air tile is not zero
tileNumberToNameMap[0] = Block.AIR
}

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.modulebasegame
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.App.IS_DEVELOPMENT_BUILD
import net.torvald.terrarum.App.printdbg
@@ -19,6 +20,10 @@ class EntryPoint : ModuleEntryPoint() {
private val moduleName = "basegame"
override fun getTitleScreen(batch: SpriteBatch): IngameInstance? {
return TitleScreen(batch)
}
override fun invoke() {
printdbg(this, "Hello, world!")

View File

@@ -1,4 +1,4 @@
package net.torvald.terrarum
package net.torvald.terrarum.modulebasegame
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.InputAdapter
@@ -11,6 +11,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.jme3.math.FastMath
import net.torvald.random.HQRNG
import net.torvald.terrarum.*
import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.App.printdbgerr
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
@@ -23,8 +24,6 @@ import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.WorldTime
import net.torvald.terrarum.gameworld.fmod
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.IngameRenderer
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.ui.UIRemoCon
import net.torvald.terrarum.modulebasegame.ui.UITitleRemoConYaml
import net.torvald.terrarum.realestate.LandUtil

View File

@@ -8,9 +8,9 @@ import net.torvald.terrarum.App
import net.torvald.terrarum.INGAME
import net.torvald.terrarum.Terrarum.getPlayerSaveFiledesc
import net.torvald.terrarum.Terrarum.getWorldSaveFiledesc
import net.torvald.terrarum.TitleScreen
import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.TitleScreen
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_UI_HEIGHT
import net.torvald.terrarum.serialise.WriteSavegame

View File

@@ -4,10 +4,14 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.App
import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.App.printdbgerr
import net.torvald.terrarum.QNDTreeNode
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.Yaml
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
import net.torvald.terrarum.modulebasegame.TitleScreen
import net.torvald.terrarum.serialise.WriteConfig
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas

View File

@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.badlogic.gdx.graphics.glutils.FloatFrameBuffer
import com.badlogic.gdx.utils.Disposable
import net.torvald.random.HQRNG
import net.torvald.terrarum.App
@@ -34,9 +34,9 @@ object Toolkit : Disposable {
private val shaderKawaseDown = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/boxdown.frag")
private val shaderKawaseUp = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/boxup.frag")
private lateinit var fboBlur: FrameBuffer
private lateinit var fboBlurHalf: FrameBuffer
private lateinit var fboBlurQuarter: FrameBuffer
private lateinit var fboBlur: FloatFrameBuffer
private lateinit var fboBlurHalf: FloatFrameBuffer
private lateinit var fboBlurQuarter: FloatFrameBuffer
private lateinit var blurWriteQuad: Mesh
private lateinit var blurWriteQuad2: Mesh
private lateinit var blurWriteQuad4: Mesh
@@ -302,20 +302,17 @@ object Toolkit : Disposable {
val fw = App.scr.width//MathUtils.nextPowerOfTwo(App.scr.width)
val fh = App.scr.height//MathUtils.nextPowerOfTwo(App.scr.height)
fboBlur = FrameBuffer(
Pixmap.Format.RGBA8888,
fboBlur = FloatFrameBuffer(
fw,
fh,
true
)
fboBlurHalf = FrameBuffer(
Pixmap.Format.RGBA8888,
fboBlurHalf = FloatFrameBuffer(
fw / 2,
fh / 2,
true
)
fboBlurQuarter = FrameBuffer(
Pixmap.Format.RGBA8888,
fboBlurQuarter = FloatFrameBuffer(
fw / 4,
fh / 4,
true

Binary file not shown.