Skip to content

Commit

Permalink
update to kotlin 1.4; fixed a bug where trying to colour a text using…
Browse files Browse the repository at this point in the history
… gdxbatch's colour would cause undesirable results
  • Loading branch information
curioustorvald committed Sep 12, 2021
1 parent 3841611 commit 92aeb3c
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 64 deletions.
7 changes: 2 additions & 5 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions .idea/libraries/GdxLib.xml

This file was deleted.

4 changes: 1 addition & 3 deletions .idea/libraries/KotlinJavaRuntime.xml
100755 → 100644

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/libraries/TesterLib.xml

This file was deleted.

10 changes: 10 additions & 0 deletions .idea/libraries/com_badlogicgames_gdx_gdx_1_10_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BuildJAR_TerrarumSansBitmap.iml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="com.badlogicgames.gdx:gdx:1.10.0" level="project" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="library" name="GdxLib" level="project" />
</component>
</module>
4 changes: 1 addition & 3 deletions FontTestGDX/FontTestGDX.iml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="library" name="GdxLib" level="project" />
<orderEntry type="library" name="TesterLib" level="project" />
<orderEntry type="module" module-name="BuildJAR_TerrarumSansBitmap" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
</module>
33 changes: 8 additions & 25 deletions src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ class GameFontBase(

private lateinit var tempLinotype: Texture

private lateinit var originalColour: Color

private var nullProp = GlyphProps(15, 0)

private val pixmapOffsetY = 10
Expand All @@ -414,12 +412,10 @@ class GameFontBase(
val x = Math.round(x)
val y = Math.round(y)

originalColour = batch.color.cpy()
val mainColObj = originalColour
var mainCol: Int = originalColour.toRGBA8888().forceOpaque()

val charSeqHash = charSeq.toCodePoints().getHash()

var renderCol = -1 // subject to change with the colour code

if (charSeqNotBlank) {

val cacheObj = getCache(charSeqHash)
Expand Down Expand Up @@ -458,10 +454,10 @@ class GameFontBase(

if (isColourCode(c)) {
if (c == 0x100000) {
mainCol = originalColour.toRGBA8888().forceOpaque()
renderCol = -1
}
else {
mainCol = getColour(c)
renderCol = getColour(c)
}
}
else if (isCharsetOverride(c)) {
Expand Down Expand Up @@ -492,15 +488,9 @@ class GameFontBase(
val jungTex = hangulSheet.get(indexJung, jungRow)
val jongTex = hangulSheet.get(indexJong, jongRow)

linotypePixmap.setColor(mainCol)
linotypePixmap.drawPixmap(choTex, posXbuffer[index], pixmapOffsetY, mainCol)
linotypePixmap.drawPixmap(jungTex, posXbuffer[index], pixmapOffsetY, mainCol)
linotypePixmap.drawPixmap(jongTex, posXbuffer[index], pixmapOffsetY, mainCol)

//batch.color = mainCol
//batch.draw(choTex, x + posXbuffer[index].toFloat(), y)
//batch.draw(jungTex, x + posXbuffer[index].toFloat(), y)
//batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index].toFloat(), y)
linotypePixmap.drawPixmap(choTex, posXbuffer[index], pixmapOffsetY, renderCol)
linotypePixmap.drawPixmap(jungTex, posXbuffer[index], pixmapOffsetY, renderCol)
linotypePixmap.drawPixmap(jongTex, posXbuffer[index], pixmapOffsetY, renderCol)


index += hangulLength - 1
Expand All @@ -518,14 +508,11 @@ class GameFontBase(
val posX = posXbuffer[index]
val texture = sheets[sheetID].get(sheetX, sheetY)

linotypePixmap.drawPixmap(texture, posX, posY + pixmapOffsetY, mainCol)
linotypePixmap.drawPixmap(texture, posX, posY + pixmapOffsetY, renderCol)

//batch.color = mainCol
//batch.draw(texture, posX, posY)

}
catch (noSuchGlyph: ArrayIndexOutOfBoundsException) {
//batch.color = mainCol
}
}

Expand All @@ -550,9 +537,6 @@ class GameFontBase(
}



batch.color = mainColObj

if (!flipY) {
batch.draw(tempLinotype, x.toFloat(), (y - pixmapOffsetY).toFloat())
}
Expand All @@ -567,7 +551,6 @@ class GameFontBase(

}

batch.color = originalColour
return null
}

Expand Down

0 comments on commit 92aeb3c

Please sign in to comment.