UI: sub-UIs work?

This commit is contained in:
minjaesong
2017-07-25 17:21:02 +09:00
parent 3578df4770
commit 33657624a6
31 changed files with 390 additions and 283 deletions

View File

@@ -1,19 +1,25 @@
## Minimum requirements ##
* Any CPU with 1.8 GHz in speed
* GPU that supports OpenGL 2.0, is capable of 4K texture (8K for Chinese/Japanese language)
* 2 GB of RAM
* Processor with 2.4 GHz speed
* GPU that can support OpenGL 2.1, is capable of 4K texture
* 4 GB of RAM
* 2 GB of free disk space
* Windows Vista/Mac OS X Lion or higher (Mac OS X Snow Leopard is incompatible with a shader the game uses)
* PC: Java 8, Up-to-date graphics driver
## Recommended requirements ##
* Intel i5 with 2.4+ GHz in speed (or any CPU with 4 or more threads, 2.4+ GHz in speed)
* GPU that supports OpenGL 2.0, is capable of 8K texture
* 4 GB of RAM
* Processor with 3.0 GHz speed, 4 threads available
* GPU that can support OpenGL 2.1, is capable of 4K texture
* 8 GB of RAM
* 5 GB of free disk space
* Windows Vista/Mac OS X Lion or higher
* PC: Java 8, Up-to-date graphics driver
## Tested environment ##
(to devs: please extend this list with your test results!)
* MacBookPro9,2 (MacBook Pro 13 inch mid-2012)
* Intel 6700K, nVidia GTX970, Windows 10

View File

@@ -1,4 +1,7 @@
#version 120
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_color;

View File

@@ -1,4 +1,7 @@
#version 120
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_color;

View File

@@ -1,4 +1,7 @@
#version 120
#version 100
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_color;
@@ -11,18 +14,5 @@ void main(void) {
vec4 colorTex0 = texture2D(u_texture, v_texCoords); // lightmap (RGB) pre-mixed
vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (A) pre-mixed
vec4 newColor = vec4(0.0, 0.0, 0.0, colorTex0.a);
if (colorTex0.r > colorTex1.r) newColor.r = colorTex0.r;
else newColor.r = colorTex1.r;
if (colorTex0.g > colorTex1.g) newColor.g = colorTex0.g;
else newColor.g = colorTex1.g;
if (colorTex0.b > colorTex1.b) newColor.b = colorTex0.b;
else newColor.b = colorTex1.b;
gl_FragColor = newColor;
gl_FragColor = vec4(max(colorTex0.rgb, colorTex1.rgb), colorTex0.a);
}

View File

@@ -57,7 +57,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
val actorContainer = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
val actorContainerInactive = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
val particlesContainer = CircularArray<ParticleBase>(PARTICLES_MAX)
val uiContainer = ArrayList<UIHandler>()
val uiContainer = ArrayList<UICanvas>()
private val actorsRenderBehind = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
private val actorsRenderMiddle = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
@@ -111,26 +111,26 @@ class Ingame(val batch: SpriteBatch) : Screen {
lateinit var consoleHandler: UIHandler
lateinit var debugWindow: UIHandler
lateinit var notifier: UIHandler
lateinit var consoleHandler: UICanvas
lateinit var debugWindow: UICanvas
lateinit var notifier: UICanvas
lateinit var uiPieMenu: UIHandler
lateinit var uiQuickBar: UIHandler
lateinit var uiInventoryPlayer: UIHandler
lateinit var uiInventoryContainer: UIHandler
lateinit var uiVitalPrimary: UIHandler
lateinit var uiVitalSecondary: UIHandler
lateinit var uiVitalItem: UIHandler // itemcount/durability of held block or active ammo of held gun. As for the block, max value is 500.
lateinit var uiPieMenu: UICanvas
lateinit var uiQuickBar: UICanvas
lateinit var uiInventoryPlayer: UICanvas
lateinit var uiInventoryContainer: UICanvas
lateinit var uiVitalPrimary: UICanvas
lateinit var uiVitalSecondary: UICanvas
lateinit var uiVitalItem: UICanvas // itemcount/durability of held block or active ammo of held gun. As for the block, max value is 500.
lateinit var uiWatchBasic: UIHandler
lateinit var uiWatchTierOne: UIHandler
lateinit var uiWatchBasic: UICanvas
lateinit var uiWatchTierOne: UICanvas
// UI aliases
lateinit var uiAliases: ArrayList<UIHandler>
lateinit var uiAliases: ArrayList<UICanvas>
private set
lateinit var uiAlasesPausing: ArrayList<UIHandler>
lateinit var uiAlasesPausing: ArrayList<UICanvas>
private set
inline val paused: Boolean
@@ -296,66 +296,63 @@ class Ingame(val batch: SpriteBatch) : Screen {
// init console window
consoleHandler = UIHandler(ConsoleWindow())
consoleHandler = ConsoleWindow()
consoleHandler.setPosition(0, 0)
// init debug window
debugWindow = UIHandler(BasicDebugInfoWindow())
debugWindow = BasicDebugInfoWindow()
debugWindow.setPosition(0, 0)
// init notifier
notifier = UIHandler(Notification())
notifier.UI.handler = notifier
notifier = Notification()
notifier.setPosition(
(Terrarum.WIDTH - notifier.UI.width) / 2, Terrarum.HEIGHT - notifier.UI.height)
(Terrarum.WIDTH - notifier.width) / 2, Terrarum.HEIGHT - notifier.height)
// >- queue up game UIs that should pause the world -<
// inventory
uiInventoryPlayer = UIHandler(
UIInventory(player,
width = 900,
height = Terrarum.HEIGHT - 160,
categoryWidth = 210
),
uiInventoryPlayer = UIInventory(player,
width = 900,
height = Terrarum.HEIGHT - 160,
categoryWidth = 210,
toggleKeyLiteral = Terrarum.getConfigInt("keyinventory")
)
uiInventoryPlayer.setPosition(
-uiInventoryPlayer.UI.width,
-uiInventoryPlayer.width,
70
)
// >- lesser UIs -<
// quick bar
uiQuickBar = UIHandler(UIQuickBar())
uiQuickBar = UIQuickBar()
uiQuickBar.isVisible = true
uiQuickBar.setPosition(0, 0)
// pie menu
uiPieMenu = UIHandler(UIPieMenu())
uiPieMenu = UIPieMenu()
uiPieMenu.setPosition(Terrarum.HALFW, Terrarum.HALFH)
// vital metre
// fill in getter functions by
// (uiAliases[UI_QUICK_BAR]!!.UI as UIVitalMetre).vitalGetterMax = { some_function }
//uiVitalPrimary = UIHandler(UIVitalMetre(player, { 80f }, { 100f }, Color.red, 2), customPositioning = true)
//uiVitalPrimary = UIVitalMetre(player, { 80f }, { 100f }, Color.red, 2, customPositioning = true)
//uiVitalPrimary.setAsAlwaysVisible()
//uiVitalSecondary = UIHandler(UIVitalMetre(player, { 73f }, { 100f }, Color(0x00dfff), 1), customPositioning = true)
//uiVitalSecondary = UIVitalMetre(player, { 73f }, { 100f }, Color(0x00dfff), 1) customPositioning = true)
//uiVitalSecondary.setAsAlwaysVisible()
//uiVitalItem = UIHandler(UIVitalMetre(player, { null }, { null }, Color(0xffcc00), 0), customPositioning = true)
//uiVitalItem = UIVitalMetre(player, { null }, { null }, Color(0xffcc00), 0, customPositioning = true)
//uiVitalItem.setAsAlwaysVisible()
// basic watch-style notification bar (temperature, new mail)
uiWatchBasic = UIHandler(UIBasicNotifier(player))
uiWatchBasic = UIBasicNotifier(player)
uiWatchBasic.setAsAlwaysVisible()
uiWatchBasic.setPosition(Terrarum.WIDTH - uiWatchBasic.UI.width, 0)
uiWatchBasic.setPosition(Terrarum.WIDTH - uiWatchBasic.width, 0)
uiWatchTierOne = UIHandler(UITierOneWatch(player))
uiWatchTierOne = UITierOneWatch(player)
uiWatchTierOne.setAsAlwaysVisible()
uiWatchTierOne.setPosition(Terrarum.WIDTH - uiWatchTierOne.UI.width, uiWatchBasic.UI.height - 2)
uiWatchTierOne.setPosition(Terrarum.WIDTH - uiWatchTierOne.width, uiWatchBasic.height - 2)
// batch-process uiAliases
@@ -994,7 +991,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
/** Send message to notifier UI and toggle the UI as opened. */
fun sendNotification(msg: Array<String>) {
(notifier.UI as Notification).sendNotification(msg)
(notifier as Notification).sendNotification(msg)
}
fun wakeDormantActors() {
@@ -1249,11 +1246,11 @@ class Ingame(val batch: SpriteBatch) : Screen {
particlesContainer.add(particle)
}
fun addUI(ui: UIHandler) {
fun addUI(ui: UICanvas) {
// check for exact duplicates
if (uiContainer.contains(ui)) {
throw IllegalArgumentException(
"Exact copy of the UI already exists: The instance of ${ui.UI.javaClass.simpleName}"
"Exact copy of the UI already exists: The instance of ${ui.javaClass.simpleName}"
)
}
@@ -1382,21 +1379,20 @@ class Ingame(val batch: SpriteBatch) : Screen {
// resize UIs
notifier.setPosition(
(Terrarum.WIDTH - notifier.UI.width) / 2, Terrarum.HEIGHT - notifier.UI.height)
(Terrarum.WIDTH - notifier.width) / 2, Terrarum.HEIGHT - notifier.height)
// inventory
uiInventoryPlayer.UI =
uiInventoryPlayer =
UIInventory(player,
width = 840,
height = Terrarum.HEIGHT - 160,
categoryWidth = 210
)
uiInventoryPlayer.UI.handler = uiInventoryPlayer
// basic watch-style notification bar (temperature, new mail)
uiWatchBasic.setPosition(Terrarum.WIDTH - uiWatchBasic.UI.width, 0)
uiWatchTierOne.setPosition(Terrarum.WIDTH - uiWatchTierOne.UI.width, uiWatchBasic.UI.height - 2)
uiWatchBasic.setPosition(Terrarum.WIDTH - uiWatchBasic.width, 0)
uiWatchTierOne.setPosition(Terrarum.WIDTH - uiWatchTierOne.width, uiWatchBasic.height - 2)
}
}

View File

@@ -32,6 +32,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import org.lwjgl.input.Controllers
import java.io.File
import java.io.IOException
import java.lang.management.ManagementFactory
import java.util.*
/**
@@ -289,7 +290,7 @@ object Terrarum : Game() {
println("[Terrarum] os.arch = $systemArch") // debug info
if (is32BitJVM) {
println("32 Bit JVM detected")
System.err.println("[Terrarum] 32 Bit JVM detected")
}
joypadLabelStart = when (getConfigString("joypadlabelstyle")) {
@@ -325,9 +326,25 @@ object Terrarum : Game() {
val USE_VSYNC = getConfigBoolean("usevsync")
var VSYNC = USE_VSYNC
val VSYNC_TRIGGER_THRESHOLD = 56
val GL_VERSION: Int
get() = Gdx.graphics.glVersion.majorVersion * 100 +
Gdx.graphics.glVersion.minorVersion * 10 +
Gdx.graphics.glVersion.releaseVersion
val MINIMAL_GL_VERSION = 210
override fun create() {
println("[Terrarum] GL_VERSION = $GL_VERSION")
println("[Terrarum] GL info:\n${Gdx.graphics.glVersion.debugVersionString}") // debug info
if (GL_VERSION < MINIMAL_GL_VERSION) {
// TODO notify properly
throw Error("Graphics device not capable -- device's GL_VERSION: $GL_VERSION, required: $MINIMAL_GL_VERSION")
}
fullscreenQuad = Mesh(
true, 4, 6,
VertexAttribute.Position(),
@@ -409,16 +426,16 @@ object Terrarum : Game() {
// jump right into the ingame
ingame = Ingame(batch)
/*ingame = Ingame(batch)
ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong())
ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW
LoadScreen.screenToLoad = ingame!!
super.setScreen(LoadScreen)
super.setScreen(LoadScreen)*/
// title screen
//super.setScreen(TitleScreen(batch))
super.setScreen(TitleScreen(batch))
}
internal fun changeScreen(screen: Screen) {

View File

@@ -16,6 +16,7 @@ import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.fmod
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.serialise.ReadLayerData
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIHandler
import net.torvald.terrarum.ui.UITitleRemoConRoot
import net.torvald.terrarum.weather.WeatherMixer
@@ -64,7 +65,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
val tileSize = FeaturesDrawer.TILE_SIZE.toFloat()
val catmullRomTension = -1f
val catmullRomTension = 0f
// pan camera
actor.moveRight(axisMax)
@@ -80,16 +81,18 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
val p3 = (p1 + 2) fmod codomainSize
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.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) {
/*if (!firstTime) {
actor.moveDown(yDiff.bipolarClamp(axisMax.toDouble()).toFloat())
}
else {
actor.hitbox.setPosition(actor.hitbox.canonicalX, targetYPos.toDouble())
firstTime = false
}
}*/
actor.hitbox.setPosition(actor.hitbox.canonicalX, targetYPos.toDouble()) // just move the cameraY to interpolated path
//println("${actor.hitbox.canonicalX}, ${actor.hitbox.canonicalY}")
@@ -106,15 +109,15 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
lateinit var logo: TextureRegion
val uiContainer = ArrayList<UIHandler>()
private lateinit var uiMenu: UIHandler
val uiContainer = ArrayList<UICanvas>()
private lateinit var uiMenu: UICanvas
private fun loadThingsWhileIntroIsVisible() {
demoWorld = ReadLayerData(FileInputStream(ModMgr.getFile("basegame", "demoworld")))
// construct camera nodes
val nodeCount = 60
val nodeCount = 100
cameraNodes = kotlin.FloatArray(nodeCount, { it ->
val tileXPos = (demoWorld.width.toFloat() * it / nodeCount).floorInt()
var travelDownCounter = 0
@@ -144,7 +147,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
FeaturesDrawer.world = demoWorld
uiMenu = UIHandler(UITitleRemoConRoot())
uiMenu = UITitleRemoConRoot()
uiMenu.setPosition(0, UITitleRemoConRoot.menubarOffY)
uiMenu.setAsOpen()
@@ -358,7 +361,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
if (loadDone) {
// resize UI by re-creating it (!!)
uiMenu.UI.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
uiMenu.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
uiMenu.setPosition(0, UITitleRemoConRoot.menubarOffY)
}

View File

@@ -39,7 +39,7 @@ internal object Authenticator : ConsoleCommand {
Echo(msg)
println("[Authenticator] " + msg)
a = !a
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).reset()
(Terrarum.ingame!!.consoleHandler as ConsoleWindow).reset()
}
else {
printUsage() // thou shalt not pass!

View File

@@ -16,13 +16,13 @@ internal object Echo : ConsoleCommand {
val sb = StringBuilder()
for (ch in single_line) {
if (ch == '\n') {
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
(Terrarum.ingame!!.consoleHandler as ConsoleWindow).sendMessage(sb.toString())
sb.delete(0, sb.length - 1)
}
else
sb.append(ch)
}
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
(Terrarum.ingame!!.consoleHandler as ConsoleWindow).sendMessage(sb.toString())
}
operator fun invoke(args: Array<String>) = execute(args)

View File

@@ -14,7 +14,7 @@ internal object EchoError : ConsoleCommand {
}
fun execute(single_line: String) {
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage("$ccR$single_line")
(Terrarum.ingame!!.consoleHandler as ConsoleWindow).sendMessage("$ccR$single_line")
}
operator fun invoke(args: Array<String>) = execute(args)

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.console
import com.badlogic.gdx.Gdx
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.langpack.Lang
@@ -11,6 +12,8 @@ internal object Version : ConsoleCommand {
Echo("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
Echo("Polyglot language pack version ${Lang.POLYGLOT_VERSION}")
Echo("GL_VERSION: ${Terrarum.GL_VERSION}")
Echo("Renderer: ${Gdx.graphics.glVersion.rendererString}, ${Gdx.graphics.glVersion.vendorString}")
}
override fun printUsage() {

View File

@@ -530,7 +530,7 @@ open class ActorHumanoid(
// force update inventory UI
try {
(Terrarum.ingame!!.uiInventoryPlayer.UI as UIInventory).shutUpAndRebuild()
(Terrarum.ingame!!.uiInventoryPlayer as UIInventory).shutUpAndRebuild()
}
catch (LateInitMyArse: kotlin.UninitializedPropertyAccessException) { }
}

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath
@@ -27,7 +28,7 @@ class BasicDebugInfoWindow : UICanvas() {
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
val player = Terrarum.ingame!!.player
val hitbox = player.hitbox
@@ -38,7 +39,7 @@ class BasicDebugInfoWindow : UICanvas() {
prevPlayerY = hitbox.canonicalY
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
fun Int.rawR() = this / LightmapRenderer.MUL_2
fun Int.rawG() = this % LightmapRenderer.MUL_2 / LightmapRenderer.MUL
fun Int.rawB() = this % LightmapRenderer.MUL
@@ -87,16 +88,14 @@ class BasicDebugInfoWindow : UICanvas() {
printLineColumn(batch, 2, 3, "veloX measured $ccG${xdelta}")
printLineColumn(batch, 2, 4, "veloY measured $ccG${ydelta}")
if (player != null) {
printLineColumn(batch, 1, 7,
"walled " +
"${if (player.walledLeft) "$ccR" else "$ccG"}L" +
"${if (player.walledBottom) "$ccR" else "$ccG"}${0x1F.toChar()}" +
"${if (player.walledTop) "$ccR" else "$ccG"}${0x1E.toChar()}" +
"${if (player.walledRight) "$ccR" else "$ccG"}R" +
"${if (player.colliding) "$ccR" else "$ccG"}${0x08.toChar()}"
)
}
printLineColumn(batch, 1, 7,
"walled " +
"${if (player.walledLeft) "$ccR" else "$ccG"}L" +
"${if (player.walledBottom) "$ccR" else "$ccG"}${0x1F.toChar()}" +
"${if (player.walledTop) "$ccR" else "$ccG"}${0x1E.toChar()}" +
"${if (player.walledRight) "$ccR" else "$ccG"}R" +
"${if (player.colliding) "$ccR" else "$ccG"}${0x08.toChar()}"
)

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.dataclass.HistoryArray
@@ -46,10 +47,10 @@ class ConsoleWindow : UICanvas() {
reset()
}
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
// background
batch.color = UIColour
batch.fillRect(drawOffX, drawOffY, width.toFloat(), height.toFloat())

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.Terrarum
@@ -30,10 +31,10 @@ class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas
this.messagesList = messagesList
}
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
blendNormal()
val textWidth = messagesList.map { Terrarum.fontGame.getWidth(it) }.sorted()[1]

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.Second
@@ -26,7 +27,7 @@ class Notification : UICanvas() {
override var openCloseTime: Second = MessageWindow.OPEN_CLOSE_TIME
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
if (handler.isOpened)
displayTimer += delta
@@ -36,24 +37,24 @@ class Notification : UICanvas() {
}
}
override fun render(batch: SpriteBatch) {
msgUI.render(batch)
override fun renderUI(batch: SpriteBatch, camera: Camera) {
msgUI.render(batch, camera)
}
override fun doOpening(delta: Float) {
UICanvas.doOpeningFade(handler, openCloseTime)
UICanvas.doOpeningFade(this, openCloseTime)
}
override fun doClosing(delta: Float) {
UICanvas.doClosingFade(handler, openCloseTime)
UICanvas.doClosingFade(this, openCloseTime)
}
override fun endOpening(delta: Float) {
UICanvas.endOpeningFade(handler)
UICanvas.endOpeningFade(this)
}
override fun endClosing(delta: Float) {
UICanvas.endClosingFade(handler)
UICanvas.endClosingFade(this)
}
fun sendNotification(message: Array<String>) {

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
/**
@@ -10,10 +11,10 @@ class NullUI : UICanvas() {
override var height: Int = 0
override var openCloseTime = 0f
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
}
override fun doOpening(delta: Float) {

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.ui
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.*
@@ -28,7 +29,7 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas() {
private var font = Watch7SegSmall
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
if (ELon) {
ELuptimer += delta
}
@@ -100,7 +101,7 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas() {
return sb.toString()
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
// light overlay or EL
if (ELon) {
blendNormal()

View File

@@ -1,6 +1,8 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.Second
@@ -12,20 +14,36 @@ import net.torvald.terrarum.gameactors.roundInt
*
* Created by minjaesong on 15-12-31.
*/
abstract class UICanvas {
abstract class UICanvas(
toggleKeyLiteral: Int? = null, toggleButtonLiteral: Int? = null,
// UI positions itself? (you must g.flush() yourself after the g.translate(Int, Int))
customPositioning: Boolean = false, // mainly used by vital meter
doNotWarnConstant: Boolean = false
) {
abstract var width: Int
abstract var height: Int
inline var posX: Int
get() = handler.posX
set(value) { handler.posX = value }
inline var posY: Int
get() = handler.posY
set(value) { handler.posY = value }
/**
* Usage: (in StateInGame:) uiHandlerField.ui.handler = uiHandlerField
*/
open lateinit var handler: UIHandler
protected val handler = UIHandler(toggleKeyLiteral, toggleButtonLiteral, customPositioning, doNotWarnConstant)
init {
}
/**
* In milliseconds
*
* Timer itself is implemented in the handler.
* Timer itself is implemented in the ui.handler.
*/
abstract var openCloseTime: Second
@@ -46,27 +64,41 @@ abstract class UICanvas {
get() = mouseUp && Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary"))
abstract fun update(delta: Float)
fun update(delta: Float) {
handler.update(this, delta)
}
fun render(batch: SpriteBatch, camera: Camera) {
handler.render(this, batch, camera)
}
abstract fun render(batch: SpriteBatch)
inline fun addSubUI(ui: UICanvas) {
handler.addSubUI(ui)
}
/** Override this for the actual update */
abstract fun updateUI(delta: Float)
/** Override this for the actual render */
abstract fun renderUI(batch: SpriteBatch, camera: Camera)
/**
* Do not modify handler.openCloseCounter here.
* Do not modify ui.handler.openCloseCounter here.
*/
abstract fun doOpening(delta: Float)
/**
* Do not modify handler.openCloseCounter here.
* Do not modify ui.handler.openCloseCounter here.
*/
abstract fun doClosing(delta: Float)
/**
* Do not modify handler.openCloseCounter here.
* Do not modify ui.handler.openCloseCounter here.
*/
abstract fun endOpening(delta: Float)
/**
* Do not modify handler.openCloseCounter here.
* Do not modify ui.handler.openCloseCounter here.
*/
abstract fun endClosing(delta: Float)
@@ -78,31 +110,37 @@ abstract class UICanvas {
open fun mouseMoved(screenX: Int, screenY: Int): Boolean {
uiItems.forEach { it.mouseMoved(screenX, screenY) }
handler.subUIs.forEach { it.mouseMoved(screenX, screenY) }
return true
}
open fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
uiItems.forEach { it.touchDragged(screenX, screenY, pointer) }
handler.subUIs.forEach { it.touchDragged(screenX, screenY, pointer) }
return true
}
open fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
uiItems.forEach { it.touchDown(screenX, screenY, pointer, button) }
handler.subUIs.forEach { it.touchDown(screenX, screenY, pointer, button) }
return true
}
open fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
uiItems.forEach { it.touchUp(screenX, screenY, pointer, button) }
handler.subUIs.forEach { it.touchUp(screenX, screenY, pointer, button) }
return true
}
open fun scrolled(amount: Int): Boolean {
uiItems.forEach { it.scrolled(amount) }
handler.subUIs.forEach { it.scrolled(amount) }
return true
}
open fun keyDown(keycode: Int): Boolean {
uiItems.forEach { it.keyDown(keycode) }
handler.subUIs.forEach { it.keyDown(keycode) }
return true
}
open fun keyUp(keycode: Int): Boolean {
uiItems.forEach { it.keyUp(keycode) }
handler.subUIs.forEach { it.keyUp(keycode) }
return true
}
open fun keyTyped(character: Char): Boolean {
@@ -115,85 +153,138 @@ abstract class UICanvas {
this.height = height
}
// handler func aliases //
inline fun setPosition(x: Int, y: Int) {
handler.setPosition(x, y)
}
inline fun setAsAlwaysVisible() {
handler.setAsAlwaysVisible()
}
inline fun setAsOpen() {
handler.setAsOpen()
}
inline fun setAsClose() {
handler.setAsClose()
}
inline fun toggleOpening() {
handler.toggleOpening()
}
inline val isOpened: Boolean
get() = handler.isOpened
inline val isOpening: Boolean
get() = handler.isOpening
inline val isClosing: Boolean
get() = handler.isClosing
inline val isClosed: Boolean
get() = handler.isClosed
inline var opacity: Float
get() = handler.opacity
set(value) { handler.opacity = value }
inline var scale: Float
get() = handler.scale
set(value) { handler.scale = value }
inline val isTakingControl: Boolean
get() = handler.isTakingControl
inline var isVisible: Boolean
get() = handler.isVisible
set(value) { handler.isVisible = value }
// end of handler func aliases
companion object {
const val OPENCLOSE_GENERIC = 0.2f
fun doOpeningFade(handler: UIHandler, openCloseTime: Second) {
handler.opacity = handler.openCloseCounter / openCloseTime
fun doOpeningFade(ui: UICanvas, openCloseTime: Second) {
ui.handler.opacity = ui.handler.openCloseCounter / openCloseTime
}
fun doClosingFade(handler: UIHandler, openCloseTime: Second) {
handler.opacity = (openCloseTime - handler.openCloseCounter) / openCloseTime
fun doClosingFade(ui: UICanvas, openCloseTime: Second) {
ui.handler.opacity = (openCloseTime - ui.handler.openCloseCounter) / openCloseTime
}
fun endOpeningFade(handler: UIHandler) {
handler.opacity = 1f
fun endOpeningFade(ui: UICanvas) {
ui.handler.opacity = 1f
}
fun endClosingFade(handler: UIHandler) {
handler.opacity = 0f
fun endClosingFade(ui: UICanvas) {
ui.handler.opacity = 0f
}
fun doOpeningPopOut(handler: UIHandler, openCloseTime: Second, position: Position) {
fun doOpeningPopOut(ui: UICanvas, openCloseTime: Second, position: Position) {
when (position) {
Position.LEFT -> handler.posX = Movement.fastPullOut(
handler.openCloseCounter / openCloseTime,
-handler.UI.width.toFloat(),
Position.LEFT -> ui.handler.posX = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
-ui.width.toFloat(),
0f
).roundInt()
Position.TOP -> handler.posY = Movement.fastPullOut(
handler.openCloseCounter / openCloseTime,
-handler.UI.height.toFloat(),
Position.TOP -> ui.handler.posY = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
-ui.height.toFloat(),
0f
).roundInt()
Position.RIGHT -> handler.posX = Movement.fastPullOut(
handler.openCloseCounter / openCloseTime,
Position.RIGHT -> ui.handler.posX = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
Terrarum.WIDTH.toFloat(),
Terrarum.WIDTH - handler.UI.width.toFloat()
Terrarum.WIDTH - ui.width.toFloat()
).roundInt()
Position.BOTTOM -> handler.posY = Movement.fastPullOut(
handler.openCloseCounter / openCloseTime,
Position.BOTTOM -> ui.handler.posY = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
Terrarum.HEIGHT.toFloat(),
Terrarum.HEIGHT - handler.UI.height.toFloat()
Terrarum.HEIGHT - ui.height.toFloat()
).roundInt()
}
}
fun doClosingPopOut(handler: UIHandler, openCloseTime: Second, position: Position) {
fun doClosingPopOut(ui: UICanvas, openCloseTime: Second, position: Position) {
when (position) {
Position.LEFT -> handler.posX = Movement.fastPullOut(
handler.openCloseCounter / openCloseTime,
Position.LEFT -> ui.handler.posX = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
0f,
-handler.UI.width.toFloat()
-ui.width.toFloat()
).roundInt()
Position.TOP -> handler.posY = Movement.fastPullOut(
handler.openCloseCounter / openCloseTime,
Position.TOP -> ui.handler.posY = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
0f,
-handler.UI.height.toFloat()
-ui.height.toFloat()
).roundInt()
Position.RIGHT -> handler.posX = Movement.fastPullOut(
handler.openCloseCounter / openCloseTime,
Terrarum.WIDTH - handler.UI.width.toFloat(),
Position.RIGHT -> ui.handler.posX = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
Terrarum.WIDTH - ui.width.toFloat(),
Terrarum.WIDTH.toFloat()
).roundInt()
Position.BOTTOM -> handler.posY = Movement.fastPullOut(
handler.openCloseCounter / openCloseTime,
Terrarum.HEIGHT - handler.UI.height.toFloat(),
Position.BOTTOM -> ui.handler.posY = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
Terrarum.HEIGHT - ui.height.toFloat(),
Terrarum.HEIGHT.toFloat()
).roundInt()
}
}
fun endOpeningPopOut(handler: UIHandler, position: Position) {
fun endOpeningPopOut(ui: UICanvas, position: Position) {
when (position) {
Position.LEFT -> handler.posX = 0
Position.TOP -> handler.posY = 0
Position.RIGHT -> handler.posX = Terrarum.WIDTH - handler.UI.width
Position.BOTTOM -> handler.posY = Terrarum.HEIGHT - handler.UI.height
Position.LEFT -> ui.handler.posX = 0
Position.TOP -> ui.handler.posY = 0
Position.RIGHT -> ui.handler.posX = Terrarum.WIDTH - ui.width
Position.BOTTOM -> ui.handler.posY = Terrarum.HEIGHT - ui.height
}
}
fun endClosingPopOut(handler: UIHandler, position: Position) {
fun endClosingPopOut(ui: UICanvas, position: Position) {
when (position) {
Position.LEFT -> handler.posX = -handler.UI.width
Position.TOP -> handler.posY = -handler.UI.height
Position.RIGHT -> handler.posX = Terrarum.WIDTH
Position.BOTTOM -> handler.posY = Terrarum.HEIGHT
Position.LEFT -> ui.handler.posX = -ui.width
Position.TOP -> ui.handler.posY = -ui.height
Position.RIGHT -> ui.handler.posX = Terrarum.WIDTH
Position.BOTTOM -> ui.handler.posY = Terrarum.HEIGHT
}
}

View File

@@ -17,7 +17,7 @@ import net.torvald.terrarum.round
*
* Created by minjaesong on 15-12-31.
*/
class UIHandler(var UI: UICanvas,
class UIHandler(//var UI: UICanvas,
var toggleKeyLiteral: Int? = null, var toggleButtonLiteral: Int? = null,
// UI positions itself? (you must g.flush() yourself after the g.translate(Int, Int))
var customPositioning: Boolean = false, // mainly used by vital meter
@@ -61,7 +61,7 @@ class UIHandler(var UI: UICanvas,
var openCloseCounter = 0f
init {
UI.handler = this
//UI.handler = this
}
@@ -69,7 +69,23 @@ class UIHandler(var UI: UICanvas,
private val toggleButton: Int?; get() = toggleButtonLiteral // to support in-screen keybind changing
fun update(delta: Float) {
val subUIs = ArrayList<UICanvas>()
fun addSubUI(ui: UICanvas) {
if (subUIs.contains(ui))
throw IllegalArgumentException(
"Exact copy of the UI already exists: The instance of ${ui.javaClass.simpleName}"
)
subUIs.add(ui)
}
fun removeSubUI(ui: UICanvas) {
subUIs.remove(ui)
}
fun update(ui: UICanvas, delta: Float) {
// open/close UI by key pressed
if (toggleKey != null) {
if (KeyToggler.isOn(toggleKey!!)) {
@@ -89,7 +105,7 @@ class UIHandler(var UI: UICanvas,
if (isVisible || alwaysVisible) {
UI.update(delta)
ui.updateUI(delta)
}
if (isOpening) {
@@ -99,12 +115,12 @@ class UIHandler(var UI: UICanvas,
// println("UI ${UI.javaClass.simpleName} (open)")
// println("-> timecounter $openCloseCounter / ${UI.openCloseTime} timetakes")
if (openCloseCounter < UI.openCloseTime) {
UI.doOpening(delta)
if (openCloseCounter < ui.openCloseTime) {
ui.doOpening(delta)
// println("UIHandler.opening ${UI.javaClass.simpleName}")
}
else {
UI.endOpening(delta)
ui.endOpening(delta)
isOpening = false
isClosing = false
isOpened = true
@@ -117,12 +133,12 @@ class UIHandler(var UI: UICanvas,
// println("UI ${UI.javaClass.simpleName} (close)")
// println("-> timecounter $openCloseCounter / ${UI.openCloseTime} timetakes")
if (openCloseCounter < UI.openCloseTime) {
UI.doClosing(delta)
if (openCloseCounter < ui.openCloseTime) {
ui.doClosing(delta)
// println("UIHandler.closing ${UI.javaClass.simpleName}")
}
else {
UI.endClosing(delta)
ui.endClosing(delta)
isClosing = false
isOpening = false
isOpened = false
@@ -130,9 +146,13 @@ class UIHandler(var UI: UICanvas,
openCloseCounter = 0f
}
}
subUIs.forEach { it.update(delta) }
}
fun render(batch: SpriteBatch, camera: Camera) {
fun render(ui: UICanvas, batch: SpriteBatch, camera: Camera) {
if (isVisible || alwaysVisible) {
// camera SHOULD BE CENTERED to HALFX and HALFY (see StateInGame) //
@@ -149,9 +169,13 @@ class UIHandler(var UI: UICanvas,
}
batch.color = Color.WHITE
UI.render(batch)
ui.renderUI(batch, camera)
//ingameGraphics.flush()
}
subUIs.forEach { it.render(batch, camera) }
}
fun setPosition(x: Int, y: Int) {
@@ -219,68 +243,6 @@ class UIHandler(var UI: UICanvas,
}
}
fun keyDown(keycode: Int): Boolean {
if (isVisible) {
return UI.keyDown(keycode)
}
return false
}
fun keyUp(keycode: Int): Boolean {
if (isVisible) {
return UI.keyUp(keycode)
}
return false
}
fun keyTyped(char: Char): Boolean {
if (isVisible) {
return UI.keyTyped(char)
}
return false
}
fun mouseMoved(screenX: Int, screenY: Int) {
if (isVisible) {
UI.mouseMoved(screenX, screenY)
}
}
fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
if (isVisible) {
UI.touchDragged(screenX, screenY, pointer)
}
return false
}
fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (isVisible) {
UI.touchDown(screenX, screenY, pointer, button)
}
return false
}
fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (isVisible) {
UI.touchUp(screenX, screenY, pointer, button)
}
return false
}
fun scrolled(amount: Int): Boolean {
if (isVisible) {
UI.scrolled(amount)
}
return false
}
// constant UI can't take control
val isTakingControl: Boolean
get() {
@@ -290,10 +252,6 @@ class UIHandler(var UI: UICanvas,
return isVisible && !isOpening
}
fun dispose() {
UI.dispose()
}
fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
Ingame.setCameraPosition(batch, camera, newX, newY)
}

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
@@ -23,8 +24,13 @@ class UIInventory(
var actor: Pocketed?,
override var width: Int,
override var height: Int,
var categoryWidth: Int
) : UICanvas() {
var categoryWidth: Int,
toggleKeyLiteral: Int? = null, toggleButtonLiteral: Int? = null,
// UI positions itself? (you must g.flush() yourself after the g.translate(Int, Int))
customPositioning: Boolean = false, // mainly used by vital meter
doNotWarnConstant: Boolean = false
) : UICanvas(toggleKeyLiteral, toggleButtonLiteral, customPositioning, doNotWarnConstant) {
val inventory: ActorInventory?
get() = actor?.inventory
@@ -189,10 +195,7 @@ class UIInventory(
}
override fun update(delta: Float) {
if (handler == null) {
throw Error("Handler for this UI is null, you douchebag.")
}
override fun updateUI(delta: Float) {
catButtons.update(delta)
@@ -223,7 +226,7 @@ class UIInventory(
private val weightBarWidth = 60f
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
// background
blendNormal()
batch.color = backgroundColour
@@ -369,19 +372,19 @@ class UIInventory(
override fun doOpening(delta: Float) {
UICanvas.doOpeningPopOut(handler, openCloseTime, UICanvas.Companion.Position.LEFT)
UICanvas.doOpeningPopOut(this, openCloseTime, UICanvas.Companion.Position.LEFT)
}
override fun doClosing(delta: Float) {
UICanvas.doClosingPopOut(handler, openCloseTime, UICanvas.Companion.Position.LEFT)
UICanvas.doClosingPopOut(this, openCloseTime, UICanvas.Companion.Position.LEFT)
}
override fun endOpening(delta: Float) {
UICanvas.endOpeningPopOut(handler, UICanvas.Companion.Position.LEFT)
UICanvas.endOpeningPopOut(this, UICanvas.Companion.Position.LEFT)
}
override fun endClosing(delta: Float) {
UICanvas.endClosingPopOut(handler, UICanvas.Companion.Position.LEFT)
UICanvas.endClosingPopOut(this, UICanvas.Companion.Position.LEFT)
}
override fun keyDown(keycode: Int): Boolean {

View File

@@ -43,9 +43,9 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI
abstract val height: Int
protected val relativeMouseX: Int
get() = (Terrarum.mouseScreenX - (parentUI.handler?.posX ?: 0) - this.posX)
get() = (Terrarum.mouseScreenX - (parentUI.posX) - this.posX)
protected val relativeMouseY: Int
get() = (Terrarum.mouseScreenY - (parentUI.handler?.posY ?: 0) - this.posY)
get() = (Terrarum.mouseScreenY - (parentUI.posY) - this.posY)
/** If mouse is hovering over it */
open val mouseUp: Boolean
@@ -122,8 +122,6 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI
}
if (clickOnceListener != null && !clickOnceListenerFired && mouseUp) {
println("arstineotarsneio")
clickOnceListener!!.invoke(relativeMouseX, relativeMouseY, button)
actionDone = true
}

View File

@@ -173,6 +173,14 @@ class UIItemTextButtonList(
batch.color = backgroundCol
}
fun select(index: Int) {
selectedIndex = index
}
fun unselect() {
selectedIndex = null
}
override fun dispose() {
iconSpriteSheet?.dispose()
}

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath
@@ -34,7 +35,7 @@ class UIPieMenu : UICanvas() {
var selection: Int = -1
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
if (selection >= 0)
Terrarum.ingame!!.player.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
selection % slotCount
@@ -53,7 +54,7 @@ class UIPieMenu : UICanvas() {
}
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
// draw radial thingies
for (i in 0..slotCount - 1) {
// set position
@@ -98,22 +99,22 @@ class UIPieMenu : UICanvas() {
}
override fun doOpening(delta: Float) {
UICanvas.doOpeningFade(handler, openCloseTime)
UICanvas.doOpeningFade(this, openCloseTime)
handler.scale = smallenSize + (1f.minus(smallenSize) * handler.opacity)
}
override fun doClosing(delta: Float) {
UICanvas.doClosingFade(handler, openCloseTime)
UICanvas.doClosingFade(this, openCloseTime)
handler.scale = smallenSize + (1f.minus(smallenSize) * handler.opacity)
}
override fun endOpening(delta: Float) {
UICanvas.endOpeningFade(handler)
UICanvas.endOpeningFade(this)
handler.scale = 1f
}
override fun endClosing(delta: Float) {
UICanvas.endClosingFade(handler)
UICanvas.endClosingFade(this)
handler.scale = 1f
}

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.Terrarum
@@ -28,10 +29,10 @@ class UIQuickBar : UICanvas() {
get() = Terrarum.ingame!!.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
set(value) { Terrarum.ingame!!.player.actorValue.set(AVKey.__PLAYER_QUICKSLOTSEL, value.fmod(SLOT_COUNT)) }
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
for (i in 0..SLOT_COUNT - 1) {
val image = if (i == selection)

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.ui
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.*
@@ -40,7 +41,7 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas() {
get() = Terrarum.ingame!!.world.time
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
if (ELon) {
ELuptimer += delta
}
@@ -55,7 +56,7 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas() {
}
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
// light overlay or EL
if (ELon) {
blendNormal()

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.gameactors.Second
@@ -29,7 +30,7 @@ class UITitleRemoConCredits(val superMenu: UICanvas) : UICanvas() {
highlightBackCol = Color(0),
backgroundCol = Color(0),
inactiveCol = Color.WHITE,
defaultSelection = null
defaultSelection = 0
)
init {
@@ -38,16 +39,17 @@ class UITitleRemoConCredits(val superMenu: UICanvas) : UICanvas() {
// attach listeners
menubar.buttons[menuLabels.indexOf("MENU_LABEL_RETURN")].clickOnceListener = { _, _, _ ->
superMenu.handler.setAsOpen()
this.handler.setAsClose()
println("UITitleRemoConCredits srtaenirstneiotrsaeinoarst")
superMenu.setAsOpen()
this.setAsClose()
}
}
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
menubar.update(delta)
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
menubar.render(batch)
}

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.Terrarum
@@ -44,22 +45,37 @@ class UITitleRemoConRoot : UICanvas() {
//private val paneCredits = UIHandler()
private val remoConCredits = UIHandler(UITitleRemoConCredits(this))
private val remoConCredits = UITitleRemoConCredits(this)
init {
remoConCredits.setPosition(0, menubarOffY)
addSubUI(remoConCredits)
////////////////////////////
uiItems.add(menubar)
// attach listeners
menubar.buttons[menuLabels.indexOf("MENU_LABEL_CREDITS")].clickOnceListener = { _, _, _ ->
remoConCredits.setAsOpen()
this.setAsClose()
}
menubar.buttons[menuLabels.indexOf("MENU_LABEL_QUIT")].clickOnceListener = { _, _, _ -> System.exit(0) }
}
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
menubar.update(delta)
//println("UITitleRemoConRoot bro u even updatez")
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
menubar.render(batch)
}

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath
@@ -46,7 +47,7 @@ class UIVitalMetre(
return c
}
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
handler.setPosition(
Terrarum.HALFW,
Terrarum.HALFH
@@ -56,7 +57,7 @@ class UIVitalMetre(
/**
* g must be same as World Graphics!
*/
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
// TODO now that we just can't draw arcs, we need to re-think about this
/*if (vitalGetterVal() != null && vitalGetterMax() != null && player != null) {
@@ -99,19 +100,19 @@ class UIVitalMetre(
}
override fun doOpening(delta: Float) {
UICanvas.doOpeningFade(handler, openCloseTime)
UICanvas.doOpeningFade(this, openCloseTime)
}
override fun doClosing(delta: Float) {
UICanvas.doClosingFade(handler, openCloseTime)
UICanvas.doClosingFade(this, openCloseTime)
}
override fun endOpening(delta: Float) {
UICanvas.endOpeningFade(handler)
UICanvas.endOpeningFade(this)
}
override fun endClosing(delta: Float) {
UICanvas.endClosingFade(handler)
UICanvas.endClosingFade(this)
}
override fun dispose() {

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.virtualcomputer.worldobject.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.gameactors.Second
import net.torvald.terrarum.ui.*
@@ -24,11 +25,11 @@ class UITextTerminal(val terminal: Terminal) : UICanvas() {
*/
override var openCloseTime: Second = OPENCLOSE_GENERIC
override fun update(delta: Float) {
override fun updateUI(delta: Float) {
terminal.update(delta)
}
override fun render(batch: SpriteBatch) {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
//terminal.render(gc, terminalDisplay.graphics)
}

View File

@@ -135,6 +135,7 @@ object WeatherMixer {
Terrarum.shaderBayerSkyboxFill.setUniformf("topColor", topCol.r, topCol.g, topCol.b)
Terrarum.shaderBayerSkyboxFill.setUniformf("bottomColor", bottomCol.r, bottomCol.g, bottomCol.b)
Terrarum.shaderBayerSkyboxFill.setUniformf("parallax", parallax)
Terrarum.shaderBayerSkyboxFill.setUniformf("parallax_size", 1f/3f)
Terrarum.fullscreenQuad.render(Terrarum.shaderBayerSkyboxFill, GL20.GL_TRIANGLES)
Terrarum.shaderBayerSkyboxFill.end()
}