summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-07-26 10:44:10 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-07-26 10:44:35 -0300
commit07c99e11f5939699fefa10fab0b898ddc9246f85 (patch)
treee78399383955a8574547652336e4bfd8c066f198 /tools
parent18cbcdafbaa047d97d03dcf3cba36f384e242158 (diff)
QOL, script buttons in scene tabs
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/editor_data.cpp17
-rw-r--r--tools/editor/editor_data.h1
-rw-r--r--tools/editor/editor_node.cpp18
-rw-r--r--tools/editor/editor_node.h1
-rw-r--r--tools/editor/project_export.cpp2
5 files changed, 37 insertions, 2 deletions
diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp
index 87983d387c..f729a6c869 100644
--- a/tools/editor/editor_data.cpp
+++ b/tools/editor/editor_data.cpp
@@ -515,6 +515,23 @@ String EditorData::get_scene_type(int p_idx) const {
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 52e86639f9..14a50da082 100644
--- a/tools/editor/editor_data.h
+++ b/tools/editor/editor_data.h
@@ -178,6 +178,7 @@ public:
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 ae2eac29cc..7789008c62 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -109,6 +109,7 @@ 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);
@@ -123,10 +124,16 @@ void EditorNode::_update_scene_tabs() {
}
+
+
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?"(*)":""),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());
@@ -220,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"));
@@ -3583,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);
@@ -4027,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) {
@@ -4181,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");