click to add/remove entry from playground selection

This commit is contained in:
2021-09-18 20:41:44 -06:00
parent 4adbd7d750
commit f3d7cecd4e
6 changed files with 46 additions and 17 deletions

View File

@@ -166,6 +166,10 @@
(defCommand SelectEntry [e OneEntry]
(set selectedEntries [e]) [])
(defCommand ToggleEntrySelection [e OneEntry]
(unless (selectedEntries.remove e)
(selectedEntries.push e)) [])
(defCommand SelectEntries [entries (Entries null null)]
(set selectedEntries entries) [])

View File

@@ -6,6 +6,7 @@ import flash.display.BitmapData;
import flixel.addons.display.FlxExtendedSprite;
import nat.Entry;
import nat.Archive;
import nat.ArchiveController;
import nat.BoolExpInterp;
import nat.components.Images;
import nat.components.Positions;

View File

@@ -2,7 +2,10 @@
(defNew [:String positionKey
&prop :Archive archive
&prop :Entry e]
&prop :Entry e
&prop :ArchiveController controller]
[&mut :Bool selected false]
(let [images (readComponent archive e Images)]
(case (dictGet (readComponent archive e Positions) positionKey)
((object x x y y z z)
@@ -13,6 +16,20 @@
(enableMouseClicks false)
(enableMouseDrag)
}))
(set mousePressedCallback
->[self _x _y]
{
(controller.ToggleEntrySelection e)
(set selected !selected)
(if selected
{
(set color FlxColor.BLUE)
}
{
(set color FlxColor.WHITE)
})
})
(set mouseStopDragCallback
->[self _dx _dy]
(withWritableComponents archive e [positions Positions]

View File

@@ -4,6 +4,7 @@ import kiss.Prelude;
import kiss.List;
import nat.System;
import nat.BoolExpInterp;
import nat.ArchiveController;
import nat.components.Positions;
@:build(kiss.Kiss.build())

View File

@@ -2,7 +2,10 @@
(prop :Map<String,EntrySprite> sprites (new Map))
(defNew [:String tagFilterString :String positionKey :PlayState playState]
(defNew [:String tagFilterString
:String positionKey
:PlayState playState
&prop :ArchiveController controller]
(super
->[archive e]
?(and (tagsMatch archive e tagFilterString) (hasComponent e Images))
@@ -14,7 +17,7 @@
(withWritableComponents archive e [positions Positions]
(when !(positions.exists positionKey)
(dictSet positions positionKey (object x 0.0 y 0.0 z 0.0))))
(let [sprite (new EntrySprite positionKey archive e)]
(let [sprite (new EntrySprite positionKey archive e controller)]
(playState.entryGroup.add sprite)
(dictSet sprites e.id sprite))
})

View File

@@ -16,9 +16,10 @@
archive
(new Archive archiveDir)]
(set this.archive archive)
(new ArchiveController
archive
this))
(set controller
(new ArchiveController
archive
this)))
(prop &mut :FlxGroup uiGroup (new FlxGroup))
(add uiGroup)
@@ -39,7 +40,7 @@
// TODO allow configuring the tags at runtime and erasing/re-creating sprites later
// TODO allow using other position keys and erasing/re-creating sprites later
(prop &mut :EntrySpriteSystem spriteSystem)
(set spriteSystem (new EntrySpriteSystem "!done" "Playground-MAIN" this))
(set spriteSystem (new EntrySpriteSystem "!done" "Playground-MAIN" this controller))
(archive.addSystem spriteSystem)
(spriteSystem.process archive))
@@ -114,16 +115,18 @@
(set textInput.hasFocus true)
(set textInput.callback
->:Void [text action]
(case [text action]
([text FlxInputText.ENTER_ACTION]
(set textInput.callback null)
(hideUI textInput)
// This part is hacky...
(set lastUI textInputLabel)
(hideUI textInputLabel)
(resolve text))
//([_ FlxInputText.])
(otherwise {})))
// Super weird that this check is necessary
(when textInput
(case [text action]
([text FlxInputText.ENTER_ACTION]
(set textInput.callback null)
(hideUI textInput)
// This part is hacky...
(set lastUI textInputLabel)
(hideUI textInputLabel)
(resolve text))
//([_ FlxInputText.])
(otherwise {}))))
(showUI textInput))
(method :Void enterNumber [prompt resolve min max &opt inStepsOf]