From f0d2415906cdef4ffd5637168a2c2622e52c986c Mon Sep 17 00:00:00 2001 From: Song Minjae Date: Fri, 15 Apr 2016 19:38:04 +0900 Subject: [PATCH] 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 --- res/graphics/fonts/numeric_small.png | Bin 0 -> 983 bytes .../terrarum/mapdrawer/LightmapRenderer.kt | 18 +-------- .../torvald/terrarum/mapdrawer/MapCamera.kt | 35 ++++++++++-------- .../terrarum/ui/BasicDebugInfoWindow.kt | 28 ++++++++------ work_files/graphics/fonts/numeric_small.png | Bin 0 -> 983 bytes .../graphics/fonts/numeric_small_old.png | Bin 6 files changed, 38 insertions(+), 43 deletions(-) create mode 100644 res/graphics/fonts/numeric_small.png create mode 100644 work_files/graphics/fonts/numeric_small.png rename res/graphics/fonts/number_small.png => work_files/graphics/fonts/numeric_small_old.png (100%) diff --git a/res/graphics/fonts/numeric_small.png b/res/graphics/fonts/numeric_small.png new file mode 100644 index 0000000000000000000000000000000000000000..851d2bc46e3e78238e378cf23bb779febdd6a438 GIT binary patch literal 983 zcmeAS@N?(olHy`uVBq!ia0vp^0YJ>b!3-oLg*sRn7?>FXd_r9R|NmcJUJfLI;-g?R z1V&m2@SK0}0O)7tk|4ieU?#YJiq{dyZT56=45_%48raBtz<@*OzkOAr>y>LunEC{- zyRvc5TplfTGfS@G%U>mFhc@H(l!q2NtlRpT?bV+jymd6EZEfUL4wHK3W@U-gxbQ^v z+Di&HjYW?4-zo5|b)B>Qy~Z@h+abL2&qPb2Lj max) max = value - } - } - return max - } - - val range: Int - get() = reds.size + val range: Int = CHANNEL_MAX fun get(index: Int): IntArray { return when (index) { diff --git a/src/net/torvald/terrarum/mapdrawer/MapCamera.kt b/src/net/torvald/terrarum/mapdrawer/MapCamera.kt index 33e7948a7..38b3830b0 100644 --- a/src/net/torvald/terrarum/mapdrawer/MapCamera.kt +++ b/src/net/torvald/terrarum/mapdrawer/MapCamera.kt @@ -392,25 +392,28 @@ object MapCamera { nearbyTiles[NEARBY_TILE_KEY_BACK] = map.getTileFrom(WALL, x, y) ?: 4096 try { - if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_RIGHT]).isSolid - && TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_LEFT]).isSolid) { - if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_BACK]).isSolid) - return 0 - else - return 3 - } 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) { + if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_DOWN]).isSolid) + // has tile on the bottom + return 3 + else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_RIGHT]).isSolid + && TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_LEFT]).isSolid) + // has tile on both sides 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 } catch (e: ArrayIndexOutOfBoundsException) { - return if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_BACK]).isSolid) - 0 - else - 3 + return if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_DOWN]).isSolid) + // has tile on the bottom + 3 else 0 } } diff --git a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt index b42eb8cb0..507c70dd7 100644 --- a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt +++ b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt @@ -166,7 +166,10 @@ class BasicDebugInfoWindow : UICanvas { Lang["DEV_COLOUR_LEGEND_BLUE"] + " : nextHitbox", (Terrarum.WIDTH - 200).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) { @@ -177,17 +180,19 @@ class BasicDebugInfoWindow : UICanvas { 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) { - val uiColour = Color(0x99000000.toInt()) - val barR = Color(0xFF0000.toInt()) - val barG = Color(0x00FF00.toInt()) - val barB = Color(0x0000FF.toInt()) + val uiColour = Color(0xAA000000.toInt()) + val barR = Color(0xDD0000.toInt()) + val barG = Color(0x00DD00.toInt()) + val barB = Color(0x0000DD.toInt()) val barColour = arrayOf(barR, barG, barB) - val w = 256.toFloat() - val h = 100.toFloat() + val w = histogramW.toFloat() + val h = histogramH.toFloat() val range = histogram.range - val histogramMax = histogram.screen_tiles - //val histogramMax = histogram.histogramMax + val histogramMax = histogram.screen_tiles.toFloat() g.color = uiColour 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_h = FastMath.ceil(h / histogramMax.toFloat()) * histogram_value.toFloat() - val bar_y = y + (h / histogramMax.toFloat()) - bar_h + h + val bar_h = FastMath.ceil(h / histogramMax * histogram_value.toFloat()).toFloat() + val bar_y = y + (h / histogramMax) - bar_h + h val bar_w = 1f + g.color = barColour[c] g.fillRect(bar_x, bar_y, bar_w, bar_h) } diff --git a/work_files/graphics/fonts/numeric_small.png b/work_files/graphics/fonts/numeric_small.png new file mode 100644 index 0000000000000000000000000000000000000000..851d2bc46e3e78238e378cf23bb779febdd6a438 GIT binary patch literal 983 zcmeAS@N?(olHy`uVBq!ia0vp^0YJ>b!3-oLg*sRn7?>FXd_r9R|NmcJUJfLI;-g?R z1V&m2@SK0}0O)7tk|4ieU?#YJiq{dyZT56=45_%48raBtz<@*OzkOAr>y>LunEC{- zyRvc5TplfTGfS@G%U>mFhc@H(l!q2NtlRpT?bV+jymd6EZEfUL4wHK3W@U-gxbQ^v z+Di&HjYW?4-zo5|b)B>Qy~Z@h+abL2&qPb2Lj