diff --git a/projects/nat-archive-tool/src/nat/ArchiveController.kiss b/projects/nat-archive-tool/src/nat/ArchiveController.kiss index 9bd3a92c..6cecdbb9 100644 --- a/projects/nat-archive-tool/src/nat/ArchiveController.kiss +++ b/projects/nat-archive-tool/src/nat/ArchiveController.kiss @@ -152,6 +152,7 @@ // Add systems! (archive.addSystem nameSystem) (archive.addSystem (new WikipediaImageSystem)) + (archive.addSystem (new ImageAttachmentSystem)) // Just for testing: // (archive.addSystem (new AttachmentSystem ["jpg" "jpeg" "png"] ->[archive e files] ~files)) @@ -215,6 +216,20 @@ (doFor e entries (addFiles archive e files)) entries) - + + (method adjustImagePins [:Array entries increment] + (doFor e entries + (if (hasComponent e Images) + (withWritableComponents archive e [images Images] + (set images.pinnedImageIndex (max 0 (min images.imageFiles.length (+ increment images.pinnedImageIndex))))) + (ui.reportError "Entry $e has no Images component"))) + entries) + + (defCommand PinNextImage [entries (SelectedEntries 1 null)] + (adjustImagePins entries 1)) + + (defCommand PinPreviousImage [entries (SelectedEntries 1 null)] + (adjustImagePins entries -1)) + (defCommand SelectByName [name (Text null)] (SelectEntries (nameSystem.getEntries name)) [])) diff --git a/projects/nat-archive-tool/src/nat/components/Images.hx b/projects/nat-archive-tool/src/nat/components/Images.hx new file mode 100644 index 00000000..58ee3621 --- /dev/null +++ b/projects/nat-archive-tool/src/nat/components/Images.hx @@ -0,0 +1,6 @@ +package nat.components; + +typedef Images = { + imageFiles:Array, + pinnedImageIndex:Int +}; diff --git a/projects/nat-archive-tool/src/nat/systems/ImageAttachmentSystem.hx b/projects/nat-archive-tool/src/nat/systems/ImageAttachmentSystem.hx new file mode 100644 index 00000000..31f29602 --- /dev/null +++ b/projects/nat-archive-tool/src/nat/systems/ImageAttachmentSystem.hx @@ -0,0 +1,7 @@ +package nat.systems; + +import kiss.Prelude; +import kiss.List; + +@:build(kiss.Kiss.build()) +class ImageAttachmentSystem extends AttachmentSystem {} diff --git a/projects/nat-archive-tool/src/nat/systems/ImageAttachmentSystem.kiss b/projects/nat-archive-tool/src/nat/systems/ImageAttachmentSystem.kiss new file mode 100644 index 00000000..6a3ad21c --- /dev/null +++ b/projects/nat-archive-tool/src/nat/systems/ImageAttachmentSystem.kiss @@ -0,0 +1,12 @@ +(load "../Lib.kiss") + +(defNew [] + (super + ["jpg" "jpeg" "png"] + ->[archive e imageFiles] + (unless (hasComponent e Images) + (withWritableEntry archive e + (addComponent archive e Images + (object + imageFiles imageFiles + pinnedImageIndex 0)))))) \ No newline at end of file