-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
GDScript: Fix Inspector "Add Input" button, improve tweening, add pri…
…nt in chat, fix entry signals, add export vars (#184) * GDScript: Improve tweening and add print in chat * GDScript: Fix Inspector "Add Input" button * GDScript and visual scripting: Fix custom entry creation dialog * GDScript: Sync exposed @export vars with SpaceObject space vars * Add an inspector for script object variables
1 parent
e30e030
commit 9273b4c
Showing
23 changed files
with
382 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
mirror-godot-app/creator/selection/inspector/script/inspector_script_object_vars.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
extends InspectorCategoryBase | ||
|
||
|
||
const _TRASH_BUTTON = preload("res://creator/selection/inspector/script/entry_input_trash_button.tscn") | ||
|
||
var target_node: Node # SpaceObject or SpaceGlobalScripts | ||
var _is_editable: bool = false | ||
var _object_vars: Dictionary | ||
var _property_list: Control | ||
|
||
|
||
## Must run before _ready() | ||
func setup(target_object: Node, is_editable: bool) -> void: | ||
target_node = target_object | ||
_property_list = $Properties/MarginContainer/PropertyList | ||
_is_editable = is_editable | ||
|
||
|
||
func setup_object_vars(object_vars: Dictionary) -> void: | ||
_object_vars = object_vars | ||
for obj_var_name in _object_vars: | ||
_setup_object_var(obj_var_name, _object_vars[obj_var_name]) | ||
if _property_list.get_child_count() < 5: | ||
if _property_list.get_child_count() != 0: | ||
$CategoryTitle/ToggleButton.hover_tooltip_text = "" | ||
set_visible_to_maximum_size() | ||
|
||
|
||
func _setup_object_var(obj_var_name: String, obj_var_value: Variant) -> void: | ||
var obj_var_type: int = typeof(obj_var_value) | ||
if obj_var_type == TYPE_NIL or not obj_var_type in ScriptParameterCreationMenu.INSPECTOR_PRIMITIVE_SCENES: | ||
return | ||
var obj_var_scene = ScriptParameterCreationMenu.INSPECTOR_PRIMITIVE_SCENES[obj_var_type].instantiate() | ||
obj_var_scene.label_text = obj_var_name | ||
obj_var_scene.reset_value = Serialization.type_convert_any(_get_default_value_of_obj_var(obj_var_name), obj_var_type) | ||
# Be careful, the order matters here! Value editors with setters | ||
# that use onready vars can only be used after adding as a child, | ||
# and then we need to refresh if a refresh method exists. | ||
_property_list.add_child(obj_var_scene) | ||
obj_var_scene.current_value = obj_var_value | ||
if obj_var_scene.has_method(&"refresh"): | ||
obj_var_scene.refresh() | ||
obj_var_scene.value_changed.connect(_on_object_var_changed.bind(obj_var_scene)) | ||
if _is_editable and GameplaySettings.script_show_add_inspector_input: | ||
var trash_button: Node = _TRASH_BUTTON.instantiate() | ||
obj_var_scene.add_child(trash_button) | ||
trash_button.pressed.connect(_on_delete_object_var.bind(obj_var_name)) | ||
|
||
|
||
func _on_object_var_changed(value, which: Control) -> void: | ||
var obj_var_name: String = which.label_text | ||
Zone.script_network_sync.set_variable_on_node(target_node, obj_var_name, value) | ||
|
||
|
||
func _on_delete_object_var(obj_var_name: String) -> void: | ||
Zone.script_network_sync.set_variable_on_node(target_node, obj_var_name, null) | ||
for child in _property_list.get_children(): | ||
child.cleanup_and_delete() | ||
_property_list.remove_child(child) | ||
var vars = target_node.get_meta(&"MirrorScriptObjectVariables") | ||
vars.erase(obj_var_name) | ||
setup_object_vars(vars) | ||
|
||
|
||
func _get_default_value_of_obj_var(obj_var_name: String) -> Variant: | ||
var script_instances: Array[ScriptInstance] = target_node.get_script_instances() | ||
for script_inst in script_instances: | ||
if script_inst.has_method(&"get_default_value_of_exposed_variable"): | ||
var def = script_inst.get_default_value_of_exposed_variable(obj_var_name) | ||
if def != null: | ||
return def | ||
return null |
18 changes: 18 additions & 0 deletions
18
mirror-godot-app/creator/selection/inspector/script/inspector_script_object_vars.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://bhbojmr3nuwrc"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://dkxqj3l0xm8uw" path="res://creator/selection/inspector/categories/inspector_category_base.tscn" id="1_ov2tq"] | ||
[ext_resource type="Script" path="res://creator/selection/inspector/script/inspector_script_object_vars.gd" id="2_abj1i"] | ||
|
||
[node name="InspectorScriptObjectVars" instance=ExtResource("1_ov2tq")] | ||
script = ExtResource("2_abj1i") | ||
|
||
[node name="ToggleButton" parent="CategoryTitle" index="0" node_paths=PackedStringArray("properties")] | ||
properties = NodePath("../../Properties") | ||
hover_tooltip_text = "Use @export in GDScript" | ||
|
||
[node name="Text" parent="CategoryTitle/ToggleButton/Name" index="3"] | ||
text = "OBJECT VARIABLES" | ||
|
||
[connection signal="mouse_entered" from="CategoryTitle/ToggleButton" to="CategoryTitle/ToggleButton" method="_on_hoverable_button_mouse_entered"] | ||
[connection signal="mouse_exited" from="CategoryTitle/ToggleButton" to="CategoryTitle/ToggleButton" method="_on_hoverable_button_mouse_exited"] | ||
[connection signal="pressed" from="CategoryTitle/ToggleButton" to="CategoryTitle/ToggleButton" method="_on_hoverable_button_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class_name TMUserGDScriptBase extends Object | ||
|
||
|
||
signal load_exposed_vars() | ||
signal save_exposed_vars() | ||
signal tmusergdscript_runtime_error(error_str: String, frame_index: int, line_num: int, func_name: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters