Map exploring disables undo button + ExploredRegion smallfixes (#8741)

This commit is contained in:
Gualdimar 2023-02-25 00:44:43 +02:00 committed by GitHub
parent 3278cbc904
commit e69eb5b518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 12 deletions

View File

@ -115,13 +115,12 @@ class ExploredRegion () : IsPartOfGameInfoSerialization {
}
// Expand region from the nearest edge
if (rightSideDistance > leftSideDistance) {
if (rightSideDistance > leftSideDistance)
topLeft.x = longitude
shouldRecalculateCoords = true
} else {
else
bottomRight.x = longitude
shouldRecalculateCoords = true
}
shouldRecalculateCoords = true
}
}
@ -146,7 +145,7 @@ class ExploredRegion () : IsPartOfGameInfoSerialization {
val bottomRightWorld = worldFromLatLong(bottomRight, tileRadius)
// Convert X to the stage coords
val mapCenterX = mapMaxX * 0.5f + tileRadius
val mapCenterX = if (isWorldWrap) mapMaxX * 0.5f + tileRadius else mapMaxX * 0.5f
var left = mapCenterX + topLeftWorld.x
var right = mapCenterX + bottomRightWorld.x

View File

@ -2,6 +2,7 @@
import com.badlogic.gdx.math.Vector2
import com.unciv.Constants
import com.unciv.GUI
import com.unciv.UncivGame
import com.unciv.logic.IsPartOfGameInfoSerialization
import com.unciv.logic.city.City
@ -248,7 +249,13 @@ open class Tile : IsPartOfGameInfoSerialization {
fun setExplored(player: Civilization, isExplored: Boolean, explorerPosition: Vector2? = null) {
if (isExplored) {
exploredBy.add(player.civName)
player.exploredTiles.add(position)
// Disable the undo button if a new tile has been explored
if (player.exploredTiles.add(position) && GUI.isWorldLoaded()) {
val worldScreen = GUI.getWorldScreen()
worldScreen.preActionGameInfo = worldScreen.gameInfo
}
if(player.playerType == PlayerType.Human)
player.exploredRegion.checkTilePosition(position, explorerPosition)
} else {

View File

@ -118,7 +118,7 @@ class TechPolicyDiplomacyButtons(val worldScreen: WorldScreen) : Table(BaseScree
}
private fun updateUndoButton() {
// Don't show policies until they become relevant
// Don't show the undo button if there is no action to undo
if (worldScreen.gameInfo != worldScreen.preActionGameInfo) {
undoButtonHolder.touchable = Touchable.enabled
undoButtonHolder.actor = undoButton

View File

@ -305,10 +305,10 @@ class WorldScreen(
fun whileKeyPressedLoop() {
for (keycode in pressedKeys) {
when (keycode) {
Input.Keys.W, Input.Keys.UP -> mapHolder.scrollY -= amountToMove
Input.Keys.S, Input.Keys.DOWN -> mapHolder.scrollY += amountToMove
Input.Keys.A, Input.Keys.LEFT -> mapHolder.scrollX -= amountToMove
Input.Keys.D, Input.Keys.RIGHT -> mapHolder.scrollX += amountToMove
Input.Keys.W, Input.Keys.UP -> mapHolder.scrollY = mapHolder.restrictY(-amountToMove)
Input.Keys.S, Input.Keys.DOWN -> mapHolder.scrollY = mapHolder.restrictY(amountToMove)
Input.Keys.A, Input.Keys.LEFT -> mapHolder.scrollX = mapHolder.restrictX(amountToMove)
Input.Keys.D, Input.Keys.RIGHT -> mapHolder.scrollX = mapHolder.restrictX(-amountToMove)
}
}
mapHolder.updateVisualScroll()