mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 22:01:52 +09:00
read from ingame lang
This commit is contained in:
@@ -14,7 +14,7 @@ import net.torvald.terrarum.btex.BTeXDrawCall
|
||||
import net.torvald.terrarum.btex.TypesetDrawCall
|
||||
import net.torvald.terrarum.ceilToFloat
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.console.GetAV.isNum
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.toHex
|
||||
import net.torvald.terrarum.tryDispose
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
@@ -31,7 +31,6 @@ import org.xml.sax.helpers.DefaultHandler
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.StringReader
|
||||
import java.util.regex.Pattern
|
||||
import javax.xml.parsers.SAXParserFactory
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.reflect.KFunction
|
||||
@@ -909,11 +908,26 @@ object BTeXParser {
|
||||
}
|
||||
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
fun processElemVAR(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
attribs["id"]?.let {
|
||||
fun processElemV(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
val hasID = (attribs["id"] != null)
|
||||
val hasFROMGAME = (attribs["fromgame"] != null)
|
||||
|
||||
if (hasID && hasFROMGAME) {
|
||||
throw IllegalStateException("Use only one of following attributes: id, fromgame")
|
||||
}
|
||||
else if (hasID) {
|
||||
val it = attribs["id"]!!
|
||||
val value = varMap[it] ?: throw NullPointerException("No variable definition of '$it'")
|
||||
handler.paragraphBuffer.append(value)
|
||||
}
|
||||
else if (hasFROMGAME) {
|
||||
val it = attribs["fromgame"]!!
|
||||
val value = Lang.get(it, true)
|
||||
handler.paragraphBuffer.append(value)
|
||||
}
|
||||
else {
|
||||
throw IllegalStateException("One of following attribute required: id, fromgame")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,11 +11,9 @@ import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
||||
import net.torvald.btex.BTeXParser
|
||||
import net.torvald.terrarum.FlippingSpriteBatch
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.btex.BTeXDocument
|
||||
import net.torvald.terrarum.ceilToInt
|
||||
import net.torvald.terrarum.gdxClearAndEnableBlend
|
||||
import net.torvald.terrarum.inUse
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.unicode.EMDASH
|
||||
import java.io.File
|
||||
import kotlin.system.measureTimeMillis
|
||||
@@ -26,7 +24,7 @@ import kotlin.system.measureTimeMillis
|
||||
*/
|
||||
class BTeXTest : ApplicationAdapter() {
|
||||
|
||||
val filePath = "btex_ko.xml"
|
||||
val filePath = "btex.xml"
|
||||
// val filePath = "test.xml"
|
||||
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
||||
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
||||
@@ -46,6 +44,8 @@ class BTeXTest : ApplicationAdapter() {
|
||||
)
|
||||
|
||||
override fun create() {
|
||||
Lang.invoke()
|
||||
|
||||
batch = FlippingSpriteBatch(1000)
|
||||
camera = OrthographicCamera(1280f, 720f)
|
||||
camera.setToOrtho(true) // some elements are pre-flipped, while some are not. The statement itself is absolutely necessary to make edge of the screen as the origin
|
||||
|
||||
Reference in New Issue
Block a user