NAT Godot make tabs and entries without crashing

This commit is contained in:
2023-02-13 07:49:39 -07:00
parent be59bfb2eb
commit 783f9f5ee8
3 changed files with 30 additions and 18 deletions

View File

@@ -2,7 +2,7 @@
(loadFrom "kiss-godot" "src/kiss_godot/Util.kiss") (loadFrom "kiss-godot" "src/kiss_godot/Util.kiss")
(defNew [&prop :GodotUI godotUI (defNew [&prop :GodotUI godotUI
&prop :Node rootNode] &prop :RootNode rootNode]
(super (super
godotUI godotUI
->[archive e] (hasComponent e Name) ->[archive e] (hasComponent e Name)
@@ -12,7 +12,7 @@
:PanelContainer ePanel (cast (ePanelScene.instance)) :PanelContainer ePanel (cast (ePanelScene.instance))
:Label eLabel (getNode ePanel "EntryLabel")] :Label eLabel (getNode ePanel "EntryLabel")]
(set eLabel.text (readComponentOr e Name "")) (set eLabel.text (readComponentOr e Name ""))
(.addChild (getNode pgScrollContainer "Entries") ePanel) (pgEntries.addChild ePanel)
ePanel) ePanel)
// Draw line: // Draw line:
->[archive e pos e2 pos2 &opt ui] ->[archive e pos e2 pos2 &opt ui]
@@ -22,10 +22,12 @@
null)) null))
(prop &mut :ScrollContainer pgScrollContainer null) (prop &mut :ScrollContainer pgScrollContainer null)
(prop &mut :Node pgEntries null)
(method &override :Void switchPlaygroundKey [key] (method &override :Void switchPlaygroundKey [:String key]
(super.switchPlaygroundKey key) (set pgScrollContainer (getNode rootNode.pgTabs key))
(set pgScrollContainer (getNode rootNode key))) (set pgEntries (getNode pgScrollContainer "Entries"))
(super.switchPlaygroundKey key))
(method &override :Void clear [:ColorF color] (method &override :Void clear [:ColorF color]
null) null)

View File

@@ -32,14 +32,7 @@
(method :Void chooseBetweenStrings [:String prompt :Array<String> choices :String->Void resolve] (throw "TODO Not implemented!")) (method :Void chooseBetweenStrings [:String prompt :Array<String> choices :String->Void resolve] (throw "TODO Not implemented!"))
(defNew [&prop :Archive archive (defNew [&prop :Archive archive
&prop :Node rootNode] &prop :RootNode rootNode]
[ [
:EntryPanelSystem pgSystem (new EntryPanelSystem this 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))))

View File

@@ -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 [] (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 // TODO find a better way to pass the archiveDir to a Godot game
(let [archiveDir (let [archiveDir
(or (Sys.getEnv "NAT_DIR") (throw "NAT_DIR environment variable must be set")) (or (Sys.getEnv "NAT_DIR") (throw "NAT_DIR environment variable must be set"))
archive archive
(new Archive archiveDir) (new Archive archiveDir)]
ui (new GodotUI archive this)
controller (new ArchiveController archive ui)] (doFor =>key playground archive.playgrounds
(set ui.controller controller))) (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))))