new small number font, fix on histogram drawing and torch drawing (now less likely to stick on wall)

Former-commit-id: 04d20ca0bf3c48152234073eb6875512450b942f
Former-commit-id: bde21ffce1581885cc449143c2f72932837f3c57
This commit is contained in:
Song Minjae
2016-04-15 19:38:04 +09:00
parent a903c629ec
commit f0d2415906
6 changed files with 38 additions and 43 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

View File

@@ -619,8 +619,7 @@ object LightmapRenderer {
val GREEN = 1 val GREEN = 1
val BLUE = 2 val BLUE = 2
val screen_tiles: Int val screen_tiles: Int = (for_x_end - for_x_start + 2) * (for_y_end - for_y_start + 2)
get() = (for_x_end - for_x_start + 2) * (for_y_end - for_y_start + 2)
val brightest: Int val brightest: Int
get() { get() {
@@ -645,20 +644,7 @@ object LightmapRenderer {
return CHANNEL_MAX return CHANNEL_MAX
} }
val histogramMax: Int val range: Int = CHANNEL_MAX
get() {
var max = 0
for (c in 0..2) {
for (i in 0..CHANNEL_MAX) {
val value = get(c)[i]
if (value > max) max = value
}
}
return max
}
val range: Int
get() = reds.size
fun get(index: Int): IntArray { fun get(index: Int): IntArray {
return when (index) { return when (index) {

View File

@@ -392,25 +392,28 @@ object MapCamera {
nearbyTiles[NEARBY_TILE_KEY_BACK] = map.getTileFrom(WALL, x, y) ?: 4096 nearbyTiles[NEARBY_TILE_KEY_BACK] = map.getTileFrom(WALL, x, y) ?: 4096
try { try {
if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_RIGHT]).isSolid if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_DOWN]).isSolid)
&& TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_LEFT]).isSolid) { // has tile on the bottom
if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_BACK]).isSolid) return 3
return 0 else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_RIGHT]).isSolid
else && TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_LEFT]).isSolid)
return 3 // has tile on both sides
} else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_RIGHT]).isSolid) {
return 2
} else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_LEFT]).isSolid) {
return 1
} else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_BACK]).isSolid) {
return 0 return 0
} else else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_RIGHT]).isSolid)
// has tile on the right
return 2
else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_LEFT]).isSolid)
// has tile on the left
return 1
else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_BACK]).isSolid)
// has tile on the back
return 0
else
return 3 return 3
} catch (e: ArrayIndexOutOfBoundsException) { } catch (e: ArrayIndexOutOfBoundsException) {
return if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_BACK]).isSolid) return if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_DOWN]).isSolid)
0 // has tile on the bottom
else 3 else 0
3
} }
} }

View File

@@ -166,7 +166,10 @@ class BasicDebugInfoWindow : UICanvas {
Lang["DEV_COLOUR_LEGEND_BLUE"] + " : nextHitbox", (Terrarum.WIDTH - 200).toFloat() Lang["DEV_COLOUR_LEGEND_BLUE"] + " : nextHitbox", (Terrarum.WIDTH - 200).toFloat()
, line(3).toFloat()) , line(3).toFloat())
drawHistogram(g, LightmapRenderer.histogram, Terrarum.WIDTH - 256 - 30, Terrarum.HEIGHT - 100 - 30) drawHistogram(g, LightmapRenderer.histogram,
Terrarum.WIDTH - histogramW - 30,
Terrarum.HEIGHT - histogramH - 30
)
} }
private fun printLine(g: Graphics, l: Int, s: String) { private fun printLine(g: Graphics, l: Int, s: String) {
@@ -177,17 +180,19 @@ class BasicDebugInfoWindow : UICanvas {
g.drawString(s, (20 + column(col)).toFloat(), line(row).toFloat()) g.drawString(s, (20 + column(col)).toFloat(), line(row).toFloat())
} }
val histogramW = 256
val histogramH = 200
private fun drawHistogram(g: Graphics, histogram: LightmapRenderer.Histogram, x: Int, y: Int) { private fun drawHistogram(g: Graphics, histogram: LightmapRenderer.Histogram, x: Int, y: Int) {
val uiColour = Color(0x99000000.toInt()) val uiColour = Color(0xAA000000.toInt())
val barR = Color(0xFF0000.toInt()) val barR = Color(0xDD0000.toInt())
val barG = Color(0x00FF00.toInt()) val barG = Color(0x00DD00.toInt())
val barB = Color(0x0000FF.toInt()) val barB = Color(0x0000DD.toInt())
val barColour = arrayOf(barR, barG, barB) val barColour = arrayOf(barR, barG, barB)
val w = 256.toFloat() val w = histogramW.toFloat()
val h = 100.toFloat() val h = histogramH.toFloat()
val range = histogram.range val range = histogram.range
val histogramMax = histogram.screen_tiles val histogramMax = histogram.screen_tiles.toFloat()
//val histogramMax = histogram.histogramMax
g.color = uiColour g.color = uiColour
g.fillRect(x.toFloat(), y.toFloat(), w.plus(1).toFloat(), h.toFloat()) g.fillRect(x.toFloat(), y.toFloat(), w.plus(1).toFloat(), h.toFloat())
@@ -203,9 +208,10 @@ class BasicDebugInfoWindow : UICanvas {
} }
val bar_x = x + (w / w.minus(1).toFloat()) * i.toFloat() val bar_x = x + (w / w.minus(1).toFloat()) * i.toFloat()
val bar_h = FastMath.ceil(h / histogramMax.toFloat()) * histogram_value.toFloat() val bar_h = FastMath.ceil(h / histogramMax * histogram_value.toFloat()).toFloat()
val bar_y = y + (h / histogramMax.toFloat()) - bar_h + h val bar_y = y + (h / histogramMax) - bar_h + h
val bar_w = 1f val bar_w = 1f
g.color = barColour[c] g.color = barColour[c]
g.fillRect(bar_x, bar_y, bar_w, bar_h) g.fillRect(bar_x, bar_y, bar_w, bar_h)
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

View File

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 230 B