fixed bad color rendering on blocksdrawer and lightmaprenderer

This commit is contained in:
minjaesong
2017-07-02 21:53:50 +09:00
parent bea125b66d
commit bbc68110d9
15 changed files with 61 additions and 66 deletions

View File

@@ -424,6 +424,10 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
FeaturesDrawer.drawEnvOverlay(batch) FeaturesDrawer.drawEnvOverlay(batch)
if (KeyToggler.isOn(Input.Keys.F7))
blendNormal()
else
blendMul()
LightmapRenderer.draw(batch) LightmapRenderer.draw(batch)

View File

@@ -479,9 +479,9 @@ object TerrarumGDX : ApplicationAdapter() {
inline val mouseY: Double inline val mouseY: Double
get() = GameController.mouseY.toDouble() get() = GameController.mouseY.toDouble()
@JvmStatic inline val mouseTileX: Int @JvmStatic inline val mouseTileX: Int
get() = mouseX.toInt() / TILE_SIZE get() = GameController.mouseTileX
@JvmStatic inline val mouseTileY: Int @JvmStatic inline val mouseTileY: Int
get() = mouseY.toInt() / TILE_SIZE get() = GameController.mouseTileY
inline val mouseScreenX: Int inline val mouseScreenX: Int
get() = Gdx.input.x get() = Gdx.input.x
inline val mouseScreenY: Int inline val mouseScreenY: Int
@@ -602,6 +602,17 @@ infix fun Color.minus(other: Color) = Color( // don't turn into an operator!
fun Int.toHex() = this.toLong().and(0xFFFFFFFF).toString(16).padStart(8, '0').toUpperCase() fun Int.toHex() = this.toLong().and(0xFFFFFFFF).toString(16).padStart(8, '0').toUpperCase()
val ccW = GameFontBase.toColorCode(0xFFFF)
val ccY = GameFontBase.toColorCode(0xFE8F)
val ccO = GameFontBase.toColorCode(0xFB2F)
val ccR = GameFontBase.toColorCode(0xF88F)
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)

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.ccW
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import java.util.Formatter import java.util.Formatter
@@ -9,8 +10,6 @@ import java.util.Formatter
*/ */
internal object CodexEdictis : ConsoleCommand { internal object CodexEdictis : ConsoleCommand {
val ccW = 0.toChar()//GameFontBase.colToCode["o"]
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 1) { if (args.size == 1) {
printList() printList()

View File

@@ -1,8 +1,8 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.*
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import java.time.ZonedDateTime import java.time.ZonedDateTime
import java.util.ArrayList import java.util.ArrayList
import java.util.Formatter import java.util.Formatter
import java.util.regex.Pattern import java.util.regex.Pattern
@@ -23,11 +23,6 @@ internal object CommandInterpreter {
"tips" "tips"
) )
private val ccW = 0.toChar()//GameFontBase.colToCode["w"]
private val ccG = 0.toChar()//GameFontBase.colToCode["g"]
private val ccY = 0.toChar()//GameFontBase.colToCode["y"]
private val ccR = 0.toChar()//GameFontBase.colToCode["r"]
internal fun execute(command: String) { internal fun execute(command: String) {
val cmd: Array<CommandInput?> = parse(command) val cmd: Array<CommandInput?> = parse(command)

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.*
import net.torvald.terrarum.TerrarumGDX import net.torvald.terrarum.TerrarumGDX
/** /**
@@ -7,13 +8,6 @@ import net.torvald.terrarum.TerrarumGDX
*/ */
internal object GetAV : ConsoleCommand { internal object GetAV : ConsoleCommand {
val ccW = 0.toChar()//GameFontBase.colToCode["w"]
val ccG = 0.toChar()//GameFontBase.colToCode["g"]
val ccY = 0.toChar()//GameFontBase.colToCode["y"]
val ccM = 0.toChar()//GameFontBase.colToCode["m"]
val ccK = 0.toChar()//GameFontBase.colToCode["k"]
val ccO = 0.toChar()//GameFontBase.colToCode["o"]
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
try { try {
if (args.size == 1 && TerrarumGDX.ingame!!.player != null) { if (args.size == 1 && TerrarumGDX.ingame!!.player != null) {

View File

@@ -1,14 +1,12 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.*
import net.torvald.terrarum.TerrarumGDX import net.torvald.terrarum.TerrarumGDX
/** /**
* Created by minjaesong on 16-06-16. * Created by minjaesong on 16-06-16.
*/ */
internal object Seed : ConsoleCommand { internal object Seed : ConsoleCommand {
val ccG = 0.toChar()//GameFontBase.colToCode["g"]
val ccW = 0.toChar()//GameFontBase.colToCode["w"]
val ccY = 0.toChar()//GameFontBase.colToCode["y"]
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
Echo("Map$ccW: $ccG${TerrarumGDX.ingame!!.world.generatorSeed}") Echo("Map$ccW: $ccG${TerrarumGDX.ingame!!.world.generatorSeed}")

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.*
import net.torvald.terrarum.TerrarumGDX import net.torvald.terrarum.TerrarumGDX
/** /**
@@ -7,12 +8,6 @@ import net.torvald.terrarum.TerrarumGDX
*/ */
internal object SetAV : ConsoleCommand { internal object SetAV : ConsoleCommand {
val ccW = 0.toChar()//GameFontBase.colToCode["w"]
val ccG = 0.toChar()//GameFontBase.colToCode["g"]
val ccY = 0.toChar()//GameFontBase.colToCode["y"]
val ccR = 0.toChar()//GameFontBase.colToCode["r"]
val ccM = 0.toChar()//GameFontBase.colToCode["m"]
override fun printUsage() { override fun printUsage() {
Echo("${ccW}Set actor value of specific target to desired value.") Echo("${ccW}Set actor value of specific target to desired value.")
Echo("${ccW}Usage: ${ccY}setav ${ccG}(id) <av> <val>") Echo("${ccW}Usage: ${ccY}setav ${ccG}(id) <av> <val>")

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.debuggerapp package net.torvald.terrarum.debuggerapp
import net.torvald.terrarum.*
import net.torvald.terrarum.gameactors.ActorValue import net.torvald.terrarum.gameactors.ActorValue
import net.torvald.terrarum.TerrarumGDX import net.torvald.terrarum.TerrarumGDX
import net.torvald.terrarum.console.Echo import net.torvald.terrarum.console.Echo
@@ -74,7 +75,7 @@ class ActorValueTracker constructor() : JFrame() {
override fun mousePressed(e: MouseEvent?) { override fun mousePressed(e: MouseEvent?) {
if (actorValue != null && modavInputKey.text.isNotBlank()) { if (actorValue != null && modavInputKey.text.isNotBlank()) {
actorValue!!.remove(modavInputKey.text) actorValue!!.remove(modavInputKey.text)
Echo("${SetAV.ccW}Removed ${SetAV.ccM}${modavInputKey.text} ${SetAV.ccW}of ${SetAV.ccY}${actor!!.referenceID}") Echo("${ccW}Removed ${ccM}${modavInputKey.text} ${ccW}of ${ccY}${actor!!.referenceID}")
println("[ActorValueTracker] Removed ActorValue '${modavInputKey.text}' of $actor") println("[ActorValueTracker] Removed ActorValue '${modavInputKey.text}' of $actor")
} }
} }

View File

@@ -103,9 +103,13 @@ object GameController : InputAdapter() {
ingame.uiContainer.forEach { it.keyDown(keycode) } // for KeyboardControlled UIcanvases ingame.uiContainer.forEach { it.keyDown(keycode) } // for KeyboardControlled UIcanvases
// Debug UIs
if (keycode == Input.Keys.F3) { if (keycode == Input.Keys.F3) {
ingame.debugWindow.toggleOpening() ingame.debugWindow.toggleOpening()
} }
if (keycode == Input.Keys.GRAVE) {
ingame.consoleHandler.toggleOpening()
}
return true return true

View File

@@ -4,14 +4,14 @@ import com.badlogic.gdx.Gdx
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 com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.terrarum.*
import net.torvald.terrarum.worlddrawer.LightmapRenderer import net.torvald.terrarum.worlddrawer.LightmapRenderer
import net.torvald.terrarum.worlddrawer.FeaturesDrawer import net.torvald.terrarum.worlddrawer.FeaturesDrawer
import net.torvald.terrarum.TerrarumGDX
import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.blendScreen
import net.torvald.terrarum.fillRect
import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.terrarumsansbitmap.gdx.GameFontBase import net.torvald.terrarumsansbitmap.gdx.GameFontBase
import net.torvald.terrarum.TerrarumGDX.mouseTileX
import net.torvald.terrarum.TerrarumGDX.mouseTileY
import net.torvald.terrarum.TerrarumGDX.mouseScreenX
import net.torvald.terrarum.TerrarumGDX.mouseScreenY
/** /**
* Created by minjaesong on 16-03-14. * Created by minjaesong on 16-03-14.
@@ -31,19 +31,6 @@ 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 = GameFontBase.toColorCode(0xFFFF)
val ccY = GameFontBase.toColorCode(0xFE8F)
val ccO = GameFontBase.toColorCode(0xFB2F)
val ccR = GameFontBase.toColorCode(0xF88F)
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)
override fun update(delta: Float) { override fun update(delta: Float) {
@@ -64,9 +51,6 @@ class BasicDebugInfoWindow : UICanvas {
val player = TerrarumGDX.ingame!!.player val player = TerrarumGDX.ingame!!.player
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()
batch.color = Color(0xFFEE88FF.toInt()) batch.color = Color(0xFFEE88FF.toInt())
val hitbox = player?.hitbox val hitbox = player?.hitbox

View File

@@ -123,11 +123,18 @@ class ConsoleWindow : UICanvas, KeyControlled {
return true return true
} }
override fun keyTyped(character: Char): Boolean { val acceptedChars = "1234567890-=qwfpgjluy;[]\\arstdhneio'zxcvbkm,./!@#$%^&*()_+QWFPGJLUY:{}|ARSTDHNEIO\"ZXCVBKM<>? ".toSet()
commandInputPool!!.append(character)
inputCursorPos += 1
return true override fun keyTyped(character: Char): Boolean {
if (character in acceptedChars) {
commandInputPool!!.append(character)
inputCursorPos += 1
return true
}
else {
return false
}
} }
override fun keyUp(keycode: Int): Boolean { override fun keyUp(keycode: Int): Boolean {

View File

@@ -352,8 +352,7 @@ object BlocksDrawer {
*/ */
blendNormal() blendNormal()
batch.color = wallOverlayColour drawTiles(batch, WALL, false, wallOverlayColour)
drawTiles(batch, WALL, false)
} }
fun renderTerrain(batch: SpriteBatch) { fun renderTerrain(batch: SpriteBatch) {
@@ -362,8 +361,7 @@ object BlocksDrawer {
*/ */
blendNormal() blendNormal()
batch.color = Color.WHITE drawTiles(batch, TERRAIN, false, Color.WHITE) // regular tiles
drawTiles(batch, TERRAIN, false) // regular tiles
} }
fun renderFront(batch: SpriteBatch, drawWires: Boolean) { fun renderFront(batch: SpriteBatch, drawWires: Boolean) {
@@ -372,11 +370,10 @@ object BlocksDrawer {
*/ */
blendMul() blendMul()
batch.color = Color.WHITE drawTiles(batch, TERRAIN, true, Color.WHITE) // blendmul tiles
drawTiles(batch, TERRAIN, true) // blendmul tiles
if (drawWires) { if (drawWires) {
drawTiles(batch, WIRE, false) drawTiles(batch, WIRE, false, Color.WHITE)
} }
blendNormal() blendNormal()
@@ -384,7 +381,7 @@ object BlocksDrawer {
private val tileDrawLightThreshold = 2 private val tileDrawLightThreshold = 2
private fun drawTiles(batch: SpriteBatch, mode: Int, drawModeTilesBlendMul: Boolean) { private fun drawTiles(batch: SpriteBatch, mode: Int, drawModeTilesBlendMul: Boolean, color: Color) {
val for_y_start = y / TILE_SIZE val for_y_start = y / TILE_SIZE
val for_y_end = BlocksDrawer.clampHTile(for_y_start + (height / TILE_SIZE) + 2) val for_y_end = BlocksDrawer.clampHTile(for_y_start + (height / TILE_SIZE) + 2)
@@ -393,6 +390,8 @@ object BlocksDrawer {
var zeroTileCounter = 0 var zeroTileCounter = 0
batch.color = color
// loop // loop
for (y in for_y_start..for_y_end) { for (y in for_y_start..for_y_end) {
for (x in for_x_start..for_x_end - 1) { for (x in for_x_start..for_x_end - 1) {
@@ -490,7 +489,7 @@ object BlocksDrawer {
batch.fillRect(x.toFloat(), y.toFloat(), TILE_SIZEF, TILE_SIZEF) batch.fillRect(x.toFloat(), y.toFloat(), TILE_SIZEF, TILE_SIZEF)
batch.color = Color.WHITE batch.color = color
} }
} // end if (not an air) } // end if (not an air)
} catch (e: NullPointerException) { } catch (e: NullPointerException) {

View File

@@ -320,6 +320,8 @@ object LightmapRenderer {
val this_y_end = for_y_end// + overscan_open val this_y_end = for_y_end// + overscan_open
val originalColour = batch.color.cpy()
// draw to the // draw to the
try { try {
// loop for "scanlines" // loop for "scanlines"
@@ -329,7 +331,7 @@ object LightmapRenderer {
while (x < this_x_end) { while (x < this_x_end) {
// smoothing enabled and zoom is 0.75 or greater // smoothing enabled and zoom is 0.75 or greater
// (zoom of 0.5 should not smoothed, for performance) // (zoom of 0.5 should not smoothed, for performance)
if (TerrarumGDX.getConfigBoolean("smoothlighting") ?: false && if (TerrarumGDX.getConfigBoolean("smoothlighting") &&
TerrarumGDX.ingame!!.screenZoom >= 0.75) { TerrarumGDX.ingame!!.screenZoom >= 0.75) {
val thisLightLevel = getLightForOpaque(x, y) ?: 0 val thisLightLevel = getLightForOpaque(x, y) ?: 0
@@ -435,6 +437,8 @@ object LightmapRenderer {
} }
batch.color = originalColour
} }
val lightScalingMagic = 8f val lightScalingMagic = 8f