mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
read from ingame lang
This commit is contained in:
34
btexdoc.dtd
34
btexdoc.dtd
@@ -16,7 +16,8 @@
|
||||
<!ENTITY % fontstyle "%fontstyle.basic; | %fontstyle.extra;">
|
||||
<!ENTITY % inlinelogo "btex | tex | latex">
|
||||
<!ENTITY % textdecor "emph | itemname | targetname">
|
||||
<!ENTITY % inline "a | %special; | %fontstyle; | code | bucks | %inlinelogo; | index | var | %textdecor;">
|
||||
<!ENTITY % vars "v | veun | vneun | vi | vga | veul | vreul | vwa | vgwa | vro | veuro">
|
||||
<!ENTITY % inline "a | %special; | %fontstyle; | code | bucks | %inlinelogo; | index | %vars; | %textdecor;">
|
||||
<!ENTITY % inline.meta "a | %special.basic; | %inlinelogo;">
|
||||
<!ENTITY % Inline "(#PCDATA | %inline;)*">
|
||||
<!ENTITY % Inline.meta "(#PCDATA | %inline.meta;)*">
|
||||
@@ -38,6 +39,9 @@
|
||||
start %Number; #IMPLIED">
|
||||
|
||||
<!ENTITY % id-only "id CDATA #REQUIRED">
|
||||
<!ENTITY % varattr
|
||||
"id CDATA #IMPLIED
|
||||
fromgame CDATA #IMPLIED">
|
||||
<!ENTITY % key-value
|
||||
"key CDATA #REQUIRED
|
||||
value CDATA #REQUIRED">
|
||||
@@ -103,8 +107,6 @@
|
||||
<!ELEMENT btex EMPTY>
|
||||
<!ELEMENT latex EMPTY>
|
||||
<!ELEMENT tex EMPTY>
|
||||
<!ELEMENT var EMPTY>
|
||||
<!ATTLIST var %id-only;>
|
||||
<!ELEMENT pair EMPTY>
|
||||
<!ATTLIST pair %key-value;>
|
||||
<!ELEMENT index EMPTY>
|
||||
@@ -150,3 +152,29 @@
|
||||
<!ATTLIST a
|
||||
href CDATA #REQUIRED
|
||||
>
|
||||
|
||||
<!-- var tags -->
|
||||
<!ELEMENT v EMPTY>
|
||||
<!ATTLIST v %varattr;>
|
||||
<!-- regular josa -->
|
||||
<!ELEMENT veun EMPTY>
|
||||
<!ATTLIST veun %varattr;>
|
||||
<!ELEMENT vneun EMPTY>
|
||||
<!ATTLIST vneun %varattr;>
|
||||
<!ELEMENT vi EMPTY>
|
||||
<!ATTLIST vi %varattr;>
|
||||
<!ELEMENT vga EMPTY>
|
||||
<!ATTLIST vga %varattr;>
|
||||
<!ELEMENT veul EMPTY>
|
||||
<!ATTLIST veul %varattr;>
|
||||
<!ELEMENT vreul EMPTY>
|
||||
<!ATTLIST vreul %varattr;>
|
||||
<!ELEMENT vwa EMPTY>
|
||||
<!ATTLIST vwa %varattr;>
|
||||
<!ELEMENT vgwa EMPTY>
|
||||
<!ATTLIST vgwa %varattr;>
|
||||
<!-- irregular josa -->
|
||||
<!ELEMENT vro EMPTY>
|
||||
<!ATTLIST vro %varattr;>
|
||||
<!ELEMENT veuro EMPTY>
|
||||
<!ATTLIST veuro %varattr;>
|
||||
|
||||
@@ -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