font update/ime fix

This commit is contained in:
minjaesong
2023-06-06 18:15:55 +09:00
parent eb2c716691
commit 8d0d84fbf8
17 changed files with 50 additions and 41 deletions

Binary file not shown.

View File

@@ -241,6 +241,7 @@ object IME {
TerrarumIMEConf(name, copying, lang, candidatesCount, if (keysymtable == null) keysyms else null, if (keysymtable == null) null else keysymtable, mode),
{ headkey, shifted, alted, lowLayerKeysym ->
val a = jsval.invokeMember("accept", headkey, shifted, alted, lowLayerKeysym)
// println(a.getArrayElement(0).asString().map { it.code.toString(16) })
a.getArrayElement(0).asString().toCanditates() to a.getArrayElement(1).asString()
}, {
jsval.invokeMember("backspace").asString().toCanditates()

View File

@@ -29,7 +29,7 @@ class IMEDictionary(private val filename: String) {
private var dictLoaded = false
private fun loadDict() {
val reader = FileReader(File("assets/keylayout/", filename))
val reader = FileReader(File("assets/keylayout/", filename), Charsets.UTF_8)
reader.forEachLine {
if (it.contains(',')) {
val (key, value) = it.split(',')

View File

@@ -74,7 +74,7 @@ class Notification : UICanvas() {
message.forEachIndexed { index, s ->
val xoff = 6 + (displayedTextWidth - realTextWidth) / 2
val y = -textHeight + App.fontGame.lineHeight * index
App.fontGame.draw(batch, s, LRmargin + xoff, y)
App.fontGame.draw(batch, s, LRmargin + xoff, y )
}

View File

@@ -180,7 +180,7 @@ class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() {
else
drawX + width/2 - panelgap - labelWidth // right aligned at the middle of the panel, offsetted by panelgap
App.fontGame.draw(batch, label, xpos.toFloat(), drawY + optionsYpos[index].toFloat())
App.fontGame.draw(batch, label, xpos.toFloat(), drawY + optionsYpos[index] - 2f)
// draw hrule
if (mode == "h1") {

View File

@@ -350,7 +350,7 @@ private class UIItemInputKeycap(
batch.draw(labels.get(21,2), (posX + (width - 20) / 2).toFloat(), posY + 4f)
else {
val keysymw = App.fontGame.getWidth(keysym)
App.fontGame.draw(batch, keysym, posX + (width - keysymw) / 2, posY + 4)
App.fontGame.draw(batch, keysym, posX + (width - keysymw) / 2, posY + 2)
}
}

View File

@@ -416,17 +416,17 @@ class UIItemControlPaletteBaloon(val parent: UIKeyboardControlPanel, initialX: I
// texts. Sorted in the same way as UIItemControlPaletteBaloon.iconButtons
batch.color = Color.WHITE
App.fontGame.draw(batch, Lang["GAME_ACTION_MOVE_VERB"], col0 + 72, posY + 43)
App.fontGame.draw(batch, Lang["GAME_ACTION_JUMP"], col1 + 40, posY + 43)
App.fontGame.draw(batch, Lang["GAME_ACTION_MOVE_VERB"], col0 + 72, posY + 41)
App.fontGame.draw(batch, Lang["GAME_ACTION_JUMP"], col1 + 40, posY + 41)
App.fontGame.draw(batch, Lang["GAME_INVENTORY"], col0 + 40, row1)
App.fontGame.draw(batch, Lang["GAME_CRAFTING"], col0 + 40, row2)
App.fontGame.draw(batch, Lang["GAME_ACTION_GRAPPLE"], col0 + 40, row3)
App.fontGame.draw(batch, Lang["GAME_ACTION_QUICKSEL"], col0 + 40, row4)
App.fontGame.draw(batch, Lang["GAME_INVENTORY"], col0 + 40, row1 - 2)
App.fontGame.draw(batch, Lang["GAME_CRAFTING"], col0 + 40, row2 - 2)
App.fontGame.draw(batch, Lang["GAME_ACTION_GRAPPLE"], col0 + 40, row3 - 2)
App.fontGame.draw(batch, Lang["GAME_ACTION_QUICKSEL"], col0 + 40, row4 - 2)
App.fontGame.draw(batch, Lang["GAME_ACTION_ZOOM"], col1 + 40, row1)
App.fontGame.draw(batch, Lang["MENU_LABEL_IME_TOGGLE"], col1 + 40, row2)
App.fontGame.draw(batch, Lang["MENU_LABEL_MENU"], col1 + 40, row3)
App.fontGame.draw(batch, Lang["GAME_ACTION_ZOOM"], col1 + 40, row1 - 2)
App.fontGame.draw(batch, Lang["MENU_LABEL_IME_TOGGLE"], col1 + 40, row2 - 2)
App.fontGame.draw(batch, Lang["MENU_LABEL_MENU"], col1 + 40, row3 - 2)
}

View File

@@ -636,10 +636,10 @@ class UIItemPlayerCells(
// texts
batch.color = highlightTextCol
val playTimeTextLen = App.fontGame.getWidth(totalPlayTime)
App.fontGame.draw(batch, playerName, x + 146f, y + height - 82f)
App.fontGame.draw(batch, worldName, x + 146f, y + height - 53f)
App.fontGame.draw(batch, lastPlayTime, x + 146f, y + height - 24f)
App.fontGame.draw(batch, totalPlayTime, x + width - 5f - playTimeTextLen, y + height - 24f)
App.fontGame.draw(batch, playerName, x + 146f, y + height - 84f)
App.fontGame.draw(batch, worldName, x + 146f, y + height - 55f)
App.fontGame.draw(batch, lastPlayTime, x + 146f, y + height - 26f)
App.fontGame.draw(batch, totalPlayTime, x + width - 5f - playTimeTextLen, y + height - 26f)
// icons
batch.draw(icons.get(24,0), x + 120f, y + height - 82f) // player name
batch.draw(icons.get(12,0), x + 119f, y + height - 53f) // world map
@@ -808,7 +808,7 @@ class UIItemWorldCells(
App.fontSmallNumbers.draw(batch, "${skimmer.diskFile.length().ushr(10)} KiB", x + 3f, y + height - 16f)
// savegame name
if (saveDamaged) batch.color = colourBad
App.fontGame.draw(batch, saveName, x + 3f, y + 1f)
App.fontGame.draw(batch, saveName, x + 3f, y + -1f)
super.render(batch, camera)
batch.color = Color.WHITE

View File

@@ -35,10 +35,10 @@ class UITooltip : UICanvas() {
val textMarginX = 4
override var width: Int
get() = msgWidth + (textMarginX + Toolkit.baloonTile.tileW) * 2
get() = msgWidth + (textMarginX + 36) * 2
set(value) { throw Error("You are not supposed to set the width of the tooltip manually.") }
override var height: Int
get() = Toolkit.baloonTile.tileH * 2 + font.lineHeight.toInt()
get() = 36 * 2 + font.lineHeight.toInt()
set(value) { throw Error("You are not supposed to set the height of the tooltip manually.") }
override fun renderUI(batch: SpriteBatch, camera: Camera) {

View File

@@ -387,9 +387,9 @@ class UIItemWorldCellsSimple(
// draw texts
batch.color = tcol
batch.draw(icons.get(0, 1), posX + 4f, posY + 1f)
App.fontGame.draw(batch, worldName ?: "$EMDASH", posX + 32, posY + 1)
App.fontGame.draw(batch, worldName ?: "$EMDASH", posX + 32, posY - 1)
batch.draw(icons.get(1, 1), posX + 4f, posY + 25f)
App.fontGame.draw(batch, if (worldInfo?.seed == null) "$EMDASH" else "${(if (worldInfo.seed > 0) "+" else "")}${worldInfo.seed}" , posX + 32, posY + 25)
App.fontGame.draw(batch, if (worldInfo?.seed == null) "$EMDASH" else "${(if (worldInfo.seed > 0) "+" else "")}${worldInfo.seed}" , posX + 32, posY + 23)
// text separator
batch.color = bcol.cpy().sub(0f,0f,0f,0.65f)
Toolkit.fillArea(batch, posX + 2, posY + 23, width - 4, 1)

View File

@@ -21,6 +21,7 @@ object Toolkit : Disposable {
object Theme {
val COL_INVENTORY_CELL_BORDER = Color(1f, 1f, 1f, 0.25f)
val COL_CELL_FILL = Color(0x282828C8)
val COL_CELL_FILL_OPAQUE = Color(0x282828FF)
val COL_LIST_DEFAULT = Color.WHITE // white
val COL_INACTIVE = Color.LIGHT_GRAY
@@ -50,7 +51,7 @@ object Toolkit : Disposable {
private lateinit var blurWriteQuad2: Mesh
private lateinit var blurWriteQuad4: Mesh
val baloonTile = TextureRegionPack("assets/graphics/gui/message_black_tileable.tga", 36, 36)
// val baloonTile = TextureRegionPack("assets/graphics/gui/message_black_tileable.tga", 36, 36)
val textureWhiteSquare = Texture(Gdx.files.internal("assets/graphics/ortho_line_tex_2px.tga"))
val textureWhiteCircle = Texture(Gdx.files.internal("assets/graphics/circle_512.tga"))
@@ -70,7 +71,7 @@ object Toolkit : Disposable {
private val rng = HQRNG()
override fun dispose() {
baloonTile.dispose()
// baloonTile.dispose()
textureWhiteSquare.dispose()
textureWhiteCircle.dispose()
@@ -251,7 +252,7 @@ object Toolkit : Disposable {
fun drawBaloon(batch: SpriteBatch, x: Float, y: Float, w: Float, h: Float) {
// centre area
batch.draw(baloonTile.get(1, 1), x, y, w, h)
/*batch.draw(baloonTile.get(1, 1), x, y, w, h)
// edges
batch.draw(baloonTile.get(1, 0), x, y - baloonTile.tileH, w, baloonTile.tileH.toFloat())
@@ -263,7 +264,13 @@ object Toolkit : Disposable {
batch.draw(baloonTile.get(0, 0), x - baloonTile.tileW, y - baloonTile.tileH)
batch.draw(baloonTile.get(2, 0), x + w, y - baloonTile.tileH)
batch.draw(baloonTile.get(2, 2), x + w, y + h)
batch.draw(baloonTile.get(0, 2), x - baloonTile.tileW, y + h)
batch.draw(baloonTile.get(0, 2), x - baloonTile.tileW, y + h)*/
batch.color = Theme.COL_CELL_FILL_OPAQUE
fillArea(batch, x - 4, y - 4, w + 8, h + 8)
batch.color = Theme.COL_INACTIVE
drawBoxBorder(batch, x - 4, y - 4, w + 8, h + 8)
}
private var init = false

View File

@@ -72,7 +72,7 @@ class UIItemInlineRadioButtons(
val xpos = getCellX(i)
val text = labelfuns[i]()
val tw = App.fontGame.getWidth(text)
App.fontGame.draw(batch, text, xpos + (cellWidth - tw) / 2, posY + 2)
App.fontGame.draw(batch, text, xpos + (cellWidth - tw) / 2, posY)
}
}
@@ -83,7 +83,7 @@ class UIItemInlineRadioButtons(
Toolkit.drawBoxBorder(batch, xpos - 1, posY - 1, cellWidth + 2, height + 2)
val text = labelfuns[mouseOnSelection]()
val tw = App.fontGame.getWidth(text)
App.fontGame.draw(batch, text, xpos + (cellWidth - tw) / 2, posY + 2)
App.fontGame.draw(batch, text, xpos + (cellWidth - tw) / 2, posY)
}
// selection borders and text
@@ -92,7 +92,7 @@ class UIItemInlineRadioButtons(
Toolkit.drawBoxBorder(batch, xpos - 1, posY - 1, cellWidth + 2, height + 2)
val text = labelfuns[selection]()
val tw = App.fontGame.getWidth(text)
App.fontGame.draw(batch, text, xpos + (cellWidth - tw) / 2, posY + 2)
App.fontGame.draw(batch, text, xpos + (cellWidth - tw) / 2, posY)
super.render(batch, camera)

View File

@@ -85,12 +85,12 @@ class UIItemModuleInfoCell(
batch.draw(modIcon, initialX + 35f, initialY + 12f)
batch.shader = null
batch.color = Color.WHITE
App.fontGame.draw(batch, "$ccZero${modName.toUpperCase()}$ccNum $modVer", initialX + 86f + 3f, initialY + 2f)
App.fontGame.draw(batch, "$ccZero${modName.toUpperCase()}$ccNum $modVer", initialX + 86f + 3f, initialY.toFloat())
if (modErrored)
App.fontGame.draw(batch, "$emphRed${modErrors.first().cause?.message}", initialX + 86f + 3f, initialY + 26f)
App.fontGame.draw(batch, "$emphRed${modErrors.first().cause?.message}", initialX + 86f + 3f, initialY + 24f)
else
App.fontGame.draw(batch, "$ccDesc$modDesc", initialX + 86f + 3f, initialY + 26f)
App.fontGame.draw(batch, "$ccZero2$modAuthor$ccNum2 $modDate", initialX + 86f + 3f, initialY + 50f)
App.fontGame.draw(batch, "$ccDesc$modDesc", initialX + 86f + 3f, initialY + 24f)
App.fontGame.draw(batch, "$ccZero2$modAuthor$ccNum2 $modDate", initialX + 86f + 3f, initialY + 48f)
if (modErrored) {
batch.draw(CommonResourcePool.getAsTextureRegion("basegame_errored_icon32"), initialX + width - 40f, initialY + 8f + 12f)

View File

@@ -158,7 +158,7 @@ class UIItemSpinner(
// draw text
batch.color = UIItemTextLineInput.TEXTINPUT_COL_TEXT
// batch.draw(fbo.colorBufferTexture, posX + buttonW + 3f, posY + 2f, fbo.width.toFloat(), fbo.height.toFloat())
App.fontGame.draw(batch, textCache, posX + buttonW + 3f + (fboWidth - textCacheLen).div(2), posY + 2f)
App.fontGame.draw(batch, textCache, posX + buttonW + 3f + (fboWidth - textCacheLen).div(2), posY.toFloat())
super.render(batch, camera)
}

View File

@@ -81,7 +81,7 @@ open class UIItemTextButton(
Alignment.LEFT -> posX + paddingLeft
Alignment.RIGHT -> width - paddingRight - textW
}
val fontY = posY + 2 + (hitboxSize - font.lineHeight.toInt()) / 2
val fontY = posY + (hitboxSize - font.lineHeight.toInt()) / 2
// draw background

View File

@@ -517,7 +517,7 @@ class UIItemTextLineInput(
0
// TODO support alignment-right
App.fontGameFBO.draw(it, text, -1f*cursorDrawScroll + textDrawOffset, 0f)
App.fontGameFBO.draw(it, text, -1f*cursorDrawScroll + textDrawOffset, -2f)
} }
textCommitListener(getTextOrPlaceholder())
}
@@ -587,7 +587,8 @@ class UIItemTextLineInput(
batch.draw(labels.get(8,2), btn2PosX + 2f, posY + 2f)
// state of the candidates are concurrently changing, so we buffer them
val localCandidates = ArrayList<CodepointSequence>(); candidates.forEach { localCandidates.add(it) }
val localCandidates = ArrayList<CodepointSequence>()
candidates.forEach { localCandidates.add(it) }
// draw candidates view
if (localCandidates.isNotEmpty() && ime != null) {
@@ -618,7 +619,7 @@ class UIItemTextLineInput(
val candidateNum = listOf(i+48,46,32)
App.fontGame.draw(batch, CodepointSequence(candidateNum + localCandidates[i]),
candidatePosX + (i / halfcount) * (longestCandidateW + 3) + 2,
candidatePosY + (i % halfcount) * 20 // using hard-coded 20 instead of the actual font height of 24
candidatePosY + (i % halfcount) * 20 - 2 // using hard-coded 20 instead of the actual font height of 24
)
}
@@ -639,7 +640,7 @@ class UIItemTextLineInput(
Toolkit.drawBoxBorder(batch, candidatePosX - 1, candidatePosY - 1, candidateWinW + 2, candidateWinH + 2)
val previewTextWidth = textWidths[0]
App.fontGame.draw(batch, localCandidates[0], candidatePosX + (candidateWinW - previewTextWidth) / 2, candidatePosY)
App.fontGame.draw(batch, localCandidates[0], candidatePosX + (candidateWinW - previewTextWidth) / 2, candidatePosY - 2)
}
}

View File

@@ -197,7 +197,7 @@ class UIItemTextSelector(
val t = labelCache[selection]
val tw = App.fontGame.getWidth(t)
// batch.draw(fbo.colorBufferTexture, posX + buttonW + 3f, posY + 2f, fbo.width.toFloat(), fbo.height.toFloat())
App.fontGame.draw(batch, t, posX + buttonW + 3 + (fboWidth - tw) / 2, posY + 2)
App.fontGame.draw(batch, t, posX + buttonW + 3 + (fboWidth - tw) / 2, posY)
}
// palette
else {
@@ -226,7 +226,7 @@ class UIItemTextSelector(
val tw = App.fontGame.getWidth(t)
App.fontGame.draw(batch, t,
palX + (palW - tw) / 2,
getPalItemPosY(index)
getPalItemPosY(index) - 2
)
}
}