mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 11:34:54 -04:00
UI: Fixed edges for edge tiles on word wrap maps
This commit is contained in:
parent
8f5979ac2a
commit
df72363bf0
@ -310,6 +310,7 @@ class TileMap(initialCapacity: Int = 10) : IsPartOfGameInfoSerialization {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the clock position of [otherTile] seen from [tile]'s position
|
||||
* Returns -1 if not neighbors
|
||||
@ -789,3 +790,16 @@ class TileMap(initialCapacity: Int = 10) : IsPartOfGameInfoSerialization {
|
||||
.distinct()
|
||||
}
|
||||
}
|
||||
|
||||
enum class NeighborDirection(val clockPosition: Int) {
|
||||
TopRight(2),
|
||||
BottomRight(4),
|
||||
Bottom(6),
|
||||
BottomLeft(8),
|
||||
TopLeft(10),
|
||||
Top(12);
|
||||
|
||||
companion object {
|
||||
val byClockPosition = entries.associateBy { it.clockPosition }
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package com.unciv.ui.components.tilegroups
|
||||
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.logic.map.NeighborDirection
|
||||
import com.unciv.logic.map.mapunit.MapUnit
|
||||
import com.unciv.logic.map.tile.RoadStatus
|
||||
import com.unciv.models.metadata.GameSettings
|
||||
@ -9,7 +10,6 @@ import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.tilesets.TileSetCache
|
||||
import com.unciv.models.tilesets.TileSetConfig
|
||||
import com.unciv.ui.components.tilegroups.layers.EdgeTileImage
|
||||
import com.unciv.ui.components.tilegroups.layers.NeighborDirection
|
||||
import com.unciv.ui.images.ImageAttempter
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
|
||||
|
@ -2,15 +2,15 @@ package com.unciv.ui.components.tilegroups.layers
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.Batch
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.logic.map.NeighborDirection
|
||||
import com.unciv.logic.map.tile.Tile
|
||||
import com.unciv.models.ruleset.unique.LocalUniqueCache
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.components.tilegroups.TileGroup
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import kotlin.random.Random
|
||||
|
||||
@ -108,7 +108,8 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
||||
|
||||
private val neighborEdgeDataList: Sequence<NeighborEdgeData> = if (!tile.isTilemapInitialized()) emptySequence()
|
||||
else tile.neighbors.map {
|
||||
val direction = NeighborDirection.fromVector(it.position.cpy().sub(tile.position))
|
||||
val clockPosition = tile.tileMap.getNeighborTileClockPosition(tile, it)
|
||||
val direction = NeighborDirection.byClockPosition[clockPosition]
|
||||
NeighborEdgeData(it, direction)
|
||||
}.toList().asSequence()
|
||||
|
||||
@ -275,24 +276,4 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
||||
|
||||
}
|
||||
|
||||
enum class NeighborDirection {
|
||||
Top, TopRight, TopLeft, Bottom, BottomLeft, BottomRight;
|
||||
|
||||
companion object {
|
||||
fun fromVector(vector2: Vector2): NeighborDirection? {
|
||||
val x = vector2.x.toInt()
|
||||
val y = vector2.y.toInt()
|
||||
return when (x) {
|
||||
1 -> if (y == 1) Top // x == 1 && y == 1
|
||||
else TopLeft // x == 1 && y == 0
|
||||
0 -> if (y == 1) TopRight // x == 0 && y == 1
|
||||
else BottomLeft // x == 0 && y == -1
|
||||
-1 -> if (y == -1) Bottom // x == -1 && y == -1
|
||||
else BottomRight // x == -1 && y == 0
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class EdgeTileImage(val fileName:String, val originTileFilter: String, val destinationTileFilter: String, val edgeType: NeighborDirection)
|
||||
|
Loading…
x
Reference in New Issue
Block a user