From 03f0b2a1f978ad1d8546d9ea6fab1aff021b675c Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 26 Jul 2018 23:15:33 +0300 Subject: [PATCH] Added getBackground helper function --- core/src/com/unciv/ui/EmpireOverviewScreen.kt | 2 +- core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt | 3 +-- core/src/com/unciv/ui/utils/ImageGetter.kt | 5 +++++ core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt | 2 +- core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt | 3 +-- .../unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt | 3 +-- core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt | 3 +-- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/src/com/unciv/ui/EmpireOverviewScreen.kt b/core/src/com/unciv/ui/EmpireOverviewScreen.kt index fde6c99bc6..3c5ac89f36 100644 --- a/core/src/com/unciv/ui/EmpireOverviewScreen.kt +++ b/core/src/com/unciv/ui/EmpireOverviewScreen.kt @@ -81,7 +81,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){ private fun createTradeTable(trade:Trade, civName:String): Table { val table = Table(skin) - table.background = ImageGetter.getDrawable(ImageGetter.WhiteDot).tint(ImageGetter.getBlue().lerp(Color.BLACK,0.5f)) + table.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK,0.5f)) table.defaults().pad(10f) table.add(civInfo.civName) table.add(civName).row() diff --git a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt index ffd2e778a9..ebb8b57262 100644 --- a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt @@ -70,8 +70,7 @@ open class CameraStageBaseScreen : Screen { private fun displayTutorial() { isTutorialShowing = true val tutorialTable = Table().pad(10f) - tutorialTable.background(ImageGetter.getDrawable(ImageGetter.WhiteDot) - .tint(Color(0x101050cf))) + tutorialTable.background = ImageGetter.getBackground(Color(0x101050cf)) val label = Label(tutorialTexts[0], skin) label.setAlignment(Align.center) tutorialTexts.removeAt(0) diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index ed7a42b9c3..f0a3f90be6 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.scenes.scene2d.ui.Image +import com.badlogic.gdx.scenes.scene2d.utils.Drawable import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable import java.util.* @@ -55,4 +56,8 @@ object ImageGetter { } fun getBlue() = Color(0x004085bf) + + fun getBackground(color:Color): Drawable { + return getDrawable(WhiteDot).tint(color) + } } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt index d6e45611a3..68dd2c2d2d 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt @@ -35,7 +35,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() { val happinessDrawable = ImageGetter.getStatIcon("Happiness").drawable init { - background = ImageGetter.getDrawable("skin/whiteDot.png").tint(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) + background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) add(getStatsTable()).row() add(getResourceTable()) diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt index 81a7072ba0..9e1ee66226 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt @@ -19,8 +19,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() { private val battle = Battle(worldScreen.civInfo.gameInfo) init{ skin = CameraStageBaseScreen.skin - background = ImageGetter.getDrawable(ImageGetter.WhiteDot) - .tint(ImageGetter.getBlue()) + background = ImageGetter.getBackground(ImageGetter.getBlue()) pad(5f) } diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt b/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt index 3d59881711..18dfff4d32 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt @@ -18,8 +18,7 @@ class WorldScreenBottomBar(val worldScreen: WorldScreen) : Table(){ add(battleTable).width(worldScreen.stage.width/3).fill() // so that background fills entire middle third add(tileInfoTable).width(worldScreen.stage.width/3).fill() - val tileTableBackground = ImageGetter.getDrawable(ImageGetter.WhiteDot) - .tint(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) + val tileTableBackground = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) tileTableBackground.minHeight = 0f tileTableBackground.minWidth = 0f background = tileTableBackground diff --git a/core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt b/core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt index 36de07cd98..7a49bbba6b 100644 --- a/core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt +++ b/core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt @@ -9,8 +9,7 @@ import com.unciv.ui.utils.* open class PopupTable: Table(){ init { - val tileTableBackground = ImageGetter.getDrawable("skin/whiteDot.png") - .tint(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) + val tileTableBackground = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) background = tileTableBackground this.pad(20f)