| 2871 | } |
| 2872 | |
| 2873 | void SceneTreeDock::_update_script_button() { |
| 2874 | bool can_create_script = false; |
| 2875 | bool can_detach_script = false; |
| 2876 | bool can_extend_script = false; |
| 2877 | |
| 2878 | if (profile_allow_script_editing) { |
| 2879 | Array selection = editor_selection->get_selected_nodes(); |
| 2880 | |
| 2881 | for (int i = 0; i < selection.size(); i++) { |
| 2882 | Node *n = Object::cast_to<Node>(selection[i]); |
| 2883 | Ref<Script> s = n->get_script(); |
| 2884 | Ref<Script> cts; |
| 2885 | |
| 2886 | if (n->has_meta(SceneStringName(_custom_type_script))) { |
| 2887 | cts = PropertyUtils::get_custom_type_script(n); |
| 2888 | } |
| 2889 | |
| 2890 | if (selection.size() == 1) { |
| 2891 | if (s.is_valid()) { |
| 2892 | if (cts.is_valid() && s == cts) { |
| 2893 | can_extend_script = true; |
| 2894 | } |
| 2895 | } else { |
| 2896 | can_create_script = true; |
| 2897 | } |
| 2898 | } |
| 2899 | |
| 2900 | if (s.is_valid()) { |
| 2901 | if (cts.is_valid()) { |
| 2902 | if (s != cts) { |
| 2903 | can_detach_script = true; |
| 2904 | break; |
| 2905 | } |
| 2906 | } else { |
| 2907 | can_detach_script = true; |
| 2908 | break; |
| 2909 | } |
| 2910 | } |
| 2911 | } |
| 2912 | } |
| 2913 | |
| 2914 | button_create_script->set_visible(can_create_script); |
| 2915 | button_detach_script->set_visible(can_detach_script); |
| 2916 | button_extend_script->set_visible(can_extend_script); |
| 2917 | |
| 2918 | update_script_button_queued = false; |
| 2919 | } |
| 2920 | |
| 2921 | void SceneTreeDock::_queue_update_script_button() { |
| 2922 | if (update_script_button_queued) { |
nothing calls this directly
no test coverage detected