From bb10c557398e5c05e3c7f4de79c666a99abaa7df Mon Sep 17 00:00:00 2001
From: minjaesong
Date: Fri, 26 Apr 2024 03:30:59 +0900
Subject: [PATCH] more btex styling
---
assets/mods/basegame/books/btex.xml | 4 ++--
src/net/torvald/btex/BTeXDocument.kt | 2 +-
src/net/torvald/btex/BTeXParser.kt | 12 ++++++++++--
.../torvald/terrarum/modulebasegame/ui/UICrafting.kt | 2 +-
src/net/torvald/terrarum/tests/BTeXTest.kt | 8 ++++----
src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt | 2 +-
.../{Screenshot-1714034883660.png => real_bg.png} | 0
test_assets/real_bg_with_guides.png | 3 +++
8 files changed, 22 insertions(+), 11 deletions(-)
rename test_assets/{Screenshot-1714034883660.png => real_bg.png} (100%)
create mode 100644 test_assets/real_bg_with_guides.png
diff --git a/assets/mods/basegame/books/btex.xml b/assets/mods/basegame/books/btex.xml
index 0fa11a0b7..d67ad18e9 100644
--- a/assets/mods/basegame/books/btex.xml
+++ b/assets/mods/basegame/books/btex.xml
@@ -54,8 +54,8 @@
Full Control of the Shape
With you can fully control how your publishing would look like,
- from a pile of papers that look like they have been typed out using typewriter, a pile of papers but a
- fully-featured printouts that have illustrations in it, to a true hardcover book.
+ from a pile of papers that look like they have been typed out using typewriter, a pile of printouts
+ that have pictures in it, to a true hardcover book.
This style is controlled using the cover attribute on the root tag,
with following values: typewriter, printout and hardcover.
diff --git a/src/net/torvald/btex/BTeXDocument.kt b/src/net/torvald/btex/BTeXDocument.kt
index 78a994471..b1d4d8552 100644
--- a/src/net/torvald/btex/BTeXDocument.kt
+++ b/src/net/torvald/btex/BTeXDocument.kt
@@ -18,7 +18,7 @@ class BTeXDocument {
var textWidth = 480
var lineHeightInPx = 24
- var pageLines = 20
+ var pageLines = 25
var textHeight = pageLines * lineHeightInPx
val pageMarginH = 15
diff --git a/src/net/torvald/btex/BTeXParser.kt b/src/net/torvald/btex/BTeXParser.kt
index 4ce0847d6..2ba12648a 100644
--- a/src/net/torvald/btex/BTeXParser.kt
+++ b/src/net/torvald/btex/BTeXParser.kt
@@ -407,10 +407,12 @@ object BTeXParser {
)
private val pageWidthMap = hashMapOf(
- "standard" to 480
+ "standard" to 480,
+ "examination" to 640,
)
private val pageHeightMap = hashMapOf(
- "standard" to 20
+ "standard" to 25,
+ "examination" to 18,
)
@@ -522,6 +524,9 @@ object BTeXParser {
fun closeElemEDITION(handler: BTeXHandler, doc: BTeXDocument, theTag: String, uri: String, siblingIndex: Int) = closeElemP(handler, doc, theTag, uri, siblingIndex)
@CloseTag // reflective access is impossible with 'private'
fun closeElemCHAPTER(handler: BTeXHandler, doc: BTeXDocument, theTag: String, uri: String, siblingIndex: Int) {
+ // if current line is the last line, proceed to the next page
+ if (doc.currentLine == doc.pageLines - 1) doc.addNewPage()
+
val indent = 16
val thePar = "\n" + handler.paragraphBuffer.toString().trim()
typesetParagraphs(thePar, handler, doc.textWidth - indent).also {
@@ -541,6 +546,9 @@ object BTeXParser {
}
@CloseTag // reflective access is impossible with 'private'
fun closeElemSECTION(handler: BTeXHandler, doc: BTeXDocument, theTag: String, uri: String, siblingIndex: Int) {
+ // if current line is the last line, proceed to the next page
+ if (doc.currentLine == doc.pageLines - 1) doc.addNewPage()
+
val indent = 8
val thePar = "\n" + handler.paragraphBuffer.toString().trim()
typesetParagraphs(thePar, handler, doc.textWidth - indent).also {
diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UICrafting.kt b/src/net/torvald/terrarum/modulebasegame/ui/UICrafting.kt
index 39fee04a2..d2801e71d 100644
--- a/src/net/torvald/terrarum/modulebasegame/ui/UICrafting.kt
+++ b/src/net/torvald/terrarum/modulebasegame/ui/UICrafting.kt
@@ -67,7 +67,7 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
UIInventoryFull.drawBackground(batch, opacity)
}
- uiItems.forEach { it.render(frameDelta, batch, camera) }
+// uiItems.forEach { it.render(frameDelta, batch, camera) }
}
override fun dispose() {
diff --git a/src/net/torvald/terrarum/tests/BTeXTest.kt b/src/net/torvald/terrarum/tests/BTeXTest.kt
index 439778e62..bac509aa2 100644
--- a/src/net/torvald/terrarum/tests/BTeXTest.kt
+++ b/src/net/torvald/terrarum/tests/BTeXTest.kt
@@ -83,8 +83,8 @@ class BTeXTest : ApplicationAdapter() {
Full Control of the Shape
With you can fully control how your publishing would look like,
- from a pile of papers that look like they have been typed out using typewriter, a pile of papers but a
- fully-featured printouts that have illustrations in it, to a true hardcover book.
+ from a pile of papers that look like they have been typed out using typewriter, a pile of printouts
+ that have pictures in it, to a true hardcover book.
This style is controlled using the cover attribute on the root tag,
with following values: typewriter, printout and hardcover.
@@ -114,7 +114,7 @@ class BTeXTest : ApplicationAdapter() {
camera.update()
batch.projectionMatrix = camera.combined
- bg = TextureRegion(Texture(Gdx.files.internal("test_assets/Screenshot-1714034883660.png")))
+ bg = TextureRegion(Texture(Gdx.files.internal("test_assets/real_bg_with_guides.png")))
document = BTeXParser.invoke(tex)
}
@@ -127,7 +127,7 @@ class BTeXTest : ApplicationAdapter() {
gdxClearAndEnableBlend(.063f, .070f, .086f, 1f)
val drawX = (1280 - (pageGap + document.pageWidth*2)) / 2
- val drawY = 100
+ val drawY = 24
batch.inUse {
batch.color = Color.WHITE
diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt
index f6fb35111..f65295b5b 100644
--- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt
+++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt
@@ -713,7 +713,7 @@ internal object BlocksDrawer {
}
private var _tilesBufferAsTex: Texture = Texture(1, 1, Pixmap.Format.RGBA8888)
- private val occlusionIntensity = 0.5f//0.22222222f // too low value and dark-coloured walls won't darken enough
+ private val occlusionIntensity = 0.22222222f // too low value and dark-coloured walls won't darken enough
private fun renderUsingBuffer(mode: Int, projectionMatrix: Matrix4, drawGlow: Boolean, drawEmissive: Boolean) {
//Gdx.gl.glClearColor(.094f, .094f, .094f, 0f)
diff --git a/test_assets/Screenshot-1714034883660.png b/test_assets/real_bg.png
similarity index 100%
rename from test_assets/Screenshot-1714034883660.png
rename to test_assets/real_bg.png
diff --git a/test_assets/real_bg_with_guides.png b/test_assets/real_bg_with_guides.png
new file mode 100644
index 000000000..cb69dc6de
--- /dev/null
+++ b/test_assets/real_bg_with_guides.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:222ce740647cb2e77da76e212581a5fc0b9d41641f833945cb08ee63a00a4894
+size 661839