diff --git a/projects/nat-godot-playground/EntryPanel.tscn b/projects/nat-godot-playground/EntryPanel.tscn new file mode 100644 index 00000000..a5594e7d --- /dev/null +++ b/projects/nat-godot-playground/EntryPanel.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/EntryContainer.gd" type="Script" id=1] + +[node name="EntryPanel" type="PanelContainer"] +margin_right = 40.0 +margin_bottom = 40.0 +mouse_filter = 1 +script = ExtResource( 1 ) + +[node name="EntryLabel" type="Label" parent="."] +margin_left = 7.0 +margin_top = 13.0 +margin_right = 192.0 +margin_bottom = 27.0 +text = "Hello NAT Godot Playground!" + +[connection signal="mouse_entered" from="." to="." method="_on_EntryPanel_mouse_entered"] +[connection signal="mouse_exited" from="." to="." method="_on_EntryPanel_mouse_exited"] diff --git a/projects/nat-godot-playground/Main.tscn b/projects/nat-godot-playground/Main.tscn index 1d7c19ce..275a6d51 100644 --- a/projects/nat-godot-playground/Main.tscn +++ b/projects/nat-godot-playground/Main.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=3 format=2] -[ext_resource path="res://scripts/Playground.gd" type="Script" id=1] -[ext_resource path="res://scripts/EntryContainer.gd" type="Script" id=2] +[ext_resource path="res://Playground.tscn" type="PackedScene" id=1] [ext_resource path="res://build/src/RootNode.cs" type="Script" id=3] [node name="RootNode" type="Control"] @@ -18,33 +17,4 @@ anchor_bottom = 1.0 margin_right = 8.0 margin_bottom = 36.0 -[node name="PlaygroundScrollContainer" type="ScrollContainer" parent="PlaygroundTabContainer"] -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_left = 4.0 -margin_top = 32.0 -margin_right = -4.0 -margin_bottom = -4.0 -rect_min_size = Vector2( 1280, 720 ) - -[node name="Playground" type="Control" parent="PlaygroundTabContainer/PlaygroundScrollContainer"] -margin_right = 1280.0 -margin_bottom = 720.0 -rect_min_size = Vector2( 1280, 720 ) -script = ExtResource( 1 ) - -[node name="EntryContainer" type="PanelContainer" parent="PlaygroundTabContainer/PlaygroundScrollContainer/Playground"] -margin_right = 40.0 -margin_bottom = 40.0 -mouse_filter = 1 -script = ExtResource( 2 ) - -[node name="EntryLabel" type="Label" parent="PlaygroundTabContainer/PlaygroundScrollContainer/Playground/EntryContainer"] -margin_left = 7.0 -margin_top = 13.0 -margin_right = 192.0 -margin_bottom = 27.0 -text = "Hello NAT Godot Playground!" - -[connection signal="mouse_entered" from="PlaygroundTabContainer/PlaygroundScrollContainer/Playground/EntryContainer" to="PlaygroundTabContainer/PlaygroundScrollContainer/Playground/EntryContainer" method="_on_EntryContainer_mouse_entered"] -[connection signal="mouse_exited" from="PlaygroundTabContainer/PlaygroundScrollContainer/Playground/EntryContainer" to="PlaygroundTabContainer/PlaygroundScrollContainer/Playground/EntryContainer" method="_on_EntryContainer_mouse_exited"] +[node name="Playground" parent="PlaygroundTabContainer" instance=ExtResource( 1 )] diff --git a/projects/nat-godot-playground/Playground.tscn b/projects/nat-godot-playground/Playground.tscn new file mode 100644 index 00000000..08cbad7a --- /dev/null +++ b/projects/nat-godot-playground/Playground.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://scripts/Playground.gd" type="Script" id=1] +[ext_resource path="res://scripts/EntryContainer.gd" type="Script" id=2] +[ext_resource path="res://EntryPanel.tscn" type="PackedScene" id=3] + +[node name="Playground" type="ScrollContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 +rect_min_size = Vector2( 1280, 720 ) + +[node name="Entries" type="Control" parent="."] +margin_right = 1280.0 +margin_bottom = 720.0 +rect_min_size = Vector2( 1280, 720 ) +script = ExtResource( 1 ) + +[node name="EntryPanel" type="PanelContainer" parent="Entries" instance=ExtResource( 3 )] +margin_right = 40.0 +margin_bottom = 40.0 +mouse_filter = 1 +script = ExtResource( 2 ) + +[connection signal="mouse_entered" from="Entries/EntryPanel" to="Entries/EntryPanel" method="_on_EntryPanel_mouse_entered"] +[connection signal="mouse_exited" from="Entries/EntryPanel" to="Entries/EntryPanel" method="_on_EntryPanel_mouse_exited"] diff --git a/projects/nat-godot-playground/playgrounds.json b/projects/nat-godot-playground/playgrounds.json new file mode 100644 index 00000000..9e86c1c4 --- /dev/null +++ b/projects/nat-godot-playground/playgrounds.json @@ -0,0 +1,6 @@ +{ + "default": "Playground-MAIN", + "Playground-MAIN": { + "catsMatch": "true" + } +} diff --git a/projects/nat-godot-playground/scripts/EntryContainer.gd b/projects/nat-godot-playground/scripts/EntryContainer.gd index ff9b80cb..ffaa1d1c 100644 --- a/projects/nat-godot-playground/scripts/EntryContainer.gd +++ b/projects/nat-godot-playground/scripts/EntryContainer.gd @@ -16,13 +16,13 @@ func _ready(): # pass -func _on_EntryContainer_mouse_entered(): +func _on_EntryPanel_mouse_entered(): var current_focus_z = get_parent().current_focus_z if is_nan(current_focus_z) or current_focus_z <= self.z: get_parent().current_focus = self get_parent().current_focus_z = self.z -func _on_EntryContainer_mouse_exited(): +func _on_EntryPanel_mouse_exited(): if get_parent().current_focus == self: get_parent().current_focus = null get_parent().current_focus_z = NAN diff --git a/projects/nat-godot-playground/scripts/EntryPanelSystem.hx b/projects/nat-godot-playground/scripts/EntryPanelSystem.hx new file mode 100644 index 00000000..5a5849fb --- /dev/null +++ b/projects/nat-godot-playground/scripts/EntryPanelSystem.hx @@ -0,0 +1,6 @@ +package; + +import kiss.Prelude; + +@:build(kiss.Kiss.build()) +class EntryPanelSystem extends PlaygroundSystem {} \ No newline at end of file diff --git a/projects/nat-godot-playground/scripts/EntryPanelSystem.kiss b/projects/nat-godot-playground/scripts/EntryPanelSystem.kiss new file mode 100644 index 00000000..1ca85138 --- /dev/null +++ b/projects/nat-godot-playground/scripts/EntryPanelSystem.kiss @@ -0,0 +1,31 @@ +(loadFrom "nat-archive-tool" "src/nat/Lib.kiss") +(loadFrom "kiss-godot" "src/kiss_godot/Macros.kiss") + +(defNew [&prop :GodotUI godotUI + &prop :Node rootNode] + (super + godotUI + ->[archive e] (hasComponent e Name) + // Create Entry node: + ->[archive e pos &opt ui] + (let [:PackedScene ePanelScene (GD.load "res://EntryPanel.tscn") + :PanelContainer ePanel (cast (ePanelScene.instance)) + :Label eLabel (getNode ePanel "EntryLabel")] + (set eLabel.text (readComponentOr e Name "")) + (.addChild (getNode pgScrollContainer "Entries") ePanel) + ePanel) + // Draw line: + ->[archive e pos e2 pos2 &opt ui] + null + // Remove Entry node: + ->[archive e &opt ui] + null)) + +(prop &mut :ScrollContainer pgScrollContainer null) + +(method &override :Void switchPlaygroundKey [key] + (super.switchPlaygroundKey key) + (set pgScrollContainer (getNode rootNode 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 ef61cc49..92c418b5 100644 --- a/projects/nat-godot-playground/scripts/GodotUI.kiss +++ b/projects/nat-godot-playground/scripts/GodotUI.kiss @@ -1,18 +1,45 @@ +(loadFrom "kiss-godot" "src/kiss_godot/Macros.kiss") + (prop &mut :ArchiveController controller (property default default)) (prop &mut :Null> shortcutHandler (property default null)) + (method :Void showPrefixMap [:Map map] (throw "TODO Not implemented!")) + (method :Void hidePrefixMap [] (throw "TODO Not implemented!")) -(method :Null playgroundSystem [] (throw "TODO Not implemented!")) + +(method :Null> playgroundSystem [] pgSystem) + (method :Void enterText [:String prompt :String->Void resolve :Float maxLength] (throw "TODO Not implemented!")) + (method :Void enterNumber [:String prompt :Float->Void resolve :Float min :Float max &opt :Null inStepsOf &opt :Null allowNaN] (throw "TODO Not implemented!")) + (method :Void chooseEntry [:String prompt :Archive archive :Entry->Void resolve] (throw "TODO Not implemented!")) + (method :Void chooseEntries [:String prompt :Archive archive :Array->Void resolve :Int min :Float max] (throw "TODO Not implemented!")) + (method :Void handleChanges [:Archive archive :ChangeSet changeSet] (throw "TODO Not implemented!")) + (method :Void displayMessage [:String message] (throw "TODO Not implemented!")) + (method :Void reportError [:String error] (throw "TODO Not implemented!")) + (method :Void onSelectionChanged [:Array selectedEntries :Array lastSelectedEntries] (throw "TODO Not implemented!")) + (method :Void choosePosition [:String prompt :Position->Void resolve] (throw "TODO Not implemented!")) -(method :Option cursorPosition [] (throw "TODO Not implemented!"))(method :Void chooseBetweenStrings [:String prompt :Array choices :String->Void resolve] (throw "TODO Not implemented!")) + +(method :Option cursorPosition [] (throw "TODO Not implemented!")) + +(method :Void chooseBetweenStrings [:String prompt :Array choices :String->Void resolve] (throw "TODO Not implemented!")) (defNew [&prop :Archive archive - &prop :Node rootNode]) \ No newline at end of file + &prop :Node 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