diff --git a/projects/nat-godot-playground/scripts/EntryPanelSystem.kiss b/projects/nat-godot-playground/scripts/EntryPanelSystem.kiss index 6e9f9db4..ef803a67 100644 --- a/projects/nat-godot-playground/scripts/EntryPanelSystem.kiss +++ b/projects/nat-godot-playground/scripts/EntryPanelSystem.kiss @@ -2,7 +2,7 @@ (loadFrom "kiss-godot" "src/kiss_godot/Util.kiss") (defNew [&prop :GodotUI godotUI - &prop :Node rootNode] + &prop :RootNode rootNode] (super godotUI ->[archive e] (hasComponent e Name) @@ -12,7 +12,7 @@ :PanelContainer ePanel (cast (ePanelScene.instance)) :Label eLabel (getNode ePanel "EntryLabel")] (set eLabel.text (readComponentOr e Name "")) - (.addChild (getNode pgScrollContainer "Entries") ePanel) + (pgEntries.addChild ePanel) ePanel) // Draw line: ->[archive e pos e2 pos2 &opt ui] @@ -22,10 +22,12 @@ null)) (prop &mut :ScrollContainer pgScrollContainer null) +(prop &mut :Node pgEntries null) -(method &override :Void switchPlaygroundKey [key] - (super.switchPlaygroundKey key) - (set pgScrollContainer (getNode rootNode key))) +(method &override :Void switchPlaygroundKey [:String key] + (set pgScrollContainer (getNode rootNode.pgTabs key)) + (set pgEntries (getNode pgScrollContainer "Entries")) + (super.switchPlaygroundKey key)) (method &override :Void clear [:ColorF color] null) \ No newline at end of file diff --git a/projects/nat-godot-playground/scripts/GodotUI.kiss b/projects/nat-godot-playground/scripts/GodotUI.kiss index c96c7a44..5b93c681 100644 --- a/projects/nat-godot-playground/scripts/GodotUI.kiss +++ b/projects/nat-godot-playground/scripts/GodotUI.kiss @@ -32,14 +32,7 @@ (method :Void chooseBetweenStrings [:String prompt :Array choices :String->Void resolve] (throw "TODO Not implemented!")) (defNew [&prop :Archive archive - &prop :Node rootNode] + &prop :RootNode rootNode] [ :EntryPanelSystem pgSystem (new EntryPanelSystem this rootNode) - :TabContainer pgTabs (getNode rootNode "PlaygroundTabContainer") - :PackedScene pgScene (GD.load "res://Playground.tscn") - ] - - (doFor =>key playground archive.playgrounds - (let [pg (pgScene.instance)] - (set pg.name key) - (pgTabs.addChild pg)))) \ No newline at end of file + ]) \ No newline at end of file diff --git a/projects/nat-godot-playground/scripts/RootNode.kiss b/projects/nat-godot-playground/scripts/RootNode.kiss index 12274145..a19b5ea5 100644 --- a/projects/nat-godot-playground/scripts/RootNode.kiss +++ b/projects/nat-godot-playground/scripts/RootNode.kiss @@ -1,9 +1,26 @@ +(loadFrom "kiss-godot" "src/kiss_godot/Util.kiss") + +(prop &mut :TabContainer pgTabs) +(prop &mut :PackedScene pgScene) + (method &override &public :Void _Ready [] + (printThroughGD) + + (set pgTabs (getNode this "PlaygroundTabContainer")) + (set pgScene (GD.load "res://Playground.tscn")) + // TODO find a better way to pass the archiveDir to a Godot game (let [archiveDir (or (Sys.getEnv "NAT_DIR") (throw "NAT_DIR environment variable must be set")) archive - (new Archive archiveDir) - ui (new GodotUI archive this) - controller (new ArchiveController archive ui)] - (set ui.controller controller))) \ No newline at end of file + (new Archive archiveDir)] + + (doFor =>key playground archive.playgrounds + (unless (= key "default") + (let [pg (pgScene.instance)] + (set pg.name key) + (pgTabs.addChild pg)))) + + (let [ui (new GodotUI archive this) + controller (new ArchiveController archive ui)] + (set ui.controller controller)))) \ No newline at end of file