inventory UI: quickslot designation

Former-commit-id: b2bddf7c271c678213f8f346d1de4b5c1dc27f60
This commit is contained in:
Song Minjae
2017-03-26 00:42:41 +09:00
parent b6290134a9
commit 816502df3d
29 changed files with 137 additions and 93 deletions

View File

@@ -54,26 +54,26 @@ open class GameFontBase : Font {
9
}
private fun isHangul(c: Char) = c.toInt() >= 0xAC00 && c.toInt() < 0xD7A4
private fun isAscii(c: Char) = c.toInt() >= 0x20 && c.toInt() <= 0xFF
private fun isHangul(c: Char) = c.toInt() in 0xAC00..0xD7A3
private fun isAscii(c: Char) = c.toInt() in 0x20..0xFF
private fun isRunic(c: Char) = runicList.contains(c)
private fun isExtA(c: Char) = c.toInt() >= 0x100 && c.toInt() < 0x180
private fun isExtB(c: Char) = c.toInt() >= 0x180 && c.toInt() < 0x250
private fun isKana(c: Char) = c.toInt() >= 0x3040 && c.toInt() < 0x3100
private fun isCJKPunct(c: Char) = c.toInt() >= 0x3000 && c.toInt() < 0x3040
private fun isUniHan(c: Char) = c.toInt() >= 0x3400 && c.toInt() < 0xA000
private fun isCyrilic(c: Char) = c.toInt() >= 0x400 && c.toInt() < 0x460
private fun isFullwidthUni(c: Char) = c.toInt() >= 0xFF00 && c.toInt() < 0xFF20
private fun isUniPunct(c: Char) = c.toInt() >= 0x2000 && c.toInt() < 0x2070
private fun isWenQuanYi1(c: Char) = c.toInt() >= 0x33F3 && c.toInt() <= 0x69FC
private fun isWenQuanYi2(c: Char) = c.toInt() >= 0x69FD && c.toInt() <= 0x9FDC
private fun isGreek(c: Char) = c.toInt() >= 0x370 && c.toInt() <= 0x3CE
private fun isThai(c: Char) = c.toInt() >= 0xE00 && c.toInt() <= 0xE7F
private fun isThaiDiacritics(c: Char) = (c.toInt() >= 0xE34 && c.toInt() <= 0xE3A)
|| (c.toInt() >= 0xE47 && c.toInt() <= 0xE4E)
|| (c.toInt() == 0xE31)
private fun isExtA(c: Char) = c.toInt() in 0x100..0x17F
private fun isExtB(c: Char) = c.toInt() in 0x180..0x24F
private fun isKana(c: Char) = c.toInt() in 0x3040..0x30FF
private fun isCJKPunct(c: Char) = c.toInt() in 0x3000..0x303F
private fun isUniHan(c: Char) = c.toInt() in 0x3400..0x9FFF
private fun isCyrilic(c: Char) = c.toInt() in 0x400..0x45F
private fun isFullwidthUni(c: Char) = c.toInt() in 0xFF00..0xFF1F
private fun isUniPunct(c: Char) = c.toInt() in 0x2000..0x206F
private fun isWenQuanYi1(c: Char) = c.toInt() in 0x33F3..0x69FC
private fun isWenQuanYi2(c: Char) = c.toInt() in 0x69FD..0x9FDC
private fun isGreek(c: Char) = c.toInt() in 0x370..0x3CE
private fun isThai(c: Char) = c.toInt() in 0xE00..0xE7F
private fun isThaiDiacritics(c: Char) = c.toInt() in 0xE34..0xE3A
|| c.toInt() in 0xE47..0xE4E
|| c.toInt() == 0xE31
private fun isThaiEF(c: Char) = c.toInt() == 0xE40
private fun isKeycap(c: Char) = c.toInt() >= 0xE000 && c.toInt() <= 0xE07F
private fun isKeycap(c: Char) = c.toInt() in 0xE000..0xE0FF
@@ -147,15 +147,14 @@ open class GameFontBase : Font {
val chr = s[i]
val ctype = getSheetType(s[i])
if (chr.toInt() == 0x21B) // Romanian t; HAX!
len += 6
else if (variableWidthSheets.contains(ctype)) {
try {
len += asciiWidths[chr.toInt()]!!
if (variableWidthSheets.contains(ctype)) {
len += try {
asciiWidths[chr.toInt()]!!
}
catch (e: kotlin.KotlinNullPointerException) {
println("KotlinNullPointerException on glyph number ${Integer.toHexString(chr.toInt()).toUpperCase()}")
System.exit(1)
//System.exit(1)
W_LATIN_WIDE // failsafe
}
}
else if (zeroWidthSheets.contains(ctype))
@@ -219,17 +218,17 @@ open class GameFontBase : Font {
hangulSheet.getSubImage(indexCho, choRow).drawWithShadow(
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f).toFloat(),
Math.round(y).toFloat(),
scale.toFloat(), thisCol
)
hangulSheet.getSubImage(indexJung, jungRow).drawWithShadow(
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f).toFloat(),
Math.round(y).toFloat(),
scale.toFloat(), thisCol
)
hangulSheet.getSubImage(indexJong, jongRow).drawWithShadow(
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f).toFloat(),
Math.round(y).toFloat(),
scale.toFloat(), thisCol
)
}
@@ -379,9 +378,8 @@ open class GameFontBase : Font {
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
// to deal with the height difference of the sheets
Math.round(y).toFloat() + (if (prevInstance == SHEET_CJK_PUNCT) -1 // height hack
else if (prevInstance == SHEET_FW_UNI) (H - H_HANGUL) / 2 // completely legit height adjustment
else if (prevInstance == SHEET_KEYCAP) (H - SIZE_KEYCAP) / 2 // completely legit height adjustment
Math.round(y).toFloat() +
(if (prevInstance == SHEET_KEYCAP) (H - SIZE_KEYCAP) / 2 // completely legit height adjustment
else 0).toFloat(),
scale.toFloat(), thisCol
@@ -525,9 +523,7 @@ open class GameFontBase : Font {
internal val W_LATIN_WIDE = 9 // width of regular letters
internal val H = 20
internal val H_HANGUL = 16
internal val H_UNIHAN = 16
internal val H_KANA = 20
internal val SIZE_KEYCAP = 18
@@ -572,8 +568,8 @@ open class GameFontBase : Font {
*/
internal val runicList = arrayOf('ᚠ', 'ᚢ', 'ᚦ', 'ᚬ', 'ᚱ', 'ᚴ', 'ᚼ', 'ᚾ', '', 'ᛅ', 'ᛋ', 'ᛏ', 'ᛒ', 'ᛘ', 'ᛚ', 'ᛦ', 'ᛂ', '', '᛫', '', 'ᛮ', 'ᛯ', 'ᛰ')
internal var interchar = 0
internal var scale = 1
var interchar = 0
var scale = 1
set(value) {
if (value > 0) field = value
else throw IllegalArgumentException("Font scale cannot be zero or negative (input: $value)")

View File

@@ -11,7 +11,7 @@ class GameFontImpl : GameFontBase() {
init {
GameFontBase.hangulSheet = SpriteSheet(
"./assets/graphics/fonts/hangul_johab.tga", GameFontBase.W_HANGUL, GameFontBase.H_HANGUL)
"./assets/graphics/fonts/hangul_johab.tga", GameFontBase.W_HANGUL, GameFontBase.H)
GameFontBase.asciiSheet = SpriteSheet(
"./assets/graphics/fonts/ascii_variable.tga", 15, 19, 1)
GameFontBase.runicSheet = SpriteSheet(
@@ -21,9 +21,9 @@ class GameFontImpl : GameFontBase() {
GameFontBase.extBSheet = SpriteSheet(
"./assets/graphics/fonts/LatinExtB_variable.tga", 15, 19, 1)
GameFontBase.kanaSheet = SpriteSheet(
"./assets/graphics/fonts/kana.tga", GameFontBase.W_KANA, GameFontBase.H_KANA)
"./assets/graphics/fonts/kana.tga", GameFontBase.W_KANA, GameFontBase.H)
GameFontBase.cjkPunct = SpriteSheet(
"./assets/graphics/fonts/cjkpunct.tga", GameFontBase.W_ASIAN_PUNCT, GameFontBase.H_KANA)
"./assets/graphics/fonts/cjkpunct.tga", GameFontBase.W_ASIAN_PUNCT, GameFontBase.H)
/*uniHan = new SpriteSheet(
"./assets/graphics/fonts/unifont_unihan"
+ ((!terrarum.gameLocale.contains("zh"))
@@ -82,6 +82,7 @@ class GameFontImpl : GameFontBase() {
}
fun reload() {
GameFontBase.cyrilic.destroy()
GameFontBase.cyrilic = SpriteSheet(
when (Terrarum.gameLocale.substring(0..1)) {
"bg" -> "./assets/graphics/fonts/cyrilic_bulgarian_variable.tga"

View File

@@ -10,19 +10,16 @@ import org.newdawn.slick.SpriteSheet
class NewRunes : Font {
private val runeSize = 12
private val encPlane = IntArray(128, {
if (it < 0x20)
0x20 + it
else if (it < 0x30)
0x3000 + (it - 0x20)
// hard-coded encode map
private fun codeToEnc(code: Int): Int? = if (code in 0x21..0x3f)
code - 0x20
else if (code in 0x3001..0x300f)
code - 0x3000 + 0x20
else if (code in 0x3131..0x3163)
code - 0x3130 + 0x30
else
0x3130 + (it - 0x30)
})
null
private fun codeToEnc(c: Char): Int? {
val result = encPlane.binarySearch(c.toInt())
return if (result >= 0) result else null
}
private val runes = SpriteSheet("./assets/graphics/fonts/newrunes.tga", runeSize, runeSize)
@@ -36,7 +33,7 @@ class NewRunes : Font {
override fun drawString(x: Float, y: Float, text: String, col: Color) {
text.forEachIndexed { index, c ->
val encodePoint = codeToEnc(c)
val encodePoint = codeToEnc(c.toInt())
if (encodePoint != null) {
runes.getSubImage(encodePoint % 16, encodePoint / 16).draw(