From e9d450eb60587aa9db41e1d83a186ea9b45d8335 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 30 Apr 2021 12:29:56 +0300 Subject: [PATCH] Tile options in map editor screen no longer 'click' on tiles behind them Fixed new map screen --- .../com/unciv/ui/mapeditor/EditorMapHolder.kt | 4 ++-- .../unciv/ui/mapeditor/GameParametersScreen.kt | 2 +- ...rOptionsTable.kt => MapEditorOptionsTable.kt} | 4 +++- .../com/unciv/ui/mapeditor/MapEditorScreen.kt | 16 ++++++++-------- core/src/com/unciv/ui/mapeditor/NewMapScreen.kt | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) rename core/src/com/unciv/ui/mapeditor/{TileEditorOptionsTable.kt => MapEditorOptionsTable.kt} (98%) diff --git a/core/src/com/unciv/ui/mapeditor/EditorMapHolder.kt b/core/src/com/unciv/ui/mapeditor/EditorMapHolder.kt index 62d63e8747..ed560c256c 100644 --- a/core/src/com/unciv/ui/mapeditor/EditorMapHolder.kt +++ b/core/src/com/unciv/ui/mapeditor/EditorMapHolder.kt @@ -57,10 +57,10 @@ class EditorMapHolder(private val mapEditorScreen: MapEditorScreen, internal val tileGroup.update() tileGroup.onClick { - val distance = mapEditorScreen.tileEditorOptions.brushSize - 1 + val distance = mapEditorScreen.mapEditorOptionsTable.brushSize - 1 for (tileInfo in mapEditorScreen.tileMap.getTilesInDistance(tileGroup.tileInfo.position, distance)) { - mapEditorScreen.tileEditorOptions.updateTileWhenClicked(tileInfo) + mapEditorScreen.mapEditorOptionsTable.updateTileWhenClicked(tileInfo) tileInfo.setTerrainTransients() tileGroups[tileInfo]!!.forEach { it.update() } diff --git a/core/src/com/unciv/ui/mapeditor/GameParametersScreen.kt b/core/src/com/unciv/ui/mapeditor/GameParametersScreen.kt index 6786122f16..b48631b82e 100644 --- a/core/src/com/unciv/ui/mapeditor/GameParametersScreen.kt +++ b/core/src/com/unciv/ui/mapeditor/GameParametersScreen.kt @@ -35,7 +35,7 @@ class GameParametersScreen(var mapEditorScreen: MapEditorScreen): IPreviousScree mapEditorScreen.gameSetupInfo = gameSetupInfo mapEditorScreen.ruleset.clear() mapEditorScreen.ruleset.add(ruleset) - mapEditorScreen.tileEditorOptions.update() + mapEditorScreen.mapEditorOptionsTable.update() // Remove resources that are not applicable to this ruleset for(tile in mapEditorScreen.tileMap.values) { if (tile.resource != null && !ruleset.tileResources.containsKey(tile.resource!!)) diff --git a/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt b/core/src/com/unciv/ui/mapeditor/MapEditorOptionsTable.kt similarity index 98% rename from core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt rename to core/src/com/unciv/ui/mapeditor/MapEditorOptionsTable.kt index be59a1a05a..32458e5832 100644 --- a/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt +++ b/core/src/com/unciv/ui/mapeditor/MapEditorOptionsTable.kt @@ -3,6 +3,7 @@ package com.unciv.ui.mapeditor import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.Group +import com.badlogic.gdx.scenes.scene2d.Touchable import com.badlogic.gdx.scenes.scene2d.ui.Slider import com.badlogic.gdx.scenes.scene2d.ui.Table import com.unciv.Constants @@ -20,7 +21,7 @@ import com.unciv.ui.tilegroups.TileGroup import com.unciv.ui.tilegroups.TileSetStrings import com.unciv.ui.utils.* -class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraStageBaseScreen.skin) { +class MapEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraStageBaseScreen.skin) { private val tileSetLocation = "TileSets/" + UncivGame.Current.settings.tileSet + "/" var tileAction: (TileInfo) -> Unit = {} @@ -37,6 +38,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera init { update() + touchable = Touchable.enabled } fun update() { diff --git a/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt b/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt index 6d483245e0..2b22e1ccfe 100644 --- a/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt +++ b/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt @@ -20,7 +20,7 @@ class MapEditorScreen(): CameraStageBaseScreen() { var gameSetupInfo = GameSetupInfo() lateinit var mapHolder: EditorMapHolder - lateinit var tileEditorOptions: TileEditorOptionsTable + lateinit var mapEditorOptionsTable: MapEditorOptionsTable private val showHideEditorOptionsButton = ">".toTextButton() @@ -40,18 +40,18 @@ class MapEditorScreen(): CameraStageBaseScreen() { stage.addActor(mapHolder) stage.scrollFocus = mapHolder - tileEditorOptions = TileEditorOptionsTable(this) - stage.addActor(tileEditorOptions) - tileEditorOptions.setPosition(stage.width - tileEditorOptions.width, 0f) + mapEditorOptionsTable = MapEditorOptionsTable(this) + stage.addActor(mapEditorOptionsTable) + mapEditorOptionsTable.setPosition(stage.width - mapEditorOptionsTable.width, 0f) showHideEditorOptionsButton.labelCell.pad(10f) showHideEditorOptionsButton.pack() showHideEditorOptionsButton.onClick { if (showHideEditorOptionsButton.text.toString() == ">") { - tileEditorOptions.addAction(Actions.moveTo(stage.width, 0f, 0.5f)) + mapEditorOptionsTable.addAction(Actions.moveTo(stage.width, 0f, 0.5f)) showHideEditorOptionsButton.setText("<") } else { - tileEditorOptions.addAction(Actions.moveTo(stage.width - tileEditorOptions.width, 0f, 0.5f)) + mapEditorOptionsTable.addAction(Actions.moveTo(stage.width - mapEditorOptionsTable.width, 0f, 0.5f)) showHideEditorOptionsButton.setText(">") } } @@ -103,10 +103,10 @@ class MapEditorScreen(): CameraStageBaseScreen() { val stageCoords = mapHolder.actor.stageToLocalCoordinates(Vector2(event!!.stageX, event.stageY)) val centerTileInfo = mapHolder.getClosestTileTo(stageCoords) if (centerTileInfo != null) { - val distance = tileEditorOptions.brushSize - 1 + val distance = mapEditorOptionsTable.brushSize - 1 for (tileInfo in tileMap.getTilesInDistance(centerTileInfo.position, distance)) { - tileEditorOptions.updateTileWhenClicked(tileInfo) + mapEditorOptionsTable.updateTileWhenClicked(tileInfo) tileInfo.setTerrainTransients() mapHolder.tileGroups[tileInfo]!!.forEach { diff --git a/core/src/com/unciv/ui/mapeditor/NewMapScreen.kt b/core/src/com/unciv/ui/mapeditor/NewMapScreen.kt index a7224af746..2085ed1d6d 100644 --- a/core/src/com/unciv/ui/mapeditor/NewMapScreen.kt +++ b/core/src/com/unciv/ui/mapeditor/NewMapScreen.kt @@ -46,7 +46,7 @@ class NewMapScreen(val mapParameters: MapParameters = MapParameters()) : PickerS topTable.apply { add(ScrollPane(newMapScreenOptionsTable).apply { setOverscroll(false, false) }) pack() - setFillParent(true) +// setFillParent(true) } rightButtonSetEnabled(true)