| 112 | } |
| 113 | |
| 114 | void EditorSelectionHistory::add_object(ObjectID p_object, const String &p_property, bool p_inspector_only) { |
| 115 | Object *obj = ObjectDB::get_instance(p_object); |
| 116 | ERR_FAIL_NULL(obj); |
| 117 | RefCounted *r = Object::cast_to<RefCounted>(obj); |
| 118 | _Object o; |
| 119 | if (r) { |
| 120 | o.ref = Ref<RefCounted>(r); |
| 121 | } |
| 122 | o.object = p_object; |
| 123 | o.property = p_property; |
| 124 | o.inspector_only = p_inspector_only; |
| 125 | |
| 126 | bool has_prev = current_elem_idx >= 0 && current_elem_idx < history.size(); |
| 127 | |
| 128 | if (has_prev) { |
| 129 | history.resize(current_elem_idx + 1); // Clip history to next. |
| 130 | } |
| 131 | |
| 132 | HistoryElement h; |
| 133 | if (!p_property.is_empty() && has_prev) { |
| 134 | // Add a sub property. |
| 135 | HistoryElement &prev_element = history.write[current_elem_idx]; |
| 136 | h = prev_element; |
| 137 | h.path.resize(h.level + 1); |
| 138 | h.path.push_back(o); |
| 139 | h.level++; |
| 140 | |
| 141 | } else { |
| 142 | // Create a new history item. |
| 143 | h.path.push_back(o); |
| 144 | h.level = 0; |
| 145 | } |
| 146 | |
| 147 | history.push_back(h); |
| 148 | current_elem_idx++; |
| 149 | } |
| 150 | |
| 151 | void EditorSelectionHistory::replace_object(ObjectID p_old_object, ObjectID p_new_object) { |
| 152 | for (HistoryElement &element : history) { |
no test coverage detected