diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
commit | 5dbf1809c6e3e905b94b8764e99491e608122261 (patch) | |
tree | 5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /editor/editor_sub_scene.cpp | |
parent | 45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff) |
A Whole New World (clang-format edition)
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?
I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon
A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format
A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
Diffstat (limited to 'editor/editor_sub_scene.cpp')
-rw-r--r-- | editor/editor_sub_scene.cpp | 122 |
1 files changed, 50 insertions, 72 deletions
diff --git a/editor/editor_sub_scene.cpp b/editor/editor_sub_scene.cpp index 917560b540..01c08bb231 100644 --- a/editor/editor_sub_scene.cpp +++ b/editor/editor_sub_scene.cpp @@ -31,27 +31,25 @@ #include "scene/gui/margin_container.h" #include "scene/resources/packed_scene.h" -void EditorSubScene::_path_selected(const String& p_path) { +void EditorSubScene::_path_selected(const String &p_path) { path->set_text(p_path); _path_changed(p_path); - } -void EditorSubScene::_path_changed(const String& p_path) { +void EditorSubScene::_path_changed(const String &p_path) { tree->clear(); - if (scene) { memdelete(scene); - scene=NULL; + scene = NULL; } - if (p_path=="") + if (p_path == "") return; - Ref<PackedScene> ps = ResourceLoader::load(p_path,"PackedScene"); + Ref<PackedScene> ps = ResourceLoader::load(p_path, "PackedScene"); if (ps.is_null()) return; @@ -60,10 +58,7 @@ void EditorSubScene::_path_changed(const String& p_path) { if (!scene) return; - _fill_tree(scene,NULL); - - - + _fill_tree(scene, NULL); } void EditorSubScene::_path_browse() { @@ -71,45 +66,37 @@ void EditorSubScene::_path_browse() { file_dialog->popup_centered_ratio(); } - void EditorSubScene::_notification(int p_what) { - if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { + if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { if (!is_visible_in_tree()) { - - } } } - -void EditorSubScene::_fill_tree(Node* p_node,TreeItem *p_parent) { +void EditorSubScene::_fill_tree(Node *p_node, TreeItem *p_parent) { TreeItem *it = tree->create_item(p_parent); - it->set_metadata(0,p_node); - it->set_text(0,p_node->get_name()); - it->set_editable(0,false); - it->set_selectable(0,true); - if (has_icon(p_node->get_class(),"EditorIcons")) { - it->set_icon(0,get_icon(p_node->get_class(),"EditorIcons")); - + it->set_metadata(0, p_node); + it->set_text(0, p_node->get_name()); + it->set_editable(0, false); + it->set_selectable(0, true); + if (has_icon(p_node->get_class(), "EditorIcons")) { + it->set_icon(0, get_icon(p_node->get_class(), "EditorIcons")); } - for(int i=0;i<p_node->get_child_count();i++) { + for (int i = 0; i < p_node->get_child_count(); i++) { Node *c = p_node->get_child(i); - if (c->get_owner()!=scene) + if (c->get_owner() != scene) continue; - _fill_tree(c,it); + _fill_tree(c, it); } - } - void EditorSubScene::ok_pressed() { - TreeItem *s = tree->get_selected(); if (!s) return; @@ -119,29 +106,26 @@ void EditorSubScene::ok_pressed() { emit_signal("subscene_selected"); hide(); clear(); - - } +void EditorSubScene::_reown(Node *p_node, List<Node *> *p_to_reown) { -void EditorSubScene::_reown(Node* p_node,List<Node*> *p_to_reown) { - - if (p_node==scene) { + if (p_node == scene) { scene->set_filename(""); p_to_reown->push_back(p_node); - } else if (p_node->get_owner()==scene){ + } else if (p_node->get_owner() == scene) { p_to_reown->push_back(p_node); } - for(int i=0;i<p_node->get_child_count();i++) { - Node *c=p_node->get_child(i); - _reown(c,p_to_reown); + for (int i = 0; i < p_node->get_child_count(); i++) { + Node *c = p_node->get_child(i); + _reown(c, p_to_reown); } } -void EditorSubScene::move(Node* p_new_parent, Node* p_new_owner) { +void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) { if (!scene) { return; @@ -156,27 +140,24 @@ void EditorSubScene::move(Node* p_new_parent, Node* p_new_owner) { return; } - List<Node*> to_reown; - _reown(selnode,&to_reown); + List<Node *> to_reown; + _reown(selnode, &to_reown); - if (selnode!=scene) { + if (selnode != scene) { selnode->get_parent()->remove_child(selnode); } p_new_parent->add_child(selnode); - for (List<Node*>::Element *E=to_reown.front();E;E=E->next()) { + for (List<Node *>::Element *E = to_reown.front(); E; E = E->next()) { E->get()->set_owner(p_new_owner); } - if (selnode!=scene) { + if (selnode != scene) { memdelete(scene); } - scene=NULL; - + scene = NULL; //return selnode; - - } void EditorSubScene::clear() { @@ -187,52 +168,49 @@ void EditorSubScene::clear() { void EditorSubScene::_bind_methods() { - ClassDB::bind_method(D_METHOD("_path_selected"),&EditorSubScene::_path_selected); - ClassDB::bind_method(D_METHOD("_path_changed"),&EditorSubScene::_path_changed); - ClassDB::bind_method(D_METHOD("_path_browse"),&EditorSubScene::_path_browse); - ADD_SIGNAL( MethodInfo("subscene_selected")); - + ClassDB::bind_method(D_METHOD("_path_selected"), &EditorSubScene::_path_selected); + ClassDB::bind_method(D_METHOD("_path_changed"), &EditorSubScene::_path_changed); + ClassDB::bind_method(D_METHOD("_path_browse"), &EditorSubScene::_path_browse); + ADD_SIGNAL(MethodInfo("subscene_selected")); } - EditorSubScene::EditorSubScene() { - scene=NULL; + scene = NULL; set_title(TTR("Select Node(s) to Import")); set_hide_on_ok(false); - VBoxContainer *vb = memnew( VBoxContainer ); + VBoxContainer *vb = memnew(VBoxContainer); add_child(vb); //set_child_rect(vb); - HBoxContainer *hb = memnew( HBoxContainer ); - path = memnew( LineEdit ); - path->connect("text_entered",this,"_path_changed"); + HBoxContainer *hb = memnew(HBoxContainer); + path = memnew(LineEdit); + path->connect("text_entered", this, "_path_changed"); hb->add_child(path); path->set_h_size_flags(SIZE_EXPAND_FILL); - Button *b = memnew( Button ); + Button *b = memnew(Button); b->set_text(" .. "); hb->add_child(b); - b->connect("pressed",this,"_path_browse"); - vb->add_margin_child(TTR("Scene Path:"),hb); + b->connect("pressed", this, "_path_browse"); + vb->add_margin_child(TTR("Scene Path:"), hb); - tree = memnew( Tree ); + tree = memnew(Tree); tree->set_v_size_flags(SIZE_EXPAND_FILL); - vb->add_margin_child(TTR("Import From Node:"),tree,true); - tree->connect("item_activated",this,"_ok",make_binds(),CONNECT_DEFERRED); + vb->add_margin_child(TTR("Import From Node:"), tree, true); + tree->connect("item_activated", this, "_ok", make_binds(), CONNECT_DEFERRED); - file_dialog = memnew( EditorFileDialog ); + file_dialog = memnew(EditorFileDialog); List<String> extensions; - ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions); + ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); - for(List<String>::Element *E = extensions.front();E;E=E->next() ) { + for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file_dialog->add_filter("*."+E->get()); + file_dialog->add_filter("*." + E->get()); } file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); add_child(file_dialog); - file_dialog->connect("file_selected",this,"_path_selected"); - + file_dialog->connect("file_selected", this, "_path_selected"); } |