Fix UI bugs (#8655)

* UI Fixes: fog, flags opacity, air table

---------

Co-authored-by: vegeta1k95 <vfylfhby>
This commit is contained in:
vegeta1k95
2023-02-11 02:35:29 +01:00
committed by GitHub
parent c35c4c4fb5
commit 4f60c36e9a
3 changed files with 18 additions and 17 deletions

View File

@ -66,9 +66,7 @@ class TileLayerOverlay(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
override fun doUpdate(viewingCiv: Civilization?) {
val isViewable = viewingCiv == null || isViewable(viewingCiv)
if (!isViewable && !tileGroup.isForceVisible)
fog.isVisible = true
fog.isVisible = !isViewable && !tileGroup.isForceVisible
if (viewingCiv == null)
return

View File

@ -58,10 +58,10 @@ class TileLayerUnitFlag(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup
// Display air unit table for carriers/transports
if (unit.getTile().airUnits.any { unit.isTransportTypeOf(it) } && !unit.getTile().isCityCenter()) {
val table = getAirUnitTable(unit)
addActor(table)
newIcon.addActor(table)
table.toBack()
table.y = newIcon.y + newIcon.height/2 - table.height/2
table.x = newIcon.x + newIcon.width - table.width/2
table.y = newIcon.height/2 - table.height/2
table.x = newIcon.width - table.width*0.45f
}
// Fade out action indicator for own non-idle units
@ -70,7 +70,7 @@ class TileLayerUnitFlag(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup
// Fade out flag for own out-of-moves units
if (unit.civ == viewingCiv && unit.currentMovement == 0f)
newIcon.color.a = 0.5f
newIcon.color.a = 0.5f * UncivGame.Current.settings.unitIconOpacity
}

View File

@ -185,42 +185,45 @@ class UnitGroup(val unit: MapUnit, val size: Float): Group() {
}
fun highlightRed() {
flagSelection.color = colorFromRGB(230, 0, 0).apply { a = 1f }
flagSelection.color = colorFromRGB(230, 0, 0)
flagBg.drawOutline = true
}
fun selectUnit() {
color.a = 1f
val opacity = UncivGame.Current.settings.unitIconOpacity
color.a = opacity
//If unit is idle, leave actionGroup at 50% opacity when selected
if (unit.isIdle()) {
actionGroup?.color?.a = 0.5f
actionGroup?.color?.a = opacity * 0.5f
} else { //Else set to 100% opacity when selected
actionGroup?.color?.a = 1f
actionGroup?.color?.a = opacity
}
// Unit base icon is faded out only if out of moves
// Foreign unit icons are never faded!
val shouldBeFaded = (unit.owner == UncivGame.Current.worldScreen?.viewingCiv?.civName
&& unit.currentMovement == 0f)
val alpha = if (shouldBeFaded) 0.5f else 1f
val alpha = if (shouldBeFaded) opacity * 0.5f else opacity
flagIcon.color.a = alpha
flagBg.color.a = alpha
flagSelection.color.a = 1f
flagSelection.color.a = opacity
if (UncivGame.Current.settings.continuousRendering) {
flagSelection.color.a = 1f
flagSelection.color.a = opacity
flagSelection.addAction(
Actions.repeat(
RepeatAction.FOREVER,
Actions.sequence(
Actions.alpha(0.7f, 1f),
Actions.alpha(1f, 1f)
Actions.alpha(opacity*0.7f, 1f),
Actions.alpha(opacity, 1f)
)
)
)
} else {
flagSelection.color.a = 0.8f
flagSelection.color.a = opacity * 0.8f
}
}
}