From fab32e8c8a257f54331733838900877b63b0124b Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 4 May 2023 11:07:54 +0300 Subject: [PATCH] Resolved #9304 - Added Policy icons and solved 'icons from Image' reflection :) --- core/src/com/unciv/ui/components/Fonts.kt | 8 ++++++++ .../unciv/ui/screens/pickerscreens/PolicyPickerScreen.kt | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/ui/components/Fonts.kt b/core/src/com/unciv/ui/components/Fonts.kt index 3aee50b357..dba73282fd 100644 --- a/core/src/com/unciv/ui/components/Fonts.kt +++ b/core/src/com/unciv/ui/components/Fonts.kt @@ -21,6 +21,7 @@ import com.unciv.GUI import com.unciv.UncivGame import com.unciv.models.ruleset.Ruleset import com.unciv.models.translations.tr +import com.unciv.ui.components.extensions.setSize import com.unciv.ui.images.ImageGetter @@ -281,6 +282,12 @@ object Fonts { for (nation in ruleset.nations.values) addChar(nation.name, ImageGetter.getNationPortrait(nation, ORIGINAL_FONT_SIZE)) + + for (policy in ruleset.policies.values) { + val fileLocation = if (policy.name in ruleset.policyBranches) + "PolicyBranchIcons/" + policy.name else "PolicyIcons/" + policy.name + addChar(policy.name, ImageGetter.getImage(fileLocation).apply { setSize(ORIGINAL_FONT_SIZE) }) + } } val frameBuffer by lazy { FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width, Gdx.graphics.height, false) } @@ -305,6 +312,7 @@ object Fonts { // Pixmap is now *upside down* so we need to flip it around the y axis + pixmap.blending = Pixmap.Blending.None for (i in 0..w) for (j in 0..h/2) { val topPixel = pixmap.getPixel(i,j) diff --git a/core/src/com/unciv/ui/screens/pickerscreens/PolicyPickerScreen.kt b/core/src/com/unciv/ui/screens/pickerscreens/PolicyPickerScreen.kt index be9d547f82..2968dfabc2 100644 --- a/core/src/com/unciv/ui/screens/pickerscreens/PolicyPickerScreen.kt +++ b/core/src/com/unciv/ui/screens/pickerscreens/PolicyPickerScreen.kt @@ -520,10 +520,10 @@ class PolicyPickerScreen(val viewingCiv: Civilization, val canChangeState: Boole }.toGroup(15f) else null val expandIcon = ImageGetter.getImage("OtherIcons/BackArrow").apply { rotation = 90f }.toGroup(10f) table.add(expandIcon).minWidth(15f).expandX().left() - table.add(branch.name.tr().uppercase().toLabel(fontSize = 14).apply { setAlignment(Align.center) }).center() + table.add(branch.name.tr(hideIcons = true).uppercase().toLabel(fontSize = 14).apply { setAlignment(Align.center) }).center() table.add(icon).expandX().left().padLeft(5f) - header.setTouchable(Touchable.enabled) + header.touchable = Touchable.enabled header.add(table).minWidth(150f).growX() header.pack()