Scale component for NAT entries

This commit is contained in:
2021-09-27 19:45:54 -06:00
parent 6eb8aafb77
commit 0e21755e31
4 changed files with 16 additions and 0 deletions

View File

@@ -235,5 +235,13 @@
(defCommand PinPreviousImage [entries (SelectedEntries 1 null)]
(adjustImagePins entries -1))
(defCommand SetScale [entries (SelectedEntries 1 null) scale (Number 0 null null)]
(doFor e entries
(if (hasComponent e Scale)
(withWritableComponents archive e [scaleComponent Scale]
(set scaleComponent scale))
(addComponent archive e Scale scale)))
entries)
(defCommand SelectByName [name (Text null)]
(SelectEntries (nameSystem.getEntries name)) []))

View File

@@ -0,0 +1,3 @@
package nat.components;
typedef Scale = Float;

View File

@@ -10,6 +10,7 @@ import nat.ArchiveController;
import nat.BoolExpInterp;
import nat.components.Images;
import nat.components.Positions;
import nat.components.Scale;
@:build(kiss.Kiss.build())
class EntrySprite extends FlxExtendedSprite {}

View File

@@ -13,6 +13,10 @@
(.onComplete (BitmapData.loadFromFile (joinPath archive.archiveDir "files" (nth images.imageFiles images.pinnedImageIndex)))
->bitmapData {
(loadGraphic bitmapData)
(when (hasComponent e Scale)
(let [:Float scale (readComponent archive e Scale)]
(this.scale.set scale scale)
(updateHitbox)))
(enableMouseClicks false)
(enableMouseDrag)
}))