Overlay work

This commit is contained in:
woahscam 2021-10-29 01:06:12 -04:00
parent 8e5ab4be7a
commit df29d908d7
4 changed files with 78 additions and 41 deletions

View file

@ -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("<h2><b>Tile [${point.x}, ${point.y}] Information</b></h2><br>")
.append("<hr width=\"250px\"><br>")
@ -246,6 +255,22 @@ object Rs2MapEditor {
.append("</tr>")
.append("</tbody>")
.append("</table>")
.append("<table style=\"border:1px solid gray;margin-left:auto;margin-right:auto;>")
.append("<thead>")
.append("<tr style=\"text-align:center\">")
.append("<th>OverlayID</th>")
.append("<th>Color</th>")
.append("<th>Hide underlay</th>")
.append("</tr>")
.append("</thead>")
.append("<tbody>")
.append("<tr style=\"text-align:center\">")
.append("<td>${def.overlayId}</td>")
.append("<td>${floDef.color}</td>")
.append("<td>${floDef.hideUnderlay}</td>")
.append("</tr>")
.append("</tbody>")
.append("</table>")
.append("<br/>")
.append("<table style=\"border:1px solid gray;margin-left:auto;margin-right:auto;>")
.append("<thead>")

View file

@ -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)
}
}

View file

@ -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<Int, OverlayDefinition>()

View file

@ -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))
}
}