Add copy script path item to script editor

This commit is contained in:
sersoong 2017-12-01 15:24:31 +08:00
parent db262f80be
commit f3bb2d8679
2 changed files with 19 additions and 0 deletions

View File

@ -806,6 +806,12 @@ void ScriptEditor::_close_all_tab(int except) {
}
}
void ScriptEditor::_copy_script_path() {
ScriptTextEditor *ste = tab_container->get_child(tab_container->get_current_tab())->cast_to<ScriptTextEditor>();
Ref<Script> script = ste->get_edited_script();
OS::get_singleton()->set_clipboard(script->get_path());
}
void ScriptEditor::_close_docs_tab() {
int child_count = tab_container->get_child_count();
@ -1560,6 +1566,9 @@ void ScriptEditor::_menu_option(int p_option) {
case FILE_CLOSE_ALL: {
_close_all_tab(-1);
} break;
case FILE_COPY_SCRIPT_PATH: {
_copy_script_path();
} break;
case CLOSE_DOCS: {
_close_docs_tab();
} break;
@ -1611,6 +1620,9 @@ void ScriptEditor::_menu_option(int p_option) {
case FILE_CLOSE_ALL: {
_close_all_tab(-1);
} break;
case FILE_COPY_SCRIPT_PATH: {
_copy_script_path();
} break;
case FILE_CLOSE: {
_close_current_tab();
} break;
@ -1908,6 +1920,8 @@ void ScriptEditor::_script_rmb_selected(int p_idx, const Vector2 &p_pos) {
script_list_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_file"), FILE_CLOSE);
script_list_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_other_tabs"), FILE_CLOSE_OTHERS);
script_list_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_all"), FILE_CLOSE_ALL);
script_list_menu->add_separator();
script_list_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/copy_script_path"), FILE_COPY_SCRIPT_PATH);
}
script_list_menu->set_pos(script_list->get_global_pos() + p_pos);
@ -2651,6 +2665,7 @@ void ScriptEditor::_bind_methods() {
ObjectTypeDB::bind_method("_file_dialog_action", &ScriptEditor::_file_dialog_action);
ObjectTypeDB::bind_method("_tab_changed", &ScriptEditor::_tab_changed);
ObjectTypeDB::bind_method("_menu_option", &ScriptEditor::_menu_option);
ObjectTypeDB::bind_method("_copy_script_path", &ScriptEditor::_copy_script_path);
ObjectTypeDB::bind_method("_close_current_tab", &ScriptEditor::_close_current_tab);
ObjectTypeDB::bind_method("_close_other_tabs", &ScriptEditor::_close_other_tabs);
ObjectTypeDB::bind_method("_close_all_tab", &ScriptEditor::_close_all_tab);
@ -2751,6 +2766,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_theme", TTR("Save Theme")), FILE_SAVE_THEME);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_theme_as", TTR("Save Theme As")), FILE_SAVE_THEME_AS);
file_menu->get_popup()->add_separator();
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy_script_path", TTR("Copy Script Path")), FILE_COPY_SCRIPT_PATH);
file_menu->get_popup()->add_separator();
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_docs", TTR("Close Docs")), CLOSE_DOCS);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_other_tabs", TTR("Close Other Tabs")), FILE_CLOSE_OTHERS);

View File

@ -118,6 +118,7 @@ class ScriptEditor : public VBoxContainer {
FILE_CLOSE,
FILE_CLOSE_OTHERS,
FILE_CLOSE_ALL,
FILE_COPY_SCRIPT_PATH,
CLOSE_DOCS,
EDIT_UNDO,
EDIT_REDO,
@ -245,6 +246,7 @@ class ScriptEditor : public VBoxContainer {
void _close_other_tabs(int idx);
void _close_all_tab(int except);
void _close_docs_tab();
void _copy_script_path();
bool grab_focus_block;