mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
gdx font working good
This commit is contained in:
@@ -4,6 +4,7 @@ import com.badlogic.gdx.ApplicationAdapter
|
|||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication
|
import com.badlogic.gdx.backends.lwjgl.LwjglApplication
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
|
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.GL20
|
import com.badlogic.gdx.graphics.GL20
|
||||||
import com.badlogic.gdx.graphics.Texture
|
import com.badlogic.gdx.graphics.Texture
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||||
@@ -73,6 +74,7 @@ class TestTestTest : ApplicationAdapter() {
|
|||||||
batch.inBatch {
|
batch.inBatch {
|
||||||
|
|
||||||
text.forEachIndexed { index, s ->
|
text.forEachIndexed { index, s ->
|
||||||
|
gameFont.color = Color(1f, 1f, 1f, 1f)
|
||||||
gameFont.draw(batch, s, 10f, 10 + (20 * text.size) - 20f * index)
|
gameFont.draw(batch, s, 10f, 10 + (20 * text.size) - 20f * index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import java.util.zip.GZIPInputStream
|
|||||||
*
|
*
|
||||||
* Created by minjaesong on 2017-06-15.
|
* Created by minjaesong on 2017-06-15.
|
||||||
*/
|
*/
|
||||||
class GameFontBase(val noShadow: Boolean) : BitmapFont() {
|
class GameFontBase(val noShadow: Boolean = false) : BitmapFont() {
|
||||||
|
|
||||||
private fun getHanChosung(hanIndex: Int) = hanIndex / (JUNG_COUNT * JONG_COUNT)
|
private fun getHanChosung(hanIndex: Int) = hanIndex / (JUNG_COUNT * JONG_COUNT)
|
||||||
private fun getHanJungseong(hanIndex: Int) = hanIndex / JONG_COUNT % JUNG_COUNT
|
private fun getHanJungseong(hanIndex: Int) = hanIndex / JONG_COUNT % JUNG_COUNT
|
||||||
@@ -328,6 +328,11 @@ class GameFontBase(val noShadow: Boolean) : BitmapFont() {
|
|||||||
//print("[TerrarumSansBitmap] widthTable for $textBuffer: ")
|
//print("[TerrarumSansBitmap] widthTable for $textBuffer: ")
|
||||||
//textBWidth.forEach { print("$it ") }; println()
|
//textBWidth.forEach { print("$it ") }; println()
|
||||||
|
|
||||||
|
|
||||||
|
val mainCol = this.color.cpy()
|
||||||
|
val shadowCol = this.color.cpy().mul(0.5f)
|
||||||
|
|
||||||
|
|
||||||
textBuffer.forEachIndexed { index, c ->
|
textBuffer.forEachIndexed { index, c ->
|
||||||
val sheetID = getSheetType(c)
|
val sheetID = getSheetType(c)
|
||||||
val sheetXY = getSheetwisePosition(c)
|
val sheetXY = getSheetwisePosition(c)
|
||||||
@@ -335,6 +340,43 @@ class GameFontBase(val noShadow: Boolean) : BitmapFont() {
|
|||||||
//println("[TerrarumSansBitmap] sprite: $sheetID:${sheetXY[0]}x${sheetXY[1]}")
|
//println("[TerrarumSansBitmap] sprite: $sheetID:${sheetXY[0]}x${sheetXY[1]}")
|
||||||
|
|
||||||
if (sheetID != SHEET_HANGUL) {
|
if (sheetID != SHEET_HANGUL) {
|
||||||
|
|
||||||
|
if (!noShadow) {
|
||||||
|
batch.color = shadowCol
|
||||||
|
batch.draw(
|
||||||
|
sheets[sheetID].get(sheetXY[0], sheetXY[1]),
|
||||||
|
x + textBWidth[index] + 1,
|
||||||
|
y +
|
||||||
|
if (sheetID == SHEET_UNIHAN) // evil exceptions
|
||||||
|
offsetUnihan
|
||||||
|
else if (sheetID == SHEET_CUSTOM_SYM)
|
||||||
|
offsetCustomSym
|
||||||
|
else 0
|
||||||
|
)
|
||||||
|
batch.draw(
|
||||||
|
sheets[sheetID].get(sheetXY[0], sheetXY[1]),
|
||||||
|
x + textBWidth[index],
|
||||||
|
y - 1 +
|
||||||
|
if (sheetID == SHEET_UNIHAN) // evil exceptions
|
||||||
|
offsetUnihan
|
||||||
|
else if (sheetID == SHEET_CUSTOM_SYM)
|
||||||
|
offsetCustomSym
|
||||||
|
else 0
|
||||||
|
)
|
||||||
|
batch.draw(
|
||||||
|
sheets[sheetID].get(sheetXY[0], sheetXY[1]),
|
||||||
|
x + textBWidth[index] + 1,
|
||||||
|
y - 1 +
|
||||||
|
if (sheetID == SHEET_UNIHAN) // evil exceptions
|
||||||
|
offsetUnihan
|
||||||
|
else if (sheetID == SHEET_CUSTOM_SYM)
|
||||||
|
offsetCustomSym
|
||||||
|
else 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
batch.color = mainCol
|
||||||
batch.draw(
|
batch.draw(
|
||||||
sheets[sheetID].get(sheetXY[0], sheetXY[1]),
|
sheets[sheetID].get(sheetXY[0], sheetXY[1]),
|
||||||
x + textBWidth[index],
|
x + textBWidth[index],
|
||||||
@@ -358,12 +400,25 @@ class GameFontBase(val noShadow: Boolean) : BitmapFont() {
|
|||||||
val jungRow = getHanMedialRow(hIndex)
|
val jungRow = getHanMedialRow(hIndex)
|
||||||
val jongRow = getHanFinalRow(hIndex)
|
val jongRow = getHanFinalRow(hIndex)
|
||||||
|
|
||||||
|
|
||||||
|
if (!noShadow) {
|
||||||
|
batch.color = shadowCol
|
||||||
|
|
||||||
|
batch.draw(hangulSheet.get(indexCho, choRow), x + textBWidth[index] + 1, y)
|
||||||
|
batch.draw(hangulSheet.get(indexJung, jungRow), x + textBWidth[index], y - 1)
|
||||||
|
batch.draw(hangulSheet.get(indexJong, jongRow), x + textBWidth[index] + 1, y - 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
batch.color = mainCol
|
||||||
batch.draw(hangulSheet.get(indexCho, choRow), x + textBWidth[index], y)
|
batch.draw(hangulSheet.get(indexCho, choRow), x + textBWidth[index], y)
|
||||||
batch.draw(hangulSheet.get(indexJung, jungRow), x + textBWidth[index], y)
|
batch.draw(hangulSheet.get(indexJung, jungRow), x + textBWidth[index], y)
|
||||||
batch.draw(hangulSheet.get(indexJong, jongRow), x + textBWidth[index], y)
|
batch.draw(hangulSheet.get(indexJong, jongRow), x + textBWidth[index], y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.color = mainCol
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user