SceneDebuggerTree
| 912 | |
| 913 | /// SceneDebuggerTree |
| 914 | SceneDebuggerTree::SceneDebuggerTree(Node *p_root) { |
| 915 | // Flatten tree into list, depth first, use stack to avoid recursion. |
| 916 | List<Node *> stack; |
| 917 | stack.push_back(p_root); |
| 918 | bool is_root = true; |
| 919 | const StringName &is_visible_sn = SNAME("is_visible"); |
| 920 | const StringName &is_visible_in_tree_sn = SNAME("is_visible_in_tree"); |
| 921 | while (stack.size()) { |
| 922 | Node *n = stack.front()->get(); |
| 923 | stack.pop_front(); |
| 924 | |
| 925 | int count = n->get_child_count(); |
| 926 | for (int i = 0; i < count; i++) { |
| 927 | stack.push_front(n->get_child(count - i - 1)); |
| 928 | } |
| 929 | |
| 930 | int view_flags = 0; |
| 931 | if (is_root) { |
| 932 | // Prevent root window visibility from being changed. |
| 933 | is_root = false; |
| 934 | } else if (n->has_method(is_visible_sn)) { |
| 935 | const Variant visible = n->call(is_visible_sn); |
| 936 | if (visible.get_type() == Variant::BOOL) { |
| 937 | view_flags = RemoteNode::VIEW_HAS_VISIBLE_METHOD; |
| 938 | view_flags |= uint8_t(visible) * RemoteNode::VIEW_VISIBLE; |
| 939 | } |
| 940 | if (n->has_method(is_visible_in_tree_sn)) { |
| 941 | const Variant visible_in_tree = n->call(is_visible_in_tree_sn); |
| 942 | if (visible_in_tree.get_type() == Variant::BOOL) { |
| 943 | view_flags |= uint8_t(visible_in_tree) * RemoteNode::VIEW_VISIBLE_IN_TREE; |
| 944 | } |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | String class_name; |
| 949 | ScriptInstance *script_instance = n->get_script_instance(); |
| 950 | if (script_instance) { |
| 951 | Ref<Script> script = script_instance->get_script(); |
| 952 | if (script.is_valid()) { |
| 953 | class_name = script->get_global_name(); |
| 954 | |
| 955 | if (class_name.is_empty()) { |
| 956 | // If there is no class_name in this script we just take the script path. |
| 957 | class_name = script->get_path(); |
| 958 | } |
| 959 | } |
| 960 | } |
| 961 | nodes.push_back(RemoteNode(count, n->get_name(), class_name.is_empty() ? n->get_class() : class_name, n->get_instance_id(), n->get_scene_file_path(), view_flags)); |
| 962 | } |
| 963 | } |
| 964 | |
| 965 | void SceneDebuggerTree::serialize(Array &p_arr) { |
| 966 | for (const RemoteNode &n : nodes) { |
nothing calls this directly
no test coverage detected