Added getBackground helper function

This commit is contained in:
Yair Morgenstern 2018-07-26 23:15:33 +03:00
parent 1cba56c947
commit 03f0b2a1f9
7 changed files with 11 additions and 10 deletions

View file

@ -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()

View file

@ -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)

View file

@ -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)
}
}

View file

@ -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())

View file

@ -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)
}

View file

@ -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

View file

@ -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)