diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/editor_data.cpp | 25 | ||||
-rw-r--r-- | tools/editor/editor_data.h | 2 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 34 | ||||
-rw-r--r-- | tools/editor/editor_node.h | 1 | ||||
-rw-r--r-- | tools/editor/project_export.cpp | 2 |
5 files changed, 61 insertions, 3 deletions
diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index c4808d0cad..f729a6c869 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -507,6 +507,31 @@ uint64_t EditorData::get_scene_version(int p_idx) const{ return edited_scene[p_idx].version; } +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_type(); + +} + +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>(); + Ref<Script> s=edited_scene[p_idx].root->get_script(); + if (!s.is_valid()) { + Node *n = edited_scene[p_idx].root->get_child(0); + while(!s.is_valid() && n && n->get_filename()==String()) { + s=n->get_script(); + n=n->get_parent(); + } + } + return s; +} + String EditorData::get_scene_title(int p_idx) const { ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),String()); if (!edited_scene[p_idx].root) diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h index e3fdd52d01..14a50da082 100644 --- a/tools/editor/editor_data.h +++ b/tools/editor/editor_data.h @@ -177,6 +177,8 @@ public: int get_edited_scene_count() const; String get_scene_title(int p_idx) const; String get_scene_path(int p_idx) const; + String get_scene_type(int p_idx) const; + Ref<Script> get_scene_root_script(int p_idx) const; void set_edited_scene_version(uint64_t version); uint64_t get_edited_scene_version() const; uint64_t get_scene_version(int p_idx) const; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 7b44f2cad9..7789008c62 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -109,10 +109,31 @@ EditorNode *EditorNode::singleton=NULL; void EditorNode::_update_scene_tabs() { scene_tabs->clear_tabs(); + Ref<Texture> script_icon = gui_base->get_icon("Script","EditorIcons"); for(int i=0;i<editor_data.get_edited_scene_count();i++) { + + String type=editor_data.get_scene_type(i); + Ref<Texture> icon; + if (type!=String()) { + + if (!gui_base->has_icon(type,"EditorIcons")) { + type="Node"; + } + + icon=gui_base->get_icon(type,"EditorIcons"); + + } + + + int current = editor_data.get_edited_scene(); bool unsaved = (i==current)?saved_version!=editor_data.get_undo_redo().get_version():editor_data.get_scene_version(i)!=0; - scene_tabs->add_tab(editor_data.get_scene_title(i)+(unsaved?"(*)":"")); + scene_tabs->add_tab(editor_data.get_scene_title(i)+(unsaved?"(*)":""),icon); + + if (editor_data.get_scene_root_script(i).is_valid()) { + scene_tabs->set_tab_right_button(i,script_icon); + } + } scene_tabs->set_current_tab(editor_data.get_edited_scene()); @@ -206,7 +227,7 @@ void EditorNode::_notification(int p_what) { circle_step=0; circle_step_msec=tick; - circle_step_frame=frame+1; + circle_step_frame=frame+1; update_menu->set_icon(gui_base->get_icon("Progress"+itos(circle_step+1),"EditorIcons")); @@ -3569,6 +3590,7 @@ void EditorNode::_bind_methods() { ObjectTypeDB::bind_method("set_current_scene",&EditorNode::set_current_scene); ObjectTypeDB::bind_method("set_current_version",&EditorNode::set_current_version); ObjectTypeDB::bind_method("_scene_tab_changed",&EditorNode::_scene_tab_changed); + ObjectTypeDB::bind_method("_scene_tab_script_edited",&EditorNode::_scene_tab_script_edited); ObjectTypeDB::bind_method("_set_main_scene_state",&EditorNode::_set_main_scene_state); ObjectTypeDB::bind_method("_update_scene_tabs",&EditorNode::_update_scene_tabs); @@ -4013,6 +4035,13 @@ void EditorNode::_load_docks() { } +void EditorNode::_scene_tab_script_edited(int p_tab) { + + Ref<Script> script = editor_data.get_scene_root_script(p_tab); + if (script.is_valid()) + edit_resource(script); +} + void EditorNode::_scene_tab_changed(int p_tab) { @@ -4167,6 +4196,7 @@ EditorNode::EditorNode() { scene_tabs->add_tab("unsaved"); scene_tabs->set_tab_align(Tabs::ALIGN_CENTER); scene_tabs->connect("tab_changed",this,"_scene_tab_changed"); + scene_tabs->connect("right_button_pressed",this,"_scene_tab_script_edited"); top_dark_vb->add_child(scene_tabs); //left left_l_hsplit = memnew( HSplitContainer ); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 293da2031d..495f069b55 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -469,6 +469,7 @@ class EditorNode : public Node { void _dock_split_dragged(int ofs); void _dock_popup_exit(); void _scene_tab_changed(int p_tab); + void _scene_tab_script_edited(int p_tab); Dictionary _get_main_scene_state(); void _set_main_scene_state(Dictionary p_state); diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index e38c672a3e..a087f23c25 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -1131,7 +1131,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { tree->set_column_min_width(1,90); filters = memnew( LineEdit ); - vb->add_margin_child("Filters for Non-Resources (Comma Separated):",filters); + vb->add_margin_child("Filters to export non-resource files (Comma Separated, ie: *.json, *.txt):",filters); filters->connect("text_changed",this,"_filters_edited"); |