Fix crash in EnumButtonTests due to attempted TextRenderer usage
This commit is contained in:
parent
ed3d2d3621
commit
d750339c07
|
@ -6,7 +6,6 @@ import net.shadowfacts.cacao.geometry.Point
|
||||||
import net.shadowfacts.cacao.geometry.Size
|
import net.shadowfacts.cacao.geometry.Size
|
||||||
import net.shadowfacts.cacao.util.Color
|
import net.shadowfacts.cacao.util.Color
|
||||||
import net.shadowfacts.cacao.util.RenderHelper
|
import net.shadowfacts.cacao.util.RenderHelper
|
||||||
import kotlin.math.roundToInt
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple View that displays text. Allows for controlling the color and shadow of the text. Label cannot be used
|
* A simple View that displays text. Allows for controlling the color and shadow of the text. Label cannot be used
|
||||||
|
@ -94,8 +93,7 @@ class Label(
|
||||||
var lines = text.split("\n")
|
var lines = text.split("\n")
|
||||||
if (wrappingMode == WrappingMode.WRAP) {
|
if (wrappingMode == WrappingMode.WRAP) {
|
||||||
lines = lines.flatMap {
|
lines = lines.flatMap {
|
||||||
val maxWidth = bounds.width.toInt()
|
wrapStringToWidthAsList(it, bounds.width)
|
||||||
textRenderer.wrapStringToWidthAsList(it, maxWidth)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0 < maxLines && maxLines < lines.size) {
|
if (0 < maxLines && maxLines < lines.size) {
|
||||||
|
@ -104,4 +102,9 @@ class Label(
|
||||||
this.lines = lines
|
this.lines = lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun wrapStringToWidthAsList(string: String, width: Double): List<String> {
|
||||||
|
if (RenderHelper.disabled) return listOf(string)
|
||||||
|
return textRenderer.wrapStringToWidthAsList(string, width.toInt())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue