Tile options in map editor screen no longer 'click' on tiles behind them

Fixed new map screen
This commit is contained in:
Yair Morgenstern 2021-04-30 12:29:56 +03:00
parent 81c1e34f0f
commit e9d450eb60
5 changed files with 15 additions and 13 deletions

View File

@ -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() }

View File

@ -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!!))

View File

@ -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() {

View File

@ -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 {

View File

@ -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)