diff --git a/src/main/kotlin/Rs2MapEditor.kt b/src/main/kotlin/Rs2MapEditor.kt index aff3cf4..abd8639 100644 --- a/src/main/kotlin/Rs2MapEditor.kt +++ b/src/main/kotlin/Rs2MapEditor.kt @@ -432,8 +432,72 @@ object Rs2MapEditor { g.drawPolyline(xArray, yArray, nPoints) g.color = color } + + 9,7,6,8 -> { + if(scenery.id == 85 || scenery.id == 83) return + when(scenery.rotation){ + 0,2 -> {pointX1 = 0; pointY1 = height; pointX2 = width; pointY2 = 0} + 1,3 -> {pointX1 = 0; pointY1 = 0; pointX2 = width; pointY2 = height} + } + + val overlayNorth = getOverlayId(scenery.x + 1, scenery.y) + val overlaySouth = getOverlayId(scenery.x - 1, scenery.y) + val northWest = getOverlayId(scenery.x - 1, scenery.y + 1) + val north = getOverlayId(scenery.x, scenery.y + 1) + val northEast = getOverlayId(scenery.x + 1, scenery.y + 1) + val east = getOverlayId(scenery.x + 1, scenery.y) + val southWest = getOverlayId(scenery.x - 1, scenery.y - 1) + val south = getOverlayId(scenery.x, scenery.y - 1) + val southEast = getOverlayId(scenery.x + 1, scenery.y - 1) + val west = getOverlayId(scenery.x - 1, scenery.y) + + var backFillVertice = Pair(0,0) + when(scenery.rotation){ + 0, 2 -> { + val sumA = getOverlaySum(north, northWest, west) + val sumB = getOverlaySum(south, southEast, east) + backFillVertice = if(sumA > sumB) Pair(width,height) + else if (sumA == sumB) Pair(-1,-1) + else Pair(0,0) + } + 1,3 -> { + val sumA = getOverlaySum(north, northEast, east) + val sumB = getOverlaySum(south, southWest, west) + backFillVertice = if(sumA > sumB) Pair(0,height) + else if (sumA == sumB) Pair(-1,-1) + else Pair(width,0) + } + } + + val fluDef = getUnderlayColor(scenery.x, scenery.y) + g.color = fluDef + if(overlaySouth != overlayNorth && backFillVertice.first != -1) + g.fillPolygon(intArrayOf(pointX1, pointX2, backFillVertice.first), intArrayOf(pointY1, pointY2, backFillVertice.second), 3) + g.color = color + g.drawLine(pointX1, pointY1, pointX2, pointY2) + } } } + + fun getOverlaySum(vararg overlays: Int): Int{ + var sum = 0 + for(overlay in overlays){ + sum += overlay.coerceAtMost(1) + } + return sum + } + + fun getUnderlayColor(x: Int, y: Int): Color { + var underlayID = (MapTileParser.definition.getTile(x, y, plane).underlayId - 1) + if (underlayID < 0) { + underlayID = 0 + } + return underlayMap[underlayID]?.getRGB() ?: Color.BLACK + } + + fun getOverlayId(x: Int, y: Int): Int { + return MapTileParser.definition.getTile(x, y, plane).overlayId + } } class ScrollPane : JPanel() {