From f8db8a3faa30b71dca33ced38be16d3f93f43e8a Mon Sep 17 00:00:00 2001 From: Rémi Verschelde Date: Sun, 19 Mar 2017 00:36:26 +0100 Subject: Bring that Whole New World to the Old Continent too Applies the clang-format style to the 2.1 branch as done for master in 5dbf1809c6e3e905b94b8764e99491e608122261. --- editor/editor_data.cpp | 517 ++++++++++++++++++++++--------------------------- 1 file changed, 229 insertions(+), 288 deletions(-) (limited to 'editor/editor_data.cpp') diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 25a7290f4..d0d8f107e 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -27,30 +27,30 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_data.h" -#include "globals.h" +#include "editor_node.h" #include "editor_settings.h" -#include "os/dir_access.h" +#include "globals.h" #include "io/resource_loader.h" -#include "scene/resources/packed_scene.h" +#include "os/dir_access.h" #include "os/file_access.h" -#include "editor_node.h" +#include "scene/resources/packed_scene.h" void EditorHistory::_cleanup_history() { - for(int i=0;i=history.size()) - current=history.size()-1; + if (current >= history.size()) + current = history.size() - 1; } -void EditorHistory::_add_object(ObjectID p_object,const String& p_property,int p_level_change) { +void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int p_level_change) { Object *obj = ObjectDB::get_instance(p_object); ERR_FAIL_COND(!obj); Reference *r = obj->cast_to(); Obj o; if (r) - o.ref=REF(r); - o.object=p_object; - o.property=p_property; + o.ref = REF(r); + o.object = p_object; + o.property = p_property; History h; - bool has_prev = current>=0 && current= 0 && current < history.size(); if (has_prev) { - history.resize(current+1); //clip history to next + history.resize(current + 1); //clip history to next } - if (p_property!="" && has_prev) { + if (p_property != "" && has_prev) { //add a sub property History &pr = history[current]; - h=pr; - h.path.resize(h.level+1); + h = pr; + h.path.resize(h.level + 1); h.path.push_back(o); h.level++; - } else if (p_level_change!=-1 && has_prev) { + } else if (p_level_change != -1 && has_prev) { //add a sub property History &pr = history[current]; - h=pr; - ERR_FAIL_INDEX(p_level_change,h.path.size()); - h.level=p_level_change; + h = pr; + ERR_FAIL_INDEX(p_level_change, h.path.size()); + h.level = p_level_change; } else { //add a new node h.path.push_back(o); - h.level=0; + h.level = 0; } history.push_back(h); @@ -113,17 +113,17 @@ void EditorHistory::_add_object(ObjectID p_object,const String& p_property,int p void EditorHistory::add_object(ObjectID p_object) { - _add_object(p_object,"",-1); + _add_object(p_object, "", -1); } -void EditorHistory::add_object(ObjectID p_object,const String& p_subprop) { +void EditorHistory::add_object(ObjectID p_object, const String &p_subprop) { - _add_object(p_object,p_subprop,-1); + _add_object(p_object, p_subprop, -1); } -void EditorHistory::add_object(ObjectID p_object,int p_relevel){ +void EditorHistory::add_object(ObjectID p_object, int p_relevel) { - _add_object(p_object,"",p_relevel); + _add_object(p_object, "", p_relevel); } int EditorHistory::get_history_len() { @@ -134,26 +134,24 @@ int EditorHistory::get_history_pos() { } ObjectID EditorHistory::get_history_obj(int p_obj) const { - ERR_FAIL_INDEX_V(p_obj,history.size(),0); - ERR_FAIL_INDEX_V(history[p_obj].level,history[p_obj].path.size(),0); + ERR_FAIL_INDEX_V(p_obj, history.size(), 0); + ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), 0); return history[p_obj].path[history[p_obj].level].object; } bool EditorHistory::is_at_begining() const { - return current<=0; + return current <= 0; } bool EditorHistory::is_at_end() const { - return ((current+1)>=history.size()); + return ((current + 1) >= history.size()); } - bool EditorHistory::next() { - _cleanup_history(); - if ((current+1)0) + if (current > 0) current--; else return false; @@ -176,11 +173,10 @@ bool EditorHistory::previous() { ObjectID EditorHistory::get_current() { - - if (current<0 || current >=history.size()) + if (current < 0 || current >= history.size()) return 0; - History &h=history[current]; + History &h = history[current]; Object *obj = ObjectDB::get_instance(h.path[h.level].object); if (!obj) return 0; @@ -190,22 +186,21 @@ ObjectID EditorHistory::get_current() { int EditorHistory::get_path_size() const { - if (current<0 || current >=history.size()) + if (current < 0 || current >= history.size()) return 0; - const History &h=history[current]; + const History &h = history[current]; return h.path.size(); - } ObjectID EditorHistory::get_path_object(int p_index) const { - if (current<0 || current >=history.size()) + if (current < 0 || current >= history.size()) return 0; - const History &h=history[current]; + const History &h = history[current]; - ERR_FAIL_INDEX_V(p_index,h.path.size(),0); + ERR_FAIL_INDEX_V(p_index, h.path.size(), 0); Object *obj = ObjectDB::get_instance(h.path[p_index].object); if (!obj) @@ -216,31 +211,30 @@ ObjectID EditorHistory::get_path_object(int p_index) const { String EditorHistory::get_path_property(int p_index) const { - if (current<0 || current >=history.size()) + if (current < 0 || current >= history.size()) return ""; - const History &h=history[current]; + const History &h = history[current]; - ERR_FAIL_INDEX_V(p_index,h.path.size(),""); + ERR_FAIL_INDEX_V(p_index, h.path.size(), ""); return h.path[p_index].property; - } void EditorHistory::clear() { history.clear(); - current=-1; + current = -1; } EditorHistory::EditorHistory() { - current=-1; + current = -1; } -EditorPlugin* EditorData::get_editor(Object *p_object) { +EditorPlugin *EditorData::get_editor(Object *p_object) { - for (int i=0;ihas_main_screen() && editor_plugins[i]->handles(p_object)) return editor_plugins[i]; @@ -249,9 +243,9 @@ EditorPlugin* EditorData::get_editor(Object *p_object) { return NULL; } -EditorPlugin* EditorData::get_subeditor(Object *p_object) { +EditorPlugin *EditorData::get_subeditor(Object *p_object) { - for (int i=0;ihas_main_screen() && editor_plugins[i]->handles(p_object)) return editor_plugins[i]; @@ -260,8 +254,8 @@ EditorPlugin* EditorData::get_subeditor(Object *p_object) { return NULL; } -Vector EditorData::get_subeditors(Object* p_object) { - Vector sub_plugins; +Vector EditorData::get_subeditors(Object *p_object) { + Vector sub_plugins; for (int i = 0; i < editor_plugins.size(); i++) { if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) { sub_plugins.push_back(editor_plugins[i]); @@ -270,11 +264,11 @@ Vector EditorData::get_subeditors(Object* p_object) { return sub_plugins; } -EditorPlugin* EditorData::get_editor(String p_name) { +EditorPlugin *EditorData::get_editor(String p_name) { - for(int i=0;iget_name()==p_name) + if (editor_plugins[i]->get_name() == p_name) return editor_plugins[i]; } @@ -288,79 +282,73 @@ void EditorData::copy_object_params(Object *p_object) { List pinfo; p_object->get_property_list(&pinfo); - for( List::Element *E=pinfo.front();E;E=E->next()) { + for (List::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage&PROPERTY_USAGE_EDITOR)) + if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) continue; PropertyData pd; - pd.name=E->get().name; - pd.value=p_object->get(pd.name); + pd.name = E->get().name; + pd.value = p_object->get(pd.name); clipboard.push_back(pd); } } void EditorData::get_editor_breakpoints(List *p_breakpoints) { - - for(int i=0;iget_breakpoints(p_breakpoints); } - - } Dictionary EditorData::get_editor_states() const { Dictionary metadata; - for(int i=0;iget_state(); + Dictionary state = editor_plugins[i]->get_state(); if (state.empty()) continue; - metadata[editor_plugins[i]->get_name()]=state; + metadata[editor_plugins[i]->get_name()] = state; } return metadata; - } -Dictionary EditorData::get_scene_editor_states(int p_idx) const -{ - ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),Dictionary()); +Dictionary EditorData::get_scene_editor_states(int p_idx) const { + ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), Dictionary()); EditedScene es = edited_scene[p_idx]; return es.editor_states; } -void EditorData::set_editor_states(const Dictionary& p_states) { +void EditorData::set_editor_states(const Dictionary &p_states) { List keys; p_states.get_key_list(&keys); - List::Element *E=keys.front(); - for(;E;E=E->next()) { + List::Element *E = keys.front(); + for (; E; E = E->next()) { String name = E->get(); - int idx=-1; - for(int i=0;iget_name()==name) { - idx=i; + if (editor_plugins[i]->get_name() == name) { + idx = i; break; } } - if (idx==-1) + if (idx == -1) continue; editor_plugins[idx]->set_state(p_states[name]); } - } void EditorData::notify_edited_scene_changed() { - for(int i=0;iedited_scene_changed(); } @@ -368,16 +356,15 @@ void EditorData::notify_edited_scene_changed() { void EditorData::clear_editor_states() { - for(int i=0;iclear(); } - } void EditorData::save_editor_external_data() { - for(int i=0;isave_external_data(); } @@ -385,42 +372,36 @@ void EditorData::save_editor_external_data() { void EditorData::apply_changes_in_editors() { - for(int i=0;iapply_changes(); } - } void EditorData::save_editor_global_states() { - for(int i=0;isave_global_state(); } } -void EditorData::restore_editor_global_states(){ +void EditorData::restore_editor_global_states() { - for(int i=0;irestore_global_state(); } - } - void EditorData::paste_object_params(Object *p_object) { + for (List::Element *E = clipboard.front(); E; E = E->next()) { - for( List::Element *E=clipboard.front();E;E=E->next()) { - - p_object->set( E->get().name, E->get().value); + p_object->set(E->get().name, E->get().value); } - } - UndoRedo &EditorData::get_undo_redo() { return undo_redo; @@ -428,14 +409,13 @@ UndoRedo &EditorData::get_undo_redo() { void EditorData::remove_editor_plugin(EditorPlugin *p_plugin) { - p_plugin->undo_redo=NULL; + p_plugin->undo_redo = NULL; editor_plugins.erase(p_plugin); - } void EditorData::add_editor_plugin(EditorPlugin *p_plugin) { - p_plugin->undo_redo=&undo_redo; + p_plugin->undo_redo = &undo_redo; editor_plugins.push_back(p_plugin); } @@ -444,32 +424,30 @@ int EditorData::get_editor_plugin_count() const { } EditorPlugin *EditorData::get_editor_plugin(int p_idx) { - ERR_FAIL_INDEX_V(p_idx,editor_plugins.size(),NULL); + ERR_FAIL_INDEX_V(p_idx, editor_plugins.size(), NULL); return editor_plugins[p_idx]; } - -void EditorData::add_custom_type(const String& p_type, const String& p_inherits,const Ref