some GodotUI function implementations
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
[node name="RootNode" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = 256.0
|
||||
margin_bottom = 120.0
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"haxe_script": "res://scripts/RootNode.hx"
|
||||
@@ -13,7 +15,16 @@ __meta__ = {
|
||||
[node name="PlaygroundTabContainer" type="TabContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = 8.0
|
||||
margin_bottom = 36.0
|
||||
|
||||
[node name="UIPanel" type="Panel" parent="."]
|
||||
anchor_top = 0.8
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="UIPanel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="UIContainer" type="VBoxContainer" parent="UIPanel/ScrollContainer"]
|
||||
|
||||
[connection signal="tab_changed" from="PlaygroundTabContainer" to="." method="_on_PlaygroundTabContainer_tab_changed"]
|
||||
|
@@ -62,6 +62,19 @@ hide_native_script_field=true
|
||||
external_editor="VSCode"
|
||||
build_on_play=false
|
||||
|
||||
[input]
|
||||
|
||||
type_command={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":96,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
type_shortcut={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":59,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[mono]
|
||||
|
||||
project/assembly_name="nat-godot-playground"
|
||||
|
@@ -9,7 +9,14 @@
|
||||
|
||||
(method :Null<PlaygroundSystem<Dynamic>> playgroundSystem [] pgSystem)
|
||||
|
||||
(method :Void enterText [:String prompt :String->Void resolve :Float maxLength] (throw "TODO Not implemented!"))
|
||||
(method :Void enterText [:String prompt :String->Void resolve :Float maxLength]
|
||||
(displayMessage prompt)
|
||||
(let [lineEdit (new LineEdit)]
|
||||
(unless (= maxLength Math.POSITIVE_INFINITY)
|
||||
(set lineEdit.maxLength (Std.int maxLength)))
|
||||
(set rootNode.resolveString resolve)
|
||||
(lineEdit.connect "text_entered" rootNode "_on_LineEdit_text_entered")
|
||||
(rootNode.uiContainer.addChild lineEdit)))
|
||||
|
||||
(method :Void enterNumber [:String prompt :Float->Void resolve :Float min :Float max &opt :Null<Float> inStepsOf &opt :Null<Bool> allowNaN] (throw "TODO Not implemented!"))
|
||||
|
||||
@@ -17,17 +24,27 @@
|
||||
|
||||
(method :Void chooseEntries [:String prompt :Archive archive :Array<Entry>->Void resolve :Int min :Float max] (throw "TODO Not implemented!"))
|
||||
|
||||
(method :Void handleChanges [:Archive archive :ChangeSet changeSet] (throw "TODO Not implemented!"))
|
||||
(method :Void handleChanges [:Archive archive :ChangeSet changeSet]
|
||||
null)
|
||||
|
||||
(method :Void displayMessage [:String message] (throw "TODO Not implemented!"))
|
||||
(method :Void displayMessage [:String message]
|
||||
(let [label (new Label)]
|
||||
(set label.text message)
|
||||
(rootNode.uiContainer.addChild label)))
|
||||
|
||||
(method :Void reportError [:String error] (throw "TODO Not implemented!"))
|
||||
|
||||
(method :Void onSelectionChanged [:Array<Entry> selectedEntries :Array<Entry> lastSelectedEntries] (throw "TODO Not implemented!"))
|
||||
|
||||
(method :Void choosePosition [:String prompt :Position->Void resolve] (throw "TODO Not implemented!"))
|
||||
(method :Void choosePosition [:String prompt :Position->Void resolve]
|
||||
(throw "TODO Not implemented!"))
|
||||
|
||||
(method :Option<Position> cursorPosition [] (throw "TODO Not implemented!"))
|
||||
(method :Option<Position> cursorPosition []
|
||||
(let [pos (.getMousePosition (rootNode.getViewport))]
|
||||
(Some (vector2ToPosition pos))))
|
||||
|
||||
(function :Position vector2ToPosition [:Vector2 pos]
|
||||
(object x pos.x y pos.y z 0.0))
|
||||
|
||||
(method :Void chooseBetweenStrings [:String prompt :Array<String> choices :String->Void resolve] (throw "TODO Not implemented!"))
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
(prop &mut :TabContainer pgTabs)
|
||||
(prop &mut :PackedScene pgScene)
|
||||
|
||||
(prop &mut :VBoxContainer uiContainer)
|
||||
|
||||
(defNew []
|
||||
[
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
(set pgTabs (getNode this "PlaygroundTabContainer"))
|
||||
(set pgScene (GD.load "res://Playground.tscn"))
|
||||
(set uiContainer (getNode this "UIPanel/ScrollContainer/UIContainer"))
|
||||
|
||||
(doFor =>key playground archive.playgrounds
|
||||
(unless (= key "default")
|
||||
@@ -29,5 +30,28 @@
|
||||
|
||||
(set ui.controller (new ArchiveController archive ui)))
|
||||
|
||||
(method &override &public :Void _Process [:Float delta]
|
||||
(when (Input.isActionJustPressed "type_command")
|
||||
(ui.controller.typeCommand))
|
||||
|
||||
(when (Input.isActionJustPressed "type_shortcut")
|
||||
0 **(ui.controller.typeShortcut)))
|
||||
|
||||
(method :Void _on_PlaygroundTabContainer_tab_changed [:Int tab]
|
||||
(when ui.controller (.switchPlaygroundKey (ui.playgroundSystem) .name (pgTabs.getChild tab))))
|
||||
|
||||
(prop &mut :String->Void resolveString null)
|
||||
(method :Void _on_LineEdit_text_entered [:String text]
|
||||
(let [rs resolveString]
|
||||
(set resolveString null)
|
||||
(rs text)))
|
||||
|
||||
(prop &mut :Position->Void resolvePosition null)
|
||||
(method &override &public :Void _Input [:InputEvent event]
|
||||
(typeCase [event]
|
||||
([:InputEventMouseButton mouseButtonEvent]
|
||||
(when (= mouseButtonEvent.buttonIndex ButtonList.Left)
|
||||
(whenLet [rp resolvePosition]
|
||||
(set resolvePosition null)
|
||||
(rp (GodotUI.vector2ToPosition (.getMousePosition (getViewport)))))))
|
||||
(otherwise)))
|
Reference in New Issue
Block a user