diff options
Diffstat (limited to 'editor/editor_data.cpp')
-rw-r--r-- | editor/editor_data.cpp | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 9c739474d1..6f6a863b70 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -39,9 +39,7 @@ #include "scene/resources/packed_scene.h" void EditorHistory::cleanup_history() { - for (int i = 0; i < history.size(); i++) { - bool fail = false; for (int j = 0; j < history[i].path.size(); j++) { @@ -79,7 +77,6 @@ void EditorHistory::cleanup_history() { } void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int p_level_change, bool p_inspector_only) { - Object *obj = ObjectDB::get_instance(p_object); ERR_FAIL_COND(!obj); Reference *r = Object::cast_to<Reference>(obj); @@ -122,22 +119,18 @@ void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int } void EditorHistory::add_object_inspector_only(ObjectID p_object) { - _add_object(p_object, "", -1, true); } void EditorHistory::add_object(ObjectID p_object) { - _add_object(p_object, "", -1); } void EditorHistory::add_object(ObjectID p_object, const String &p_subprop) { - _add_object(p_object, p_subprop, -1); } void EditorHistory::add_object(ObjectID p_object, int p_relevel) { - _add_object(p_object, "", p_relevel); } @@ -149,7 +142,6 @@ int EditorHistory::get_history_pos() { } bool EditorHistory::is_history_obj_inspector_only(int p_obj) const { - ERR_FAIL_INDEX_V(p_obj, history.size(), false); ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), false); return history[p_obj].path[history[p_obj].level].inspector_only; @@ -165,12 +157,10 @@ bool EditorHistory::is_at_beginning() const { return current <= 0; } bool EditorHistory::is_at_end() const { - return ((current + 1) >= history.size()); } bool EditorHistory::next() { - cleanup_history(); if ((current + 1) < history.size()) @@ -182,7 +172,6 @@ bool EditorHistory::next() { } bool EditorHistory::previous() { - cleanup_history(); if (current > 0) @@ -194,7 +183,6 @@ bool EditorHistory::previous() { } bool EditorHistory::is_current_inspector_only() const { - if (current < 0 || current >= history.size()) return false; @@ -202,7 +190,6 @@ bool EditorHistory::is_current_inspector_only() const { return h.path[h.level].inspector_only; } ObjectID EditorHistory::get_current() { - if (current < 0 || current >= history.size()) return ObjectID(); @@ -215,7 +202,6 @@ ObjectID EditorHistory::get_current() { } int EditorHistory::get_path_size() const { - if (current < 0 || current >= history.size()) return 0; @@ -224,7 +210,6 @@ int EditorHistory::get_path_size() const { } ObjectID EditorHistory::get_path_object(int p_index) const { - if (current < 0 || current >= history.size()) return ObjectID(); @@ -240,7 +225,6 @@ ObjectID EditorHistory::get_path_object(int p_index) const { } String EditorHistory::get_path_property(int p_index) const { - if (current < 0 || current >= history.size()) return ""; @@ -252,20 +236,16 @@ String EditorHistory::get_path_property(int p_index) const { } void EditorHistory::clear() { - history.clear(); current = -1; } EditorHistory::EditorHistory() { - current = -1; } EditorPlugin *EditorData::get_editor(Object *p_object) { - for (int i = 0; i < editor_plugins.size(); i++) { - if (editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) return editor_plugins[i]; } @@ -274,9 +254,7 @@ EditorPlugin *EditorData::get_editor(Object *p_object) { } EditorPlugin *EditorData::get_subeditor(Object *p_object) { - for (int i = 0; i < editor_plugins.size(); i++) { - if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) return editor_plugins[i]; } @@ -295,9 +273,7 @@ Vector<EditorPlugin *> EditorData::get_subeditors(Object *p_object) { } EditorPlugin *EditorData::get_editor(String p_name) { - for (int i = 0; i < editor_plugins.size(); i++) { - if (editor_plugins[i]->get_name() == p_name) return editor_plugins[i]; } @@ -306,14 +282,12 @@ EditorPlugin *EditorData::get_editor(String p_name) { } void EditorData::copy_object_params(Object *p_object) { - clipboard.clear(); List<PropertyInfo> pinfo; p_object->get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR) || E->get().name == "script" || E->get().name == "scripts") continue; @@ -325,18 +299,14 @@ void EditorData::copy_object_params(Object *p_object) { } void EditorData::get_editor_breakpoints(List<String> *p_breakpoints) { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->get_breakpoints(p_breakpoints); } } Dictionary EditorData::get_editor_states() const { - Dictionary metadata; for (int i = 0; i < editor_plugins.size(); i++) { - Dictionary state = editor_plugins[i]->get_state(); if (state.empty()) continue; @@ -353,17 +323,14 @@ Dictionary EditorData::get_scene_editor_states(int p_idx) const { } void EditorData::set_editor_states(const Dictionary &p_states) { - List<Variant> keys; p_states.get_key_list(&keys); List<Variant>::Element *E = keys.front(); for (; E; E = E->next()) { - String name = E->get(); int idx = -1; for (int i = 0; i < editor_plugins.size(); i++) { - if (editor_plugins[i]->get_name() == name) { idx = i; break; @@ -377,64 +344,49 @@ void EditorData::set_editor_states(const Dictionary &p_states) { } void EditorData::notify_edited_scene_changed() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->edited_scene_changed(); editor_plugins[i]->notify_scene_changed(get_edited_scene_root()); } } void EditorData::notify_resource_saved(const Ref<Resource> &p_resource) { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->notify_resource_saved(p_resource); } } void EditorData::clear_editor_states() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->clear(); } } void EditorData::save_editor_external_data() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->save_external_data(); } } void EditorData::apply_changes_in_editors() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->apply_changes(); } } void EditorData::save_editor_global_states() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->save_global_state(); } } void EditorData::restore_editor_global_states() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->restore_global_state(); } } void EditorData::paste_object_params(Object *p_object) { - ERR_FAIL_NULL(p_object); undo_redo.create_action(TTR("Paste Params")); for (List<PropertyData>::Element *E = clipboard.front(); E; E = E->next()) { @@ -446,11 +398,9 @@ void EditorData::paste_object_params(Object *p_object) { } bool EditorData::call_build() { - bool result = true; for (int i = 0; i < editor_plugins.size() && result; i++) { - result &= editor_plugins[i]->build(); } @@ -458,18 +408,15 @@ bool EditorData::call_build() { } UndoRedo &EditorData::get_undo_redo() { - return undo_redo; } void EditorData::remove_editor_plugin(EditorPlugin *p_plugin) { - p_plugin->undo_redo = nullptr; editor_plugins.erase(p_plugin); } void EditorData::add_editor_plugin(EditorPlugin *p_plugin) { - p_plugin->undo_redo = &undo_redo; editor_plugins.push_back(p_plugin); } @@ -478,13 +425,11 @@ int EditorData::get_editor_plugin_count() const { return editor_plugins.size(); } EditorPlugin *EditorData::get_editor_plugin(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, editor_plugins.size(), nullptr); return editor_plugins[p_idx]; } void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) { - ERR_FAIL_COND_MSG(p_script.is_null(), "It's not a reference to a valid Script object."); CustomType ct; ct.name = p_type; @@ -498,9 +443,7 @@ void EditorData::add_custom_type(const String &p_type, const String &p_inherits, } Object *EditorData::instance_custom_type(const String &p_type, const String &p_inherits) { - if (get_custom_types().has(p_inherits)) { - for (int i = 0; i < get_custom_types()[p_inherits].size(); i++) { if (get_custom_types()[p_inherits][i].name == p_type) { Ref<Script> script = get_custom_types()[p_inherits][i].script; @@ -520,9 +463,7 @@ Object *EditorData::instance_custom_type(const String &p_type, const String &p_i } void EditorData::remove_custom_type(const String &p_type) { - for (Map<String, Vector<CustomType>>::Element *E = custom_types.front(); E; E = E->next()) { - for (int i = 0; i < E->get().size(); i++) { if (E->get()[i].name == p_type) { E->get().remove(i); @@ -536,7 +477,6 @@ void EditorData::remove_custom_type(const String &p_type) { } int EditorData::add_edited_scene(int p_at_pos) { - if (p_at_pos < 0) p_at_pos = edited_scene.size(); EditedScene es; @@ -557,7 +497,6 @@ int EditorData::add_edited_scene(int p_at_pos) { } void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) { - ERR_FAIL_INDEX(p_idx, edited_scene.size()); ERR_FAIL_INDEX(p_to_idx, edited_scene.size()); SWAP(edited_scene.write[p_idx], edited_scene.write[p_to_idx]); @@ -566,7 +505,6 @@ void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) { void EditorData::remove_scene(int p_idx) { ERR_FAIL_INDEX(p_idx, edited_scene.size()); if (edited_scene[p_idx].root) { - for (int i = 0; i < editor_plugins.size(); i++) { editor_plugins[i]->notify_scene_closed(edited_scene[p_idx].root->get_filename()); } @@ -584,7 +522,6 @@ void EditorData::remove_scene(int p_idx) { } bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths) { - /* if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner())) return false; @@ -602,7 +539,6 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> String path = ss->get_path(); if (!checked_paths.has(path)) { - uint64_t modified_time = FileAccess::get_modified_time(path); if (modified_time != ss->get_last_modified_time()) { return true; //external scene changed @@ -613,7 +549,6 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> } for (int i = 0; i < p_node->get_child_count(); i++) { - bool found = _find_updated_instances(p_root, p_node->get_child(i), checked_paths); if (found) return true; @@ -623,7 +558,6 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> } bool EditorData::check_and_update_scene(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), false); if (!edited_scene[p_idx].root) return false; @@ -669,11 +603,9 @@ bool EditorData::check_and_update_scene(int p_idx) { } int EditorData::get_edited_scene() const { - return current_edited_scene; } void EditorData::set_edited_scene(int p_idx) { - ERR_FAIL_INDEX(p_idx, edited_scene.size()); current_edited_scene = p_idx; //swap @@ -688,7 +620,6 @@ Node *EditorData::get_edited_scene_root(int p_idx) { } } void EditorData::set_edited_scene_root(Node *p_root) { - ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); edited_scene.write[current_edited_scene].root = p_root; if (p_root) { @@ -700,12 +631,10 @@ void EditorData::set_edited_scene_root(Node *p_root) { } int EditorData::get_edited_scene_count() const { - return edited_scene.size(); } Vector<EditorData::EditedScene> EditorData::get_edited_scenes() const { - Vector<EditedScene> out_edited_scenes_list = Vector<EditedScene>(); for (int i = 0; i < edited_scene.size(); i++) { @@ -726,7 +655,6 @@ void EditorData::set_edited_scene_version(uint64_t version, int p_scene_idx) { } uint64_t EditorData::get_edited_scene_version() const { - ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), 0); return edited_scene[current_edited_scene].version; } @@ -736,14 +664,12 @@ uint64_t EditorData::get_scene_version(int p_idx) const { } String EditorData::get_scene_type(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String()); if (!edited_scene[p_idx].root) return ""; return edited_scene[p_idx].root->get_class(); } void EditorData::move_edited_scene_to_index(int p_idx) { - ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); ERR_FAIL_INDEX(p_idx, edited_scene.size()); @@ -754,7 +680,6 @@ void EditorData::move_edited_scene_to_index(int p_idx) { } Ref<Script> EditorData::get_scene_root_script(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), Ref<Script>()); if (!edited_scene[p_idx].root) return Ref<Script>(); @@ -784,7 +709,6 @@ String EditorData::get_scene_title(int p_idx) const { } void EditorData::set_scene_path(int p_idx, const String &p_path) { - ERR_FAIL_INDEX(p_idx, edited_scene.size()); edited_scene.write[p_idx].path = p_path; @@ -794,7 +718,6 @@ void EditorData::set_scene_path(int p_idx, const String &p_path) { } String EditorData::get_scene_path(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String()); if (edited_scene[p_idx].root) { @@ -813,14 +736,12 @@ void EditorData::set_edited_scene_live_edit_root(const NodePath &p_root) { edited_scene.write[current_edited_scene].live_edit_root = p_root; } NodePath EditorData::get_edited_scene_live_edit_root() { - ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), String()); return edited_scene[current_edited_scene].live_edit_root; } void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary &p_custom) { - ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); EditedScene &es = edited_scene.write[current_edited_scene]; @@ -849,7 +770,6 @@ Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, } void EditorData::clear_edited_scenes() { - for (int i = 0; i < edited_scene.size(); i++) { if (edited_scene[i].root) { memdelete(edited_scene[i].root); @@ -892,7 +812,6 @@ bool EditorData::script_class_is_parent(const String &p_class, const String &p_i } StringName EditorData::script_class_get_base(const String &p_class) const { - Ref<Script> script = script_class_load_script(p_class); if (script.is_null()) return StringName(); @@ -919,7 +838,6 @@ Object *EditorData::script_class_instance(const String &p_class) { } Ref<Script> EditorData::script_class_load_script(const String &p_class) const { - if (!ScriptServer::is_global_class(p_class)) return Ref<Script>(); @@ -988,7 +906,6 @@ void EditorData::script_class_load_icon_paths() { } EditorData::EditorData() { - current_edited_scene = -1; //load_imported_scenes_from_globals(); @@ -997,7 +914,6 @@ EditorData::EditorData() { /////////// void EditorSelection::_node_removed(Node *p_node) { - if (!selection.has(p_node)) return; @@ -1010,7 +926,6 @@ void EditorSelection::_node_removed(Node *p_node) { } void EditorSelection::add_node(Node *p_node) { - ERR_FAIL_NULL(p_node); ERR_FAIL_COND(!p_node->is_inside_tree()); if (selection.has(p_node)) @@ -1020,7 +935,6 @@ void EditorSelection::add_node(Node *p_node) { nl_changed = true; Object *meta = nullptr; for (List<Object *>::Element *E = editor_plugins.front(); E; E = E->next()) { - meta = E->get()->call("_get_editor_data", p_node); if (meta) { break; @@ -1034,7 +948,6 @@ void EditorSelection::add_node(Node *p_node) { } void EditorSelection::remove_node(Node *p_node) { - ERR_FAIL_NULL(p_node); if (!selection.has(p_node)) @@ -1050,16 +963,13 @@ void EditorSelection::remove_node(Node *p_node) { //emit_signal("selection_changed"); } bool EditorSelection::is_selected(Node *p_node) const { - return selection.has(p_node); } Array EditorSelection::_get_transformable_selected_nodes() { - Array ret; for (List<Node *>::Element *E = selected_node_list.front(); E; E = E->next()) { - ret.push_back(E->get()); } @@ -1067,11 +977,9 @@ Array EditorSelection::_get_transformable_selected_nodes() { } TypedArray<Node> EditorSelection::get_selected_nodes() { - TypedArray<Node> ret; for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - ret.push_back(E->key()); } @@ -1079,7 +987,6 @@ TypedArray<Node> EditorSelection::get_selected_nodes() { } void EditorSelection::_bind_methods() { - ClassDB::bind_method(D_METHOD("clear"), &EditorSelection::clear); ClassDB::bind_method(D_METHOD("add_node", "node"), &EditorSelection::add_node); ClassDB::bind_method(D_METHOD("remove_node", "node"), &EditorSelection::remove_node); @@ -1090,19 +997,16 @@ void EditorSelection::_bind_methods() { } void EditorSelection::add_editor_plugin(Object *p_object) { - editor_plugins.push_back(p_object); } void EditorSelection::_update_nl() { - if (!nl_changed) return; selected_node_list.clear(); for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - Node *parent = E->key(); parent = parent->get_parent(); bool skip = false; @@ -1123,7 +1027,6 @@ void EditorSelection::_update_nl() { } void EditorSelection::update() { - _update_nl(); if (!changed) @@ -1141,7 +1044,6 @@ void EditorSelection::_emit_change() { } List<Node *> &EditorSelection::get_selected_node_list() { - if (changed) update(); else @@ -1150,7 +1052,6 @@ List<Node *> &EditorSelection::get_selected_node_list() { } List<Node *> EditorSelection::get_full_selected_node_list() { - List<Node *> node_list; for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { node_list.push_back(E->key()); @@ -1160,9 +1061,7 @@ List<Node *> EditorSelection::get_full_selected_node_list() { } void EditorSelection::clear() { - while (!selection.empty()) { - remove_node(selection.front()->key()); } @@ -1170,13 +1069,11 @@ void EditorSelection::clear() { nl_changed = true; } EditorSelection::EditorSelection() { - emitted = false; changed = false; nl_changed = false; } EditorSelection::~EditorSelection() { - clear(); } |