MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _clear_array

Method _clear_array

editor/inspector/editor_inspector.cpp:2773–2813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2771}
2772
2773void EditorInspectorArray::_clear_array() {
2774 EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
2775 undo_redo->create_action(vformat(TTR("Clear Property Array with Prefix %s"), array_element_prefix));
2776 if (mode == MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION) {
2777 for (int i = count - 1; i >= 0; i--) {
2778 // Call the function.
2779 Callable move_function = EditorNode::get_editor_data().get_move_array_element_function(object->get_class_name());
2780 if (move_function.is_valid()) {
2781 move_function.call(undo_redo, object, array_element_prefix, i, -1);
2782 } else {
2783 WARN_PRINT(vformat("Could not find a function to move arrays elements for class %s. Register a move element function using EditorData::add_move_array_element_function", object->get_class_name()));
2784 }
2785 }
2786 } else if (mode == MODE_USE_COUNT_PROPERTY) {
2787 List<PropertyInfo> object_property_list;
2788 object->get_property_list(&object_property_list);
2789
2790 Array properties_as_array = _extract_properties_as_array(object_property_list);
2791 properties_as_array.resize(count);
2792
2793 // For undoing things
2794 undo_redo->add_undo_property(object, count_property, count);
2795 for (int i = 0; i < (int)properties_as_array.size(); i++) {
2796 Dictionary d = Dictionary(properties_as_array[i]);
2797 for (const KeyValue<Variant, Variant> &kv : d) {
2798 undo_redo->add_undo_property(object, vformat(kv.key, i), kv.value);
2799 }
2800 }
2801
2802 // Change the array size then set the properties.
2803 undo_redo->add_do_property(object, count_property, 0);
2804 }
2805 undo_redo->commit_action();
2806
2807 // Handle page change and update counts.
2808 emit_signal(SNAME("page_change_request"), 0);
2809 count = 0;
2810 begin_array_index = 0;
2811 end_array_index = 0;
2812 max_page = 0;
2813}
2814
2815void EditorInspectorArray::_resize_array(int p_size) {
2816 ERR_FAIL_COND(p_size < 0);

Callers

nothing calls this directly

Calls 13

vformatFunction · 0.85
TTRFunction · 0.85
sizeMethod · 0.65
DictionaryClass · 0.50
create_actionMethod · 0.45
is_validMethod · 0.45
callMethod · 0.45
get_property_listMethod · 0.45
resizeMethod · 0.45
add_undo_propertyMethod · 0.45
add_do_propertyMethod · 0.45

Tested by

no test coverage detected