mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
tweak in Kana font, fonts can now produce colours
Former-commit-id: 4f83fbe93e86ffae090986b58802a2fe0c1fd83e Former-commit-id: 9b0ae019b5dae16236c25597ca31e6aa3b6fb78c
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 22 KiB |
@@ -162,7 +162,7 @@ constructor() : Font {
|
||||
|
||||
override fun drawString(x: Float, y: Float, s: String, color: Color) {
|
||||
// hangul fonts first
|
||||
hangulSheet.startUse()
|
||||
//hangulSheet.startUse() // disabling texture binding to make the font coloured
|
||||
// JOHAB
|
||||
for (i in 0..s.length - 1) {
|
||||
val ch = s[i]
|
||||
@@ -180,18 +180,43 @@ constructor() : Font {
|
||||
|
||||
val glyphW = getWidth("" + ch)
|
||||
|
||||
// initials
|
||||
/*// initials
|
||||
hangulSheet.renderInUse(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW), Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f), indexCho, choRow)
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW),
|
||||
Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f),
|
||||
indexCho, choRow
|
||||
)
|
||||
// medials
|
||||
hangulSheet.renderInUse(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW), Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f), indexJung, jungRow)
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW),
|
||||
Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f),
|
||||
indexJung, jungRow
|
||||
)
|
||||
// finals
|
||||
hangulSheet.renderInUse(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW), Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f), indexJong, jongRow)
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW),
|
||||
Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f),
|
||||
indexJong, jongRow
|
||||
)*/
|
||||
|
||||
hangulSheet.getSubImage(indexCho, choRow).draw(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
|
||||
Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f).toFloat(),
|
||||
color
|
||||
)
|
||||
hangulSheet.getSubImage(indexJung, jungRow).draw(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
|
||||
Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f).toFloat(),
|
||||
color
|
||||
)
|
||||
hangulSheet.getSubImage(indexJong, jongRow).draw(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
|
||||
Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f).toFloat(),
|
||||
color
|
||||
)
|
||||
}
|
||||
}
|
||||
hangulSheet.endUse()
|
||||
//hangulSheet.endUse()
|
||||
|
||||
// unihan fonts
|
||||
/*uniHan.startUse();
|
||||
@@ -214,41 +239,51 @@ constructor() : Font {
|
||||
uniHan.endUse();*/
|
||||
|
||||
// WenQuanYi 1
|
||||
wenQuanYi_1.startUse()
|
||||
//wenQuanYi_1.startUse()
|
||||
|
||||
for (i in 0..s.length - 1) {
|
||||
val ch = s[i]
|
||||
|
||||
if (isWenQuanYi1(ch)) {
|
||||
val glyphW = getWidth("" + ch)
|
||||
wenQuanYi_1.renderInUse(
|
||||
/*wenQuanYi_1.renderInUse(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW),
|
||||
Math.round((H - H_UNIHAN) / 2 + y),
|
||||
wenQuanYiIndexX(ch),
|
||||
wenQuanYi1IndexY(ch)
|
||||
)*/
|
||||
wenQuanYi_1.getSubImage(wenQuanYiIndexX(ch), wenQuanYi1IndexY(ch)).draw(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
|
||||
Math.round((H - H_UNIHAN) / 2 + y).toFloat(),
|
||||
color
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
wenQuanYi_1.endUse()
|
||||
//wenQuanYi_1.endUse()
|
||||
// WenQuanYi 2
|
||||
wenQuanYi_2.startUse()
|
||||
//wenQuanYi_2.startUse()
|
||||
|
||||
for (i in 0..s.length - 1) {
|
||||
val ch = s[i]
|
||||
|
||||
if (isWenQuanYi2(ch)) {
|
||||
val glyphW = getWidth("" + ch)
|
||||
wenQuanYi_2.renderInUse(
|
||||
/*wenQuanYi_2.renderInUse(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW),
|
||||
Math.round((H - H_UNIHAN) / 2 + y),
|
||||
wenQuanYiIndexX(ch),
|
||||
wenQuanYi2IndexY(ch)
|
||||
)*/
|
||||
wenQuanYi_2.getSubImage(wenQuanYiIndexX(ch), wenQuanYi2IndexY(ch)).draw(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
|
||||
Math.round((H - H_UNIHAN) / 2 + y).toFloat(),
|
||||
color
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
wenQuanYi_2.endUse()
|
||||
//wenQuanYi_2.endUse()
|
||||
|
||||
// regular fonts
|
||||
var prevInstance = -1
|
||||
@@ -259,9 +294,9 @@ constructor() : Font {
|
||||
|
||||
// if not init, endUse first
|
||||
if (prevInstance != -1) {
|
||||
sheetKey[prevInstance].endUse()
|
||||
//sheetKey[prevInstance].endUse()
|
||||
}
|
||||
sheetKey[getSheetType(ch)].startUse()
|
||||
//sheetKey[getSheetType(ch)].startUse()
|
||||
prevInstance = getSheetType(ch)
|
||||
|
||||
val sheetX: Int
|
||||
@@ -315,15 +350,22 @@ constructor() : Font {
|
||||
|
||||
val glyphW = getWidth("" + ch)
|
||||
try {
|
||||
sheetKey[prevInstance].renderInUse(
|
||||
/*sheetKey[prevInstance].renderInUse(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW) // Interchar: pull punct right next to hangul to the left
|
||||
+ if (i > 0 && isHangul(s[i - 1])) -3 else 0, Math.round(y) +
|
||||
if (prevInstance == SHEET_CJK_PUNCT)
|
||||
-1
|
||||
else if (prevInstance == SHEET_FW_UNI)
|
||||
(H - H_HANGUL) / 2
|
||||
else 0,
|
||||
sheetX, sheetY)
|
||||
+ if (i > 0 && isHangul(s[i - 1])) -3 else 0,
|
||||
Math.round(y) + if (prevInstance == SHEET_CJK_PUNCT) -1
|
||||
else if (prevInstance == SHEET_FW_UNI) (H - H_HANGUL) / 2
|
||||
else 0,
|
||||
sheetX, sheetY
|
||||
)*/
|
||||
sheetKey[prevInstance].getSubImage(sheetX, sheetY).draw(
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat() // Interchar: pull punct right next to hangul to the left
|
||||
+ if (i > 0 && isHangul(s[i - 1])) -3f else 0f,
|
||||
Math.round(y).toFloat() + (if (prevInstance == SHEET_CJK_PUNCT) -1
|
||||
else if (prevInstance == SHEET_FW_UNI) (H - H_HANGUL) / 2
|
||||
else 0).toFloat(),
|
||||
color
|
||||
)
|
||||
}
|
||||
catch (e: ArrayIndexOutOfBoundsException) {
|
||||
// character that does not exist in the sheet. No render, pass.
|
||||
@@ -332,7 +374,7 @@ constructor() : Font {
|
||||
|
||||
}
|
||||
if (prevInstance != -1) {
|
||||
sheetKey[prevInstance].endUse()
|
||||
//sheetKey[prevInstance].endUse()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ object Lang {
|
||||
|
||||
// reload correct (C/J) unihan fonts if applicable
|
||||
try {
|
||||
(Terrarum.gameFontWhite as GameFontWhite).reloadUnihan()
|
||||
(Terrarum.gameFont as GameFontWhite).reloadUnihan()
|
||||
}
|
||||
catch (e: SlickException) {
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.torvald.terrarum
|
||||
import com.torvald.imagefont.GameFontWhite
|
||||
import com.torvald.JsonFetcher
|
||||
import com.torvald.JsonWriter
|
||||
import com.torvald.terrarum.langpack.Lang
|
||||
import org.lwjgl.input.Controllers
|
||||
import org.lwjgl.opengl.GL11
|
||||
import org.newdawn.slick.AppGameContainer
|
||||
@@ -12,7 +11,6 @@ import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.SlickException
|
||||
import org.newdawn.slick.state.StateBasedGame
|
||||
import java.io.File
|
||||
import java.io.FileWriter
|
||||
import java.io.IOException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
@@ -50,7 +48,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
||||
|
||||
@Throws(SlickException::class)
|
||||
override fun initStatesList(gc: GameContainer) {
|
||||
gameFontWhite = GameFontWhite()
|
||||
gameFont = GameFontWhite()
|
||||
|
||||
hasController = gc.input.controllerCount > 0
|
||||
if (hasController) {
|
||||
@@ -99,7 +97,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
||||
|
||||
var gameLocale = "" // locale override
|
||||
|
||||
lateinit var gameFontWhite: Font
|
||||
lateinit var gameFont: Font
|
||||
|
||||
val SCENE_ID_HOME = 1
|
||||
val SCENE_ID_GAME = 3
|
||||
@@ -354,10 +352,21 @@ fun main(args: Array<String>) = Terrarum.main(args)
|
||||
|
||||
fun setBlendModeMul() {
|
||||
GL11.glEnable(GL11.GL_BLEND)
|
||||
GL11.glColorMask(true, true, true, true)
|
||||
GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_ONE_MINUS_SRC_ALPHA)
|
||||
}
|
||||
|
||||
fun setBlendModeNormal() {
|
||||
GL11.glEnable(GL11.GL_BLEND)
|
||||
GL11.glColorMask(true, true, true, true)
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA)
|
||||
}
|
||||
}
|
||||
|
||||
fun setBlendModeAlphaMap() {
|
||||
GL11.glDisable(GL11.GL_BLEND)
|
||||
GL11.glColorMask(false, false, false, true)
|
||||
}
|
||||
|
||||
fun disableBlend() {
|
||||
GL11.glDisable(GL11.GL_BLEND)
|
||||
}
|
||||
|
||||
@@ -25,16 +25,9 @@ Connect two or more tracker head to play the array of trackers play simultaneous
|
||||
|
||||
<actorid>.json
|
||||
{
|
||||
0 = [long],
|
||||
1 = [long],
|
||||
...
|
||||
47 = [long],
|
||||
notes = [arr<int>, fixed size of 48],
|
||||
speed = 120
|
||||
}
|
||||
|
||||
*long: array of bits that indicates the note is stricken (1) or not (0)
|
||||
0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000
|
||||
↑G5 ↑C5 ↑C4 ↑C3 ↑C2 ↑C1 E0↑
|
||||
(Assuming C3 (32nd bit) as middle 'C')
|
||||
|
||||
*int: (0-63) number of the note pitch that is struck. 32: Middle C (C3)
|
||||
*speed: in BPM
|
||||
@@ -2,6 +2,8 @@ package com.torvald.terrarum.ui
|
||||
|
||||
import com.torvald.imagefont.GameFontWhite
|
||||
import com.jme3.math.FastMath
|
||||
import com.torvald.terrarum.disableBlend
|
||||
import com.torvald.terrarum.setBlendModeNormal
|
||||
import org.lwjgl.opengl.GL11
|
||||
import org.newdawn.slick.*
|
||||
|
||||
@@ -20,6 +22,7 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
|
||||
private val messageWindowRadius: Int
|
||||
|
||||
private var uiFont: Font? = null
|
||||
private var fontCol: Color = if (!isBlackVariant) Color.black else Color.white
|
||||
private val GLYPH_HEIGHT = 20
|
||||
|
||||
override var openCloseTime: Int = OPEN_CLOSE_TIME
|
||||
@@ -31,18 +34,16 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
|
||||
|
||||
init {
|
||||
if (!isBlackVariant) {
|
||||
//segmentLeft = new Image("./res/graphics/gui/message_twoline_white_left.png");
|
||||
//segmentRight = new Image("./res/graphics/gui/message_twoline_white_right.png");
|
||||
//segmentBody = new Image("./res/graphics/gui/message_twoline_white_body.png");
|
||||
//uiFont = new GameFontBlack();
|
||||
TODO("Black font not supported for now")
|
||||
segmentLeft = Image("./res/graphics/gui/message_twoline_white_left.png");
|
||||
segmentRight = Image("./res/graphics/gui/message_twoline_white_right.png");
|
||||
segmentBody = Image("./res/graphics/gui/message_twoline_white_body.png");
|
||||
}
|
||||
else {
|
||||
segmentLeft = Image("./res/graphics/gui/message_twoline_black_left.png")
|
||||
segmentRight = Image("./res/graphics/gui/message_twoline_black_right.png")
|
||||
segmentBody = Image("./res/graphics/gui/message_twoline_black_body.png")
|
||||
uiFont = GameFontWhite()
|
||||
}
|
||||
uiFont = GameFontWhite()
|
||||
height = segmentLeft!!.height
|
||||
messageWindowRadius = segmentLeft!!.width
|
||||
messagesList = arrayOf("", "")
|
||||
@@ -60,7 +61,7 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
val canvasG = uidrawCanvas.graphics
|
||||
|
||||
canvasG.setDrawMode(Graphics.MODE_NORMAL)
|
||||
disableBlend()
|
||||
drawSegments(canvasG)
|
||||
canvasG.setDrawMode(Graphics.MODE_ALPHA_MAP)
|
||||
drawSegments(canvasG)
|
||||
@@ -69,9 +70,11 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
|
||||
|
||||
canvasG.setDrawMode(Graphics.MODE_NORMAL)
|
||||
for (i in 0..Math.min(messagesList.size, MESSAGES_DISPLAY) - 1) {
|
||||
canvasG.color = fontCol
|
||||
canvasG.drawString(messagesList[i], (messageWindowRadius + 4).toFloat(), (messageWindowRadius + GLYPH_HEIGHT * i).toFloat())
|
||||
}
|
||||
|
||||
setBlendModeNormal()
|
||||
g.drawImage(uidrawCanvas, 0f, 0f, Color(1f,1f,1f,opacity))
|
||||
|
||||
canvasG.clear()
|
||||
|
||||
@@ -93,7 +93,7 @@ constructor(val UI: UICanvas) {
|
||||
fun render(gc: GameContainer, gameGraphicInstance: Graphics) {
|
||||
if (visible || alwaysVisible) {
|
||||
UIGraphicInstance.clear()
|
||||
UIGraphicInstance.font = Terrarum.gameFontWhite
|
||||
UIGraphicInstance.font = Terrarum.gameFont
|
||||
|
||||
UI.render(gc, UIGraphicInstance)
|
||||
gameGraphicInstance.drawImage(UIDrawnCanvas,
|
||||
|
||||
Reference in New Issue
Block a user