mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
debugger's got its colour codes back
This commit is contained in:
Binary file not shown.
@@ -73,7 +73,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
|||||||
val ZOOM_MIN = 0.5f
|
val ZOOM_MIN = 0.5f
|
||||||
|
|
||||||
var worldDrawFrameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width.div(ZOOM_MIN).ceilInt(), Gdx.graphics.height.div(ZOOM_MIN).ceilInt(), false)
|
var worldDrawFrameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width.div(ZOOM_MIN).ceilInt(), Gdx.graphics.height.div(ZOOM_MIN).ceilInt(), false)
|
||||||
var backDrawFrameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width, Gdx.graphics.height, false)
|
//var backDrawFrameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width, Gdx.graphics.height, false)
|
||||||
|
|
||||||
//private lateinit var shader12BitCol: Shader // grab LibGDX if you want some shader
|
//private lateinit var shader12BitCol: Shader // grab LibGDX if you want some shader
|
||||||
//private lateinit var shaderBlur: Shader
|
//private lateinit var shaderBlur: Shader
|
||||||
@@ -127,55 +127,21 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
|||||||
var camera = OrthographicCamera(Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat())
|
var camera = OrthographicCamera(Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat())
|
||||||
|
|
||||||
// invert Y
|
// invert Y
|
||||||
fun initViewPort(width: Int, height: Int, aspect: Float) {
|
fun initViewPort(width: Int, height: Int) {
|
||||||
val width = width.toFloat()
|
|
||||||
val height = height.toFloat()
|
|
||||||
|
|
||||||
// Get the window size in pixels
|
|
||||||
val w = Gdx.graphics.width.toFloat()
|
|
||||||
val h = Gdx.graphics.height.toFloat()
|
|
||||||
|
|
||||||
val vw: Float
|
|
||||||
val vh: Float // Viewport size in screen coordinates
|
|
||||||
val ox: Float
|
|
||||||
val oy: Float // Viewport offset in screen coordinates
|
|
||||||
|
|
||||||
// Check aspect ratio
|
|
||||||
if (w > h * aspect) {
|
|
||||||
// Black bars on the sides
|
|
||||||
vh = h
|
|
||||||
vw = Math.round(vh * aspect).toFloat()
|
|
||||||
oy = 0f
|
|
||||||
ox = (w - vw) / 2
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Black bars on top and bottom
|
|
||||||
vw = w
|
|
||||||
vh = Math.round(vw * (1 / aspect)).toFloat()
|
|
||||||
ox = 0f
|
|
||||||
oy = (h - vh) / 2
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create camera with the desired resolution
|
|
||||||
//camera = OrthographicCamera(width, height)
|
|
||||||
|
|
||||||
// Move camera center to push 0,0 into the corner
|
|
||||||
//camera.translate(width / 2, height / 2)
|
|
||||||
|
|
||||||
// Set Y to point downwards
|
// Set Y to point downwards
|
||||||
camera.setToOrtho(true, width, height)
|
camera.setToOrtho(true, width.toFloat(), height.toFloat())
|
||||||
|
|
||||||
// Update camera matrix
|
// Update camera matrix
|
||||||
camera.update()
|
camera.update()
|
||||||
|
|
||||||
// Set viewport to restrict drawing
|
// Set viewport to restrict drawing
|
||||||
Gdx.gl20.glViewport(ox.toInt(), oy.toInt(), vw.toInt(), vh.toInt())
|
Gdx.gl20.glViewport(0, 0, width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun show() {
|
override fun show() {
|
||||||
// Set up viewport on first load
|
// Set up viewport on first load
|
||||||
initViewPort(Gdx.graphics.width, Gdx.graphics.height, Gdx.graphics.width.toFloat() / Gdx.graphics.height.toFloat())
|
initViewPort(Gdx.graphics.width, Gdx.graphics.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,7 +149,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
|||||||
Gdx.input.inputProcessor = GameController
|
Gdx.input.inputProcessor = GameController
|
||||||
|
|
||||||
|
|
||||||
initViewPort(Gdx.graphics.width, Gdx.graphics.height, Gdx.graphics.width.toFloat() / Gdx.graphics.height.toFloat())
|
initViewPort(Gdx.graphics.width, Gdx.graphics.height)
|
||||||
|
|
||||||
|
|
||||||
// load things when the game entered this "state"
|
// load things when the game entered this "state"
|
||||||
@@ -410,14 +376,15 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
|||||||
Gdx.gl.glClearColor(0f,0f,0f,0f)
|
Gdx.gl.glClearColor(0f,0f,0f,0f)
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||||
}
|
}
|
||||||
backDrawFrameBuffer.inAction {
|
|
||||||
Gdx.gl.glClearColor(0f,0f,0f,0f)
|
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
// Post-update; ones that needs everything is completed //
|
||||||
|
LightmapRenderer.renderLightMap() //
|
||||||
|
FeaturesDrawer.render(batch) //
|
||||||
|
// end of post-update //
|
||||||
|
|
||||||
|
|
||||||
|
// now the actual drawing part //
|
||||||
worldDrawFrameBuffer.inAction {
|
worldDrawFrameBuffer.inAction {
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
camera.position.set(WorldCamera.gdxCamX, WorldCamera.gdxCamY, 0f) // make camara work
|
camera.position.set(WorldCamera.gdxCamX, WorldCamera.gdxCamY, 0f) // make camara work
|
||||||
@@ -426,6 +393,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
blendNormal()
|
blendNormal()
|
||||||
|
|
||||||
|
|
||||||
@@ -450,42 +418,33 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
|||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// draw map related stuffs //
|
// draw map related stuffs //
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
LightmapRenderer.renderLightMap()
|
|
||||||
|
|
||||||
//BlocksDrawer.renderFront(batch, false)
|
BlocksDrawer.renderFront(batch, false)
|
||||||
// --> blendNormal() <-- by BlocksDrawer.renderFront
|
// --> blendNormal() <-- by BlocksDrawer.renderFront
|
||||||
//FeaturesDrawer.render(batch)
|
FeaturesDrawer.drawEnvOverlay(batch)
|
||||||
|
|
||||||
|
|
||||||
//FeaturesDrawer.drawEnvOverlay(batch)
|
LightmapRenderer.draw(batch)
|
||||||
|
|
||||||
//if (!KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendMul()
|
|
||||||
//else blendNormal()
|
|
||||||
//blendMul()
|
|
||||||
//LightmapRenderer.draw(batch)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// draw actor glows //
|
// draw actor glows //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// needs some new blending/shader for glow...
|
// FIXME needs some new blending/shader for glow...
|
||||||
|
|
||||||
//actorsRenderMiddle.forEach { it.drawGlow(batch) }
|
//actorsRenderMiddle.forEach { it.drawGlow(batch) }
|
||||||
//actorsRenderMidTop.forEach { it.drawGlow(batch) }
|
//actorsRenderMidTop.forEach { it.drawGlow(batch) }
|
||||||
player?.drawGlow(batch)
|
//player?.drawGlow(batch)
|
||||||
//actorsRenderFront.forEach { it.drawGlow(batch) }
|
//actorsRenderFront.forEach { it.drawGlow(batch) }
|
||||||
// --> blendLightenOnly() <-- introduced by childs of ActorWithBody //
|
// --> blendLightenOnly() <-- introduced by childs of ActorWithBody //
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////
|
||||||
// draw framebuffers to screen //
|
// draw to main screen //
|
||||||
/////////////////////////////////
|
/////////////////////////
|
||||||
blendNormal()
|
blendNormal()
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
camera.position.set(TerrarumGDX.HALFW.toFloat(), TerrarumGDX.HALFH.toFloat(), 0f) // make camara work
|
camera.position.set(TerrarumGDX.HALFW.toFloat(), TerrarumGDX.HALFH.toFloat(), 0f) // make camara work
|
||||||
@@ -493,14 +452,99 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
|||||||
batch.projectionMatrix = camera.combined
|
batch.projectionMatrix = camera.combined
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// draw framebuffers to screen //
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
WeatherMixer.render(batch)
|
WeatherMixer.render(batch)
|
||||||
|
|
||||||
val tex = worldDrawFrameBuffer.colorBufferTexture // TODO zoom!
|
val tex = worldDrawFrameBuffer.colorBufferTexture // TODO zoom!
|
||||||
batch.draw(tex, 0f, 0f, Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat())
|
batch.draw(tex, 0f, 0f, Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////
|
||||||
|
// debug informations //
|
||||||
|
////////////////////////
|
||||||
|
|
||||||
|
blendNormal()
|
||||||
|
// draw reference ID if debugWindow is open
|
||||||
|
if (debugWindow.isVisible) {
|
||||||
|
|
||||||
|
actorContainer.forEachIndexed { i, actor ->
|
||||||
|
if (actor is ActorWithBody) {
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||||
|
actor.referenceID.toString(),
|
||||||
|
actor.hitbox.startX.toFloat(),
|
||||||
|
actor.hitbox.canonicalY.toFloat() + 4
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// debug physics
|
||||||
|
if (KeyToggler.isOn(Input.Keys.F11)) {
|
||||||
|
actorContainer.forEachIndexed { i, actor ->
|
||||||
|
if (actor is ActorWithPhysics) {
|
||||||
|
/*shapeRenderer.inUse(ShapeRenderer.ShapeType.Line) {
|
||||||
|
shapeRenderer.color = Color(1f, 0f, 1f, 1f)
|
||||||
|
//shapeRenderer.lineWidth = 1f
|
||||||
|
shapeRenderer.rect(
|
||||||
|
actor.hitbox.startX.toFloat(),
|
||||||
|
actor.hitbox.startY.toFloat(),
|
||||||
|
actor.hitbox.width.toFloat(),
|
||||||
|
actor.hitbox.height.toFloat()
|
||||||
|
)
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// velocity
|
||||||
|
batch.color = Color.CHARTREUSE//GameFontBase.codeToCol["g"]
|
||||||
|
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||||
|
"${0x7F.toChar()}X ${actor.externalForce.x}",
|
||||||
|
actor.hitbox.startX.toFloat(),
|
||||||
|
actor.hitbox.canonicalY.toFloat() + 4 + 8
|
||||||
|
)
|
||||||
|
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||||
|
"${0x7F.toChar()}Y ${actor.externalForce.y}",
|
||||||
|
actor.hitbox.startX.toFloat(),
|
||||||
|
actor.hitbox.canonicalY.toFloat() + 4 + 8 * 2
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// fluidmap debug
|
||||||
|
if (KeyToggler.isOn(Input.Keys.F4)) {
|
||||||
|
WorldSimulator.drawFluidMapDebug(batch)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// draw some overlays (UI) //
|
||||||
|
/////////////////////////////
|
||||||
|
|
||||||
|
//uiContainer.forEach { if (it != consoleHandler) it.render(batch) } // FIXME draws black of grey coloured box on top right
|
||||||
|
debugWindow.render(batch)
|
||||||
|
// make sure console draws on top of other UIs
|
||||||
|
consoleHandler.render(batch)
|
||||||
|
notifier.render(batch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ////// //// // //// // //
|
||||||
|
// // // // // // // //
|
||||||
|
// //// // // // // // ////
|
||||||
|
// // // // ////// // //
|
||||||
|
////// ////// //// // // //// ////
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// draw map related stuffs //
|
// draw map related stuffs //
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
@@ -1037,15 +1081,12 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
|||||||
override fun resize(width: Int, height: Int) {
|
override fun resize(width: Int, height: Int) {
|
||||||
worldDrawFrameBuffer.dispose()
|
worldDrawFrameBuffer.dispose()
|
||||||
worldDrawFrameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width.div(ZOOM_MIN).ceilInt(), Gdx.graphics.height.div(ZOOM_MIN).ceilInt(), false)
|
worldDrawFrameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width.div(ZOOM_MIN).ceilInt(), Gdx.graphics.height.div(ZOOM_MIN).ceilInt(), false)
|
||||||
backDrawFrameBuffer.dispose()
|
|
||||||
backDrawFrameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width, Gdx.graphics.height, false)
|
|
||||||
|
|
||||||
// Set up viewport when window is resized
|
// Set up viewport when window is resized
|
||||||
initViewPort(width, height, width.toFloat() / height.toFloat())
|
initViewPort(width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
worldDrawFrameBuffer.dispose()
|
worldDrawFrameBuffer.dispose()
|
||||||
backDrawFrameBuffer.dispose()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ import net.torvald.terrarum.langpack.Lang
|
|||||||
import net.torvald.terrarum.TerrarumGDX
|
import net.torvald.terrarum.TerrarumGDX
|
||||||
import net.torvald.terrarum.gameactors.Factionable
|
import net.torvald.terrarum.gameactors.Factionable
|
||||||
import net.torvald.terrarum.gameactors.Player
|
import net.torvald.terrarum.gameactors.Player
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-02-17.
|
* Created by minjaesong on 16-02-17.
|
||||||
*/
|
*/
|
||||||
internal object GetFactioning : ConsoleCommand {
|
internal object GetFactioning : ConsoleCommand {
|
||||||
val ccW = 0.toChar()//GameFontBase.colToCode["w"]
|
val ccW = GameFontBase.toColorCode(0xFFFF)
|
||||||
val ccG = 0.toChar()//GameFontBase.colToCode["g"]
|
val ccY = GameFontBase.toColorCode(0xFE8F)
|
||||||
val ccY = 0.toChar()//GameFontBase.colToCode["y"]
|
val ccM = GameFontBase.toColorCode(0xEAFF)
|
||||||
val ccM = 0.toChar()//GameFontBase.colToCode["m"]
|
val ccG = GameFontBase.toColorCode(0x8F8F)
|
||||||
val ccK = 0.toChar()//GameFontBase.colToCode["k"]
|
val ccK = GameFontBase.toColorCode(0x888F)
|
||||||
val ccB = 0.toChar()//GameFontBase.colToCode["b"]
|
|
||||||
|
|
||||||
private val PRINT_INDENTATION = "$ccK --> $ccW"
|
private val PRINT_INDENTATION = "$ccK --> $ccW"
|
||||||
|
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
|||||||
|
|
||||||
@Transient private val world: GameWorld = TerrarumGDX.ingame!!.world
|
@Transient private val world: GameWorld = TerrarumGDX.ingame!!.world
|
||||||
|
|
||||||
var hitboxTranslateX: Double = 0.0// relative to spritePosX
|
var hitboxTranslateX: Int = 0// relative to spritePosX
|
||||||
protected set
|
protected set
|
||||||
var hitboxTranslateY: Double = 0.0// relative to spritePosY
|
var hitboxTranslateY: Int = 0// relative to spritePosY
|
||||||
protected set
|
protected set
|
||||||
var baseHitboxW: Int = 0
|
var baseHitboxW: Int = 0
|
||||||
protected set
|
protected set
|
||||||
@@ -269,8 +269,8 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
|||||||
fun setHitboxDimension(w: Int, h: Int, tx: Int, ty: Int) {
|
fun setHitboxDimension(w: Int, h: Int, tx: Int, ty: Int) {
|
||||||
baseHitboxH = h
|
baseHitboxH = h
|
||||||
baseHitboxW = w
|
baseHitboxW = w
|
||||||
hitboxTranslateX = tx.toDouble()
|
hitboxTranslateX = tx
|
||||||
hitboxTranslateY = ty.toDouble()
|
hitboxTranslateY = ty
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setPosition(pos: Point2d) = setPosition(pos.x, pos.y)
|
fun setPosition(pos: Point2d) = setPosition(pos.x, pos.y)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.gamecontroller
|
package net.torvald.terrarum.gamecontroller
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.Input
|
||||||
import com.badlogic.gdx.InputAdapter
|
import com.badlogic.gdx.InputAdapter
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent
|
import com.badlogic.gdx.scenes.scene2d.InputEvent
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputListener
|
import com.badlogic.gdx.scenes.scene2d.InputListener
|
||||||
@@ -24,10 +25,10 @@ object GameController : InputAdapter() {
|
|||||||
|
|
||||||
/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise) */
|
/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise) */
|
||||||
val mouseX: Float
|
val mouseX: Float
|
||||||
get() = (WorldCamera.x + TerrarumGDX.mouseX.toFloat() / (ingame.screenZoom ?: 1f))
|
get() = WorldCamera.x + Gdx.input.x / (ingame.screenZoom)
|
||||||
/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise)*/
|
/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise)*/
|
||||||
val mouseY: Float
|
val mouseY: Float
|
||||||
get() = (WorldCamera.y + TerrarumGDX.mouseY.toFloat() / (ingame.screenZoom ?: 1f))
|
get() = WorldCamera.y + Gdx.input.y / (ingame.screenZoom)
|
||||||
/** currently pointing tile coordinate */
|
/** currently pointing tile coordinate */
|
||||||
val mouseTileX: Int
|
val mouseTileX: Int
|
||||||
get() = (mouseX / FeaturesDrawer.TILE_SIZE).floorInt()
|
get() = (mouseX / FeaturesDrawer.TILE_SIZE).floorInt()
|
||||||
@@ -102,6 +103,10 @@ object GameController : InputAdapter() {
|
|||||||
|
|
||||||
ingame.uiContainer.forEach { it.keyDown(keycode) } // for KeyboardControlled UIcanvases
|
ingame.uiContainer.forEach { it.keyDown(keycode) } // for KeyboardControlled UIcanvases
|
||||||
|
|
||||||
|
if (keycode == Input.Keys.F3) {
|
||||||
|
ingame.debugWindow.toggleOpening()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.torvald.terrarum.imagefont
|
package net.torvald.terrarum.imagefont
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout
|
import com.badlogic.gdx.graphics.g2d.GlyphLayout
|
||||||
@@ -25,15 +26,67 @@ object TinyAlphNum : BitmapFont() {
|
|||||||
return W * str.length
|
return W * str.length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lateinit var colourHolder: Color
|
||||||
|
|
||||||
override fun draw(batch: Batch, text: CharSequence, x: Float, y: Float): GlyphLayout? {
|
override fun draw(batch: Batch, text: CharSequence, x: Float, y: Float): GlyphLayout? {
|
||||||
|
val originalColour = batch.color
|
||||||
|
colourHolder = batch.color
|
||||||
|
|
||||||
|
var charsPrinted = 0
|
||||||
text.forEachIndexed { index, c ->
|
text.forEachIndexed { index, c ->
|
||||||
batch.draw(fontSheet.get(index % 16, index / 16), x + index * W, y)
|
if (isColourCodeHigh(c)) {
|
||||||
|
val cchigh = c
|
||||||
|
val cclow = text[index + 1]
|
||||||
|
val colour = getColour(cchigh, cclow)
|
||||||
|
|
||||||
|
colourHolder = colour
|
||||||
|
}
|
||||||
|
else if (c in 0.toChar()..255.toChar()) {
|
||||||
|
batch.color = colourHolder.cpy().mul(0.5f, 0.5f, 0.5f, 1f)
|
||||||
|
batch.draw(fontSheet.get(c.toInt() % 16, c.toInt() / 16), x + charsPrinted * W + 1, y)
|
||||||
|
batch.draw(fontSheet.get(c.toInt() % 16, c.toInt() / 16), x + charsPrinted * W , y + 1)
|
||||||
|
batch.draw(fontSheet.get(c.toInt() % 16, c.toInt() / 16), x + charsPrinted * W + 1, y + 1)
|
||||||
|
|
||||||
|
|
||||||
|
batch.color = colourHolder.cpy()
|
||||||
|
batch.draw(fontSheet.get(c.toInt() % 16, c.toInt() / 16), x + charsPrinted * W, y)
|
||||||
|
|
||||||
|
charsPrinted += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
batch.color = originalColour
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLineHeight() = H.toFloat()
|
override fun getLineHeight() = H.toFloat()
|
||||||
override fun getCapHeight() = getLineHeight()
|
override fun getCapHeight() = getLineHeight()
|
||||||
override fun getXHeight() = getLineHeight()
|
override fun getXHeight() = getLineHeight()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private fun isColourCodeHigh(c: Char) = c.toInt() in 0b110110_1111000000..0b110110_1111111111
|
||||||
|
private fun isColourCodeLow(c: Char) = c.toInt() in 0b110111_0000000000..0b110111_1111111111
|
||||||
|
|
||||||
|
private fun getColour(charHigh: Char, charLow: Char): Color { // input: 0x10ARGB, out: RGBA8888
|
||||||
|
val codePoint = Character.toCodePoint(charHigh, charLow)
|
||||||
|
|
||||||
|
if (colourBuffer.containsKey(codePoint))
|
||||||
|
return colourBuffer[codePoint]!!
|
||||||
|
|
||||||
|
val r = codePoint.and(0xF000).ushr(12)
|
||||||
|
val g = codePoint.and(0x0F00).ushr(8)
|
||||||
|
val b = codePoint.and(0x00F0).ushr(4)
|
||||||
|
val a = codePoint.and(0x000F)
|
||||||
|
|
||||||
|
val col = Color(r.shl(28) or r.shl(24) or g.shl(20) or g.shl(16) or b.shl(12) or b.shl(8) or a.shl(4) or a)
|
||||||
|
|
||||||
|
|
||||||
|
colourBuffer[codePoint] = col
|
||||||
|
return col
|
||||||
|
}
|
||||||
|
|
||||||
|
private val colourBuffer = HashMap<Int, Color>()
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ import net.torvald.terrarum.blendNormal
|
|||||||
import net.torvald.terrarum.blendScreen
|
import net.torvald.terrarum.blendScreen
|
||||||
import net.torvald.terrarum.fillRect
|
import net.torvald.terrarum.fillRect
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-03-14.
|
* Created by minjaesong on 16-03-14.
|
||||||
@@ -30,11 +31,18 @@ class BasicDebugInfoWindow : UICanvas {
|
|||||||
private var xdelta = 0.0
|
private var xdelta = 0.0
|
||||||
private var ydelta = 0.0
|
private var ydelta = 0.0
|
||||||
|
|
||||||
val ccW = 0.toChar()//GameFontBase.colToCode["w"]
|
val ccW = GameFontBase.toColorCode(0xFFFF)
|
||||||
val ccG = 0.toChar()//GameFontBase.colToCode["g"]
|
val ccY = GameFontBase.toColorCode(0xFE8F)
|
||||||
val ccY = 0.toChar()//GameFontBase.colToCode["y"]
|
val ccO = GameFontBase.toColorCode(0xFB2F)
|
||||||
val ccR = 0.toChar()//GameFontBase.colToCode["r"]
|
val ccR = GameFontBase.toColorCode(0xF88F)
|
||||||
val ccM = 0.toChar()//GameFontBase.colToCode["m"]
|
val ccF = GameFontBase.toColorCode(0xFAEF)
|
||||||
|
val ccM = GameFontBase.toColorCode(0xEAFF)
|
||||||
|
val ccB = GameFontBase.toColorCode(0x88FF)
|
||||||
|
val ccC = GameFontBase.toColorCode(0x8FFF)
|
||||||
|
val ccG = GameFontBase.toColorCode(0x8F8F)
|
||||||
|
val ccV = GameFontBase.toColorCode(0x080F)
|
||||||
|
val ccX = GameFontBase.toColorCode(0x853F)
|
||||||
|
val ccK = GameFontBase.toColorCode(0x888F)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -59,9 +67,7 @@ class BasicDebugInfoWindow : UICanvas {
|
|||||||
val mouseTileX = ((WorldCamera.x + TerrarumGDX.mouseX / TerrarumGDX.ingame!!.screenZoom) / FeaturesDrawer.TILE_SIZE).toInt()
|
val mouseTileX = ((WorldCamera.x + TerrarumGDX.mouseX / TerrarumGDX.ingame!!.screenZoom) / FeaturesDrawer.TILE_SIZE).toInt()
|
||||||
val mouseTileY = ((WorldCamera.y + TerrarumGDX.mouseY / TerrarumGDX.ingame!!.screenZoom) / FeaturesDrawer.TILE_SIZE).toInt()
|
val mouseTileY = ((WorldCamera.y + TerrarumGDX.mouseY / TerrarumGDX.ingame!!.screenZoom) / FeaturesDrawer.TILE_SIZE).toInt()
|
||||||
|
|
||||||
//g.color = GameFontBase.codeToCol["y"]
|
batch.color = Color(0xFFEE88FF.toInt())
|
||||||
|
|
||||||
batch.color = Color.WHITE
|
|
||||||
|
|
||||||
val hitbox = player?.hitbox
|
val hitbox = player?.hitbox
|
||||||
|
|
||||||
@@ -155,6 +161,9 @@ class BasicDebugInfoWindow : UICanvas {
|
|||||||
Gdx.graphics.width - histogramW - 30,
|
Gdx.graphics.width - histogramW - 30,
|
||||||
Gdx.graphics.height - histogramH - 30
|
Gdx.graphics.height - histogramH - 30
|
||||||
)
|
)
|
||||||
|
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
|
||||||
if (TerrarumGDX.controller != null) {
|
if (TerrarumGDX.controller != null) {
|
||||||
drawGamepadAxis(batch,
|
drawGamepadAxis(batch,
|
||||||
TerrarumGDX.controller!!.getAxisValue(3),
|
TerrarumGDX.controller!!.getAxisValue(3),
|
||||||
|
|||||||
@@ -127,11 +127,13 @@ class UIHandler(val UI: UICanvas,
|
|||||||
|
|
||||||
fun render(batch: SpriteBatch) {
|
fun render(batch: SpriteBatch) {
|
||||||
if (isVisible || alwaysVisible) {
|
if (isVisible || alwaysVisible) {
|
||||||
|
// camera SHOULD BE CENTERED to HALFX and HALFY (see StateInGame) //
|
||||||
|
|
||||||
batch.projectionMatrix = Matrix4()
|
|
||||||
|
|
||||||
if (!customPositioning)
|
//batch.projectionMatrix = Matrix4()
|
||||||
TerrarumGDX.ingame?.camera?.position?.set(posX.toFloat(), posY.toFloat(), 0f) // does it work?
|
//
|
||||||
|
//if (!customPositioning)
|
||||||
|
// TerrarumGDX.ingame?.camera?.position?.set(posX.toFloat(), posY.toFloat(), 0f) // does it work?
|
||||||
|
|
||||||
UI.render(batch)
|
UI.render(batch)
|
||||||
//ingameGraphics.flush()
|
//ingameGraphics.flush()
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ class UIInventory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseMoved(screenX: Int, screenY: Int): Boolean {
|
override fun mouseMoved(screenX: Int, screenY: Int): Boolean {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun keyDown(keycode: Int): Boolean {
|
override fun keyDown(keycode: Int): Boolean {
|
||||||
|
|||||||
@@ -342,7 +342,9 @@ object BlocksDrawer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// NO draw lightmap using colour filter, actors must also be hidden behind the darkness
|
||||||
|
///////////////////////////////////////////
|
||||||
|
|
||||||
fun renderWall(batch: SpriteBatch) {
|
fun renderWall(batch: SpriteBatch) {
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user