mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
bringing back old animating titlescreen
This commit is contained in:
1
assets/mods/basegame/demoworld
Normal file
1
assets/mods/basegame/demoworld
Normal file
File diff suppressed because one or more lines are too long
@@ -72,7 +72,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
/**
|
/**
|
||||||
* when FALSE, some assertion and print code will not execute
|
* when FALSE, some assertion and print code will not execute
|
||||||
*/
|
*/
|
||||||
public static boolean IS_DEVELOPMENT_BUILD = false;
|
public static boolean IS_DEVELOPMENT_BUILD = true;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -277,6 +277,11 @@ public class AppLoader implements ApplicationListener {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
// print copyright message
|
||||||
|
System.out.println(csiB+GAME_NAME+" "+csiG+getVERSION_STRING()+" "+csiK+"\u2014"+" "+csi0+TerrarumAppConfiguration.COPYRIGHT_DATE_NAME);
|
||||||
|
System.out.println(csiG+TerrarumAppConfiguration.COPYRIGHT_LICENSE_TERMS_SHORT+csi0);
|
||||||
|
|
||||||
|
|
||||||
// load configs
|
// load configs
|
||||||
getDefaultDirectory();
|
getDefaultDirectory();
|
||||||
createDirs();
|
createDirs();
|
||||||
@@ -925,7 +930,8 @@ public class AppLoader implements ApplicationListener {
|
|||||||
defaultDir = System.getProperty("user.home") + "/.Terrarum";
|
defaultDir = System.getProperty("user.home") + "/.Terrarum";
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultSaveDir = defaultDir + "/Saves";
|
// defaultSaveDir = defaultDir + "/Players"; // as per the save format in the game's planning
|
||||||
|
defaultSaveDir = defaultDir + "/Saves"; // for the demo release
|
||||||
configDir = defaultDir + "/config.json";
|
configDir = defaultDir + "/config.json";
|
||||||
|
|
||||||
System.out.println(String.format("os.name = %s (with identifier %s)", OSName, operationSystem));
|
System.out.println(String.format("os.name = %s (with identifier %s)", OSName, operationSystem));
|
||||||
@@ -1140,6 +1146,9 @@ public class AppLoader implements ApplicationListener {
|
|||||||
// //
|
// //
|
||||||
|
|
||||||
public static String csiR = "\u001B[31m";
|
public static String csiR = "\u001B[31m";
|
||||||
|
public static String csiG = "\u001B[32m";
|
||||||
|
public static String csiB = "\u001B[34m";
|
||||||
|
public static String csiK = "\u001B[37m";
|
||||||
public static String csi0 = "\u001B[m";
|
public static String csi0 = "\u001B[m";
|
||||||
|
|
||||||
public static void printdbg(Object obj, Object message) {
|
public static void printdbg(Object obj, Object message) {
|
||||||
@@ -1148,7 +1157,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
if (message == null)
|
if (message == null)
|
||||||
System.out.println("[" + out + "] null");
|
System.out.println("[" + out + "] null");
|
||||||
else
|
else
|
||||||
System.out.println("[" + out + "] " + message.toString());
|
System.out.println("[" + out + "] " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1158,7 +1167,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
if (message == null)
|
if (message == null)
|
||||||
System.out.println(csiR + "[" + out + "] null" + csi0);
|
System.out.println(csiR + "[" + out + "] null" + csi0);
|
||||||
else
|
else
|
||||||
System.out.println(csiR + "[" + out + "] " + message.toString() + csi0);
|
System.out.println(csiR + "[" + out + "] " + message + csi0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1167,7 +1176,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
if (message == null)
|
if (message == null)
|
||||||
System.out.println("[" + out + "] null");
|
System.out.println("[" + out + "] null");
|
||||||
else
|
else
|
||||||
System.out.println("[" + out + "] " + message.toString());
|
System.out.println("[" + out + "] " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShaderProgram loadShaderFromFile(String vert, String frag) {
|
public static ShaderProgram loadShaderFromFile(String vert, String frag) {
|
||||||
|
|||||||
@@ -15,6 +15,20 @@ object TerrarumAppConfiguration {
|
|||||||
const val COPYRIGHT_DATE_NAME = "Copyright 2013-2021 CuriousTorvald (minjaesong)"
|
const val COPYRIGHT_DATE_NAME = "Copyright 2013-2021 CuriousTorvald (minjaesong)"
|
||||||
val COPYRIGHT_LICENSE: String; get() = Lang["COPYRIGHT_GNU_GPL_3"]
|
val COPYRIGHT_LICENSE: String; get() = Lang["COPYRIGHT_GNU_GPL_3"]
|
||||||
const val COPYRIGHT_LICENSE_ENGLISH = "Distributed under GNU GPL 3"
|
const val COPYRIGHT_LICENSE_ENGLISH = "Distributed under GNU GPL 3"
|
||||||
|
const val COPYRIGHT_LICENSE_TERMS_SHORT = """
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
|||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.console.CommandDict
|
import net.torvald.terrarum.console.CommandDict
|
||||||
|
import net.torvald.terrarum.console.Echo
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
@@ -26,9 +27,15 @@ import net.torvald.terrarum.modulebasegame.gameactors.HumanoidNPC
|
|||||||
import net.torvald.terrarum.gameworld.WorldTime
|
import net.torvald.terrarum.gameworld.WorldTime
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIRemoCon
|
import net.torvald.terrarum.modulebasegame.ui.UIRemoCon
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UITitleRemoConYaml
|
import net.torvald.terrarum.modulebasegame.ui.UITitleRemoConYaml
|
||||||
|
import net.torvald.terrarum.serialise.ReadWorld
|
||||||
import net.torvald.terrarum.weather.WeatherMixer
|
import net.torvald.terrarum.weather.WeatherMixer
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
|
import java.io.IOException
|
||||||
|
import kotlin.math.atan2
|
||||||
|
import kotlin.math.cos
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
import kotlin.math.sin
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-09-02.
|
* Created by minjaesong on 2017-09-02.
|
||||||
@@ -58,53 +65,31 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
private lateinit var demoWorld: GameWorld
|
private lateinit var demoWorld: GameWorld
|
||||||
private lateinit var cameraNodes: FloatArray // camera Y-pos
|
private lateinit var cameraNodes: FloatArray // camera Y-pos
|
||||||
private val cameraAI = object : ActorAI {
|
private val cameraAI = object : ActorAI {
|
||||||
private val axisMax = 1f
|
|
||||||
|
|
||||||
private var firstTime = true
|
private var firstTime = true
|
||||||
|
|
||||||
override fun update(actor: Actor, delta: Float) {
|
override fun update(actor: Actor, delta: Float) {
|
||||||
val actor = actor as HumanoidNPC
|
val actor = actor as ActorWithBody
|
||||||
|
val ww = TILE_SIZEF * demoWorld.width
|
||||||
|
|
||||||
// fuck
|
val indexThis = ((actor.hitbox.canonicalX / ww * cameraNodes.size).floorInt()) % cameraNodes.size
|
||||||
val avSpeed = 1.0 // FIXME camera goes faster when FPS is high
|
val indexNext = (indexThis + 1) % cameraNodes.size
|
||||||
actor.actorValue[AVKey.SPEED] = avSpeed
|
val xwstart: Float = indexThis.toFloat() / cameraNodes.size * ww
|
||||||
actor.actorValue[AVKey.ACCEL] = avSpeed / 6.0
|
val xwend: Float = ((indexThis + 1).toFloat() / cameraNodes.size) * ww
|
||||||
// end fuck
|
val xw: Float = xwend - xwstart
|
||||||
|
|
||||||
|
val px: Double = (actor.hitbox.canonicalX + actor.actorValue.getAsDouble(AVKey.SPEED)!!) % ww.toDouble()
|
||||||
|
val xperc: Double = (px - xwstart) / xw
|
||||||
|
|
||||||
|
val y = FastMath.interpolateLinear(xperc.toFloat(), cameraNodes[indexThis], cameraNodes[indexNext])
|
||||||
|
|
||||||
val tileSize = TILE_SIZEF
|
if (firstTime) {
|
||||||
val catmullRomTension = 0f
|
firstTime = false
|
||||||
|
actor.hitbox.setPositionY(y - 8.0)
|
||||||
// pan camera
|
|
||||||
actor.moveRight(axisMax)
|
|
||||||
|
|
||||||
|
|
||||||
val domainSize = demoWorld.width * tileSize
|
|
||||||
val codomainSize = cameraNodes.size
|
|
||||||
val x = actor.hitbox.canonicalX.toFloat()
|
|
||||||
|
|
||||||
val p1 = (x / (domainSize / codomainSize)).floorInt() fmod cameraNodes.size
|
|
||||||
val p0 = ((p1 - 1) fmod codomainSize) fmod cameraNodes.size
|
|
||||||
val p2 = ((p1 + 1) fmod codomainSize) fmod cameraNodes.size
|
|
||||||
val p3 = ((p1 + 2) fmod codomainSize) fmod cameraNodes.size
|
|
||||||
val u: Float = 1f - (p2 - (x / (domainSize / codomainSize))) / (p2 - p1)
|
|
||||||
|
|
||||||
//val targetYPos = FastMath.interpolateCatmullRom(u, catmullRomTension, cameraNodes[p0], cameraNodes[p1], cameraNodes[p2], cameraNodes[p3])
|
|
||||||
val targetYPos = FastMath.interpolateLinear(u, cameraNodes[p1], cameraNodes[p2])
|
|
||||||
val yDiff = targetYPos - actor.hitbox.canonicalY
|
|
||||||
|
|
||||||
/*if (!firstTime) {
|
|
||||||
actor.moveDown(yDiff.bipolarClamp(axisMax.toDouble()).toFloat())
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
actor.hitbox.setPosition(actor.hitbox.canonicalX, targetYPos.toDouble())
|
(actor as CameraPlayer).moveTo(px, y - 8.0)
|
||||||
firstTime = false
|
}
|
||||||
}*/
|
|
||||||
actor.hitbox.setPosition(actor.hitbox.canonicalX, targetYPos.toDouble()) // just move the cameraY to interpolated path
|
|
||||||
|
|
||||||
|
|
||||||
//println("${actor.hitbox.canonicalX}, ${actor.hitbox.canonicalY}")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private lateinit var cameraPlayer: ActorWithBody
|
private lateinit var cameraPlayer: ActorWithBody
|
||||||
@@ -122,28 +107,51 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
printdbg(this, "Intro pre-load")
|
printdbg(this, "Intro pre-load")
|
||||||
|
|
||||||
|
|
||||||
demoWorld = GameWorld(1, 64, 64, 0L, 0L, 0)
|
try {
|
||||||
|
val reader = java.io.FileReader(ModMgr.getFile("basegame", "demoworld"))
|
||||||
|
//ReadWorld.readWorldAndSetNewWorld(Terrarum.ingame!! as TerrarumIngame, reader)
|
||||||
|
val world = ReadWorld.invoke(reader)
|
||||||
|
demoWorld = world
|
||||||
|
printdbg(this, "Demo world loaded")
|
||||||
|
}
|
||||||
|
catch (e: IOException) {
|
||||||
|
demoWorld = GameWorld(1, 64, 64, 0L, 0L, 0)
|
||||||
|
printdbg(this, "Demo world not found, using empty world")
|
||||||
|
}
|
||||||
|
|
||||||
printdbg(this, "Demo world gen complete")
|
|
||||||
|
|
||||||
// set time to summer
|
// set time to summer
|
||||||
demoWorld.worldTime.addTime(WorldTime.DAY_LENGTH * 32)
|
demoWorld.worldTime.addTime(WorldTime.DAY_LENGTH * 32)
|
||||||
|
|
||||||
// construct camera nodes
|
// construct camera nodes
|
||||||
val nodeCount = 100
|
val nodeCount = 400
|
||||||
cameraNodes = kotlin.FloatArray(nodeCount) { it ->
|
cameraNodes = kotlin.FloatArray(nodeCount) {
|
||||||
val tileXPos = (demoWorld.width.toFloat() * it / nodeCount).floorInt()
|
val tileXPos = (demoWorld.width.toFloat() * it / nodeCount).floorInt()
|
||||||
var travelDownCounter = 0
|
var travelDownCounter = 0
|
||||||
while (travelDownCounter < demoWorld.height && !BlockCodex[demoWorld.getTileFromTerrain(tileXPos, travelDownCounter)].isSolid) {
|
while (travelDownCounter < demoWorld.height && !BlockCodex[demoWorld.getTileFromTerrain(tileXPos, travelDownCounter)].isSolid) {
|
||||||
travelDownCounter += 4
|
travelDownCounter += 1
|
||||||
}
|
}
|
||||||
|
// println("Camera node #${it+1} = $travelDownCounter")
|
||||||
travelDownCounter * TILE_SIZEF
|
travelDownCounter * TILE_SIZEF
|
||||||
}
|
}
|
||||||
|
// apply gaussian blur to the camera nodes
|
||||||
|
for (i in cameraNodes.indices) {
|
||||||
|
val offM3 = cameraNodes[(i-3) fmod cameraNodes.size] * 0.025f
|
||||||
|
val offM2 = cameraNodes[(i-2) fmod cameraNodes.size] * 0.11f
|
||||||
|
val offM1 = cameraNodes[(i-1) fmod cameraNodes.size] * 0.29f
|
||||||
|
val off0 = cameraNodes[i] * 0.15f
|
||||||
|
val off1 = cameraNodes[(i+1) fmod cameraNodes.size] * 0.29f
|
||||||
|
val off2 = cameraNodes[(i+2) fmod cameraNodes.size] * 0.11f
|
||||||
|
val off3 = cameraNodes[(i+3) fmod cameraNodes.size] * 0.025f
|
||||||
|
|
||||||
|
cameraNodes[i] = offM3 + offM2 + offM1 + off0 + off1 + off2 + off3
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cameraPlayer = CameraPlayer(demoWorld, cameraAI)
|
cameraPlayer = CameraPlayer(demoWorld, cameraAI)
|
||||||
|
|
||||||
demoWorld.worldTime.timeDelta = 150
|
demoWorld.worldTime.timeDelta = 0//150
|
||||||
|
|
||||||
|
|
||||||
IngameRenderer.setRenderedWorld(demoWorld)
|
IngameRenderer.setRenderedWorld(demoWorld)
|
||||||
@@ -239,7 +247,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
|
|
||||||
if (!demoWorld.layerTerrain.ptr.destroyed) { // FIXME q&d hack to circumvent the dangling pointer issue #26
|
if (!demoWorld.layerTerrain.ptr.destroyed) { // FIXME q&d hack to circumvent the dangling pointer issue #26
|
||||||
IngameRenderer.invoke(gamePaused = true, uiContainer = uiContainer)
|
IngameRenderer.invoke(gamePaused = false, uiContainer = uiContainer)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printdbgerr(this, "Demoworld is already been destroyed")
|
printdbgerr(this, "Demoworld is already been destroyed")
|
||||||
@@ -365,6 +373,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
override val hitbox = Hitbox(0.0, 0.0, 2.0, 2.0)
|
override val hitbox = Hitbox(0.0, 0.0, 2.0, 2.0)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
actorValue[AVKey.SPEED] = 3.0
|
||||||
hitbox.setPosition(
|
hitbox.setPosition(
|
||||||
HQRNG().nextInt(demoWorld.width) * TILE_SIZED,
|
HQRNG().nextInt(demoWorld.width) * TILE_SIZED,
|
||||||
0.0 // Y pos: placeholder; camera AI will take it over
|
0.0 // Y pos: placeholder; camera AI will take it over
|
||||||
@@ -375,7 +384,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
override fun drawGlow(batch: SpriteBatch) { }
|
override fun drawGlow(batch: SpriteBatch) { }
|
||||||
|
|
||||||
override fun update(delta: Float) {
|
override fun update(delta: Float) {
|
||||||
|
ai.update(this, delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActorValueChange(key: String, value: Any?) { }
|
override fun onActorValueChange(key: String, value: Any?) { }
|
||||||
@@ -404,11 +413,21 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun moveTo(bearing: Double) {
|
override fun moveTo(bearing: Double) {
|
||||||
TODO("not implemented")
|
println(bearing)
|
||||||
|
val v = actorValue.getAsDouble(AVKey.SPEED)!!
|
||||||
|
hitbox.translate(v * cos(bearing), v * sin(bearing))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun moveTo(toX: Double, toY: Double) {
|
override fun moveTo(toX: Double, toY: Double) {
|
||||||
TODO("not implemented")
|
val ww = TILE_SIZED * demoWorld.width
|
||||||
|
// select appropriate toX because ROUNDWORLD
|
||||||
|
val xdiff1 = toX - hitbox.canonicalX
|
||||||
|
val xdiff2 = (toX + ww) - hitbox.canonicalX
|
||||||
|
|
||||||
|
val xdiff = if (xdiff1 < 0) xdiff2 else xdiff1
|
||||||
|
val ydiff = toY - hitbox.canonicalY
|
||||||
|
moveTo(atan2(ydiff, xdiff))
|
||||||
|
hitbox.setPositionX(hitbox.canonicalX % ww)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package net.torvald.terrarum.console
|
|
||||||
|
|
||||||
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
|
||||||
|
|
||||||
object ExportRendererFboRGB: ConsoleCommand {
|
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
|
||||||
IngameRenderer.fboRGBexportRequested = true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun printUsage() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
20
src/net/torvald/terrarum/console/ScreencapNogui.kt
Normal file
20
src/net/torvald/terrarum/console/ScreencapNogui.kt
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package net.torvald.terrarum.console
|
||||||
|
|
||||||
|
import net.torvald.terrarum.AppLoader
|
||||||
|
import net.torvald.terrarum.ccG
|
||||||
|
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||||
|
|
||||||
|
object ScreencapNogui: ConsoleCommand {
|
||||||
|
|
||||||
|
override fun execute(args: Array<String>) {
|
||||||
|
if (args.size == 2) {
|
||||||
|
IngameRenderer.fboRGBexportPath = AppLoader.defaultDir + "/Exports/${args[1]}.tga"
|
||||||
|
IngameRenderer.fboRGBexportRequested = true
|
||||||
|
Echo("FBO exported to$ccG Exports/${args[1]}.tga")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun printUsage() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -330,6 +330,21 @@ object IngameRenderer : Disposable {
|
|||||||
|
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
if (fboRGBexportRequested) {
|
||||||
|
fboRGBexportRequested = false
|
||||||
|
try {
|
||||||
|
val w = 960
|
||||||
|
val h = 640
|
||||||
|
val p = Pixmap.createFromFrameBuffer((fboRGB.width - w).ushr(1), (fboRGB.height - h).ushr(1), w, h)
|
||||||
|
PixmapIO2.writeTGA(Gdx.files.absolute(fboRGBexportPath), p, true)
|
||||||
|
p.dispose()
|
||||||
|
}
|
||||||
|
catch (e: Throwable) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -368,6 +383,7 @@ object IngameRenderer : Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal var fboRGBexportRequested = false
|
internal var fboRGBexportRequested = false
|
||||||
|
internal var fboRGBexportPath = ""
|
||||||
|
|
||||||
private fun drawToRGB(
|
private fun drawToRGB(
|
||||||
actorsRenderBehind: List<ActorWithBody>?,
|
actorsRenderBehind: List<ActorWithBody>?,
|
||||||
@@ -418,25 +434,6 @@ object IngameRenderer : Disposable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fboRGBexportRequested) {
|
|
||||||
fboRGBexportRequested = false
|
|
||||||
val fileChooser = JFileChooser()
|
|
||||||
fileChooser.showSaveDialog(null)
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (fileChooser.selectedFile != null) {
|
|
||||||
fboRGB.inAction(null, null) {
|
|
||||||
val p = ScreenUtils.getFrameBufferPixmap(0, 0, fboRGB.width, fboRGB.height)
|
|
||||||
PixmapIO2.writeTGA(Gdx.files.absolute(fileChooser.selectedFile.absolutePath), p, false)
|
|
||||||
p.dispose()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e: Throwable) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fboRGB_lightMixed.inAction(camera, batch) {
|
fboRGB_lightMixed.inAction(camera, batch) {
|
||||||
|
|
||||||
setCameraPosition(0f, 0f)
|
setCameraPosition(0f, 0f)
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
|||||||
*/
|
*/
|
||||||
internal object SetTimeDelta : ConsoleCommand {
|
internal object SetTimeDelta : ConsoleCommand {
|
||||||
|
|
||||||
val HARD_LIMIT = 60
|
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
val world = (Terrarum.ingame!! as TerrarumIngame).world
|
val world = (Terrarum.ingame!! as TerrarumIngame).world
|
||||||
|
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
|
|||||||
// TODO scrolling of the palette, as the old method flat out won't work with The Flattening
|
// TODO scrolling of the palette, as the old method flat out won't work with The Flattening
|
||||||
|
|
||||||
private val tabs = UIItemTextButtonList(
|
private val tabs = UIItemTextButtonList(
|
||||||
this, arrayOf("Terrain", "Wall", "Wire"),
|
this, 36, arrayOf("Terrain", "Wall", "Wire"),
|
||||||
0, 0, textAreaWidth = MENUBAR_SIZE, width = MENUBAR_SIZE,
|
0, 0, textAreaWidth = MENUBAR_SIZE, width = MENUBAR_SIZE,
|
||||||
defaultSelection = 0
|
defaultSelection = 0
|
||||||
)
|
)
|
||||||
private val closeButton = UIItemTextButtonList(
|
private val closeButton = UIItemTextButtonList(
|
||||||
this, arrayOf("Close"),
|
this, 36, arrayOf("Close"),
|
||||||
0, this.height - UIItemTextButtonList.DEFAULT_LINE_HEIGHT,
|
0, this.height - UIItemTextButtonList.DEFAULT_LINE_HEIGHT,
|
||||||
width = MENUBAR_SIZE, textAreaWidth = MENUBAR_SIZE
|
width = MENUBAR_SIZE, textAreaWidth = MENUBAR_SIZE
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
private val gameMenuListHeight = DEFAULT_LINE_HEIGHT * gameMenu.size
|
private val gameMenuListHeight = DEFAULT_LINE_HEIGHT * gameMenu.size
|
||||||
private val gameMenuListWidth = 400
|
private val gameMenuListWidth = 400
|
||||||
private val gameMenuButtons = UIItemTextButtonList(
|
private val gameMenuButtons = UIItemTextButtonList(
|
||||||
this, gameMenu,
|
this, DEFAULT_LINE_HEIGHT, gameMenu,
|
||||||
(AppLoader.screenSize.screenW - gameMenuListWidth) / 2,
|
(AppLoader.screenSize.screenW - gameMenuListWidth) / 2,
|
||||||
INVENTORY_CELLS_OFFSET_Y + (INVENTORY_CELLS_UI_HEIGHT - gameMenuListHeight) / 2,
|
INVENTORY_CELLS_OFFSET_Y + (INVENTORY_CELLS_UI_HEIGHT - gameMenuListHeight) / 2,
|
||||||
gameMenuListWidth, gameMenuListHeight,
|
gameMenuListWidth, gameMenuListHeight,
|
||||||
|
|||||||
@@ -38,12 +38,12 @@ class UIProxyNewRandomGame : UICanvas() {
|
|||||||
|
|
||||||
|
|
||||||
val ingame = TerrarumIngame(AppLoader.batch)
|
val ingame = TerrarumIngame(AppLoader.batch)
|
||||||
val worldParam = TerrarumIngame.NewWorldParameters(2400, 1280, 0x51621DL)
|
// val worldParam = TerrarumIngame.NewWorldParameters(2400, 1280, 0x51621DL)
|
||||||
//val worldParam = TerrarumIngame.NewWorldParameters(2400, 1280, HQRNG().nextLong())
|
val worldParam = TerrarumIngame.NewWorldParameters(2400, 1280, HQRNG().nextLong())
|
||||||
|
|
||||||
//val worldParam = TerrarumIngame.NewWorldParameters(6000, 1800, 0x51621DL) // small
|
//val worldParam = TerrarumIngame.NewWorldParameters(6000, 1800, 0x51621DL) // small
|
||||||
// val worldParam = TerrarumIngame.NewWorldParameters(9000, 2250, 0x51621DL) // normal
|
// val worldParam = TerrarumIngame.NewWorldParameters(9000, 2250, 0x51621DL) // normal
|
||||||
//val worldParam = TerrarumIngame.NewWorldParameters(13500, 3000, 0x51621DL) // large
|
//val worldParam = TerrarumIngame.NewWorldParDoubleameters(13500, 3000, 0x51621DL) // large
|
||||||
//val worldParam = TerrarumIngame.NewWorldParameters(22500, 4500, 0x51621DL) // huge
|
//val worldParam = TerrarumIngame.NewWorldParameters(22500, 4500, 0x51621DL) // huge
|
||||||
ingame.gameLoadInfoPayload = worldParam
|
ingame.gameLoadInfoPayload = worldParam
|
||||||
ingame.gameLoadMode = TerrarumIngame.GameLoadMode.CREATE_NEW
|
ingame.gameLoadMode = TerrarumIngame.GameLoadMode.CREATE_NEW
|
||||||
|
|||||||
@@ -248,11 +248,14 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
|
|||||||
|
|
||||||
class UIRemoConElement(uiRemoCon: UIRemoCon, val labels: Array<String>) {
|
class UIRemoConElement(uiRemoCon: UIRemoCon, val labels: Array<String>) {
|
||||||
|
|
||||||
|
private val lineHeight = 36
|
||||||
|
|
||||||
private val menubar = UIItemTextButtonList(
|
private val menubar = UIItemTextButtonList(
|
||||||
uiRemoCon,
|
uiRemoCon,
|
||||||
|
lineHeight,
|
||||||
labels,
|
labels,
|
||||||
0, menubarOffY,
|
menubarOffX,
|
||||||
|
menubarOffY - lineHeight * labels.size + 16,
|
||||||
uiRemoCon.width, getRemoConHeight(labels),
|
uiRemoCon.width, getRemoConHeight(labels),
|
||||||
textAreaWidth = uiRemoCon.width,
|
textAreaWidth = uiRemoCon.width,
|
||||||
readFromLang = true,
|
readFromLang = true,
|
||||||
@@ -261,7 +264,8 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
|
|||||||
backgroundCol = Color(0),
|
backgroundCol = Color(0),
|
||||||
inactiveCol = Color.WHITE,
|
inactiveCol = Color.WHITE,
|
||||||
defaultSelection = null,
|
defaultSelection = null,
|
||||||
itemHitboxSize = 34
|
itemHitboxSize = lineHeight - 2,
|
||||||
|
alignment = UIItemTextButton.Companion.Alignment.LEFT
|
||||||
)
|
)
|
||||||
|
|
||||||
fun update(delta: Float) {
|
fun update(delta: Float) {
|
||||||
@@ -288,9 +292,10 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val remoConWidth = 304
|
val remoConWidth = 300
|
||||||
fun getRemoConHeight(menu: ArrayList<String>) = DEFAULT_LINE_HEIGHT * menu.size.plus(1)
|
fun getRemoConHeight(menu: ArrayList<String>) = DEFAULT_LINE_HEIGHT * menu.size.plus(1)
|
||||||
fun getRemoConHeight(menu: Array<String>) = DEFAULT_LINE_HEIGHT * menu.size.plus(1)
|
fun getRemoConHeight(menu: Array<String>) = DEFAULT_LINE_HEIGHT * menu.size.plus(1)
|
||||||
val menubarOffY: Int; get() = AppLoader.screenSize.screenH / 2 - (AppLoader.fontGame.lineHeight * 1.5).toInt()
|
val menubarOffX: Int; get() = (0.11 * AppLoader.screenSize.screenW).toInt()
|
||||||
|
val menubarOffY: Int; get() = (0.82 * AppLoader.screenSize.screenH).toInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ class UITitleLanguage : UICanvas() {
|
|||||||
|
|
||||||
private val localeList = Lang.languageList.toList().sorted()
|
private val localeList = Lang.languageList.toList().sorted()
|
||||||
private val textArea = UIItemTextButtonList(this,
|
private val textArea = UIItemTextButtonList(this,
|
||||||
|
24,
|
||||||
localeList.map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }.toTypedArray(),
|
localeList.map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }.toTypedArray(),
|
||||||
AppLoader.screenSize.screenW - width, textAreaHMargin,
|
AppLoader.screenSize.screenW - width, textAreaHMargin,
|
||||||
width, height,
|
width, height,
|
||||||
|
|||||||
@@ -13,12 +13,9 @@ object UITitleRemoConYaml {
|
|||||||
* The class must be the UICanvas
|
* The class must be the UICanvas
|
||||||
*/
|
*/
|
||||||
val menus = """
|
val menus = """
|
||||||
- MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UITitleCharactersList
|
- MENU_LABEL_CONTINUE
|
||||||
- CONTEXT_CHARACTER_NEW
|
- MENU_LABEL_NEW_GAME : net.torvald.terrarum.modulebasegame.ui.UIProxyNewRandomGame
|
||||||
- CONTEXT_CHARACTER_DELETE
|
- MENU_IO_LOAD
|
||||||
- MENU_LABEL_RETURN
|
|
||||||
- MENU_MODE_MULTIPLAYER
|
|
||||||
- MENU_LABEL_RETURN
|
|
||||||
- MENU_OPTIONS
|
- MENU_OPTIONS
|
||||||
- MENU_OPTIONS_GRAPHICS
|
- MENU_OPTIONS_GRAPHICS
|
||||||
- MENU_OPTIONS_CONTROLS
|
- MENU_OPTIONS_CONTROLS
|
||||||
@@ -38,12 +35,12 @@ object UITitleRemoConYaml {
|
|||||||
- MENU_LABEL_QUIT
|
- MENU_LABEL_QUIT
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
val debugTools = """
|
val debugTools = "" /*"""
|
||||||
- Development Tools $
|
- Development Tools $
|
||||||
- Building Maker : net.torvald.terrarum.modulebasegame.ui.UIProxyNewBuildingMaker
|
- Building Maker : net.torvald.terrarum.modulebasegame.ui.UIProxyNewBuildingMaker
|
||||||
- Start New Random Game : net.torvald.terrarum.modulebasegame.ui.UIProxyNewRandomGame
|
- Start New Random Game : net.torvald.terrarum.modulebasegame.ui.UIProxyNewRandomGame
|
||||||
- MENU_LABEL_RETURN
|
- MENU_LABEL_RETURN
|
||||||
""".trimIndent()
|
""".trimIndent()*/
|
||||||
|
|
||||||
operator fun invoke() = if (AppLoader.IS_DEVELOPMENT_BUILD)
|
operator fun invoke() = if (AppLoader.IS_DEVELOPMENT_BUILD)
|
||||||
Yaml(menus + "\n" + debugTools).parse()
|
Yaml(menus + "\n" + debugTools).parse()
|
||||||
|
|||||||
@@ -12,11 +12,12 @@ import kotlin.math.roundToInt
|
|||||||
*/
|
*/
|
||||||
class UIItemTextButtonList(
|
class UIItemTextButtonList(
|
||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
|
val lineHeight: Int,
|
||||||
labelsList: Array<String>,
|
labelsList: Array<String>,
|
||||||
initialX: Int,
|
initialX: Int,
|
||||||
initialY: Int,
|
initialY: Int,
|
||||||
override var width: Int,
|
override var width: Int,
|
||||||
override var height: Int = DEFAULT_LINE_HEIGHT * labelsList.size,
|
override var height: Int = lineHeight * labelsList.size,
|
||||||
val readFromLang: Boolean = false,
|
val readFromLang: Boolean = false,
|
||||||
val defaultSelection: Int? = null, // negative: INVALID, positive: valid, null: no select
|
val defaultSelection: Int? = null, // negative: INVALID, positive: valid, null: no select
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ class UIItemTextButtonList(
|
|||||||
val kinematic: Boolean = false,
|
val kinematic: Boolean = false,
|
||||||
|
|
||||||
val alignment: UIItemTextButton.Companion.Alignment = UIItemTextButton.Companion.Alignment.CENTRE,
|
val alignment: UIItemTextButton.Companion.Alignment = UIItemTextButton.Companion.Alignment.CENTRE,
|
||||||
val itemHitboxSize: Int = DEFAULT_LINE_HEIGHT
|
val itemHitboxSize: Int = lineHeight
|
||||||
) : UIItem(parentUI, initialX, initialY) {
|
) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -75,7 +76,7 @@ class UIItemTextButtonList(
|
|||||||
val h = height.toFloat()
|
val h = height.toFloat()
|
||||||
val ss = labelsList.size.toFloat()
|
val ss = labelsList.size.toFloat()
|
||||||
val lh = itemHitboxSize
|
val lh = itemHitboxSize
|
||||||
val vertOff = (h/ss * i + (h/ss - lh) / 2f).roundToInt()
|
val vertOff = lineHeight * i
|
||||||
|
|
||||||
if (!kinematic) {
|
if (!kinematic) {
|
||||||
UIItemTextButton(
|
UIItemTextButton(
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ class UINSMenu(
|
|||||||
|
|
||||||
val list = UIItemTextButtonList(
|
val list = UIItemTextButtonList(
|
||||||
this,
|
this,
|
||||||
|
UIItemTextButtonList.DEFAULT_LINE_HEIGHT,
|
||||||
stringsFromTree,
|
stringsFromTree,
|
||||||
width, LINE_HEIGHT,
|
width, LINE_HEIGHT,
|
||||||
uiWidth, listHeight,
|
uiWidth, listHeight,
|
||||||
|
|||||||
Reference in New Issue
Block a user