mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 01:54:04 +09:00
simplified a structure of UIs a bit
This commit is contained in:
@@ -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
|
{ 0,32, 8,40, 2,34,10,42}, // 8x8 bayer ordered dithering
|
||||||
{48,16,56,24,50,18,58,26}, // pattern. Each input pixel
|
{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
|
{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},
|
{51,19,59,27,49,17,57,25},
|
||||||
{15,47, 7,39,13,45, 5,37},
|
{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
|
{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 bayerSize = 8.0;*/
|
||||||
float bayerDivider = bayerSize * bayerSize;
|
|
||||||
|
|
||||||
|
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 nearestColour(vec4 incolor) {
|
||||||
vec4 rgbaCounts = vec4(rcount, gcount, bcount, acount);
|
vec4 rgbaCounts = vec4(rcount, gcount, bcount, acount);
|
||||||
|
|||||||
@@ -5,26 +5,29 @@ uniform sampler2D u_texture;
|
|||||||
|
|
||||||
uniform vec3 topColor;
|
uniform vec3 topColor;
|
||||||
uniform vec3 bottomColor;
|
uniform vec3 bottomColor;
|
||||||
uniform float screenHeight;
|
|
||||||
|
|
||||||
|
|
||||||
// "steps" of R, G and B. Must be integer && equal or greater than 2
|
// "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 rcount = 64.0; // it even works on 256.0!
|
||||||
uniform float gcount = 256.0;
|
uniform float gcount = 64.0; // using 128: has less banding and most monitors are internally 6-bit
|
||||||
uniform float bcount = 256.0;
|
uniform float bcount = 64.0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int bayer[8][8] = {
|
int bayer[12][12] = {
|
||||||
{ 0,32, 8,40, 2,34,10,42}, // 8x8 bayer ordered dithering
|
{0 ,96 ,64 ,8 ,104,72 ,2 ,98 ,66 ,10 ,106,74 }, // 12x12 bayer ordered dithering
|
||||||
{48,16,56,24,50,18,58,26}, // pattern. Each input pixel
|
{112,80 ,16 ,120,88 ,24 ,114,82 ,18 ,122,90 ,26 }, // pattern. Each input pixel
|
||||||
{12,44, 4,36,14,46, 6,38}, // is scaled to the 0..63 range
|
{48 ,32 ,128,56 ,40 ,136,50 ,34 ,130,58 ,42 ,138}, // is scaled to the 0..143 range
|
||||||
{60,28,52,20,62,30,54,22}, // before looking in this table
|
{12 ,108,76 ,4 ,100,68 ,14 ,110,78 ,6 ,102,70 }, // before looking in this table
|
||||||
{ 3,35,11,43, 1,33, 9,41}, // to determine the action
|
{124,92 ,28 ,116,84 ,20 ,126,94 ,30 ,118,86 ,22 }, // to determine the action
|
||||||
{51,19,59,27,49,17,57,25},
|
{60 ,44 ,140,52 ,36 ,132,62 ,46 ,142,54 ,38 ,134},
|
||||||
{15,47, 7,39,13,45, 5,37},
|
{3 ,99 ,67 ,11 ,107,75 ,1 ,97 ,65 ,9 ,105,73 },
|
||||||
{63,31,55,23,61,29,53,21} }; // fun fact: you can calculate bayer value on-the-fly but LUT is faster
|
{115,83 ,19 ,123,91 ,27 ,113,81 ,17 ,121,89 ,25 },
|
||||||
float bayerSize = 8.0;
|
{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;
|
float bayerDivider = bayerSize * bayerSize;
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +48,7 @@ vec4 nearestColour(vec4 incolor) {
|
|||||||
void main(void) {
|
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 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 inR = mix(bottomColor.r, topColor.r, scale);
|
||||||
float inG = mix(bottomColor.g, topColor.g, scale);
|
float inG = mix(bottomColor.g, topColor.g, scale);
|
||||||
float inB = mix(bottomColor.b, topColor.b, scale);
|
float inB = mix(bottomColor.b, topColor.b, scale);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ object ColorLimiterTest : ApplicationAdapter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var timer = 0f
|
private var timer = 0f
|
||||||
private var timerTick = 0.5f
|
private var timerTick = 1f
|
||||||
private var ditherStart = 2f
|
private var ditherStart = 2f
|
||||||
private var ditherEnd = 16f
|
private var ditherEnd = 16f
|
||||||
private var dither = ditherStart
|
private var dither = ditherStart
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
|
|
||||||
|
|
||||||
KeyToggler.update()
|
KeyToggler.update()
|
||||||
GameController.processInput(delta)
|
GameController.update(delta)
|
||||||
|
|
||||||
|
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
@@ -483,12 +483,6 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
world.globalLight = WeatherMixer.globalLightNow
|
world.globalLight = WeatherMixer.globalLightNow
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////
|
|
||||||
// input-related updates //
|
|
||||||
///////////////////////////
|
|
||||||
uiContainer.forEach { it.processInput(delta) }
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// camera-related updates //
|
// camera-related updates //
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
@@ -608,11 +602,14 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
// mix lighpmap canvas to this canvas (Colors -- RGB channel)
|
// mix lighpmap canvas to this canvas (Colors -- RGB channel)
|
||||||
if (!KeyToggler.isOn(Input.Keys.F6)) { // F6 to disable lightmap draw
|
if (!KeyToggler.isOn(Input.Keys.F6)) { // F6 to disable lightmap draw
|
||||||
setCameraPosition(0f, 0f)
|
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!
|
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()
|
if (KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendNormal()
|
||||||
else blendMul()
|
else blendMul()
|
||||||
@@ -671,14 +668,17 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
// --> blendNormal() <-- introduced by childs of ActorWithBody //
|
// --> 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
|
if (!KeyToggler.isOn(Input.Keys.F6)) { // F6 to disable lightmap draw
|
||||||
setCameraPosition(0f, 0f)
|
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!
|
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()
|
if (KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendNormal()
|
||||||
else blendMul()
|
else blendMul()
|
||||||
@@ -702,22 +702,6 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
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
|
// draw blended world
|
||||||
val worldTex = worldDrawFrameBuffer.colorBufferTexture // WORLD: light_color must be applied beforehand
|
val worldTex = worldDrawFrameBuffer.colorBufferTexture // WORLD: light_color must be applied beforehand
|
||||||
val glowTex = worldGlowFrameBuffer.colorBufferTexture // GLOW: light_uvlight 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
|
val blendedTex = worldBlendFrameBuffer.colorBufferTexture
|
||||||
blendedTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest)
|
blendedTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest)
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
//batch.shader = Terrarum.shaderBayer
|
|
||||||
batch.shader = null
|
batch.shader = null
|
||||||
blendNormal()
|
blendNormal()
|
||||||
batch.draw(blendedTex, 0f, 0f, blendedTex.width.toFloat(), blendedTex.height.toFloat())
|
batch.draw(blendedTex, 0f, 0f, blendedTex.width.toFloat(), blendedTex.height.toFloat())
|
||||||
|
|||||||
@@ -150,10 +150,21 @@ object Terrarum : Game() {
|
|||||||
private val localeSimple = arrayOf("de", "en", "es", "it")
|
private val localeSimple = arrayOf("de", "en", "es", "it")
|
||||||
var gameLocale = "lateinit"
|
var gameLocale = "lateinit"
|
||||||
set(value) {
|
set(value) {
|
||||||
if (localeSimple.contains(value.substring(0..1)))
|
if (value.isBlank() || value.isEmpty()) {
|
||||||
field = value.substring(0..1)
|
field = sysLang
|
||||||
else
|
}
|
||||||
field = value
|
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)
|
fontGame.reload(value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,19 +154,6 @@ class UIItemInventoryElem(
|
|||||||
return true
|
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 {
|
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
if (item != null && Terrarum.ingame != null) {
|
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() {
|
override fun dispose() {
|
||||||
itemImage?.texture?.dispose()
|
itemImage?.texture?.dispose()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ object GameController : InputAdapter() {
|
|||||||
val mouseTileY: Int
|
val mouseTileY: Int
|
||||||
get() = (mouseY / FeaturesDrawer.TILE_SIZE).floorInt()
|
get() = (mouseY / FeaturesDrawer.TILE_SIZE).floorInt()
|
||||||
|
|
||||||
fun processInput(delta: Float) {
|
fun update(delta: Float) {
|
||||||
// actor process input
|
// actor process input
|
||||||
if (!ingame.consoleHandler.isTakingControl) {
|
if (!ingame.consoleHandler.isTakingControl) {
|
||||||
if (ingame.canPlayerControl) {
|
if (ingame.canPlayerControl) {
|
||||||
@@ -50,14 +50,6 @@ object GameController : InputAdapter() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
ingame.uiContainer.forEach {
|
|
||||||
it.processInput(delta)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ingame.consoleHandler.processInput(delta)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class WorldTime(initTime: Long = 0L) {
|
|||||||
|
|
||||||
fun update(delta: Float) {
|
fun update(delta: Float) {
|
||||||
//time
|
//time
|
||||||
realMillisec += delta
|
realMillisec += delta * 1000.0
|
||||||
if (realMillisec >= 1000.0 / REAL_SEC_TO_GAME_SECS) {
|
if (realMillisec >= 1000.0 / REAL_SEC_TO_GAME_SECS) {
|
||||||
realMillisec -= 1000.0 / REAL_SEC_TO_GAME_SECS
|
realMillisec -= 1000.0 / REAL_SEC_TO_GAME_SECS
|
||||||
TIME_T += timeDelta
|
TIME_T += timeDelta
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import net.torvald.terrarum.Terrarum.mouseTileY
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-03-14.
|
* Created by minjaesong on 16-03-14.
|
||||||
*/
|
*/
|
||||||
class BasicDebugInfoWindow : UICanvas {
|
class BasicDebugInfoWindow : UICanvas() {
|
||||||
|
|
||||||
override var width: Int = Terrarum.WIDTH
|
override var width: Int = Terrarum.WIDTH
|
||||||
override var height: Int = Terrarum.HEIGHT
|
override var height: Int = Terrarum.HEIGHT
|
||||||
@@ -272,9 +272,6 @@ class BasicDebugInfoWindow : UICanvas {
|
|||||||
|
|
||||||
private fun column(i: Int): Float = 300f * (i - 1)
|
private fun column(i: Int): Float = 300f * (i - 1)
|
||||||
|
|
||||||
override fun processInput(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import net.torvald.terrarum.fillRect
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 15-12-31.
|
* Created by minjaesong on 15-12-31.
|
||||||
*/
|
*/
|
||||||
class ConsoleWindow : UICanvas, KeyControlled {
|
class ConsoleWindow : UICanvas() {
|
||||||
|
|
||||||
internal var UIColour = Color(0x404080_80.toInt())
|
internal var UIColour = Color(0x404080_80.toInt())
|
||||||
|
|
||||||
@@ -210,9 +210,6 @@ class ConsoleWindow : UICanvas, KeyControlled {
|
|||||||
openingTimeCounter = 0f
|
openingTimeCounter = 0f
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processInput(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-01-27.
|
* 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
|
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) {
|
override fun doOpening(delta: Float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,7 @@ import net.torvald.terrarum.gameactors.Second
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-01-23.
|
* Created by minjaesong on 16-01-23.
|
||||||
*/
|
*/
|
||||||
class Notification : UICanvas {
|
class Notification : UICanvas() {
|
||||||
|
|
||||||
private val SHOWUP_MAX = 15000
|
private val SHOWUP_MAX = 15000
|
||||||
|
|
||||||
@@ -42,9 +42,6 @@ class Notification : UICanvas {
|
|||||||
msgUI.render(batch)
|
msgUI.render(batch)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processInput(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
UICanvas.doOpeningFade(handler, openCloseTime)
|
UICanvas.doOpeningFade(handler, openCloseTime)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|||||||
/**
|
/**
|
||||||
* Created by SKYHi14 on 2017-03-13.
|
* Created by SKYHi14 on 2017-03-13.
|
||||||
*/
|
*/
|
||||||
class NullUI : UICanvas {
|
class NullUI : UICanvas() {
|
||||||
override var width: Int = 0
|
override var width: Int = 0
|
||||||
override var height: Int = 0
|
override var height: Int = 0
|
||||||
override var handler: UIHandler? = null
|
override var handler: UIHandler? = null
|
||||||
@@ -17,9 +17,6 @@ class NullUI : UICanvas {
|
|||||||
override fun render(batch: SpriteBatch) {
|
override fun render(batch: SpriteBatch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processInput(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-06-10.
|
* 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 width = 116
|
||||||
override var height = 24
|
override var height = 24
|
||||||
override var handler: UIHandler? = null
|
override var handler: UIHandler? = null
|
||||||
@@ -117,9 +117,6 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas {
|
|||||||
font.draw(batch, getMailStr(), 93f, 5f)
|
font.draw(batch, getMailStr(), 93f, 5f)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processInput(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,22 +10,25 @@ import net.torvald.terrarum.gameactors.roundInt
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 15-12-31.
|
* Created by minjaesong on 15-12-31.
|
||||||
*/
|
*/
|
||||||
interface UICanvas {
|
abstract class UICanvas {
|
||||||
|
|
||||||
var width: Int
|
abstract var width: Int
|
||||||
var height: Int
|
abstract var height: Int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage: (in StateInGame:) uiHandlerField.ui.handler = uiHandlerField
|
* Usage: (in StateInGame:) uiHandlerField.ui.handler = uiHandlerField
|
||||||
*/
|
*/
|
||||||
var handler: UIHandler?
|
abstract var handler: UIHandler?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In milliseconds
|
* In milliseconds
|
||||||
*
|
*
|
||||||
* Timer itself is implemented in the handler.
|
* Timer itself is implemented in the handler.
|
||||||
*/
|
*/
|
||||||
var openCloseTime: Second
|
abstract var openCloseTime: Second
|
||||||
|
|
||||||
|
|
||||||
|
protected val uiItems = ArrayList<UIItem>()
|
||||||
|
|
||||||
|
|
||||||
val relativeMouseX: Int
|
val relativeMouseX: Int
|
||||||
@@ -41,33 +44,69 @@ interface UICanvas {
|
|||||||
get() = mouseUp && Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary"))
|
get() = mouseUp && Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary"))
|
||||||
|
|
||||||
|
|
||||||
fun update(delta: Float)
|
abstract fun update(delta: Float)
|
||||||
|
|
||||||
fun render(batch: SpriteBatch)
|
abstract fun render(batch: SpriteBatch)
|
||||||
|
|
||||||
fun processInput(delta: Float)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not modify handler!!.openCloseCounter here.
|
* Do not modify handler!!.openCloseCounter here.
|
||||||
*/
|
*/
|
||||||
fun doOpening(delta: Float)
|
abstract fun doOpening(delta: Float)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not modify handler!!.openCloseCounter here.
|
* Do not modify handler!!.openCloseCounter here.
|
||||||
*/
|
*/
|
||||||
fun doClosing(delta: Float)
|
abstract fun doClosing(delta: Float)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not modify handler!!.openCloseCounter here.
|
* Do not modify handler!!.openCloseCounter here.
|
||||||
*/
|
*/
|
||||||
fun endOpening(delta: Float)
|
abstract fun endOpening(delta: Float)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not modify handler!!.openCloseCounter here.
|
* 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 {
|
companion object {
|
||||||
const val OPENCLOSE_GENERIC = 0.2f
|
const val OPENCLOSE_GENERIC = 0.2f
|
||||||
|
|||||||
@@ -215,69 +215,63 @@ class UIHandler(var UI: UICanvas,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun processInput(delta: Float) {
|
|
||||||
if (isVisible) {
|
|
||||||
UI.processInput(delta)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun keyDown(keycode: Int): Boolean {
|
fun keyDown(keycode: Int): Boolean {
|
||||||
if (isVisible && UI is KeyControlled) {
|
if (isVisible) {
|
||||||
return (UI as KeyControlled).keyDown(keycode)
|
return UI.keyDown(keycode)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun keyUp(keycode: Int): Boolean {
|
fun keyUp(keycode: Int): Boolean {
|
||||||
if (isVisible && UI is KeyControlled) {
|
if (isVisible) {
|
||||||
return (UI as KeyControlled).keyUp(keycode)
|
return UI.keyUp(keycode)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun keyTyped(char: Char): Boolean {
|
fun keyTyped(char: Char): Boolean {
|
||||||
if (isVisible && UI is KeyControlled) {
|
if (isVisible) {
|
||||||
return (UI as KeyControlled).keyTyped(char)
|
return UI.keyTyped(char)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mouseMoved(screenX: Int, screenY: Int) {
|
fun mouseMoved(screenX: Int, screenY: Int) {
|
||||||
if (isVisible && UI is MouseControlled) {
|
if (isVisible) {
|
||||||
(UI as MouseControlled).mouseMoved(screenX, screenY)
|
UI.mouseMoved(screenX, screenY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
|
fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
|
||||||
if (isVisible && UI is MouseControlled) {
|
if (isVisible) {
|
||||||
(UI as MouseControlled).touchDragged(screenX, screenY, pointer)
|
UI.touchDragged(screenX, screenY, pointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
if (isVisible && UI is MouseControlled) {
|
if (isVisible) {
|
||||||
(UI as MouseControlled).touchDown(screenX, screenY, pointer, button)
|
UI.touchDown(screenX, screenY, pointer, button)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
if (isVisible && UI is MouseControlled) {
|
if (isVisible) {
|
||||||
(UI as MouseControlled).touchUp(screenX, screenY, pointer, button)
|
UI.touchUp(screenX, screenY, pointer, button)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun scrolled(amount: Int): Boolean {
|
fun scrolled(amount: Int): Boolean {
|
||||||
if (isVisible && UI is MouseControlled) {
|
if (isVisible) {
|
||||||
(UI as MouseControlled).scrolled(amount)
|
UI.scrolled(amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package net.torvald.terrarum.ui
|
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.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
@@ -7,6 +9,7 @@ import net.torvald.terrarum.Terrarum.joypadLabelNinA
|
|||||||
import net.torvald.terrarum.Terrarum.joypadLabelNinY
|
import net.torvald.terrarum.Terrarum.joypadLabelNinY
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
import net.torvald.terrarum.gameactors.ActorInventory.Companion.CAPACITY_MODE_NO_ENCUMBER
|
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.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
@@ -21,7 +24,7 @@ class UIInventory(
|
|||||||
override var width: Int,
|
override var width: Int,
|
||||||
override var height: Int,
|
override var height: Int,
|
||||||
var categoryWidth: Int
|
var categoryWidth: Int
|
||||||
) : UICanvas, MouseControlled, KeyControlled {
|
) : UICanvas() {
|
||||||
|
|
||||||
val inventory: ActorInventory?
|
val inventory: ActorInventory?
|
||||||
get() = actor?.inventory
|
get() = actor?.inventory
|
||||||
@@ -62,7 +65,7 @@ class UIInventory(
|
|||||||
|
|
||||||
val pageButtonRealWidth = pageButtonExtraGap + itemStripGutterH
|
val pageButtonRealWidth = pageButtonExtraGap + itemStripGutterH
|
||||||
|
|
||||||
val catButtons = UIItemTextButtonList(
|
private val catButtons = UIItemTextButtonList(
|
||||||
this,
|
this,
|
||||||
arrayOf(
|
arrayOf(
|
||||||
"MENU_LABEL_ALL",
|
"MENU_LABEL_ALL",
|
||||||
@@ -95,7 +98,7 @@ class UIInventory(
|
|||||||
)
|
)
|
||||||
|
|
||||||
val itemsStripWidth = ((width - catButtons.width) - (2 * itemStripGutterH + itemInterColGutter)) / 2 - pageButtonExtraGap
|
val itemsStripWidth = ((width - catButtons.width) - (2 * itemStripGutterH + itemInterColGutter)) / 2 - pageButtonExtraGap
|
||||||
val items = Array(
|
private val items = Array(
|
||||||
((height - controlHelpHeight) / (UIItemInventoryElem.height + itemStripGutterV)) * 2, {
|
((height - controlHelpHeight) / (UIItemInventoryElem.height + itemStripGutterV)) * 2, {
|
||||||
UIItemInventoryElem(
|
UIItemInventoryElem(
|
||||||
parentUI = this,
|
parentUI = this,
|
||||||
@@ -112,7 +115,26 @@ class UIInventory(
|
|||||||
drawBackOnNull = true,
|
drawBackOnNull = true,
|
||||||
inactiveTextCol = defaultTextColour
|
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<InventoryPair>()
|
var inventorySortList = ArrayList<InventoryPair>()
|
||||||
private var rebuildList = true
|
private var rebuildList = true
|
||||||
@@ -145,6 +167,27 @@ class UIInventory(
|
|||||||
private val seekDown: Int; get() = Terrarum.getConfigInt("keydown") // to support in-screen keybind changing
|
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) {
|
override fun update(delta: Float) {
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
throw Error("Handler for this UI is null, you douchebag.")
|
throw Error("Handler for this UI is null, you douchebag.")
|
||||||
@@ -152,6 +195,9 @@ class UIInventory(
|
|||||||
|
|
||||||
catButtons.update(delta)
|
catButtons.update(delta)
|
||||||
|
|
||||||
|
scrollLeftButton.update(delta)
|
||||||
|
scrollRightButton.update(delta)
|
||||||
|
|
||||||
if (actor != null && inventory != null) {
|
if (actor != null && inventory != null) {
|
||||||
// monitor and check if category selection has been changed
|
// monitor and check if category selection has been changed
|
||||||
// OR UI is being opened from closed state
|
// OR UI is being opened from closed state
|
||||||
@@ -186,6 +232,9 @@ class UIInventory(
|
|||||||
|
|
||||||
catButtons.render(batch)
|
catButtons.render(batch)
|
||||||
|
|
||||||
|
// left/right page mover
|
||||||
|
scrollLeftButton.render(batch)
|
||||||
|
scrollRightButton.render(batch)
|
||||||
|
|
||||||
items.forEach {
|
items.forEach {
|
||||||
it.render(batch)
|
it.render(batch)
|
||||||
@@ -265,7 +314,7 @@ class UIInventory(
|
|||||||
for (k in 0..items.size - 1) {
|
for (k in 0..items.size - 1) {
|
||||||
// we have an item
|
// we have an item
|
||||||
try {
|
try {
|
||||||
val sortListItem = inventorySortList[k + itemsScrollOffset]
|
val sortListItem = inventorySortList[k + itemPage * items.size]
|
||||||
items[k].item = sortListItem.item
|
items[k].item = sortListItem.item
|
||||||
items[k].amount = sortListItem.amount
|
items[k].amount = sortListItem.amount
|
||||||
items[k].itemImage = ItemCodex.getItemImage(sortListItem.item)
|
items[k].itemImage = ItemCodex.getItemImage(sortListItem.item)
|
||||||
@@ -308,8 +357,6 @@ class UIInventory(
|
|||||||
// Inputs //
|
// Inputs //
|
||||||
////////////
|
////////////
|
||||||
|
|
||||||
override fun processInput(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
UICanvas.doOpeningPopOut(handler, openCloseTime, UICanvas.Companion.Position.LEFT)
|
UICanvas.doOpeningPopOut(handler, openCloseTime, UICanvas.Companion.Position.LEFT)
|
||||||
@@ -317,7 +364,6 @@ class UIInventory(
|
|||||||
|
|
||||||
override fun doClosing(delta: Float) {
|
override fun doClosing(delta: Float) {
|
||||||
UICanvas.doClosingPopOut(handler, openCloseTime, UICanvas.Companion.Position.LEFT)
|
UICanvas.doClosingPopOut(handler, openCloseTime, UICanvas.Companion.Position.LEFT)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endOpening(delta: Float) {
|
override fun endOpening(delta: Float) {
|
||||||
@@ -328,11 +374,9 @@ class UIInventory(
|
|||||||
UICanvas.endClosingPopOut(handler, UICanvas.Companion.Position.LEFT)
|
UICanvas.endClosingPopOut(handler, UICanvas.Companion.Position.LEFT)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseMoved(screenX: Int, screenY: Int): Boolean {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun keyDown(keycode: Int): Boolean {
|
override fun keyDown(keycode: Int): Boolean {
|
||||||
|
super.keyDown(keycode)
|
||||||
|
|
||||||
items.forEach { if (it.mouseUp) it.keyDown(keycode) }
|
items.forEach { if (it.mouseUp) it.keyDown(keycode) }
|
||||||
shutUpAndRebuild()
|
shutUpAndRebuild()
|
||||||
|
|
||||||
@@ -340,21 +384,17 @@ class UIInventory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun keyUp(keycode: Int): Boolean {
|
override fun keyUp(keycode: Int): Boolean {
|
||||||
|
super.keyUp(keycode)
|
||||||
|
|
||||||
items.forEach { if (it.mouseUp) it.keyUp(keycode) }
|
items.forEach { if (it.mouseUp) it.keyUp(keycode) }
|
||||||
shutUpAndRebuild()
|
shutUpAndRebuild()
|
||||||
|
|
||||||
return true
|
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 {
|
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) }
|
items.forEach { if (it.mouseUp) it.touchDown(screenX, screenY, pointer, button) }
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@@ -366,12 +406,9 @@ class UIInventory(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun scrolled(amount: Int): Boolean {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
catButtons.dispose()
|
catButtons.dispose()
|
||||||
items.forEach { it.dispose() }
|
items.forEach { it.dispose() }
|
||||||
|
scrollImageButtonAtlas.dispose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,19 +28,99 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI
|
|||||||
open val mousePushed: Boolean
|
open val mousePushed: Boolean
|
||||||
get() = mouseUp && Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary")!!)
|
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)
|
abstract fun render(batch: SpriteBatch)
|
||||||
|
|
||||||
// keyboard controlled
|
// keyboard controlled
|
||||||
abstract fun keyDown(keycode: Int): Boolean
|
open fun keyDown(keycode: Int): Boolean {
|
||||||
abstract fun keyUp(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
|
// mouse controlled
|
||||||
abstract fun mouseMoved(screenX: Int, screenY: Int): Boolean
|
open fun mouseMoved(screenX: Int, screenY: Int): Boolean {
|
||||||
abstract fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean
|
if (mouseMovedAction != null) {
|
||||||
abstract fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean
|
mouseMovedAction!!.invoke(relativeMouseX, relativeMouseY)
|
||||||
abstract fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean
|
return true
|
||||||
abstract fun scrolled(amount: Int): Boolean
|
}
|
||||||
|
|
||||||
|
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()
|
abstract fun dispose()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import net.torvald.terrarum.fillRect
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-07-16.
|
* Created by minjaesong on 2017-07-16.
|
||||||
*/
|
*/
|
||||||
class UIItemImageButton(
|
open class UIItemImageButton(
|
||||||
parent: UICanvas,
|
parent: UICanvas,
|
||||||
val image: TextureRegion,
|
val image: TextureRegion,
|
||||||
|
|
||||||
@@ -18,20 +18,19 @@ class UIItemImageButton(
|
|||||||
val buttonBackCol: Color = Color(0),
|
val buttonBackCol: Color = Color(0),
|
||||||
val buttonBackBlendMode: String = BlendMode.NORMAL,
|
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 activeBackCol: Color = Color(0xb0b0b0_ff.toInt()),
|
||||||
val activeBackBlendMode: String = BlendMode.MULTIPLY,
|
val activeBackBlendMode: String = BlendMode.MULTIPLY,
|
||||||
|
|
||||||
override var posX: Int,
|
override var posX: Int,
|
||||||
override var posY: Int,
|
override var posY: Int,
|
||||||
override val width: Int,
|
override val width: Int = image.regionWidth,
|
||||||
override val height: Int
|
override val height: Int = image.regionHeight
|
||||||
) : UIItem(parent) {
|
) : UIItem(parent) {
|
||||||
|
|
||||||
override fun update(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun render(batch: SpriteBatch) {
|
override fun render(batch: SpriteBatch) {
|
||||||
|
// draw background
|
||||||
if (mouseUp) {
|
if (mouseUp) {
|
||||||
BlendMode.resolve(activeBackBlendMode)
|
BlendMode.resolve(activeBackBlendMode)
|
||||||
batch.color = activeBackCol
|
batch.color = activeBackCol
|
||||||
@@ -43,41 +42,15 @@ class UIItemImageButton(
|
|||||||
|
|
||||||
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||||
|
|
||||||
|
|
||||||
|
// draw image
|
||||||
blendNormal()
|
blendNormal()
|
||||||
|
|
||||||
batch.color = if (mouseUp) activeCol else buttonCol
|
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() {
|
override fun dispose() {
|
||||||
image.texture.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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|||||||
*
|
*
|
||||||
* Created by SKYHi14 on 2017-03-13.
|
* Created by SKYHi14 on 2017-03-13.
|
||||||
*/
|
*/
|
||||||
class UIItemTextButton(
|
open class UIItemTextButton(
|
||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
val labelText: String,
|
val labelText: String,
|
||||||
override var posX: Int,
|
override var posX: Int,
|
||||||
@@ -44,9 +44,6 @@ class UIItemTextButton(
|
|||||||
var highlighted: Boolean = false
|
var highlighted: Boolean = false
|
||||||
|
|
||||||
|
|
||||||
override fun update(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private val glyphLayout = GlyphLayout()
|
private val glyphLayout = GlyphLayout()
|
||||||
|
|
||||||
override fun render(batch: SpriteBatch) {
|
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() {
|
override fun dispose() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,34 +167,6 @@ class UIItemTextButtonList(
|
|||||||
batch.color = backgroundCol
|
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() {
|
override fun dispose() {
|
||||||
iconSpriteSheet?.dispose()
|
iconSpriteSheet?.dispose()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.dyn4j.geometry.Vector2
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-07-20.
|
* Created by minjaesong on 16-07-20.
|
||||||
*/
|
*/
|
||||||
class UIPieMenu : UICanvas {
|
class UIPieMenu : UICanvas() {
|
||||||
private val cellSize = UIQuickBar.CELL_SIZE
|
private val cellSize = UIQuickBar.CELL_SIZE
|
||||||
|
|
||||||
private val slotCount = UIQuickBar.SLOT_COUNT
|
private val slotCount = UIQuickBar.SLOT_COUNT
|
||||||
@@ -40,6 +40,19 @@ class UIPieMenu : UICanvas {
|
|||||||
Terrarum.ingame!!.player!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
|
Terrarum.ingame!!.player!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
|
||||||
selection % slotCount
|
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) {
|
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) {
|
override fun doOpening(delta: Float) {
|
||||||
UICanvas.doOpeningFade(handler, openCloseTime)
|
UICanvas.doOpeningFade(handler, openCloseTime)
|
||||||
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
|
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.itemproperties.ItemCodex
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-07-20.
|
* Created by minjaesong on 16-07-20.
|
||||||
*/
|
*/
|
||||||
class UIQuickBar : UICanvas, MouseControlled {
|
class UIQuickBar : UICanvas() {
|
||||||
private val gutter = 8
|
private val gutter = 8
|
||||||
override var width: Int = (ItemSlotImageBuilder.slotImage.width + gutter) * SLOT_COUNT
|
override var width: Int = (ItemSlotImageBuilder.slotImage.width + gutter) * SLOT_COUNT
|
||||||
override var height: Int = ItemSlotImageBuilder.slotImage.height + 4 + Terrarum.fontGame.lineHeight.toInt()
|
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) {
|
override fun doOpening(delta: Float) {
|
||||||
handler!!.opacity = handler!!.openCloseCounter.toFloat() / openCloseTime
|
handler!!.opacity = handler!!.openCloseCounter.toFloat() / openCloseTime
|
||||||
}
|
}
|
||||||
@@ -90,23 +87,9 @@ class UIQuickBar : UICanvas, MouseControlled {
|
|||||||
handler!!.opacity = 0f
|
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 {
|
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)
|
selection = selection.plus(if (amount > 1) 1 else if (amount < -1) -1 else 0).fmod(SLOT_COUNT)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-06-11.
|
* 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 width = 85
|
||||||
override var height = 52
|
override var height = 52
|
||||||
override var handler: UIHandler? = null
|
override var handler: UIHandler? = null
|
||||||
@@ -107,9 +107,6 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas {
|
|||||||
batch.draw(moonDial.get(moonPhase, 0), 4f, 22f)
|
batch.draw(moonDial.get(moonPhase, 0), 4f, 22f)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processInput(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class UIVitalMetre(
|
|||||||
var vitalGetterMax: () -> Float?,
|
var vitalGetterMax: () -> Float?,
|
||||||
var color: Color?,
|
var color: Color?,
|
||||||
val order: Int
|
val order: Int
|
||||||
) : UICanvas {
|
) : UICanvas() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// semitransparent
|
// semitransparent
|
||||||
@@ -105,9 +105,6 @@ class UIVitalMetre(
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processInput(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
UICanvas.doOpeningFade(handler, openCloseTime)
|
UICanvas.doOpeningFade(handler, openCloseTime)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,39 +9,8 @@ import net.torvald.terrarum.virtualcomputer.terminal.Terminal
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-09-08.
|
* 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 width: Int = terminal.displayW// + some
|
||||||
override var height: Int = terminal.displayH// + frame
|
override var height: Int = terminal.displayH// + frame
|
||||||
@@ -68,9 +37,6 @@ class UITextTerminal(val terminal: Terminal) : UICanvas, KeyControlled, MouseCon
|
|||||||
//terminal.render(gc, terminalDisplay.graphics)
|
//terminal.render(gc, terminalDisplay.graphics)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processInput(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not modify handler!!.openCloseCounter here.
|
* Do not modify handler!!.openCloseCounter here.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -106,13 +106,12 @@ object WeatherMixer {
|
|||||||
val topCol = getGradientColour(skyboxColourMap, 0, timeNow)
|
val topCol = getGradientColour(skyboxColourMap, 0, timeNow)
|
||||||
val bottomCol = getGradientColour(skyboxColourMap, 1, timeNow)
|
val bottomCol = getGradientColour(skyboxColourMap, 1, timeNow)
|
||||||
|
|
||||||
Terrarum.textureWhiteSquare.bind(0)
|
//Terrarum.textureWhiteSquare.bind(0)
|
||||||
|
|
||||||
Terrarum.shaderBayerSkyboxFill.begin()
|
Terrarum.shaderBayerSkyboxFill.begin()
|
||||||
Terrarum.shaderBayerSkyboxFill.setUniformMatrix("u_projTrans", camera.combined)
|
Terrarum.shaderBayerSkyboxFill.setUniformMatrix("u_projTrans", camera.combined)
|
||||||
Terrarum.shaderBayerSkyboxFill.setUniformf("topColor", topCol.r, topCol.g, topCol.b)
|
Terrarum.shaderBayerSkyboxFill.setUniformf("topColor", topCol.r, topCol.g, topCol.b)
|
||||||
Terrarum.shaderBayerSkyboxFill.setUniformf("bottomColor", bottomCol.r, bottomCol.g, bottomCol.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.ingame!!.fullscreenQuad.render(Terrarum.shaderBayerSkyboxFill, GL20.GL_TRIANGLES)
|
||||||
Terrarum.shaderBayerSkyboxFill.end()
|
Terrarum.shaderBayerSkyboxFill.end()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user