Highlight overlapping tiles separately

main
idylls 1 year ago
parent 67bc2a4857
commit 703851896d
Signed by: idylls
GPG Key ID: 8A7167CBC2CC9F0F

@ -310,19 +310,15 @@ class Overlay
&& _hoveredTile != null
) {
val hoveredTile = _hoveredTile.sceneLocation
renderTile(gfx, hoveredTile, Color(0, 0, 255), 1.0)
when (val p = findPath(
findPath(
playerTrueTile,
hoveredTile,
collisionFlags,
tiles,
)) {
null -> emptySequence<ScenePoint>()
else -> p
}
)?.toList()
} else {
emptySequence<ScenePoint>()
null
}
val destinationPoint = client.getLocalDestinationLocation()
@ -334,38 +330,102 @@ class Overlay
destinationPoint.sceneX,
destinationPoint.sceneY,
)
when (val p = findPath(
findPath(
playerTrueTile,
destinationTile,
collisionFlags,
tiles,
)) {
null -> emptySequence<ScenePoint>()
else -> p
}
)?.toList()
} else {
emptySequence<ScenePoint>()
null
}
paintTiles(
gfx,
hoveredPathTiles,
config.highlightHoveredBorder(),
config.highlightHoveredBorderWidth(),
)
paintTiles(
val overlappingTiles = when (config.highlightOverlapping()) {
true -> {
if (
(destinationPathTiles == null)
|| (hoveredPathTiles == null)
) {
null
} else {
destinationPathTiles
.toSet()
.intersect(hoveredPathTiles.toSet())
}
}
false -> null
}
doPaint(
gfx,
destinationPathTiles,
config.highlightDestinationBorder(),
config.highlightDestinationBorderWidth(),
hoveredPathTiles,
overlappingTiles,
)
return null
}
fun doPaint(
gfx: Graphics2D,
destinationPathTiles: Iterable<ScenePoint>?,
hoveredPathTiles: Iterable<ScenePoint>?,
overlappingTiles: Set<ScenePoint>?,
) {
if (overlappingTiles != null) {
val ot = destinationPathTiles!!.filter({t ->
overlappingTiles.contains(t)
})
val dpt = destinationPathTiles.filter({t ->
!overlappingTiles.contains(t)
})
val hpt = hoveredPathTiles!!.filter({t ->
!overlappingTiles.contains(t)
})
paintTiles(
gfx,
ot,
config.highlightOverlappingBorder(),
config.highlightOverlappingBorderWidth(),
)
paintTiles(
gfx,
dpt,
config.highlightDestinationBorder(),
config.highlightDestinationBorderWidth(),
)
paintTiles(
gfx,
hpt,
config.highlightHoveredBorder(),
config.highlightHoveredBorderWidth(),
)
} else {
if (destinationPathTiles != null) {
paintTiles(
gfx,
destinationPathTiles,
config.highlightDestinationBorder(),
config.highlightDestinationBorderWidth(),
)
}
if (hoveredPathTiles != null) {
paintTiles(
gfx,
hoveredPathTiles,
config.highlightHoveredBorder(),
config.highlightHoveredBorderWidth(),
)
}
}
}
fun paintTiles(
gfx: Graphics2D,
tiles: Sequence<ScenePoint>,
tiles: Iterable<ScenePoint>,
color: Color,
borderWidth: Double,
) {

@ -26,11 +26,11 @@ public interface PathosConfig : Config {
const val hoveredPath = "hoveredPath"
@ConfigSection(
name = "Additional",
description = "Additional Settings",
name = "Overlapping",
description = "Overlapping Settings",
position = 2,
)
const val additional = "additional"
const val overlapping = "overlapping"
}
@ConfigItem(
@ -88,4 +88,32 @@ public interface PathosConfig : Config {
position = 2,
)
fun highlightHoveredBorderWidth(): Double = 1.0
@ConfigItem(
keyName = "highlightOverlapping",
name = "Highlight overlapping tiles separately",
description = "When enabled, tiles that are in both the hovered path and current path will be highlighted separately",
section = overlapping,
position = 0,
)
fun highlightOverlapping(): Boolean = true
@Alpha
@ConfigItem(
keyName = "highlightOverlappingBorder",
name = "Overlapping tiles border color",
description = "Configures the border color of overlapping tiles",
section = overlapping,
position = 1,
)
fun highlightOverlappingBorder(): Color = Color(255, 255, 255, 128)
@ConfigItem(
keyName = "highlightOverlappingBorderWidth",
name = "Overlapping path tiles border width",
description = "Configures the border width of overlapping tiles",
section = overlapping,
position = 2,
)
fun highlightOverlappingBorderWidth(): Double = 1.0
}

Loading…
Cancel
Save