diff --git a/assets/mods/basegame/books/btex.xml b/assets/mods/basegame/books/btex.xml
index b5bb86da9..11d948bb0 100644
--- a/assets/mods/basegame/books/btex.xml
+++ b/assets/mods/basegame/books/btex.xml
@@ -160,6 +160,24 @@
+
+
+
Figures, or external images can be inserted using the self-closing img tag.
+ This tag inserts the image starting from the current line; if the size is taller than the
+ remaining lines, the image will be printed onto the next page. Its syntax is as follows:
+
+ <img src="web URL" height="8"/>
<img fromgame="basegame:gui/small.png" height="4"/>
<img gameitem="basegame:33" height="1"/>
+
+
+ The height attribute specifies the height of the image in the number of lines,
+ rather than pixels.
+
+ Supported image formats: JPEG, PNG, BMP or TGA
+
+
The Index Page
The contents of the Index Page is filled in automatically by reading through your manuscript.
diff --git a/src/net/torvald/btex/BTeXDocument.kt b/src/net/torvald/btex/BTeXDocument.kt
index b74347758..ec1e6a33a 100644
--- a/src/net/torvald/btex/BTeXDocument.kt
+++ b/src/net/torvald/btex/BTeXDocument.kt
@@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.utils.Disposable
-import net.torvald.terrarum.FlippingSpriteBatch
import net.torvald.terrarum.ceilToInt
import net.torvald.terrarum.concurrent.ThreadExecutor
import net.torvald.terrarum.imagefont.TinyAlphNum
diff --git a/src/net/torvald/btex/BTeXParser.kt b/src/net/torvald/btex/BTeXParser.kt
index 955ff791a..999d2bd88 100644
--- a/src/net/torvald/btex/BTeXParser.kt
+++ b/src/net/torvald/btex/BTeXParser.kt
@@ -792,10 +792,11 @@ object BTeXParser {
if (tocPage != null) {
// estimate the number of TOC pages
// TOC page always takes up a full paper, therefore tocSizeInPages is always multiple of 2
- var tocSizeInPages = (cptSectMap.size + 2) / doc.pageLines
+ var tocSizeInPages = ((cptSectMap.size + 2f) / doc.pageLines).ceilToInt()
if (tocSizeInPages == 0) tocSizeInPages = 2
if (tocSizeInPages % 2 == 1) tocSizeInPages += 1
+ println("TOC number of entries: ${cptSectMap.size}, estimated page count: $tocSizeInPages")
// renumber things
if (tocSizeInPages > 1) {
@@ -812,6 +813,7 @@ object BTeXParser {
}
}
+ var currentTOCpage = tocPage!!
cptSectMap.forEach { (type, name, pg, part, cpt, sect) ->
val indent = if (type == "subsection") 2*PAR_INDENTATION else if (type == "section") PAR_INDENTATION else 0
val heading = if (part == null && cpt == null && sect == null)
@@ -823,7 +825,11 @@ object BTeXParser {
else
"$cpt.$sect${spacingBlockToString(HEADING_NUM_TITLE_GAP)}"
- typesetTOCline("$heading", name, pg, handler, indent, tocPage)
+ typesetTOCline("$heading", name, pg, handler, indent, currentTOCpage)
+
+ if (doc.linesPrintedOnPage[currentTOCpage] >= doc.pageLines) {
+ currentTOCpage += 1
+ }
}
}
}
@@ -1728,7 +1734,7 @@ object BTeXParser {
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
val ccBucks = TerrarumSansBitmap.toColorCode(5,0,0)
- val ccCode = TerrarumSansBitmap.toColorCode(8,0,0)
+ val ccCode = TerrarumSansBitmap.toColorCode(7,0,0)
val ccHref = TerrarumSansBitmap.toColorCode(0,3,11)
val ccEmph = TerrarumSansBitmap.toColorCode(0xfc11)
val ccItemName = TerrarumSansBitmap.toColorCode(0xf03b)
diff --git a/src/net/torvald/terrarum/tests/BTeXTest.kt b/src/net/torvald/terrarum/tests/BTeXTest.kt
index c2a327036..c0a7b81e9 100644
--- a/src/net/torvald/terrarum/tests/BTeXTest.kt
+++ b/src/net/torvald/terrarum/tests/BTeXTest.kt
@@ -26,9 +26,10 @@ import kotlin.system.measureTimeMillis
*/
class BTeXTest : ApplicationAdapter() {
+ val filePath = "btex.xml"
// val filePath = "btex_ko.xml"
// val filePath = "test.xml"
- val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
+// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
// val filePath = "literature/koKR/yisang_nalgae.btxbook"