From e9296842b6b9f54408b06d2ba86a8a79fae5c016 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 19 Apr 2023 22:31:29 +0300 Subject: [PATCH] 4.6.4-patch2 Use the same framebuffer / spritebatch for all icon renders --- buildSrc/src/main/kotlin/BuildConfig.kt | 4 ++-- core/src/com/unciv/UncivGame.kt | 2 +- core/src/com/unciv/models/ruleset/unique/Unique.kt | 2 +- core/src/com/unciv/ui/components/Fonts.kt | 13 +++++-------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/buildSrc/src/main/kotlin/BuildConfig.kt b/buildSrc/src/main/kotlin/BuildConfig.kt index baadf8c8c7..a6bcf5236a 100644 --- a/buildSrc/src/main/kotlin/BuildConfig.kt +++ b/buildSrc/src/main/kotlin/BuildConfig.kt @@ -3,8 +3,8 @@ package com.unciv.build object BuildConfig { const val kotlinVersion = "1.8.0" const val appName = "Unciv" - const val appCodeNumber = 853 - const val appVersion = "4.6.4-patch1" + const val appCodeNumber = 854 + const val appVersion = "4.6.4-patch2" const val gdxVersion = "1.11.0" const val roboVMVersion = "2.3.1" diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index 872e2e0a0c..2697397b5c 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -531,7 +531,7 @@ open class UncivGame(val isConsoleMode: Boolean = false) : Game(), PlatformSpeci companion object { //region AUTOMATICALLY GENERATED VERSION DATA - DO NOT CHANGE THIS REGION, INCLUDING THIS COMMENT - val VERSION = Version("4.6.4-patch1", 853) + val VERSION = Version("4.6.4-patch2", 854) //endregion lateinit var Current: UncivGame diff --git a/core/src/com/unciv/models/ruleset/unique/Unique.kt b/core/src/com/unciv/models/ruleset/unique/Unique.kt index eb9edfe219..9a14ccd0c8 100644 --- a/core/src/com/unciv/models/ruleset/unique/Unique.kt +++ b/core/src/com/unciv/models/ruleset/unique/Unique.kt @@ -137,7 +137,7 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s val relevantTile by lazy { state.attackedTile ?: state.tile - ?: state.unit?.getTile() + ?: relevantUnit?.getTile() ?: state.city?.getCenterTile() } diff --git a/core/src/com/unciv/ui/components/Fonts.kt b/core/src/com/unciv/ui/components/Fonts.kt index 6b234ca51d..3aee50b357 100644 --- a/core/src/com/unciv/ui/components/Fonts.kt +++ b/core/src/com/unciv/ui/components/Fonts.kt @@ -283,15 +283,16 @@ object Fonts { addChar(nation.name, ImageGetter.getNationPortrait(nation, ORIGINAL_FONT_SIZE)) } - fun getPixmapFromActor(actor: Actor): Pixmap { - val spriteBatch = SpriteBatch() + val frameBuffer by lazy { FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width, Gdx.graphics.height, false) } + val spriteBatch by lazy { SpriteBatch() } + + fun getPixmapFromActor(actor: Actor): Pixmap { - val frameBuffer = - FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width, Gdx.graphics.height, false) frameBuffer.begin() Gdx.gl.glClearColor(0f,0f,0f,0f) Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) + spriteBatch.begin() actor.draw(spriteBatch, 1f) spriteBatch.end() @@ -302,10 +303,6 @@ object Fonts { Gdx.gl.glReadPixels(0, 0, w, h, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixmap.pixels) frameBuffer.end() - // These need to be disposed so they don't clog up the RAM *but not right now* - spriteBatch.dispose() - frameBuffer.dispose() - // Pixmap is now *upside down* so we need to flip it around the y axis for (i in 0..w)