Option to disable max zoom limit (#8702)

* Option to disable max zoom limit

* Reverted old flickering fix

* Reworked

* Removed redundant import

* Added comment
This commit is contained in:
Gualdimar 2023-02-20 16:44:30 +02:00 committed by GitHub
parent f99c322319
commit 0b507422f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 14 deletions

View File

@ -86,7 +86,7 @@ open class ZoomableScrollPane(
onViewportChanged()
}
public override fun sizeChanged() {
override fun sizeChanged() {
updatePadding()
super.sizeChanged()
updateCulling()

View File

@ -134,11 +134,6 @@ class MapEditorScreen(map: TileMap? = null): BaseScreen(), RecreateOnResize {
tileClickHandler?.invoke(it)
}
if (tileMap.mapParameters.worldWrap) {
result.sizeChanged()
result.zoom(result.minZoom)
}
stage.root.addActorAt(0, result)
stage.scrollFocus = result

View File

@ -755,20 +755,23 @@ class WorldMapHolder(
override fun reloadMaxZoom()
{
if (continuousScrollingX) {
// For world-wrap we do not allow viewport to become bigger than the map size,
// because we don't want to render the same tiles multiple times (they will be
// flickering because of movement).
// Hence we limit minimal possible zoom to content width + some extra offset.
val maxWorldZoomOut = UncivGame.Current.settings.maxWorldZoomOut
val mapRadius = tileMap.mapParameters.mapSize.radius
val pad = width / tileMap.mapParameters.mapSize.radius * 0.7f
// Limit max zoom out by the map width
val enableZoomLimit = (mapRadius < 21 && maxWorldZoomOut < 3f) || (mapRadius > 20 && maxWorldZoomOut < 4f)
if (enableZoomLimit) {
// For world-wrap we limit minimal possible zoom to content width + some extra offset
// to hide one column of tiles so that the player doesn't see it teleporting from side to side
val pad = if (continuousScrollingX) width / mapRadius * 0.7f else 0f
minZoom = max(
(width + pad) * scaleX / maxX,
1f / UncivGame.Current.settings.maxWorldZoomOut
1f / maxWorldZoomOut
)// add some extra padding offset
// If the window becomes too wide and minZoom > maxZoom, we cannot zoom
maxZoom = max(2f * minZoom, UncivGame.Current.settings.maxWorldZoomOut)
maxZoom = max(2f * minZoom, maxWorldZoomOut)
}
else
super.reloadMaxZoom()