diff --git a/assets/4096_bayer.frag b/assets/4096_bayer.frag index 2ba2da362..1669791d2 100644 --- a/assets/4096_bayer.frag +++ b/assets/4096_bayer.frag @@ -11,7 +11,7 @@ uniform float acount = 1.0; -int bayer[8][8] = { +/*int bayer[8][8] = { { 0,32, 8,40, 2,34,10,42}, // 8x8 bayer ordered dithering {48,16,56,24,50,18,58,26}, // pattern. Each input pixel {12,44, 4,36,14,46, 6,38}, // is scaled to the 0..63 range @@ -20,9 +20,25 @@ int bayer[8][8] = { {51,19,59,27,49,17,57,25}, {15,47, 7,39,13,45, 5,37}, {63,31,55,23,61,29,53,21} }; // fun fact: you can calculate bayer value on-the-fly but LUT is faster -float bayerSize = 8.0; -float bayerDivider = bayerSize * bayerSize; +float bayerSize = 8.0;*/ +int bayer[12][12] = { +{0 ,96 ,64 ,8 ,104,72 ,2 ,98 ,66 ,10 ,106,74 }, // 12x12 bayer ordered dithering +{112,80 ,16 ,120,88 ,24 ,114,82 ,18 ,122,90 ,26 }, // pattern. Each input pixel +{48 ,32 ,128,56 ,40 ,136,50 ,34 ,130,58 ,42 ,138}, // is scaled to the 0..143 range +{12 ,108,76 ,4 ,100,68 ,14 ,110,78 ,6 ,102,70 }, // before looking in this table +{124,92 ,28 ,116,84 ,20 ,126,94 ,30 ,118,86 ,22 }, // to determine the action +{60 ,44 ,140,52 ,36 ,132,62 ,46 ,142,54 ,38 ,134}, +{3 ,99 ,67 ,11 ,107,75 ,1 ,97 ,65 ,9 ,105,73 }, +{115,83 ,19 ,123,91 ,27 ,113,81 ,17 ,121,89 ,25 }, +{51 ,35 ,131,59 ,43 ,139,49 ,33 ,129,57 ,41 ,137}, +{15 ,111,79 ,7 ,103,71 ,13 ,109,77 ,5 ,101,69 }, +{127,95 ,31 ,119,87 ,23 ,125,93 ,29 ,117,85 ,21 }, +{63 ,47 ,143,55 ,39 ,135,61 ,45 ,141,53 ,37 ,133}}; +float bayerSize = 12.0; + + +float bayerDivider = bayerSize * bayerSize; vec4 nearestColour(vec4 incolor) { vec4 rgbaCounts = vec4(rcount, gcount, bcount, acount); diff --git a/assets/4096_bayer_skyboxfill.frag b/assets/4096_bayer_skyboxfill.frag index 1603551d5..8e9562dc2 100644 --- a/assets/4096_bayer_skyboxfill.frag +++ b/assets/4096_bayer_skyboxfill.frag @@ -5,26 +5,29 @@ uniform sampler2D u_texture; uniform vec3 topColor; uniform vec3 bottomColor; -uniform float screenHeight; // "steps" of R, G and B. Must be integer && equal or greater than 2 -uniform float rcount = 256.0; // it even works on 256.0! -uniform float gcount = 256.0; -uniform float bcount = 256.0; +uniform float rcount = 64.0; // it even works on 256.0! +uniform float gcount = 64.0; // using 128: has less banding and most monitors are internally 6-bit +uniform float bcount = 64.0; -int bayer[8][8] = { -{ 0,32, 8,40, 2,34,10,42}, // 8x8 bayer ordered dithering -{48,16,56,24,50,18,58,26}, // pattern. Each input pixel -{12,44, 4,36,14,46, 6,38}, // is scaled to the 0..63 range -{60,28,52,20,62,30,54,22}, // before looking in this table -{ 3,35,11,43, 1,33, 9,41}, // to determine the action -{51,19,59,27,49,17,57,25}, -{15,47, 7,39,13,45, 5,37}, -{63,31,55,23,61,29,53,21} }; // fun fact: you can calculate bayer value on-the-fly but LUT is faster -float bayerSize = 8.0; +int bayer[12][12] = { +{0 ,96 ,64 ,8 ,104,72 ,2 ,98 ,66 ,10 ,106,74 }, // 12x12 bayer ordered dithering +{112,80 ,16 ,120,88 ,24 ,114,82 ,18 ,122,90 ,26 }, // pattern. Each input pixel +{48 ,32 ,128,56 ,40 ,136,50 ,34 ,130,58 ,42 ,138}, // is scaled to the 0..143 range +{12 ,108,76 ,4 ,100,68 ,14 ,110,78 ,6 ,102,70 }, // before looking in this table +{124,92 ,28 ,116,84 ,20 ,126,94 ,30 ,118,86 ,22 }, // to determine the action +{60 ,44 ,140,52 ,36 ,132,62 ,46 ,142,54 ,38 ,134}, +{3 ,99 ,67 ,11 ,107,75 ,1 ,97 ,65 ,9 ,105,73 }, +{115,83 ,19 ,123,91 ,27 ,113,81 ,17 ,121,89 ,25 }, +{51 ,35 ,131,59 ,43 ,139,49 ,33 ,129,57 ,41 ,137}, +{15 ,111,79 ,7 ,103,71 ,13 ,109,77 ,5 ,101,69 }, +{127,95 ,31 ,119,87 ,23 ,125,93 ,29 ,117,85 ,21 }, +{63 ,47 ,143,55 ,39 ,135,61 ,45 ,141,53 ,37 ,133}}; // fun fact: you can calculate bayer value on-the-fly but LUT is faster +float bayerSize = 12.0; float bayerDivider = bayerSize * bayerSize; @@ -45,7 +48,7 @@ vec4 nearestColour(vec4 incolor) { void main(void) { float spread = 1.0 / (0.299 * (rcount - 1.0) + 0.587 * (gcount - 1.0) + 0.114 * (bcount - 1.0)); // this spread value is optimised one -- try your own values for various effects! - float scale = v_texCoords.y; // screenHeight; + float scale = v_texCoords.y; float inR = mix(bottomColor.r, topColor.r, scale); float inG = mix(bottomColor.g, topColor.g, scale); float inB = mix(bottomColor.b, topColor.b, scale); diff --git a/src/net/torvald/terrarum/ColorLimiterTest.kt b/src/net/torvald/terrarum/ColorLimiterTest.kt index 44f3c458a..6a891ff46 100644 --- a/src/net/torvald/terrarum/ColorLimiterTest.kt +++ b/src/net/torvald/terrarum/ColorLimiterTest.kt @@ -61,7 +61,7 @@ object ColorLimiterTest : ApplicationAdapter() { } private var timer = 0f - private var timerTick = 0.5f + private var timerTick = 1f private var ditherStart = 2f private var ditherEnd = 16f private var dither = ditherStart diff --git a/src/net/torvald/terrarum/Ingame.kt b/src/net/torvald/terrarum/Ingame.kt index 7f2cc5728..fee27fd4d 100644 --- a/src/net/torvald/terrarum/Ingame.kt +++ b/src/net/torvald/terrarum/Ingame.kt @@ -466,7 +466,7 @@ class Ingame(val batch: SpriteBatch) : Screen { KeyToggler.update() - GameController.processInput(delta) + GameController.update(delta) if (!paused) { @@ -483,12 +483,6 @@ class Ingame(val batch: SpriteBatch) : Screen { world.globalLight = WeatherMixer.globalLightNow - /////////////////////////// - // input-related updates // - /////////////////////////// - uiContainer.forEach { it.processInput(delta) } - - //////////////////////////// // camera-related updates // //////////////////////////// @@ -608,11 +602,14 @@ class Ingame(val batch: SpriteBatch) : Screen { // mix lighpmap canvas to this canvas (Colors -- RGB channel) if (!KeyToggler.isOn(Input.Keys.F6)) { // F6 to disable lightmap draw setCameraPosition(0f, 0f) - batch.shader = null + batch.shader = Terrarum.shaderBayer + batch.shader.setUniformf("rcount", 64f) + batch.shader.setUniformf("gcount", 64f) + batch.shader.setUniformf("bcount", 64f) // de-banding val lightTex = blurWriteBuffer.colorBufferTexture // TODO zoom! - lightTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) + lightTex.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear) if (KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendNormal() else blendMul() @@ -671,14 +668,17 @@ class Ingame(val batch: SpriteBatch) : Screen { // --> blendNormal() <-- introduced by childs of ActorWithBody // - // mix lighpmap canvas to this canvas (UV lights -- A channel) + // mix lighpmap canvas to this canvas (UV lights -- A channel written on RGB as greyscale image) if (!KeyToggler.isOn(Input.Keys.F6)) { // F6 to disable lightmap draw setCameraPosition(0f, 0f) - batch.shader = null + batch.shader = Terrarum.shaderBayer + batch.shader.setUniformf("rcount", 64f) + batch.shader.setUniformf("gcount", 64f) + batch.shader.setUniformf("bcount", 64f) // de-banding val lightTex = blurWriteBuffer.colorBufferTexture // TODO zoom! - lightTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) + lightTex.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear) if (KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendNormal() else blendMul() @@ -702,22 +702,6 @@ class Ingame(val batch: SpriteBatch) : Screen { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) - - // draw skybox - /*WeatherMixer.render(camera) - - - batch.inUse { - batch.color = Color.WHITE - blendNormal() - - Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // reset active textureunit to zero (i don't know tbh, but it won't work without this) - batch.shader = null - }*/ - - - - // draw blended world val worldTex = worldDrawFrameBuffer.colorBufferTexture // WORLD: light_color must be applied beforehand val glowTex = worldGlowFrameBuffer.colorBufferTexture // GLOW: light_uvlight must be applied beforehand @@ -776,7 +760,6 @@ class Ingame(val batch: SpriteBatch) : Screen { val blendedTex = worldBlendFrameBuffer.colorBufferTexture blendedTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) batch.color = Color.WHITE - //batch.shader = Terrarum.shaderBayer batch.shader = null blendNormal() batch.draw(blendedTex, 0f, 0f, blendedTex.width.toFloat(), blendedTex.height.toFloat()) diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 1eacee442..63bc3f538 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -150,10 +150,21 @@ object Terrarum : Game() { private val localeSimple = arrayOf("de", "en", "es", "it") var gameLocale = "lateinit" set(value) { - if (localeSimple.contains(value.substring(0..1))) - field = value.substring(0..1) - else - field = value + if (value.isBlank() || value.isEmpty()) { + field = sysLang + } + else { + try { + if (localeSimple.contains(value.substring(0..1))) + field = value.substring(0..1) + else + field = value + } + catch (e: StringIndexOutOfBoundsException) { + field = value + } + } + fontGame.reload(value) } diff --git a/src/net/torvald/terrarum/UIItemInventoryElem.kt b/src/net/torvald/terrarum/UIItemInventoryElem.kt index ac4301155..b88449000 100644 --- a/src/net/torvald/terrarum/UIItemInventoryElem.kt +++ b/src/net/torvald/terrarum/UIItemInventoryElem.kt @@ -154,19 +154,6 @@ class UIItemInventoryElem( return true } - override fun keyUp(keycode: Int): Boolean { - return false - } - - override fun mouseMoved(screenX: Int, screenY: Int): Boolean { - return false - } - - override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { - return false - } - - override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { if (item != null && Terrarum.ingame != null) { @@ -188,14 +175,6 @@ class UIItemInventoryElem( } - override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - - override fun scrolled(amount: Int): Boolean { - return false - } - override fun dispose() { itemImage?.texture?.dispose() } diff --git a/src/net/torvald/terrarum/gamecontroller/GameController.kt b/src/net/torvald/terrarum/gamecontroller/GameController.kt index 0e238a63e..cc412d705 100644 --- a/src/net/torvald/terrarum/gamecontroller/GameController.kt +++ b/src/net/torvald/terrarum/gamecontroller/GameController.kt @@ -34,7 +34,7 @@ object GameController : InputAdapter() { val mouseTileY: Int get() = (mouseY / FeaturesDrawer.TILE_SIZE).floorInt() - fun processInput(delta: Float) { + fun update(delta: Float) { // actor process input if (!ingame.consoleHandler.isTakingControl) { if (ingame.canPlayerControl) { @@ -50,14 +50,6 @@ object GameController : InputAdapter() { } } } - else { - ingame.uiContainer.forEach { - it.processInput(delta) - } - } - } - else { - ingame.consoleHandler.processInput(delta) } diff --git a/src/net/torvald/terrarum/gameworld/WorldTime.kt b/src/net/torvald/terrarum/gameworld/WorldTime.kt index 2675bb84d..fcb7e1c50 100644 --- a/src/net/torvald/terrarum/gameworld/WorldTime.kt +++ b/src/net/torvald/terrarum/gameworld/WorldTime.kt @@ -144,7 +144,7 @@ class WorldTime(initTime: Long = 0L) { fun update(delta: Float) { //time - realMillisec += delta + realMillisec += delta * 1000.0 if (realMillisec >= 1000.0 / REAL_SEC_TO_GAME_SECS) { realMillisec -= 1000.0 / REAL_SEC_TO_GAME_SECS TIME_T += timeDelta diff --git a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt index 599b3032b..3bb6a8dfb 100644 --- a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt +++ b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt @@ -12,7 +12,7 @@ import net.torvald.terrarum.Terrarum.mouseTileY /** * Created by minjaesong on 16-03-14. */ -class BasicDebugInfoWindow : UICanvas { +class BasicDebugInfoWindow : UICanvas() { override var width: Int = Terrarum.WIDTH override var height: Int = Terrarum.HEIGHT @@ -272,9 +272,6 @@ class BasicDebugInfoWindow : UICanvas { private fun column(i: Int): Float = 300f * (i - 1) - override fun processInput(delta: Float) { - } - override fun doOpening(delta: Float) { } diff --git a/src/net/torvald/terrarum/ui/ConsoleWindow.kt b/src/net/torvald/terrarum/ui/ConsoleWindow.kt index 4ca7f61d0..073867d95 100644 --- a/src/net/torvald/terrarum/ui/ConsoleWindow.kt +++ b/src/net/torvald/terrarum/ui/ConsoleWindow.kt @@ -14,7 +14,7 @@ import net.torvald.terrarum.fillRect /** * Created by minjaesong on 15-12-31. */ -class ConsoleWindow : UICanvas, KeyControlled { +class ConsoleWindow : UICanvas() { internal var UIColour = Color(0x404080_80.toInt()) @@ -210,9 +210,6 @@ class ConsoleWindow : UICanvas, KeyControlled { openingTimeCounter = 0f } - override fun processInput(delta: Float) { - } - override fun dispose() { } } diff --git a/src/net/torvald/terrarum/ui/KeyControlled.kt b/src/net/torvald/terrarum/ui/KeyControlled.kt index da553903d..e69de29bb 100644 --- a/src/net/torvald/terrarum/ui/KeyControlled.kt +++ b/src/net/torvald/terrarum/ui/KeyControlled.kt @@ -1,10 +0,0 @@ -package net.torvald.terrarum.ui - -/** - * Created by minjaesong on 16-03-06. - */ -interface KeyControlled { - fun keyDown(keycode: Int): Boolean - fun keyUp(keycode: Int): Boolean - fun keyTyped(character: Char): Boolean -} \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/MessageWindow.kt b/src/net/torvald/terrarum/ui/MessageWindow.kt index a906c13c4..ba2c7c640 100644 --- a/src/net/torvald/terrarum/ui/MessageWindow.kt +++ b/src/net/torvald/terrarum/ui/MessageWindow.kt @@ -11,7 +11,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack /** * Created by minjaesong on 16-01-27. */ -class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas { +class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas() { private val segment = if (isBlackVariant) SEGMENT_BLACK else SEGMENT_WHITE @@ -51,9 +51,6 @@ class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas } } - override fun processInput(delta: Float) { - } - override fun doOpening(delta: Float) { } diff --git a/src/net/torvald/terrarum/ui/MouseControlled.kt b/src/net/torvald/terrarum/ui/MouseControlled.kt index e04c80ddc..e69de29bb 100644 --- a/src/net/torvald/terrarum/ui/MouseControlled.kt +++ b/src/net/torvald/terrarum/ui/MouseControlled.kt @@ -1,12 +0,0 @@ -package net.torvald.terrarum.ui - -/** - * Created by minjaesong on 16-03-06. - */ -interface MouseControlled { - fun mouseMoved(screenX: Int, screenY: Int): Boolean - fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean - fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean - fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean - fun scrolled(amount: Int): Boolean -} \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/Notification.kt b/src/net/torvald/terrarum/ui/Notification.kt index eb299cb2b..9f9c9d5a2 100644 --- a/src/net/torvald/terrarum/ui/Notification.kt +++ b/src/net/torvald/terrarum/ui/Notification.kt @@ -7,7 +7,7 @@ import net.torvald.terrarum.gameactors.Second /** * Created by minjaesong on 16-01-23. */ -class Notification : UICanvas { +class Notification : UICanvas() { private val SHOWUP_MAX = 15000 @@ -42,9 +42,6 @@ class Notification : UICanvas { msgUI.render(batch) } - override fun processInput(delta: Float) { - } - override fun doOpening(delta: Float) { UICanvas.doOpeningFade(handler, openCloseTime) } diff --git a/src/net/torvald/terrarum/ui/NullUI.kt b/src/net/torvald/terrarum/ui/NullUI.kt index 96883bc72..0f901618e 100644 --- a/src/net/torvald/terrarum/ui/NullUI.kt +++ b/src/net/torvald/terrarum/ui/NullUI.kt @@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch /** * Created by SKYHi14 on 2017-03-13. */ -class NullUI : UICanvas { +class NullUI : UICanvas() { override var width: Int = 0 override var height: Int = 0 override var handler: UIHandler? = null @@ -17,9 +17,6 @@ class NullUI : UICanvas { override fun render(batch: SpriteBatch) { } - override fun processInput(delta: Float) { - } - override fun doOpening(delta: Float) { } diff --git a/src/net/torvald/terrarum/ui/UIBasicNotifier.kt b/src/net/torvald/terrarum/ui/UIBasicNotifier.kt index f7d1554c7..19a917248 100644 --- a/src/net/torvald/terrarum/ui/UIBasicNotifier.kt +++ b/src/net/torvald/terrarum/ui/UIBasicNotifier.kt @@ -14,7 +14,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack /** * Created by minjaesong on 2017-06-10. */ -class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas { +class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas() { override var width = 116 override var height = 24 override var handler: UIHandler? = null @@ -117,9 +117,6 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas { font.draw(batch, getMailStr(), 93f, 5f) } - override fun processInput(delta: Float) { - } - override fun doOpening(delta: Float) { } diff --git a/src/net/torvald/terrarum/ui/UICanvas.kt b/src/net/torvald/terrarum/ui/UICanvas.kt index c72336daa..09ead1279 100644 --- a/src/net/torvald/terrarum/ui/UICanvas.kt +++ b/src/net/torvald/terrarum/ui/UICanvas.kt @@ -10,22 +10,25 @@ import net.torvald.terrarum.gameactors.roundInt /** * Created by minjaesong on 15-12-31. */ -interface UICanvas { +abstract class UICanvas { - var width: Int - var height: Int + abstract var width: Int + abstract var height: Int /** * Usage: (in StateInGame:) uiHandlerField.ui.handler = uiHandlerField */ - var handler: UIHandler? + abstract var handler: UIHandler? /** * In milliseconds * * Timer itself is implemented in the handler. */ - var openCloseTime: Second + abstract var openCloseTime: Second + + + protected val uiItems = ArrayList() val relativeMouseX: Int @@ -41,33 +44,69 @@ interface UICanvas { get() = mouseUp && Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary")) - fun update(delta: Float) + abstract fun update(delta: Float) - fun render(batch: SpriteBatch) - - fun processInput(delta: Float) + abstract fun render(batch: SpriteBatch) /** * Do not modify handler!!.openCloseCounter here. */ - fun doOpening(delta: Float) + abstract fun doOpening(delta: Float) /** * Do not modify handler!!.openCloseCounter here. */ - fun doClosing(delta: Float) + abstract fun doClosing(delta: Float) /** * Do not modify handler!!.openCloseCounter here. */ - fun endOpening(delta: Float) + abstract fun endOpening(delta: Float) /** * Do not modify handler!!.openCloseCounter here. */ - fun endClosing(delta: Float) + abstract fun endClosing(delta: Float) - fun dispose() + abstract fun dispose() + + fun addItem(uiItem: UIItem) { + uiItems.add(uiItem) + } + + open fun mouseMoved(screenX: Int, screenY: Int): Boolean { + uiItems.forEach { it.mouseMoved(screenX, screenY) } + return true + } + open fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + uiItems.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) } + return true + } + open fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + uiItems.forEach { it.touchUp(screenX, screenY, pointer, button) } + return true + } + open fun scrolled(amount: Int): Boolean { + uiItems.forEach { it.scrolled(amount) } + return true + } + + open fun keyDown(keycode: Int): Boolean { + uiItems.forEach { it.keyDown(keycode) } + return true + } + open fun keyUp(keycode: Int): Boolean { + uiItems.forEach { it.keyUp(keycode) } + return true + } + open fun keyTyped(character: Char): Boolean { + return false + //uiItems.forEach { it.keyT } + } companion object { const val OPENCLOSE_GENERIC = 0.2f diff --git a/src/net/torvald/terrarum/ui/UIHandler.kt b/src/net/torvald/terrarum/ui/UIHandler.kt index bb329c5f5..df26b4a9c 100644 --- a/src/net/torvald/terrarum/ui/UIHandler.kt +++ b/src/net/torvald/terrarum/ui/UIHandler.kt @@ -215,69 +215,63 @@ class UIHandler(var UI: UICanvas, } } - fun processInput(delta: Float) { - if (isVisible) { - UI.processInput(delta) - } - } - fun keyDown(keycode: Int): Boolean { - if (isVisible && UI is KeyControlled) { - return (UI as KeyControlled).keyDown(keycode) + if (isVisible) { + return UI.keyDown(keycode) } return false } fun keyUp(keycode: Int): Boolean { - if (isVisible && UI is KeyControlled) { - return (UI as KeyControlled).keyUp(keycode) + if (isVisible) { + return UI.keyUp(keycode) } return false } fun keyTyped(char: Char): Boolean { - if (isVisible && UI is KeyControlled) { - return (UI as KeyControlled).keyTyped(char) + if (isVisible) { + return UI.keyTyped(char) } return false } fun mouseMoved(screenX: Int, screenY: Int) { - if (isVisible && UI is MouseControlled) { - (UI as MouseControlled).mouseMoved(screenX, screenY) + if (isVisible) { + UI.mouseMoved(screenX, screenY) } } fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { - if (isVisible && UI is MouseControlled) { - (UI as MouseControlled).touchDragged(screenX, screenY, pointer) + if (isVisible) { + UI.touchDragged(screenX, screenY, pointer) } return false } fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - if (isVisible && UI is MouseControlled) { - (UI as MouseControlled).touchDown(screenX, screenY, pointer, button) + if (isVisible) { + UI.touchDown(screenX, screenY, pointer, button) } return false } fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - if (isVisible && UI is MouseControlled) { - (UI as MouseControlled).touchUp(screenX, screenY, pointer, button) + if (isVisible) { + UI.touchUp(screenX, screenY, pointer, button) } return false } fun scrolled(amount: Int): Boolean { - if (isVisible && UI is MouseControlled) { - (UI as MouseControlled).scrolled(amount) + if (isVisible) { + UI.scrolled(amount) } return false diff --git a/src/net/torvald/terrarum/ui/UIInventory.kt b/src/net/torvald/terrarum/ui/UIInventory.kt index b1953fd7e..939404a8b 100644 --- a/src/net/torvald/terrarum/ui/UIInventory.kt +++ b/src/net/torvald/terrarum/ui/UIInventory.kt @@ -1,5 +1,7 @@ package net.torvald.terrarum.ui +import com.badlogic.gdx.Gdx +import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.g2d.SpriteBatch import net.torvald.terrarum.* @@ -7,6 +9,7 @@ import net.torvald.terrarum.Terrarum.joypadLabelNinA import net.torvald.terrarum.Terrarum.joypadLabelNinY import net.torvald.terrarum.gameactors.* import net.torvald.terrarum.gameactors.ActorInventory.Companion.CAPACITY_MODE_NO_ENCUMBER +import net.torvald.terrarum.gameworld.fmod import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.itemproperties.ItemCodex import net.torvald.terrarum.langpack.Lang @@ -21,7 +24,7 @@ class UIInventory( override var width: Int, override var height: Int, var categoryWidth: Int -) : UICanvas, MouseControlled, KeyControlled { +) : UICanvas() { val inventory: ActorInventory? get() = actor?.inventory @@ -62,7 +65,7 @@ class UIInventory( val pageButtonRealWidth = pageButtonExtraGap + itemStripGutterH - val catButtons = UIItemTextButtonList( + private val catButtons = UIItemTextButtonList( this, arrayOf( "MENU_LABEL_ALL", @@ -95,7 +98,7 @@ class UIInventory( ) val itemsStripWidth = ((width - catButtons.width) - (2 * itemStripGutterH + itemInterColGutter)) / 2 - pageButtonExtraGap - val items = Array( + private val items = Array( ((height - controlHelpHeight) / (UIItemInventoryElem.height + itemStripGutterV)) * 2, { UIItemInventoryElem( parentUI = this, @@ -112,7 +115,26 @@ class UIInventory( drawBackOnNull = true, inactiveTextCol = defaultTextColour ) }) - val itemsScrollOffset = 0 + + + private val scrollImageButtonAtlas = TextureRegionPack( + Gdx.files.internal("assets/graphics/gui/inventory/page_arrow_button.tga"), + 40, 54 + ) + private val scrollLeftButton = UIItemImageButton(this, + scrollImageButtonAtlas.get(0, 0), + posX = categoryWidth, + posY = (height - controlHelpHeight - scrollImageButtonAtlas.tileH) / 2 + ) + private val scrollRightButton = UIItemImageButton(this, + scrollImageButtonAtlas.get(1, 0), + posX = width - scrollImageButtonAtlas.tileW, + posY = (height - controlHelpHeight - scrollImageButtonAtlas.tileH) / 2 + ) + var itemPage = 0 + var maxItemPage = 1 // TODO total size of current category / items.size + + var inventorySortList = ArrayList() private var rebuildList = true @@ -145,6 +167,27 @@ class UIInventory( private val seekDown: Int; get() = Terrarum.getConfigInt("keydown") // to support in-screen keybind changing + init { + // assign actions to the buttons + scrollLeftButton.clickOnceAction = { mouseX, mouseY, button -> // click once action doesn't work ?! + if (button == Input.Buttons.LEFT) { + println("prevpage") + itemPage = (itemPage - 1) fmod maxItemPage + } + } + scrollRightButton.clickOnceAction = { mouseX, mouseY, button -> + if (button == Input.Buttons.LEFT) { + println("nextpage") + itemPage = (itemPage + 1) fmod maxItemPage + } + } + + + addItem(scrollLeftButton) + addItem(scrollRightButton) + } + + override fun update(delta: Float) { if (handler == null) { throw Error("Handler for this UI is null, you douchebag.") @@ -152,6 +195,9 @@ class UIInventory( catButtons.update(delta) + scrollLeftButton.update(delta) + scrollRightButton.update(delta) + if (actor != null && inventory != null) { // monitor and check if category selection has been changed // OR UI is being opened from closed state @@ -186,6 +232,9 @@ class UIInventory( catButtons.render(batch) + // left/right page mover + scrollLeftButton.render(batch) + scrollRightButton.render(batch) items.forEach { it.render(batch) @@ -265,7 +314,7 @@ class UIInventory( for (k in 0..items.size - 1) { // we have an item try { - val sortListItem = inventorySortList[k + itemsScrollOffset] + val sortListItem = inventorySortList[k + itemPage * items.size] items[k].item = sortListItem.item items[k].amount = sortListItem.amount items[k].itemImage = ItemCodex.getItemImage(sortListItem.item) @@ -308,8 +357,6 @@ class UIInventory( // Inputs // //////////// - override fun processInput(delta: Float) { - } override fun doOpening(delta: Float) { UICanvas.doOpeningPopOut(handler, openCloseTime, UICanvas.Companion.Position.LEFT) @@ -317,7 +364,6 @@ class UIInventory( override fun doClosing(delta: Float) { UICanvas.doClosingPopOut(handler, openCloseTime, UICanvas.Companion.Position.LEFT) - } override fun endOpening(delta: Float) { @@ -328,11 +374,9 @@ class UIInventory( UICanvas.endClosingPopOut(handler, UICanvas.Companion.Position.LEFT) } - override fun mouseMoved(screenX: Int, screenY: Int): Boolean { - return false - } - override fun keyDown(keycode: Int): Boolean { + super.keyDown(keycode) + items.forEach { if (it.mouseUp) it.keyDown(keycode) } shutUpAndRebuild() @@ -340,21 +384,17 @@ class UIInventory( } override fun keyUp(keycode: Int): Boolean { + super.keyUp(keycode) + items.forEach { if (it.mouseUp) it.keyUp(keycode) } shutUpAndRebuild() return true } - override fun keyTyped(character: Char): Boolean { - return false - } - - override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { - return false - } - override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + super.touchDown(screenX, screenY, pointer, button) + items.forEach { if (it.mouseUp) it.touchDown(screenX, screenY, pointer, button) } return true @@ -366,12 +406,9 @@ class UIInventory( return true } - override fun scrolled(amount: Int): Boolean { - return false - } - override fun dispose() { catButtons.dispose() items.forEach { it.dispose() } + scrollImageButtonAtlas.dispose() } } diff --git a/src/net/torvald/terrarum/ui/UIItem.kt b/src/net/torvald/terrarum/ui/UIItem.kt index b97f92806..03c87cff1 100644 --- a/src/net/torvald/terrarum/ui/UIItem.kt +++ b/src/net/torvald/terrarum/ui/UIItem.kt @@ -28,19 +28,99 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI open val mousePushed: Boolean get() = mouseUp && Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary")!!) - abstract fun update(delta: Float) + + + // kind of listener implementation + var updateAction: ((Float) -> Unit)? = null + var keyDownAction: ((Int) -> Unit)? = null + var keyUpAction: ((Int) -> Unit)? = null + var mouseMovedAction: ((Int, Int) -> Unit)? = null + var touchDraggedAction: ((Int, Int, Int) -> Unit)? = null + var touchDownAction: ((Int, Int, Int, Int) -> Unit)? = null + var touchUpAction: ((Int, Int, Int, Int) -> Unit)? = null + var scrolledAction: ((Int) -> Unit)? = null + + var clickOnceAction: ((Int, Int, Int) -> Unit)? = null + var clickOnceActionEngaged = false + + + + open fun update(delta: Float) { + if (updateAction != null) { + updateAction!!.invoke(delta) + } + } abstract fun render(batch: SpriteBatch) // keyboard controlled - abstract fun keyDown(keycode: Int): Boolean - abstract fun keyUp(keycode: Int): Boolean + open fun keyDown(keycode: Int): Boolean { + if (keyDownAction != null) { + keyDownAction!!.invoke(keycode) + return true + } + + return false + } + open fun keyUp(keycode: Int): Boolean { + if (keyUpAction != null) { + keyUpAction!!.invoke(keycode) + return true + } + + return false + } // mouse controlled - abstract fun mouseMoved(screenX: Int, screenY: Int): Boolean - abstract fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean - abstract fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean - abstract fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean - abstract fun scrolled(amount: Int): Boolean + open fun mouseMoved(screenX: Int, screenY: Int): Boolean { + if (mouseMovedAction != null) { + mouseMovedAction!!.invoke(relativeMouseX, relativeMouseY) + return true + } + + return false + } + open fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + if (touchDraggedAction != null) { + touchDraggedAction!!.invoke(relativeMouseX, relativeMouseY, pointer) + return true + } + + return false + } + open fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + var actionDone = false + + if (touchDownAction != null) { + touchDownAction!!.invoke(relativeMouseX, relativeMouseY, pointer, button) + actionDone = true + } + + if (!clickOnceActionEngaged && mouseUp) { + clickOnceAction!!.invoke(relativeMouseX, relativeMouseY, button) + actionDone = true + } + + return actionDone + } + open fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + clickOnceActionEngaged = false + + if (touchUpAction != null) { + touchUpAction!!.invoke(relativeMouseX, relativeMouseY, pointer, button) + return true + } + + return false + } + open fun scrolled(amount: Int): Boolean { + if (scrolledAction != null) { + scrolledAction!!.invoke(amount) + return true + } + + return false + } + abstract fun dispose() } diff --git a/src/net/torvald/terrarum/ui/UIItemImageButton.kt b/src/net/torvald/terrarum/ui/UIItemImageButton.kt index e9fc31cf0..3aa9f40d9 100644 --- a/src/net/torvald/terrarum/ui/UIItemImageButton.kt +++ b/src/net/torvald/terrarum/ui/UIItemImageButton.kt @@ -10,7 +10,7 @@ import net.torvald.terrarum.fillRect /** * Created by minjaesong on 2017-07-16. */ -class UIItemImageButton( +open class UIItemImageButton( parent: UICanvas, val image: TextureRegion, @@ -18,20 +18,19 @@ class UIItemImageButton( val buttonBackCol: Color = Color(0), val buttonBackBlendMode: String = BlendMode.NORMAL, - val activeCol: Color = Color(0x00f8ff_ff), + val activeCol: Color = Color(0xfff066_ff.toInt()), val activeBackCol: Color = Color(0xb0b0b0_ff.toInt()), val activeBackBlendMode: String = BlendMode.MULTIPLY, override var posX: Int, override var posY: Int, - override val width: Int, - override val height: Int + override val width: Int = image.regionWidth, + override val height: Int = image.regionHeight ) : UIItem(parent) { - override fun update(delta: Float) { - } override fun render(batch: SpriteBatch) { + // draw background if (mouseUp) { BlendMode.resolve(activeBackBlendMode) batch.color = activeBackCol @@ -43,41 +42,15 @@ class UIItemImageButton( batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat()) + + // draw image blendNormal() batch.color = if (mouseUp) activeCol else buttonCol - batch.draw(image, (posX - (image.regionWidth / 2)).toFloat(), (posY - (image.regionHeight / 2)).toFloat()) + batch.draw(image, (posX + (width - image.regionWidth) / 2).toFloat(), (posY + (height - image.regionHeight) / 2).toFloat()) } override fun dispose() { image.texture.dispose() } - - override fun keyDown(keycode: Int): Boolean { - return false - } - - override fun keyUp(keycode: Int): Boolean { - return false - } - - override fun mouseMoved(screenX: Int, screenY: Int): Boolean { - return false - } - - override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { - return false - } - - override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - - override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - - override fun scrolled(amount: Int): Boolean { - return false - } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/UIItemTextButton.kt b/src/net/torvald/terrarum/ui/UIItemTextButton.kt index 657d3b9bf..1fef61403 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButton.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButton.kt @@ -11,7 +11,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch * * Created by SKYHi14 on 2017-03-13. */ -class UIItemTextButton( +open class UIItemTextButton( parentUI: UICanvas, val labelText: String, override var posX: Int, @@ -44,9 +44,6 @@ class UIItemTextButton( var highlighted: Boolean = false - override fun update(delta: Float) { - } - private val glyphLayout = GlyphLayout() override fun render(batch: SpriteBatch) { @@ -78,34 +75,6 @@ class UIItemTextButton( ) } - override fun keyDown(keycode: Int): Boolean { - return false - } - - override fun keyUp(keycode: Int): Boolean { - return false - } - - override fun mouseMoved(screenX: Int, screenY: Int): Boolean { - return false - } - - override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { - return false - } - - override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - - override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - - override fun scrolled(amount: Int): Boolean { - return false - } - override fun dispose() { } } diff --git a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt index 19e14b32d..3b2913e8a 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt @@ -167,34 +167,6 @@ class UIItemTextButtonList( batch.color = backgroundCol } - override fun keyDown(keycode: Int): Boolean { - return false - } - - override fun keyUp(keycode: Int): Boolean { - return false - } - - override fun mouseMoved(screenX: Int, screenY: Int): Boolean { - return false - } - - override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { - return false - } - - override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - - override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - - override fun scrolled(amount: Int): Boolean { - return false - } - override fun dispose() { iconSpriteSheet?.dispose() } diff --git a/src/net/torvald/terrarum/ui/UIPieMenu.kt b/src/net/torvald/terrarum/ui/UIPieMenu.kt index 68afcf195..3230f10e0 100644 --- a/src/net/torvald/terrarum/ui/UIPieMenu.kt +++ b/src/net/torvald/terrarum/ui/UIPieMenu.kt @@ -13,7 +13,7 @@ import org.dyn4j.geometry.Vector2 /** * Created by minjaesong on 16-07-20. */ -class UIPieMenu : UICanvas { +class UIPieMenu : UICanvas() { private val cellSize = UIQuickBar.CELL_SIZE private val slotCount = UIQuickBar.SLOT_COUNT @@ -40,6 +40,19 @@ class UIPieMenu : UICanvas { Terrarum.ingame!!.player!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] = selection % slotCount } + + + // update controls + if (handler!!.isOpened || handler!!.isOpening) { + val cursorPos = Vector2(Terrarum.mouseX, Terrarum.mouseY) + val centre = Vector2(Terrarum.HALFW.toDouble(), Terrarum.HALFH.toDouble()) + val deg = -(centre - cursorPos).direction.toFloat() + + selection = Math.round(deg * slotCount / FastMath.TWO_PI) + if (selection < 0) selection += 10 + + // TODO add gamepad support + } } override fun render(batch: SpriteBatch) { @@ -86,19 +99,6 @@ class UIPieMenu : UICanvas { } } - override fun processInput(delta: Float) { - if (handler!!.isOpened || handler!!.isOpening) { - val cursorPos = Vector2(Terrarum.mouseX, Terrarum.mouseY) - val centre = Vector2(Terrarum.HALFW.toDouble(), Terrarum.HALFH.toDouble()) - val deg = -(centre - cursorPos).direction.toFloat() - - selection = Math.round(deg * slotCount / FastMath.TWO_PI) - if (selection < 0) selection += 10 - - // TODO add gamepad support - } - } - override fun doOpening(delta: Float) { UICanvas.doOpeningFade(handler, openCloseTime) handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity) diff --git a/src/net/torvald/terrarum/ui/UIQuickBar.kt b/src/net/torvald/terrarum/ui/UIQuickBar.kt index 54956d598..d83a4eff5 100644 --- a/src/net/torvald/terrarum/ui/UIQuickBar.kt +++ b/src/net/torvald/terrarum/ui/UIQuickBar.kt @@ -11,7 +11,7 @@ import net.torvald.terrarum.itemproperties.ItemCodex /** * Created by minjaesong on 16-07-20. */ -class UIQuickBar : UICanvas, MouseControlled { +class UIQuickBar : UICanvas() { private val gutter = 8 override var width: Int = (ItemSlotImageBuilder.slotImage.width + gutter) * SLOT_COUNT override var height: Int = ItemSlotImageBuilder.slotImage.height + 4 + Terrarum.fontGame.lineHeight.toInt() @@ -71,9 +71,6 @@ class UIQuickBar : UICanvas, MouseControlled { } - override fun processInput(delta: Float) { - } - override fun doOpening(delta: Float) { handler!!.opacity = handler!!.openCloseCounter.toFloat() / openCloseTime } @@ -90,23 +87,9 @@ class UIQuickBar : UICanvas, MouseControlled { handler!!.opacity = 0f } - override fun mouseMoved(screenX: Int, screenY: Int): Boolean { - return false - } - - override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { - return false - } - - override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - - override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - override fun scrolled(amount: Int): Boolean { + super.scrolled(amount) + selection = selection.plus(if (amount > 1) 1 else if (amount < -1) -1 else 0).fmod(SLOT_COUNT) return true diff --git a/src/net/torvald/terrarum/ui/UITierOneWatch.kt b/src/net/torvald/terrarum/ui/UITierOneWatch.kt index 239dc8e15..91feb1faa 100644 --- a/src/net/torvald/terrarum/ui/UITierOneWatch.kt +++ b/src/net/torvald/terrarum/ui/UITierOneWatch.kt @@ -17,7 +17,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack /** * Created by minjaesong on 2017-06-11. */ -class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas { +class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas() { override var width = 85 override var height = 52 override var handler: UIHandler? = null @@ -107,9 +107,6 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas { batch.draw(moonDial.get(moonPhase, 0), 4f, 22f) } - override fun processInput(delta: Float) { - } - override fun doOpening(delta: Float) { } diff --git a/src/net/torvald/terrarum/ui/UIVitalMetre.kt b/src/net/torvald/terrarum/ui/UIVitalMetre.kt index 6fa5e2220..10aacfd10 100644 --- a/src/net/torvald/terrarum/ui/UIVitalMetre.kt +++ b/src/net/torvald/terrarum/ui/UIVitalMetre.kt @@ -17,7 +17,7 @@ class UIVitalMetre( var vitalGetterMax: () -> Float?, var color: Color?, val order: Int -) : UICanvas { +) : UICanvas() { init { // semitransparent @@ -105,9 +105,6 @@ class UIVitalMetre( }*/ } - override fun processInput(delta: Float) { - } - override fun doOpening(delta: Float) { UICanvas.doOpeningFade(handler, openCloseTime) } diff --git a/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt b/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt index 061ac6067..93de13950 100644 --- a/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt +++ b/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt @@ -9,39 +9,8 @@ import net.torvald.terrarum.virtualcomputer.terminal.Terminal /** * Created by minjaesong on 16-09-08. */ -class UITextTerminal(val terminal: Terminal) : UICanvas, KeyControlled, MouseControlled { +class UITextTerminal(val terminal: Terminal) : UICanvas() { - override fun keyDown(keycode: Int): Boolean { - return false - } - - override fun mouseMoved(screenX: Int, screenY: Int): Boolean { - return false - } - - override fun keyUp(keycode: Int): Boolean { - return false - } - - override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { - return false - } - - override fun keyTyped(character: Char): Boolean { - return false - } - - override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - - override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - return false - } - - override fun scrolled(amount: Int): Boolean { - return false - } override var width: Int = terminal.displayW// + some override var height: Int = terminal.displayH// + frame @@ -68,9 +37,6 @@ class UITextTerminal(val terminal: Terminal) : UICanvas, KeyControlled, MouseCon //terminal.render(gc, terminalDisplay.graphics) } - override fun processInput(delta: Float) { - } - /** * Do not modify handler!!.openCloseCounter here. */ diff --git a/src/net/torvald/terrarum/weather/WeatherMixer.kt b/src/net/torvald/terrarum/weather/WeatherMixer.kt index 45d884fcf..63e079f9a 100644 --- a/src/net/torvald/terrarum/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/weather/WeatherMixer.kt @@ -106,13 +106,12 @@ object WeatherMixer { val topCol = getGradientColour(skyboxColourMap, 0, timeNow) val bottomCol = getGradientColour(skyboxColourMap, 1, timeNow) - Terrarum.textureWhiteSquare.bind(0) + //Terrarum.textureWhiteSquare.bind(0) Terrarum.shaderBayerSkyboxFill.begin() Terrarum.shaderBayerSkyboxFill.setUniformMatrix("u_projTrans", camera.combined) Terrarum.shaderBayerSkyboxFill.setUniformf("topColor", topCol.r, topCol.g, topCol.b) Terrarum.shaderBayerSkyboxFill.setUniformf("bottomColor", bottomCol.r, bottomCol.g, bottomCol.b) - Terrarum.shaderBayerSkyboxFill.setUniformf("screenHeight", Terrarum.HEIGHT.toFloat()) Terrarum.ingame!!.fullscreenQuad.render(Terrarum.shaderBayerSkyboxFill, GL20.GL_TRIANGLES) Terrarum.shaderBayerSkyboxFill.end() }