Browse Source

Show current scene file in FileSystem dock

volzhs 7 years ago
parent
commit
a9acb95ef4
2 changed files with 21 additions and 0 deletions
  1. 19 0
      editor/filesystem_dock.cpp
  2. 2 0
      editor/filesystem_dock.h

+ 19 - 0
editor/filesystem_dock.cpp

@@ -200,6 +200,7 @@ void FileSystemDock::_notification(int p_what) {
 
 
 			button_hist_next->set_icon(get_icon("Forward", ei));
 			button_hist_next->set_icon(get_icon("Forward", ei));
 			button_hist_prev->set_icon(get_icon("Back", ei));
 			button_hist_prev->set_icon(get_icon("Back", ei));
+			button_show->set_icon(get_icon("GuiVisibilityVisible", "EditorIcons"));
 			file_options->connect("id_pressed", this, "_file_option");
 			file_options->connect("id_pressed", this, "_file_option");
 			folder_options->connect("id_pressed", this, "_folder_option");
 			folder_options->connect("id_pressed", this, "_folder_option");
 
 
@@ -317,6 +318,15 @@ void FileSystemDock::_favorites_pressed() {
 	_update_tree(true);
 	_update_tree(true);
 }
 }
 
 
+void FileSystemDock::_show_current_scene_file() {
+
+	int index = EditorNode::get_editor_data().get_edited_scene();
+	String path = EditorNode::get_editor_data().get_scene_path(index);
+	if (path != String()) {
+		navigate_to_path(path);
+	}
+}
+
 String FileSystemDock::get_selected_path() const {
 String FileSystemDock::get_selected_path() const {
 
 
 	TreeItem *sel = tree->get_selected();
 	TreeItem *sel = tree->get_selected();
@@ -1779,6 +1789,7 @@ void FileSystemDock::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("_update_tree"), &FileSystemDock::_update_tree);
 	ClassDB::bind_method(D_METHOD("_update_tree"), &FileSystemDock::_update_tree);
 	ClassDB::bind_method(D_METHOD("_rescan"), &FileSystemDock::_rescan);
 	ClassDB::bind_method(D_METHOD("_rescan"), &FileSystemDock::_rescan);
 	ClassDB::bind_method(D_METHOD("_favorites_pressed"), &FileSystemDock::_favorites_pressed);
 	ClassDB::bind_method(D_METHOD("_favorites_pressed"), &FileSystemDock::_favorites_pressed);
+	ClassDB::bind_method(D_METHOD("_show_current_scene_file"), &FileSystemDock::_show_current_scene_file);
 	//ClassDB::bind_method(D_METHOD("_instance_pressed"),&ScenesDock::_instance_pressed);
 	//ClassDB::bind_method(D_METHOD("_instance_pressed"),&ScenesDock::_instance_pressed);
 	ClassDB::bind_method(D_METHOD("_go_to_file_list"), &FileSystemDock::_go_to_file_list);
 	ClassDB::bind_method(D_METHOD("_go_to_file_list"), &FileSystemDock::_go_to_file_list);
 	ClassDB::bind_method(D_METHOD("_dir_rmb_pressed"), &FileSystemDock::_dir_rmb_pressed);
 	ClassDB::bind_method(D_METHOD("_dir_rmb_pressed"), &FileSystemDock::_dir_rmb_pressed);
@@ -1828,6 +1839,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
 	ED_SHORTCUT("filesystem_dock/rename", TTR("Rename"));
 	ED_SHORTCUT("filesystem_dock/rename", TTR("Rename"));
 
 
 	HBoxContainer *toolbar_hbc = memnew(HBoxContainer);
 	HBoxContainer *toolbar_hbc = memnew(HBoxContainer);
+	toolbar_hbc->add_constant_override("separation", 0);
 	add_child(toolbar_hbc);
 	add_child(toolbar_hbc);
 
 
 	button_hist_prev = memnew(ToolButton);
 	button_hist_prev = memnew(ToolButton);
@@ -1864,6 +1876,13 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
 	button_favorite->set_focus_mode(FOCUS_NONE);
 	button_favorite->set_focus_mode(FOCUS_NONE);
 	toolbar_hbc->add_child(button_favorite);
 	toolbar_hbc->add_child(button_favorite);
 
 
+	button_show = memnew(Button);
+	button_show->set_flat(true);
+	button_show->connect("pressed", this, "_show_current_scene_file");
+	toolbar_hbc->add_child(button_show);
+	button_show->set_focus_mode(FOCUS_NONE);
+	button_show->set_tooltip(TTR("Show current scene file."));
+
 	//Control *spacer = memnew( Control);
 	//Control *spacer = memnew( Control);
 
 
 	/*
 	/*

+ 2 - 0
editor/filesystem_dock.h

@@ -106,6 +106,7 @@ private:
 	Button *button_display_mode;
 	Button *button_display_mode;
 	Button *button_hist_next;
 	Button *button_hist_next;
 	Button *button_hist_prev;
 	Button *button_hist_prev;
+	Button *button_show;
 	LineEdit *current_path;
 	LineEdit *current_path;
 	LineEdit *search_box;
 	LineEdit *search_box;
 	TextureRect *search_icon;
 	TextureRect *search_icon;
@@ -204,6 +205,7 @@ private:
 	void _rescan();
 	void _rescan();
 
 
 	void _favorites_pressed();
 	void _favorites_pressed();
+	void _show_current_scene_file();
 	void _search_changed(const String &p_text);
 	void _search_changed(const String &p_text);
 
 
 	void _dir_rmb_pressed(const Vector2 &p_pos);
 	void _dir_rmb_pressed(const Vector2 &p_pos);