mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
Removed zoom limit for world-wrap maps (#8684)
* Removed zoom limit for world-wrap maps * Update min/max zoom after changing options * Returned zoom limit for world screen
This commit is contained in:
parent
c6b888e6ed
commit
51e223c8ad
@ -45,7 +45,7 @@ open class ZoomableScrollPane(
|
|||||||
this.addListener(zoomListener)
|
this.addListener(zoomListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reloadMaxZoom() {
|
open fun reloadMaxZoom() {
|
||||||
|
|
||||||
maxZoom = UncivGame.Current.settings.maxWorldZoomOut
|
maxZoom = UncivGame.Current.settings.maxWorldZoomOut
|
||||||
minZoom = 1f / maxZoom
|
minZoom = 1f / maxZoom
|
||||||
@ -90,17 +90,6 @@ open class ZoomableScrollPane(
|
|||||||
updatePadding()
|
updatePadding()
|
||||||
super.sizeChanged()
|
super.sizeChanged()
|
||||||
updateCulling()
|
updateCulling()
|
||||||
|
|
||||||
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 content = actor
|
|
||||||
if (content != null)
|
|
||||||
minZoom = max((width + 80f) * scaleX / content.width, 1f / UncivGame.Current.settings.maxWorldZoomOut)// add some extra padding offset
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePadding() {
|
private fun updatePadding() {
|
||||||
|
@ -163,9 +163,14 @@ class TileGroupMap<T: TileGroup>(
|
|||||||
|
|
||||||
if (worldWrap) {
|
if (worldWrap) {
|
||||||
|
|
||||||
|
// Prevent flickering when zoomed out so you can see entire map
|
||||||
|
val visibleMapWidth: Float
|
||||||
|
if(mapHolder.width > width) visibleMapWidth = width - groupSize * 1.5f
|
||||||
|
else visibleMapWidth = mapHolder.width
|
||||||
|
|
||||||
// Where is viewport's boundaries
|
// Where is viewport's boundaries
|
||||||
val rightSide = mapHolder.scrollX + mapHolder.width/2f
|
val rightSide = mapHolder.scrollX + visibleMapWidth/2f
|
||||||
val leftSide = mapHolder.scrollX - mapHolder.width/2f
|
val leftSide = mapHolder.scrollX - visibleMapWidth/2f
|
||||||
|
|
||||||
// Have we looked beyond map?
|
// Have we looked beyond map?
|
||||||
val diffRight = rightSide - topX
|
val diffRight = rightSide - topX
|
||||||
|
@ -169,6 +169,7 @@ private fun addMaxZoomSlider(table: Table, settings: GameSettings) {
|
|||||||
) {
|
) {
|
||||||
settings.maxWorldZoomOut = it
|
settings.maxWorldZoomOut = it
|
||||||
settings.save()
|
settings.save()
|
||||||
|
UncivGame.Current.worldScreen?.mapHolder?.reloadMaxZoom()
|
||||||
}
|
}
|
||||||
table.add(maxZoomSlider).pad(5f).row()
|
table.add(maxZoomSlider).pad(5f).row()
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ import com.unciv.ui.screens.basescreen.UncivStage
|
|||||||
import com.unciv.utils.Log
|
import com.unciv.utils.Log
|
||||||
import com.unciv.utils.concurrency.Concurrency
|
import com.unciv.utils.concurrency.Concurrency
|
||||||
import com.unciv.utils.concurrency.launchOnGLThread
|
import com.unciv.utils.concurrency.launchOnGLThread
|
||||||
|
import java.lang.Float.max
|
||||||
|
|
||||||
|
|
||||||
class WorldMapHolder(
|
class WorldMapHolder(
|
||||||
@ -71,7 +72,6 @@ class WorldMapHolder(
|
|||||||
init {
|
init {
|
||||||
if (Gdx.app.type == Application.ApplicationType.Desktop) this.setFlingTime(0f)
|
if (Gdx.app.type == Application.ApplicationType.Desktop) this.setFlingTime(0f)
|
||||||
continuousScrollingX = tileMap.mapParameters.worldWrap
|
continuousScrollingX = tileMap.mapParameters.worldWrap
|
||||||
reloadMaxZoom()
|
|
||||||
setupZoomPanListeners()
|
setupZoomPanListeners()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -753,6 +753,28 @@ class WorldMapHolder(
|
|||||||
unitActionOverlays.clear()
|
unitActionOverlays.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 pad = width / tileMap.mapParameters.mapSize.radius * 0.7f
|
||||||
|
minZoom = max(
|
||||||
|
(width + pad) * scaleX / maxX,
|
||||||
|
1f / UncivGame.Current.settings.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)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
super.reloadMaxZoom()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// For debugging purposes
|
// For debugging purposes
|
||||||
override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha)
|
override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha)
|
||||||
override fun act(delta: Float) = super.act(delta)
|
override fun act(delta: Float) = super.act(delta)
|
||||||
|
@ -137,6 +137,7 @@ class WorldScreen(
|
|||||||
|
|
||||||
// This is the most memory-intensive operation we have currently, most OutOfMemory errors will occur here
|
// This is the most memory-intensive operation we have currently, most OutOfMemory errors will occur here
|
||||||
mapHolder.addTiles()
|
mapHolder.addTiles()
|
||||||
|
mapHolder.reloadMaxZoom()
|
||||||
|
|
||||||
// resume music (in case choices from the menu lead to instantiation of a new WorldScreen)
|
// resume music (in case choices from the menu lead to instantiation of a new WorldScreen)
|
||||||
UncivGame.Current.musicController.resume()
|
UncivGame.Current.musicController.resume()
|
||||||
@ -242,7 +243,6 @@ class WorldScreen(
|
|||||||
}
|
}
|
||||||
globalShortcuts.add(KeyCharAndCode.ctrl('O')) { // Game Options
|
globalShortcuts.add(KeyCharAndCode.ctrl('O')) { // Game Options
|
||||||
this.openOptionsPopup(onClose = {
|
this.openOptionsPopup(onClose = {
|
||||||
mapHolder.reloadMaxZoom()
|
|
||||||
nextTurnButton.update(this)
|
nextTurnButton.update(this)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user