mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 13:18:56 +07:00
Fix UI bugs (#8655)
* UI Fixes: fog, flags opacity, air table --------- Co-authored-by: vegeta1k95 <vfylfhby>
This commit is contained in:
@ -66,9 +66,7 @@ class TileLayerOverlay(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
override fun doUpdate(viewingCiv: Civilization?) {
|
override fun doUpdate(viewingCiv: Civilization?) {
|
||||||
|
|
||||||
val isViewable = viewingCiv == null || isViewable(viewingCiv)
|
val isViewable = viewingCiv == null || isViewable(viewingCiv)
|
||||||
|
fog.isVisible = !isViewable && !tileGroup.isForceVisible
|
||||||
if (!isViewable && !tileGroup.isForceVisible)
|
|
||||||
fog.isVisible = true
|
|
||||||
|
|
||||||
if (viewingCiv == null)
|
if (viewingCiv == null)
|
||||||
return
|
return
|
||||||
|
@ -58,10 +58,10 @@ class TileLayerUnitFlag(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup
|
|||||||
// Display air unit table for carriers/transports
|
// Display air unit table for carriers/transports
|
||||||
if (unit.getTile().airUnits.any { unit.isTransportTypeOf(it) } && !unit.getTile().isCityCenter()) {
|
if (unit.getTile().airUnits.any { unit.isTransportTypeOf(it) } && !unit.getTile().isCityCenter()) {
|
||||||
val table = getAirUnitTable(unit)
|
val table = getAirUnitTable(unit)
|
||||||
addActor(table)
|
newIcon.addActor(table)
|
||||||
table.toBack()
|
table.toBack()
|
||||||
table.y = newIcon.y + newIcon.height/2 - table.height/2
|
table.y = newIcon.height/2 - table.height/2
|
||||||
table.x = newIcon.x + newIcon.width - table.width/2
|
table.x = newIcon.width - table.width*0.45f
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fade out action indicator for own non-idle units
|
// 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
|
// Fade out flag for own out-of-moves units
|
||||||
if (unit.civ == viewingCiv && unit.currentMovement == 0f)
|
if (unit.civ == viewingCiv && unit.currentMovement == 0f)
|
||||||
newIcon.color.a = 0.5f
|
newIcon.color.a = 0.5f * UncivGame.Current.settings.unitIconOpacity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,42 +185,45 @@ class UnitGroup(val unit: MapUnit, val size: Float): Group() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun highlightRed() {
|
fun highlightRed() {
|
||||||
flagSelection.color = colorFromRGB(230, 0, 0).apply { a = 1f }
|
flagSelection.color = colorFromRGB(230, 0, 0)
|
||||||
flagBg.drawOutline = true
|
flagBg.drawOutline = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun selectUnit() {
|
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 is idle, leave actionGroup at 50% opacity when selected
|
||||||
if (unit.isIdle()) {
|
if (unit.isIdle()) {
|
||||||
actionGroup?.color?.a = 0.5f
|
actionGroup?.color?.a = opacity * 0.5f
|
||||||
} else { //Else set to 100% opacity when selected
|
} 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
|
// Unit base icon is faded out only if out of moves
|
||||||
// Foreign unit icons are never faded!
|
// Foreign unit icons are never faded!
|
||||||
val shouldBeFaded = (unit.owner == UncivGame.Current.worldScreen?.viewingCiv?.civName
|
val shouldBeFaded = (unit.owner == UncivGame.Current.worldScreen?.viewingCiv?.civName
|
||||||
&& unit.currentMovement == 0f)
|
&& unit.currentMovement == 0f)
|
||||||
val alpha = if (shouldBeFaded) 0.5f else 1f
|
val alpha = if (shouldBeFaded) opacity * 0.5f else opacity
|
||||||
flagIcon.color.a = alpha
|
flagIcon.color.a = alpha
|
||||||
flagBg.color.a = alpha
|
flagBg.color.a = alpha
|
||||||
flagSelection.color.a = 1f
|
flagSelection.color.a = opacity
|
||||||
|
|
||||||
if (UncivGame.Current.settings.continuousRendering) {
|
if (UncivGame.Current.settings.continuousRendering) {
|
||||||
flagSelection.color.a = 1f
|
flagSelection.color.a = opacity
|
||||||
flagSelection.addAction(
|
flagSelection.addAction(
|
||||||
Actions.repeat(
|
Actions.repeat(
|
||||||
RepeatAction.FOREVER,
|
RepeatAction.FOREVER,
|
||||||
Actions.sequence(
|
Actions.sequence(
|
||||||
Actions.alpha(0.7f, 1f),
|
Actions.alpha(opacity*0.7f, 1f),
|
||||||
Actions.alpha(1f, 1f)
|
Actions.alpha(opacity, 1f)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
flagSelection.color.a = 0.8f
|
flagSelection.color.a = opacity * 0.8f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user