diff --git a/src/main/kotlin/Rs2MapEditor.kt b/src/main/kotlin/Rs2MapEditor.kt index 46d01f4..672fdd2 100644 --- a/src/main/kotlin/Rs2MapEditor.kt +++ b/src/main/kotlin/Rs2MapEditor.kt @@ -117,8 +117,16 @@ object Rs2MapEditor { val point = Point(column, flippedY) colorPointMap[point] = MapTileParser.definition.getTile(column, flippedY, 0).underlayId val mapCell = MapCell() - mapCell.background = - underlayMap[MapTileParser.definition.getTile(column, flippedY, 0).underlayId]!!.getRGB() + + val overlayID = MapTileParser.definition.getTile(column, flippedY, 0).overlayId + val floDef = overlayMap[overlayID]!! + + if (overlayID == 0) { + mapCell.background = underlayMap[MapTileParser.definition.getTile(column, flippedY, 0).underlayId]!!.getRGB() + } else { + mapCell.background = Color(overlayMap[overlayID]!!.color) + } + mapCell.border = border val npcsHere = npcs.filter { it.x == column && it.y == flippedY && it.plane == 0 }.toList() if (npcsHere.isNotEmpty()) { @@ -227,6 +235,7 @@ object Rs2MapEditor { } else if (SwingUtilities.isRightMouseButton(e)) { val point = Point(selectedPointX, selectedPointY) val def = MapTileParser.definition.getTile(point.x, point.y, 0) + val floDef = overlayMap[def.overlayId]!! val string = StringBuilder() .append("

Tile [${point.x}, ${point.y}] Information


") .append("

") @@ -246,6 +255,22 @@ object Rs2MapEditor { .append("") .append("") .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("
OverlayIDColorHide underlay
${def.overlayId}${floDef.color}${floDef.hideUnderlay}
") .append("
") .append("") .append("") diff --git a/src/main/kotlin/cacheops/cache/definition/data/OverlayDefinition.kt b/src/main/kotlin/cacheops/cache/definition/data/OverlayDefinition.kt index 109837b..ea63601 100644 --- a/src/main/kotlin/cacheops/cache/definition/data/OverlayDefinition.kt +++ b/src/main/kotlin/cacheops/cache/definition/data/OverlayDefinition.kt @@ -1,5 +1,7 @@ package cacheops.cache.definition.data +import java.awt.Color + data class OverlayDefinition( var color: Int = 0, var texture: Int = -1, @@ -17,4 +19,8 @@ data class OverlayDefinition( override fun toString(): String { return "" } + + fun getRGB(): Color { + return Color(color) + } } diff --git a/src/main/kotlin/cacheops/cache/definition/decoder/FloorOverlayConfiguration.kt b/src/main/kotlin/cacheops/cache/definition/decoder/FloorOverlayConfiguration.kt index f55c18e..e87e34a 100644 --- a/src/main/kotlin/cacheops/cache/definition/decoder/FloorOverlayConfiguration.kt +++ b/src/main/kotlin/cacheops/cache/definition/decoder/FloorOverlayConfiguration.kt @@ -8,7 +8,7 @@ import java.nio.ByteBuffer object FloorOverlayConfiguration { - val cache = Rs2MapEditor.library.index(Indices.CONFIGURATION).archive(Archives.FLOOR_UNDERLAYS) + val cache = Rs2MapEditor.library.index(Indices.CONFIGURATION).archive(Archives.FLOOR_OVERLAYS) var floorOverlays = hashMapOf() diff --git a/src/main/kotlin/cacheops/cache/definition/decoder/FloorOverlayDecoder.kt b/src/main/kotlin/cacheops/cache/definition/decoder/FloorOverlayDecoder.kt index 26c7be5..f9c4e2b 100644 --- a/src/main/kotlin/cacheops/cache/definition/decoder/FloorOverlayDecoder.kt +++ b/src/main/kotlin/cacheops/cache/definition/decoder/FloorOverlayDecoder.kt @@ -26,6 +26,9 @@ class FloorOverlayDecoder { while (true) { val opcode = buffer.unsignedByte() if (opcode == 0) { + if (color == 12098407) { + color = waterColor + } return OverlayDefinition(color, texture, hideUnderlay, blendColor, scale, blockShadow, aByte0, blendTexture, waterColor, waterScale, anInt0, waterIntensity) } decodeOverlayType(opcode, buffer) @@ -42,7 +45,7 @@ class FloorOverlayDecoder { private fun decodeOverlayType(opcode: Int, buffer: ByteBuffer) { when (opcode) { - 1 -> color = rgbToHsl(buffer.medium()) + 1 -> color = buffer.medium()//rgbToHsl(buffer.medium()) 2 -> texture = buffer.unsignedByte() 3 -> { texture = buffer.unsignedShort() @@ -51,7 +54,7 @@ class FloorOverlayDecoder { } } 5 -> hideUnderlay = false - 7 -> blendColor = rgbToHsl(buffer.medium()) + 7 -> blendColor = buffer.medium()//rgbToHsl(buffer.medium()) 8 -> anInt3081 9 -> scale = buffer.unsignedShort() 10 -> blockShadow = false //Possibly blockShadow? @@ -77,15 +80,15 @@ class FloorOverlayDecoder { } } - private fun rgbToHsl(i_7_: Int): Int { - if (i_7_ == 16711935) { + private fun rgbToHsl(rgb: Int): Int { + if (rgb == 16711935) { return -1 } else { - val d = (((0xff80ae and i_7_) shr 16).toDouble() / 256.0) - val d_8_ = (((0xff6a and i_7_) shr 8).toDouble() / 256.0) - val d_9_ = ((i_7_ and 0xff).toDouble() / 256.0) + val d = (((0xff80ae and rgb) shr 16).toDouble() / 256.0) + val d_8_ = (((0xff6a and rgb) shr 8).toDouble() / 256.0) + val d_9_ = ((rgb and 0xff).toDouble() / 256.0) var d_11_ = d if (d_11_ > d_8_) { d_11_ = d_8_ @@ -100,54 +103,57 @@ class FloorOverlayDecoder { if (d_12_ < d_9_) { d_12_ = d_9_ } - var d_13_ = 0.0 - var d_14_ = 0.0 - val d_15_ = (d_12_ + d_11_) / 2.0 + var h = 0.0 + var s = 0.0 + val l = (d_12_ + d_11_) / 2.0 if (d_11_ != d_12_) { - if (d_15_ < 0.5) { - d_14_ = (-d_11_ + d_12_) / (d_12_ + d_11_) + if (l < 0.5) { + s = (-d_11_ + d_12_) / (d_12_ + d_11_) } - if (d_15_ >= 0.5) { - d_14_ = (d_12_ - d_11_) / (-d_12_ + 2.0 - d_11_) + if (l >= 0.5) { + s = (d_12_ - d_11_) / (-d_12_ + 2.0 - d_11_) } if (d_12_ == d) { - d_13_ = (d_8_ - d_9_) / (d_12_ - d_11_) + h = (d_8_ - d_9_) / (d_12_ - d_11_) } else if (d_12_ == d_8_) { - d_13_ = (-d + d_9_) / (-d_11_ + d_12_) + 2.0 + h = (-d + d_9_) / (-d_11_ + d_12_) + 2.0 } else if (d_12_ == d_9_) { - d_13_ = (d - d_8_) / (d_12_ - d_11_) + 4.0 + h = (d - d_8_) / (d_12_ - d_11_) + 4.0 } } - d_13_ /= 6.0 - val i_16_ = (d_13_ * 256.0).toInt() - var i_17_ = (d_14_ * 256.0).toInt() - if (i_17_ >= 0) { - if (i_17_ > 255) { - i_17_ = 255 + h /= 6.0 + + val hue = (h * 256.0).toInt() + var saturation = (s * 256.0).toInt() + var lumiance = (l * 256.0).toInt() + + if (saturation >= 0) { + if (saturation > 255) { + saturation = 255 } } else { - i_17_ = 0 + saturation = 0 } - var i_18_ = (d_15_ * 256.0).toInt() - if (i_18_ >= 0) { - if (i_18_ > 255) { - i_18_ = 255 + + if (lumiance >= 0) { + if (lumiance > 255) { + lumiance = 255 } } else { - i_18_ = 0 + lumiance = 0 } - if (i_18_ > 243) { - i_17_ = i_17_ shr 4 - } else if (i_18_ <= 217) { - if (i_18_ > 192) { - i_17_ = i_17_ shr 2 - } else if (i_18_ > 179) { - i_17_ = i_17_ shr 1 + if (lumiance > 243) { + saturation = (saturation shr 4) + } else if (lumiance <= 217) { + if (lumiance > 192) { + saturation = (saturation shr 2) + } else if (lumiance > 179) { + saturation = (saturation shr 1) } } else { - i_17_ = i_17_ shr 3 + saturation = (saturation shr 3) } - return ((((i_16_ and 0xff) shr 2) shl 10) + ((i_17_ shr 5) shl 7) + (i_18_ shr 1)) + return ((((hue and 0xff) shr 2) shl 10) + ((saturation shr 5) shl 7) + (lumiance shr 1)) } }