more work on the Terminal, ComputerCraft compatibility layer (wip), quarried stone texture

Former-commit-id: 1fd1b5ce05663dd41d6077077b64e08ac0f1b5a0
Former-commit-id: bd52729417fc4dfcd8ad11f00d34507943156a83
This commit is contained in:
Song Minjae
2016-09-16 20:49:46 +09:00
parent abf167d6b8
commit a0afc8ab7a
37 changed files with 897 additions and 128 deletions

View File

@@ -15,7 +15,7 @@ class TinyAlphNum : Font {
internal val W = 8
internal val H = 8
private val chars = arrayOf(
/*private val chars = arrayOf(
'0','1','2','3','4','5','6','7',
'8','9','[','#','@',':','>','?',
' ','A','B','C','D','E','F','G',
@@ -25,11 +25,11 @@ class TinyAlphNum : Font {
'+','/','S','T','U','V','W','X',
'Y','Z','_',',','%','=','"','!'
)
private val mappingTable = HashMap<Int, Int>()
private val mappingTable = HashMap<Int, Int>()*/
init {
fontSheet = SpriteSheet("./assets/graphics/fonts/alphanumeric_small.png", W, H)
chars.forEachIndexed { i, c -> mappingTable[c.toInt()] = i }
fontSheet = SpriteSheet("./assets/graphics/fonts/cp949.png", W, H)
//chars.forEachIndexed { i, c -> mappingTable[c.toInt()] = i }
}
override fun getHeight(str: String): Int = H
@@ -52,15 +52,29 @@ class TinyAlphNum : Font {
var thisCol = col
var textPosOffset = 0
for (i in 0..text.length - 1) {
val index = charToSpriteNum(text.toUpperCase().codePointAt(i))
//val index = charToSpriteNum(text.toUpperCase().codePointAt(i))
val ch = text[i]
val index = ch.toInt() and 0xFF
if (ch.isColourCode()) {
thisCol = GameFontBase.colourKey[ch]!!
continue
}
if (index != null) {
fontSheet.getSubImage(index % 8, index / 8).draw(
// shadow
fontSheet.getSubImage(index % 16, index / 16).draw(
x + textPosOffset + 1, y, thisCol.darker(0.5f)
)
fontSheet.getSubImage(index % 16, index / 16).draw(
x + textPosOffset + 1, y + 1, thisCol.darker(0.5f)
)
fontSheet.getSubImage(index % 16, index / 16).draw(
x + textPosOffset, y + 1, thisCol.darker(0.5f)
)
// main
fontSheet.getSubImage(index % 16, index / 16).draw(
x + textPosOffset, y, thisCol
)
}
@@ -72,7 +86,7 @@ class TinyAlphNum : Font {
throw UnsupportedOperationException()
}
private fun charToSpriteNum(ch: Int): Int? = mappingTable[ch]
//private fun charToSpriteNum(ch: Int): Int? = mappingTable[ch]
fun Char.isColourCode() = GameFontBase.colourKey.containsKey(this)
}