Files
kiss-vscode/projects/nat-godot-playground/scripts/EntryPanelSystem.kiss

44 lines
1.6 KiB
Plaintext

(loadFrom "nat-archive-tool" "src/nat/Lib.kiss")
(loadFrom "kiss-godot" "src/kiss_godot/Util.kiss")
(defNew [&prop :GodotUI godotUI
&prop :RootNode rootNode]
(super
godotUI
->[archive e] (hasComponent e Name)
// Create Entry node:
->[archive e pos &opt ui]
(let [:PackedScene ePanelScene (GD.load "res://EntryPanel.tscn")
:EntryPanel ePanel (cast (ePanelScene.instance))
:Label eLabel (getNode ePanel "EntryLabel")]
(set eLabel.text (readComponentOr e Name ""))
(set ePanel.rectPosition (new Vector2 pos.x pos.y))
(set ePanel.z pos.z)
(set ePanel.e e)
(pgEntries.addChild ePanel)
ePanel)
// Draw line:
->[archive e pos e2 pos2 &opt ui]
null
// Remove Entry node:
->[archive e &opt ui]
null))
(prop &mut :TabContainer pgTabs null)
(prop &mut :ScrollContainer pgScrollContainer null)
(prop &mut :Node pgEntries null)
(method &override :Void switchPlaygroundKey [:String key]
(set pgTabs rootNode.pgTabs)
(unless (= .name (pgTabs.getChild pgTabs.currentTab) key)
(doFor [idx :Control tab] (enumerate (collect (pgTabs.getChildren)) -1)
(when (and tab (= tab.name key))
(set pgTabs.currentTab idx))))
(set pgScrollContainer (getNode pgTabs key))
(set pgEntries (getNode pgScrollContainer "Entries"))
(super.switchPlaygroundKey key))
(method &override :Void clear [:ColorF color]
null)