42 lines
1.4 KiB
Plaintext
42 lines
1.4 KiB
Plaintext
(loadFrom "nat-archive-tool" "src/nat/Lib.kiss")
|
|
|
|
(defNew [:String positionKey
|
|
&prop :Archive archive
|
|
&prop :Entry e
|
|
&prop :ArchiveController controller]
|
|
[&mut :Bool selected false]
|
|
|
|
(let [images (readComponent e Images)]
|
|
(case (dictGet (readComponent e Positions) positionKey)
|
|
((object x x y y z z)
|
|
(super x y)))
|
|
(.onComplete (BitmapData.loadFromFile (joinPath archive.archiveDir "files" (nth images.imageFiles images.pinnedImageIndex)))
|
|
->bitmapData {
|
|
(loadGraphic bitmapData)
|
|
(updateColor)
|
|
(when (hasComponent e Scale)
|
|
(let [:Float scale (readComponent e Scale)]
|
|
(this.scale.set scale scale)
|
|
(updateHitbox)))
|
|
(enableMouseClicks false)
|
|
(enableMouseDrag)
|
|
}))
|
|
|
|
(set mousePressedCallback
|
|
->[self _x _y]
|
|
{
|
|
(controller.ToggleSelectEntry e)
|
|
})
|
|
(set mouseStopDragCallback
|
|
->[self _dx _dy]
|
|
(withWritableComponents archive e [positions Positions]
|
|
(dictSet positions positionKey (object x (cast this.x Float) y (cast this.y Float) z 0.0)))))
|
|
|
|
(method updateColor []
|
|
(if (controller.isSelected e)
|
|
{
|
|
(set color FlxColor.BLUE)
|
|
}
|
|
{
|
|
(set color FlxColor.WHITE)
|
|
})) |