Add support for property groups

This commit is contained in:
Bastiaan Olij
2021-09-15 13:56:20 +10:00
parent 02802b1d0e
commit e839199848
8 changed files with 39 additions and 11 deletions

View File

@@ -4,5 +4,5 @@ entry_symbol = "example_library_init"
[libraries]
Linux.64 = "bin/x11/libgdexample.so"
Windows.64 = "bin/win64/libgdexample.dll"
linux.64 = "bin/x11/libgdexample.so"
windows.64 = "bin/win64/libgdexample.dll"

View File

@@ -13,9 +13,9 @@ func _ready():
prints("vararg args", $Example.varargs_func("some", "arguments", "to", "test"))
# Use properties.
prints("custom postion is", $Example.custom_position)
$Example.custom_position = Vector2(50, 50)
prints("custom postion now is", $Example.custom_position)
prints("custom position is", $Example.group_subgroup_custom_position)
$Example.group_subgroup_custom_position = Vector2(50, 50)
prints("custom position now is", $Example.group_subgroup_custom_position)
# Get constants
prints("FIRST", $Example.FIRST)

View File

@@ -7,9 +7,6 @@ script = ExtResource( "1_c326s" )
[node name="Example" type="Example" parent="."]
script = null
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Example"]
offset_left = 194.0

View File

@@ -53,9 +53,12 @@ void Example::_bind_methods() {
}
// Properties.
ADD_GROUP("Test group","group_");
ADD_SUBGROUP("Test subgroup","group_subgroup_");
ClassDB::bind_method(D_METHOD("get_custom_position"), &Example::get_custom_position);
ClassDB::bind_method(D_METHOD("set_custom_position", "position"), &Example::set_custom_position);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "custom_position"), "set_custom_position", "get_custom_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "group_subgroup_custom_position"), "set_custom_position", "get_custom_position");
// Signals.
ADD_SIGNAL(MethodInfo("custom_signal", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::INT, "value")));