mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
ImageGetter.getDrawable a few ns faster (#6936)
This commit is contained in:
parent
6f7af9ee22
commit
e927ef6f64
@ -170,8 +170,7 @@ object ImageGetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getDrawable(fileName: String?): TextureRegionDrawable {
|
fun getDrawable(fileName: String?): TextureRegionDrawable {
|
||||||
return if (fileName != null && textureRegionDrawables.containsKey(fileName)) textureRegionDrawables[fileName]!!
|
return textureRegionDrawables[fileName] ?: textureRegionDrawables[whiteDotLocation]!!
|
||||||
else textureRegionDrawables[whiteDotLocation]!!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRoundedEdgeRectangle(tintColor: Color? = null): NinePatchDrawable {
|
fun getRoundedEdgeRectangle(tintColor: Color? = null): NinePatchDrawable {
|
||||||
|
@ -57,13 +57,13 @@ fun Color.darken(t: Float): Color = Color(this).lerp(Color.BLACK, t)
|
|||||||
* The result is returned as a new instance. */
|
* The result is returned as a new instance. */
|
||||||
fun Color.brighten(t: Float): Color = Color(this).lerp(Color.WHITE, t)
|
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.centerX(parent: Actor) { x = parent.width / 2 - width / 2 }
|
||||||
fun Actor.centerY(parent: Actor){ y = parent.height/2- height/2}
|
fun Actor.centerY(parent: Actor) { y = parent.height / 2 - height / 2 }
|
||||||
fun Actor.center(parent: Actor){ centerX(parent); centerY(parent)}
|
fun Actor.center(parent: Actor) { centerX(parent); centerY(parent) }
|
||||||
|
|
||||||
fun Actor.centerX(parent: Stage){ x = parent.width/2 - width/2 }
|
fun Actor.centerX(parent: Stage) { x = parent.width / 2 - width / 2 }
|
||||||
fun Actor.centerY(parent: Stage){ y = parent.height/2- height/2}
|
fun Actor.centerY(parent: Stage) { y = parent.height / 2 - height / 2 }
|
||||||
fun Actor.center(parent: Stage){ centerX(parent); centerY(parent)}
|
fun Actor.center(parent: Stage) { centerX(parent); centerY(parent) }
|
||||||
|
|
||||||
/** same as [onClick], but sends the [InputEvent] and coordinates along */
|
/** 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) {
|
fun Actor.onClickEvent(sound: UncivSound = UncivSound.Click, function: (event: InputEvent?, x: Float, y: Float) -> Unit) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user