mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-01 02:14:51 +07:00
Fix ColorMarkupLabel prefSize (#9077)
This commit is contained in:
parent
2d184655c7
commit
ce495d4ff2
@ -3,6 +3,7 @@
|
||||
package com.unciv.ui.components
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.unciv.Constants
|
||||
import com.unciv.models.translations.tr
|
||||
@ -33,8 +34,6 @@ class ColorMarkupLabel private constructor(
|
||||
fontSize: Int = Constants.defaultFontSize)
|
||||
: this (fontSize, prepareText(text, textColor, symbolColor))
|
||||
|
||||
private val originalMarkupEnabled: Boolean
|
||||
|
||||
init {
|
||||
if (fontSize != Constants.defaultFontSize) {
|
||||
val labelStyle = LabelStyle(style) // clone otherwise all default-styled Labels affected
|
||||
@ -42,15 +41,22 @@ class ColorMarkupLabel private constructor(
|
||||
style.font = Fonts.font
|
||||
setFontScale(fontSize / Fonts.ORIGINAL_FONT_SIZE)
|
||||
}
|
||||
originalMarkupEnabled = style.font.data.markupEnabled
|
||||
}
|
||||
|
||||
override fun layout() {
|
||||
val originalMarkupEnabled = style.font.data.markupEnabled
|
||||
style.font.data.markupEnabled = true
|
||||
super.layout()
|
||||
style.font.data.markupEnabled = originalMarkupEnabled
|
||||
}
|
||||
|
||||
override fun computePrefSize(layout: GlyphLayout?) {
|
||||
val originalMarkupEnabled = style.font.data.markupEnabled
|
||||
style.font.data.markupEnabled = true
|
||||
super.computePrefSize(layout)
|
||||
style.font.data.markupEnabled = originalMarkupEnabled
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun mapMarkup(text: String): String {
|
||||
val translated = text.tr()
|
||||
|
Loading…
Reference in New Issue
Block a user