From 4c9e15c0ea754b611fae7a308fe7c24dff4af973 Mon Sep 17 00:00:00 2001 From: lishaoxia1985 <49801619+lishaoxia1985@users.noreply.github.com> Date: Sun, 11 Jul 2021 15:51:57 +0800 Subject: [PATCH] Make map symmetrical if it's not wrapped (#4461) --- core/src/com/unciv/ui/map/TileGroupMap.kt | 6 ++++-- core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt | 2 -- core/src/com/unciv/ui/utils/ZoomableScrollPane.kt | 9 ++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/src/com/unciv/ui/map/TileGroupMap.kt b/core/src/com/unciv/ui/map/TileGroupMap.kt index 9bdf51e490..4206e3449b 100644 --- a/core/src/com/unciv/ui/map/TileGroupMap.kt +++ b/core/src/com/unciv/ui/map/TileGroupMap.kt @@ -120,9 +120,11 @@ class TileGroupMap(tileGroups: Collection, private val leftAndR // there are tiles "below the zero", // so we zero out the starting position of the whole board so they will be displayed as well - // The width has to be lowered by groupSize because wrapped maps are missing a tile on the right. + // Map's width is reduced by groupSize if it is wrapped, because wrapped map will miss a tile on the right. // This ensures that wrapped maps have a smooth transition. - setSize(topX - bottomX + leftAndRightPadding * 2 - groupSize, topY - bottomY + topAndBottomPadding * 2) + // If map is not wrapped, Map's width doesn't need to be reduce by groupSize + if (worldWrap) setSize(topX - bottomX + leftAndRightPadding * 2 - groupSize, topY - bottomY + topAndBottomPadding * 2) + else setSize(topX - bottomX + leftAndRightPadding * 2, topY - bottomY + topAndBottomPadding * 2) } /** diff --git a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt index 7589c3b3e6..74581edb61 100644 --- a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt @@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.Screen import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.GL20 -import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.scenes.scene2d.Stage @@ -96,7 +95,6 @@ open class CameraStageBaseScreen : Screen { skin.get(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts.font.apply { data.setScale(20 / Fonts.ORIGINAL_FONT_SIZE) } skin } - internal var batch: Batch = SpriteBatch() } fun onBackButtonClicked(action: () -> Unit) { diff --git a/core/src/com/unciv/ui/utils/ZoomableScrollPane.kt b/core/src/com/unciv/ui/utils/ZoomableScrollPane.kt index b47bf5eb76..baafc76e61 100644 --- a/core/src/com/unciv/ui/utils/ZoomableScrollPane.kt +++ b/core/src/com/unciv/ui/utils/ZoomableScrollPane.kt @@ -11,10 +11,6 @@ open class ZoomableScrollPane: ScrollPane(null) { var continuousScrollingX = false init{ - // Remove the existing inputListener - // which defines that mouse scroll = vertical movement - val zoomListener = listeners.last { it is InputListener && it !in captureListeners } - removeListener(zoomListener) addZoomListeners() } @@ -30,7 +26,10 @@ open class ZoomableScrollPane: ScrollPane(null) { } private fun addZoomListeners() { - + // At first, Remove the existing inputListener + // which defines that mouse scroll = vertical movement + val zoomListener = listeners.last { it is InputListener && it !in captureListeners } + removeListener(zoomListener) addListener(object : InputListener() { override fun scrolled(event: InputEvent?, x: Float, y: Float, amountX: Float, amountY: Float): Boolean { if (amountX > 0 || amountY > 0) zoomOut()