ImageGetter.getDrawable a few ns faster (#6936)

This commit is contained in:
SomeTroglodyte 2022-05-25 18:33:17 +02:00 committed by GitHub
parent 6f7af9ee22
commit e927ef6f64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -170,8 +170,7 @@ object ImageGetter {
}
fun getDrawable(fileName: String?): TextureRegionDrawable {
return if (fileName != null && textureRegionDrawables.containsKey(fileName)) textureRegionDrawables[fileName]!!
else textureRegionDrawables[whiteDotLocation]!!
return textureRegionDrawables[fileName] ?: textureRegionDrawables[whiteDotLocation]!!
}
fun getRoundedEdgeRectangle(tintColor: Color? = null): NinePatchDrawable {

View File

@ -57,13 +57,13 @@ fun Color.darken(t: Float): Color = Color(this).lerp(Color.BLACK, t)
* The result is returned as a new instance. */
fun Color.brighten(t: Float): Color = Color(this).lerp(Color.WHITE, t)
fun Actor.centerX(parent: Actor){ x = parent.width/2 - width/2 }
fun Actor.centerY(parent: Actor){ y = parent.height/2- height/2}
fun Actor.center(parent: Actor){ centerX(parent); centerY(parent)}
fun Actor.centerX(parent: Actor) { x = parent.width / 2 - width / 2 }
fun Actor.centerY(parent: Actor) { y = parent.height / 2 - height / 2 }
fun Actor.center(parent: Actor) { centerX(parent); centerY(parent) }
fun Actor.centerX(parent: Stage){ x = parent.width/2 - width/2 }
fun Actor.centerY(parent: Stage){ y = parent.height/2- height/2}
fun Actor.center(parent: Stage){ centerX(parent); centerY(parent)}
fun Actor.centerX(parent: Stage) { x = parent.width / 2 - width / 2 }
fun Actor.centerY(parent: Stage) { y = parent.height / 2 - height / 2 }
fun Actor.center(parent: Stage) { centerX(parent); centerY(parent) }
/** same as [onClick], but sends the [InputEvent] and coordinates along */
fun Actor.onClickEvent(sound: UncivSound = UncivSound.Click, function: (event: InputEvent?, x: Float, y: Float) -> Unit) {