mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-03 22:22:51 +07:00
Fix ExploredRegion rectangular maps support + Zoomout flicker prevention reworked (#8826)
* Fix ExploredRegion rectangular maps support + Increased zoom padding * Flicker prevention reworked
This commit is contained in:
parent
ce2f128260
commit
38839d2c9c
@ -544,7 +544,7 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
for (unit in civInfo.units.getCivUnits())
|
||||
unit.updateVisibleTiles(false) // this needs to be done after all the units are assigned to their civs and all other transients are set
|
||||
if(civInfo.playerType == PlayerType.Human)
|
||||
civInfo.exploredRegion.setMapParameters(tileMap.mapParameters.worldWrap, tileMap.mapParameters.mapSize.radius) // Required for the correct calculation of the explored region on world wrap maps
|
||||
civInfo.exploredRegion.setMapParameters(tileMap.mapParameters) // Required for the correct calculation of the explored region on world wrap maps
|
||||
civInfo.cache.updateSightAndResources() // only run ONCE and not for each unit - this is a huge performance saver!
|
||||
|
||||
// Since this depends on the cities of ALL civilizations,
|
||||
|
@ -5,6 +5,8 @@ import com.unciv.logic.IsPartOfGameInfoSerialization
|
||||
import com.unciv.logic.map.HexMath.getLatitude
|
||||
import com.unciv.logic.map.HexMath.getLongitude
|
||||
import com.unciv.logic.map.HexMath.worldFromLatLong
|
||||
import com.unciv.logic.map.MapParameters
|
||||
import com.unciv.logic.map.MapShape
|
||||
import com.unciv.ui.components.tilegroups.TileGroupMap
|
||||
import kotlin.math.abs
|
||||
|
||||
@ -54,10 +56,13 @@ class ExploredRegion () : IsPartOfGameInfoSerialization {
|
||||
return toReturn
|
||||
}
|
||||
|
||||
fun setMapParameters(worldWrap: Boolean, radius: Int)
|
||||
{
|
||||
isWorldWrap = worldWrap
|
||||
mapRadius = radius.toFloat()
|
||||
fun setMapParameters(mapParameters: MapParameters) {
|
||||
isWorldWrap = mapParameters.worldWrap
|
||||
|
||||
if (mapParameters.shape == MapShape.rectangular)
|
||||
mapRadius = (mapParameters.mapSize.width / 2).toFloat()
|
||||
else
|
||||
mapRadius = mapParameters.mapSize.radius.toFloat()
|
||||
}
|
||||
|
||||
// Check if tilePosition is beyond explored region
|
||||
|
@ -61,6 +61,8 @@ class TileGroupMap<T: TileGroup>(
|
||||
private var drawTopX = 0f
|
||||
private var drawBottomX = 0f
|
||||
|
||||
private var maxVisibleMapWidth = 0f
|
||||
|
||||
init {
|
||||
|
||||
for (tileGroup in tileGroups) {
|
||||
@ -141,6 +143,8 @@ class TileGroupMap<T: TileGroup>(
|
||||
else setSize(topX - bottomX, topY - bottomY)
|
||||
|
||||
cullingArea = Rectangle(0f, 0f, width, height)
|
||||
|
||||
maxVisibleMapWidth = width - groupSize * 1.5f
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,7 +173,7 @@ class TileGroupMap<T: TileGroup>(
|
||||
|
||||
if (worldWrap) {
|
||||
// Prevent flickering when zoomed out so you can see entire map
|
||||
val visibleMapWidth = if (mapHolder.width > width) width - groupSize * 1.5f
|
||||
val visibleMapWidth = if (mapHolder.width > maxVisibleMapWidth) maxVisibleMapWidth
|
||||
else mapHolder.width
|
||||
|
||||
// Where is viewport's boundaries
|
||||
|
Loading…
Reference in New Issue
Block a user