mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 01:08:25 +07:00
Prevent MapEditor 'pinch zoom' painting tiles (#9101)
This commit is contained in:
@ -17,6 +17,7 @@ import com.unciv.ui.components.tilegroups.TileSetStrings
|
|||||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||||
import com.unciv.ui.components.ZoomableScrollPane
|
import com.unciv.ui.components.ZoomableScrollPane
|
||||||
import com.unciv.ui.components.extensions.onClick
|
import com.unciv.ui.components.extensions.onClick
|
||||||
|
import com.unciv.ui.screens.basescreen.UncivStage
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,10 +44,29 @@ class EditorMapHolder(
|
|||||||
if (editorScreen == null) touchable = Touchable.disabled
|
if (editorScreen == null) touchable = Touchable.disabled
|
||||||
continuousScrollingX = tileMap.mapParameters.worldWrap
|
continuousScrollingX = tileMap.mapParameters.worldWrap
|
||||||
addTiles(parentScreen.stage)
|
addTiles(parentScreen.stage)
|
||||||
if (editorScreen != null) addCaptureListener(getDragPaintListener())
|
if (editorScreen != null) {
|
||||||
|
addCaptureListener(getDragPaintListener())
|
||||||
|
setupZoomPanListeners()
|
||||||
|
}
|
||||||
reloadMaxZoom()
|
reloadMaxZoom()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** See also: [WorldMapHolder.setupZoomPanListeners][com.unciv.ui.screens.worldscreen.WorldMapHolder.setupZoomPanListeners] */
|
||||||
|
private fun setupZoomPanListeners() {
|
||||||
|
|
||||||
|
fun setActHit() {
|
||||||
|
val isEnabled = !isZooming() && !isPanning
|
||||||
|
(stage as UncivStage).performPointerEnterExitEvents = isEnabled
|
||||||
|
tileGroupMap.shouldAct = isEnabled
|
||||||
|
tileGroupMap.shouldHit = isEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
onPanStartListener = { setActHit() }
|
||||||
|
onPanStopListener = { setActHit() }
|
||||||
|
onZoomStartListener = { setActHit() }
|
||||||
|
onZoomStopListener = { setActHit() }
|
||||||
|
}
|
||||||
|
|
||||||
private fun addTiles(stage: Stage) {
|
private fun addTiles(stage: Stage) {
|
||||||
|
|
||||||
val tileSetStrings = TileSetStrings()
|
val tileSetStrings = TileSetStrings()
|
||||||
|
@ -189,6 +189,7 @@ class MapEditorEditTab(
|
|||||||
|
|
||||||
fun tileClickHandler(tile: Tile) {
|
fun tileClickHandler(tile: Tile) {
|
||||||
if (brushSize < -1 || brushSize > 5 || brushHandlerType == BrushHandlerType.None) return
|
if (brushSize < -1 || brushSize > 5 || brushHandlerType == BrushHandlerType.None) return
|
||||||
|
if (editorScreen.mapHolder.isPanning || editorScreen.mapHolder.isZooming()) return
|
||||||
editorScreen.hideSelection()
|
editorScreen.hideSelection()
|
||||||
|
|
||||||
when (brushHandlerType) {
|
when (brushHandlerType) {
|
||||||
|
Reference in New Issue
Block a user