diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2019-08-15 14:50:26 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2019-08-23 15:53:07 +0200 |
commit | 9eb10f1e4a470d5d3cc5d94f8daa9e36297b0f28 (patch) | |
tree | aa41477029d234d53ccd5e8432b3ecc11f384ce2 /scene/main | |
parent | 791d7f78b52f5b828aa5541897e12c6a1861ef6f (diff) |
Add an `editor_description` property to Node for documentation purposes
It is implemented using editor-only metadata, in a way similar to
edit locking or Position2D gizmo extents.
This closes #2082.
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/node.cpp | 24 | ||||
-rw-r--r-- | scene/main/node.h | 5 |
2 files changed, 20 insertions, 9 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 0b3a193d18..bd01ca2886 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1875,6 +1875,19 @@ String Node::get_filename() const { return data.filename; } +void Node::set_editor_description(const String &p_editor_description) { + + set_meta("_editor_description_", p_editor_description); +} +String Node::get_editor_description() const { + + if (has_meta("_editor_description_")) { + return get_meta("_editor_description_"); + } else { + return ""; + } +} + void Node::set_editable_instance(Node *p_node, bool p_editable) { ERR_FAIL_NULL(p_node); @@ -2788,6 +2801,10 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("rpc_config", "method", "mode"), &Node::rpc_config); ClassDB::bind_method(D_METHOD("rset_config", "property", "mode"), &Node::rset_config); + ClassDB::bind_method(D_METHOD("_set_editor_description", "editor_description"), &Node::set_editor_description); + ClassDB::bind_method(D_METHOD("_get_editor_description"), &Node::get_editor_description); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "editor_description", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_editor_description", "_get_editor_description"); + ClassDB::bind_method(D_METHOD("_set_import_path", "import_path"), &Node::set_import_path); ClassDB::bind_method(D_METHOD("_get_import_path"), &Node::get_import_path); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "_import_path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_import_path", "_get_import_path"); @@ -2860,10 +2877,6 @@ void Node::_bind_methods() { ADD_SIGNAL(MethodInfo("tree_exiting")); ADD_SIGNAL(MethodInfo("tree_exited")); - //ADD_PROPERTY( PropertyInfo( Variant::BOOL, "process/process" ),"set_process","is_processing") ; - //ADD_PROPERTY( PropertyInfo( Variant::BOOL, "process/physics_process" ), "set_physics_process","is_physics_processing") ; - //ADD_PROPERTY( PropertyInfo( Variant::BOOL, "process/input" ), "set_process_input","is_processing_input" ) ; - //ADD_PROPERTY( PropertyInfo( Variant::BOOL, "process/unhandled_input" ), "set_process_unhandled_input","is_processing_unhandled_input" ) ; ADD_GROUP("Pause", "pause_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "pause_mode", PROPERTY_HINT_ENUM, "Inherit,Stop,Process"), "set_pause_mode", "get_pause_mode"); @@ -2887,9 +2900,6 @@ void Node::_bind_methods() { BIND_VMETHOD(MethodInfo("_unhandled_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); BIND_VMETHOD(MethodInfo("_unhandled_key_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEventKey"))); BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_configuration_warning")); - - //ClassDB::bind_method(D_METHOD("get_child",&Node::get_child,PH("index"))); - //ClassDB::bind_method(D_METHOD("get_node",&Node::get_node,PH("path"))); } String Node::_get_name_num_separator() { diff --git a/scene/main/node.h b/scene/main/node.h index 67b40f6dfc..51a1436014 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -318,6 +318,9 @@ public: void set_filename(const String &p_filename); String get_filename() const; + void set_editor_description(const String &p_editor_description); + String get_editor_description() const; + void set_editable_instance(Node *p_node, bool p_editable); bool is_editable_instance(const Node *p_node) const; void set_editable_instances(const HashMap<NodePath, int> &p_editable_instances); @@ -363,8 +366,6 @@ public: Node *duplicate_from_editor(Map<const Node *, Node *> &r_duplimap) const; #endif - //Node *clone_tree() const; - // used by editors, to save what has changed only void set_scene_instance_state(const Ref<SceneState> &p_state); Ref<SceneState> get_scene_instance_state() const; |