Replaced BackgroundActor companion (#7749)

as it was interfering with the moddable UI
This commit is contained in:
Leonard Günther
2022-09-07 11:18:47 +02:00
committed by GitHub
parent 7c1b298a24
commit 35e225b68f
2 changed files with 3 additions and 14 deletions

View File

@ -1,8 +1,6 @@
package com.unciv.ui.worldscreen
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.NinePatch
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.utils.Drawable
@ -11,7 +9,7 @@ import com.badlogic.gdx.utils.Align
import com.unciv.ui.images.ImageGetter
/** An Actor that just draws a Drawable [background], preferably a [NinePatchDrawable] created
* by [BackgroundActor.getRoundedEdgeRectangle], meant to work in Table Cells and to be overlaid with other Widgets.
* by [ImageGetter.getRoundedEdgeRectangle], meant to work in Table Cells and to be overlaid with other Widgets.
* The drawable's center can be moved to any of the corners or vertex centers using `align`, which will also scale the
* drawable up by factor 2 and clip to the original rectangle. This can be used to draw rectangles with one or two rounded corners.
* @param align An [Align] constant - In which corner of the [BackgroundActor] rectangle the center of the [background] should be.
@ -49,13 +47,4 @@ class BackgroundActor(val background: Drawable, align: Int) : Actor() {
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha)
background.draw(batch, x, y, w, h)
}
companion object {
fun getRoundedEdgeRectangle(tintColor: Color): NinePatchDrawable {
val region = ImageGetter.getDrawable("Skin/roundedEdgeRectangle").region
val drawable = NinePatchDrawable(NinePatch(region, 25, 25, 24, 24))
drawable.setPadding(15f, 15f, 15f, 15f)
return drawable.tint(tintColor)
}
}
}

View File

@ -81,10 +81,10 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
resourceTable.background = backgroundDrawable
add(statsTable).colspan(3).growX().row()
add(resourceTable).colspan(3).growX().row()
val leftFillerBG = BackgroundActor.getRoundedEdgeRectangle(backColor)
val leftFillerBG = ImageGetter.getRoundedEdgeRectangle(backColor)
leftFillerCell = add(BackgroundActor(leftFillerBG, Align.topLeft))
add().growX()
val rightFillerBG = BackgroundActor.getRoundedEdgeRectangle(backColor)
val rightFillerBG = ImageGetter.getRoundedEdgeRectangle(backColor)
rightFillerCell = add(BackgroundActor(rightFillerBG, Align.topRight))
pack()
}